X-Git-Url: https://git.deb.at/w?p=pkg%2Fmmv.git;a=blobdiff_plain;f=mmv.c;h=2e72a731e426c3378d5887c355abda40d337e3e7;hp=1215984a682712dfc8cd2aebee2b725e0aaeccc6;hb=9754b91798e38c5041fa84a2905d3244aee14fb1;hpb=bf800994d6598a56ee0690be95967dcee3b861d1 diff --git a/mmv.c b/mmv.c index 1215984..2e72a73 100644 --- a/mmv.c +++ b/mmv.c @@ -62,8 +62,7 @@ static char USAGE[] = %s [-m|x%s|c|o|a|z] [-h] [-d|p] [-g|t] [-v|n] [from to]\n\ \n\ Use #N in the ``to'' pattern to get the string matched\n\ -by the N'th ``from'' pattern wildcard.\n\ -Use -- as the end of options.\n"; +by the N'th ``from'' pattern wildcard.\n"; #define OTHEROPT (_osmajor < 3 ? "" : "|r") @@ -76,9 +75,7 @@ Use #[l|u]N in the ``to'' pattern to get the [lowercase|uppercase of the]\n\ string matched by the N'th ``from'' pattern wildcard.\n\ \n\ A ``from'' pattern containing wildcards should be quoted when given\n\ -on the command line. Also you may need to quote ``to'' pattern.\n\ -\n\ -Use -- as the end of options.\n"; +on the command line.\n"; #ifdef IS_SYSV #define OTHEROPT "" @@ -439,7 +436,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; +static FILE *outfile = stdout; static char IDF[] = "$$mmvdid."; static char TEMP[] = "$$mmvtmp."; @@ -500,8 +497,6 @@ int main(argc, argv) { char *frompat, *topat; - outfile = stdout; - init(); procargs(argc, argv, &frompat, &topat); domatch(frompat, topat); @@ -580,11 +575,6 @@ static void procargs(argc, argv, pfrompat, ptopat) for (argc--, argv++; argc > 0 && **argv == '-'; argc--, argv++) for (p = *argv + 1; *p != '\0'; p++) { c = mylower(*p); - if (c == '-') { - argc--; - argv++; - goto endargs; - } if (c == 'v' && !noex) verbose = 1; else if (c == 'n' && !verbose) @@ -628,7 +618,6 @@ static void procargs(argc, argv, pfrompat, ptopat) } } -endargs: if (op == DFLT) if (strcmp(cmdname, MOVENAME) == 0) op = XMOVE; @@ -1010,16 +999,20 @@ static int parsepat() printf(TRAILESC, from, to, ESC); return(-1); } -#ifdef IS_MSDOS default: if ( +#ifdef IS_MSDOS c <= ' ' || c >= 127 || strchr(":/\\*?[]=+;,\"|<>", c) != NULL +#else + c & 0x80 +#endif ) { printf("%s -> %s : illegal character '%c' (0x%02X).\n", from, to, c, c); return(-1); } +#ifdef IS_MSDOS if (isupper(c)) *p = c + ('a' - 'A'); #endif @@ -2631,7 +2624,7 @@ static int copymove(p) static int copy(ff, len) FILEINFO *ff; - off_t len; + long len; { char buf[BUFSIZE], c; int f, t, k, mode, perm; @@ -2679,7 +2672,7 @@ static int copy(ff, len) return(-1); } if (op & APPEND) - lseek(t, (off_t)0, SEEK_END); + lseek(t, 0L, 2); #ifdef IS_MSDOS if (op & ZAPPEND && filelength(t) != 0) { if (lseek(t, -1L, 1) == -1L || read(t, &c, 1) != 1) { @@ -2691,10 +2684,10 @@ static int copy(ff, len) lseek(t, -1L, 1); } #endif - if ((op & APPEND) && len != (off_t)-1) { + if ((op & APPEND) && len != -1L) { while ( len != 0 && - (k = read(f, buf, (len > BUFSIZE) ? BUFSIZE : (size_t)len)) > 0 && + (k = read(f, buf, len > BUFSIZE ? BUFSIZE : (unsigned)len)) > 0 && write(t, buf, k) == k ) len -= k;