comparison main.c @ 105:600f36cd7353

don't use getprogname() in the name of portability
author David A. Holland
date Tue, 11 Jun 2013 11:24:48 -0400
parents 51848a7584e0
children 2b0b61fd1a36
comparison
equal deleted inserted replaced
104:91f600e6647b 105:600f36cd7353
871 return false; 871 return false;
872 } 872 }
873 873
874 DEAD static 874 DEAD static
875 void 875 void
876 usage(void) 876 usage(const char *argv0)
877 { 877 {
878 fprintf(stderr, "Usage: %s [options] [infile [outfile]]\n", 878 const char *progname;
879 getprogname()); 879
880 progname = strrchr(argv0, '/');
881 progname = progname == NULL ? argv0 : progname + 1;
882
883 fprintf(stderr, "Usage: %s [options] [infile [outfile]]\n", progname);
880 fprintf(stderr, "Common options:\n"); 884 fprintf(stderr, "Common options:\n");
881 fprintf(stderr, " -C Retain comments\n"); 885 fprintf(stderr, " -C Retain comments\n");
882 fprintf(stderr, " -Dmacro[=def] Predefine macro\n"); 886 fprintf(stderr, " -Dmacro[=def] Predefine macro\n");
883 fprintf(stderr, " -Idir Add to include path\n"); 887 fprintf(stderr, " -Idir Add to include path\n");
884 fprintf(stderr, " -M Issue depend info\n"); 888 fprintf(stderr, " -M Issue depend info\n");
981 place_setcommandline(&cmdplace, i+1, 1); 985 place_setcommandline(&cmdplace, i+1, 1);
982 if (check_arg_option(argv[i]+1, &cmdplace, argv[i+1])) { 986 if (check_arg_option(argv[i]+1, &cmdplace, argv[i+1])) {
983 i++; 987 i++;
984 continue; 988 continue;
985 } 989 }
986 usage(); 990 usage(argv[0]);
987 } 991 }
988 if (i < argc) { 992 if (i < argc) {
989 inputfile = argv[i++]; 993 inputfile = argv[i++];
990 } 994 }
991 if (i < argc) { 995 if (i < argc) {
992 outputfile = argv[i++]; 996 outputfile = argv[i++];
993 } 997 }
994 if (i < argc) { 998 if (i < argc) {
995 usage(); 999 usage(argv[0]);
996 } 1000 }
997 1001
998 mode.output_file = outputfile; 1002 mode.output_file = outputfile;
999 1003
1000 loadincludepath(); 1004 loadincludepath();