summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1994-07-25 23:01:19 +0000
committerRoland McGrath <roland@redhat.com>1994-07-25 23:01:19 +0000
commit21a1b3b2557f4d224cd18093e8ab2b2197725f27 (patch)
tree641f459b9688555251e66c7442a65983735ad82e
parentc8e76a708e4e4d8bf513146be424abdf2ce0e015 (diff)
downloadgunmake-21a1b3b2557f4d224cd18093e8ab2b2197725f27.tar.gz
[__MSDOS__] (dosify): New function.
(dir_contents_file_exists_p) [__MSDOS__]: Call it on FILENAME and process the result instead of FILENAME itself. (file_impossible_p) [__MSDOS__]: Likewise. Part of MSDOS/GO32 port from DJ Delorie <dj@ctron.com>.
-rw-r--r--dir.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index d280d2a..07752d3 100644
--- a/dir.c
+++ b/dir.c
@@ -47,6 +47,49 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
#endif /* POSIX */
+#ifdef __MSDOS__
+#inlcude <ctype.h>
+
+static char *
+dosify (filename)
+ char *filename;
+{
+ static char dos_filename[14];
+ char *df;
+ int i;
+
+ if (filename == 0)
+ return 0;
+
+ if (strpbrk (filename, "\"*+,;<=>?[\\]|") != 0)
+ return filename;
+
+ df = dos_filename;
+
+ /* First, transform the name part. */
+ for (i = 0; *filename != '\0' && i < 8 && *filename != '.'; ++i)
+ *df++ = tolower (*filename++);
+
+ /* Now skip to the next dot. */
+ while (*filename != '\0' && *filename != '.')
+ ++filename;
+ if (*filename != '\0')
+ {
+ *df++ = *filename++;
+ for (i = 0; *filename != '\0' && i < 3 && *filename != '.'; ++i)
+ *df++ = tolower (*filename++);
+ }
+
+ /* Look for more dots. */
+ while (*filename != '\0' && *filename != '.')
+ ++filename;
+ if (*filename == '.')
+ return filename;
+ *df = 0;
+ return dos_filename;
+}
+#endif
+
/* Hash table of directories. */
#ifndef DIRECTORY_BUCKETS
@@ -213,6 +256,10 @@ dir_contents_file_exists_p (dir, filename)
/* The directory could not be stat'd or opened. */
return 0;
+#ifdef __MSDOS__
+ filename = dosify (filename);
+#endif
+
hash = 0;
if (filename != 0)
{
@@ -404,6 +451,10 @@ file_impossible_p (filename)
/* There are no files entered for this directory. */
return 0;
+#ifdef __MSDOS__
+ p = filename = dosify (p);
+#endif
+
for (hash = 0; *p != '\0'; ++p)
HASH (hash, *p);
hash %= DIRFILE_BUCKETS;