# HG changeset patch # User Matti Hamalainen # Date 1403410006 -10800 # Node ID c22caa6e3fcb72c223871b1934a785dc841c51de # Parent 37bf3d8766b79ed10c3aca2e534a8ecbf3ca6538 Cosmetics. diff -r 37bf3d8766b7 -r c22caa6e3fcb th_args.c --- a/th_args.c Sun Jun 22 06:20:26 2014 +0300 +++ b/th_args.c Sun Jun 22 07:06:46 2014 +0300 @@ -1,7 +1,7 @@ /* * Simple commandline argument processing * Programmed and designed by Matti 'ccr' Hamalainen - * (C) Copyright 2002-2012 Tecnic Software productions (TNSP) + * (C) Copyright 2002-2008 Tecnic Software productions (TNSP) * * Please read file 'COPYING' for information on license and distribution. */ @@ -161,27 +161,27 @@ int optN; BOOL isFound; - /* Short options can be combined: -a -b -c == -abc */ + // Short options can be combined: -a -b -c == -abc while (*tmpArg) { for (optN = 0, isFound = FALSE; (optN < optListN) && !isFound; optN++) if (*tmpArg == optList[optN].optShort) { - /* Get possible option argument, if needed */ + // Get possible option argument, if needed if ((optList[optN].flags & OPT_ARGMASK) != 0 && (++(*newArgIndex) < argc)) optArg = argv[*newArgIndex]; else optArg = NULL; - /* Check if option argument is required */ + // Check if option argument is required if (!th_args_check_arg(&optList[optN], optArg)) return FALSE; else { char tmpStr[2] = { 0, 0 }; - /* Option was given succesfully, try to handle it */ + // Option was given succesfully, try to handle it wasGiven[optN] = TRUE; tmpStr[0] = *tmpArg; @@ -221,8 +221,8 @@ (void) argv; (void) newArgIndex; - /* Long option */ - for (optN = -1, optLen = i = 0; (i < optListN) && (optN < 0); i++) + // Long option + for (optN = -1, optLen = i = 0; i < optListN && optN < 0; i++) if (optList[i].optLong) { optLen = strlen(optList[i].optLong); @@ -230,7 +230,7 @@ optN = i; } - /* Get possible option argument, if needed */ + // Get possible option argument, if needed if (optN >= 0) { if ((optList[optN].flags & OPT_ARGMASK) != 0) @@ -238,12 +238,12 @@ else optArg = NULL; - /* Check if option argument is required */ + // Check if option argument is required if (!th_args_check_arg(&optList[optN], optArg)) return FALSE; else { - /* Option was given succesfully, try to handle it */ + // Option was given succesfully, try to handle it wasGiven[optN] = TRUE; if (!handleOpt(optList[optN].id, optArg, currArg)) return FALSE; @@ -272,7 +272,7 @@ char *currArg; BOOL *wasGiven; - /* Allocate wasGiven */ + // Allocate wasGiven wasGiven = (BOOL *) th_calloc(optListN, sizeof(BOOL)); if (!wasGiven) { @@ -280,7 +280,7 @@ exit(128); } - /* Parse arguments */ + // Parse arguments argIndex = 1; optionsOK = TRUE; endOptions = FALSE; @@ -293,7 +293,7 @@ currArg++; if (*currArg == '-') { - /* Check for "--", which ends the options-list */ + // Check for "--", which ends the options-list currArg++; if (*currArg == 0) { @@ -301,7 +301,7 @@ continue; } - /* Long options */ + // Long options if (!th_args_process_long(currArg, &newArgIndex, wasGiven, argc, argv, optList, optListN, handleOpt)) @@ -309,7 +309,7 @@ } else { - /* Short options */ + // Short options if (!th_args_process_short(currArg, &newArgIndex, wasGiven, argc, argv, optList, optListN, handleOpt)) @@ -320,7 +320,7 @@ } else { - /* Was not option argument */ + // Was not option argument if (handleNonOption == NULL || (handleNonOption != NULL && !handleNonOption(currArg))) { @@ -329,7 +329,7 @@ } } - /* Check if we bail out on invalid argument */ + // Check if we bail out on invalid argument if (!optionsOK && bailOut) { th_free(wasGiven); @@ -339,7 +339,7 @@ argIndex++; } - /* Check wasGiven by isRequired */ + // Check wasGiven by isRequired for (i = 0; i < optListN; i++) if ((optList[i].flags & OPT_REQUIRED) != 0 && !wasGiven[i]) { @@ -366,13 +366,13 @@ { optarg_t *o = &optList[i]; - /* Print short option */ + // Print short option if (o->optShort != 0) fprintf(outFile, " -%c, ", o->optShort); else fprintf(outFile, " "); - /* Print long option */ + // Print long option if (o->optLong) { char tmpStr[64], *p;