]> git.mxchange.org Git - flightgear.git/commitdiff
more small fixes
authorehofman <ehofman>
Thu, 7 May 2009 12:23:30 +0000 (12:23 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 18 May 2009 10:24:16 +0000 (12:24 +0200)
utils/xmlgrep/sample.xml
utils/xmlgrep/testxml.c
utils/xmlgrep/xml.c

index 8510890207a8e35f9c683ef104067992cda6463f..7fec2d03eaa034e0c06cb09d3a29c398d9aab8c7 100644 (file)
@@ -13,7 +13,7 @@
   <test n="2"/>
 
   <menu><name>* Traffic, # taxiing to runway (.</name></menu>
-  <menu><name>* Traffic, # holding short runway (.</name></menu>
+  <sample><test>       * Traffic, # taxiing to runway (.    </test></sample>
 
   <!--
     - x is positive to the right
index 318002ba92dc9024424db8c14596b56c84097303..dd22d457ed8ae436df9dd43ea239ae6fc4a9a659 100644 (file)
@@ -110,6 +110,38 @@ int main()
 
          free(node_id);
          free(path_id);
+
+         path_id = xmlNodeGet(root_id, "Configuration/output/sample/test");
+         if (path_id)
+         {
+            xmlNodeCopyString(root_id ,"Configuration/output/menu/name", buf, BUFLEN);
+            printf("Testing xmlCompareString against a fixed string: \t\t\t");
+            if (xmlCompareString(path_id, buf))        /* no match */
+               printf("failed.\n\t'%s' differs\n", buf);
+            else
+               printf("succes.\n");
+
+            s = xmlGetString(path_id);
+            if (s)
+            {
+               printf("Testing xmlGetString  against a fixed string: \t\t\t\t");
+               if (strcmp(s, buf))                     /* mismatch */
+                  printf("failed.\n\t'%s' differs from\n\t'%s'\n", s, buf);
+               else
+                  printf("succes.\n");
+
+               printf("Testing xmlCopyString gainst a fixed string: \t\t\t\t");
+               xmlCopyString(path_id, buf, BUFLEN);
+               if (strcmp(s, buf))                     /* mismatch */
+                  printf("failed.\n\t'%s' differs from\n\t'%s'\n", s, buf);
+               else
+                  printf("succes.\n"); 
+
+               free(s);
+            }
+
+            free(path_id);
+         }
       }
       else
       {
index f319dbfc25f1769c50667345dc635a7bc1729b8c..9ee3ff6ac03ad5b45a583d8af4245560c6f769b9 100644 (file)
@@ -465,11 +465,12 @@ xmlGetString(const void *id)
         char *ps;
 
         ps = xid->start;
-        len = xid->len;
+        len = xid->len-1;
         __xmlPrepareData(&ps, &len);
 
         if (len)
         {
+            len++;
             str = malloc(len+1);
             if (str)
             {
@@ -503,10 +504,11 @@ xmlCopyString(const void *id, char *buffer, size_t buflen)
         char *p;
 
         p = xid->start;
-        len = xid->len;
+        len = xid->len-1;
         __xmlPrepareData(&p, &len);
         if (len)
         {
+            len++;
             if (len >= buflen)
             {
                 len = buflen-1;
@@ -538,7 +540,7 @@ xmlCompareString(const void *id, const char *s)
         ps = xid->start;
         len = xid->len-1;
         __xmlPrepareData(&ps, &len);
-        ret = strncasecmp(ps, s, len);
+        ret = strncasecmp(ps, s, len+1);
     }
 
     return ret;
@@ -1638,7 +1640,7 @@ __xmlProcessCDATA(char **start, size_t *len)
             {
                 if ((restlen > 3) && (memcmp(new, "]]>", 3) == 0))
                 {
-                    *len = new-*start;
+                    *len = new - *start;
                     restlen -= 3;
                     new += 3;
                     break;
@@ -1717,7 +1719,8 @@ __xmlInfoProcess(const char *start, size_t len)
 }
 
 
-static void __xmlPrepareData(char **start, size_t *blocklen)
+static void
+__xmlPrepareData(char **start, size_t *blocklen)
 {
     size_t len = *blocklen;
     char *pe, *ps = *start;