Wednesday, September 07, 2022

Re: current status of OCaml

Index: gnum4.c
===================================================================
RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
retrieving revision 1.54
diff -u -p -r1.54 gnum4.c
--- gnum4.c 4 Jul 2022 10:41:21 -0000 1.54
+++ gnum4.c 7 Sep 2022 22:32:44 -0000
@@ -538,6 +538,7 @@ doformat(const char *argv[], int argc)
size_t l;
const char *thisarg;
char temp[2];
+ const char *errstr;
long extra;

while (*format != 0) {
@@ -595,6 +596,15 @@ doformat(const char *argv[], int argc)
temp[0] = strtoul(argv[pos++], NULL, 10);
temp[1] = 0;
thisarg = temp;
+ break;
+ case 'd':
+ thisarg = argv[pos++];
+ (void) strtonum(thisarg, LONG_MIN, LONG_MAX, &errstr);
+ if (errstr != NULL) {
+ temp[0] = '0';
+ temp[1] = 0;
+ thisarg = temp;
+ }
break;
default:
m4errx(1, "Unsupported format specification: %s.",
Index: m4.1
===================================================================
RCS file: /cvs/src/usr.bin/m4/m4.1,v
retrieving revision 1.68
diff -u -p -r1.68 m4.1
--- m4.1 14 Jun 2022 21:31:45 -0000 1.68
+++ m4.1 7 Sep 2022 22:32:44 -0000
@@ -291,7 +291,7 @@ and following arguments, in a way simila
This built-in is only available in GNU-m4 compatibility mode, and the only
parameters implemented are there for autoconf compatibility:
left-padding flag, an optional field width, a maximum field width,
-*-specified field widths, and the %s and %c data type.
+*-specified field widths, and the %s, %c and %d data types.
.It Fn ifdef name yes no
If the macro named by the first argument is defined then return the second
argument, otherwise the third.
>> I'm waaay, waaay out of my comfort zone here, but shouldn't that do
>> the trick already?
>
> Argh. Strike that. Please.

At the risk of embarrassing myself even further: Here's a less stupid
attempt. It doesn't behave exactly as GNU m4 in the presence of
arguments that can't be parsed as a number (GNU interprets digits up to
the first non-digit as a number and throws a warning), though.

No comments:

Post a Comment