Skip to content

Commit 35e6a0c

Browse files
committed
Use PROGNAME_CPP for the binary name
1 parent 4591837 commit 35e6a0c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/main.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#include <errno.h>
2525
#include "CPP.h"
2626

27+
#ifndef PROGNAME_CPP
28+
# define PROGNAME_CPP "cpp"
29+
#endif
30+
2731

2832
/* cpp */
2933
/* private */
@@ -62,13 +66,13 @@ static int _cpp(Prefs * prefs, int filec, char * filev[])
6266
if(prefs->outfile == NULL)
6367
fp = stdout;
6468
else if((fp = fopen(prefs->outfile, "w")) == NULL)
65-
return error_set_print("cpp", 1, "%s: %s", prefs->outfile,
66-
strerror(errno));
69+
return error_set_print(PROGNAME_CPP, 1, "%s: %s",
70+
prefs->outfile, strerror(errno));
6771
for(i = 0; i < filec; i++)
6872
ret |= _cpp_do(prefs, fp, filev[i]);
6973
if(fclose(fp) != 0)
70-
return error_set_print("cpp", 1, "%s: %s", prefs->outfile,
71-
strerror(errno));
74+
return error_set_print(PROGNAME_CPP, 1, "%s: %s",
75+
prefs->outfile, strerror(errno));
7276
return ret;
7377
}
7478

@@ -143,15 +147,15 @@ static void _do_print_token(FILE * fp, Token * token)
143147
/* cpp_error */
144148
static int _cpp_error(void)
145149
{
146-
return error_print("cpp");
150+
return error_print(PROGNAME_CPP);
147151
}
148152

149153

150154
/* usage */
151155
/* FIXME -E prints metadata? */
152156
static int _usage(void)
153157
{
154-
fputs("Usage: cpp [-D name[=value]]...[-I directory][-o file][-t][-U name]... input...\n"
158+
fputs("Usage: " PROGNAME_CPP " [-D name[=value]]...[-I directory][-o file][-t][-U name]... input...\n"
155159
" -D Add a substitution\n"
156160
" -I Add a directory to the search path\n"
157161
" -o Write output to a file\n"
@@ -218,7 +222,7 @@ static int _main_add_define(Prefs * prefs, char * define)
218222
value = strtok(define, "=");
219223
if((p = realloc(prefs->defines, sizeof(*p) * (prefs->defines_cnt + 1)))
220224
== NULL)
221-
return error_set_print("cpp", 1, "%s", strerror(errno));
225+
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
222226
prefs->defines = p;
223227
prefs->defines[prefs->defines_cnt++] = define;
224228
return 0;
@@ -230,7 +234,7 @@ static int _main_add_path(Prefs * prefs, char const * path)
230234

231235
if((p = realloc(prefs->paths, sizeof(*p) * (prefs->paths_cnt + 1)))
232236
== NULL)
233-
return error_set_print("cpp", 1, "%s", strerror(errno));
237+
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
234238
prefs->paths = p;
235239
prefs->paths[prefs->paths_cnt++] = path;
236240
return 0;
@@ -244,7 +248,7 @@ static int _main_add_undefine(Prefs * prefs, char const * undefine)
244248
return 1;
245249
if((p = realloc(prefs->undefines, sizeof(*p)
246250
* (prefs->undefines_cnt + 1))) == NULL)
247-
return error_set_print("cpp", 1, "%s", strerror(errno));
251+
return error_set_print(PROGNAME_CPP, 1, "%s", strerror(errno));
248252
prefs->undefines = p;
249253
prefs->undefines[prefs->undefines_cnt++] = undefine;
250254
return 0;

0 commit comments

Comments
 (0)