From: Iain Patterson Date: Tue, 7 Jan 2014 19:02:36 +0000 (+0000) Subject: Overload str_number(). X-Git-Tag: v2.22~76 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=03f6899464b863fc2dd05e7c8e5047e0c1b9281d;p=nssm.git Overload str_number(). Allow passing the bogus pointer to str_number() in case we want to inspect it later. --- diff --git a/nssm.cpp b/nssm.cpp index 32f1142..9f3174f 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -13,16 +13,20 @@ int str_equiv(const TCHAR *a, const TCHAR *b) { } /* Convert a string to a number. */ -int str_number(const TCHAR *string, unsigned long *number) { +int str_number(const TCHAR *string, unsigned long *number, TCHAR **bogus) { if (! string) return 1; - TCHAR *bogus; - *number = _tcstoul(string, &bogus, 0); - if (*bogus) return 2; + *number = _tcstoul(string, bogus, 0); + if (**bogus) return 2; return 0; } +int str_number(const TCHAR *string, unsigned long *number) { + TCHAR *bogus; + return str_number(string, number, &bogus); +} + /* Remove basename of a path. */ void strip_basename(TCHAR *buffer) { size_t len = _tcslen(buffer); diff --git a/nssm.h b/nssm.h index 70d5396..d50e9d6 100644 --- a/nssm.h +++ b/nssm.h @@ -19,6 +19,7 @@ int str_equiv(const TCHAR *, const TCHAR *); void strip_basename(TCHAR *); +int str_number(const TCHAR *, unsigned long *, TCHAR **); int str_number(const TCHAR *, unsigned long *); int usage(int);