summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortgoodwin <tgoodwin>1998-10-30 16:07:02 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:13 +0100
commita1f1ee9b27d08644061bc440b779f99c3e9362f0 (patch)
treec97701925be98cde60f189a45bc224fa2e903a79
parentc1959b3d914f52bf0c00523e360aece68d9076d3 (diff)
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.
-rw-r--r--history.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/history.c b/history.c
index d1035dd..a4d3016 100644
--- 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);
}