Fix some bugs

This commit is contained in:
Justine Tunney 2022-08-14 13:28:07 -07:00
parent 5584f6adcf
commit 6c0bbfac4a
15 changed files with 289 additions and 136 deletions

View file

@ -133,62 +133,6 @@ static ZCONST char CannotSetTimestamps[] =
#ifndef SFX
#ifdef NO_DIR /* for AT&T 3B1 */
#define _opendir(path) fopen(path,"r")
#define _closedir(dir) fclose(dir)
typedef FILE DIR;
typedef struct zdir {
FILE *dirhandle;
struct dirent *entry;
} DIR
DIR *opendir OF((ZCONST char *dirspec));
void closedir OF((DIR *dirp));
struct dirent *readdir OF((DIR *dirp));
DIR *opendir(dirspec)
ZCONST char *dirspec;
{
DIR *dirp;
if ((dirp = malloc(sizeof(DIR)) != NULL) {
if ((dirp->dirhandle = fopen(dirspec, "r")) == NULL) {
free(dirp);
dirp = NULL;
}
}
return dirp;
}
void closedir(dirp)
DIR *dirp;
{
fclose(dirp->dirhandle);
free(dirp);
}
/*
* Apparently originally by Rich Salz.
* Cleaned up and modified by James W. Birdsall.
*/
struct dirent *readdir(dirp)
DIR *dirp;
{
if (dirp == NULL)
return NULL;
for (;;)
if (fread(&(dirp->entry), sizeof (struct dirent), 1,
dirp->dirhandle) == 0)
return (struct dirent *)NULL;
else if ((dirp->entry).d_ino)
return &(dirp->entry);
} /* end function readdir() */
#endif /* NO_DIR */
/**********************/
/* Function do_wild() */ /* for porting: dir separator; match(ignore_case) */