[LOG2LINES]

Improve Log2lines.exe help usage by Victor Martinez Calvo
CORE-7427 #resolve

svn path=/trunk/; revision=61670
This commit is contained in:
Daniel Reimer 2014-01-18 12:03:34 +00:00
parent aaf0f8ce65
commit 38e6fa7f14
2 changed files with 20 additions and 2 deletions

View file

@ -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;
}

View file

@ -46,6 +46,9 @@ char opt_7z[PATH_MAX]; // -z <opt_7z>
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, " ");
}