Browse Source

Overload str_number().

Allow passing the bogus pointer to str_number() in case we want to
inspect it later.
Iain Patterson 10 years ago
parent
commit
03f6899464
2 changed files with 9 additions and 4 deletions
  1. 8 4
      nssm.cpp
  2. 1 0
      nssm.h

+ 8 - 4
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);

+ 1 - 0
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);