summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ChangeLog4
-rw-r--r--src/arith.y6
-rw-r--r--src/arith_yylex.c2
-rw-r--r--src/bltin/bltin.h7
-rw-r--r--src/cd.c2
-rw-r--r--src/error.c2
-rw-r--r--src/error.h2
-rw-r--r--src/eval.c6
-rw-r--r--src/exec.c3
-rw-r--r--src/expand.c6
-rw-r--r--src/histedit.c24
-rw-r--r--src/input.c4
-rw-r--r--src/jobs.c16
-rw-r--r--src/main.c4
-rw-r--r--src/memalloc.c10
-rw-r--r--src/miscbltin.c12
-rw-r--r--src/mkinit.c4
-rw-r--r--src/mystring.c2
-rw-r--r--src/options.c14
-rw-r--r--src/parser.c2
-rw-r--r--src/redir.c10
-rw-r--r--src/trap.c2
-rw-r--r--src/var.c5
23 files changed, 75 insertions, 74 deletions
diff --git a/ChangeLog b/ChangeLog
index 275293a..d04bbde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-03-02  Herbert Xu <herbert@gondor.apana.org.au>
+
+	* Renamed symbols to avoid conflict with libc.
+
 2005-02-28  Herbert Xu <herbert@gondor.apana.org.au>
 
 	* Replaced EXEVAL with SKIPEVAL.
diff --git a/src/arith.y b/src/arith.y
index 35d012d..63a5692 100644
--- a/src/arith.y
+++ b/src/arith.y
@@ -61,7 +61,7 @@ int yyparse(void);
 void yyerror(const char *);
 #ifdef TESTARITH
 int main(int , char *[]);
-int error(char *);
+int sh_error(char *);
 #endif
 
 %}
@@ -145,7 +145,7 @@ main(argc, argv)
 {
 	printf("%d\n", exp(argv[1]));
 }
-error(s)
+sh_error(s)
 	char *s;
 {
 	fprintf(stderr, "exp: %s\n", s);
@@ -163,6 +163,6 @@ yyerror(s)
 #endif
 	yyclearin;
 	arith_lex_reset();	/* reprime lex */
-	error("arithmetic expression: %s: \"%s\"", s, arith_startbuf);
+	sh_error("arithmetic expression: %s: \"%s\"", s, arith_startbuf);
 	/* NOTREACHED */
 }
diff --git a/src/arith_yylex.c b/src/arith_yylex.c
index a9af68e..9550224 100644
--- a/src/arith_yylex.c
+++ b/src/arith_yylex.c
@@ -57,7 +57,7 @@ yylex()
 			continue;
 		default:
 err:
-			error("arith: syntax error: \"%s\"", arith_startbuf);
+			sh_error("arith: syntax error: \"%s\"", arith_startbuf);
 			/* NOTREACHED */
 		case '0':
 		case '1':
diff --git a/src/bltin/bltin.h b/src/bltin/bltin.h
index 03aace5..c8068b9 100644
--- a/src/bltin/bltin.h
+++ b/src/bltin/bltin.h
@@ -70,14 +70,9 @@
 #define ferror outerr
 #endif
 #define INITARGS(argv)
-#define	err sh_err
-#define	verr sh_verr
-#define	errx sh_errx
-#define	verrx sh_verrx
+#define	error sh_error
 #define	warn sh_warn
-#define	vwarn sh_vwarn
 #define	warnx sh_warnx
-#define	vwarnx sh_vwarnx
 #define exit sh_exit
 #define setprogname(s)
 #define getprogname() commandname
diff --git a/src/cd.c b/src/cd.c
index 1a7aaee..aa84a63 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -152,7 +152,7 @@ docd:
 			break;
 		}
 	} while (path);
-	error("can't cd to %s", dest);
+	sh_error("can't cd to %s", dest);
 	/* NOTREACHED */
 out:
 	if (flags & CD_PRINT)
