Author: dreimer Date: Sat Jan 18 12:03:34 2014 New Revision: 61670
URL: http://svn.reactos.org/svn/reactos?rev=61670&view=rev Log: [LOG2LINES] Improve Log2lines.exe help usage by Victor Martinez Calvo CORE-7427 #resolve
Modified: trunk/reactos/tools/log2lines/log2lines.c trunk/reactos/tools/log2lines/options.c
Modified: trunk/reactos/tools/log2lines/log2lines.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/log2lines.c... ============================================================================== --- trunk/reactos/tools/log2lines/log2lines.c [iso-8859-1] (original) +++ trunk/reactos/tools/log2lines/log2lines.c [iso-8859-1] Sat Jan 18 12:03:34 2014 @@ -566,6 +566,7 @@ main(int argc, const char **argv) { int res = 0; + int optInit = 0; int optCount = 0;
dbgIn = stdin; @@ -579,9 +580,10 @@ memset(&revinfo, 0, sizeof(REVINFO)); clearLastLine();
- optionInit(argc, argv); + optInit = optionInit(argc, argv); optCount = optionParse(argc, argv); - if (optCount < 0) + + if (optCount < 0 || optInit < 0) { return optCount; }
Modified: trunk/reactos/tools/log2lines/options.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/log2lines/options.c?r... ============================================================================== --- trunk/reactos/tools/log2lines/options.c [iso-8859-1] (original) +++ trunk/reactos/tools/log2lines/options.c [iso-8859-1] Sat Jan 18 12:03:34 2014 @@ -46,6 +46,9 @@ char opt_scanned[LINESIZE]; // all scanned options char opt_SourcesPath[LINESIZE]; //sources path
+/* optionInit returns 0 for normal operation, and -1 in case just "loglines.exe" was written. +In such case, the help is shown */ + int optionInit(int argc, const char **argv) { int i; @@ -64,8 +67,20 @@ l2l_dbg(1, "Trunk build revision: %d\n", revinfo.buildrev);
strcpy(opt_scanned, ""); + + //The user introduced "log2lines.exe" or "log2lines.exe /?" + //Let's help the user + if ((argc == 1) || + ((argc == 2) && (argv[1][0] == '/') && (argv[1][1] == '?'))) + { + opt_help++; + usage(1); + return -1; + } + for (i = 1; i < argc; i++) { + if ((argv[i][0] == '-') && (i+1 < argc)) { //Because these arguments can contain spaces we cant use getopt(), a known bug: @@ -90,6 +105,7 @@ break; } } + strcat(opt_scanned, argv[i]); strcat(opt_scanned, " "); }