Changeset 2132

Show
Ignore:
Timestamp:
04/16/08 08:14:47 (1 month ago)
Author:
karpet
Message:

clarify/rename vars

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/src/libswish3/libswish3.h

    r2130 r2132  
    315315struct swish_Tag 
    316316{ 
    317     xmlChar            *name; 
    318     xmlChar            *metaname; 
     317    xmlChar            *raw;            // tag as libxml2 sees it 
     318    xmlChar            *baked;          // tag as libswish3 sees it 
    319319    xmlChar            *context; 
    320320    struct swish_Tag   *next; 
  • libswish3/trunk/src/libswish3/parser.c

    r2131 r2132  
    7575); 
    7676 
    77 static xmlChar *flatten_tag_stack( 
    78     xmlChar *tag, 
    79     swish_TagStack *stack 
    80 ); 
    81 static void add_stack_to_prop_buf( 
    82     xmlChar *tag, 
    83     swish_ParserData *parser_data 
    84 ); 
    85 static void push_tag_stack( 
    86     swish_TagStack *stack, 
    87     xmlChar *tag, 
    88     xmlChar *metaname 
    89 ); 
    90 static swish_Tag *pop_tag_stack( 
    91     swish_TagStack *stack 
    92 ); 
    93 static swish_Tag *pop_tag_stack_on_match( 
    94     swish_TagStack *stack, 
    95     xmlChar *tag 
    96 ); 
    97 static void free_swishTag( 
    98     swish_Tag * st 
    99 ); 
    100  
    10177static void mystartDocument( 
    10278    void *parser_data 
     
    232208); 
    233209 
     210 
     211/* tag tracker */ 
     212static xmlChar *flatten_tag_stack( 
     213    xmlChar *baked, 
     214    swish_TagStack *stack 
     215); 
     216static void add_stack_to_prop_buf( 
     217    xmlChar *baked, 
     218    swish_ParserData *parser_data 
     219); 
     220static void push_tag_stack( 
     221    swish_TagStack *stack, 
     222    xmlChar *raw, 
     223    xmlChar *baked 
     224); 
     225static swish_Tag *pop_tag_stack( 
     226    swish_TagStack *stack 
     227); 
     228static swish_Tag *pop_tag_stack_on_match( 
     229    swish_TagStack *stack, 
     230    xmlChar *raw 
     231); 
     232static void free_swishTag( 
     233    swish_Tag * st 
     234); 
     235 
     236/*********************************************************************** 
     237 *                end prototypes 
     238 ***********************************************************************/ 
     239  
    234240swish_Parser * 
    235241swish_init_parser( 
     
    501507    if (parser_data->s3->config->flags->context_as_meta) { 
    502508        for (s->temp = s->head; s->temp != NULL; s->temp = s->temp->next) { 
    503             if (xmlStrEqual(s->temp->name, metaname))   // already added 
     509            if (xmlStrEqual(s->temp->baked, metaname))   // already added 
    504510                continue; 
    505511 
    506             swish_add_buf_to_nb(parser_data->metanames, s->temp->name
     512            swish_add_buf_to_nb(parser_data->metanames, s->temp->baked
    507513                                parser_data->meta_buf, (xmlChar *)SWISH_META_CONNECTOR, 0, 
    508514                                1); 
     
    691697            SWISH_DEBUG_MSG(" %s = new metaname", parser_data->tag); 
    692698 
    693         flush_buffer(parser_data, parser_data->metastack->head->name
     699        flush_buffer(parser_data, parser_data->metastack->head->baked
    694700                     parser_data->metastack->head->context); 
    695701 
     
    727733    if ((st = pop_tag_stack_on_match(parser_data->propstack, (xmlChar *)tag)) != NULL) { 
    728734 
    729         add_stack_to_prop_buf(parser_data->tag, parser_data); 
     735        add_stack_to_prop_buf(st->baked, parser_data); 
    730736        xmlBufferEmpty(parser_data->prop_buf); 
    731737        free_swishTag(st); 
     
    734740    if ((st = pop_tag_stack_on_match(parser_data->metastack, (xmlChar *)tag)) != NULL) { 
    735741 
    736         flush_buffer(parser_data, st->metaname, st->context); 
     742        flush_buffer(parser_data, st->baked, st->context); 
    737743        free_swishTag(st); 
    738744    } 
     
    11001106        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    11011107            SWISH_DEBUG_MSG("%s %d POP %s [%s] [%s]", ptr->metastack->name, 
    1102                             ptr->metastack->count, st->name, st->metaname, st->context); 
     1108                            ptr->metastack->count, st->raw, st->baked, st->context); 
    11031109 
    11041110        free_swishTag(st); 
     
    11131119        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    11141120            SWISH_DEBUG_MSG("%s %d POP %s [%s] [%s]", ptr->propstack->name, 
    1115                             ptr->propstack->count, st->name, st->metaname, st->context); 
     1121                            ptr->propstack->count, st->raw, st->baked, st->context); 
    11161122 
    11171123        free_swishTag(st); 
     
    20272033 
    20282034    if (metaname == NULL) 
    2029         metaname = parser_data->metastack->head->name
     2035        metaname = parser_data->metastack->head->baked
    20302036 
    20312037    if (context == NULL) 
     
    21152121    for (stack->temp = stack->head; stack->temp != NULL; stack->temp = stack->temp->next) { 
    21162122        SWISH_DEBUG_MSG("  %d: count %d  tagstack: %s", i++, stack->temp->n, 
    2117                         stack->temp->name); 
     2123                        stack->temp->raw); 
    21182124 
    21192125    } 
     
    21332139static xmlChar * 
    21342140flatten_tag_stack( 
    2135     xmlChar *tag
     2141    xmlChar *baked
    21362142    swish_TagStack *stack 
    21372143) 
     
    21452151    stack->temp = stack->head; 
    21462152 
    2147     if (tag != NULL) { 
    2148         flat = swish_xstrdup(tag); 
     2153    if (baked != NULL) { 
     2154        flat = swish_xstrdup(baked); 
    21492155    } 
    21502156    else { 
    2151         flat = swish_xstrdup(stack->head->name); 
     2157        flat = swish_xstrdup(stack->head->baked); 
    21522158        stack->temp = stack->temp->next; 
    21532159    } 
    21542160 
    21552161    for (; stack->temp != NULL; stack->temp = stack->temp->next) { 
    2156         size = ((xmlStrlen(flat) + (xmlStrlen(stack->temp->name)) * sizeof(xmlChar))) + 2; 
     2162        size = ((xmlStrlen(flat) + (xmlStrlen(stack->temp->baked)) * sizeof(xmlChar))) + 2; 
    21572163        tmp = swish_xmalloc(size); 
    2158         if (snprintf((char *)tmp, size, "%s %s", (char *)flat, (char *)stack->temp->name) > 0) { 
     2164        if (snprintf((char *)tmp, size, "%s %s", (char *)flat, (char *)stack->temp->baked) > 0) { 
    21592165            if (flat != NULL) 
    21602166                swish_xfree(flat); 
     
    21632169        } 
    21642170        else { 
    2165             SWISH_CROAK("sprintf failed to concat %s -> %s", stack->temp->name, flat); 
     2171            SWISH_CROAK("sprintf failed to concat %s -> %s", stack->temp->baked, flat); 
    21662172        } 
    21672173 
     
    21732179static void 
    21742180add_stack_to_prop_buf( 
    2175     xmlChar *tag
     2181    xmlChar *baked
    21762182    swish_ParserData *parser_data 
    21772183) 
     
    21852191     
    21862192    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2187         SWISH_DEBUG_MSG("adding property %s to buffer", tag); 
    2188     } 
    2189  
    2190     if (tag != NULL) { 
    2191         prop = swish_hash_fetch(parser_data->s3->config->properties, tag); 
     2193        SWISH_DEBUG_MSG("adding property %s to buffer", baked); 
     2194    } 
     2195 
     2196    if (baked != NULL) { 
     2197        prop = swish_hash_fetch(parser_data->s3->config->properties, baked); 
    21922198 
    21932199        /* 
     
    21972203            cleanwsp = 0; 
    21982204 
    2199         swish_add_buf_to_nb(parser_data->properties, tag, parser_data->prop_buf, 
     2205        swish_add_buf_to_nb(parser_data->properties, baked, parser_data->prop_buf, 
    22002206                            (xmlChar *)SWISH_PROP_CONNECTOR, cleanwsp, 0); 
    22012207 
     
    22052211    // TODO configurable?? 
    22062212    for (stack->temp = stack->head; stack->temp != NULL; stack->temp = stack->temp->next) { 
    2207         if (xmlStrEqual(stack->temp->name, (xmlChar *)"_")) 
     2213        if (xmlStrEqual(stack->temp->baked, (xmlChar *)"_")) 
    22082214            continue; 
    22092215 
    2210         swish_add_buf_to_nb(parser_data->properties, stack->temp->name, parser_data->prop_buf, 
     2216        swish_add_buf_to_nb(parser_data->properties, stack->temp->baked, parser_data->prop_buf, 
    22112217                            (xmlChar *)SWISH_PROP_CONNECTOR, cleanwsp, 0); 
    22122218    } 
     
    22202226{ 
    22212227    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2222         SWISH_DEBUG_MSG(" freeing swishTag: %s %s %s", st->name, st->metaname, st->context); 
     2228        SWISH_DEBUG_MSG(" freeing swishTag: %s %s %s", st->raw, st->baked, st->context); 
    22232229    } 
    22242230     
    2225     swish_xfree(st->name); 
    2226     swish_xfree(st->metaname); 
     2231    swish_xfree(st->raw); 
     2232    swish_xfree(st->baked); 
    22272233    swish_xfree(st->context); 
    22282234    swish_xfree(st); 
     
    22322238push_tag_stack( 
    22332239    swish_TagStack *stack, 
    2234     xmlChar *tag
    2235     xmlChar *metaname 
     2240    xmlChar *raw
     2241    xmlChar *baked 
    22362242) 
    22372243{ 
     
    22402246 
    22412247    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2242         SWISH_DEBUG_MSG("%s PUSH: tag = '%s'", stack->name, tag); 
     2248        SWISH_DEBUG_MSG("%s PUSH: tag = '%s'", stack->name, raw); 
    22432249        _debug_stack(stack); 
    22442250    } 
    22452251 
    22462252    //assign this tag to the struct  
    2247     thistag->name = swish_xstrdup(tag); 
    2248  
    2249     // the metaname (the normalized tag) 
    2250     thistag->metaname = swish_xstrdup(metaname); 
     2253    thistag->raw = swish_xstrdup(raw); 
     2254 
     2255    // the normalized tag 
     2256    thistag->baked = swish_xstrdup(baked); 
    22512257 
    22522258    //increment counter  
     
    22802286 
    22812287    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2282         SWISH_DEBUG_MSG("%s POP: %s", stack->name, stack->head->name); 
     2288        SWISH_DEBUG_MSG("%s POP: %s", stack->name, stack->head->raw); 
    22832289        _debug_stack(stack); 
    22842290 
     
    22882294        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    22892295            SWISH_DEBUG_MSG("%s %d: popping '%s'", stack->name, stack->head->n, 
    2290                             stack->head->name); 
     2296                            stack->head->raw); 
    22912297 
    22922298        } 
     
    23032309        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    23042310            SWISH_DEBUG_MSG("%s %d: popping '%s' will leave stack empty [%s]", 
    2305                             stack->name, stack->head->n, stack->head->name
     2311                            stack->name, stack->head->n, stack->head->raw
    23062312                            stack->head->context); 
    23072313 
     
    23372343 
    23382344    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2339         SWISH_DEBUG_MSG("%s: POP if %s matches %s", stack->name, tag, stack->head->name); 
     2345        SWISH_DEBUG_MSG("%s: POP if %s matches %s", stack->name, tag, stack->head->raw); 
    23402346        _debug_stack(stack); 
    23412347    } 
    23422348 
    2343     if (xmlStrEqual(stack->head->name, tag)) { 
     2349    if (xmlStrEqual(stack->head->raw, tag)) { 
    23442350 
    23452351        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
     
    23542360 
    23552361            if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2356                 SWISH_DEBUG_MSG("%s POPPED.  tag = %s  st->name = %s", stack->name, 
    2357                                 tag, st->name); 
     2362                SWISH_DEBUG_MSG("%s POPPED.  tag = %s  st->raw = %s", stack->name, 
     2363                                tag, st->raw); 
    23582364                 
    23592365                _debug_stack(stack); 
     
    23672373        else if (stack->count) { 
    23682374            if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    2369                 SWISH_DEBUG_MSG("%s head %s", stack->name, stack->head->name); 
     2375                SWISH_DEBUG_MSG("%s head %s", stack->name, stack->head->raw); 
    23702376 
    23712377        } 
     
    23842390    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    23852391        if (st != NULL) 
    2386             SWISH_DEBUG_MSG("POP on match returning: %s", st->name); 
     2392            SWISH_DEBUG_MSG("POP on match returning: %s", st->raw); 
    23872393        else 
    23882394            SWISH_DEBUG_MSG("POP on match returning null");