# HG changeset patch # User Mike Becker # Date 1316157299 -7200 # Node ID 902cb8d2053c9d0c98d37bc46cd0f02bcdd49a73 # Parent 06cbd0ec003dc6abd712f44b97668e2bf0a208b2 removed dynamic programm name diff -r 06cbd0ec003d -r 902cb8d2053c .cproject --- a/.cproject Thu Sep 15 13:38:03 2011 +0200 +++ b/.cproject Fri Sep 16 09:14:59 2011 +0200 @@ -60,4 +60,24 @@ + + + + make + + all + true + true + false + + + make + + clean + true + true + false + + + diff -r 06cbd0ec003d -r 902cb8d2053c cline.c --- a/cline.c Thu Sep 15 13:38:03 2011 +0200 +++ b/cline.c Fri Sep 16 09:14:59 2011 +0200 @@ -8,13 +8,14 @@ #include "cline.h" #include "scanner.h" #include "settings.h" +#include "arguments.h" -void printHelpText(const char* prgName) { +void printHelpText() { // Help text const char* helpText = "\nUsage:" - "\n %s [-hrm][-s suffix][]" - "\n %s [-hrm][-S suffix][]" + "\n cline [-hrm][-s suffix][]" + "\n cline [-hrm][-S suffix][]" "\n\nCounts the line terminator characters (\\n) within all" " files in the specified\ndirectory." "\n\nOptions:" @@ -27,16 +28,16 @@ "\n -r, -R - includes subdirectories" "\n\n" "The default call without any options is:" - "\n %s ./\n" + "\n cline ./\n" "So each file in the working directory is counted. If you want to count C" "\nsource code in your working directory and its subdirectories, type:" - "\n %s -rs .c\n"; + "\n cline -rs .c\n"; - printf(helpText, prgName, prgName, prgName, prgName); + printf(helpText); } -int exit_with_help(char* prgName, settings_t* settings, int code) { - printHelpText(prgName); +int exit_with_help(settings_t* settings, int code) { + printHelpText(); destroy_settings_t(settings); return code; } @@ -50,15 +51,6 @@ return 1; } - // Program name - char* prgName = strrchr(argv[0], settings->fileSeparator); - - if (prgName == NULL) { - prgName = argv[0]; - } else { - prgName++; - } - // Get arguments char* directory = "./"; char* suffix = " "; @@ -72,49 +64,49 @@ // s if ((argflags & 2) > 0) { if (registerArgument(&checked, 6)) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } settings->includeSuffixes = true; t++; if (t >= argc) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } suffix = argv[t]; } // S if ((argflags & 4) > 0) { if (registerArgument(&checked, 6)) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } settings->includeSuffixes = false; t++; if (t >= argc) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } suffix = argv[t]; } // h if ((argflags & 1) > 0 || strcmp(argv[t], "--help") == 0) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } // r, R if ((argflags & 24) > 0) { if (registerArgument(&checked, 24)) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } settings->recursive = true; } // m if ((argflags & 32) > 0) { if (registerArgument(&checked, 32)) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } settings->matchesOnly = true; } // Path if (argflags == 0) { if (registerArgument(&checked, 1024)) { - return exit_with_help(prgName, settings, 1); + return exit_with_help(settings, 1); } directory = argv[t]; } diff -r 06cbd0ec003d -r 902cb8d2053c cline.h --- a/cline.h Thu Sep 15 13:38:03 2011 +0200 +++ b/cline.h Fri Sep 16 09:14:59 2011 +0200 @@ -15,8 +15,8 @@ extern "C" { #endif -void printHelpText(const char*); -int exit_with_help(char*, settings_t*, int); +void printHelpText(); +int exit_with_help(settings_t*, int); #ifdef _cplusplus }