rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit 692977070514082a226f256e8df7dfea33b31bc2
parent f5e2a8522f34b56018b77520738fb15fab083ee6
Author: tjg <tjg>
Date:   Fri, 12 Oct 2001 10:22:05 +0000

fix a few more warnings

Diffstat:
Mbuiltins.c | 6+++---
Minput.c | 20++++++++++----------
Mlex.c | 8++++----
Mmksignal.c | 17+++++++++--------
Mrc.h | 2+-
Mutils.c | 2+-
6 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/builtins.c b/builtins.c @@ -251,7 +251,7 @@ extern void b_builtin(char **ignore) { /* wait for a given process, or all outstanding processes */ static void b_wait(char **av) { - int stat; + int status; pid_t pid; if (av[1] == NULL) { waitforall(); @@ -265,8 +265,8 @@ static void b_wait(char **av) { badnum(av[1]); return; } - if (rc_wait4(pid, &stat, FALSE) > 0) - setstatus(pid, stat); + if (rc_wait4(pid, &status, FALSE) > 0) + setstatus(pid, status); else set(FALSE); sigchk(); diff --git a/input.c b/input.c @@ -38,7 +38,7 @@ static Input *istack, *itop; static int (*realgchar)(void); static void (*realugchar)(int); -int last; +int lastchar; #if EDITLINE || READLINE static char *rlinebuf, *prompt; @@ -49,7 +49,7 @@ extern int gchar() { if (eofread) { eofread = FALSE; - return last = EOF; + return lastchar = EOF; } while ((c = (*realgchar)()) == '\0') @@ -63,7 +63,7 @@ extern void ugchar(int c) { } static int dead() { - return last = EOF; + return lastchar = EOF; } static void ugdead(int ignore) { @@ -80,7 +80,7 @@ static void ugalive(int c) { /* get the next character from a string. */ static int stringgchar() { - return last = (inbuf[chars_out] == '\0' ? EOF : inbuf[chars_out++]); + return lastchar = (inbuf[chars_out] == '\0' ? EOF : inbuf[chars_out++]); } /* @@ -140,13 +140,13 @@ static int fdgchar() { break; } if (chars_in == 0) - return last = EOF; + return lastchar = EOF; chars_out = 2; if (dashvee) writeall(2, inbuf + 2, chars_in); history(); } - return last = inbuf[chars_out++]; + return lastchar = inbuf[chars_out++]; } /* set up the input stack, and put a "dead" input at the bottom, so that yyparse will always read eof */ @@ -167,7 +167,7 @@ static void pushcommon() { istack->ibuf = inbuf; istack->lineno = lineno; istack->saved = save_lineno; - istack->last = last; + istack->last = lastchar; istack->eofread = eofread; istack++; idiff = istack - itop; @@ -214,7 +214,7 @@ extern void popinput() { realgchar = dead; realugchar = ugdead; } - last = istack->last; + lastchar = istack->last; eofread = istack->eofread; inbuf = istack->ibuf; chars_out = istack->index; @@ -230,7 +230,7 @@ extern void popinput() { extern void flushu() { int c; - if (last == '\n' || last == EOF) + if (lastchar == '\n' || lastchar == EOF) return; while ((c = gchar()) != '\n' && c != EOF) ; /* skip to newline */ @@ -292,7 +292,7 @@ extern Node *doit(bool clobberexecit) { inityy(); if (yyparse() == 1 && execit) rc_raise(eError); - eof = (last == EOF); /* "last" can be clobbered during a walk() */ + eof = (lastchar == EOF); /* "lastchar" can be clobbered during a walk() */ if (parsetree != NULL) { if (execit) walk(parsetree, TRUE); diff --git a/lex.c b/lex.c @@ -321,13 +321,13 @@ extern void yyerror(const char *s) { if (!interactive) { if (w != NW) tok = realbuf; - else if (last == EOF) + else if (lastchar == EOF) tok = "eof"; - else if (last == '\n') + else if (lastchar == '\n') tok = "end of line"; else - tok = nprint((last < 32 || last > 126) ? "(decimal %d)" : "'%c'", last); - fprint(2, "line %d: %s near %s\n", lineno - (last == '\n'), s, tok); + tok = nprint((lastchar < 32 || lastchar > 126) ? "(decimal %d)" : "'%c'", lastchar); + fprint(2, "line %d: %s near %s\n", lineno - (lastchar == '\n'), s, tok); } else fprint(2, "%s\n", s); } diff --git a/mksignal.c b/mksignal.c @@ -1,5 +1,6 @@ -#include <stdio.h> #include <signal.h> +#include <stdio.h> +#include <stdlib.h> #ifdef NSIG #define NUMSIG NSIG @@ -7,13 +8,13 @@ #define NUMSIG 1 #endif -typedef struct { +struct signaming { int signo; - char *signame; - char *sigmsg; -} signaming; + const char *signame; + const char *sigmsg; +}; -static signaming signamings[] = { +static struct signaming signamings[] = { #ifdef SIGABRT { SIGABRT, "sigabrt", "abort"}, #endif @@ -191,7 +192,7 @@ static signaming signamings[] = { { 0, 0, 0} }; -static void barf(char *msg) { +static void barf(const char *msg) { fprintf(stderr, "mksignals: %s\n", msg); exit(1); } @@ -199,7 +200,7 @@ static void barf(char *msg) { int main(void) { int maxsig = NUMSIG-1; int s; - signaming *snp; + struct signaming *snp; FILE *outf; for (snp = signamings; snp->signo; ++snp) diff --git a/rc.h b/rc.h @@ -278,7 +278,7 @@ extern void pushfd(int); extern void pushstring(char **, bool); extern void popinput(void); extern void closefds(void); -extern int last; +extern int lastchar; extern bool rcrc; diff --git a/utils.c b/utils.c @@ -57,7 +57,7 @@ extern int n2u(char *s, unsigned int base) { /* The last word in portable ANSI: a strcmp wrapper for qsort */ extern int starstrcmp(const void *s1, const void *s2) { - return strcmp(*(char **)s1, *(char **)s2); + return strcmp(*(char * const *)s1, *(char * const *)s2); } /* tests to see if pathname begins with "/", "./", or "../" */