OSDN Git Service

cmdutils: allow ':'-separated modifiers in option names.
authorAnton Khirnov <anton@khirnov.net>
Fri, 29 Jul 2011 11:47:37 +0000 (13:47 +0200)
committerAnton Khirnov <anton@khirnov.net>
Fri, 12 Aug 2011 11:51:30 +0000 (13:51 +0200)
cmdutils.c

index d3fdae7..1df2556 100644 (file)
@@ -141,8 +141,11 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, int
 }
 
 static const OptionDef* find_option(const OptionDef *po, const char *name){
+    const char *p = strchr(name, ':');
+    int len = p ? p - name : strlen(name);
+
     while (po->name != NULL) {
-        if (!strcmp(name, po->name))
+        if (!strncmp(name, po->name, len) && strlen(po->name) == len)
             break;
         po++;
     }