From 03f6899464b863fc2dd05e7c8e5047e0c1b9281d Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 7 Jan 2014 19:02:36 +0000 Subject: [PATCH] Overload str_number(). Allow passing the bogus pointer to str_number() in case we want to inspect it later. --- nssm.cpp | 12 ++++++++---- nssm.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) 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); -- 2.20.1