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.5 by greg, Sat Feb 25 01:15:02 2012 UTC vs.
Revision 2.8 by greg, Thu Apr 2 16:40:32 2015 UTC

# Line 74 | Line 74 | ezxml_t ezxml_child(ezxml_t xml, const char *name)
74      return xml;
75   }
76  
77 + /* returns the given tag's character content or empty string if none */
78 + char *ezxml_txt(ezxml_t xml)
79 + {
80 +        if (xml == NULL)
81 +                return "";
82 +        return xml->txt;
83 + }
84 +
85   /* returns the Nth tag with the same name in the same subsection or NULL if not */
86   /* found */
87   ezxml_t ezxml_idx(ezxml_t xml, int idx)
# Line 374 | Line 382 | short ezxml_internal_dtd(ezxml_root_t root, char *s, s
382              if (*(s = t + strcspn(t, EZXML_WS ">")) == '>') continue;
383              else *s = '\0'; /* null terminate tag name */
384              for (i = 0; root->attr[i] && strcmp(n, root->attr[i][0]); i++);
385 <
386 <            while (*(n = ++s + strspn(s, EZXML_WS)) && *n != '>') {
385 >            ++s;
386 >            while (*(n = s + strspn(s, EZXML_WS)) && *n != '>') {
387                  if (*(s = n + strcspn(n, EZXML_WS))) *s = '\0'; /* attr name */
388                  else { ezxml_err(root, t, "malformed <!ATTLIST"); break; }
389  
# Line 416 | Line 424 | short ezxml_internal_dtd(ezxml_root_t root, char *s, s
424                  root->attr[i][j + 1] = (v) ? ezxml_decode(v, root->ent, *c)
425                                             : NULL;
426                  root->attr[i][j] = n; /* attribute name  */
427 +                ++s;
428              }
429          }
430          else if (! strncmp(s, "<!--", 4)) s = strstr(s + 4, "-->"); /* comments */
# Line 921 | Line 930 | ezxml_t ezxml_add_child(ezxml_t xml, const char *name,
930   ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt)
931   {
932      if (! xml) return NULL;
933 +    if (txt == xml->txt) return xml;
934      if (xml->flags & EZXML_TXTM) free(xml->txt); /* existing txt was malloced */
935      xml->flags &= ~EZXML_TXTM;
936      xml->txt = (char *)txt;
937      return xml;
938 + }
939 +
940 + /* add text to the current character content, allocating memory as needed (GW) */
941 + ezxml_t ezxml_add_txt(ezxml_t xml, const char *txt)
942 + {
943 +        int     len;
944 +        if (! xml) return NULL;
945 +        if (!*txt) return xml;
946 +        len = strlen(xml->txt) + strlen(txt) + 1;
947 +        if (xml->flags & EZXML_TXTM) {
948 +                xml->txt = (char *)realloc(xml->txt, len);
949 +        } else {
950 +                xml->txt = strcpy((char *)malloc(len), xml->txt);
951 +                xml->flags |= EZXML_TXTM;
952 +        }
953 +        strcat(xml->txt, txt);
954 +        return xml;
955   }
956  
957   /* 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