]> diplodocus.org Git - nmh/commitdiff
dtimezone(): Explain abs(3) is undefined on INT_MIN.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sat, 29 Jul 2017 14:06:11 +0000 (15:06 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sat, 29 Jul 2017 14:10:19 +0000 (15:10 +0100)
That's why a negative int is flipped over into unsigned by assuming
two's complement.

sbr/dtime.c

index 3a51d87ff11145783475c06b76e9ce8b87760c9c..b3ca012a860ce8eace93f8643acf1bc69bc121b9 100644 (file)
@@ -291,7 +291,7 @@ char *dtimezone(int offset, int flags)
     unsigned os, hours, mins;
 
     pos = offset >= 0;
-    os = pos ? offset : ~offset + 1;
+    os = pos ? offset : ~offset + 1; /* abs(3) undefined on INT_MIN. */
     hours = os / 60;
     mins = os % 60;