]> git.mxchange.org Git - flightgear.git/blobdiff - utils/xmlgrep/xmlgrep.c
Merge branch 'ehofman/version'
[flightgear.git] / utils / xmlgrep / xmlgrep.c
index 3ec17fbcb02d1c2d46d6cb7c3696dbc7aaa3fab3..23577b0c8d2415a25343817e413c1dcd33836cf1 100644 (file)
@@ -5,12 +5,13 @@
 #include <string.h>
 #ifndef _MSC_VER
 # include <strings.h>
+# include <unistd.h>   /* read */
 #else
 # define strncasecmp strnicmp
 # include <stdlib.h>
+# include <io.h>
 #endif
 #include <assert.h>
-#include <unistd.h>    /* read */
 #include <sys/stat.h>  /* fstat */
 #include <fcntl.h>     /* open */
 
@@ -212,17 +213,23 @@ void walk_the_tree(size_t num, void *xid, char *tree)
             {
                 if (xmlNodeGetPos(xid, xmid, _print, i) != 0)
                 {
-                    char value[STRING_LEN];
+                    char *value;
 
-                    xmlCopyString(xmid, (char *)&value, STRING_LEN);
-                    if (_value && _attribute)
+                    value = xmlGetString(xmid);
+                    if (_value && _attribute && value)
                     {
+#if 1
+                       char *a = xmlAttributeGetString(xmid, _attribute);
+                       if (a && !strcmp(a, _value))
+#else
                        if (!xmlAttributeCompareString(xmid, _attribute, _value))
+#endif
                        {
                           printf("%s: <%s %s=\"%s\">%s</%s>\n",
                                  _filenames[num], _print, _attribute, _value,
                                                   value, _print);
                        }
+                       if (value) free(value);
                     }
                     else
                     {