ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/ezxml.c
(Generate patch)

Comparing ray/src/common/ezxml.c (file contents):
Revision 2.6 by greg, Sun Oct 26 17:35:53 2014 UTC vs.
Revision 2.7 by greg, Sat Feb 14 00:34:43 2015 UTC

# Line 922 | Line 922 | ezxml_t ezxml_add_child(ezxml_t xml, const char *name,
922   ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt)
923   {
924      if (! xml) return NULL;
925 +    if (txt == xml->txt) return xml;
926      if (xml->flags & EZXML_TXTM) free(xml->txt); /* existing txt was malloced */
927      xml->flags &= ~EZXML_TXTM;
928      xml->txt = (char *)txt;
929      return xml;
930 + }
931 +
932 + /* add text to the current character content, allocating memory as needed (GW) */
933 + ezxml_t ezxml_add_txt(ezxml_t xml, const char *txt)
934 + {
935 +        int     len;
936 +        if (! xml) return NULL;
937 +        if (!*txt) return xml;
938 +        len = strlen(xml->txt) + strlen(txt) + 1;
939 +        if (xml->flags & EZXML_TXTM) {
940 +                xml->txt = (char *)realloc(xml->txt, len);
941 +        } else {
942 +                xml->txt = strcpy((char *)malloc(len), xml->txt);
943 +                xml->flags |= EZXML_TXTM;
944 +        }
945 +        strcat(xml->txt, txt);
946 +        return xml;
947   }
948  
949   /* Sets the given tag attribute or adds a new attribute if not found. A value */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines