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 */
144148static 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? */
152156static 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