[hackers] [scc] [cc1] fix and refactor the tool name check || Quentin Rameau
commit 33e76ce23d79e16f3e4bc0abfcb62e2e43c1845a
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sat Jun 18 14:19:19 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Sat Jun 18 14:19:19 2016 +0200
[cc1] fix and refactor the tool name check
Don't use argv0 which is not set before ARGBEGIN.
diff --git a/cc1/main.c b/cc1/main.c
index d7fa487..50b2651 100644
--- a/cc1/main.c
+++ b/cc1/main.c
_AT_@ -15,7 +15,7 @@ char *argv0;
int warnings;
jmp_buf recover;
-static char *base, *output;
+static char *name, *output;
static struct items uflags;
int onlycpp;
_AT_@ -31,7 +31,7 @@ clean(void)
static void
usage(void)
{
- die(!strcmp(base, "cpp") ?
+ die(!strcmp(name, "cpp") ?
"usage: cpp [-wd] [-D def[=val]]... [-U def]... [-I dir]... "
"[input]" :
"usage: cc1 [-Ewd] [-D def[=val]]... [-U def]... [-I dir]... "
_AT_@ -41,17 +41,14 @@ usage(void)
int
main(int argc, char *argv[])
{
- char *base;
+ char *cp;
int i;
atexit(clean);
icpp();
/* if run as cpp, only run the preprocessor */
- if ((base = strrchr(argv0, '/')))
- ++base;
- else
- base = argv0;
+ name = (cp = strrchr(*argv, '/')) ? cp + 1 : *argv;
ARGBEGIN {
case 'D':
_AT_@ -85,7 +82,7 @@ main(int argc, char *argv[])
if (output && !freopen(output, "w", stdout))
die("error opening output: %s", strerror(errno));
- if (!strcmp(base, "cpp"))
+ if (!strcmp(name, "cpp"))
onlycpp = 1;
for (i = 0; i < uflags.n; ++i)
Received on Tue Jun 21 2016 - 08:32:07 CEST
This archive was generated by hypermail 2.3.0
: Tue Jun 21 2016 - 08:36:18 CEST