X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=mmv.c;h=200392c05f913d3e48a41a59dedbe6c148e08b4e;hb=9a2c51c923289b5636b27ed9dd51132e05ee364d;hp=abce4a40b91e82f7642267970502af6b9a8cc7bd;hpb=5350e76f1bbd9d9e52bc0beaa31708bf46bbf85f;p=pkg%2Fmmv.git diff --git a/mmv.c b/mmv.c index abce4a4..200392c 100644 --- a/mmv.c +++ b/mmv.c @@ -124,6 +124,7 @@ extern unsigned _stklen = 10000; #else /* for various flavors of UN*X */ +#include #include #include #include @@ -438,7 +439,9 @@ 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; +#ifdef IS_MSDOS static char IDF[] = "$$mmvdid."; +#endif static char TEMP[] = "$$mmvtmp."; static char TOOLONG[] = "(too long)"; static char EMPTY[] = "(empty)"; @@ -456,12 +459,12 @@ char pathbuf[MAXPATH]; char fullrep[MAXPATH + 1]; static char *(start[MAXWILD]); static int len[MAXWILD]; -static char hasdot[MAXWILD]; static REP mistake; #define MISTAKE (&mistake) #ifdef IS_MSDOS +static char hasdot[MAXWILD]; static int olddevflag, curdisk, maxdisk; static struct { char ph_banner[30]; @@ -626,7 +629,7 @@ static void procargs(argc, argv, pfrompat, ptopat) } endargs: - if (op == DFLT) + if (op == DFLT) { if (strcmp(cmdname, MOVENAME) == 0) op = XMOVE; else if (strcmp(cmdname, COPYNAME) == 0) @@ -637,6 +640,8 @@ endargs: op = HARDLINK; else op = DFLTOP; + } + if ( op & DIRMOVE && #ifdef IS_MSDOS @@ -783,7 +788,7 @@ static void matchpat() static int parsepat() { char *p, *lastname, c; - int totwilds, instage, x, havedot; + int totwilds, instage, x; static char TRAILESC[] = "%s -> %s : trailing %c is superfluous.\n"; lastname = from; @@ -1046,7 +1051,7 @@ static int dostage(lastend, pathend, start1, len1, stage, anylev) DIRINFO *di; HANDLE *h, *hto; int prelen, litlen, nfils, i, k, flags, try; - FILEINFO **pf, *fdel; + FILEINFO **pf, *fdel = NULL; char *nto, *firstesc; REP *p; int wantdirs, ret = 1, laststage = (stage + 1 == nstages); @@ -1176,11 +1181,12 @@ static int trymatch(ffrom, pat) if (*p == '.' || (!matchall && ffrom->fi_attrib & (FA_HIDDEN | FA_SYSTEM))) return(strcmp(pat, p) == 0); #else - if (*p == '.') + if (*p == '.') { if (p[1] == '\0' || (p[1] == '.' && p[2] == '\0')) return(strcmp(pat, p) == 0); else if (!matchall && *pat != '.') return(0); + } #endif return(-1); } @@ -1316,7 +1322,7 @@ static int checkto(hfrom, f, phto, pnto, pfdel) { char tpath[MAXPATH + 1]; char *pathend; - FILEINFO *fdel; + FILEINFO *fdel = NULL; int hlen, tlen; if (op & DIRMOVE) { @@ -1409,7 +1415,9 @@ static char *getpath(tpath) static int badname(s) char *s; { +#ifdef IS_MSDOS char *ext; +#endif return ( #ifdef IS_MSDOS @@ -1719,20 +1727,19 @@ static HANDLE *checkdir(p, pathend, which) struct stat dstat; DIRID d; DEVID v; - DIRINFO **newdirs, *di; - int nfils; - FILEINFO **fils; + DIRINFO *di = NULL; char *myp, *lastslash = NULL; int sticky; HANDLE *h; - if (hsearch(p, which, &h)) + if (hsearch(p, which, &h)) { if (h->h_di == NULL) { direrr = h->h_err; return(NULL); } else return(h); + } if (*p == '\0') myp = "."; @@ -1903,7 +1910,10 @@ static int match(pat, s, start1, len1) char *pat, *s, **start1; int *len1; { - char c, *olds; + char c; +#ifdef IS_MSDOS + char *olds; +#endif *start1 = 0; for(;;) @@ -2380,9 +2390,9 @@ static void goonordie() static void doreps() { char *fstart; - int k, printaliased = 0, alias; + int k, printaliased = 0, alias = 0; REP *first, *p; - long aliaslen; + long aliaslen = 0l; #ifdef IS_MSDOS ctrlbrk(breakrep); @@ -2400,11 +2410,12 @@ static void doreps() } strcpy(fullrep, p->r_hto->h_name); strcat(fullrep, p->r_nto); - if (!noex && (p->r_flags & R_ISCYCLE)) + if (!noex && (p->r_flags & R_ISCYCLE)) { if (op & APPEND) aliaslen = appendalias(first, p, &printaliased); else alias = movealias(first, p, &printaliased); + } strcpy(pathbuf, p->r_hfrom->h_name); fstart = pathbuf + strlen(pathbuf); if ((p->r_flags & R_ISALIASED) && !(op & APPEND)) @@ -2463,7 +2474,7 @@ static long appendalias(first, p, pprintaliased) REP *first, *p; int *pprintaliased; { - long ret; + long ret = 0l; #ifdef IS_MSDOS int fd; @@ -2630,9 +2641,10 @@ static int copy(ff, len) FILEINFO *ff; off_t len; { - char buf[BUFSIZE], c; + char buf[BUFSIZE]; int f, t, k, mode, perm; #ifdef IS_MSDOS + char c; struct ftime tim; #else #ifdef IS_SYSV