[xml] Still problems with xmllint on win32 & fixes



Hi,

I'M sorry but I've still problems with xmllint on win32. SGML_CATALOG_FILES / xmlLoadCatalogs() can't handle win32 filenames

I've attached a patch which solves the problem. I know it's not commitable as I just changed it that 'it is working' because I don't know the internals of libxml

Can you please take a look on this and add a proper fix to libxml2?

Thx,
Christian Ehrlicher
Index: catalog.c
===================================================================
--- catalog.c   (revision 3576)
+++ catalog.c   (working copy)
@@ -44,6 +44,12 @@
 #define MAX_DELEGATE   50
 #define MAX_CATAL_DEPTH        50
 
+#ifdef _WIN32
+# define PATH_SEAPARATOR ';'
+#else
+# define PATH_SEAPARATOR ':'
+#endif
+
 /**
  * TODO:
  *
@@ -3209,6 +3215,9 @@
     const char *cur;
     const char *paths;
     xmlChar *path;
+#ifdef _WIN32
+    int i, iLen;
+#endif
 
     if (pathss == NULL)
        return;
@@ -3218,15 +3227,21 @@
        while (xmlIsBlank_ch(*cur)) cur++;
        if (*cur != 0) {
            paths = cur;
-           while ((*cur != 0) && (*cur != ':') && (!xmlIsBlank_ch(*cur)))
+           while ((*cur != 0) && (*cur != PATH_SEAPARATOR) && (!xmlIsBlank_ch(*cur)))
                cur++;
            path = xmlStrndup((const xmlChar *)paths, cur - paths);
-           if (path != NULL) {
+#ifdef _WIN32
+            iLen = strlen(path);
+            for(i = 0; i < iLen; i++)
+                if(path[i] == '\\')
+                    path[i] = '/';
+#endif
+            if (path != NULL) {
                xmlLoadCatalog((const char *) path);
                xmlFree(path);
            }
        }
-       while (*cur == ':')
+       while (*cur == PATH_SEAPARATOR)
            cur++;
     }
 }
Index: uri.c
===================================================================
--- uri.c       (revision 3576)
+++ uri.c       (working copy)
@@ -435,6 +435,9 @@
                if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
                     ((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) ||
                    ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||
+#ifdef WIN32
+                    ((*(p) == ':')) ||
+#endif
                    ((*(p) == ',')))
                    ret[len++] = *p++;
                else {
@@ -1156,6 +1159,18 @@
     cur = *str;
     if (!IS_ALPHA(*cur))
        return(2);
+#ifdef _WIN32
+    // check for windows path
+    if (cur[1] == ':') {
+        int ret;
+        if (uri->scheme != NULL)
+            xmlFree(uri->scheme);
+        uri->scheme = STRNDUP("file", 4);
+        ret = xmlParseURIPathSegments(uri, &cur, 1);
+        *str = cur;
+        return ret;
+    }
+#endif
     cur++;
     while (IS_SCHEME(*cur)) cur++;
     if (uri != NULL) {
@@ -1656,6 +1671,8 @@
 
     ret = xmlParseURIScheme(uri, str);
     if (ret != 0) return(ret);
+    if (uri->path && *uri->path)
+        return ret;
     if (**str != ':') {
        *str = cur;
        return(1);
Index: xmllint.c
===================================================================
--- xmllint.c   (revision 3576)
+++ xmllint.c   (working copy)
@@ -209,6 +209,11 @@
  *                                                                     *
  ************************************************************************/
 #define MAX_PATHS 64
+#ifdef _WIN32
+# define PATH_SEPARATOR ';'
+#else
+# define PATH_SEPARATOR ':'
+#endif
 static xmlChar *paths[MAX_PATHS + 1];
 static int nbpaths = 0;
 static int load_trace = 0;
@@ -225,10 +230,10 @@
            return;
        }
        cur = path;
-       while ((*cur == ' ') || (*cur == ':'))
+       while ((*cur == ' ') || (*cur == PATH_SEPARATOR))
            cur++;
        path = cur;
-       while ((*cur != 0) && (*cur != ' ') && (*cur != ':'))
+       while ((*cur != 0) && (*cur != ' ') && (*cur != PATH_SEPARATOR))
            cur++;
        if (cur != path) {
            paths[nbpaths] = xmlStrndup(path, cur - path);

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]