rc

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

commit a1f1ee9b27d08644061bc440b779f99c3e9362f0
parent c1959b3d914f52bf0c00523e360aece68d9076d3
Author: tgoodwin <tgoodwin>
Date:   Fri, 30 Oct 1998 16:07:02 +0000

  Portability: rename basename() to rc_basename(), since the former is
  quite widespread, and has a variety of different definitions (none of
  them, of course, static).
  Portability: work around i386 GCC 2.7.2.3 optimization bug triggered
  by a (really quite simple) expression in history.c.

Diffstat:
Mhistory.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/history.c b/history.c @@ -56,7 +56,7 @@ static char *newstr() { return ealloc((size_t)1024); } -static char *basename(const char *s) { +static char *rc_basename(char *s) { char *t = strrchr(s, '/'); return (t == NULL) ? s : t + 1; } @@ -175,7 +175,8 @@ start: continue; /* skip incrementing s */ case '\t': for (;; col++) { - if ((*f++ = s<end? *s++ : '\t') == '\t') { + *f = s<end? *s++ : '\t'; + if (*f++ == '\t') { col = col | 07; /* advance to before next tabstop */ } if ((col&07) == 07) /* stop before tabstop */ @@ -268,12 +269,13 @@ int main(int argc, char **argv) { int i; char *s; - s = progname = basename(argv[0]); + s = progname = rc_basename(argv[0]); me = *s++; if (*s == me) { s++; editit = TRUE; } +editit = TRUE; if (*s == 'p') { s++; printit = TRUE; @@ -329,7 +331,7 @@ next: s = getcommand(); fprintf(stderr, "%s\n", s); if (shell == NULL) shell = "/bin/sh"; - execl(shell, basename(shell), "-c", s, NULL); + execl(shell, rc_basename(shell), "-c", s, NULL); perror(shell); exit(1); }