diff --git a/src/error.c b/src/error.c
index d0fc0cd..7098988 100644
--- a/src/error.c
+++ b/src/error.c
@@ -178,7 +178,7 @@ exverror(int cond, const char *msg, va_list ap)
 
 
 void
-error(const char *msg, ...)
+sh_error(const char *msg, ...)
 {
 	va_list ap;
 
diff --git a/src/error.h b/src/error.h
index 4a793c5..3de25d5 100644
--- a/src/error.h
+++ b/src/error.h
@@ -137,7 +137,7 @@ void onint(void) __attribute__((__noreturn__));
 #else
 void onint(void);
 #endif
-void error(const char *, ...) __attribute__((__noreturn__));
+void sh_error(const char *, ...) __attribute__((__noreturn__));
 void exerror(int, const char *, ...) __attribute__((__noreturn__));
 const char *errmsg(int, int);
 
diff --git a/src/eval.c b/src/eval.c
index 30c9c2a..7f00b21 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -540,7 +540,7 @@ evalpipe(union node *n, int flags)
 		if (lp->next) {
 			if (pipe(pip) < 0) {
 				close(prevfd);
-				error("Pipe call failed");
+				sh_error("Pipe call failed");
 			}
 		}
 		if (forkshell(jp, lp->n, n->npipe.backgnd) == 0) {
@@ -625,7 +625,7 @@ evalbackcmd(union node *n, struct backcmd *result)
 		struct job *jp;
 
 		if (pipe(pip) < 0)
-			error("Pipe call failed");
+			sh_error("Pipe call failed");
 		jp = makejob(n, 1);
 		if (forkshell(jp, n, FORK_NOJOB) == 0) {
 			FORCEINTON;
@@ -1037,7 +1037,7 @@ breakcmd(int argc, char **argv)
 	int n = argc > 1 ? number(argv[1]) : 1;
 
 	if (n <= 0)
-		error(illnum, argv[1]);
+		sh_error(illnum, argv[1]);
 	if (n > loopnest)
 		n = loopnest;
 	if (n > 0) {
diff --git a/src/exec.c b/src/exec.c
index f43108e..72757ab 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -430,7 +430,8 @@ loop:
 			readcmdfile(fullname);
 			if ((cmdp = cmdlookup(name, 0)) == NULL ||
 			    cmdp->cmdtype != CMDFUNCTION)
-				error("%s not defined in %s", name, fullname);
+				sh_error("%s not defined in %s", name,
+					 fullname);
 			stunalloc(fullname);
 			goto success;
 		}
diff --git a/src/expand.c b/src/expand.c
index 1debde9..bc0de60 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -511,7 +511,7 @@ expari(int quotes)
 			p--;
 #ifdef DEBUG
 			if (p < start) {
-				error("missing CTLARI (shouldn't happen)");
+				sh_error("missing CTLARI (shouldn't happen)");
 			}
 #endif
 		}
@@ -1204,7 +1204,7 @@ nometa:
 			exparg.lastp = &str->next;
 			break;
 		default:	/* GLOB_NOSPACE */
-			error("Out of space");
+			sh_error("Out of space");
 		}
 		str = str->next;
 	}
@@ -1749,5 +1749,5 @@ varunset(const char *end, const char *var, const char *umsg, int varflags)
 		} else
 			msg = umsg;
 	}
-	error("%.*s: %s%s", end - var - 1, var, msg, tail);
+	sh_error("%.*s: %s%s", end - var - 1, var, msg, tail);
 }
diff --git a/src/histedit.c b/src/histedit.c
index b09900b..0d435cd 100644
--- a/src/histedit.c
+++ b/src/histedit.c
@@ -220,10 +220,10 @@ histcmd(int argc, char **argv)
 #endif
 
 	if (hist == NULL)
-		error("history not active");
+		sh_error("history not active");
 
 	if (argc == 1)
-		error("missing history argument");
+		sh_error("missing history argument");
 
 #ifdef __GLIBC__
 	optind = 0;
@@ -249,11 +249,11 @@ histcmd(int argc, char **argv)
 			sflg = 1;
 			break;
 		case ':':
