Changeset 2128

Show
Ignore:
Timestamp:
04/15/08 10:04:58 (1 month ago)
Author:
karpet
Message:

attributes for namespace-aware libxml2 were utterly broken. now the only thing broken is XMLClassAttributes

Files:

Legend:

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

    r2116 r2128  
    1818 */ 
    1919 
    20 #define TEST_SAX 0 
    21  
    2220/*  
    2321 * parse XML doc from memory using libxml2 SAX2 based on tutorial at 
     
    159157    void *data, 
    160158    const xmlChar *tag, 
    161     const xmlChar **atts 
     159    xmlChar **atts 
    162160); 
    163161static void close_tag( 
     
    231229); 
    232230 
    233 #if   TEST_SAX 
    234 #include "testsax.c" 
    235 #endif 
    236  
    237231swish_Parser * 
    238232swish_init_parser( 
     
    255249     */ 
    256250    get_env_vars(); 
    257      
     251 
    258252    if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { 
    259253        SWISH_DEBUG_MSG("parser ptr 0x%x", (int)p); 
     
    291285) 
    292286{ 
    293     int i, is_html_tag; 
    294     xmlChar *swishtag, *alias, *metaname, *metacontent; 
     287    int i, j, is_html_tag, size; 
     288    xmlChar *swishtag, *attr_lower, *attr_val_lower, *alias, *metaname, *metacontent; 
     289    swish_StringList *strlist; 
     290 
     291    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
     292        SWISH_DEBUG_MSG(" tag: %s (%s) ", tag, parser_data->tag); 
     293        if (atts != NULL) { 
     294            SWISH_DEBUG_MSG(" has attributes [%d]", xmlStrlen((xmlChar*)atts)); 
     295            for (i = 0; (atts[i] != NULL); i+=2) { 
     296                SWISH_DEBUG_MSG(" att: %s=", atts[i]); 
     297                if (atts[i+1] != NULL) { 
     298                    SWISH_DEBUG_MSG(" '%s'", atts[i+1]); 
     299                } 
     300            } 
     301        } 
     302    } 
    295303 
    296304    metaname = NULL; 
     
    307315    if (parser_data->is_html) { 
    308316 
     317        /* 
     318           TODO config features about img tags and a/href tags  
     319         */ 
    309320        if (xmlStrEqual(swishtag, (xmlChar *)"br") 
    310321            || xmlStrEqual(swishtag, (xmlChar *)"img")) { 
     
    360371        if (metaname != NULL && metacontent != NULL) { 
    361372            if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    362                 SWISH_DEBUG_MSG("found HTML meta: %s => %s", metaname, 
    363                                 metacontent); 
     373                SWISH_DEBUG_MSG("found HTML meta: %s => %s", metaname, metacontent); 
    364374 
    365375            /* 
     
    387397        parser_data->bump_word = 1; 
    388398 
    389     } 
    390  
    391     if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    392         fprintf(stderr, " >>> build_tag (%s (%s) ", tag, parser_data->tag); 
    393         if (atts != 0) { 
    394             for (i = 0; (atts[i] != 0); i++) { 
    395                 fprintf(stderr, ", %s='", atts[i++]); 
    396                 if (atts[i] != 0) { 
    397                     fprintf(stderr, "%s'", atts[i]); 
     399        if (atts != NULL 
     400            && swish_hash_exists(parser_data->s3->config->stringlists, 
     401                                 (xmlChar *)SWISH_CLASS_ATTRIBUTES)) { 
     402            strlist = 
     403                swish_hash_fetch(parser_data->s3->config->stringlists, 
     404                                 (xmlChar *)SWISH_CLASS_ATTRIBUTES); 
     405                                  
     406             
     407                                  
     408            for (i = 0; (atts[i] != NULL); i += 2) { 
     409 
     410                if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     411                    SWISH_DEBUG_MSG(" %d XML attr: %s=%s [%d]", i, atts[i], atts[i + 1], 
     412                                    xmlStrlen(atts[i + 1])); 
     413 
     414                attr_lower = swish_str_tolower(atts[i]); 
     415                attr_val_lower = swish_str_tolower(atts[i + 1]); 
     416 
     417                /* 
     418                   is it one of ours?  
     419                 */ 
     420                for (j = 0; j < strlist->n; j++) { 
     421                    if (xmlStrEqual(strlist->word[j], attr_lower)) { 
     422                        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     423                            SWISH_DEBUG_MSG("found %s: %s", attr_lower, attr_val_lower); 
     424 
     425                        // eligible attribute name 
     426                        size = xmlStrlen(swishtag) + xmlStrlen(attr_val_lower) + 2;     // dot + NULL 
     427                        metaname = swish_xmalloc(size + 1); 
     428                        snprintf((char *)metaname, size, "%s.%s", (char *)swishtag, 
     429                                 (char *)attr_val_lower); 
     430 
     431                        swish_xfree(swishtag); 
     432                        swishtag = metaname; 
     433                    } 
    398434                } 
     435 
     436                swish_xfree(attr_lower); 
     437                swish_xfree(attr_val_lower); 
     438 
    399439            } 
    400440        } 
    401         fprintf(stderr, ")\n"); 
     441 
    402442    } 
    403443 
     
    415455    } 
    416456 
     457    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
     458        SWISH_DEBUG_MSG(" swishtag = %s", swishtag); 
     459    } 
     460 
    417461    return swishtag; 
    418  
    419462} 
    420463 
     
    430473    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    431474        SWISH_DEBUG_MSG("buffer is >>%s<< before flush, word_pos = %d", 
    432                         xmlBufferContent(parser_data->meta_buf), 
    433                         parser_data->word_pos); 
    434  
    435     /* 
    436      * since we only flush the buffer when metaname changes, and * we do 
    437      * not want to match across metanames, bump the word_pos here * before  
     475                        xmlBufferContent(parser_data->meta_buf), parser_data->word_pos); 
     476 
     477    /* 
     478     * since we only flush the buffer when metaname changes, and we do 
     479     * not want to match across metanames, bump the word_pos here before  
    438480     * parsing the string and making the tmp wordlist  
    439481     */ 
     
    449491                        (xmlChar *)SWISH_META_CONNECTOR, 0, 1); 
    450492 
    451     if (parser_data->context_as_meta) { 
     493    /* 
     494     *  add to every metaname on the stack. 
     495     *  Disabling this for now, as it ought to be up the handler() to decide 
     496     *  to index a token under multiple metanames, and we associate context 
     497     *  with the WordList 
     498     */ 
     499 
     500    if (parser_data->s3->config->flags->context_as_meta) { 
    452501        for (s->temp = s->head; s->temp != NULL; s->temp = s->temp->next) { 
    453             if (xmlStrEqual(s->temp->name, metaname))   /* just added * above */ 
     502            if (xmlStrEqual(s->temp->name, metaname))   // already added 
    454503                continue; 
    455504 
    456505            swish_add_buf_to_nb(parser_data->metanames, s->temp->name, 
    457                                 parser_data->meta_buf, 
    458                                 (xmlChar *)SWISH_META_CONNECTOR, 0, 1); 
     506                                parser_data->meta_buf, (xmlChar *)SWISH_META_CONNECTOR, 0, 
     507                                1); 
    459508        } 
    460509    } 
    461510 
    462511    if (parser_data->s3->analyzer->tokenize) { 
    463  
    464         tokenize(parser_data, 
    465                  (xmlChar *)xmlBufferContent(parser_data->meta_buf), 
     512        tokenize(parser_data, (xmlChar *)xmlBufferContent(parser_data->meta_buf), 
    466513                 xmlBufferLength(parser_data->meta_buf), metaname, context); 
    467514    } 
     
    519566) 
    520567{ 
    521     open_tag(data, name, atts); 
     568    open_tag(data, name, (xmlChar **)atts); 
    522569} 
    523570 
     
    550597) 
    551598{ 
    552     open_tag(data, localname, attributes); 
     599    int i, j, len; 
     600    xmlChar **atts; 
     601    atts = NULL; 
     602 
     603    if (nb_attributes > 0) { 
     604        atts = swish_xmalloc(((nb_attributes * 2) + 1) * sizeof(xmlChar *)); 
     605        j=0; 
     606        for (i = 0; i < nb_attributes * 5; i += 5) { 
     607            atts[j] = (xmlChar *)attributes[i]; 
     608            len = (int)(attributes[i + 4] - attributes[i + 3]); 
     609            if (len > 0) { 
     610                atts[j+1] = xmlStrsub(attributes[i + 3], 0, len); 
     611            } 
     612            else { 
     613                atts[j] = NULL; 
     614            } 
     615            j+=2; 
     616        } 
     617        atts[j] = NULL; 
     618    } 
     619     
     620    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
     621        SWISH_DEBUG_MSG(" tag: %s nb_attributes %d", localname, nb_attributes); 
     622        if (atts != NULL) { 
     623            for (i = 0; (atts[i] != NULL); i+=2) { 
     624                SWISH_DEBUG_MSG(" att: %s=%s", atts[i], atts[i + 1]); 
     625                //SWISH_DEBUG_MSG(" att: %s=", atts[i++], atts[i] || ""); 
     626            } 
     627        } 
     628    } 
     629 
     630    open_tag(data, localname, atts); 
     631 
     632    if (atts != NULL) { 
     633        swish_xfree(atts); 
     634    } 
    553635} 
    554636 
     
    571653    void *data, 
    572654    const xmlChar *tag, 
    573     const xmlChar **atts 
    574 
    575 
    576     swish_ParserData *parser_data = (swish_ParserData *)data; 
     655    xmlChar **atts 
     656
     657
     658    swish_ParserData *parser_data; 
     659    parser_data = (swish_ParserData *)data; 
    577660 
    578661    if (parser_data->tag != NULL) 
     
    582665 
    583666    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    584         SWISH_DEBUG_MSG("checking config for '%s' in watched tags", 
    585                         parser_data->tag); 
     667        SWISH_DEBUG_MSG("checking config for '%s' in watched tags", parser_data->tag); 
    586668 
    587669    /* 
    588670     * set property if this tag is configured for it  
    589671     */ 
    590     if (swish_hash_exists 
    591         (parser_data->s3->config->properties, parser_data->tag)) { 
     672    if (swish_hash_exists(parser_data->s3->config->properties, parser_data->tag)) { 
    592673        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    593674            SWISH_DEBUG_MSG(" %s = new property", parser_data->tag); 
     
    596677        xmlBufferEmpty(parser_data->prop_buf); 
    597678 
    598         parser_data->propstack = 
    599             push_tag_stack(parser_data->propstack, parser_data->tag); 
     679        parser_data->propstack = push_tag_stack(parser_data->propstack, parser_data->tag); 
    600680 
    601681        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
     
    613693                     parser_data->metastack->flat); 
    614694 
    615         parser_data->metastack = 
    616             push_tag_stack(parser_data->metastack, parser_data->tag); 
     695        parser_data->metastack = push_tag_stack(parser_data->metastack, parser_data->tag); 
    617696    } 
    618697 
     
    643722 
    644723    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    645         SWISH_DEBUG_MSG(" endElement(%s) (%s)", (xmlChar *)tag, 
    646                         parser_data->tag); 
     724        SWISH_DEBUG_MSG(" endElement(%s) (%s)", (xmlChar *)tag, parser_data->tag); 
    647725 
    648726    if ((context = 
    649          pop_tag_stack_on_match(parser_data->propstack, 
    650                                 parser_data->tag)) != NULL) { 
     727         pop_tag_stack_on_match(parser_data->propstack, parser_data->tag)) != NULL) { 
    651728 
    652729        /* 
     
    659736 
    660737    if ((context = 
    661          pop_tag_stack_on_match(parser_data->metastack, 
    662                                 parser_data->tag)) != NULL) { 
     738         pop_tag_stack_on_match(parser_data->metastack, parser_data->tag)) != NULL) { 
    663739 
    664740        /* 
     
    885961 
    886962    if (!size && !xmlStrlen(buffer) && !parser_data->docinfo->size) { 
    887         SWISH_WARN("%s appears to be empty -- can't parse it", 
    888                    parser_data->docinfo->uri); 
     963        SWISH_WARN("%s appears to be empty -- can't parse it", parser_data->docinfo->uri); 
    889964 
    890965        return 1; 
     
    892967 
    893968    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    894         SWISH_DEBUG_MSG("%s -- using %s parser", parser_data->docinfo->uri, 
    895                         parser); 
     969        SWISH_DEBUG_MSG("%s -- using %s parser", parser_data->docinfo->uri, parser); 
    896970 
    897971    /* 
     
    899973     */ 
    900974    if (filename && !buffer) { 
    901         buffer = 
    902             swish_slurp_file_len(filename, (long)parser_data->docinfo->size); 
     975        buffer = swish_slurp_file_len(filename, (long)parser_data->docinfo->size); 
    903976        size = parser_data->docinfo->size; 
    904977    } 
     
    910983 
    911984    else if (parser[0] == 'X') 
    912 #if TEST_SAX 
    913         ret = 
    914             xmlSAXUserParseMemory(debugSAX2Handler, NULL, (const char *)buffer, 
    915                                   size); 
    916 #else 
    917985        ret = xml_parser(my_parser_ptr, parser_data, buffer, size); 
    918 #endif 
    919986 
    920987    else if (parser[0] == 'T') 
     
    9451012        SWISH_DEBUG_MSG("init parser_data"); 
    9461013 
    947     swish_ParserData *ptr = 
    948         (swish_ParserData *)swish_xmalloc(sizeof(swish_ParserData)); 
     1014    swish_ParserData *ptr = (swish_ParserData *)swish_xmalloc(sizeof(swish_ParserData)); 
    9491015 
    9501016    ptr->s3 = s3; 
     
    9711037    ptr->metastack->flat = NULL; 
    9721038    ptr->metastack->count = 0; 
    973     ptr->metastack = 
    974         push_tag_stack(ptr->metastack, (xmlChar *)SWISH_DEFAULT_METANAME); 
     1039    ptr->metastack = push_tag_stack(ptr->metastack, (xmlChar *)SWISH_DEFAULT_METANAME); 
    9751040 
    9761041    ptr->propstack = (swish_TagStack *)swish_xmalloc(sizeof(swish_TagStack)); 
     
    10121077 
    10131078    /* 
    1014      * TODO make this configurable  
    1015      */ 
    1016     ptr->context_as_meta = 1; 
    1017  
    1018     /* 
    10191079     * pointer to the xmlParserCtxt since we want to free it only after 
    10201080     * we're completely done with it. NOTE this is a change per libxml2 
     
    11121172    else { 
    11131173        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    1114             SWISH_DEBUG_MSG 
    1115                 ("swish_ParserData libxml2 parser ctxt already freed"); 
     1174            SWISH_DEBUG_MSG("swish_ParserData libxml2 parser ctxt already freed"); 
    11161175 
    11171176    } 
     
    12671326 
    12681327            if (!val) 
    1269                 SWISH_WARN("Failed to parse Content-Location header '%s'", 
     1328                SWISH_WARN("Failed to parse Content-Location header '%s'", line); 
     1329 
     1330            if (!*val) 
     1331                SWISH_WARN("Failed to find path name in Content-Location header '%s'", 
    12701332                           line); 
    1271  
    1272             if (!*val) 
    1273                 SWISH_WARN 
    1274                     ("Failed to find path name in Content-Location header '%s'", 
    1275                      line); 
    12761333 
    12771334            if (info->uri != NULL) 
     
    12891346 
    12901347            if (!*val) 
    1291                 SWISH_WARN("Failed to find path name in Path-Name header '%s'", 
    1292                            line); 
     1348                SWISH_WARN("Failed to find path name in Path-Name header '%s'", line); 
    12931349 
    12941350            if (info->uri != NULL) 
     
    13061362 
    13071363            if (!*val) 
    1308                 SWISH_WARN 
    1309                     ("Failed to find path name in Document-Type header '%s'", 
    1310                      line); 
     1364                SWISH_WARN("Failed to find path name in Document-Type header '%s'", line); 
    13111365 
    13121366            if (info->parser != NULL) 
     
    13221376 
    13231377            if (!*val) 
    1324                 SWISH_WARN 
    1325                     ("Failed to find path name in Parser-Type header '%s'", 
    1326                      line); 
     1378                SWISH_WARN("Failed to find path name in Parser-Type header '%s'", line); 
    13271379 
    13281380            if (info->parser != NULL) 
     
    13381390 
    13391391            if (!*val) 
    1340                 SWISH_WARN 
    1341                     ("Failed to find path name in Content-Type header '%s'", 
    1342                      line); 
     1392                SWISH_WARN("Failed to find path name in Content-Type header '%s'", line); 
    13431393 
    13441394            /* 
     
    13571407 
    13581408            if (!val) 
    1359                 SWISH_WARN("Failed to parse Encoding or Charset header '%s'", 
     1409                SWISH_WARN("Failed to parse Encoding or Charset header '%s'", line); 
     1410 
     1411            if (!*val) 
     1412                SWISH_WARN("Failed to find value in Encoding or Charset header '%s'", 
    13601413                           line); 
    1361  
    1362             if (!*val) 
    1363                 SWISH_WARN 
    1364                     ("Failed to find value in Encoding or Charset header '%s'", 
    1365                      line); 
    13661414 
    13671415            if (info->encoding != NULL) 
     
    13821430 
    13831431            if (!*val) 
    1384                 SWISH_WARN("Failed to find value in Update-Mode header '%s'", 
    1385                            line); 
     1432                SWISH_WARN("Failed to find value in Update-Mode header '%s'", line); 
    13861433 
    13871434            if (info->update != NULL) 
     
    14171464 
    14181465    setenv("SWISH_PARSER_ERROR", "0", 0); 
    1419     SWISH_PARSER_ERROR = 
    1420         (int)strtol(getenv("SWISH_PARSER_ERROR"), (char **)NULL, 10); 
     1466    SWISH_PARSER_ERROR = (int)strtol(getenv("SWISH_PARSER_ERROR"), (char **)NULL, 10); 
    14211467 
    14221468    setenv("SWISH_PARSER_WARNING", "0", 0); 
    1423     SWISH_PARSER_WARNING = 
    1424         (int)strtol(getenv("SWISH_PARSER_WARNING"), (char **)NULL, 10); 
     1469    SWISH_PARSER_WARNING = (int)strtol(getenv("SWISH_PARSER_WARNING"), (char **)NULL, 10); 
    14251470 
    14261471    setenv("SWISH_PARSER_FATAL", "0", 0); 
    1427     SWISH_PARSER_FATAL = 
    1428         (int)strtol(getenv("SWISH_PARSER_FATAL"), (char **)NULL, 10); 
     1472    SWISH_PARSER_FATAL = (int)strtol(getenv("SWISH_PARSER_FATAL"), (char **)NULL, 10); 
    14291473 
    14301474    if (SWISH_DEBUG) { 
     
    14661510    ln = swish_xmalloc(SWISH_MAXSTRLEN + 1); 
    14671511    head_buf = 
    1468         xmlBufferCreateSize((SWISH_MAX_HEADERS * SWISH_MAXSTRLEN) + 
    1469                             SWISH_MAX_HEADERS); 
     1512        xmlBufferCreateSize((SWISH_MAX_HEADERS * SWISH_MAXSTRLEN) + SWISH_MAX_HEADERS); 
    14701513 
    14711514    /* 
     
    15161559             */ 
    15171560            xmlErr = 
    1518                 docparser(parser_data, NULL, read_buffer, 
    1519                           parser_data->docinfo->size); 
     1561                docparser(parser_data, NULL, read_buffer, parser_data->docinfo->size); 
    15201562 
    15211563            if (xmlErr) 
     
    17021744    parser_data->docinfo->ref_cnt++; 
    17031745 
    1704     if (!swish_docinfo_from_filesystem 
    1705         (filename, parser_data->docinfo, parser_data)) { 
     1746    if (!swish_docinfo_from_filesystem(filename, parser_data->docinfo, parser_data)) { 
    17061747        SWISH_WARN("Skipping %s", filename); 
    17071748        free_parser_data(parser_data); 
     
    18791920 
    18801921    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    1881         SWISH_DEBUG_MSG("txt parser encoding: %s", 
    1882                         parser_data->docinfo->encoding); 
     1922        SWISH_DEBUG_MSG("txt parser encoding: %s", parser_data->docinfo->encoding); 
    18831923 
    18841924    if (parser_data->docinfo->encoding != (xmlChar *)SWISH_DEFAULT_ENCODING) { 
    1885         if (!xmlStrncasecmp 
    1886             (parser_data->docinfo->encoding, (xmlChar *)"iso-8859-1", 10)) { 
     1925        if (!xmlStrncasecmp(parser_data->docinfo->encoding, (xmlChar *)"iso-8859-1", 10)) { 
    18871926            out = swish_xmalloc(size * 2); 
    18881927 
     
    18951934        } 
    18961935 
    1897         else if (xmlStrEqual 
    1898                  (parser_data->docinfo->encoding, (xmlChar *)"unknown")) { 
     1936        else if (xmlStrEqual(parser_data->docinfo->encoding, (xmlChar *)"unknown")) { 
    18991937            if (SWISH_DEBUG & SWISH_DEBUG_PARSER) 
    19001938                SWISH_DEBUG_MSG("default env encoding -> %s", enc); 
     
    19611999 
    19622000    if (xmlCheckUTF8((const xmlChar *)buffer) != 0) 
    1963         parser_data->docinfo->encoding = 
    1964             swish_xstrdup((xmlChar *)SWISH_DEFAULT_ENCODING); 
     2001        parser_data->docinfo->encoding = swish_xstrdup((xmlChar *)SWISH_DEFAULT_ENCODING); 
    19652002    else 
    19662003        parser_data->docinfo->encoding = swish_xstrdup((xmlChar *)"unknown"); 
     
    20232060 
    20242061        tmplist = 
    2025             swish_tokenize(parser_data->s3->analyzer, string, 
    2026                            parser_data->offset, parser_data->word_pos, metaname, 
    2027                            context); 
     2062            swish_tokenize(parser_data->s3->analyzer, string, parser_data->offset, 
     2063                           parser_data->word_pos, metaname, context); 
    20282064 
    20292065    } 
     
    20352071 
    20362072        tmplist = 
    2037             (*parser_data->s3->analyzer->tokenizer) (parser_data->s3->analyzer, 
    2038                                                      string, 
     2073            (*parser_data->s3->analyzer->tokenizer) (parser_data->s3->analyzer, string, 
    20392074                                                     parser_data->offset, 
    2040                                                      parser_data->word_pos, 
    2041                                                      metaname, context); 
     2075                                                     parser_data->word_pos, metaname, 
     2076                                                     context); 
    20422077 
    20432078    } 
     
    20952130    int i = 0; 
    20962131 
    2097     SWISH_DEBUG_MSG("%s '%s' stack->count: %d", stack->name, stack->flat, 
    2098                     stack->count); 
    2099  
    2100     for (stack->temp = stack->head; stack->temp != NULL; 
    2101          stack->temp = stack->temp->next) { 
     2132    SWISH_DEBUG_MSG("%s '%s' stack->count: %d", stack->name, stack->flat, stack->count); 
     2133 
     2134    for (stack->temp = stack->head; stack->temp != NULL; stack->temp = stack->temp->next) { 
    21022135        SWISH_DEBUG_MSG("  %d: count %d  tagstack: %s", i++, stack->temp->n, 
    21032136                        stack->temp->name); 
     
    21062139 
    21072140    if (i != stack->count) { 
    2108         SWISH_WARN("stack count appears wrong (%d items, but count=%d)", i, 
    2109                    stack->count); 
     2141        SWISH_WARN("stack count appears wrong (%d items, but count=%d)", i, stack->count); 
    21102142 
    21112143    } 
     
    21412173 
    21422174    for (; stack->temp != NULL; stack->temp = stack->temp->next) { 
    2143         size = 
    2144             ((xmlStrlen(flat) + 
    2145               (xmlStrlen(stack->temp->name)) * sizeof(xmlChar))) + 2; 
     2175        size = ((xmlStrlen(flat) + (xmlStrlen(stack->temp->name)) * sizeof(xmlChar))) + 2; 
    21462176        tmp = swish_xmalloc(size); 
    2147         if (sprintf 
    2148             ((char *)tmp, "%s %s", (char *)flat, 
    2149              (char *)stack->temp->name) > 0) { 
     2177        if (sprintf((char *)tmp, "%s %s", (char *)flat, (char *)stack->temp->name) > 0) { 
    21502178            if (flat != NULL) 
    21512179                swish_xfree(flat); 
     
    21542182        } 
    21552183        else { 
    2156             SWISH_CROAK("sprintf failed to concat %s -> %s", stack->temp->name, 
    2157                         flat); 
     2184            SWISH_CROAK("sprintf failed to concat %s -> %s", stack->temp->name, flat); 
    21582185        } 
    21592186 
     
    22022229            continue; 
    22032230 
    2204         swish_add_buf_to_nb(parser_data->properties, s->temp->name, 
    2205                             parser_data->prop_buf, 
     2231        swish_add_buf_to_nb(parser_data->properties, s->temp->name, parser_data->prop_buf, 
    22062232                            (xmlChar *)SWISH_PROP_CONNECTOR, cleanwsp, 0); 
    22072233    } 
     
    22492275 
    22502276    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2251         SWISH_DEBUG_MSG 
    2252             (" >>> stack size: %d  thistag count: %d  current head tag = '%s'", 
    2253              stack->count, thistag->n, stack->head->name); 
     2277        SWISH_DEBUG_MSG(" >>> stack size: %d  thistag count: %d  current head tag = '%s'", 
     2278                        stack->count, thistag->n, stack->head->name); 
    22542279 
    22552280        _debug_stack(stack); 
     
    22672292 
    22682293    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2269         SWISH_DEBUG_MSG(" pop_tag_stack: %s from %s", stack->head->name, 
    2270                         stack->name); 
     2294        SWISH_DEBUG_MSG(" pop_tag_stack: %s from %s", stack->head->name, stack->name); 
    22712295        _debug_stack(stack); 
    22722296 
     
    22752299    if (stack->count > 1) { 
    22762300        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2277             SWISH_DEBUG_MSG("  >>>  %d: popping '%s' from tagstack <<<", 
    2278                             stack->head->n, stack->head->name); 
     2301            SWISH_DEBUG_MSG("  >>>  %d: popping '%s' from tagstack <<<", stack->head->n, 
     2302                            stack->head->name); 
    22792303 
    22802304        } 
     
    23242348 
    23252349    if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2326         SWISH_DEBUG_MSG("  >> stack size = %d   head of stack = %s <<", 
    2327                         stack->count, stack->head->name); 
     2350        SWISH_DEBUG_MSG("  >> stack size = %d   head of stack = %s <<", stack->count, 
     2351                        stack->head->name); 
    23282352        _debug_stack(stack); 
    23292353    } 
     
    23582382        if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    23592383            SWISH_DEBUG_MSG 
    2360                 (" >>>>>>>>>>>>>>>>>>>  current tag = '%s' matches top of tagstack", 
    2361                  tag); 
     2384                (" >>>>>>>>>>>>>>>>>>>  current tag = '%s' matches top of tagstack", tag); 
    23622385 
    23632386        } 
     
    23692392 
    23702393            if (SWISH_DEBUG & SWISH_DEBUG_PARSER) { 
    2371                 SWISH_DEBUG_MSG("stack popped. tag = %s   stack->head = %s", 
    2372                                 tag, stack->head->name); 
     2394                SWISH_DEBUG_MSG("stack popped. tag = %s   stack->head = %s", tag, 
     2395                                stack->head->name); 
    23732396                _debug_stack(stack); 
    23742397            }