From 87b83c757f7d249f983410e85d13ba450d57b417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 27 Apr 2024 13:44:29 +0200 Subject: [PATCH] ctime, localtime, tzset, wcsftime: Check content of environment. * lib/ctime.c (rpl_ctime): Index into content of each environment variable. * lib/localtime.c (rpl_localtime): Likewise. * lib/tzset.c (rpl_tzset): Likewise. * lib/wcsftime.c (rpl_wcsftime): Likewise. --- lib/ctime.c | 12 ++++++------ lib/localtime.c | 12 ++++++------ lib/tzset.c | 12 ++++++------ lib/wcsftime.c | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/ctime.c b/lib/ctime.c index 8c54ef463c..e30b7997c8 100644 --- a/lib/ctime.c +++ b/lib/ctime.c @@ -63,13 +63,13 @@ rpl_ctime (const time_t *tp) char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } #endif diff --git a/lib/localtime.c b/lib/localtime.c index f0e91ac647..1c6bb9856e 100644 --- a/lib/localtime.c +++ b/lib/localtime.c @@ -63,13 +63,13 @@ rpl_localtime (const time_t *tp) char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } #endif diff --git a/lib/tzset.c b/lib/tzset.c index f307f0c3d1..c8d48e1afb 100644 --- a/lib/tzset.c +++ b/lib/tzset.c @@ -65,13 +65,13 @@ rpl_tzset (void) char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } /* On native Windows, tzset() is deprecated. Use _tzset() instead. See diff --git a/lib/wcsftime.c b/lib/wcsftime.c index d8b471ab57..81d1762a92 100644 --- a/lib/wcsftime.c +++ b/lib/wcsftime.c @@ -61,13 +61,13 @@ rpl_wcsftime (wchar_t *buf, size_t bufsize, const wchar_t *format, const struct char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } #endif -- 2.44.0.windows.1