-			error("option -%c expects argument", optopt);
+			sh_error("option -%c expects argument", optopt);
 			/* NOTREACHED */
 		case '?':
 		default:
-			error("unknown option: -%c", optopt);
+			sh_error("unknown option: -%c", optopt);
 			/* NOTREACHED */
 		}
 	argc -= optind, argv += optind;
@@ -280,7 +280,7 @@ histcmd(int argc, char **argv)
 		if (++active > MAXHISTLOOPS) {
 			active = 0;
 			displayhist = 0;
-			error("called recursively too many times");
+			sh_error("called recursively too many times");
 		}
 		/*
 		 * Set editor.
@@ -323,7 +323,7 @@ histcmd(int argc, char **argv)
 		laststr = argv[1];
 		break;
 	default:
-		error("too many args");
+		sh_error("too many args");
 		/* NOTREACHED */
 	}
 	/*
@@ -352,10 +352,10 @@ histcmd(int argc, char **argv)
 		INTOFF;		/* easier */
 		sprintf(editfile, "%s_shXXXXXX", _PATH_TMP);
 		if ((fd = mkstemp(editfile)) < 0)
-			error("can't create temporary file %s", editfile);
+			sh_error("can't create temporary file %s", editfile);
 		if ((efp = fdopen(fd, "w")) == NULL) {
 			close(fd);
-			error("can't allocate stdio buffer for temp");
+			sh_error("can't allocate stdio buffer for temp");
 		}
 	}
 
@@ -488,15 +488,15 @@ str_to_event(const char *str, int last)
 			}
 		}
 		if (retval == -1)
-			error("history number %s not found (internal error)",
-			       str);
+			sh_error("history number %s not found (internal error)",
+				 str);
 	} else {
 		/*
 		 * pattern
 		 */
 		retval = history(hist, &he, H_PREV_STR, str);
 		if (retval == -1)
-			error("history pattern not found: %s", str);
+			sh_error("history pattern not found: %s", str);
 	}
 	return (he.num);
 }
@@ -504,7 +504,7 @@ str_to_event(const char *str, int last)
 int
 histcmd(int argc, char **argv)
 {
-	error("not compiled with history support");
+	sh_error("not compiled with history support");
 	/* NOTREACHED */
 }
 #endif
diff --git a/src/input.c b/src/input.c
index 682ef68..86d7578 100644
--- a/src/input.c
+++ b/src/input.c
@@ -441,12 +441,12 @@ setinputfile(const char *fname, int push)
 
 	INTOFF;
 	if ((fd = open(fname, O_RDONLY)) < 0)
-		error("Can't open %s", fname);
+		sh_error("Can't open %s", fname);
 	if (fd < 10) {
 		fd2 = copyfd(fd, 10);
 		close(fd);
 		if (fd2 < 0)
-			error("Out of file descriptors");
+			sh_error("Out of file descriptors");
 		fd = fd2;
 	}
 	setinputfd(fd, push);
