[Expat-checkins] expat/xmlwf xmlwf.c,1.72,1.73

Karl Waclawek kwaclaw at users.sourceforge.net
Mon Apr 30 02:50:24 CEST 2007


Update of /cvsroot/expat/expat/xmlwf
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv8987

Modified Files:
	xmlwf.c 
Log Message:
No more search for (back)slashes in the string "STDIN".
Optimized code with regards to use of path delimters on different platforms.

Index: xmlwf.c
===================================================================
RCS file: /cvsroot/expat/expat/xmlwf/xmlwf.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- xmlwf.c	5 Aug 2006 17:00:36 -0000	1.72
+++ xmlwf.c	30 Apr 2007 00:50:22 -0000	1.73
@@ -777,17 +777,28 @@
       XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction);
     }
     else if (outputDir) {
+      const XML_Char * delim = T("/");
       const XML_Char *file = useStdin ? T("STDIN") : argv[i];
-      if (tcsrchr(file, T('/')))
-        file = tcsrchr(file, T('/')) + 1;
+      if (!useStdin) {
+        /* Jump after last (back)slash */
+        const XML_Char * lastDelim = tcsrchr(file, delim[0]);
+        if (lastDelim)
+          file = lastDelim + 1;
 #if (defined(WIN32) || defined(__WATCOMC__))
-      if (tcsrchr(file, T('\\')))
-        file = tcsrchr(file, T('\\')) + 1;
+        else {
+          const XML_Char * winDelim = T("\\");
+          lastDelim = tcsrchr(file, winDelim[0]);
+          if (lastDelim) {
+            file = lastDelim + 1;
+            delim = winDelim;
+          }
+        }
 #endif
+      }
       outName = (XML_Char *)malloc((tcslen(outputDir) + tcslen(file) + 2)
                        * sizeof(XML_Char));
       tcscpy(outName, outputDir);
-      tcscat(outName, T("/"));
+      tcscat(outName, delim);
       tcscat(outName, file);
       fp = tfopen(outName, T("wb"));
       if (!fp) {



More information about the Expat-checkins mailing list