2 ** DosFCheck - check file names for DOS consistency
4 ** Distribute freely, it only encourages DOS compatibility!
8 /* This file is not part of GCC. */
33 /****************************************************************\
35 \****************************************************************/
46 printf ("The following files are not valid DOS file names:\n");
54 ENT *rv = (ENT *)malloc (sizeof (ENT));
57 fprintf (stderr, "Unable to allocate memory for an ENT\n");
60 memset (rv, 0, sizeof (ENT));
70 char *null = path+strlen (path);
71 char *last_slash = strrchr (path, '/');
73 int dots_seen, chars_seen;
75 if (last_slash+1 == null)
78 last_slash = strrchr (path, '/');
86 if (null-last_slash < 13)
87 ent->dos_name = (char *)malloc (null-last_slash);
89 ent->dos_name = (char *)malloc (13);
90 ent->full_name = (char *)malloc (null-last_slash);
91 ent->path = (char *)malloc (last_slash-first+1);
93 strcpy (ent->full_name, last_slash+1);
94 if (last_slash > first)
96 strncpy (ent->path, first, last_slash-first);
97 ent->path[last_slash-first] = '\0';
113 if (cp == last_slash+1 && strcmp (last_slash+1, "."))
116 printf ("%s - file name cannot start with dot\n", path);
123 printf ("%s - too many dots\n", path);
145 printf ("%s - invalid character `%c'\n", path, *cp);
158 if ((*cp <= ' ') || (*cp >= 0x7f))
161 printf ("%s - invalid character `%c'\n", path, *cp);
167 *dp++ = toupper (*cp);
179 compare_ent_dosname (e1, e2)
183 int r = strcmp ((*e1)->dos_name, (*e2)->dos_name);
185 r = strcmp ((*e1)->path, (*e2)->path);
187 r = strcmp ((*e1)->full_name, (*e2)->full_name);
192 compare_ent_fullname (e1, e2)
196 int r = strncmp ((*e1)->full_name, (*e2)->full_name, 14);
198 r = strcmp ((*e1)->path, (*e2)->path);
200 r = strcmp ((*e1)->full_name, (*e2)->full_name);
208 static char buf[500];
209 if (ent->path && ent->path[0])
210 sprintf (buf, "%s/%s", ent->path, ent->full_name);
212 return ent->full_name;
216 /****************************************************************\
217 * List handling routines *
218 \****************************************************************/
232 ENT *ent = alloc_ent ();
233 fill_ent (ent, line);
241 int ecount, i, first, first_err;
243 for (ecount=0, ent=eroot; ent; ent=ent->next, ecount++);
244 elist = (ENT **)malloc (sizeof (ENT *) * ecount);
245 for (ecount=0, ent=eroot; ent; ent=ent->next, ecount++)
248 qsort (elist, ecount, sizeof (ENT *), compare_ent_dosname);
252 for (i=0; i<ecount-1; i++)
254 if ((strcmp (elist[i]->dos_name, elist[i+1]->dos_name) == 0)
255 && (strcmp (elist[i]->path, elist[i+1]->path) == 0))
263 printf ("The following resolve to the same DOS file names:\n");
268 printf ("%14s : %s\n", elist[i]->dos_name, mpath (elist[i]));
271 printf ("\t\t %s\n", mpath (elist[i+1]));
277 qsort (elist, ecount, sizeof (ENT *), compare_ent_fullname);
281 for (i=0; i<ecount-1; i++)
283 if ((strncmp (elist[i]->full_name, elist[i+1]->full_name, 14) == 0)
284 && (strcmp (elist[i]->path, elist[i+1]->path) == 0))
292 printf ("The following resolve to the same SysV file names:\n");
297 printf ("%.14s : %s\n", elist[i]->full_name, mpath (elist[i]));
299 elist[i]->tagged = 1;
301 printf ("\t\t %s\n", mpath (elist[i+1]));
302 elist[i+1]->tagged = 1;
309 for (i=0; i<ecount; i++)
311 if ((strlen (elist[i]->full_name) > 14) && !elist[i]->tagged)
319 printf ("The following file names are too long for SysV:\n");
322 printf ("%.14s : %s\n", elist[i]->full_name, mpath (elist[i]));
327 /****************************************************************\
329 \****************************************************************/
338 input = fopen (argv[1], "r");
349 fgets (line, 500, input);
352 lp = line+strlen (line);
353 while ((lp != line) && (*lp <= ' '))