[comp.sources.bugs] mkmf bugs

dcon@ihlpe.ATT.COM (452is-Connet) (12/31/87)

Here are a set of diffs to fix some bugs in mkmf.  The majority were
to get it running on SYSV.  The others are:
	1. mkmf would read ALL entries in a directory, including deleted files.
		- Checks d_ino (== 0 -> file deleted).
	2. syntax as #include<file.h> would fail.  (The 1st '<' was eaten.)
		- Does an ungetc() to put character back.

David Connet
AT&T Naperville IL
ihnp4!ihlpe!dcon

#### diff OMkmf.h Mkmf.h
58a59,65
> 
> #ifdef SYSV
> #define index	strchr
> #define rindex	strrchr
> #define closedir	close
> #define opendir(x)	open(x,0)
> #endif

#### diff Obuildlist.c buildlist.c
215a216,218
> #ifdef SYSV
> 	int *dirp;			/* directory stream */
> #else
217a221
> #endif
229c233
< 		if ((suffix = rindex(dp->d_name, '.')) != NULL)
---
> 		if (dp->d_ino != 0 && (suffix = rindex(dp->d_name, '.')) != NULL)
254a259,272
> 
> #ifdef SYSV
> struct direct sysvdir
> 
> struct direct *
> readdir(fd)
> int fd;
> {
> 	if (read(fd,(char *)&sysvdir,sizeof(sysvdir)) != sizeof(sysvdir))
> 		return (NULL);
> 	else
> 		return (&sysvdir);
> }
> #endif

#### Odepend.c depend.c
547a548
> 		ungetc(c,ifp);
653a655
> 		ungetc(c,ifp);
757a760
> 		ungetc(c,ifp);

allbery@ncoast.UUCP (Brandon Allbery) (01/03/88)

As quoted from <2418@ihlpe.ATT.COM> by dcon@ihlpe.ATT.COM (452is-Connet):
+---------------
| Here are a set of diffs to fix some bugs in mkmf.  The majority were
| to get it running on SYSV.  The others are:
| 	1. mkmf would read ALL entries in a directory, including deleted files.
| 		- Checks d_ino (== 0 -> file deleted).
+---------------

Since your patches emulate readdir() by using read(), you would see this.
A better way to do this is to use dir.c from News 2.11 or rn sources; these
emulate the BSD directory routines correctly, including automatic skipping
of deleted entries.
-- 
	      Brandon S. Allbery, Moderator of comp.sources.misc
 {hoptoad,harvard!necntc,cbosgd,sun!mandrill!hal,uunet!hnsurg3}!ncoast!allbery
     [This space reserved for future quotes and similar brain twisters.]