Hi, this is my first diff submission, forgive me if have any error, if anyone has any tips on how to do this i appreciate it.
I remove some duplicate and empty lines amoung a coupe of files in csh, i think this changes help to follow 'csh code style'. >From a3a16828c1cb30a33730a540fd46de8eb932b30b Mon Sep 17 00:00:00 2001 From: kalwecaramalac <kalwe....@gmail.com> Date: Mon, 29 Jul 2019 17:49:00 -0400 Subject: [PATCH] remove empty and unnecessary duplicate lines --- bin/csh/alloc.c | 3 +-- bin/csh/csh.c | 5 ----- bin/csh/csh.h | 2 -- bin/csh/dir.c | 5 ----- bin/csh/dol.c | 6 +----- bin/csh/error.c | 1 - bin/csh/exec.c | 1 - bin/csh/glob.c | 5 ----- bin/csh/hist.c | 1 - bin/csh/lex.c | 2 -- bin/csh/misc.c | 10 ---------- bin/csh/parse.c | 1 - bin/csh/proc.c | 6 ------ bin/csh/sem.c | 2 -- bin/csh/set.c | 3 --- bin/csh/str.c | 1 - 16 files changed, 2 insertions(+), 52 deletions(-) diff --git a/bin/csh/alloc.c b/bin/csh/alloc.c index 7720ddb9536..2053bf219fe 100644 --- a/bin/csh/alloc.c +++ b/bin/csh/alloc.c @@ -72,7 +72,6 @@ xcalloc(size_t s, size_t n) child++; stderror(ERR_NOMEM); } - return (ptr); } @@ -80,7 +79,7 @@ char * xstrdup(const char *s) { char *n; - + if (s == NULL) s = ""; if ((n = strdup(s)) == NULL) { diff --git a/bin/csh/csh.c b/bin/csh/csh.c index 98e665507d1..0b23ff90ede 100644 --- a/bin/csh/csh.c +++ b/bin/csh/csh.c @@ -1190,7 +1190,6 @@ readf(void *oreo, char *buf, int siz) return read(DESC(oreo), buf, siz); } - static int writef(void *oreo, const char *buf, int siz) { @@ -1203,14 +1202,12 @@ seekf(void *oreo, fpos_t off, int whence) return lseek(DESC(oreo), off, whence); } - static int closef(void *oreo) { return close(DESC(oreo)); } - /* * Print the visible version of a string. */ @@ -1232,7 +1229,6 @@ vis_fputc(int ch, FILE *fp) void initdesc(void) { - didfds = 0; /* 0, 1, 2 aren't set up */ (void) fcntl(SHIN = dcopy(0, FSHIN), F_SETFD, FD_CLOEXEC); (void) fcntl(SHOUT = dcopy(1, FSHOUT), F_SETFD, FD_CLOEXEC); @@ -1241,7 +1237,6 @@ initdesc(void) closem(); } - void xexit(int i) { diff --git a/bin/csh/csh.h b/bin/csh/csh.h index aa88f3ad1f9..656550d3329 100644 --- a/bin/csh/csh.h +++ b/bin/csh/csh.h @@ -136,7 +136,6 @@ pid_t tpgrp; /* Terminal process group */ /* If tpgrp is -1, leave tty alone! */ pid_t opgrp; /* Initial pgrp and tty pgrp */ - /* * To be able to redirect i/o for builtins easily, the shell moves the i/o * descriptors it uses away from 0,1,2. @@ -318,7 +317,6 @@ struct command { int t_nice; }; - /* * These are declared here because they want to be * initialized in sh.init.c (to allow them to be made readonly) diff --git a/bin/csh/dir.c b/bin/csh/dir.c index d66fc677c8f..a8914540bb4 100644 --- a/bin/csh/dir.c +++ b/bin/csh/dir.c @@ -224,7 +224,6 @@ printdirs(void) void dtildepr(Char *home, Char *dir) { - if (!eq(home, STRslash) && prefix(home, dir)) (void) fprintf(cshout, "~%s", vis_str(dir + Strlen(home))); else @@ -245,7 +244,6 @@ dtilde(void) dset(dcwd->di_name); } - /* dnormalize(): * If the name starts with . or .. then we might need to normalize * it depending on the symbolic link flags @@ -457,7 +455,6 @@ dfollow(Char *cp) return (NULL); } - /* * dopushd - push new directory onto directory stack. * with no arguments exchange top and second. @@ -588,7 +585,6 @@ dopopd(Char **v, struct command *t) void dfree(struct directory *dp) { - if (dp->di_count != 0) { dp->di_next = dp->di_prev = 0; } @@ -886,7 +882,6 @@ dcanon(Char *cp, Char *p) return cp; } - /* * dnewcwd - make a new directory in the loop the current one */ diff --git a/bin/csh/dol.c b/bin/csh/dol.c index 8d96579a2aa..56ce0a0af45 100644 --- a/bin/csh/dol.c +++ b/bin/csh/dol.c @@ -87,7 +87,6 @@ static void unDredc(int); static int Dredc(void); static void Dtestq(int); - /* * Fix up the $ expansions and quotations in the * argument list to command t. @@ -317,7 +316,6 @@ Dword(void) return (0); } - /* * Get a character, performing $ substitution unless flag is 0. * Any QUOTES character which is returned from a $ expansion is @@ -773,7 +771,6 @@ setDolp(Char *cp) static void unDredc(int c) { - Dpeekrd = c; } @@ -799,7 +796,6 @@ Dredc(void) static void Dtestq(int c) { - if (cmap(c, QUOTES)) gflag = 1; } @@ -857,7 +853,7 @@ heredoc(Char *term) * Check for EOF or compare to terminator -- before expansion */ if (c < 0 || eq(lbuf, term)) { - (void) write(STDIN_FILENO, short2str(obuf), + (void) write(STDIN_FILENO, short2str(obuf), (size_t) (BUFSIZ - ocnt)); (void) lseek(STDIN_FILENO, (off_t) 0, SEEK_SET); return; diff --git a/bin/csh/error.c b/bin/csh/error.c index 9aa4054761f..7c1df869c9c 100644 --- a/bin/csh/error.c +++ b/bin/csh/error.c @@ -330,7 +330,6 @@ stderror(int id, ...) haderr = 1; /* Now to diagnostic output */ timflg = 0; /* This isn't otherwise reset */ - if (!(flags & ERR_SILENT)) { if (flags & ERR_NAME) (void) fprintf(csherr, "%s: ", bname); diff --git a/bin/csh/exec.c b/bin/csh/exec.c index 73530dfae3d..0b9ef7df391 100644 --- a/bin/csh/exec.c +++ b/bin/csh/exec.c @@ -95,7 +95,6 @@ static int tellmewhat(struct wordent *, Char *, int len); static int executable(Char *, Char *, bool); static int iscommand(Char *); - void /*ARGSUSED*/ doexec(Char **v, struct command *t) diff --git a/bin/csh/glob.c b/bin/csh/glob.c index d21cd7c5bbc..714fbd92a45 100644 --- a/bin/csh/glob.c +++ b/bin/csh/glob.c @@ -84,7 +84,6 @@ static void pword(void); static void psave(int); static void backeval(Char *, bool); - static Char * globtilde(Char **nv, Char *s) { @@ -203,7 +202,6 @@ globbrace(Char *s, Char *p, Char ***bl) return (len); } - static void expbrace(Char ***nvp, Char ***elp, int size) { @@ -260,7 +258,6 @@ expbrace(Char ***nvp, Char ***elp, int size) continue; free(bl); } - } if (elp != NULL) *elp = el; @@ -274,7 +271,6 @@ globexpand(Char **v) Char **nv, **vl, **el; int size = GLOBSPACE; - nv = vl = xreallocarray(NULL, size, sizeof(Char *)); *vl = NULL; @@ -331,7 +327,6 @@ globexpand(Char **v) static Char * handleone(Char *str, Char **vl, int action) { - Char *cp, **vlp = vl; switch (action) { diff --git a/bin/csh/hist.c b/bin/csh/hist.c index 5b3edc0eb8a..c61c771e186 100644 --- a/bin/csh/hist.c +++ b/bin/csh/hist.c @@ -95,7 +95,6 @@ enthist(int event, struct wordent *lp, bool docopy) static void hfree(struct Hist *hp) { - freelex(&hp->Hlex); free(hp); } diff --git a/bin/csh/lex.c b/bin/csh/lex.c index 5d20e22eb04..c2b72ee9071 100644 --- a/bin/csh/lex.c +++ b/bin/csh/lex.c @@ -1075,7 +1075,6 @@ getsel(int *al, int *ar, int dol) return (0); } return (1); - } static struct wordent * @@ -1244,7 +1243,6 @@ findev(Char *cp, bool anyarg) return (0); } - static void setexclp(Char *cp) { diff --git a/bin/csh/misc.c b/bin/csh/misc.c index d0964e03602..c21e13ea450 100644 --- a/bin/csh/misc.c +++ b/bin/csh/misc.c @@ -55,17 +55,14 @@ any(char *s, int c) Char ** blkend(Char **up) { - while (*up) up++; return (up); } - void blkpr(FILE *fp, Char **av) { - for (; *av; av++) { (void) fprintf(fp, "%s", vis_str(*av)); if (av[1]) @@ -96,7 +93,6 @@ blkcpy(Char **oav, Char **bv) Char ** blkcat(Char **up, Char **vp) { - (void) blkcpy(blkend(up), vp); return (up); } @@ -136,7 +132,6 @@ blkspl(Char **up, Char **vp) Char lastchr(Char *cp) { - if (!cp) return (0); if (!*cp) @@ -209,7 +204,6 @@ donefds(void) int dmove(int i, int j) { - if (i == j || i < 0) return (i); if (j >= 0) { @@ -227,7 +221,6 @@ dmove(int i, int j) int dcopy(int i, int j) { - if (i == j || i < 0 || (j < 0 && i > 2)) return (i); if (j >= 0) { @@ -290,7 +283,6 @@ Char ** copyblk(Char **v) { Char **nv = xcalloc(blklen(v) + 1, sizeof(*nv)); - return (blkcpy(nv, v)); } @@ -321,7 +313,6 @@ quote(Char *cp) void udvar(Char *name) { - setname(vis_str(name)); stderror(ERR_NAME | ERR_UNDVAR); } @@ -329,7 +320,6 @@ udvar(Char *name) int prefix(Char *sub, Char *str) { - for (;;) { if (*sub == 0) return (1); diff --git a/bin/csh/parse.c b/bin/csh/parse.c index 626d212d21a..ae4f0f8b24a 100644 --- a/bin/csh/parse.c +++ b/bin/csh/parse.c @@ -212,7 +212,6 @@ freenod(struct wordent *p1, struct wordent *p2) struct command * syntax(struct wordent *p1, struct wordent *p2, int flags) { - while (p1 != p2) if (any(";&\n", p1->word[0])) p1 = p1->next; diff --git a/bin/csh/proc.c b/bin/csh/proc.c index 44274cc2744..e8a114cb234 100644 --- a/bin/csh/proc.c +++ b/bin/csh/proc.c @@ -238,7 +238,6 @@ pwait(void) pjwait(pcurrjob); } - /* * pjwait - wait for a job to finish or become stopped * It is assumed to be in the foreground state (PFOREGND) @@ -409,7 +408,6 @@ pflush(struct process *pp) static void pclrcurr(struct process *pp) { - if (pp == pcurrent) if (pprevious != NULL) { pcurrent = pprevious; @@ -590,7 +588,6 @@ pads(Char *cp) void psavejob(void) { - pholdjob = pcurrjob; pcurrjob = NULL; } @@ -602,7 +599,6 @@ psavejob(void) void prestjob(void) { - pcurrjob = pholdjob; pholdjob = NULL; } @@ -1182,7 +1178,6 @@ pfind(Char *cp) return (0); } - /* * pgetcurr - find most recent job that is not pp, preferably stopped */ @@ -1308,7 +1303,6 @@ pfork(struct command *t, int wanttty) palloc(pid, t); sigprocmask(SIG_SETMASK, &osigset, NULL); } - return (pid); } diff --git a/bin/csh/sem.c b/bin/csh/sem.c index f9ffff8a08d..d734b8491c2 100644 --- a/bin/csh/sem.c +++ b/bin/csh/sem.c @@ -332,7 +332,6 @@ execute(struct command *t, int wanttty, int *pipein, int *pipeout) if (t->t_dflg & F_NICE) (void) setpriority(PRIO_PROCESS, 0, t->t_nice); } - } } if (pid != 0) { @@ -597,7 +596,6 @@ doio(struct command *t, int *pipein, int *pipeout) void mypipe(int *pv) { - if (pipe(pv) == -1) goto oops; pv[0] = dmove(pv[0], -1); diff --git a/bin/csh/set.c b/bin/csh/set.c index c638d0d00d9..3f5aea6bb68 100644 --- a/bin/csh/set.c +++ b/bin/csh/set.c @@ -49,7 +49,6 @@ static void unsetv1(struct varent *); static void exportpath(Char **); static void balance(struct varent *, int, int); - /* * C Shell */ @@ -166,7 +165,6 @@ doset(Char **v, struct command *t) static Char * getinx(Char *cp, int *ip) { - *ip = 0; *cp++ = 0; while (*cp && Isdigit(*cp)) @@ -428,7 +426,6 @@ set1(Char *var, Char **vec, struct varent *head) setq(var, vec, head); } - void setq(Char *name, Char **vec, struct varent *p) { diff --git a/bin/csh/str.c b/bin/csh/str.c index 108639c3c69..35516bd919e 100644 --- a/bin/csh/str.c +++ b/bin/csh/str.c @@ -402,4 +402,3 @@ vis_str(Char *cp) (void) strnvis(sdst, short2str(cp), dstsize, VIS_NOSLASH); return (sdst); } - -- 2.17.2