From 5461aa13d63cdd6755b34bb2e4938855441ce95f Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2024 11:29:50 +0100 Subject: [PATCH] wmclockmon: update `getbool` not to modify its argument Signed-off-by: Jeremy Sowden --- wmclockmon/wmclockmon-cal/tools.c | 16 +++++++--------- wmclockmon/wmclockmon-cal/tools.h | 2 +- wmclockmon/wmclockmon-config/tools.c | 16 +++++++--------- wmclockmon/wmclockmon-config/tools.h | 2 +- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/wmclockmon/wmclockmon-cal/tools.c b/wmclockmon/wmclockmon-cal/tools.c index 5410298..a2455f5 100644 --- a/wmclockmon/wmclockmon-cal/tools.c +++ b/wmclockmon/wmclockmon-cal/tools.c @@ -36,17 +36,15 @@ char *xstrdup(const char *string) { } -int getbool(char *value) { - int i; - for (i = 0 ; value[i] ; i++) value[i] = tolower(value[i]); +int getbool(const char *value) { if (strcmp(value, "0") == 0) return FALSE; if (strcmp(value, "1") == 0) return TRUE; - if (strcmp(value, "true") == 0) return TRUE; - if (strcmp(value, "false") == 0) return FALSE; - if (strcmp(value, "yes") == 0) return TRUE; - if (strcmp(value, "no") == 0) return FALSE; - if (strcmp(value, "on") == 0) return TRUE; - if (strcmp(value, "off") == 0) return FALSE; + if (strcasecmp(value, "true") == 0) return TRUE; + if (strcasecmp(value, "false") == 0) return FALSE; + if (strcasecmp(value, "yes") == 0) return TRUE; + if (strcasecmp(value, "no") == 0) return FALSE; + if (strcasecmp(value, "on") == 0) return TRUE; + if (strcasecmp(value, "off") == 0) return FALSE; printf("Error in converting \"%s\" to boolean value.\n", value); return FALSE; } diff --git a/wmclockmon/wmclockmon-cal/tools.h b/wmclockmon/wmclockmon-cal/tools.h index 9607806..f32d54b 100644 --- a/wmclockmon/wmclockmon-cal/tools.h +++ b/wmclockmon/wmclockmon-cal/tools.h @@ -12,7 +12,7 @@ void *xmalloc(size_t size); char *xstrdup(const char *string); -int getbool(char *value); +int getbool(const char *value); char *robust_home(); char *get_file(const char *datestr); diff --git a/wmclockmon/wmclockmon-config/tools.c b/wmclockmon/wmclockmon-config/tools.c index a44f200..5d88642 100644 --- a/wmclockmon/wmclockmon-config/tools.c +++ b/wmclockmon/wmclockmon-config/tools.c @@ -94,17 +94,15 @@ char *xstrdup(const char *string) { } -int getbool(char *value) { - int i; - for (i = 0 ; value[i] ; i++) value[i] = tolower(value[i]); +int getbool(const char *value) { if (strcmp(value, "0") == 0) return FALSE; if (strcmp(value, "1") == 0) return TRUE; - if (strcmp(value, "true") == 0) return TRUE; - if (strcmp(value, "false") == 0) return FALSE; - if (strcmp(value, "yes") == 0) return TRUE; - if (strcmp(value, "no") == 0) return FALSE; - if (strcmp(value, "on") == 0) return TRUE; - if (strcmp(value, "off") == 0) return FALSE; + if (strcasecmp(value, "true") == 0) return TRUE; + if (strcasecmp(value, "false") == 0) return FALSE; + if (strcasecmp(value, "yes") == 0) return TRUE; + if (strcasecmp(value, "no") == 0) return FALSE; + if (strcasecmp(value, "on") == 0) return TRUE; + if (strcasecmp(value, "off") == 0) return FALSE; printf("Error in converting \"%s\" to boolean value.\n", value); return FALSE; } diff --git a/wmclockmon/wmclockmon-config/tools.h b/wmclockmon/wmclockmon-config/tools.h index 1725188..3ff2bae 100644 --- a/wmclockmon/wmclockmon-config/tools.h +++ b/wmclockmon/wmclockmon-config/tools.h @@ -14,7 +14,7 @@ void alrm_add(Alarm **list, const char *value); void free_alrm(Alarm **list); void *xmalloc(size_t size); char *xstrdup(const char *string); -int getbool(char *value); +int getbool(const char *value); void load_cfgfile(); char *robust_home(); void save_cfgfile(); -- 2.11.4.GIT