diff --git a/src/jobs.c b/src/jobs.c
index b82bf50..fd9ca7f 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -258,7 +258,7 @@ killcmd(argc, argv)
 
 	if (argc <= 1) {
 usage:
-		error(
+		sh_error(
 "Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or\n"
 "kill -l [exitstatus]"
 		);
@@ -281,7 +281,7 @@ usage:
 				case 's':
 					signo = decode_signal(optionarg, 1);
 					if (signo < 0) {
-						error(
+						sh_error(
 							"invalid signal number or name: %s",
 							optionarg
 						);
@@ -317,8 +317,8 @@ usage:
 		if (0 < signo && signo < NSIG)
 			outfmt(out, snlfmt, signal_names[signo]);
 		else
-			error("invalid signal number or exit status: %s",
-			      *argv);
+			sh_error("invalid signal number or exit status: %s",
+				 *argv);
 		return 0;
 	}
 
@@ -727,7 +727,7 @@ gotit:
 #endif
 	return jp;
 err:
-	error(err_msg, name);
+	sh_error(err_msg, name);
 }
 
 
@@ -869,7 +869,7 @@ forkchild(struct job *jp, union node *n, int mode)
 		if (jp->nprocs == 0) {
 			close(0);
 			if (open(_PATH_DEVNULL, O_RDONLY) != 0)
-				error("Can't open %s", _PATH_DEVNULL);
+				sh_error("Can't open %s", _PATH_DEVNULL);
 		}
 	}
 	if (!oldlvl && iflag) {
@@ -928,7 +928,7 @@ forkshell(struct job *jp, union node *n, int mode)
 		TRACE(("Fork failed, errno=%d", errno));
 		if (jp)
 			freejob(jp);
-		error("Cannot fork");
+		sh_error("Cannot fork");
 	}
 	if (pid == 0)
 		forkchild(jp, n, mode);
@@ -1470,7 +1470,7 @@ STATIC void
 xtcsetpgrp(int fd, pid_t pgrp)
 {
 	if (tcsetpgrp(fd, pgrp))
-		error("Cannot set tty process group (%s)", strerror(errno));
+		sh_error("Cannot set tty process group (%s)", strerror(errno));
 }
 
 
diff --git a/src/main.c b/src/main.c
index 3575ec4..76a75f7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -312,7 +312,7 @@ readcmdfile(char *name)
 	if ((fd = open(name, O_RDONLY)) >= 0)
 		setinputfd(fd, 1);
 	else
-		error("Can't open %s", name);
+		sh_error("Can't open %s", name);
 	INTON;
 	cmdloop(0);
 	popfile();
@@ -349,7 +349,7 @@ find_dot_file(char *basename)
 	}
 
 	/* not found in the PATH */
-	error("%s: not found", basename);
+	sh_error("%s: not found", basename);
 	/* NOTREACHED */
 }
 
diff --git a/src/memalloc.c b/src/memalloc.c
index 03ad4f7..44d94ad 100644
--- a/src/memalloc.c
+++ b/src/memalloc.c
@@ -66,7 +66,7 @@ ckmalloc(size_t nbytes)
 
 	p = malloc(nbytes);
 	if (p == NULL)
-		error("Out of space");
+		sh_error("Out of space");
 	return p;
 }
 
@@ -80,7 +80,7 @@ ckrealloc(pointer p, size_t nbytes)
 {
 	p = realloc(p, nbytes);
 	if (p == NULL)
-		error("Out of space");
+		sh_error("Out of space");
 	return p;
 }
 
@@ -94,7 +94,7 @@ savestr(const char *s)
 {
 	char *p = strdup(s);
 	if (!p)
-		error("Out of space");
+		sh_error("Out of space");
 	return p;
 }
 
@@ -141,7 +141,7 @@ stalloc(size_t nbytes)
 			blocksize = MINSIZE;
 		len = sizeof(struct stack_block) - MINSIZE + blocksize;
 		if (len < blocksize)
-			error("Out of space");
+			sh_error("Out of space");
 		INTOFF;
 		sp = ckmalloc(len);
 		sp->prev = stackp;
@@ -220,7 +220,7 @@ growstackblock(void)
 
  	newlen = stacknleft * 2;
 	if (newlen < stacknleft)
-		error("Out of space");
+		sh_error("Out of space");
 	if (newlen < 128)
 		newlen += 128;
 
diff --git a/src/miscbltin.c b/src/miscbltin.c
index 8472d79..0f2619f 100644
--- a/src/miscbltin.c
+++ b/src/miscbltin.c
@@ -113,7 +113,7 @@ readcmd(int argc, char **argv)
 #endif
 	}
 	if (*(ap = argptr) == NULL)
-		error("arg count");
+		sh_error("arg count");
 	if ((ifs = bltinlookup("IFS")) == NULL)
 		ifs = defifs;
 	status = 0;
