Don't mangle the input to split_hook_name().
[nssm.git] / settings.cpp
index a144f3c..c825fbc 100644 (file)
@@ -3,6 +3,8 @@
 \r
 /* Affinity. */\r
 #define NSSM_AFFINITY_ALL _T("All")\r
+/* Default value. */\r
+#define NSSM_DEFAULT_STRING _T("Default")\r
 \r
 extern const TCHAR *exit_action_strings[];\r
 extern const TCHAR *startup_strings[];\r
@@ -12,7 +14,7 @@ extern const TCHAR *hook_action_strings[];
 \r
 /* Does the parameter refer to the default value of the setting? */\r
 static inline int is_default(const TCHAR *value) {\r
-  return (str_equiv(value, _T("default")) || str_equiv(value, _T("*")) || ! value[0]);\r
+  return (str_equiv(value, NSSM_DEFAULT_STRING) || str_equiv(value, _T("*")) || ! value[0]);\r
 }\r
 \r
 static int value_from_string(const TCHAR *name, value_t *value, const TCHAR *string) {\r
@@ -195,7 +197,8 @@ static inline bool split_hook_name(const TCHAR *hook_name, TCHAR *hook_event, TC
     if (*s == _T('/')) {\r
       *s = _T('\0');\r
       _sntprintf_s(hook_event, HOOK_NAME_LENGTH, _TRUNCATE, _T("%s"), hook_name);\r
-      _sntprintf_s(hook_action, HOOK_NAME_LENGTH, _TRUNCATE, _T("%s"), ++s);\r
+      *s++ = _T('/');\r
+      _sntprintf_s(hook_action, HOOK_NAME_LENGTH, _TRUNCATE, _T("%s"), s);\r
       return valid_hook_name(hook_event, hook_action, false);\r
     }\r
   }\r