[09/59] Omit parse_offset unnecessary *tz == '\0'

Message ID 20250105055750.1668721-10-eggert@cs.ucla.edu (mailing list archive)
State New
Headers
Series time: sync mktime from Gnulib |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Paul Eggert Jan. 5, 2025, 5:56 a.m. UTC
  * time/tzset.c (parse_offset): Simplify by omitting unnecessary
(*tz == '\0') test.
---
 time/tzset.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Patch

diff --git a/time/tzset.c b/time/tzset.c
index a0bf3382ba..9fb3a127f7 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -189,12 +189,13 @@  static bool
 parse_offset (const char **tzp, int whichrule)
 {
   const char *tz = *tzp;
+  bool leading_sign = *tz == '-' || *tz == '+';
   if (whichrule == 0
-      && (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit (*tz))))
+      && (!leading_sign && !isdigit (*tz)))
     return false;
 
   int sign;
-  if (*tz == '-' || *tz == '+')
+  if (leading_sign)
     sign = *tz++ == '-' ? 1 : -1;
   else
     sign = -1;