Fix for 687151, gswin32 starts with 7s delay while searching bad ENCODING pathname
Alex Cherepanov <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
Convert filenameforall template string back to the path name discarding
literary status of \*? because it is not supported by the OS.
This shoud fix the reported problem but a general solution need much
more efforts, including:
(1) Use of platform-independent path names in the template. I.e.
consider '/' as a path separator on any platform and map it
accordingly.
(2) Support of '?' and '*' wildcards on the platforms which don't
support them natively.
(3) Support of literary '\\', '?' and '*' on the platforms which don't
support them natively.
(4) Recursive enumeration of the directory.
_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
gp_ntfs.c.diff
(text/plain, 1.8 KB)
Index: gs/src/gp_ntfs.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gp_ntfs.c,v
retrieving revision 1.21
diff -b -u -r1.21 gp_ntfs.c
--- gs/src/gp_ntfs.c 21 Oct 2003 11:54:04 -0000 1.21
+++ gs/src/gp_ntfs.c 3 Dec 2003 12:23:35 -0000
@@ -99,7 +99,7 @@
file_enum_enum_ptrs, file_enum_reloc_ptrs, pattern);
/* Initialize an enumeration. Note that * and ? in a directory */
-/* don't work, and \ is taken literally unless a second \ follows. */
+/* don't work. Literary *?\ are not supported by the OS. */
file_enum *
gp_enumerate_files_init(const char *pat, uint patlen, gs_memory_t * mem)
{
@@ -107,7 +107,7 @@
int pat_size = 2 * patlen + 1;
char *pattern;
int hsize = 0;
- int i;
+ int i,j;
if (pfen == 0)
return 0;
@@ -119,22 +119,23 @@
"gp_enumerate_files(pattern)");
if (pattern == 0)
return 0;
- memcpy(pattern, pat, patlen);
- /* find directory name = header */
- for (i = 0; i < patlen; i++) {
- switch (pat[i]) {
- case '\\':
- if (i + 1 < patlen && pat[i + 1] == '\\')
+
+ /* decode the template into path name, discarding literary status of *? */
+ for (i = 0, j=0; i < patlen; i++) {
+ if(pat[i] == '\\' && i+1 < patlen &&
+ (pat[i+1] == '?' || pat[i+1] == '*' || pat[i+1] == '\\' ))
i++;
- /* falls through */
- case ':':
- case '/':
- hsize = i + 1;
+ pattern[j++]=pat[i];
}
+
+ for (i = 0; i < j; i++) {
+ if(pattern[i] == '/' || pattern[i] == '\\' || pattern[i] == ':')
+ hsize = i+1;
}
- pattern[patlen] = 0;
+
+ pattern[j] = 0;
pfen->pattern = pattern;
- pfen->patlen = patlen;
+ pfen->patlen = j;
pfen->pat_size = pat_size;
pfen->head_size = hsize;
pfen->memory = mem;