On Fri, Dec 27, 2019 at 01:25:30PM -0800, Steve Kargl wrote:
> The use of OpenSSL in factor(6) breaks factor(6) with respect to
> its documentation.
> 
> % man factor
>   ...
>   Numbers may be preceded by a single '+'.
>   ...
> 
> % factor +125
> factor: +125: illegal numeric format.
> 

This fixes factor(6) for the above issue.  The issue with
hexadecimal is not easily fixed.

Index: factor.c
===================================================================
--- factor.c    (revision 355983)
+++ factor.c    (working copy)
@@ -148,21 +148,23 @@
                        for (p = buf; isblank(*p); ++p);
                        if (*p == '\n' || *p == '\0')
                                continue;
+                       if (*p == '+') p++;
                        if (*p == '-')
                                errx(1, "negative numbers aren't permitted.");
-                       if (BN_dec2bn(&val, buf) == 0 &&
-                           BN_hex2bn(&val, buf) == 0)
-                               errx(1, "%s: illegal numeric format.", buf);
+                       if (BN_dec2bn(&val, p) == 0 &&
+                           BN_hex2bn(&val, p) == 0)
+                               errx(1, "%s: illegal numeric format.", p);
                        pr_fact(val);
                }
        /* Factor the arguments. */
        else
-               for (; *argv != NULL; ++argv) {
-                       if (argv[0][0] == '-')
+               for (p = *argv; p != NULL; p = *++argv) {
+                       if (*p == '-')
                                errx(1, "negative numbers aren't permitted.");
-                       if (BN_dec2bn(&val, argv[0]) == 0 &&
-                           BN_hex2bn(&val, argv[0]) == 0)
-                               errx(1, "%s: illegal numeric format.", argv[0]);
+                       if (*p == '+') p++;
+                       if (BN_dec2bn(&val, p) == 0 &&
+                           BN_hex2bn(&val, p) == 0)
+                               errx(1, "%s: illegal numeric format.", p);
                        pr_fact(val);
                }
        exit(0);

-- 
Steve
_______________________________________________
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to