diff --git a/shlr/sdb/src/query.c b/shlr/sdb/src/query.c index c9443018ac..d1fec6feb1 100644 --- a/shlr/sdb/src/query.c +++ b/shlr/sdb/src/query.c @@ -1,4 +1,4 @@ -/* sdb - LGPLv3 - Copyright 2011-2014 - pancake */ +/* sdb - LGPLv3 - Copyright 2011-2015 - pancake */ #include #include @@ -161,13 +161,16 @@ SDB_API char *sdb_querys (Sdb *r, char *buf, size_t len, const char *_cmd) { } else { if (len<1 || !buf) { bufset = 1; - buf = malloc ((len=64)); + buf = malloc ((len = 64)); } cmd = buf; } // if cmd is null, we take buf as cmd next = NULL; repeat: + /* skip spaces */ + while (*cmd && (*cmd == ' ' || *cmd == '\t')) + cmd++; s = r; p = cmd; eq = NULL; @@ -176,7 +179,7 @@ repeat: quot = NULL; json = NULL; if (next) *next = ';'; - if (*p=='%') { + if (*p == '%') { encode = 1; cmd++; p++; @@ -197,7 +200,7 @@ repeat: d = 0; } if (!is_ref) { - next = strchr (val?val:cmd, ';'); //val?val:cmd, ';'); + next = strchr (val? val: cmd, ';'); } //if (!val) val = eq; if (!is_ref && val && *val == '"') { diff --git a/shlr/sdb/src/util.c b/shlr/sdb/src/util.c index d8ce1c61f2..3374296da4 100644 --- a/shlr/sdb/src/util.c +++ b/shlr/sdb/src/util.c @@ -74,9 +74,7 @@ SDB_API ut64 sdb_atoi(const char *s) { ut64 ret; if (!s || *s=='-') return 0LL; - ret = !strncmp (s, "0x", 2)? - strtoull (s+2, &p, 16): - strtoull (s, &p, 10); + ret = strtoull (s, &p, 0); if (!p) return 0LL; return ret; }