Similar to tb's de Morgan's rule send last night.
Shaves of 4 LoC of putdata and reads easier to me.
regress passes
OK?
martijn@
Index: jot.c
===================================================================
RCS file: /cvs/src/usr.bin/jot/jot.c,v
retrieving revision 1.51
diff -u -p -r1.51 jot.c
--- jot.c 30 Jul 2021 02:47:37 -0000 1.51
+++ jot.c 13 Aug 2021 07:09:41 -0000
@@ -304,25 +304,21 @@ putdata(double x, bool last)
if (boring)
printf("%s", format);
else if (longdata && nosign) {
- if (x <= (double)ULONG_MAX && x >= 0.0)
- printf(format, (unsigned long)x);
- else
+ if (x < 0.0 || x > (double)ULONG_MAX)
return 1;
+ printf(format, (unsigned long)x);
} else if (longdata) {
- if (x <= (double)LONG_MAX && x >= (double)LONG_MIN)
- printf(format, (long)x);
- else
+ if (x < (double)LONG_MIN || x > (double)LONG_MAX)
return 1;
+ printf(format, (long)x);
} else if (chardata || (intdata && !nosign)) {
- if (x <= (double)INT_MAX && x >= (double)INT_MIN)
- printf(format, (int)x);
- else
+ if (x < (double)INT_MIN || x > (double)INT_MAX)
return 1;
+ printf(format, (int)x);
} else if (intdata) {
- if (x <= (double)UINT_MAX && x >= 0.0)
- printf(format, (unsigned int)x);
- else
+ if (x < 0.0 || x > (double)UINT_MAX)
return 1;
+ printf(format, (unsigned int)x);
} else
printf(format, x);
if (!last)