$NetBSD: patch-ab,v 1.6 2025/04/21 20:58:42 wiz 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 @@ -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