hdt: Fixing automatic mode parsing
authorErwan Velu <erwanaliasr1@gmail.com>
Mon, 18 Apr 2011 20:37:15 +0000 (22:37 +0200)
committerErwan Velu <erwanaliasr1@gmail.com>
Mon, 18 Apr 2011 21:06:02 +0000 (23:06 +0200)
Parsing of the auto='' mode was weak an non functionnal in many
configuration like

auto='dump'

This is now fixed.

com32/hdt/hdt-common.c
com32/hdt/hdt-common.h

index f475399..aac50eb 100644 (file)
@@ -121,25 +121,19 @@ void detect_parameters(const int argc, const char *argv[],
             */
 
            automode=true;
+           char *argument = (char*)argv[i]+6;
            /* Extracting the first parameter */
-           strcpy(hardware->auto_label, argv[i] + 6);
-           strcat(hardware->auto_label, " ");
-           char *pos;
-           i++;
+           strcpy(hardware->auto_label, argument);
 
            /* While we can't find the other AUTO_DELIMITER, let's process the argv[] */
-           while (((pos = strstr(argv[i], AUTO_DELIMITER)) == NULL)
-                  && (i < argc)) {
-               strcat(hardware->auto_label, argv[i]);
-               strcat(hardware->auto_label, " ");
+           while ((strchr(argument, AUTO_DELIMITER) == NULL) && (i+1<argc)) {
                i++;
-           }
+               argument = (char *)argv[i];
+               strcat(hardware->auto_label, " ");
+               strcat(hardware->auto_label, argument);
+           } 
 
-           /* If we didn't reach the end of the line, let's grab the last item */
-           if (i < argc) {
-               strcat(hardware->auto_label, argv[i]);
-               hardware->auto_label[strlen(hardware->auto_label) - 1] = 0;
-           }
+            hardware->auto_label[strlen(hardware->auto_label) - 1] = 0;
        }
     }
 }
index 3b63877..d37fcc8 100644 (file)
@@ -73,7 +73,7 @@
 /* The char that separate two commands */
 #define AUTO_SEPARATOR ";"
 /* The char that surround the list of commands */
-#define AUTO_DELIMITER "'"
+#define AUTO_DELIMITER '\'' 
 
 /* Graphic to load in background when using the vesa mode */
 #define CLI_DEFAULT_BACKGROUND "backgnd.png"