summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 5af57feb11..6be9f8f010 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -945,7 +945,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
945 const char* p = str, *f = fmt; 945 const char* p = str, *f = fmt;
946 const char** s; 946 const char** s;
947 int* d; 947 int* d;
948 bool set; 948 bool set, is_negative;
949 int i=0; 949 int i=0;
950 950
951 va_start(ap, str); 951 va_start(ap, str);
@@ -973,7 +973,13 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
973 break; 973 break;
974 974
975 case 'd': /* int */ 975 case 'd': /* int */
976 is_negative = false;
976 d = va_arg(ap, int*); 977 d = va_arg(ap, int*);
978 if (*p == '-' && isdigit(*(p+1)))
979 {
980 is_negative = true;
981 p++;
982 }
977 if (!isdigit(*p)) 983 if (!isdigit(*p))
978 { 984 {
979 if (!set_vals || *p != '-') 985 if (!set_vals || *p != '-')
@@ -987,6 +993,8 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
987 while (isdigit(*p)) 993 while (isdigit(*p))
988 *d = (*d * 10) + (*p++ - '0'); 994 *d = (*d * 10) + (*p++ - '0');
989 set = true; 995 set = true;
996 if (is_negative)
997 *d *= -1;
990 } 998 }
991 999
992 break; 1000 break;