@@ -219,7 +219,7 @@ umaskcmd(int argc, char **argv)
 			new_mask = 0;
 			do {
 				if (*ap >= '8' || *ap < '0')
-					error(illnum, *argptr);
+					sh_error(illnum, *argptr);
 				new_mask = (new_mask << 3) + (*ap - '0');
 			} while (*++ap != '\0');
 		} else {
@@ -279,7 +279,7 @@ umaskcmd(int argc, char **argv)
 					break;
 			}
 			if (*ap) {
-				error("Illegal mode: %s", *argptr);
+				sh_error("Illegal mode: %s", *argptr);
 				return 1;
 			}
 			new_mask = ~new_mask;
@@ -431,7 +431,7 @@ ulimitcmd(int argc, char **argv)
 		char *p = *argptr;
 
 		if (all || argptr[1])
-			error("too many arguments");
+			sh_error("too many arguments");
 		if (strcmp(p, "unlimited") == 0)
 			val = RLIM_INFINITY;
 		else {
@@ -444,7 +444,7 @@ ulimitcmd(int argc, char **argv)
 					break;
 			}
 			if (c)
-				error("bad number");
+				sh_error("bad number");
 			val *= l->factor;
 		}
 	}
@@ -464,7 +464,7 @@ ulimitcmd(int argc, char **argv)
 		if (how & SOFT)
 			limit.rlim_cur = val;
 		if (setrlimit(l->cmd, &limit) < 0)
-			error("error setting limit (%s)", strerror(errno));
+			sh_error("error setting limit (%s)", strerror(errno));
 	} else {
 		printlim(how, &limit, l);
 	}
diff --git a/src/mkinit.c b/src/mkinit.c
index 6e80d2d..0ead745 100644
--- a/src/mkinit.c
+++ b/src/mkinit.c
@@ -160,7 +160,7 @@ void writetext(struct text *, FILE *);
 FILE *ckfopen(char *, char *);
 void *ckmalloc(int);
 char *savestr(char *);
-void error(char *);
+static void error(char *);
 int main(int, char **);
 
 #define equal(s1, s2)	(strcmp(s1, s2) == 0)
@@ -484,7 +484,7 @@ savestr(char *s)
 	return p;
 }
 
-void
+static void
 error(char *msg)
 {
 	if (curfile != NULL)
diff --git a/src/mystring.c b/src/mystring.c
index 2ea5a1a..18163df 100644
--- a/src/mystring.c
+++ b/src/mystring.c
@@ -126,7 +126,7 @@ number(const char *s)
 {
 
 	if (! is_number(s))
-		error(illnum, s);
+		sh_error(illnum, s);
 	return atoi(s);
 }
 
diff --git a/src/options.c b/src/options.c
index 88592b6..e8c0717 100644
--- a/src/options.c
+++ b/src/options.c
@@ -150,7 +150,7 @@ procargs(int argc, char **argv)
 	xminusc = minusc;
 	if (*xargv == NULL) {
 		if (xminusc)
-			error("-c requires an argument");
+			sh_error("-c requires an argument");
 		sflag = 1;
 	}
 	if (iflag == 2 && sflag == 1 && isatty(0) && isatty(1))
@@ -265,7 +265,7 @@ minus_o(char *name, int val)
 				optlist[i] = val;
 				return;
 			}
-		error("Illegal option -o %s", name);
+		sh_error("Illegal option -o %s", name);
 	}
 }
 
@@ -287,7 +287,7 @@ setoption(int flag, int val)
 			}
 			return;
 		}
-	error("Illegal option -%c", flag);
+	sh_error("Illegal option -%c", flag);
 	/* NOTREACHED */
 }
 
@@ -351,7 +351,7 @@ shiftcmd(int argc, char **argv)
 	if (argc > 1)
 		n = number(argv[1]);
 	if (n > shellparam.nparam)
