With the attached patch for attila's regress.m4 and the inlined patch
for jot.c below, all of FreeBSD's regression tests pass.

The first hunk is attila's, the second hunk is adapted from FreeBSD
(these are both not quite compatible with our current manual) and the
third hunk is pjanzen's lost fix attached to my previous mail.

I think the change of behavior for the corner cases jot - - - - and
jot - x y -  is outweighed by being closer to FreeBSD and NetBSD.

This isn't quite ready to be committed, yet, but it's the minimal fix.

The full fix would involve expanding the ghastly mask business to
something readable similar to FreeBSD's and NetBSD's code and would
adjust the manual as well.

Any comments?

Index: jot.c
===================================================================
RCS file: /var/cvs/src/usr.bin/jot/jot.c,v
retrieving revision 1.28
diff -u -p -r1.28 jot.c
--- jot.c       17 Jul 2016 04:04:46 -0000      1.28
+++ jot.c       26 Jul 2016 18:48:31 -0000
@@ -54,10 +54,10 @@
 
 #define        is_default(s)   (strcmp((s), "-") == 0)
 
-static double  begin;
-static double  ender;
-static double  s;
-static long    reps;
+static double  begin = BEGIN_DEF;
+static double  ender = ENDER_DEF;
+static double  s = STEP_DEF;
+static long    reps = REPS_DEF;
 static bool    randomize;
 static bool    infinity;
 static bool    boring;
@@ -195,8 +195,8 @@ main(int argc, char *argv[])
                        mask = 015;
                        break;
                case 006:
-                       reps = REPS_DEF;
-                       mask = 016;
+                       s = ender > begin ? 1 : -1;
+                       mask = 007;
                        break;
                case 007:
                        if (randomize) {
@@ -394,8 +394,11 @@ getformat(void)
        if (boring)                             /* no need to bother */
                return;
        for (p = format; *p != '\0'; p++)       /* look for '%' */
-               if (*p == '%' && *(p+1) != '%') /* leave %% alone */
-                       break;
+               if (*p == '%') {
+                      if (*(p + 1) != '%')
+                              break;
+                      p++;                     /* leave %% alone */
+               }
        sz = sizeof(format) - strlen(format) - 1;
        if (*p == '\0' && !chardata) {
                int n;

Reply via email to