1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
$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 <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
+#include <sys/param.h>
+#include <limits.h>
+#if !(defined(BSD) && BSD >= 199306)
extern char *getenv();
extern long lseek();
-extern char *malloc();
+#endif
#ifdef HAS_DIRENT
#include <dirent.h>
@@ -188,7 +192,7 @@ extern char *strcpy(), *strchr();
#include <fcntl.h>
#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
|