-		error("can't shift that many");
+		sh_error("can't shift that many");
 	INTOFF;
 	shellparam.nparam -= n;
 	for (ap1 = shellparam.p ; --n >= 0 ; ap1++) {
@@ -409,7 +409,7 @@ getoptscmd(int argc, char **argv)
 	char **optbase;
 
 	if (argc < 3)
-		error("Usage: getopts optstring var [arg]");
+		sh_error("Usage: getopts optstring var [arg]");
 	else if (argc == 3) {
 		optbase = shellparam.p;
 		if (shellparam.optind > shellparam.nparam + 1) {
@@ -547,13 +547,13 @@ nextopt(const char *optstring)
 	c = *p++;
 	for (q = optstring ; *q != c ; ) {
 		if (*q == '\0')
-			error("Illegal option -%c", c);
+			sh_error("Illegal option -%c", c);
 		if (*++q == ':')
 			q++;
 	}
 	if (*++q == ':') {
 		if (*p == '\0' && (p = *argptr++) == NULL)
-			error("No arg for -%c option", c);
+			sh_error("No arg for -%c option", c);
 		optionarg = p;
 		p = NULL;
 	}
diff --git a/src/parser.c b/src/parser.c
index 35a0351..eaea9d2 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1527,7 +1527,7 @@ synexpect(int token)
 STATIC void
 synerror(const char *msg)
 {
-	error("Syntax error: %s", msg);
+	sh_error("Syntax error: %s", msg);
 	/* NOTREACHED */
 }
 
diff --git a/src/redir.c b/src/redir.c
index 9bebcb6..e7bcd50 100644
--- a/src/redir.c
+++ b/src/redir.c
@@ -157,7 +157,7 @@ redirect(union node *redir, int flags)
 				if (i != EBADF) {
 					const char *m = strerror(i);
 					close(newfd);
-					error("%d: %s", fd, m);
+					sh_error("%d: %s", fd, m);
 					/* NOTREACHED */
 				}
 			} else {
@@ -238,9 +238,9 @@ openredirect(union node *redir)
 
 	return f;
 ecreate:
-	error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
+	sh_error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
 eopen:
-	error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
+	sh_error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
 }
 
 
@@ -294,7 +294,7 @@ openhere(union node *redir)
 	size_t len = 0;
 
 	if (pipe(pip) < 0)
-		error("Pipe call failed");
+		sh_error("Pipe call failed");
 	if (redir->type == NHERE) {
 		len = strlen(redir->nhere.doc->narg.text);
 		if (len <= PIPESIZE) {
@@ -401,7 +401,7 @@ copyfd(int from, int to)
 		if (errno2 == EMFILE)
 			return EMPTY;
 		else
-			error("%d: %s", from, strerror(errno2));
+			sh_error("%d: %s", from, strerror(errno2));
 	}
 	return newfd;
 }
diff --git a/src/trap.c b/src/trap.c
index 6ccca08..15ff49a 100644
--- a/src/trap.c
+++ b/src/trap.c
@@ -132,7 +132,7 @@ trapcmd(int argc, char **argv)
 		action = *ap++;
 	while (*ap) {
 		if ((signo = decode_signal(*ap, 0)) < 0)
-			error("%s: bad trap", *ap);
+			sh_error("%s: bad trap", *ap);
 		INTOFF;
 		if (action) {
 			if (action[0] == '-' && action[1] == '\0')
diff --git a/src/var.c b/src/var.c
index 0908840..3f10c46 100644
--- a/src/var.c
+++ b/src/var.c
@@ -222,7 +222,7 @@ setvar(const char *name, const char *val, int flags)
 	p = strchrnul(q, '=');
 	namelen = p - name;
 	if (!namelen || p != q)
-		error("%.*s: bad variable name", namelen, name);
+		sh_error("%.*s: bad variable name", namelen, name);
 	vallen = 0;
 	if (val == NULL) {
 		flags |= VUNSET;
@@ -266,7 +266,8 @@ setvareq(char *s, int flags)
 			if (flags & VNOSAVE)
 				free(s);
 			n = vp->text;
-			error("%.*s: is read only", strchrnul(n, '=') - n, n);
+			sh_error("%.*s: is read only", strchrnul(n, '=') - n,
+				 n);
 		}
 
 		if (flags & VNOSET)