From b35c157126a37a6ddac8aff524a3837017fdcd38 Mon Sep 17 00:00:00 2001 From: Kyle Maxwell Date: Tue, 24 Feb 2009 19:44:22 -0800 Subject: [PATCH] fixed empty array bug --- dexter.c | 63 +++++++------- test/emptyish.dex | 3 + test/emptyish.html | 207 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 241 insertions(+), 32 deletions(-) create mode 100644 test/emptyish.dex create mode 100644 test/emptyish.html diff --git a/dexter.c b/dexter.c index 4dc49d6..38e4dce 100644 --- a/dexter.c +++ b/dexter.c @@ -323,40 +323,39 @@ void __dex_recurse(contextPtr context) { // printf("f\n"); sprintbuf(c->buf, "\n", c->name); dex_parsing_context = c; - tmp = myparse(astrdup(inner_key_of(c->json))); - if(tmp == NULL) { - - } - sprintbuf(c->buf, "\n", filter_intersection(context->magic, tmp)); + char * str = inner_key_of(c->json); + if(str != NULL) { + tmp = myparse(astrdup(str)); + sprintbuf(c->buf, "\n", filter_intersection(context->magic, tmp)); + // keys + keys = dex_alloc(sizeof(key_node)); + keys->name = c->name; + keys->use = full_expr(c, tmp); + keys->next = c->keys; + c->keys = keys; + + buf = printbuf_new(); + + sprintbuf(buf, "concat("); + while(keys != NULL){ + sprintbuf(buf, "count(set:intersection(following::*, %s)), '-',", keys->use); + keys = keys->next; + } + sprintbuf(buf, "'')"); + tmp = astrdup(buf->buf); + printbuf_free(buf); + + sprintbuf(c->key_buf, "\n", c->name, + full_expr(c, "./descendant-or-self::*"), + tmp + ); - // keys - keys = dex_alloc(sizeof(key_node)); - keys->name = c->name; - keys->use = full_expr(c, tmp); - keys->next = c->keys; - c->keys = keys; - - buf = printbuf_new(); - - sprintbuf(buf, "concat("); - while(keys != NULL){ - sprintbuf(buf, "count(set:intersection(following::*, %s)), '-',", keys->use); - keys = keys->next; - } - sprintbuf(buf, "'')"); - tmp = astrdup(buf->buf); - printbuf_free(buf); - - sprintbuf(c->key_buf, "\n", c->name, - full_expr(c, "./descendant-or-self::*"), - tmp - ); - - sprintbuf(c->buf, "\n", c->name, tmp); - sprintbuf(c->buf, "\n", c->name); - __dex_recurse(c); - sprintbuf(c->buf, "\n"); + sprintbuf(c->buf, "\n", c->name, tmp); + sprintbuf(c->buf, "\n", c->name); + __dex_recurse(c); + sprintbuf(c->buf, "\n"); + } } } else { diff --git a/test/emptyish.dex b/test/emptyish.dex new file mode 100644 index 0000000..4c854a4 --- /dev/null +++ b/test/emptyish.dex @@ -0,0 +1,3 @@ +{ + "foo": [{}] +} \ No newline at end of file diff --git a/test/emptyish.html b/test/emptyish.html new file mode 100644 index 0000000..23142fd --- /dev/null +++ b/test/emptyish.html @@ -0,0 +1,207 @@ + + +austin activity partners classifieds - craigslist + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
search for: in: + + + + +
+ +
+ + + + + +
[ Thu, 15 Jan 19:13:19 ] [ PERSONAL SAFETY TIPS ] [ AVOIDING SCAMS & FRAUD ] [success story?]
+ +

Thu Jan 15

+

Female Running Partner - (Shoal Creek or Town Lake)

+

TENNIS ANYONE? - (i35 & US71)

+

Home Workers Needed - (Anywhere, USA)

+

Do you follow Eat to Live by Dr. Joel Fuhrman? - (North Central Austin)

+

photographer buddy - (Austin/central/south/s/w) pic

+

GET IN THE BEST SHAPE OF YOUR LIFE!!! - (NW Austin) pic

+

I CAN HELP ATHLETES GET FASTER & MORE EXPLOSIVE, $28 to $35 a session -

+

Sing your heart out in the NATIONAL KARAOKE LEAGUE! - (2 Austin Divisions) pic

+

FITNESS TRAINING for $20 - (austin/round rock)

+

Looking for a great workout? - (Austin and Surrounding Areas)

+

JOIN: The Give Me A Dollar Club - (The Universe and Beyond)

+

Do You Want To Be The Biggest Loser In Austin ? -

+

Seeking Tennis Hitting Partner - (NW Austin/CP High School)

+

want to play rugby? - (West Austin area) pic

+

Tongiht DateandDash Speed-Dating Party For College Grads - (Halcyon Cafe) pic

+

4TH ANNUAL HOT CHOCOLATE AND COOKIES RIDE!!! - ( Round Rock Harley Davidson)

+

Traveling The World By Backpack Need Someone To Manage business - (Austin)

+

Massage/facial room for rent in Round Rock - (Round Rock, Tx)

+

Wed Jan 14

+

Gentle Yoga for Beginners (From $ 30/10 Classes....) - (Five Austin Locations)

+

Pflugerville Fitness Boot Camps - (Pfluger Park) pic

+

Round Rock Mommy Group Seeking New Members - (Round Rock)

+

Men's Over 30 Soccer Team looking for players - (Austin)

+

tennis players for fun times - (taylor/ hutto/granger)

+

Co-ed Soccer Players - (Austin)

+

BADMINTON TONIGHT! adult, both women and men - (austin rec center, 1301 shoal creek) pic

+

YOUTH FLAG FOOTBALL - (ROUND ROCK TX)

+

Workout!!! I'll help you quit making excuses!!! $26 - $50 -

+

S exercise - (Atx) pic

+

Dance Classes for Bigger Bodies - (Central Austin)

+

Dance partner wanted - (Austin)

+

Arabic Tutor - (Austin)

+

Tue Jan 13

+

Any norwegian speakers, anyone from Norway in Austin? - (Downtown)

+

Tennis, Biking, Badminton, Jogging, Hiking, Dancing, etc. - (Southwest Austin)

+

Tennis in NW Austin? - (Lake Creek and 183)

+

Looking for Workout partner at Gold's Gym - (SW Austin) pic

+

VOICE LESSONS -

+

Meet New People in the NATIONAL KARAOKE LEAGUE! Register Today!!! - (2 Austin Divisions) pic

+

Women's Rugby in Austin - (Burnett Middle School) pic

+

Hate the Gym ? Hate Boot camps? Join Us -

+

Interested in playing rugby? Looking to start a team in west austin - (West - dripping springs, lakeway, areas)

+

ANY QLINK XF200 SUPERMOTO OWNERS OUT THERE - (CENTRAL TEXAS) pic

+

Join Family and Friends to Lose Weight in 09!!!! - (Austin)

+

Mon Jan 12

+

H.E.A.T. Boot Camp - (DT, Round Rock, Pflugerville) pic

+

FREE !!!! Salsa Dance Classes for Beginners -

+

Austin Metro Baseball League - (Austin, Texas)

+

Hot or Not Survey: Rate Photos of Single Men and Women -

+

Early Morning or Evening Classes Available! Free Boot Camp! Bring a Fr - (Austin and Surrounding Areas)

+

Fitness Training Studios-Round Rock - (round rock/austin)

+

Baseball Players wanted 18+ - (Austin)

+

meet cool people now - (austin)

+

Want to go camping in Coloardo? -

+

Male Looking for Female Massage Partner -

+

Looking for roleplayers who like Exalted or Mage - (North Austin)

+

Doctor Who Fan Club - (North Austin)

+

Gauging Interest in group cooking class - (Wilson appliance? SW)

+

Chinese Circus Pole Classes For Everyday People - (Various) pic

+

Kickball Social League - (Austin)

+

Looking for a running partner - (S/S.W Austin)

+

Over 30 Soccer Team - (Austin)

+

Smart Drunks Need Apply - (Austin) img

+

men's freestyle wrestling? -

+

Sun Jan 11

+

French tutor - (Austin tx (North))

+

SOFTBALL SCRIMMAGES NEEDED - (SOUTH /NORTH)

+

Austin, TX area golfers -

+

Sand Volleyball - (SW Austin)

+

flag football - (Manor TEXAS)

+

Looking for synchronized swimmers... - (Austin)

+

Seeking female dance partner for tonight - (Continental Club)

+

Looking for Baseball Players for 2009 Season - (Austin, TX)

+

National Karaoke League REGISTERING NOW for Austin Spring 09 Season! - (2 Austin Divisions) pic

+

Chess - (Austin)

+

SOFTBALL PLAYERS NEEDED FOR SOFTBALL AUSTIN "C" DIVISION - (Krieg Fields )

+

Sat Jan 10

+

Play Darts at a local Pub - (Austin)

+

Audio Producer -

+

Charitable organization looking for Venue to sell kettle corn - (Austin)

+

Sports Conditioning -

+

FREE!!!!!! Salsa Dance Classes for Beginners -

+

Looking for Volleyball Players - (Cedar Park, Leander, RR & Austin)

+

Beginner Yoga for Wellness ($ 65/10 Classes) - (Dittmar Rec. Center in South Austin)

+

Take Control of Your Life and Weight, Join Now -

+

January Writers Contest -

+

Whats going on this Saturday? - (south austin) pic

+

Fri Jan 09

+

Part Time Hours - img

+

Swing Practice Partner (50+) - (Austin)

+

Free Massage Exchange -

+

MATURE ACTORS - (Austin )

+

RE: Weight loss buddy wanted is SPAMMMMM -

+

Thu Jan 08

+

Legal NLTHE Home Game - (Austin (North))

+

Martial Arts New Years Special, FREE WEEK! - (beecave,lakeway)

+

Yoga buddy wanted - (Round Rock/Austin)

+

Looking for a Trainer in Austin, near downtown - (Austin - downtown) pic

+

Running at (or near) dusk (or "magic hour") - (UT)

+

Looking for a Golf Buddy -- Male or Female - (UT)

+

Any Cat 5's RRers out there looking for someone to train with? - (Lamar & 2222)

+

Bridge Players 40+ - (Austin)

+

Looking to start a fitness program but not sure boot camp is for you? - (Austin and Surrounding Areas)

+

Wed Jan 07

+

KARATE/TAE KWON DO FAMILY ACTIVITY CENTER. SAVE MONEY/NO CONTRACTS - (CEDAR PARK, LEANDER, ROUND ROCK)

+

FREE !!!!!!!! Salsa Dance Classes for Beginners -

+

BADMINTON TONIGHT, OPEN PLAY! at austin rec center - (1301 shoal creek blvd) pic

+

Looking for Graphic Artist/ Comic Artist to Collaborate With - (Central)

+ + +

next 100 postings + +

+

+ +
 
+ +
+ + +