changeset 128:c22caa6e3fcb

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 22 Jun 2014 07:06:46 +0300
parents 37bf3d8766b7
children aa2d608fb3f3
files th_args.c
diffstat 1 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- 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;