$NetBSD: patch-ab,v 1.5 2006/07/21 16:16:40 minskim Exp $ --- mmv.c.orig 1993-10-25 10:29:39.000000000 +0000 +++ mmv.c @@ -120,13 +120,17 @@ extern unsigned _stklen = 10000; #else /* for various flavors of UN*X */ +#include #include #include #include +#include +#include +#if !(defined(BSD) && BSD >= 199306) extern char *getenv(); extern long lseek(); -extern char *malloc(); +#endif #ifdef HAS_DIRENT #include @@ -188,7 +192,7 @@ extern char *strcpy(), *strchr(); #include #endif -#ifdef IS_SYSV +#if defined(IS_SYSV) || defined(__INTERIX) /* for System V and Version 7*/ struct utimbuf { @@ -197,6 +201,9 @@ struct utimbuf { }; #define utimes(f, t) utime((f), &(t)) +#endif + +#ifdef IS_SYSV #ifndef HAS_RENAME #ifndef MV_DIR # define MV_DIR "/usr/lib/mv_dir" @@ -436,7 +443,7 @@ static CHUNK *freechunks = NULL; static SLICER slicer[2] = {{NULL, NULL, 0}, {NULL, NULL, 0}}; static int badreps = 0, paterr = 0, direrr, failed = 0, gotsig = 0, repbad; -static FILE *outfile = stdout; +static FILE *outfile; static char IDF[] = "$$mmvdid."; static char TEMP[] = "$$mmvtmp."; @@ -497,6 +504,8 @@ int main(argc, argv) { char *frompat, *topat; + outfile = stdout; + init(); procargs(argc, argv, &frompat, &topat); domatch(frompat, topat); @@ -1415,6 +1424,9 @@ static int badname(s) (*ext == '.' && strchr(ext + 1, '.') != NULL) || strlen(ext) >= MAXEXT || strncmp(s, IDF, STRLEN(IDF)) == 0 +#elif defined(NAME_MAX) + (*s == '.' && (s[1] == '\0' || strcmp(s, "..") == 0)) || + strlen(s) > NAME_MAX #else (*s == '.' && (s[1] == '\0' || strcmp(s, "..") == 0)) || strlen(s) > MAXNAMLEN @@ -2631,7 +2643,7 @@ static int copy(ff, len) #ifdef IS_MSDOS struct ftime tim; #else -#ifdef IS_SYSV +#if defined(IS_SYSV) || defined(__INTERIX) struct utimbuf tim; #else struct timeval tim[2]; @@ -2706,7 +2718,7 @@ static int copy(ff, len) #else stat(pathbuf, &fstat) || ( -#ifdef IS_SYSV +#if defined(IS_SYSV) || defined(__INTERIX) tim.actime = fstat.st_atime, tim.modtime = fstat.st_mtime, #else