From 38e6fa7f14f116cb729df46db032239cf80c1fb3 Mon Sep 17 00:00:00 2001 From: Daniel Reimer Date: Sat, 18 Jan 2014 12:03:34 +0000 Subject: [PATCH] [LOG2LINES] Improve Log2lines.exe help usage by Victor Martinez Calvo CORE-7427 #resolve svn path=/trunk/; revision=61670 --- reactos/tools/log2lines/log2lines.c | 6 ++++-- reactos/tools/log2lines/options.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/reactos/tools/log2lines/log2lines.c b/reactos/tools/log2lines/log2lines.c index c00cfd378b5..b771a41ff01 100644 --- a/reactos/tools/log2lines/log2lines.c +++ b/reactos/tools/log2lines/log2lines.c @@ -566,6 +566,7 @@ int main(int argc, const char **argv) { int res = 0; + int optInit = 0; int optCount = 0; dbgIn = stdin; @@ -579,9 +580,10 @@ main(int argc, const char **argv) 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; } diff --git a/reactos/tools/log2lines/options.c b/reactos/tools/log2lines/options.c index 5bdefbc69b3..7de58ff7f77 100644 --- a/reactos/tools/log2lines/options.c +++ b/reactos/tools/log2lines/options.c @@ -46,6 +46,9 @@ char opt_7z[PATH_MAX]; // -z 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 @@ int optionInit(int argc, const char **argv) 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 @@ int optionInit(int argc, const char **argv) break; } } + strcat(opt_scanned, argv[i]); strcat(opt_scanned, " "); }