]> git.sur5r.net Git - cc65/commitdiff
Merge pull request #141 from mrdudz/testsuite
authorOliver Schmidt <ol.sc@web.de>
Thu, 27 Nov 2014 18:24:59 +0000 (19:24 +0100)
committerOliver Schmidt <ol.sc@web.de>
Thu, 27 Nov 2014 18:24:59 +0000 (19:24 +0100)
Testsuite

80 files changed:
.gitignore
test/.gitignore [new file with mode: 0644]
test/Makefile [new file with mode: 0644]
test/bdiff.c [new file with mode: 0644]
test/err/Makefile [new file with mode: 0644]
test/misc/Makefile [new file with mode: 0644]
test/misc/common.h [new file with mode: 0644]
test/misc/endless.c [new file with mode: 0644]
test/misc/fields.c [new file with mode: 0644]
test/misc/limits.c [new file with mode: 0644]
test/misc/limits.ref [new file with mode: 0644]
test/misc/sitest.c [new file with mode: 0644]
test/readme.txt [new file with mode: 0644]
test/ref/8q.c
test/ref/Makefile [new file with mode: 0644]
test/ref/cc65080227.c
test/ref/cc65080328.c
test/ref/cc65090111.c
test/ref/cc65090124.c
test/ref/cc65090726.c
test/ref/cc65090910.c
test/ref/cc65090913.c
test/ref/cc65091007.c
test/ref/cc65091022.c
test/ref/cc65110211.c
test/ref/cf.c
test/ref/cf.in [new file with mode: 0755]
test/ref/charconst.c
test/ref/common.h [new file with mode: 0644]
test/ref/cvt.c
test/ref/fields.c [deleted file]
test/ref/init.c
test/ref/limits.c [deleted file]
test/ref/minimal.c
test/ref/otccex.c
test/ref/paranoia.c
test/ref/pointer2.c
test/ref/spill.c
test/ref/stdarg.c
test/ref/struct.c
test/ref/switch.c
test/ref/wf1.c
test/ref/wf1.in [new file with mode: 0644]
test/ref/yacc.c
test/ref/yacc.in [new file with mode: 0755]
test/ref/yacc2.c
test/val/Makefile [new file with mode: 0644]
test/val/add1.o [deleted file]
test/val/add1.prg [deleted file]
test/val/add3.c
test/val/add3.o [deleted file]
test/val/add3.prg [deleted file]
test/val/add4.o [deleted file]
test/val/add4.prg [deleted file]
test/val/cc65091020.c
test/val/common.h [new file with mode: 0644]
test/val/compare5.c
test/val/cq22.c
test/val/cq241.c
test/val/cq243.c
test/val/cq244.c
test/val/cq25.c
test/val/cq26.c
test/val/cq4.c
test/val/cq61.c
test/val/cq626.c
test/val/cq71.c
test/val/cq714.c
test/val/cq714b.c
test/val/cq715.c
test/val/cq72.c
test/val/cq757.c
test/val/cq7813.c
test/val/cq81.c
test/val/cq84.c
test/val/cq85.c
test/val/cq86.c
test/val/cq88.c
test/val/cq9.c
test/val/sitest.c [deleted file]

index 1d5928af76b58a945fcde4f9411eba6d5c044196..196cdc3d787405ad7c1e124a9e7d7287ebca4cf1 100644 (file)
@@ -8,5 +8,6 @@
 /mou/
 /ser/
 /targetutil/
+/testwrk/
 /tgi/
 /wrk/
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644 (file)
index 0000000..5761abc
--- /dev/null
@@ -0,0 +1 @@
+*.o
diff --git a/test/Makefile b/test/Makefile
new file mode 100644 (file)
index 0000000..b942cbc
--- /dev/null
@@ -0,0 +1,52 @@
+
+# toplevel makefile for the regression tests
+
+MAKE := make --no-print-dir
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+ifdef CMD_EXE
+  RM := del /f
+  EXE := .exe
+  MKDIR = mkdir
+  RMDIR = rmdir
+else
+  RM := rm -f
+  EXE :=
+  MKDIR = mkdir -p
+  RMDIR = rmdir
+endif
+
+WORKDIR := ../testwrk
+
+.PHONY: dotests clean
+
+all: dotests
+
+$(WORKDIR):
+       @$(MKDIR) $(WORKDIR)
+
+$(WORKDIR)/bdiff$(EXE): $(WORKDIR)
+       @$(CC) -o $(WORKDIR)/bdiff$(EXE) bdiff.c
+
+dotests: $(WORKDIR)/bdiff$(EXE)
+       @$(MAKE) -C val clean all
+       @$(MAKE) -C ref clean all
+       @$(MAKE) -C err clean all
+       @$(MAKE) -C misc clean all
+
+continue: $(WORKDIR)/bdiff$(EXE)
+       @$(MAKE) -C val all
+       @$(MAKE) -C ref all
+       @$(MAKE) -C err all
+       @$(MAKE) -C misc all
+
+clean:
+       @$(MAKE) -C val clean
+       @$(MAKE) -C ref clean
+       @$(MAKE) -C err clean
+       @$(MAKE) -C misc clean
+       @$(RM) $(WORKDIR)/bdiff$(EXE)
+       @$(RMDIR) $(WORKDIR)
diff --git a/test/bdiff.c b/test/bdiff.c
new file mode 100644 (file)
index 0000000..797ba43
--- /dev/null
@@ -0,0 +1,28 @@
+
+// minimal tool to compare two binaries
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+    FILE *f1, *f2;
+    if (argc < 3) {
+        return EXIT_FAILURE;
+    }
+    f1 = fopen(argv[1], "rb");
+    f2 = fopen(argv[2], "rb");
+    if ((f1 == NULL) || (f2 == NULL)) {
+        return EXIT_FAILURE;
+    }
+    for(;;) {
+        if (feof(f1) && feof(f2)) {
+            return EXIT_SUCCESS;
+        } else if (feof(f1) || feof(f2)) {
+            return EXIT_FAILURE;
+        }
+        if (fgetc(f1) != fgetc(f2)) {
+            return EXIT_FAILURE;
+        }
+    }
+}
diff --git a/test/err/Makefile b/test/err/Makefile
new file mode 100644 (file)
index 0000000..40ccfcb
--- /dev/null
@@ -0,0 +1,52 @@
+
+# makefile for the tests that MUST NOT compile
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+all: $(TESTS)
+
+$(WORKDIR)/%.prg: %.c
+       ! $(CL65) $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.o.prg: %.c
+       ! $(CL65) -O $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.os.prg: %.c
+       ! $(CL65) -Os $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.osi.prg: %.c
+       ! $(CL65) -Osi $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.osir.prg: %.c
+       ! $(CL65) -Osir $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.oi.prg: %.c
+       ! $(CL65) -Oi $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.oir.prg: %.c
+       ! $(CL65) -Oir $(CC65FLAGS) $< -o $@
+$(WORKDIR)/%.or.prg: %.c
+       ! $(CL65) -Or $(CC65FLAGS) $< -o $@
+clean:
+       @$(RM) $(TESTS)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
diff --git a/test/misc/Makefile b/test/misc/Makefile
new file mode 100644 (file)
index 0000000..b18d916
--- /dev/null
@@ -0,0 +1,67 @@
+
+# makefile for the remaining tests that need special care in one way or another
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+DIFF := $(WORKDIR)/bdiff
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+# FIXME: actually use/build differently optimized programs here
+
+all: $(TESTS)
+
+# should compile, but then hangs in an endless loop
+$(WORKDIR)/endless%prg: endless.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       ! $(SIM65) $(SIM65FLAGS) $@
+
+# these need reference data that cant be generated by a host compiled program
+# in a useful way
+$(WORKDIR)/limits%prg: limits.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/limits.out
+       $(DIFF) $(WORKDIR)/limits.out limits.ref
+
+# the rest are tests that fail currently for one reason or another
+$(WORKDIR)/fields%prg: fields.c
+       @echo "FIXME: " $@ "will currently fail"
+       $(CL65) $(CC65FLAGS) $< -o $@
+       -$(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/sitest%prg: sitest.c
+       @echo "FIXME: " $@ "will currently fail"
+       -$(CL65) $(CC65FLAGS) $< -o $@
+       -$(SIM65) $(SIM65FLAGS) $@
+
+clean:
+       @$(RM) $(TESTS)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
+
+
diff --git a/test/misc/common.h b/test/misc/common.h
new file mode 100644 (file)
index 0000000..dada61a
--- /dev/null
@@ -0,0 +1,22 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NO_OLD_FUNC_DECL
+#define NO_TYPELESS_INT
+#define NO_TYPELESS_INT_PTR
+#define MAIN_RETURNS_INT
+#define NO_IMPLICIT_FUNC_PROTOTYPES
+#define NO_FLOATS
+#define NO_WCHAR
+#define NO_EMPTY_FUNC_ARGS
+#define NO_SLOPPY_STRUCT_INIT
+#define NO_FUNCS_TAKE_STRUCTS
+#define NO_FUNCS_RETURN_STRUCTS
+#define CAST_STRUCT_PTR
+#define NO_TYPELESS_STRUCT_PTR
+#define NO_IMPLICIT_FUNCPTR_CONV
+#define SIZEOF_INT_16BIT
+#define SIZEOF_LONG_32BIT
+#define UNSIGNED_CHARS
+#define UNSIGNED_BITFIELDS
diff --git a/test/misc/endless.c b/test/misc/endless.c
new file mode 100644 (file)
index 0000000..fe07829
--- /dev/null
@@ -0,0 +1,13 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+{
+    printf("entering endless loop\n");
+    for(;;) {
+        ;
+    }
+    printf("error: should not come here\n");
+    return EXIT_FAILURE;
+}
diff --git a/test/misc/fields.c b/test/misc/fields.c
new file mode 100644 (file)
index 0000000..83bee82
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+  !!DESCRIPTION!! bitfield test
+  !!ORIGIN!!      LCC 4.1 Testsuite
+  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
+*/
+
+#include "common.h"
+
+#ifdef NO_BITFIELDS
+
+main()
+{
+        printf("NO_BITFIELDS\n\r");
+}
+
+#else
+
+#ifdef SIZEOF_INT_16BIT
+
+#ifdef REFCC
+#include <stdint.h>
+struct foo {
+       int16_t a;
+       char b;
+       int16_t x : 12, y : 4;
+       int16_t zz : 1, : 0, : 4, z : 3;
+       char c;
+} x = { 1, 2, 3, 4, 5, 6 };
+
+struct baz { uint16_t a:2, b:4, c:16;} y = { 7, 8, 9};
+int16_t i = 8;
+
+#else
+
+struct foo {
+       int a;
+       char b;
+       int x : 12, y : 4;
+       int zz : 1, : 0, : 4, z : 3;
+       char c;
+} x = { 1, 2, 3, 4, 5, 6 };
+
+struct baz { unsigned int a:2, b:4, c:16;} y = { 7, 8, 9};
+int i = 8;
+#endif
+
+#else
+struct foo {
+       int a;
+       char b;
+       int x : 12, y : 4, : 0, : 4, z : 3;
+       char c;
+} x = { 1, 2, 3, 4, 5, 6 };
+
+struct baz { unsigned int a:2, b:4, c:32;} y = { 7, 8, 9};
+int i = 16;
+#endif
+
+#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
+f1(struct baz *p);
+f2(struct baz *p);
+#endif
+
+main()
+{
+       printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c);
+       printf("y = %d b:%d c:%d\n", y.a, y.b, y.c);
+       x.y = i;
+       x.z = 070;
+       printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c);
+       y.a = 2;
+       y.c = i;
+       printf("y = %d b:%d c:%d\n", y.a, y.b, y.c);
+#ifdef CAST_STRUCT_PTR
+       f2((struct baz *)&x);
+#else
+       f2(&x);
+#endif
+       return 0;
+}
+
+f1(struct baz *p) {
+       p->a = p->b = 0;
+       if (p->b)
+               printf("p->b != 0!\n");
+       p->a = 0x3; p->b = 0xf;
+       printf("p->a = 0x%x, p->b = 0x%x\n", p->a, p->b);
+}
+f2(struct baz *p) {
+       p->a = (i==0);
+       p->b = (f1(p),0);
+}
+
+#endif
diff --git a/test/misc/limits.c b/test/misc/limits.c
new file mode 100644 (file)
index 0000000..613d6bd
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+  !!DESCRIPTION!! display type limits
+  !!ORIGIN!!      LCC 4.1 Testsuite
+  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
+*/
+
+#include <stdio.h>
+#include <limits.h>
+
+#define SSHRT_MAX      SHRT_MAX
+#define SINT_MAX       INT_MAX
+#define SLONG_MAX      LONG_MAX
+
+#define UCHAR_MIN   0
+#define USHRT_MIN   0
+#define SSHRT_MIN   SHRT_MIN
+#define UINT_MIN    0
+#define SINT_MIN    INT_MIN
+#define ULONG_MIN   0l
+#define SLONG_MIN   LONG_MIN
+
+int main(void) {
+        printf("CHAR_MAX:  0x%08x=%d\n", CHAR_MAX, CHAR_MAX);
+        printf("UCHAR_MAX: 0x%08x=%d\n", UCHAR_MAX, UCHAR_MAX);
+        printf("SCHAR_MAX: 0x%08x=%d\n", SCHAR_MAX, SCHAR_MAX);
+
+        printf("SHRT_MAX:  0x%08x=%d\n", SHRT_MAX, SHRT_MAX);
+        printf("USHRT_MAX: 0x%08x=%d\n", USHRT_MAX, USHRT_MAX);
+        printf("SSHRT_MAX: 0x%08x=%d\n", SSHRT_MAX, SSHRT_MAX);
+
+        printf("INT_MAX:   0x%08x=%d\n", INT_MAX, INT_MAX);
+        printf("UINT_MAX:  0x%08x=%d\n", UINT_MAX, UINT_MAX);
+        printf("SINT_MAX:  0x%08x=%d\n", SINT_MAX, SINT_MAX);
+
+        printf("LONG_MAX:  0x%08lx=%ld\n", LONG_MAX, LONG_MAX);
+        printf("ULONG_MAX: 0x%08lx=%ld\n", ULONG_MAX, ULONG_MAX);
+        printf("SLONG_MAX: 0x%08lx=%ld\n", SLONG_MAX, SLONG_MAX);
+
+        printf("CHAR_MIN:  0x%08x=%d\n", CHAR_MIN, CHAR_MIN);
+        printf("UCHAR_MIN: 0x%08x=%d\n", UCHAR_MIN, UCHAR_MIN);
+        printf("SCHAR_MIN: 0x%08x=%d\n", SCHAR_MIN, SCHAR_MIN);
+
+        printf("SHRT_MIN:  0x%08x=%d\n", SHRT_MIN, SHRT_MIN);
+        printf("USHRT_MIN: 0x%08x=%d\n", USHRT_MIN, USHRT_MIN);
+        printf("SSHRT_MIN: 0x%08x=%d\n", SSHRT_MIN, SSHRT_MIN);
+
+        printf("INT_MIN:   0x%08x=%d\n", INT_MIN, INT_MIN);
+        printf("UINT_MIN:  0x%08x=%d\n", UINT_MIN, UINT_MIN);
+        printf("SINT_MIN:  0x%08x=%d\n", SINT_MIN, SINT_MIN);
+
+        printf("LONG_MIN:  0x%08lx=%ld\n", LONG_MIN, LONG_MIN);
+        printf("ULONG_MIN: 0x%08lx=%ld\n", ULONG_MIN, ULONG_MIN);
+        printf("SLONG_MIN: 0x%08lx=%ld\n", SLONG_MIN, SLONG_MIN);
+
+        return 0;
+}
diff --git a/test/misc/limits.ref b/test/misc/limits.ref
new file mode 100644 (file)
index 0000000..9be906b
--- /dev/null
@@ -0,0 +1,24 @@
+CHAR_MAX:  0x000000ff=255
+UCHAR_MAX: 0x000000ff=255
+SCHAR_MAX: 0x0000007f=127
+SHRT_MAX:  0x00007fff=32767
+USHRT_MAX: 0x0000ffff=-1
+SSHRT_MAX: 0x00007fff=32767
+INT_MAX:   0x00007fff=32767
+UINT_MAX:  0x0000ffff=-1
+SINT_MAX:  0x00007fff=32767
+LONG_MAX:  0x7fffffff=2147483647
+ULONG_MAX: 0xffffffff=-1
+SLONG_MAX: 0x7fffffff=2147483647
+CHAR_MIN:  0x00000000=0
+UCHAR_MIN: 0x00000000=0
+SCHAR_MIN: 0x0000ff80=-128
+SHRT_MIN:  0x00008000=-32768
+USHRT_MIN: 0x00000000=0
+SSHRT_MIN: 0x00008000=-32768
+INT_MIN:   0x00008000=-32768
+UINT_MIN:  0x00000000=0
+SINT_MIN:  0x00008000=-32768
+LONG_MIN:  0x80000000=-2147483648
+ULONG_MIN: 0x00000000=0
+SLONG_MIN: 0x80000000=-2147483648
diff --git a/test/misc/sitest.c b/test/misc/sitest.c
new file mode 100644 (file)
index 0000000..9570f49
--- /dev/null
@@ -0,0 +1,1591 @@
+/*
+  !!DESCRIPTION!! C99 WCHAR test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+/*
+       sitest -- exercise features of C99 <stdint.h> and <inttypes.h>
+
+       This source code has been placed into the PUBLIC DOMAIN by its author.
+
+       last edit:      1999/11/05      gwyn@arl.mil
+
+       Tries to accommodate pre-C99 versions of <inttypes.h>.
+
+       Takes advantage of __Q8_* symbols defined by a particular
+       implementation of <stdint.h>, but doesn't require them.
+
+       NOTE:   This is not a thorough validation test of the facilities.
+*/
+
+#define NO_INTERNAL_WCHAR
+/*#define STANDALONE*/
+
+#include       <errno.h>
+#include       <limits.h>              /* for CHAR_BIT */
+#include       <stdio.h>
+#include       <stddef.h>              /* for ptrdiff_t */
+#include       <stdlib.h>
+#include       <string.h>
+
+#if !defined(STANDARD_C99) && !defined(STANDARD_CC65)
+
+#error "this test checks C99 features, which are not available in the selected standard."
+
+#else
+
+#ifdef NO_WCHAR
+
+#warn "this test checks C99 features, but NO_WCHAR is defined so the test will most definetly fails."
+
+#endif
+
+#include       <inttypes.h>            /* embeds <stdint.h> */
+
+#include       <signal.h>              /* for sig_atomic_t */
+
+#if    defined(INTMAX_MAX)             /* <inttypes.h> has C99 features */
+#include       <wchar.h>
+#endif
+
+#include       <inttypes.h>            /* test idempotency */
+
+#ifdef STANDALONE
+
+FILE *outfile=NULL;
+#define opentest(x) outfile=stdout;
+#define closetest(x)
+
+#else
+
+#endif
+
+#if    __STDC_VERSION__ >= 199901
+#ifndef        __Q8_QT
+#define        __Q8_QT long long
+#endif
+#endif
+
+#ifdef PRIdMAX
+#define        HAVE_PRIdMAX
+#ifndef        __Q8_MT
+#define        __Q8_MT intmax_t
+#endif
+#else
+#ifdef PRIdLEAST64
+#ifndef        __Q8_MT
+#define        __Q8_MT int_least64_t
+#endif
+#define        PRIdMAX PRIdLEAST64
+#else
+#ifndef        __Q8_MT
+#define        __Q8_MT long
+#endif
+#define        PRIdMAX "ld"
+#endif
+#endif
+
+#ifdef PRIuMAX
+#define        HAVE_PRIuMAX
+#define        U__Q8_MT        uintmax_t
+#else
+#ifdef PRIuLEAST64
+#define        U__Q8_MT        uint_least64_t
+#define        PRIuMAX PRIuLEAST64
+#else
+#define        U__Q8_MT        unsigned long
+#define        PRIuMAX "lu"
+#endif
+#endif
+
+#define        STR_SUB(s)      # s
+#define        STRINGIZE(s)    STR_SUB(s)      /* extra level to expand argument */
+
+#if    defined(SCNo32) || defined(PRIo32)
+static int32_t         int32;
+#endif
+static int_least16_t   intl16;
+static uint_least16_t  uintl16;
+static uint_fast16_t   uintf16;
+static intmax_t                intmax;
+static uintmax_t       uintmax;
+
+int
+main() {
+       int     status = 0;             /* exit status to be returned */
+
+       
+       /* <stdint.h> features: */
+
+       printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT );
+       printf("sizeof(char)=%u\n", (unsigned)sizeof(char));    /* s.b. 1 */
+       printf("sizeof(short)=%u\n", (unsigned)sizeof(short));
+       printf("sizeof(int)=%u\n", (unsigned)sizeof(int));
+       printf("sizeof(long)=%u\n", (unsigned)sizeof(long));
+#ifdef __Q8_QT
+       printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT));
+#else
+       printf("*** long long isn't defined ***\n");
+#endif
+       printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
+       printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t));
+       printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t));
+       printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t));
+       printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t));
+#if    defined(WINT_MAX) || __STDC_VERSION__ >= 199901
+       printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t));
+#else
+       printf("*** wint_t isn't defined ***\n");
+       status = EXIT_FAILURE;
+#endif
+#ifdef INT8_MAX
+       printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t));
+       printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t));
+#endif
+#ifdef INT9_MAX
+       printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t));
+       printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t));
+#endif
+#ifdef INT12_MAX
+       printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t));
+       printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t));
+#endif
+#ifdef INT16_MAX
+       printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t));
+       printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t));
+#endif
+#ifdef INT18_MAX
+       printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t));
+       printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t));
+#endif
+#ifdef INT24_MAX
+       printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t));
+       printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t));
+#endif
+#ifdef INT32_MAX
+       printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t));
+       printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t));
+#endif
+#ifdef INT36_MAX
+       printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t));
+       printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t));
+#endif
+#ifdef INT40_MAX
+       printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t));
+       printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t));
+#endif
+#ifdef INT48_MAX
+       printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t));
+       printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t));
+#endif
+#ifdef INT60_MAX
+       printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t));
+       printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t));
+#endif
+#ifdef INT64_MAX
+       printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t));
+       printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t));
+#endif
+#ifdef INT72_MAX
+       printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t));
+       printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t));
+#endif
+#ifdef INT128_MAX
+       printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t));
+       printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t));
+#endif
+       printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t));
+       printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t));
+       printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t));
+       printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t));
+       printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t));
+       printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t));
+#ifdef INT_LEAST64_MAX
+       printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t));
+       printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t));
+#else
+       printf("*** uint_least64_t isn't defined ***\n");
+       status = EXIT_FAILURE;
+#endif
+#ifdef INT_LEAST128_MAX
+       printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t));
+       printf("sizeof(uint_least128_t)=%u\n",
+               (unsigned)sizeof(uint_least128_t));
+#endif
+       printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t));
+       printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t));
+       printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t));
+       printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t));
+       printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t));
+       printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t));
+#ifdef INT_FAST64_MAX
+       printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t));
+       printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t));
+#else
+       printf("*** int_fast64_t isn't defined ***\n");
+       status = EXIT_FAILURE;
+#endif
+#ifdef INT_FAST128_MAX
+       printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t));
+       printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t));
+#endif
+#if    defined(INTPTR_MAX)
+       printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t));
+#if    defined(UINTPTR_MAX)
+       printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
+#else
+       printf("*** intptr_t is defined but uintptr_t isn't ***\n");
+       status = EXIT_FAILURE;
+#endif
+#elif  defined(UINTPTR_MAX)
+       printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
+       printf("*** uintptr_t is defined but intptr_t isn't ***\n");
+       status = EXIT_FAILURE;
+#else
+       printf("*** neither intptr_t nor uintptr_t is defined ***\n");
+       status = EXIT_FAILURE;
+#endif
+#ifdef INTMAX_MAX
+       printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
+       printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t));
+#else
+       printf("*** intmax_t isn't defined ***\n");
+       status = EXIT_FAILURE;
+#endif
+
+#ifdef INT8_MAX
+       printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN);
+       printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX);
+       printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX);
+#endif
+#ifdef INT9_MAX
+       printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN);
+       printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX);
+       printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX);
+#endif
+#ifdef INT12_MAX
+       printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN);
+       printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX);
+       printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX);
+#endif
+#ifdef INT16_MAX
+       printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN);
+       printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX);
+       printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX);
+#endif
+#ifdef INT18_MAX
+       printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN);
+       printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX);
+       printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX);
+#endif
+#ifdef INT24_MAX
+       printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN);
+       printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX);
+       printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX);
+#endif
+#ifdef INT32_MAX
+       printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN);
+       printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX);
+       printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX);
+#endif
+#ifdef INT36_MAX
+       printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN);
+       printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX);
+       printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX);
+#endif
+#ifdef INT40_MAX
+       printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN);
+       printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX);
+       printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX);
+#endif
+#ifdef INT48_MAX
+       printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN);
+       printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX);
+       printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX);
+#endif
+#ifdef INT60_MAX
+       printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN);
+       printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX);
+       printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX);
+#endif
+#ifdef INT64_MAX
+       printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN);
+       printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX);
+       printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX);
+#endif
+#ifdef INT72_MAX
+       printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN);
+       printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX);
+       printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX);
+#endif
+#ifdef INT128_MAX
+       printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN);
+       printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX);
+       printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX);
+#endif
+       printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN);
+       printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX);
+       printf("UINT_LEAST8_MAX=%"PRIuMAX"\n",
+               (U__Q8_MT)UINT_LEAST8_MAX);
+       printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN);
+       printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX);
+       printf("UINT_LEAST16_MAX=%"PRIuMAX"\n",
+               (U__Q8_MT)UINT_LEAST16_MAX);
+       printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN);
+       printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX);
+       printf("UINT_LEAST32_MAX=%"PRIuMAX"\n",
+               (U__Q8_MT)UINT_LEAST32_MAX);
+#ifdef INT_LEAST64_MAX
+       printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN);
+       printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX);
+       printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX);
+#endif
+#ifdef INT_LEAST128_MAX
+       printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN);
+       printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX);
+       printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX);
+#endif
+       printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN);
+       printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX);
+       printf("UINT_FAST8_MAX=%"PRIuMAX"\n",
+               (U__Q8_MT)UINT_FAST8_MAX);
+       printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN);
+       printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX);
+       printf("UINT_FAST16_MAX=%"PRIuMAX"\n",
+               (U__Q8_MT)UINT_FAST16_MAX);
+       printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN);
+       printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX);
+       printf("UINT_FAST32_MAX=%"PRIuMAX"\n",
+               (U__Q8_MT)UINT_FAST32_MAX);
+#ifdef INT_FAST64_MAX
+       printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN);
+       printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX);
+       printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX);
+#endif
+#ifdef INT_FAST128_MAX
+       printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN);
+       printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX);
+       printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX);
+#endif
+#ifdef INTPTR_MAX
+       printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN);
+       printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX);
+#endif
+#ifdef UINTPTR_MAX
+       printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX);
+#endif
+#ifdef INTMAX_MAX
+       printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN);
+       printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX);
+       printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX);
+#endif
+#ifdef PTRDIFF_MAX
+       printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN);
+       printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX);
+#endif
+#ifdef SIG_ATOMIC_MAX
+#if    SIG_ATOMIC_MIN < 0
+       printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN);
+       printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX);
+#else
+       printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN);
+       printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX);
+#endif
+#endif
+#ifdef SIZE_MAX
+       printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX);
+#endif
+
+#ifdef WCHAR_MAX
+#if    WCHAR_MIN < 0
+       printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN);
+       printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX);
+#else
+       printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN);
+       printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX);
+#endif
+#endif
+#ifdef WINT_MAX
+#if    WINT_MIN < 0
+       printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN);
+       printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX);
+#else
+       printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN);
+       printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX);
+#endif
+#endif
+
+       /*
+               7.18.4  Macros for integer constants
+       */
+
+       /* INTn_C for n=8 and 16 were at one point unimplementable
+          on most platforms, so they're treated as "optional": */
+#ifdef INT8_C
+       if ( INT8_C(-123) != -123 )
+               printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n",
+                      (__Q8_MT)INT8_C(-123)
+                     );
+       if ( UINT8_C(123) != 123 )
+               printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n",
+                      (U__Q8_MT)UINT8_C(123)
+                     );
+#endif
+#ifdef INT16_C
+       if ( INT16_C(-12345) != -12345 )
+               printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n",
+                      (__Q8_MT)INT16_C(-12345)
+                     );
+       if ( UINT16_C(12345) != 12345 )
+               printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n",
+                      (U__Q8_MT)UINT16_C(12345)
+                     );
+#endif
+       if ( INT32_C(-123456789) != -123456789 )
+               printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n",
+                      (__Q8_MT)INT32_C(-123456789)
+                     );
+       if ( UINT32_C(123456789) != 123456789 )
+               printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n",
+                      (U__Q8_MT)UINT32_C(123456789)
+                     );
+#ifdef INT_LEAST64_MAX
+       if ( INT64_C(-1234567890123456789) != -1234567890123456789 )
+               printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX
+                      " ***\n",
+                      (__Q8_MT)INT64_C(-1234567890123456789)
+                     );
+       if ( UINT64_C(1234567890123456789) != 1234567890123456789 )
+               printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX
+                      " ***\n",
+                      (U__Q8_MT)UINT64_C(1234567890123456789)
+                     );
+#endif
+#ifdef INTMAX_MAX
+       if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 )
+               printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX
+                      " ***\n",
+                      (__Q8_MT)INTMAX_C(-1234567890123456789)
+                     );
+       if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 )
+               printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX
+                      " ***\n",
+                      (U__Q8_MT)UINTMAX_C(1234567890123456789)
+                     );
+#endif
+
+       /* <inttypes.h> features: */
+
+#if    __STDC_VERSION__ >= 199901
+       printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t));
+#endif
+
+       /*
+               7.8.1   Macros for format specifiers
+       */
+
+       {
+       /* scanf these strings */
+       static const char       in_dn[] = "Z119bZ";
+       static const char       in_dmo[] = "Z-0119bZ";
+       static const char       in_dspx[] = "Z \t\n +0X119bZ";
+       static const char       in_dsmx[] = "Z \t\n -0x119bZ";
+       static const char       in_dsn[] = "Z \t\n 119bZ";
+       static const char       in_dp[] = "Z+119bZ";
+       static const char       in_dpx[] = "Z+0X119bz";
+
+       /* sprintf into this */
+       static char             buffer[1024];
+
+#if 1
+
+#define        SCAN(buf,fs,var,exp)    if ( sscanf(buf, "Z%" fs, &var) != 1 ) \
+                                       { \
+                                       printf("***%s=",fs, STR_SUB(fs) \
+                                              " failed ***\n" \
+                                             ); \
+                                       status = EXIT_FAILURE; \
+                                       } \
+                               else if ( var != (exp) ) \
+                                       { \
+                                       printf("***%s=",fs,  STR_SUB(fs) \
+                                              " should be: " STR_SUB(exp) \
+                                              ", was: %" fs " ***\n", var \
+                                             ); \
+                                       status = EXIT_FAILURE; \
+                                       } \
+                               else    /* for trailing semicolon */
+
+#define        PRINT(fs,var,exp)       if ( sprintf(buffer, "%" fs, var ) <= 0 ) \
+                                       { \
+                                       printf("***%s=",fs, STR_SUB(fs) \
+                                              " failed ***\n" \
+                                             ); \
+                                       status = EXIT_FAILURE; \
+                                       } \
+                               else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \
+                                       { \
+                                       printf("***%s=",fs,  STR_SUB(fs) \
+                                              " should be: " STR_SUB(exp) \
+                                              ", was: %s ***\n", buffer \
+                                             ); \
+                                       status = EXIT_FAILURE; \
+                                       } \
+                               else    /* for trailing semicolon */
+
+#else
+                                                                
+#define        SCAN(buf,fs,var,exp)
+#define        PRINT(fs,var,exp)
+
+#endif
+                                                                
+#ifdef SCNo32
+
+       SCAN(in_dn, SCNo32, int32, 9);
+
+#endif
+#ifdef PRIo32
+       PRINT(PRIo32, int32, 11);
+#endif
+       SCAN(in_dmo, SCNiLEAST16, intl16, -9);
+       SCAN(in_dspx, SCNdLEAST16, intl16, 0);
+       SCAN(in_dsmx, SCNiLEAST16, intl16, -4507);
+       PRINT(PRIdLEAST16, intl16, -4507);
+       PRINT(PRIiLEAST16, intl16, -4507);
+       SCAN(in_dsn, SCNxLEAST16, uintl16, 4507);
+       PRINT(PRIoLEAST16, uintl16, 10633);
+       PRINT(PRIuLEAST16, uintl16, 4507);
+       PRINT(PRIxLEAST16, uintl16, 119b);
+       PRINT(PRIXLEAST16, uintl16, 119B);
+       SCAN(in_dp, SCNxFAST16, uintf16, 4507);
+       PRINT(PRIxFAST16, uintf16, 119b);
+#ifdef SCNdMAX
+       SCAN(in_dp, SCNdMAX, intmax, 119);
+#endif
+#ifdef PRIiMAX
+       PRINT(PRIiMAX, intmax, 119);
+#endif
+#ifdef SCNoMAX
+       SCAN(in_dpx, SCNoMAX, uintmax, 0);
+#endif
+#ifdef PRIxMAX
+       PRINT(PRIxMAX, uintmax, 0);
+#endif
+       /* Obviously there should be a much larger battery of such tests. */
+       }
+
+#if    defined(INTMAX_MAX)             /* <inttypes.h> has C99 features */
+       /*
+               7.8.2   Functions for greatest-width integer types
+       */
+
+       {
+       static struct
+               {
+               intmax_t        input;
+               intmax_t        expect;
+               }       abs_data[] =
+               {
+#ifdef INT8_MAX
+         { INT8_MAX,           INT8_MAX,   },
+         { -INT8_MAX,          INT8_MAX,   },
+        {      UINT8_MAX,              UINT8_MAX,  },
+#endif
+
+#if 0
+  
+#ifdef INT16_MAX
+        {      INT16_MAX,              INT16_MAX,  },
+        {      -INT16_MAX,             INT16_MAX,  },
+        {      UINT16_MAX,             UINT16_MAX, },
+#endif
+#ifdef INT32_MAX
+        {      INT32_MAX,              INT32_MAX,  },
+        {      -INT32_MAX,             INT32_MAX,  },
+#ifdef INT_LEAST64_MAX                 /* else might support only 32 bits */
+        {      UINT32_MAX,             UINT32_MAX, },
+#endif
+#endif
+#ifdef INT64_MAX
+        {      INT64_MAX,              INT64_MAX,  },
+        {      -INT64_MAX,             INT64_MAX,  },
+#endif
+        {      INT_LEAST8_MAX,         INT_LEAST8_MAX,      },
+        {      -INT_LEAST8_MAX,        INT_LEAST8_MAX,      },
+        {      UINT_LEAST8_MAX,        UINT_LEAST8_MAX,     },
+        {      INT_LEAST16_MAX,        INT_LEAST16_MAX,     },
+        {      -INT_LEAST16_MAX,       INT_LEAST16_MAX,     },
+        {      UINT_LEAST16_MAX,       UINT_LEAST16_MAX,    },
+        {      INT_LEAST32_MAX,        INT_LEAST32_MAX,     },
+        {      -INT_LEAST32_MAX,       INT_LEAST32_MAX,     },
+#ifdef INT_LEAST64_MAX
+        {      UINT_LEAST32_MAX,       UINT_LEAST32_MAX,    },
+        {      INT_LEAST64_MAX,        INT_LEAST64_MAX,     },
+        {      -INT_LEAST64_MAX,       INT_LEAST64_MAX,     },
+#endif
+        {      INT_FAST8_MAX,          INT_FAST8_MAX,       },
+        {      -INT_FAST8_MAX, INT_FAST8_MAX,           },
+        {      UINT_FAST8_MAX, UINT_FAST8_MAX,          },
+        {      INT_FAST16_MAX, INT_FAST16_MAX,          },
+        {      -INT_FAST16_MAX,        INT_FAST16_MAX,      },
+        {      UINT_FAST16_MAX,        UINT_FAST16_MAX,     },
+        {      INT_FAST32_MAX, INT_FAST32_MAX,          },
+        {      -INT_FAST32_MAX,        INT_FAST32_MAX,      },
+#ifdef INT_FAST64_MAX
+        {      UINT_FAST32_MAX,        UINT_FAST32_MAX,     },
+        {      INT_FAST64_MAX, INT_FAST64_MAX,          },
+        {      -INT_FAST64_MAX,        INT_FAST64_MAX,      },
+#endif
+#ifdef INTPTR_MAX
+        {      INTPTR_MAX,             INTPTR_MAX,              },
+        {      -INTPTR_MAX,            INTPTR_MAX,          },
+#endif
+#ifdef UINTPTR_MAX
+        {      UINTPTR_MAX,            UINTPTR_MAX,         },
+#endif
+        {      INTMAX_MAX,             INTMAX_MAX,              },
+#ifdef PTRDIFF_MAX
+        {      PTRDIFF_MAX,            PTRDIFF_MAX,         },
+#endif
+#ifdef SIG_ATOMIC_MAX
+        {      SIG_ATOMIC_MAX,         SIG_ATOMIC_MAX,      },
+#if    SIG_ATOMIC_MIN < 0
+        {      -SIG_ATOMIC_MAX,        SIG_ATOMIC_MAX,      },
+#endif
+#endif
+#ifdef SIZE_MAX
+        {      SIZE_MAX,               SIZE_MAX,                },
+#endif
+#ifdef WCHAR_MAX
+        {      WCHAR_MAX,              WCHAR_MAX,               },
+#if    WCHAR_MIN < 0
+        {      -WCHAR_MAX,             WCHAR_MAX,               },
+#endif
+#endif
+#ifdef WINT_MAX
+        {      WINT_MAX,               WINT_MAX,                },
+#if    WINT_MIN < 0
+        {  -WINT_MAX,          WINT_MAX,                },
+#endif
+#endif
+        {      127,                            127,                 },
+        {      -127,                           127,                 },
+        {      128,                            128,                 },
+        {      -127-1,                         128,                 },
+        {      255,                            255,                 },
+        {      -256+1,                         255,                 },
+        {      256,                            256,                 },
+        {      -256,                           256,                 },
+        {      32767,                          32767,               },
+        {      -32767,                         32767,               },
+        {      32768,                          32768,               },
+        {      -32767-1,                       32768,               },
+        {      65535,                          65535,               },
+        {      -65536+1,                       65535,               },
+        {      65536,                          65536,               },
+        {      -65536,                         65536,               },
+        {      2147483647,                     2147483647,          },
+        {      -2147483647,                    2147483647,      },
+        {      2147483648,                     2147483648,          },
+        {      -2147483647-1,                  2147483648,      },
+#ifdef INT_LEAST64_MAX                 /* else might support only 32 bits */
+        {      4294967295,                     4294967295,          },
+        {      -4294967296+1,                  4294967295,      },
+        {      4294967296,                     4294967296,          },
+        {      -4294967296,                    4294967296,      },
+        {      9223372036854775807,            9223372036854775807,    },
+        {      -9223372036854775807,           9223372036854775807,    },
+        {      1234567890123456789,            1234567890123456789,    },
+        {      -1234567890123456789,           1234567890123456789,    },
+#endif
+        {      1,                              1,                                  },
+        {      -1,                             1,                                  },
+        {      2,                              2,                                  },
+        {      -2,                             2,                                  },
+        {      10,                             10,                                 },
+        {      -10,                            10,                             },
+        {      16,                             16,                                 },
+        {      -16,                            16,                             },
+#endif
+               /* Other test cases can be added here. */
+        {      0,              0       /* terminates the list */              },
+               },      *adp = abs_data;
+
+       do      {
+               if ( (intmax = imaxabs(adp->input)) != adp->expect )
+                       {
+                       printf("*** imaxabs(%"PRIdMAX") failed; should be: %"
+                              PRIdMAX", was: %"PRIdMAX" ***\n",
+                              adp->input, adp->expect, intmax
+                             );
+                       status = EXIT_FAILURE;
+                       }
+//             } while ( adp++->input != 0 );
+               } while ( (adp++)->input != 0 );
+       }
+
+       {
+       imaxdiv_t       result;
+       static struct
+               {
+               intmax_t        numer;
+               intmax_t        denom;
+               intmax_t        exp_quot;
+               intmax_t        exp_rem;
+               }       div_data[] =
+               {
+       {       0, 1,                           0, 0,   },
+#if 0
+       {       0, -1,                          0, 0,   },
+       {       0, 2,                           0, 0,   },
+       {       0, -2,                          0, 0,   },
+       {       0, 5,                           0, 0,   },
+       {       0, -5,                          0, 0,   },
+       {       1, 1,                           1, 0,   },
+       {       1, -1,                          -1, 0,  },
+       {       1, 2,                           0, 1,   },
+       {       1, -2,                          0, 1,   },
+       {       1, 5,                           0, 1,   },
+       {       1, -5,                          0, 1,   },
+       {       -1, 1,                          -1, 0,  },
+       {       -1, -1,                         1, 0,   },
+       {       -1, 2,                          0, -1,  },
+       {       -1, -2,                         0, -1,  },
+       {       -1, 5,                          0, -1,  },
+       {       -1, -5,                         0, -1,  },
+       {       2, 1,                           2, 0,   },
+       {       2, -1,                          -2, 0,  },
+       {       2, 2,                           1, 0,   },
+       {       2, -2,                          -1, 0,  },
+       {       2, 5,                           0, 2,   },
+       {       2, -5,                          0, 2,   },
+       {       -2, 1,                          -2, 0,  },
+       {       -2, -1,                         2, 0,   },
+       {       -2, 2,                          -1, 0,  },
+       {       -2, -2,                         1, 0,   },
+       {       -2, 5,                          0, -2,  },
+       {       -2, -5,                         0, -2,  },
+       {       17, 5,                          3, 2,   },
+       {       -17, -5,                        3, -2,  },
+       {       17, -5,                         -3, 2,  },
+       {       -17, 5,                         -3, -2, },
+       {       2147483647, 1,                  2147483647, 0,         },
+       {       -2147483647, 1,                 -2147483647, 0,        },
+       {       2147483648, 1,                  2147483648, 0,         },
+       {       -2147483647-1, 1,               -2147483647-1, 0,      },
+       {       2147483647, 2,                  1073741823, 1,         },
+       {       -2147483647, 2,                 -1073741823, -1,       },
+       {       2147483648, 2,                  1073741824, 0,         },
+       {       -2147483647-1, 2,               -1073741824, 0,        },
+#ifdef INT_LEAST64_MAX                 /* else might support only 32 bits */
+       {       4294967295, 1,                  4294967295, 0,         },
+       {       -4294967296+1, 1,               -4294967296+1, 0,      },
+       {       4294967296, 1,                  4294967296, 0,         },
+       {       -4294967296, 1,                 -4294967296, 0,        },
+       {       4294967295, -1,                 -4294967296+1, 0,      },
+       {       -4294967296+1, -1,              4294967295, 0,         },
+       {       4294967296, -1,                 -4294967296, 0,        },
+       {       -4294967296, -1,                4294967296, 0,         },
+       {       4294967295, 2,                  2147483647, 1,         },
+       {       -4294967296+1, 2,               -2147483647, -1,       },
+       {       4294967296, 2,                  2147483648, 0,         },
+       {       -4294967296, 2,                 -2147483647-1, 0,      },
+       {       4294967295, 2147483647,         2, 1,              },
+       {       -4294967296+1, 2147483647,      -2, -1,            },
+       {       4294967296, 2147483647,         2, 2,              },
+       {       -4294967296, 2147483647,        -2, -2,            },
+       {       4294967295, -2147483647,        -2, 1,             },
+       {       -4294967296+1, -2147483647,     2, -1,             },
+       {       4294967296, -2147483647,        -2, 2,             },
+       {       -4294967296, -2147483647,       2, -2,             },
+       {       4294967295, 2147483648,         1, 2147483647,     },
+       {       -4294967296+1, 2147483648,      -1, -2147483647,   },
+       {       4294967296, 2147483648,         2, 0,              },
+       {       -4294967296, 2147483648,        -2, 0,             },
+       {       4294967295, -2147483647-1,      -1, 2147483647,    },
+       {       -4294967296+1, -2147483647-1,   1, -2147483647,},
+       {       4294967296, -2147483647-1,      -2, 0,             },
+       {       -4294967296, -2147483647-1,     2, 0,              },
+       {       9223372036854775807, 1,         9223372036854775807, 0,         },
+       {       -9223372036854775807, 1,        -9223372036854775807, 0,        },
+       {       9223372036854775807, 2,         4611686018427387903, 1,         },
+       {       -9223372036854775807, 2,        -4611686018427387903, -1,       },
+#endif
+#endif
+               /* There should be a much larger battery of such tests. */
+       {       0, 0,           0, 0 }, /* 0 denom terminates the list */
+               },      *ddp;
+
+#if 0
+       for ( ddp = div_data; ddp->denom != 0; ++ddp )
+               if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot
+                    != ddp->exp_quot || result.rem != ddp->exp_rem
+                  )    {
+//                     printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX
+//                            ") failed; should be: (%"PRIdMAX",%"PRIdMAX
+//                            "), was: (%"PRIdMAX",%"PRIdMAX") ***\n",
+//                            ddp->numer, ddp->denom, ddp->exp_quot,
+//                            ddp->exp_rem, result.quot, result.rem
+//                           );
+                       printf("err:imaxdiv(%"PRIdMAX",%"PRIdMAX
+                              ") = (%"PRIdMAX",%"PRIdMAX
+                              "), is: (%"PRIdMAX",%"PRIdMAX")\n",
+                              ddp->numer, ddp->denom, ddp->exp_quot,
+                              ddp->exp_rem, result.quot, result.rem
+                             );
+                       status = EXIT_FAILURE;
+                       }
+#endif
+       }
+       
+       {
+       char            *endptr;
+       wchar_t         *wendptr;
+       static char     saved[64];      /* holds copy of input string */
+       static wchar_t  wnptr[64];      /* holds wide copy of test string */
+       static int      warned;         /* "warned for null endptr" flag */
+       register int    i;
+       static struct
+               {
+               char *          nptr;
+               int             base;
+               intmax_t        exp_val;
+               int             exp_len;
+               }       str_data[] =
+               {
+       {       "", 0,                          0, 0,      },
+       {       "", 2,                          0, 0,      },
+       {       "", 8,                          0, 0,      },
+       {       "", 9,                          0, 0,      },
+       {       "", 10,                         0, 0,      },
+       {       "", 16,                         0, 0,      },
+       {       "", 36,                         0, 0,      },
+       {       "0", 0,                         0, 1,      },
+       {       "0", 2,                         0, 1,      },
+       {       "0", 8,                         0, 1,      },
+       {       "0", 9,                         0, 1,      },
+       {       "0", 10,                        0, 1,      },
+       {       "0", 16,                        0, 1,      },
+       {       "0", 36,                        0, 1,      },
+       {       "+0", 0,                        0, 2,      },
+       {       "+0", 2,                        0, 2,      },
+       {       "+0", 8,                        0, 2,      },
+       {       "+0", 9,                        0, 2,      },
+       {       "+0", 10,                       0, 2,      },
+       {       "+0", 16,                       0, 2,      },
+       {       "+0", 36,                       0, 2,      },
+       {       "-0", 0,                        0, 2,      },
+       {       "-0", 2,                        0, 2,      },
+       {       "-0", 8,                        0, 2,      },
+       {       "-0", 9,                        0, 2,      },
+       {       "-0", 10,                       0, 2,      },
+       {       "-0", 16,                       0, 2,      },
+       {       "-0", 36,                       0, 2,      },
+       {       "Inf", 0,                       0, 0,      },
+       {       "Inf", 2,                       0, 0,      },
+       {       "Inf", 8,                       0, 0,      },
+       {       "Inf", 9,                       0, 0,      },
+       {       "Inf", 10,                      0, 0,      },
+       {       "Inf", 16,                      0, 0,      },
+       {       "Inf", 36,                      24171, 3,  },
+       {       "+Inf", 0,                      0, 0,      },
+       {       "+Inf", 2,                      0, 0,      },
+       {       "+Inf", 8,                      0, 0,      },
+       {       "+Inf", 9,                      0, 0,      },
+       {       "+Inf", 10,                     0, 0,      },
+       {       "+Inf", 16,                     0, 0,      },
+       {       "+Inf", 36,                     24171, 4,  },
+       {       "-Inf", 0,                      0, 0,      },
+       {       "-Inf", 2,                      0, 0,      },
+       {       "-Inf", 8,                      0, 0,      },
+       {       "-Inf", 9,                      0, 0,      },
+       {       "-Inf", 10,                     0, 0,      },
+       {       "-Inf", 16,                     0, 0,      },
+       {       "-Inf", 36,                     -24171, 4, },
+       {       "inf", 0,                       0, 0,      },
+       {       "inf", 2,                       0, 0,      },
+       {       "inf", 8,                       0, 0,      },
+       {       "inf", 9,                       0, 0,      },
+       {       "inf", 10,                      0, 0,      },
+       {       "inf", 16,                      0, 0,      },
+       {       "inf", 36,                      24171, 3,  },
+       {       "+inf", 0,                      0, 0,      },
+       {       "+inf", 2,                      0, 0,      },
+       {       "+inf", 8,                      0, 0,      },
+       {       "+inf", 9,                      0, 0,      },
+       {       "+inf", 10,                     0, 0,      },
+       {       "+inf", 16,                     0, 0,      },
+       {       "+inf", 36,                     24171, 4,  },
+       {       "-inf", 0,                      0, 0,      },
+       {       "-inf", 2,                      0, 0,      },
+       {       "-inf", 8,                      0, 0,      },
+       {       "-inf", 9,                      0, 0,      },
+       {       "-inf", 10,                     0, 0,      },
+       {       "-inf", 16,                     0, 0,      },
+       {       "-inf", 36,                     -24171, 4, },
+       {       "119b8Z", 0,                    119, 3,         },
+       {       "119bZ", 0,                     119, 3,             },
+       {       "-0119bZ", 0,                   -9, 4,          },
+       {       " \t\n 0X119bZ", 0,             4507, 10,       },
+       {       " \t\n +0X119bZ", 0,            4507, 11,   },
+       {       " \t\n -0x119bZ", 0,            -4507, 11,  },
+       {       " \t\n 119bZ", 0,               119, 7,         },
+       {       "+119bZ", 0,                    119, 4,         },
+       {       "+0X119bz", 0,                  4507, 7,        },
+       {       "119b8Z", 2,                    3, 2,           },
+       {       "119bZ", 2,                     3, 2,               },
+       {       "-0119bZ", 2,                   -3, 4,          },
+       {       " \t\n 0X119bZ", 2,             0, 5,           },
+       {       " \t\n +0X119bZ", 2,            0, 6,       },
+       {       " \t\n -0x119bZ", 2,            0, 6,       },
+       {       " \t\n 119bZ", 2,               3, 6,           },
+       {       "+119bZ", 2,                    3, 3,           },
+       {       "+0X119bz", 2,                  0, 2,           },
+       {       "119b8Z", 8,                    9, 2,           },
+       {       "119bZ", 8,                     9, 2,               },
+       {       "-0119bZ", 8,                   -9, 4,          },
+       {       " \t\n 0X119bZ", 8,             0, 5,           },
+       {       " \t\n +0X119bZ", 8,            0, 6,       },
+       {       " \t\n -0x119bZ", 8,            0, 6,       },
+       {       " \t\n 119bZ", 8,               9, 6,           },
+       {       "+119bZ", 8,                    9, 3,           },
+       {       "+0X119bz", 8,                  0, 2,           },
+       {       "119b8Z", 9,                    10, 2,          },
+       {       "119bZ", 9,                     10, 2,              },
+       {       "-0119bZ", 9,                   -10, 4,         },
+       {       " \t\n 0X119bZ", 9,             0, 5,           },
+       {       " \t\n +0X119bZ", 9,            0, 6,       },
+       {       " \t\n -0x119bZ", 9,            0, 6,       },
+       {       " \t\n 119bZ", 9,               10, 6,          },
+       {       "+119bZ", 9,                    10, 3,          },
+       {       "+0X119bz", 9,                  0, 2,           },
+       {       "119b8Z", 10,                   119, 3,         },
+       {       "119bZ", 10,                    119, 3,         },
+       {       "-0119bZ", 10,                  -119, 5,        },
+       {       " \t\n 0X119bZ", 10,            0, 5,       },
+       {       " \t\n +0X119bZ", 10,           0, 6,       },
+       {       " \t\n -0x119bZ", 10,           0, 6,       },
+       {       " \t\n 119bZ", 10,              119, 7,         },
+       {       "+119bZ", 10,                   119, 4,         },
+       {       "+0X119bz", 10,                 0, 2,           },
+       {       "119b8Z", 16,                   72120, 5,       },
+       {       "119bZ", 16,                    4507, 4,        },
+       {       "-0119bZ", 16,                  -4507, 6,       },
+       {       " \t\n 0X119bZ", 16,            4507, 10,   },
+       {       " \t\n +0X119bZ", 16,           4507, 11,   },
+       {       " \t\n -0x119bZ", 16,           -4507, 11,  },
+       {       " \t\n 119bZ", 16,              4507,8,         },
+       {       "+119bZ", 16,                   4507, 5,        },
+       {       "+0X119bz", 16,                 4507, 7,        },
+       {       "119b8Z", 36,                   62580275, 6,    },
+       {       "119bZ", 36,                    1738367, 5,     },
+       {       "-0119bZ", 36,                  -1738367, 7,                 },
+       {       " \t\n 0X119bZ", 36,            1997122175, 11,          },
+       {       " \t\n +0X119bZ", 36,           1997122175, 12,          },
+       {       " \t\n -0x119bZ", 36,           -1997122175, 12,         },
+       {       " \t\n 119bZ", 36,              1738367, 9,                  },
+       {       "+119bZ", 36,                   1738367, 6,                  },
+       {       "+0X119bz", 36,                 1997122175, 8,               },
+               /* There should be a much larger battery of such tests. */
+       {       "127", 0,                       127, 3,                          },
+       {       "-127", 0,                      -127, 4,                         },
+       {       "128", 0,                       128, 3,                          },
+       {       "-128", 0,                      -127-1, 4,                       },
+       {       "255", 0,                       255, 3,                          },
+       {       "-255", 0,                      -255, 4,                         },
+       {       "256", 0,                       256, 3,                          },
+       {       "-256", 0,                      -255-1, 4,                       },
+       {       "32767", 0,                     32767, 5,                        },
+       {       "-32767", 0,                    -32767, 6,                   },
+       {       "32768", 0,                     32768, 5,                        },
+       {       "-32768", 0,                    -32767-1, 6,                 },
+       {       "65535", 0,                     65535, 5,                        },
+       {       "-65535", 0,                    -65536+1, 6,                 },
+       {       "65536", 0,                     65536, 5,                        },
+       {       "-65536", 0,                    -65536, 6,                   },
+       {       "2147483647", 0,                2147483647, 10,              },
+       {       "-2147483647", 0,               -2147483647, 11,             },
+       {       "2147483648", 0,                2147483648, 10,              },
+       {       "-2147483648", 0,               -2147483647-1, 11,           },
+       {       "4294967295", 0,                4294967295, 10,              },
+       {       "-4294967295", 0,               -4294967296+1, 11,           },
+       {       "4294967296", 0,                4294967296, 10,              },
+       {       "-4294967296", 0,               -4294967296, 11,                        },
+       {       "9223372036854775807", 0,       9223372036854775807, 19,            },
+       {       "-9223372036854775807", 0,      -9223372036854775807, 20,           },
+       {       "1234567890123456789", 0,       1234567890123456789, 19,            },
+       {       "-1234567890123456789", 0,      -1234567890123456789, 20,           },
+       {       "1", 0,                         1, 1,                                       },
+       {       "-1", 0,                        -1, 2,                                      },
+       {       "2", 0,                         2, 1,                                       },
+       {       "-2", 0,                        -2, 2,                                      },
+       {       "10", 0,                        10, 2,                                      },
+       {       "-10", 0,                       -10, 3,                                     },
+       {       "16", 0,                        16, 2,                                      },
+       {       "-16", 0,                       -16, 3,                                     },
+               /* Other test cases can be added here. */
+       {       NULL, 0,        0, 0 }, /* terminates the list */
+               },      *sdp;
+
+       for ( sdp = str_data; sdp->nptr != NULL ; ++sdp )
+               {
+               /*
+                       7.8.2.3 The strtoimax and strtoumax functions
+               */
+
+               strcpy(saved, sdp->nptr);
+
+               errno = 0;              /* shouldn't be changed */
+
+               if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base))
+                 != sdp->exp_val
+                  )    {
+                       int     save = errno;
+
+                       printf("*** strtoimax(%s,,%d) failed; should be: %"
+                              PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
+                              sdp->base, sdp->exp_val, intmax
+                             );
+                       status = EXIT_FAILURE;
+                       errno = save;
+                       }
+               else if ( endptr != sdp->nptr + sdp->exp_len )
+                       {
+                       int     save = errno;
+
+                       printf("*** strtoimax(%s,,%d) returned wrong endptr"
+                              " ***\n", sdp->nptr, sdp->base
+                             );
+                       status = EXIT_FAILURE;
+                       errno = save;
+                       }
+
+               if ( errno != 0 )
+                       {
+                       printf("*** strtoimax modified errno ***\n");
+                       status = EXIT_FAILURE;
+                       }
+
+               if ( strcmp(sdp->nptr, saved) != 0 )
+                       {
+                       printf("*** strtoimax modified its input ***\n");
+                       status = EXIT_FAILURE;
+                       strcpy(saved, sdp->nptr);
+                       }
+
+               if ( sdp->exp_val >= 0 )        /* else some sign extension */
+                       {
+                       errno = 0;      /* shouldn't be changed */
+
+                       if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base
+                                                )
+                            ) != sdp->exp_val
+                          )    {
+                               int     save = errno;
+
+                               printf("*** strtoumax(%s,,%d) failed; "
+                                      "should be: %"PRIuMAX", was: %"PRIuMAX
+                                      " ***\n", sdp->nptr, sdp->base,
+                                      sdp->exp_val, uintmax
+                                     );
+                               status = EXIT_FAILURE;
+                               errno = save;
+                               }
+                       else if ( endptr != sdp->nptr + sdp->exp_len )
+                               {
+                               int     save = errno;
+
+                               printf("*** strtoumax(%s,,%d) returned wrong "
+                                      "endptr ***\n", sdp->nptr, sdp->base
+                                     );
+                               status = EXIT_FAILURE;
+                               errno = save;
+                               }
+
+                       if ( errno != 0 )
+                               {
+                               printf("*** strtoumax modified errno ***\n");
+                               status = EXIT_FAILURE;
+                               }
+
+                       if ( strcmp(sdp->nptr, saved) != 0 )
+                               {
+                               printf("*** strtoumax"
+                                      " modified its input ***\n"
+                                     );
+                               status = EXIT_FAILURE;
+                               strcpy(saved, sdp->nptr);
+                               }
+                       }
+
+               /* tests for null endptr */
+
+#define        WARN()  if (!warned) warned = 1, printf("*** Using null endptr: ***\n")
+
+               warned = 0;
+               errno = 0;              /* shouldn't be changed */
+
+               if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base))
+                 != sdp->exp_val
+                  )    {
+                       int     save = errno;
+
+                       WARN();
+                       printf("*** strtoimax(%s,NULL,%d) failed; "
+                              "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n",
+                              sdp->nptr, sdp->base, sdp->exp_val, intmax
+                             );
+                       status = EXIT_FAILURE;
+                       errno = save;
+                       }
+
+               if ( errno != 0 )
+                       {
+                       WARN();
+                       printf("*** strtoimax modified errno ***\n");
+                       status = EXIT_FAILURE;
+                       }
+
+               if ( strcmp(sdp->nptr, saved) != 0 )
+                       {
+                       WARN();
+                       printf("*** strtoimax modified its input ***\n");
+                       status = EXIT_FAILURE;
+                       strcpy(saved, sdp->nptr);
+                       }
+
+               if ( sdp->exp_val >= 0 )        /* else some sign extension */
+                       {
+                       errno = 0;      /* shouldn't be changed */
+
+                       if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL,
+                                                 sdp->base
+                                                )
+                            ) != sdp->exp_val
+                          )    {
+                               int     save = errno;
+
+                               WARN();
+                               printf("*** strtoumax(%s,NULL,%d) failed; "
+                                      "should be: %"PRIuMAX", was: %"PRIuMAX
+                                      " ***\n", sdp->nptr, sdp->base,
+                                      sdp->exp_val, uintmax
+                                     );
+                               status = EXIT_FAILURE;
+                               errno = save;
+                               }
+
+                        if ( errno != 0 )
+                               {
+                               WARN();
+                               printf("*** strtoumax modified errno ***\n");
+                               status = EXIT_FAILURE;
+                               }
+
+                        if ( strcmp(sdp->nptr, saved) != 0 )
+                               {
+                               WARN();
+                               printf("*** strtoumax"
+                                      " modified its input ***\n"
+                                     );
+                               status = EXIT_FAILURE;
+                               strcpy(saved, sdp->nptr);
+                               }
+                       }
+
+               /*
+                       7.8.2.4 The wcstoimax and wcstoumax functions
+               */
+
+               for ( i = 0; i < 64; ++i )
+                       if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
+                               break;
+
+               errno = 0;              /* shouldn't be changed */
+
+               if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base))
+                 != sdp->exp_val
+                  )    {
+                       int     save = errno;
+
+                       printf("*** wcstoimax(%s,,%d) failed; should be: %"
+                              PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
+                              sdp->base, sdp->exp_val, intmax
+                             );
+                       status = EXIT_FAILURE;
+                       errno = save;
+                       }
+               else if ( wendptr != wnptr + sdp->exp_len )
+                       {
+                       int     save = errno;
+
+                       printf("*** wcstoimax(%s,,%d) returned wrong endptr"
+                              " ***\n", sdp->nptr, sdp->base
+                             );
+                       status = EXIT_FAILURE;
+                       errno = save;
+                       }
+
+               if ( errno != 0 )
+                       {
+                       printf("*** wcstoimax modified errno ***\n");
+                       status = EXIT_FAILURE;
+                       }
+
+               for ( i = 0; i < 64; ++i )
+                       if ( wnptr[i] != sdp->nptr[i] )
+                               {
+                               printf("*** wcstoimax modified its input ***\n"
+                                     );
+                               status = EXIT_FAILURE;
+
+                               for ( ; i < 64; ++i )
+                                       if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
+                                               break;
+
+                               break;
+                               }
+                       else if ( wnptr[i] == '\0' )
+                               break;
+
+               if ( sdp->exp_val >= 0 )        /* else some sign extension */
+                       {
+                       errno = 0;      /* shouldn't be changed */
+
+                       if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base)
+                            ) != sdp->exp_val
+                          )    {
+                               int     save = errno;
+
+                               printf("*** wcstoumax(%s,,%d) failed; "
+                                      "should be: %"PRIuMAX", was: %"PRIuMAX
+                                      " ***\n", sdp->nptr, sdp->base,
+                                      sdp->exp_val, uintmax
+                                     );
+                               status = EXIT_FAILURE;
+                               errno = save;
+                               }
+                       else if ( wendptr != wnptr + sdp->exp_len )
+                               {
+                               int     save = errno;
+
+                               printf("*** wcstoumax(%s,,%d) returned wrong "
+                                      "endptr ***\n", sdp->nptr, sdp->base
+                                     );
+                               status = EXIT_FAILURE;
+                               errno = save;
+                               }
+
+                       if ( errno != 0 )
+                               {
+                               printf("*** wcstoumax modified errno ***\n");
+                               status = EXIT_FAILURE;
+                               }
+
+                       for ( i = 0; i < 64; ++i )
+                               if ( wnptr[i] != sdp->nptr[i] )
+                                       {
+                                       printf("*** wcstoumax"
+                                              " modified its input ***\n"
+                                             );
+                                       status = EXIT_FAILURE;
+
+                                       for ( ; i < 64; ++i )
+                                               if ( (wnptr[i] = sdp->nptr[i])
+                                                 == '\0'
+                                                  )
+                                                       break;
+
+                                       break;
+                                       }
+                               else if ( wnptr[i] == '\0' )
+                                       break;
+                       }
+
+               /* tests for null endptr */
+
+               warned = 0;
+               errno = 0;              /* shouldn't be changed */
+
+               if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base))
+                 != sdp->exp_val
+                  )    {
+                       int     save = errno;
+
+                       WARN();
+                       printf("*** wcstoimax(%s,NULL,%d) failed; should be: %"
+                              PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
+                              sdp->base, sdp->exp_val, intmax
+                             );
+                       status = EXIT_FAILURE;
+                       errno = save;
+                       }
+
+               if ( errno != 0 )
+                       {
+                       WARN();
+                       printf("*** wcstoimax modified errno ***\n");
+                       status = EXIT_FAILURE;
+                       }
+
+               for ( i = 0; i < 64; ++i )
+                       if ( wnptr[i] != sdp->nptr[i] )
+                               {
+                               WARN();
+                               printf("*** wcstoimax modified its input ***\n"
+                                     );
+                               status = EXIT_FAILURE;
+
+                               for ( ; i < 64; ++i )
+                                       if ( (wnptr[i] = sdp->nptr[i])
+                                         == '\0'
+                                          )
+                                               break;
+
+                               break;
+                               }
+                       else if ( wnptr[i] == '\0' )
+                               break;
+
+               if ( sdp->exp_val >= 0 )        /* else some sign extension */
+                       {
+                       errno = 0;      /* shouldn't be changed */
+
+                       if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL,
+                                                 sdp->base
+                                                )
+                            ) != sdp->exp_val
+                          )    {
+                               int     save = errno;
+
+                               WARN();
+                               printf("*** wcstoumax(%s,NULL,%d) failed; "
+                                      "should be: %"PRIuMAX", was: %"PRIuMAX
+                                      " ***\n", sdp->nptr, sdp->base,
+                                      sdp->exp_val, uintmax
+                                     );
+                               status = EXIT_FAILURE;
+                               errno = save;
+                               }
+
+                        if ( errno != 0 )
+                               {
+                               WARN();
+                               printf("*** wcstoumax modified errno ***\n");
+                               status = EXIT_FAILURE;
+                               }
+
+                       for ( i = 0; i < 64; ++i )
+                               if ( wnptr[i] != sdp->nptr[i] )
+                                       {
+                                       WARN();
+                                       printf("*** wcstoumax"
+                                              " modified its input ***\n"
+                                             );
+                                       status = EXIT_FAILURE;
+
+                                       for ( ; i < 64; ++i )
+                                               if ( (wnptr[i] = sdp->nptr[i])
+                                                 == '\0'
+                                                  )
+                                                       break;
+
+                                       break;
+                                       }
+                               else if ( wnptr[i] == '\0' )
+                                       break;
+                       }
+               }
+
+       /*
+               7.8.2.3 The strtoimax and strtoumax functions (continued)
+       */
+
+       if ( (intmax = strtoimax("1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890",
+                                &endptr, 0
+                               )
+            ) != INTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** strtoimax failed overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (intmax = strtoimax("+1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890",
+                                &endptr, 0
+                               )
+            ) != INTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** strtoimax failed +overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (intmax = strtoimax("-1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890",
+                                &endptr, 0
+                               )
+            ) != INTMAX_MIN || errno != ERANGE
+          )    {
+               printf("*** strtoimax failed -overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (uintmax = strtoumax("1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890",
+                                &endptr, 0
+                               )
+            ) != UINTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** strtoumax failed overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890",
+                                &endptr, 0
+                               )
+            ) != UINTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** strtoumax failed +overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890"
+                                "1234567890123456789012345678901234567890",
+                                &endptr, 0
+                               )
+            ) != UINTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** strtoumax failed -overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       /*
+               7.8.2.4 The wcstoimax and wcstoumax functions (continued)
+       */
+
+#ifdef NO_INTERNAL_WCHAR
+               printf("NO_INTERNAL_WCHAR\n");
+#else
+
+       if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890",
+                                &wendptr, 0
+                               )
+            ) != INTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** wcstoimax failed overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890",
+                                &wendptr, 0
+                               )
+            ) != INTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** wcstoimax failed +overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890",
+                                &wendptr, 0
+                               )
+            ) != INTMAX_MIN || errno != ERANGE
+          )    {
+               printf("*** wcstoimax failed -overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890",
+                                &wendptr, 0
+                               )
+            ) != UINTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** wcstoumax failed overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890",
+                                &wendptr, 0
+                               )
+            ) != UINTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** wcstoumax failed +overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+
+       if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890"
+                                L"1234567890123456789012345678901234567890",
+                                &wendptr, 0
+                               )
+            ) != UINTMAX_MAX || errno != ERANGE
+          )    {
+               printf("*** wcstoumax failed -overflow test ***\n");
+               status = EXIT_FAILURE;
+               }
+#endif // NO_INTERNAL_WCHAR
+       }
+#endif /* defined(INTMAX_MAX) */
+
+       if ( status != 0 )
+               printf("sitest failed.\n");
+
+       return status;
+}
+
+#endif
\ No newline at end of file
diff --git a/test/readme.txt b/test/readme.txt
new file mode 100644 (file)
index 0000000..cd3b750
--- /dev/null
@@ -0,0 +1,25 @@
+This directory contains test code for automatic regression testing of the CC65
+compiler.
+
+
+/val  - the bulk of tests are contained here, individual tests should exit with
+        an exit code of EXIT_SUCCESS when they pass, or EXIT_FAILURE on error
+
+/ref  - these tests produce output that must be compared with reference output
+
+/err  - contains tests that MUST NOT compile
+
+/misc - a few tests that need special care of some sort
+
+
+to run the tests use "make" in this (top) directory, the makefile should exit
+with no error.
+
+when a test failed you can use "make continue" to run further tests
+
+--------------------------------------------------------------------------------
+
+TODO:
+
+- reduce usage of "common.h" to a minimum
+- convert more tests from using reference output to returning an exit code
index afbe41c64c5350c2eeaf425e5647f89916c0989b..e8bd1ca2e82a11ec9102073516a0df6ef1a4b4fb 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include <stdio.h>
+
 int up[15], down[15], rows[8], x[8];
 void queens(int c);
 void print(void);
diff --git a/test/ref/Makefile b/test/ref/Makefile
new file mode 100644 (file)
index 0000000..b752adc
--- /dev/null
@@ -0,0 +1,92 @@
+
+# makefile for the regression tests that generate output which has to be
+# compared with reference output
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+DIFF := $(WORKDIR)/bdiff
+
+CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
+
+.PHONY: all clean
+
+REFS := $(patsubst %.c,$(WORKDIR)/%.ref,$(wildcard *.c))
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+all: $(REFS) $(TESTS)
+
+$(WORKDIR)/%.ref: %.c
+       $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
+       $(WORKDIR)/$*.host > $@
+
+$(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) -O $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) -Os $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) -Osi $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) -Osir $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) -Oi $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) -Oir $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+$(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
+       $(CL65) -Or $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
+       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+
+clean:
+       @$(RM) $(TESTS)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.out)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.ref)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.host)
index 4dd454b9866d24b8ca906837d35fcc6023572cae..78afbb2c23f6e58ba8bd14e64442e15447fd5501 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 long a;  /* must be static life */
 long b;  /* must be static life */
 
index 11ef735149d4d27abdd2e10dfb4bb21f181c3389..630638f3d08eefc140bcf4c4924f486ef951a30f 100644 (file)
@@ -13,6 +13,8 @@ optimizations. If I remove the struct inside f() it compiles fine ?!?
 Best, Oliver
 */
 
+#include <stdio.h>
+
 void f(void){struct{int i;}d;}
 struct{void(*p)(void);}s={f};
 
index f515716f7308c76566c17e01eda4edbc88cf4d50..be889a6088fc57dd9a3680a5cbad1514d5ec07da 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 /*
 cc65 doesn't compile this, if i use the "-O"-option.
 but it works with "while(!0)"; instead of  "for(;;);"
index fef22268f00bea6a8818d231c4e245f08a6eec56..3f8279b276362d99d7e23e12809a4466a27e665a 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include <stdio.h>
+
 /*
 there is a bug in the preprocessor (i think) ... the following works 
 (compiles) correctly:
index fb4773afb1715d34101f76ab36958e8e5da5ecbe..b260f0afd1081cc4aa55ace3ee010842028e0e0c 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!
 */
 
+#include "common.h"
+
 struct Record {
   struct Record *PtrComp;
   int x;
index c8e5ce9344b1d68499ccb9057369b1636eeb1f9a..6ac5d9dcb757fcd39ea7bb5b5a4cb1215ef069c3 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Oliver Schmidt
 */
 
+#include <stdio.h>
+
 /*
 After spending a "little" time I finally succeeded in isolating an
 (maybe THE) optimizer bug causing Contiki to fail.
index a319fec50dabdee49e7e7eda2560af1b212999a7..da6e37ef3ae80394c14a8ee3ec1db89755084438 100644 (file)
@@ -18,6 +18,8 @@
 
 */
 
+#include <stdio.h>
+
 int foo=0,bar=2;
 
 int main(void)
index 1c69e02f902dc2baa99add4defc041226c35b2e8..31f725f8b99ecacc2ef808d98a79a031b975a7be 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Johan Kotlinski
 */
 
+#include <stdio.h>
+
 /*
 This produces the compiler error "test.c(9): Error: Assignment to const"
 Shouldn't be an error, should it? baz is const, bar isn't.
index 2222539923bad91a2fcdd4f6d23f88f8fa1e5fd8..25d197c1180d66b4620e3bf39f3f76eedd8b9bcf 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Johan Kotlinski
 */
 
+#include <stdio.h>
+
 /*
 ...gives "test.c(2): Error: Variable `foo' has unknown size" using -Cl.
 Is it really unknown?
index 76b3f4a70fe582cdb3d6f99c9f5079b937e93110..83be84b67712e344d4b9dfaf711211352930e28f 100644 (file)
@@ -8,6 +8,8 @@
     test2 and test3 will result in an endless loop (SVN version: 4974M)
 */
 
+#include <stdio.h>
+
 #define OPENTEST()
 #define CLOSETEST()
 
index 951f31295e8651cbf2b10d280517b3a8057ff892..66fb42b1042ac1c86fc0780e8d13632b8a4a78c2 100644 (file)
@@ -8,11 +8,16 @@
         cf - print character frequencies
 */
 
+#include "common.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
 
+FILE *in;
+
 #define INFILE   "cf.in"
+#define GETCHAR() fgetc(in)
 
 #ifndef NO_FLOATS
 float f[0x100];
@@ -35,6 +40,11 @@ char *argv[];
         signed cutoff;
 #endif
 
+        in = fopen(INFILE, "rb");
+        if (in == NULL) {
+            return EXIT_FAILURE;
+        }
+
        if (argc <= 1)
 #ifndef NO_FLOATS
                cutoff = 0.0;
@@ -176,6 +186,6 @@ char *argv[];
 #endif
                }
     }
-
+    fclose(in);
     return 0;
 }
diff --git a/test/ref/cf.in b/test/ref/cf.in
new file mode 100755 (executable)
index 0000000..8190039
--- /dev/null
@@ -0,0 +1,19 @@
+start cf.input >
+The sky above the port was the color of television, tuned
+to a dead channel.
+"It's not like I'm using," Case heard someone say, as he
+shouldered his way through the crowd around the door of the
+Chat. "It's like my body's developed this massive drug deficiency."
+It was a Sprawl voice and a Sprawl joke. The Chatsubo
+was a bar for professional expatriates; you could drink there
+for a week and never hear two words in Japanese.
+Ratz was tending bar, his prosthetic arm jerking monotonously
+as he filled a tray of glasses with draft Kirin. He saw
+Case and smiled, his teeth a web work of East European steel
+and brown decay. Case found a place at the bar, between the
+unlikely tan on one of Lonny Zone's whores and the crisp naval
+uniform of a tall African whose cheekbones were ridged with
+Joe boys," Ratz said, shoving a draft across the bar with his
+good hand. "Maybe some business with you, Case?"
+Case shrugged. The girl to his right giggled and nudged
+< end cf.input
index 1aa9f8e3f6bae26ed7e9d9ea0dd4cd30b030288e..65ebc70be5bd479dbf2a67a5221dca388ef6868c 100644 (file)
@@ -4,6 +4,7 @@
   !!LICENCE!!     Public Domain
 */
 
+#include "common.h"
 #include <limits.h>
 #include <ctype.h>
 
diff --git a/test/ref/common.h b/test/ref/common.h
new file mode 100644 (file)
index 0000000..dada61a
--- /dev/null
@@ -0,0 +1,22 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NO_OLD_FUNC_DECL
+#define NO_TYPELESS_INT
+#define NO_TYPELESS_INT_PTR
+#define MAIN_RETURNS_INT
+#define NO_IMPLICIT_FUNC_PROTOTYPES
+#define NO_FLOATS
+#define NO_WCHAR
+#define NO_EMPTY_FUNC_ARGS
+#define NO_SLOPPY_STRUCT_INIT
+#define NO_FUNCS_TAKE_STRUCTS
+#define NO_FUNCS_RETURN_STRUCTS
+#define CAST_STRUCT_PTR
+#define NO_TYPELESS_STRUCT_PTR
+#define NO_IMPLICIT_FUNCPTR_CONV
+#define SIZEOF_INT_16BIT
+#define SIZEOF_LONG_32BIT
+#define UNSIGNED_CHARS
+#define UNSIGNED_BITFIELDS
index ed7b6084eba8348b7dd65010596e9a32027e06a6..841c1b3b20ca39ef51761cc23c98f3e5add0a4ee 100644 (file)
@@ -4,6 +4,9 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+#include <stdio.h>
+
 signed char c;
 signed short s;
 signed int i;
diff --git a/test/ref/fields.c b/test/ref/fields.c
deleted file mode 100644 (file)
index 794a819..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-  !!DESCRIPTION!! bitfield test
-  !!ORIGIN!!      LCC 4.1 Testsuite
-  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
-*/
-
-#ifdef NO_BITFIELDS
-
-main()
-{
-        printf("NO_BITFIELDS\n\r");
-}
-
-#else
-
-#ifdef SIZEOF_INT_16BIT
-
-#ifdef REFCC
-#include <stdint.h>
-struct foo {
-       int16_t a;
-       char b;
-       int16_t x : 12, y : 4;
-       int16_t zz : 1, : 0, : 4, z : 3;
-       char c;
-} x = { 1, 2, 3, 4, 5, 6 };
-
-struct baz { uint16_t a:2, b:4, c:16;} y = { 7, 8, 9};
-int16_t i = 8;
-
-#else
-
-struct foo {
-       int a;
-       char b;
-       int x : 12, y : 4;
-       int zz : 1, : 0, : 4, z : 3;
-       char c;
-} x = { 1, 2, 3, 4, 5, 6 };
-
-struct baz { unsigned int a:2, b:4, c:16;} y = { 7, 8, 9};
-int i = 8;
-#endif
-
-#else
-struct foo {
-       int a;
-       char b;
-       int x : 12, y : 4, : 0, : 4, z : 3;
-       char c;
-} x = { 1, 2, 3, 4, 5, 6 };
-
-struct baz { unsigned int a:2, b:4, c:32;} y = { 7, 8, 9};
-int i = 16;
-#endif
-
-#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
-f1(struct baz *p);
-f2(struct baz *p);
-#endif
-
-main()
-{
-       printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c);
-       printf("y = %d b:%d c:%d\n", y.a, y.b, y.c);
-       x.y = i;
-       x.z = 070;
-       printf("x = %d b:%d %d %d %d c:%d\n", x.a, x.b, x.x, x.y, x.z, x.c);
-       y.a = 2;
-       y.c = i;
-       printf("y = %d b:%d c:%d\n", y.a, y.b, y.c);
-#ifdef CAST_STRUCT_PTR
-       f2((struct baz *)&x);
-#else
-       f2(&x);
-#endif
-       return 0;
-}
-
-f1(struct baz *p) {
-       p->a = p->b = 0;
-       if (p->b)
-               printf("p->b != 0!\n");
-       p->a = 0x3; p->b = 0xf;
-       printf("p->a = 0x%x, p->b = 0x%x\n", p->a, p->b);
-}
-f2(struct baz *p) {
-       p->a = (i==0);
-       p->b = (f1(p),0);
-}
-
-#endif
index dc3f28a81473445d8d1ea574501722258187ac04..5a581675318dc39af59782ce50ee09a94b810d9f 100644 (file)
@@ -4,12 +4,13 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC\r
 */\r
 \r
+#include "common.h"\r
 /* todo: add back conditional stuff here ! */\r
 \r
 typedef struct { int codes[3]; char name[6]; } Word;\r
 \r
-#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
-
+#ifdef NO_IMPLICIT_FUNC_PROTOTYPES\r
+\r
 #ifdef NO_OLD_FUNC_DECL\r
 f();\r
 void g(Word *p);\r
@@ -42,8 +43,8 @@ Word words[] = {
 \r
 /*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/\r
 int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };\r
-int *y[] = { x[0], x[1], x[2], 0 };
-
+int *y[] = { x[0], x[1], x[2], 0 };\r
+\r
 main()\r
 {\r
        int i, j;\r
diff --git a/test/ref/limits.c b/test/ref/limits.c
deleted file mode 100644 (file)
index 613d6bd..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-  !!DESCRIPTION!! display type limits
-  !!ORIGIN!!      LCC 4.1 Testsuite
-  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
-*/
-
-#include <stdio.h>
-#include <limits.h>
-
-#define SSHRT_MAX      SHRT_MAX
-#define SINT_MAX       INT_MAX
-#define SLONG_MAX      LONG_MAX
-
-#define UCHAR_MIN   0
-#define USHRT_MIN   0
-#define SSHRT_MIN   SHRT_MIN
-#define UINT_MIN    0
-#define SINT_MIN    INT_MIN
-#define ULONG_MIN   0l
-#define SLONG_MIN   LONG_MIN
-
-int main(void) {
-        printf("CHAR_MAX:  0x%08x=%d\n", CHAR_MAX, CHAR_MAX);
-        printf("UCHAR_MAX: 0x%08x=%d\n", UCHAR_MAX, UCHAR_MAX);
-        printf("SCHAR_MAX: 0x%08x=%d\n", SCHAR_MAX, SCHAR_MAX);
-
-        printf("SHRT_MAX:  0x%08x=%d\n", SHRT_MAX, SHRT_MAX);
-        printf("USHRT_MAX: 0x%08x=%d\n", USHRT_MAX, USHRT_MAX);
-        printf("SSHRT_MAX: 0x%08x=%d\n", SSHRT_MAX, SSHRT_MAX);
-
-        printf("INT_MAX:   0x%08x=%d\n", INT_MAX, INT_MAX);
-        printf("UINT_MAX:  0x%08x=%d\n", UINT_MAX, UINT_MAX);
-        printf("SINT_MAX:  0x%08x=%d\n", SINT_MAX, SINT_MAX);
-
-        printf("LONG_MAX:  0x%08lx=%ld\n", LONG_MAX, LONG_MAX);
-        printf("ULONG_MAX: 0x%08lx=%ld\n", ULONG_MAX, ULONG_MAX);
-        printf("SLONG_MAX: 0x%08lx=%ld\n", SLONG_MAX, SLONG_MAX);
-
-        printf("CHAR_MIN:  0x%08x=%d\n", CHAR_MIN, CHAR_MIN);
-        printf("UCHAR_MIN: 0x%08x=%d\n", UCHAR_MIN, UCHAR_MIN);
-        printf("SCHAR_MIN: 0x%08x=%d\n", SCHAR_MIN, SCHAR_MIN);
-
-        printf("SHRT_MIN:  0x%08x=%d\n", SHRT_MIN, SHRT_MIN);
-        printf("USHRT_MIN: 0x%08x=%d\n", USHRT_MIN, USHRT_MIN);
-        printf("SSHRT_MIN: 0x%08x=%d\n", SSHRT_MIN, SSHRT_MIN);
-
-        printf("INT_MIN:   0x%08x=%d\n", INT_MIN, INT_MIN);
-        printf("UINT_MIN:  0x%08x=%d\n", UINT_MIN, UINT_MIN);
-        printf("SINT_MIN:  0x%08x=%d\n", SINT_MIN, SINT_MIN);
-
-        printf("LONG_MIN:  0x%08lx=%ld\n", LONG_MIN, LONG_MIN);
-        printf("ULONG_MIN: 0x%08lx=%ld\n", ULONG_MIN, ULONG_MIN);
-        printf("SLONG_MIN: 0x%08lx=%ld\n", SLONG_MIN, SLONG_MIN);
-
-        return 0;
-}
index 5aa3c5f4f869615f1838bb55ad56c86e8be89fc5..b2e2d9d8f7901f050a58b38216b8fc0a186b963f 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Groepaz/Hitmen
 */
 
+#include <stdio.h>
+
 int main(void)
 {
 #if 1
index a967e4805cf2d445fb97096d08c9cebf5cfe3927..f3d6c71ec542c128c9ecec3a504d4ec35d0e9c86 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     GPL (?), read COPYING.GPL
 */
 
+#include "common.h"
+
 /*
  * Sample OTCC C example. You can uncomment the first line and install
  * otcc in /usr/local/bin to make otcc scripts !  
index 3616c9391b34003a3133a9b0e018829f171c962c..e9a47dd717c3e8b2e442a510b2072cf6b0552f2f 100644 (file)
@@ -4,11 +4,14 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 #ifdef NO_FLOATS
 
 main()
 {
         printf("NO_FLOATS\n\r");
+        return 0;
 }
 
 #else
index 69d04a989492d96f8b26e3fdde8271449acaf079..d8c064ef3fbbfc36991fb4dbe36c3d6ef45273a0 100644 (file)
@@ -4,6 +4,7 @@
   !!LICENCE!!     public domain\r
 */\r
 \r
+#include "common.h"\r
 #include <stdio.h>\r
 \r
 /*\r
@@ -101,11 +102,11 @@ static void test30(void)
   cc65 seems to have problems here aswell ;/\r
 */\r
 \r
-int main(void) {
+int main(void) {\r
        test1();\r
        test2();\r
        test30();\r
        test31();\r
 /*     test32(); */\r
-       return 0;
+       return 0;\r
 }\r
index 2aedf0c8c9ac91e117aa5d33f6b55441927c4bce..56b03d6a7dadd81219c456ddbe9e4ecdfa34e10a 100644 (file)
@@ -4,6 +4,7 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <stdio.h>
 
 int main(void)
index b476cf338b3277a6e116959ea3fde5a7f7f16e6a..295a2ccade7e1090174735ce9cf293e94b0f2a23 100644 (file)
@@ -4,6 +4,7 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <stdarg.h>
 
 #ifndef NO_FUNCS_TAKE_STRUCTS
index ccd74953f1fc9b6105cda0cfcfd26fcd75ba7d4f..a0f181e96e6d5b54fbb000ef0a8114963656d8b8 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 typedef struct point { int x,y; } point;
 typedef struct rect { point pt1, pt2; } rect;
 
index 1fc315d901d3050f07491432ad51b9d8a1fe4c23..0821d29ee67d3a5f683d617e2d9563607c62927e 100644 (file)
@@ -4,6 +4,7 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
 #include <limits.h>
 
 #ifdef NO_IMPLICIT_FUNC_PROTOTYPES
index 3e9c80fb2b14357626073e6ff9e0ef793a8d3a39..0539d83989b8fbfae825c424624184ab0d481a3c 100644 (file)
@@ -11,6 +11,9 @@
 
 #define MAXWORDS 250
 
+FILE *in;
+#define getchar() fgetc(in)
+
 struct node
 {
        int count;              /* frequency count */
@@ -122,11 +125,17 @@ int main(void)
        struct node *root;
        char word[20];
 
+        in = fopen("wf1.in","rb");
+        if (in == NULL) {
+            return EXIT_FAILURE;
+        }
+
        root = 0;
        next = 0;
        while (getword(word))
                lookup(word, &root)->count++;
        tprint(root);
 
+        fclose(in);
         return 0;
 }
diff --git a/test/ref/wf1.in b/test/ref/wf1.in
new file mode 100644 (file)
index 0000000..3e50fba
--- /dev/null
@@ -0,0 +1,17 @@
+The sky above the port was the color of television, tuned
+to a dead channel.
+"It's not like I'm using," Case heard someone say, as he
+shouldered his way through the crowd around the door of the
+Chat. "It's like my body's developed this massive drug deficiency."
+It was a Sprawl voice and a Sprawl joke. The Chatsubo
+was a bar for professional expatriates; you could drink there
+for a week and never hear two words in Japanese.
+Ratz was tending bar, his prosthetic arm jerking monotonously
+as he filled a tray of glasses with draft Kirin. He saw
+Case and smiled, his teeth a web work of East European steel
+and brown decay. Case found a place at the bar, between the
+unlikely tan on one of Lonny Zone's whores and the crisp naval
+uniform of a tall African whose cheekbones were ridged with
+Joe boys," Ratz said, shoving a draft across the bar with his
+good hand. "Maybe some business with you, Case?"
+Case shrugged. The girl to his right giggled and nudged
index 3baefd348d50c0f7d730b0f028b80514747a2886..5768f80d00b5fb5708c8db6aa58018ecb0e68882 100644 (file)
@@ -6,6 +6,8 @@
 
 /*#define STANDALONE*/
 
+#include "common.h"
+
 #ifndef YACCDBG
 
 #include <stdio.h>
@@ -19,6 +21,9 @@
 
 #endif
 
+FILE *infile, *outfile;
+#define getchar() fgetc(infile)
+
 /* hack the original tables to work with both petscii and ascii */
 #define CHARSETHACK
 
@@ -61,7 +66,6 @@ int yymorfg;
 extern char *yysptr, yysbuf[];
 int yytchar;
 
-/*FILE *yyin ={stdin}, *yyout ={stdout};*/
 #define yyin  infile
 #define yyout outfile
 
@@ -665,7 +669,13 @@ yyunput(c)
 main() 
 {
         printf("main start\n");
+        infile = fopen("yacc.in","rb");
+        if (infile == NULL) {
+            return EXIT_FAILURE;
+        }
+        outfile = stdout;
         yyparse();
+        fclose(infile);
         printf("main end\n");
         return 0;
 }
diff --git a/test/ref/yacc.in b/test/ref/yacc.in
new file mode 100755 (executable)
index 0000000..697b244
--- /dev/null
@@ -0,0 +1,3 @@
+x=(e+1)*3/(3+7)
+
+
index c62fca34aaa188667c81557af2f7d655b4feae3b..78d654deda466b04d5ccf52401304e75609d7efd 100644 (file)
@@ -5,6 +5,8 @@
   !!AUTHOR!!      Groepaz/Hitmen
 */
 
+#include <stdio.h>
+
 # define YYTYPE char
 struct yywork 
 { 
diff --git a/test/val/Makefile b/test/val/Makefile
new file mode 100644 (file)
index 0000000..2e0aca2
--- /dev/null
@@ -0,0 +1,70 @@
+
+# makefile for the regression tests that return an error code on failure
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+CC65FLAGS = -t sim6502
+SIM65FLAGS = -x 200000000
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+
+ifdef CMD_EXE
+RM := del /f
+else
+RM := rm -f
+endif
+
+WORKDIR := ./../../testwrk
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.c)
+TESTS := $(SOURCES:%.c=$(WORKDIR)/%.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.o.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.os.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.osir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oi.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.oir.prg)
+TESTS += $(SOURCES:%.c=$(WORKDIR)/%.or.prg)
+
+all: $(TESTS)
+
+$(WORKDIR)/%.prg: %.c
+       $(CL65) $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.o.prg: %.c
+       $(CL65) -O $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.os.prg: %.c
+       $(CL65) -Os $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.osi.prg: %.c
+       $(CL65) -Osi $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.osir.prg: %.c
+       $(CL65) -Osir $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.oi.prg: %.c
+       $(CL65) -Oi $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.oir.prg: %.c
+       $(CL65) -Oir $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+$(WORKDIR)/%.or.prg: %.c
+       $(CL65) -Or $(CC65FLAGS) $< -o $@
+       $(SIM65) $(SIM65FLAGS) $@
+
+clean:
+       @$(RM) $(TESTS)
+       @$(RM) $(SOURCES:%.c=$(WORKDIR)/%.o)
diff --git a/test/val/add1.o b/test/val/add1.o
deleted file mode 100644 (file)
index bc6b2f5..0000000
Binary files a/test/val/add1.o and /dev/null differ
diff --git a/test/val/add1.prg b/test/val/add1.prg
deleted file mode 100644 (file)
index c0bdb01..0000000
Binary files a/test/val/add1.prg and /dev/null differ
index abbc93b47cc1ac00a5a2c5de56b17a47a0418ddc..c031f1d0f34ff343dcf30b0b8c8c037e7fe96ec7 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     GPL, read COPYING.GPL
 */
 
+#include "common.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
diff --git a/test/val/add3.o b/test/val/add3.o
deleted file mode 100644 (file)
index 53a4088..0000000
Binary files a/test/val/add3.o and /dev/null differ
diff --git a/test/val/add3.prg b/test/val/add3.prg
deleted file mode 100644 (file)
index 9ababe6..0000000
Binary files a/test/val/add3.prg and /dev/null differ
diff --git a/test/val/add4.o b/test/val/add4.o
deleted file mode 100644 (file)
index cc6c6aa..0000000
Binary files a/test/val/add4.o and /dev/null differ
diff --git a/test/val/add4.prg b/test/val/add4.prg
deleted file mode 100644 (file)
index b00f313..0000000
Binary files a/test/val/add4.prg and /dev/null differ
index 8ec11ef8de0c032927104872fdddfe68931195dc..d23b70a06d15cc3f8251c409b84719b3b19e8645 100644 (file)
@@ -5,6 +5,7 @@
   !!AUTHOR!!      Johan Kotlinski
 */
 
+#include <stdio.h>
 #include <assert.h>
 
 struct {
diff --git a/test/val/common.h b/test/val/common.h
new file mode 100644 (file)
index 0000000..dada61a
--- /dev/null
@@ -0,0 +1,22 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NO_OLD_FUNC_DECL
+#define NO_TYPELESS_INT
+#define NO_TYPELESS_INT_PTR
+#define MAIN_RETURNS_INT
+#define NO_IMPLICIT_FUNC_PROTOTYPES
+#define NO_FLOATS
+#define NO_WCHAR
+#define NO_EMPTY_FUNC_ARGS
+#define NO_SLOPPY_STRUCT_INIT
+#define NO_FUNCS_TAKE_STRUCTS
+#define NO_FUNCS_RETURN_STRUCTS
+#define CAST_STRUCT_PTR
+#define NO_TYPELESS_STRUCT_PTR
+#define NO_IMPLICIT_FUNCPTR_CONV
+#define SIZEOF_INT_16BIT
+#define SIZEOF_LONG_32BIT
+#define UNSIGNED_CHARS
+#define UNSIGNED_BITFIELDS
index b5dd93f01a0f29041e1d9600f7e7622975476785..9e0c97a635f0b3d03f5beadba6ca4f14b5a3839c 100644 (file)
@@ -17,9 +17,6 @@ unsigned char success = 0;
 unsigned char failures = 0;
 unsigned char dummy = 0;
 
-#ifdef SUPPORT_BIT_TYPES
-bit bit0 = 0;
-#endif
 int int0 = 0;
 int int1 = 0;
 char char0 = 0;
@@ -291,19 +288,16 @@ void c_minus1(void)
   printf("(long0 != -1)\n");
   if(long0 != -1)
   {
-       LOG_ERROR(1);
        failures++;
   }
   printf("(long0 > 0)\n");
   if(long0 > 0)
   {
-       LOG_ERROR(1);
        failures++;
   }
   printf("(long1 < 0)\n");
   if(long1 < 0)
   {
-       LOG_ERROR(1);
        failures++;
   }
 /*
index 4ce40ecc043bc0926dd1b60346d33e334391d1a7..bcd1570c8aac4855688646079cbdc9aac2e44fdd 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index d7d8ed9529eef6f13fb8c85f6fec704d1a397a3b..76f437e0ccc3a160de81f68456151eb757361703 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 03b08b4d28c26c17cebb2010f63108e7caeb358b..676c73182ff0acb8549f9d7fd045b97c3d0c233a 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 52695bfb6bfc34b3d7a552acb64fd0deb0e0aec6..bedf51e951e6886ad1ac2c2db10053383ba7b959 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index d4a0c4a90006b56bae7dcbe336d51f947dfd627c..9cb2f61c899244dddfd1748bf3ee950c3753cfa2 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 42527e80f5e246e84a63931bf8e388e5fd8a25c7..399f0a45ede098386e02712ef619ca6b1c8b06f9 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 #ifndef CQ26_INCLUDED
 struct defs {
      int cbits;          /* No. of bits per char           */
index 94f4d5fb782d17b592b39e19eac4e4445a781b73..8a8125c527fb7ecbd2d9a36c4b865e871f292f8d 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
@@ -41,7 +43,124 @@ struct defs {
      int crc;            /* Cumulative return code         */
      char rfs[8];        /* Return from section            */
 
-/*#include "cq26.c"*/ /* hardware check */
+#define CQ26_INCLUDED
+/*
+  section s26, which pokes around at the hardware
+  trying to figure out the characteristics of the machine that
+  it is running on, saves information that is subsequently
+  used by sections s626, s72, and s757. If this program is
+  to be broken up into smallish pieces, say for running on
+  a microcomputer, take care to see that s26 is called before
+  calling any of the latter three sections.
+*/
+
+/*
+        2.6  Hardware Characteristics
+*/
+
+#ifndef NO_OLD_FUNC_DECL
+s26(pd0)
+struct defs *pd0;
+{
+#else
+s26(struct defs *pd0) {
+#endif
+   static char qs26[8] = "s26    ";
+   char *ps, *pt;
+   char c0, c1;
+   #ifndef NO_FLOATS
+        float temp, one, delta;
+        double tempd, oned;
+   #endif
+   static char s[] = "%3d bits in %ss.\n";
+   static char s2[] = "%e is the least number that can be added to 1. (%s).\n";
+
+   ps = qs26;
+   pt = pd0->rfs;
+
+   while(*pt++ = *ps++);
+
+          /* Here, we shake the machinery a little to see what falls
+             out.  First, we find out how many bits are in a char.  */
+
+   pd0->cbits = 0;
+   c0 = 0;
+   c1 = 1;
+
+   while(c0 != c1) {
+     c1 = c1<<1;
+     pd0->cbits = pd0->cbits+1;
+   }
+          /* That information lets us determine the size of everything else. */
+
+   pd0->ibits = pd0->cbits * sizeof(int);
+   pd0->sbits = pd0->cbits * sizeof(short);
+   pd0->lbits = pd0->cbits * sizeof(long);
+   pd0->ubits = pd0->cbits * sizeof(unsigned);
+   #ifndef NO_FLOATS
+        pd0->fbits = pd0->cbits * sizeof(float);
+        pd0->dbits = pd0->cbits * sizeof(double);
+   #endif
+
+          /* We have now almost reconstructed the table in section 2.6, the
+             exception being the range of the floating point hardware.
+             Now there are just so many ways to conjure up a floating point
+             representation system that it's damned near impossible to guess
+             what's going on by writing a program to interpret bit patterns.
+             Further, the information isn't all that useful, if we consider
+             the fact that machines that won't handle numbers between 10**30
+             and 10**-30 are very hard to find, and that people playing with
+             numbers outside that range have a lot more to worry about than
+             just the capacity of the characteristic.
+
+             A much more useful measure is the precision, which can be ex-
+             pressed in terms of the smallest number that can be added to
+             1. without loss of significance. We calculate that here, for
+             float and double.                       */
+
+#ifndef NO_FLOATS
+   one = 1.;
+   delta = 1.;
+   temp = 0.;
+   while(temp != one) {
+     temp = one+delta;
+     delta = delta/2.;
+   }
+   pd0->fprec = delta * 4.;
+   oned = 1.;
+   delta = 1.;
+   tempd = 0.;
+   while(tempd != oned) {
+     tempd = oned+delta;
+     delta = delta/2.;
+   }
+   pd0->dprec = delta * 4.;
+#endif
+
+          /* Now, if anyone's interested, we publish the results.       */
+
+#ifndef CQ26_INCLUDED
+   if(pd0->flgm != 0) {
+     printf(s,pd0->cbits,"char");
+     printf(s,pd0->ibits,"int");
+     printf(s,pd0->sbits,"short");
+     printf(s,pd0->lbits,"long");
+     printf(s,pd0->ubits,"unsigned");
+     printf(s,pd0->fbits,"float");
+     printf(s,pd0->dbits,"double");
+     #ifndef NO_FLOATS
+        printf(s2,pd0->fprec,"float");
+        printf(s2,pd0->dprec,"double");
+     #else
+        printf("NO_FLOATS\n");
+     #endif
+   }
+#endif
+          /* Since we are only exploring and perhaps reporting, but not
+             testing any features, we cannot return an error code.  */
+
+   return 0;
+}
 
 int extvar;
 
@@ -125,10 +244,13 @@ implementation                                                  */
 
    target = ~0U;
    mask = 1;
+   printf("sizeof target: %08x pd0->cbits: %08x\n", sizeof target, pd0->cbits);
+   printf("mask: %08x target: %08x\n", mask, target);
 
    for(j=0; j<(sizeof target)*pd0->cbits; j++){
      mask = mask&target;
      target = target>>1;
+     printf("mask: %08x target: %08x\n", mask, target);
    }
 
    if(mask != 1 || target != 0){
@@ -200,11 +322,12 @@ setev(){
        int section(int j,void* pd0){
 #endif
         switch(j){
-                case 0: return s4(pd0);
+                case 0: return s26(pd0);
+                case 1: return s4(pd0);
         }
 }
 
-#define cq_sections 1
+#define cq_sections 2
 
 /*
         C REFERENCE MANUAL (main)
index f40b21d610fb1e4a6c9dfc2ddd673df5d465c4c6..3dcca645434a8e4673dd8d76912268804620c818 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 7fab43f53f909a8cc6608bd0e5e84584d612ddfb..166d3a95bbdb8f5ab3b01e82968cadd7f8938c8b 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 342b9809aef079b28d5fb6263aea766df4c404cb..7bf0d9e1eaf439e2c0c2ae717e6832b2df772e41 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 /*include "cq26.c"*/ /* hardware check */
 
 struct defs {
index 1d36b18abd952e11510f0da2de21a2b9b825eab5..f4c58801fcc254a7d8559f4a19863575094138d0 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 9a09a88f05040e1525f45c79f978c1a55e51c475..b4908f4cbe6e2e388897980d1e3bef4da9a706e9 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index dd829156c238d0b02c2eeecb45b33e02dfa0cab1..fec9c617048d5f15325e3c95cc79fb265e23bf5d 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 5f60fdcad53db3e647ffd314da321859364b4758..2f956e59d0faceb0d34640efaef7d6a9cebc1c3f 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 7c898ca5bcd2244f118e7d589a8e5e0679c9fa29..60b588555fa55a724cfb67fdc1ce1dd6c7f4d4f1 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 77d34a2a60f309f5c0787c786b78966bbb9435c3..0e743abcdaf639bde64190d16596b5c54645de20 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 198cbc4f67067a04d7b64ff2942a3e3925efb576..0271cae5d6e22fd17d3340d4e1f9aca81bd8d65c 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index fcadd9af66ab55d2bb5693709eef0d810d4daf08..d37c82f294c14bcfccfee9bfc02136c3aea7ac39 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 3e5ef938d75f1d91b324723640542aea659bb503..15b055b20a516886286df65e4aafda403db24e13 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 2800307f7d602929e8f4e2acaec4049a712601bf..9f2409e7a53641589591074dea89f87a7cd19d73 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 77bb9e88c5298eb122a3bd23b2f5e1d4d7764511..a15f75110ad819aa1e48c39b3291aee746019847 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
index 698443ce660d63daef37624c778c270879d7f91b..228ac9e770ce9ad132a7783b8872492d25fc0d44 100644 (file)
@@ -4,6 +4,8 @@
   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
 */
 
+#include "common.h"
+
 struct defs {
      int cbits;          /* No. of bits per char           */
      int ibits;          /*                 int            */
diff --git a/test/val/sitest.c b/test/val/sitest.c
deleted file mode 100644 (file)
index 9570f49..0000000
+++ /dev/null
@@ -1,1591 +0,0 @@
-/*
-  !!DESCRIPTION!! C99 WCHAR test
-  !!ORIGIN!!
-  !!LICENCE!!     public domain
-*/
-
-/*
-       sitest -- exercise features of C99 <stdint.h> and <inttypes.h>
-
-       This source code has been placed into the PUBLIC DOMAIN by its author.
-
-       last edit:      1999/11/05      gwyn@arl.mil
-
-       Tries to accommodate pre-C99 versions of <inttypes.h>.
-
-       Takes advantage of __Q8_* symbols defined by a particular
-       implementation of <stdint.h>, but doesn't require them.
-
-       NOTE:   This is not a thorough validation test of the facilities.
-*/
-
-#define NO_INTERNAL_WCHAR
-/*#define STANDALONE*/
-
-#include       <errno.h>
-#include       <limits.h>              /* for CHAR_BIT */
-#include       <stdio.h>
-#include       <stddef.h>              /* for ptrdiff_t */
-#include       <stdlib.h>
-#include       <string.h>
-
-#if !defined(STANDARD_C99) && !defined(STANDARD_CC65)
-
-#error "this test checks C99 features, which are not available in the selected standard."
-
-#else
-
-#ifdef NO_WCHAR
-
-#warn "this test checks C99 features, but NO_WCHAR is defined so the test will most definetly fails."
-
-#endif
-
-#include       <inttypes.h>            /* embeds <stdint.h> */
-
-#include       <signal.h>              /* for sig_atomic_t */
-
-#if    defined(INTMAX_MAX)             /* <inttypes.h> has C99 features */
-#include       <wchar.h>
-#endif
-
-#include       <inttypes.h>            /* test idempotency */
-
-#ifdef STANDALONE
-
-FILE *outfile=NULL;
-#define opentest(x) outfile=stdout;
-#define closetest(x)
-
-#else
-
-#endif
-
-#if    __STDC_VERSION__ >= 199901
-#ifndef        __Q8_QT
-#define        __Q8_QT long long
-#endif
-#endif
-
-#ifdef PRIdMAX
-#define        HAVE_PRIdMAX
-#ifndef        __Q8_MT
-#define        __Q8_MT intmax_t
-#endif
-#else
-#ifdef PRIdLEAST64
-#ifndef        __Q8_MT
-#define        __Q8_MT int_least64_t
-#endif
-#define        PRIdMAX PRIdLEAST64
-#else
-#ifndef        __Q8_MT
-#define        __Q8_MT long
-#endif
-#define        PRIdMAX "ld"
-#endif
-#endif
-
-#ifdef PRIuMAX
-#define        HAVE_PRIuMAX
-#define        U__Q8_MT        uintmax_t
-#else
-#ifdef PRIuLEAST64
-#define        U__Q8_MT        uint_least64_t
-#define        PRIuMAX PRIuLEAST64
-#else
-#define        U__Q8_MT        unsigned long
-#define        PRIuMAX "lu"
-#endif
-#endif
-
-#define        STR_SUB(s)      # s
-#define        STRINGIZE(s)    STR_SUB(s)      /* extra level to expand argument */
-
-#if    defined(SCNo32) || defined(PRIo32)
-static int32_t         int32;
-#endif
-static int_least16_t   intl16;
-static uint_least16_t  uintl16;
-static uint_fast16_t   uintf16;
-static intmax_t                intmax;
-static uintmax_t       uintmax;
-
-int
-main() {
-       int     status = 0;             /* exit status to be returned */
-
-       
-       /* <stdint.h> features: */
-
-       printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT );
-       printf("sizeof(char)=%u\n", (unsigned)sizeof(char));    /* s.b. 1 */
-       printf("sizeof(short)=%u\n", (unsigned)sizeof(short));
-       printf("sizeof(int)=%u\n", (unsigned)sizeof(int));
-       printf("sizeof(long)=%u\n", (unsigned)sizeof(long));
-#ifdef __Q8_QT
-       printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT));
-#else
-       printf("*** long long isn't defined ***\n");
-#endif
-       printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
-       printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t));
-       printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t));
-       printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t));
-       printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t));
-#if    defined(WINT_MAX) || __STDC_VERSION__ >= 199901
-       printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t));
-#else
-       printf("*** wint_t isn't defined ***\n");
-       status = EXIT_FAILURE;
-#endif
-#ifdef INT8_MAX
-       printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t));
-       printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t));
-#endif
-#ifdef INT9_MAX
-       printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t));
-       printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t));
-#endif
-#ifdef INT12_MAX
-       printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t));
-       printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t));
-#endif
-#ifdef INT16_MAX
-       printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t));
-       printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t));
-#endif
-#ifdef INT18_MAX
-       printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t));
-       printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t));
-#endif
-#ifdef INT24_MAX
-       printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t));
-       printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t));
-#endif
-#ifdef INT32_MAX
-       printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t));
-       printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t));
-#endif
-#ifdef INT36_MAX
-       printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t));
-       printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t));
-#endif
-#ifdef INT40_MAX
-       printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t));
-       printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t));
-#endif
-#ifdef INT48_MAX
-       printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t));
-       printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t));
-#endif
-#ifdef INT60_MAX
-       printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t));
-       printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t));
-#endif
-#ifdef INT64_MAX
-       printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t));
-       printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t));
-#endif
-#ifdef INT72_MAX
-       printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t));
-       printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t));
-#endif
-#ifdef INT128_MAX
-       printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t));
-       printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t));
-#endif
-       printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t));
-       printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t));
-       printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t));
-       printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t));
-       printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t));
-       printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t));
-#ifdef INT_LEAST64_MAX
-       printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t));
-       printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t));
-#else
-       printf("*** uint_least64_t isn't defined ***\n");
-       status = EXIT_FAILURE;
-#endif
-#ifdef INT_LEAST128_MAX
-       printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t));
-       printf("sizeof(uint_least128_t)=%u\n",
-               (unsigned)sizeof(uint_least128_t));
-#endif
-       printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t));
-       printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t));
-       printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t));
-       printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t));
-       printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t));
-       printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t));
-#ifdef INT_FAST64_MAX
-       printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t));
-       printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t));
-#else
-       printf("*** int_fast64_t isn't defined ***\n");
-       status = EXIT_FAILURE;
-#endif
-#ifdef INT_FAST128_MAX
-       printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t));
-       printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t));
-#endif
-#if    defined(INTPTR_MAX)
-       printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t));
-#if    defined(UINTPTR_MAX)
-       printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
-#else
-       printf("*** intptr_t is defined but uintptr_t isn't ***\n");
-       status = EXIT_FAILURE;
-#endif
-#elif  defined(UINTPTR_MAX)
-       printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
-       printf("*** uintptr_t is defined but intptr_t isn't ***\n");
-       status = EXIT_FAILURE;
-#else
-       printf("*** neither intptr_t nor uintptr_t is defined ***\n");
-       status = EXIT_FAILURE;
-#endif
-#ifdef INTMAX_MAX
-       printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
-       printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t));
-#else
-       printf("*** intmax_t isn't defined ***\n");
-       status = EXIT_FAILURE;
-#endif
-
-#ifdef INT8_MAX
-       printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN);
-       printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX);
-       printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX);
-#endif
-#ifdef INT9_MAX
-       printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN);
-       printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX);
-       printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX);
-#endif
-#ifdef INT12_MAX
-       printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN);
-       printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX);
-       printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX);
-#endif
-#ifdef INT16_MAX
-       printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN);
-       printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX);
-       printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX);
-#endif
-#ifdef INT18_MAX
-       printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN);
-       printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX);
-       printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX);
-#endif
-#ifdef INT24_MAX
-       printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN);
-       printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX);
-       printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX);
-#endif
-#ifdef INT32_MAX
-       printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN);
-       printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX);
-       printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX);
-#endif
-#ifdef INT36_MAX
-       printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN);
-       printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX);
-       printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX);
-#endif
-#ifdef INT40_MAX
-       printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN);
-       printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX);
-       printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX);
-#endif
-#ifdef INT48_MAX
-       printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN);
-       printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX);
-       printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX);
-#endif
-#ifdef INT60_MAX
-       printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN);
-       printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX);
-       printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX);
-#endif
-#ifdef INT64_MAX
-       printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN);
-       printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX);
-       printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX);
-#endif
-#ifdef INT72_MAX
-       printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN);
-       printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX);
-       printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX);
-#endif
-#ifdef INT128_MAX
-       printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN);
-       printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX);
-       printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX);
-#endif
-       printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN);
-       printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX);
-       printf("UINT_LEAST8_MAX=%"PRIuMAX"\n",
-               (U__Q8_MT)UINT_LEAST8_MAX);
-       printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN);
-       printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX);
-       printf("UINT_LEAST16_MAX=%"PRIuMAX"\n",
-               (U__Q8_MT)UINT_LEAST16_MAX);
-       printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN);
-       printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX);
-       printf("UINT_LEAST32_MAX=%"PRIuMAX"\n",
-               (U__Q8_MT)UINT_LEAST32_MAX);
-#ifdef INT_LEAST64_MAX
-       printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN);
-       printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX);
-       printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX);
-#endif
-#ifdef INT_LEAST128_MAX
-       printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN);
-       printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX);
-       printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX);
-#endif
-       printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN);
-       printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX);
-       printf("UINT_FAST8_MAX=%"PRIuMAX"\n",
-               (U__Q8_MT)UINT_FAST8_MAX);
-       printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN);
-       printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX);
-       printf("UINT_FAST16_MAX=%"PRIuMAX"\n",
-               (U__Q8_MT)UINT_FAST16_MAX);
-       printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN);
-       printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX);
-       printf("UINT_FAST32_MAX=%"PRIuMAX"\n",
-               (U__Q8_MT)UINT_FAST32_MAX);
-#ifdef INT_FAST64_MAX
-       printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN);
-       printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX);
-       printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX);
-#endif
-#ifdef INT_FAST128_MAX
-       printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN);
-       printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX);
-       printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX);
-#endif
-#ifdef INTPTR_MAX
-       printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN);
-       printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX);
-#endif
-#ifdef UINTPTR_MAX
-       printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX);
-#endif
-#ifdef INTMAX_MAX
-       printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN);
-       printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX);
-       printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX);
-#endif
-#ifdef PTRDIFF_MAX
-       printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN);
-       printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX);
-#endif
-#ifdef SIG_ATOMIC_MAX
-#if    SIG_ATOMIC_MIN < 0
-       printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN);
-       printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX);
-#else
-       printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN);
-       printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX);
-#endif
-#endif
-#ifdef SIZE_MAX
-       printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX);
-#endif
-
-#ifdef WCHAR_MAX
-#if    WCHAR_MIN < 0
-       printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN);
-       printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX);
-#else
-       printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN);
-       printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX);
-#endif
-#endif
-#ifdef WINT_MAX
-#if    WINT_MIN < 0
-       printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN);
-       printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX);
-#else
-       printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN);
-       printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX);
-#endif
-#endif
-
-       /*
-               7.18.4  Macros for integer constants
-       */
-
-       /* INTn_C for n=8 and 16 were at one point unimplementable
-          on most platforms, so they're treated as "optional": */
-#ifdef INT8_C
-       if ( INT8_C(-123) != -123 )
-               printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n",
-                      (__Q8_MT)INT8_C(-123)
-                     );
-       if ( UINT8_C(123) != 123 )
-               printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n",
-                      (U__Q8_MT)UINT8_C(123)
-                     );
-#endif
-#ifdef INT16_C
-       if ( INT16_C(-12345) != -12345 )
-               printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n",
-                      (__Q8_MT)INT16_C(-12345)
-                     );
-       if ( UINT16_C(12345) != 12345 )
-               printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n",
-                      (U__Q8_MT)UINT16_C(12345)
-                     );
-#endif
-       if ( INT32_C(-123456789) != -123456789 )
-               printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n",
-                      (__Q8_MT)INT32_C(-123456789)
-                     );
-       if ( UINT32_C(123456789) != 123456789 )
-               printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n",
-                      (U__Q8_MT)UINT32_C(123456789)
-                     );
-#ifdef INT_LEAST64_MAX
-       if ( INT64_C(-1234567890123456789) != -1234567890123456789 )
-               printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX
-                      " ***\n",
-                      (__Q8_MT)INT64_C(-1234567890123456789)
-                     );
-       if ( UINT64_C(1234567890123456789) != 1234567890123456789 )
-               printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX
-                      " ***\n",
-                      (U__Q8_MT)UINT64_C(1234567890123456789)
-                     );
-#endif
-#ifdef INTMAX_MAX
-       if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 )
-               printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX
-                      " ***\n",
-                      (__Q8_MT)INTMAX_C(-1234567890123456789)
-                     );
-       if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 )
-               printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX
-                      " ***\n",
-                      (U__Q8_MT)UINTMAX_C(1234567890123456789)
-                     );
-#endif
-
-       /* <inttypes.h> features: */
-
-#if    __STDC_VERSION__ >= 199901
-       printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t));
-#endif
-
-       /*
-               7.8.1   Macros for format specifiers
-       */
-
-       {
-       /* scanf these strings */
-       static const char       in_dn[] = "Z119bZ";
-       static const char       in_dmo[] = "Z-0119bZ";
-       static const char       in_dspx[] = "Z \t\n +0X119bZ";
-       static const char       in_dsmx[] = "Z \t\n -0x119bZ";
-       static const char       in_dsn[] = "Z \t\n 119bZ";
-       static const char       in_dp[] = "Z+119bZ";
-       static const char       in_dpx[] = "Z+0X119bz";
-
-       /* sprintf into this */
-       static char             buffer[1024];
-
-#if 1
-
-#define        SCAN(buf,fs,var,exp)    if ( sscanf(buf, "Z%" fs, &var) != 1 ) \
-                                       { \
-                                       printf("***%s=",fs, STR_SUB(fs) \
-                                              " failed ***\n" \
-                                             ); \
-                                       status = EXIT_FAILURE; \
-                                       } \
-                               else if ( var != (exp) ) \
-                                       { \
-                                       printf("***%s=",fs,  STR_SUB(fs) \
-                                              " should be: " STR_SUB(exp) \
-                                              ", was: %" fs " ***\n", var \
-                                             ); \
-                                       status = EXIT_FAILURE; \
-                                       } \
-                               else    /* for trailing semicolon */
-
-#define        PRINT(fs,var,exp)       if ( sprintf(buffer, "%" fs, var ) <= 0 ) \
-                                       { \
-                                       printf("***%s=",fs, STR_SUB(fs) \
-                                              " failed ***\n" \
-                                             ); \
-                                       status = EXIT_FAILURE; \
-                                       } \
-                               else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \
-                                       { \
-                                       printf("***%s=",fs,  STR_SUB(fs) \
-                                              " should be: " STR_SUB(exp) \
-                                              ", was: %s ***\n", buffer \
-                                             ); \
-                                       status = EXIT_FAILURE; \
-                                       } \
-                               else    /* for trailing semicolon */
-
-#else
-                                                                
-#define        SCAN(buf,fs,var,exp)
-#define        PRINT(fs,var,exp)
-
-#endif
-                                                                
-#ifdef SCNo32
-
-       SCAN(in_dn, SCNo32, int32, 9);
-
-#endif
-#ifdef PRIo32
-       PRINT(PRIo32, int32, 11);
-#endif
-       SCAN(in_dmo, SCNiLEAST16, intl16, -9);
-       SCAN(in_dspx, SCNdLEAST16, intl16, 0);
-       SCAN(in_dsmx, SCNiLEAST16, intl16, -4507);
-       PRINT(PRIdLEAST16, intl16, -4507);
-       PRINT(PRIiLEAST16, intl16, -4507);
-       SCAN(in_dsn, SCNxLEAST16, uintl16, 4507);
-       PRINT(PRIoLEAST16, uintl16, 10633);
-       PRINT(PRIuLEAST16, uintl16, 4507);
-       PRINT(PRIxLEAST16, uintl16, 119b);
-       PRINT(PRIXLEAST16, uintl16, 119B);
-       SCAN(in_dp, SCNxFAST16, uintf16, 4507);
-       PRINT(PRIxFAST16, uintf16, 119b);
-#ifdef SCNdMAX
-       SCAN(in_dp, SCNdMAX, intmax, 119);
-#endif
-#ifdef PRIiMAX
-       PRINT(PRIiMAX, intmax, 119);
-#endif
-#ifdef SCNoMAX
-       SCAN(in_dpx, SCNoMAX, uintmax, 0);
-#endif
-#ifdef PRIxMAX
-       PRINT(PRIxMAX, uintmax, 0);
-#endif
-       /* Obviously there should be a much larger battery of such tests. */
-       }
-
-#if    defined(INTMAX_MAX)             /* <inttypes.h> has C99 features */
-       /*
-               7.8.2   Functions for greatest-width integer types
-       */
-
-       {
-       static struct
-               {
-               intmax_t        input;
-               intmax_t        expect;
-               }       abs_data[] =
-               {
-#ifdef INT8_MAX
-         { INT8_MAX,           INT8_MAX,   },
-         { -INT8_MAX,          INT8_MAX,   },
-        {      UINT8_MAX,              UINT8_MAX,  },
-#endif
-
-#if 0
-  
-#ifdef INT16_MAX
-        {      INT16_MAX,              INT16_MAX,  },
-        {      -INT16_MAX,             INT16_MAX,  },
-        {      UINT16_MAX,             UINT16_MAX, },
-#endif
-#ifdef INT32_MAX
-        {      INT32_MAX,              INT32_MAX,  },
-        {      -INT32_MAX,             INT32_MAX,  },
-#ifdef INT_LEAST64_MAX                 /* else might support only 32 bits */
-        {      UINT32_MAX,             UINT32_MAX, },
-#endif
-#endif
-#ifdef INT64_MAX
-        {      INT64_MAX,              INT64_MAX,  },
-        {      -INT64_MAX,             INT64_MAX,  },
-#endif
-        {      INT_LEAST8_MAX,         INT_LEAST8_MAX,      },
-        {      -INT_LEAST8_MAX,        INT_LEAST8_MAX,      },
-        {      UINT_LEAST8_MAX,        UINT_LEAST8_MAX,     },
-        {      INT_LEAST16_MAX,        INT_LEAST16_MAX,     },
-        {      -INT_LEAST16_MAX,       INT_LEAST16_MAX,     },
-        {      UINT_LEAST16_MAX,       UINT_LEAST16_MAX,    },
-        {      INT_LEAST32_MAX,        INT_LEAST32_MAX,     },
-        {      -INT_LEAST32_MAX,       INT_LEAST32_MAX,     },
-#ifdef INT_LEAST64_MAX
-        {      UINT_LEAST32_MAX,       UINT_LEAST32_MAX,    },
-        {      INT_LEAST64_MAX,        INT_LEAST64_MAX,     },
-        {      -INT_LEAST64_MAX,       INT_LEAST64_MAX,     },
-#endif
-        {      INT_FAST8_MAX,          INT_FAST8_MAX,       },
-        {      -INT_FAST8_MAX, INT_FAST8_MAX,           },
-        {      UINT_FAST8_MAX, UINT_FAST8_MAX,          },
-        {      INT_FAST16_MAX, INT_FAST16_MAX,          },
-        {      -INT_FAST16_MAX,        INT_FAST16_MAX,      },
-        {      UINT_FAST16_MAX,        UINT_FAST16_MAX,     },
-        {      INT_FAST32_MAX, INT_FAST32_MAX,          },
-        {      -INT_FAST32_MAX,        INT_FAST32_MAX,      },
-#ifdef INT_FAST64_MAX
-        {      UINT_FAST32_MAX,        UINT_FAST32_MAX,     },
-        {      INT_FAST64_MAX, INT_FAST64_MAX,          },
-        {      -INT_FAST64_MAX,        INT_FAST64_MAX,      },
-#endif
-#ifdef INTPTR_MAX
-        {      INTPTR_MAX,             INTPTR_MAX,              },
-        {      -INTPTR_MAX,            INTPTR_MAX,          },
-#endif
-#ifdef UINTPTR_MAX
-        {      UINTPTR_MAX,            UINTPTR_MAX,         },
-#endif
-        {      INTMAX_MAX,             INTMAX_MAX,              },
-#ifdef PTRDIFF_MAX
-        {      PTRDIFF_MAX,            PTRDIFF_MAX,         },
-#endif
-#ifdef SIG_ATOMIC_MAX
-        {      SIG_ATOMIC_MAX,         SIG_ATOMIC_MAX,      },
-#if    SIG_ATOMIC_MIN < 0
-        {      -SIG_ATOMIC_MAX,        SIG_ATOMIC_MAX,      },
-#endif
-#endif
-#ifdef SIZE_MAX
-        {      SIZE_MAX,               SIZE_MAX,                },
-#endif
-#ifdef WCHAR_MAX
-        {      WCHAR_MAX,              WCHAR_MAX,               },
-#if    WCHAR_MIN < 0
-        {      -WCHAR_MAX,             WCHAR_MAX,               },
-#endif
-#endif
-#ifdef WINT_MAX
-        {      WINT_MAX,               WINT_MAX,                },
-#if    WINT_MIN < 0
-        {  -WINT_MAX,          WINT_MAX,                },
-#endif
-#endif
-        {      127,                            127,                 },
-        {      -127,                           127,                 },
-        {      128,                            128,                 },
-        {      -127-1,                         128,                 },
-        {      255,                            255,                 },
-        {      -256+1,                         255,                 },
-        {      256,                            256,                 },
-        {      -256,                           256,                 },
-        {      32767,                          32767,               },
-        {      -32767,                         32767,               },
-        {      32768,                          32768,               },
-        {      -32767-1,                       32768,               },
-        {      65535,                          65535,               },
-        {      -65536+1,                       65535,               },
-        {      65536,                          65536,               },
-        {      -65536,                         65536,               },
-        {      2147483647,                     2147483647,          },
-        {      -2147483647,                    2147483647,      },
-        {      2147483648,                     2147483648,          },
-        {      -2147483647-1,                  2147483648,      },
-#ifdef INT_LEAST64_MAX                 /* else might support only 32 bits */
-        {      4294967295,                     4294967295,          },
-        {      -4294967296+1,                  4294967295,      },
-        {      4294967296,                     4294967296,          },
-        {      -4294967296,                    4294967296,      },
-        {      9223372036854775807,            9223372036854775807,    },
-        {      -9223372036854775807,           9223372036854775807,    },
-        {      1234567890123456789,            1234567890123456789,    },
-        {      -1234567890123456789,           1234567890123456789,    },
-#endif
-        {      1,                              1,                                  },
-        {      -1,                             1,                                  },
-        {      2,                              2,                                  },
-        {      -2,                             2,                                  },
-        {      10,                             10,                                 },
-        {      -10,                            10,                             },
-        {      16,                             16,                                 },
-        {      -16,                            16,                             },
-#endif
-               /* Other test cases can be added here. */
-        {      0,              0       /* terminates the list */              },
-               },      *adp = abs_data;
-
-       do      {
-               if ( (intmax = imaxabs(adp->input)) != adp->expect )
-                       {
-                       printf("*** imaxabs(%"PRIdMAX") failed; should be: %"
-                              PRIdMAX", was: %"PRIdMAX" ***\n",
-                              adp->input, adp->expect, intmax
-                             );
-                       status = EXIT_FAILURE;
-                       }
-//             } while ( adp++->input != 0 );
-               } while ( (adp++)->input != 0 );
-       }
-
-       {
-       imaxdiv_t       result;
-       static struct
-               {
-               intmax_t        numer;
-               intmax_t        denom;
-               intmax_t        exp_quot;
-               intmax_t        exp_rem;
-               }       div_data[] =
-               {
-       {       0, 1,                           0, 0,   },
-#if 0
-       {       0, -1,                          0, 0,   },
-       {       0, 2,                           0, 0,   },
-       {       0, -2,                          0, 0,   },
-       {       0, 5,                           0, 0,   },
-       {       0, -5,                          0, 0,   },
-       {       1, 1,                           1, 0,   },
-       {       1, -1,                          -1, 0,  },
-       {       1, 2,                           0, 1,   },
-       {       1, -2,                          0, 1,   },
-       {       1, 5,                           0, 1,   },
-       {       1, -5,                          0, 1,   },
-       {       -1, 1,                          -1, 0,  },
-       {       -1, -1,                         1, 0,   },
-       {       -1, 2,                          0, -1,  },
-       {       -1, -2,                         0, -1,  },
-       {       -1, 5,                          0, -1,  },
-       {       -1, -5,                         0, -1,  },
-       {       2, 1,                           2, 0,   },
-       {       2, -1,                          -2, 0,  },
-       {       2, 2,                           1, 0,   },
-       {       2, -2,                          -1, 0,  },
-       {       2, 5,                           0, 2,   },
-       {       2, -5,                          0, 2,   },
-       {       -2, 1,                          -2, 0,  },
-       {       -2, -1,                         2, 0,   },
-       {       -2, 2,                          -1, 0,  },
-       {       -2, -2,                         1, 0,   },
-       {       -2, 5,                          0, -2,  },
-       {       -2, -5,                         0, -2,  },
-       {       17, 5,                          3, 2,   },
-       {       -17, -5,                        3, -2,  },
-       {       17, -5,                         -3, 2,  },
-       {       -17, 5,                         -3, -2, },
-       {       2147483647, 1,                  2147483647, 0,         },
-       {       -2147483647, 1,                 -2147483647, 0,        },
-       {       2147483648, 1,                  2147483648, 0,         },
-       {       -2147483647-1, 1,               -2147483647-1, 0,      },
-       {       2147483647, 2,                  1073741823, 1,         },
-       {       -2147483647, 2,                 -1073741823, -1,       },
-       {       2147483648, 2,                  1073741824, 0,         },
-       {       -2147483647-1, 2,               -1073741824, 0,        },
-#ifdef INT_LEAST64_MAX                 /* else might support only 32 bits */
-       {       4294967295, 1,                  4294967295, 0,         },
-       {       -4294967296+1, 1,               -4294967296+1, 0,      },
-       {       4294967296, 1,                  4294967296, 0,         },
-       {       -4294967296, 1,                 -4294967296, 0,        },
-       {       4294967295, -1,                 -4294967296+1, 0,      },
-       {       -4294967296+1, -1,              4294967295, 0,         },
-       {       4294967296, -1,                 -4294967296, 0,        },
-       {       -4294967296, -1,                4294967296, 0,         },
-       {       4294967295, 2,                  2147483647, 1,         },
-       {       -4294967296+1, 2,               -2147483647, -1,       },
-       {       4294967296, 2,                  2147483648, 0,         },
-       {       -4294967296, 2,                 -2147483647-1, 0,      },
-       {       4294967295, 2147483647,         2, 1,              },
-       {       -4294967296+1, 2147483647,      -2, -1,            },
-       {       4294967296, 2147483647,         2, 2,              },
-       {       -4294967296, 2147483647,        -2, -2,            },
-       {       4294967295, -2147483647,        -2, 1,             },
-       {       -4294967296+1, -2147483647,     2, -1,             },
-       {       4294967296, -2147483647,        -2, 2,             },
-       {       -4294967296, -2147483647,       2, -2,             },
-       {       4294967295, 2147483648,         1, 2147483647,     },
-       {       -4294967296+1, 2147483648,      -1, -2147483647,   },
-       {       4294967296, 2147483648,         2, 0,              },
-       {       -4294967296, 2147483648,        -2, 0,             },
-       {       4294967295, -2147483647-1,      -1, 2147483647,    },
-       {       -4294967296+1, -2147483647-1,   1, -2147483647,},
-       {       4294967296, -2147483647-1,      -2, 0,             },
-       {       -4294967296, -2147483647-1,     2, 0,              },
-       {       9223372036854775807, 1,         9223372036854775807, 0,         },
-       {       -9223372036854775807, 1,        -9223372036854775807, 0,        },
-       {       9223372036854775807, 2,         4611686018427387903, 1,         },
-       {       -9223372036854775807, 2,        -4611686018427387903, -1,       },
-#endif
-#endif
-               /* There should be a much larger battery of such tests. */
-       {       0, 0,           0, 0 }, /* 0 denom terminates the list */
-               },      *ddp;
-
-#if 0
-       for ( ddp = div_data; ddp->denom != 0; ++ddp )
-               if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot
-                    != ddp->exp_quot || result.rem != ddp->exp_rem
-                  )    {
-//                     printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX
-//                            ") failed; should be: (%"PRIdMAX",%"PRIdMAX
-//                            "), was: (%"PRIdMAX",%"PRIdMAX") ***\n",
-//                            ddp->numer, ddp->denom, ddp->exp_quot,
-//                            ddp->exp_rem, result.quot, result.rem
-//                           );
-                       printf("err:imaxdiv(%"PRIdMAX",%"PRIdMAX
-                              ") = (%"PRIdMAX",%"PRIdMAX
-                              "), is: (%"PRIdMAX",%"PRIdMAX")\n",
-                              ddp->numer, ddp->denom, ddp->exp_quot,
-                              ddp->exp_rem, result.quot, result.rem
-                             );
-                       status = EXIT_FAILURE;
-                       }
-#endif
-       }
-       
-       {
-       char            *endptr;
-       wchar_t         *wendptr;
-       static char     saved[64];      /* holds copy of input string */
-       static wchar_t  wnptr[64];      /* holds wide copy of test string */
-       static int      warned;         /* "warned for null endptr" flag */
-       register int    i;
-       static struct
-               {
-               char *          nptr;
-               int             base;
-               intmax_t        exp_val;
-               int             exp_len;
-               }       str_data[] =
-               {
-       {       "", 0,                          0, 0,      },
-       {       "", 2,                          0, 0,      },
-       {       "", 8,                          0, 0,      },
-       {       "", 9,                          0, 0,      },
-       {       "", 10,                         0, 0,      },
-       {       "", 16,                         0, 0,      },
-       {       "", 36,                         0, 0,      },
-       {       "0", 0,                         0, 1,      },
-       {       "0", 2,                         0, 1,      },
-       {       "0", 8,                         0, 1,      },
-       {       "0", 9,                         0, 1,      },
-       {       "0", 10,                        0, 1,      },
-       {       "0", 16,                        0, 1,      },
-       {       "0", 36,                        0, 1,      },
-       {       "+0", 0,                        0, 2,      },
-       {       "+0", 2,                        0, 2,      },
-       {       "+0", 8,                        0, 2,      },
-       {       "+0", 9,                        0, 2,      },
-       {       "+0", 10,                       0, 2,      },
-       {       "+0", 16,                       0, 2,      },
-       {       "+0", 36,                       0, 2,      },
-       {       "-0", 0,                        0, 2,      },
-       {       "-0", 2,                        0, 2,      },
-       {       "-0", 8,                        0, 2,      },
-       {       "-0", 9,                        0, 2,      },
-       {       "-0", 10,                       0, 2,      },
-       {       "-0", 16,                       0, 2,      },
-       {       "-0", 36,                       0, 2,      },
-       {       "Inf", 0,                       0, 0,      },
-       {       "Inf", 2,                       0, 0,      },
-       {       "Inf", 8,                       0, 0,      },
-       {       "Inf", 9,                       0, 0,      },
-       {       "Inf", 10,                      0, 0,      },
-       {       "Inf", 16,                      0, 0,      },
-       {       "Inf", 36,                      24171, 3,  },
-       {       "+Inf", 0,                      0, 0,      },
-       {       "+Inf", 2,                      0, 0,      },
-       {       "+Inf", 8,                      0, 0,      },
-       {       "+Inf", 9,                      0, 0,      },
-       {       "+Inf", 10,                     0, 0,      },
-       {       "+Inf", 16,                     0, 0,      },
-       {       "+Inf", 36,                     24171, 4,  },
-       {       "-Inf", 0,                      0, 0,      },
-       {       "-Inf", 2,                      0, 0,      },
-       {       "-Inf", 8,                      0, 0,      },
-       {       "-Inf", 9,                      0, 0,      },
-       {       "-Inf", 10,                     0, 0,      },
-       {       "-Inf", 16,                     0, 0,      },
-       {       "-Inf", 36,                     -24171, 4, },
-       {       "inf", 0,                       0, 0,      },
-       {       "inf", 2,                       0, 0,      },
-       {       "inf", 8,                       0, 0,      },
-       {       "inf", 9,                       0, 0,      },
-       {       "inf", 10,                      0, 0,      },
-       {       "inf", 16,                      0, 0,      },
-       {       "inf", 36,                      24171, 3,  },
-       {       "+inf", 0,                      0, 0,      },
-       {       "+inf", 2,                      0, 0,      },
-       {       "+inf", 8,                      0, 0,      },
-       {       "+inf", 9,                      0, 0,      },
-       {       "+inf", 10,                     0, 0,      },
-       {       "+inf", 16,                     0, 0,      },
-       {       "+inf", 36,                     24171, 4,  },
-       {       "-inf", 0,                      0, 0,      },
-       {       "-inf", 2,                      0, 0,      },
-       {       "-inf", 8,                      0, 0,      },
-       {       "-inf", 9,                      0, 0,      },
-       {       "-inf", 10,                     0, 0,      },
-       {       "-inf", 16,                     0, 0,      },
-       {       "-inf", 36,                     -24171, 4, },
-       {       "119b8Z", 0,                    119, 3,         },
-       {       "119bZ", 0,                     119, 3,             },
-       {       "-0119bZ", 0,                   -9, 4,          },
-       {       " \t\n 0X119bZ", 0,             4507, 10,       },
-       {       " \t\n +0X119bZ", 0,            4507, 11,   },
-       {       " \t\n -0x119bZ", 0,            -4507, 11,  },
-       {       " \t\n 119bZ", 0,               119, 7,         },
-       {       "+119bZ", 0,                    119, 4,         },
-       {       "+0X119bz", 0,                  4507, 7,        },
-       {       "119b8Z", 2,                    3, 2,           },
-       {       "119bZ", 2,                     3, 2,               },
-       {       "-0119bZ", 2,                   -3, 4,          },
-       {       " \t\n 0X119bZ", 2,             0, 5,           },
-       {       " \t\n +0X119bZ", 2,            0, 6,       },
-       {       " \t\n -0x119bZ", 2,            0, 6,       },
-       {       " \t\n 119bZ", 2,               3, 6,           },
-       {       "+119bZ", 2,                    3, 3,           },
-       {       "+0X119bz", 2,                  0, 2,           },
-       {       "119b8Z", 8,                    9, 2,           },
-       {       "119bZ", 8,                     9, 2,               },
-       {       "-0119bZ", 8,                   -9, 4,          },
-       {       " \t\n 0X119bZ", 8,             0, 5,           },
-       {       " \t\n +0X119bZ", 8,            0, 6,       },
-       {       " \t\n -0x119bZ", 8,            0, 6,       },
-       {       " \t\n 119bZ", 8,               9, 6,           },
-       {       "+119bZ", 8,                    9, 3,           },
-       {       "+0X119bz", 8,                  0, 2,           },
-       {       "119b8Z", 9,                    10, 2,          },
-       {       "119bZ", 9,                     10, 2,              },
-       {       "-0119bZ", 9,                   -10, 4,         },
-       {       " \t\n 0X119bZ", 9,             0, 5,           },
-       {       " \t\n +0X119bZ", 9,            0, 6,       },
-       {       " \t\n -0x119bZ", 9,            0, 6,       },
-       {       " \t\n 119bZ", 9,               10, 6,          },
-       {       "+119bZ", 9,                    10, 3,          },
-       {       "+0X119bz", 9,                  0, 2,           },
-       {       "119b8Z", 10,                   119, 3,         },
-       {       "119bZ", 10,                    119, 3,         },
-       {       "-0119bZ", 10,                  -119, 5,        },
-       {       " \t\n 0X119bZ", 10,            0, 5,       },
-       {       " \t\n +0X119bZ", 10,           0, 6,       },
-       {       " \t\n -0x119bZ", 10,           0, 6,       },
-       {       " \t\n 119bZ", 10,              119, 7,         },
-       {       "+119bZ", 10,                   119, 4,         },
-       {       "+0X119bz", 10,                 0, 2,           },
-       {       "119b8Z", 16,                   72120, 5,       },
-       {       "119bZ", 16,                    4507, 4,        },
-       {       "-0119bZ", 16,                  -4507, 6,       },
-       {       " \t\n 0X119bZ", 16,            4507, 10,   },
-       {       " \t\n +0X119bZ", 16,           4507, 11,   },
-       {       " \t\n -0x119bZ", 16,           -4507, 11,  },
-       {       " \t\n 119bZ", 16,              4507,8,         },
-       {       "+119bZ", 16,                   4507, 5,        },
-       {       "+0X119bz", 16,                 4507, 7,        },
-       {       "119b8Z", 36,                   62580275, 6,    },
-       {       "119bZ", 36,                    1738367, 5,     },
-       {       "-0119bZ", 36,                  -1738367, 7,                 },
-       {       " \t\n 0X119bZ", 36,            1997122175, 11,          },
-       {       " \t\n +0X119bZ", 36,           1997122175, 12,          },
-       {       " \t\n -0x119bZ", 36,           -1997122175, 12,         },
-       {       " \t\n 119bZ", 36,              1738367, 9,                  },
-       {       "+119bZ", 36,                   1738367, 6,                  },
-       {       "+0X119bz", 36,                 1997122175, 8,               },
-               /* There should be a much larger battery of such tests. */
-       {       "127", 0,                       127, 3,                          },
-       {       "-127", 0,                      -127, 4,                         },
-       {       "128", 0,                       128, 3,                          },
-       {       "-128", 0,                      -127-1, 4,                       },
-       {       "255", 0,                       255, 3,                          },
-       {       "-255", 0,                      -255, 4,                         },
-       {       "256", 0,                       256, 3,                          },
-       {       "-256", 0,                      -255-1, 4,                       },
-       {       "32767", 0,                     32767, 5,                        },
-       {       "-32767", 0,                    -32767, 6,                   },
-       {       "32768", 0,                     32768, 5,                        },
-       {       "-32768", 0,                    -32767-1, 6,                 },
-       {       "65535", 0,                     65535, 5,                        },
-       {       "-65535", 0,                    -65536+1, 6,                 },
-       {       "65536", 0,                     65536, 5,                        },
-       {       "-65536", 0,                    -65536, 6,                   },
-       {       "2147483647", 0,                2147483647, 10,              },
-       {       "-2147483647", 0,               -2147483647, 11,             },
-       {       "2147483648", 0,                2147483648, 10,              },
-       {       "-2147483648", 0,               -2147483647-1, 11,           },
-       {       "4294967295", 0,                4294967295, 10,              },
-       {       "-4294967295", 0,               -4294967296+1, 11,           },
-       {       "4294967296", 0,                4294967296, 10,              },
-       {       "-4294967296", 0,               -4294967296, 11,                        },
-       {       "9223372036854775807", 0,       9223372036854775807, 19,            },
-       {       "-9223372036854775807", 0,      -9223372036854775807, 20,           },
-       {       "1234567890123456789", 0,       1234567890123456789, 19,            },
-       {       "-1234567890123456789", 0,      -1234567890123456789, 20,           },
-       {       "1", 0,                         1, 1,                                       },
-       {       "-1", 0,                        -1, 2,                                      },
-       {       "2", 0,                         2, 1,                                       },
-       {       "-2", 0,                        -2, 2,                                      },
-       {       "10", 0,                        10, 2,                                      },
-       {       "-10", 0,                       -10, 3,                                     },
-       {       "16", 0,                        16, 2,                                      },
-       {       "-16", 0,                       -16, 3,                                     },
-               /* Other test cases can be added here. */
-       {       NULL, 0,        0, 0 }, /* terminates the list */
-               },      *sdp;
-
-       for ( sdp = str_data; sdp->nptr != NULL ; ++sdp )
-               {
-               /*
-                       7.8.2.3 The strtoimax and strtoumax functions
-               */
-
-               strcpy(saved, sdp->nptr);
-
-               errno = 0;              /* shouldn't be changed */
-
-               if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base))
-                 != sdp->exp_val
-                  )    {
-                       int     save = errno;
-
-                       printf("*** strtoimax(%s,,%d) failed; should be: %"
-                              PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
-                              sdp->base, sdp->exp_val, intmax
-                             );
-                       status = EXIT_FAILURE;
-                       errno = save;
-                       }
-               else if ( endptr != sdp->nptr + sdp->exp_len )
-                       {
-                       int     save = errno;
-
-                       printf("*** strtoimax(%s,,%d) returned wrong endptr"
-                              " ***\n", sdp->nptr, sdp->base
-                             );
-                       status = EXIT_FAILURE;
-                       errno = save;
-                       }
-
-               if ( errno != 0 )
-                       {
-                       printf("*** strtoimax modified errno ***\n");
-                       status = EXIT_FAILURE;
-                       }
-
-               if ( strcmp(sdp->nptr, saved) != 0 )
-                       {
-                       printf("*** strtoimax modified its input ***\n");
-                       status = EXIT_FAILURE;
-                       strcpy(saved, sdp->nptr);
-                       }
-
-               if ( sdp->exp_val >= 0 )        /* else some sign extension */
-                       {
-                       errno = 0;      /* shouldn't be changed */
-
-                       if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base
-                                                )
-                            ) != sdp->exp_val
-                          )    {
-                               int     save = errno;
-
-                               printf("*** strtoumax(%s,,%d) failed; "
-                                      "should be: %"PRIuMAX", was: %"PRIuMAX
-                                      " ***\n", sdp->nptr, sdp->base,
-                                      sdp->exp_val, uintmax
-                                     );
-                               status = EXIT_FAILURE;
-                               errno = save;
-                               }
-                       else if ( endptr != sdp->nptr + sdp->exp_len )
-                               {
-                               int     save = errno;
-
-                               printf("*** strtoumax(%s,,%d) returned wrong "
-                                      "endptr ***\n", sdp->nptr, sdp->base
-                                     );
-                               status = EXIT_FAILURE;
-                               errno = save;
-                               }
-
-                       if ( errno != 0 )
-                               {
-                               printf("*** strtoumax modified errno ***\n");
-                               status = EXIT_FAILURE;
-                               }
-
-                       if ( strcmp(sdp->nptr, saved) != 0 )
-                               {
-                               printf("*** strtoumax"
-                                      " modified its input ***\n"
-                                     );
-                               status = EXIT_FAILURE;
-                               strcpy(saved, sdp->nptr);
-                               }
-                       }
-
-               /* tests for null endptr */
-
-#define        WARN()  if (!warned) warned = 1, printf("*** Using null endptr: ***\n")
-
-               warned = 0;
-               errno = 0;              /* shouldn't be changed */
-
-               if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base))
-                 != sdp->exp_val
-                  )    {
-                       int     save = errno;
-
-                       WARN();
-                       printf("*** strtoimax(%s,NULL,%d) failed; "
-                              "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n",
-                              sdp->nptr, sdp->base, sdp->exp_val, intmax
-                             );
-                       status = EXIT_FAILURE;
-                       errno = save;
-                       }
-
-               if ( errno != 0 )
-                       {
-                       WARN();
-                       printf("*** strtoimax modified errno ***\n");
-                       status = EXIT_FAILURE;
-                       }
-
-               if ( strcmp(sdp->nptr, saved) != 0 )
-                       {
-                       WARN();
-                       printf("*** strtoimax modified its input ***\n");
-                       status = EXIT_FAILURE;
-                       strcpy(saved, sdp->nptr);
-                       }
-
-               if ( sdp->exp_val >= 0 )        /* else some sign extension */
-                       {
-                       errno = 0;      /* shouldn't be changed */
-
-                       if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL,
-                                                 sdp->base
-                                                )
-                            ) != sdp->exp_val
-                          )    {
-                               int     save = errno;
-
-                               WARN();
-                               printf("*** strtoumax(%s,NULL,%d) failed; "
-                                      "should be: %"PRIuMAX", was: %"PRIuMAX
-                                      " ***\n", sdp->nptr, sdp->base,
-                                      sdp->exp_val, uintmax
-                                     );
-                               status = EXIT_FAILURE;
-                               errno = save;
-                               }
-
-                        if ( errno != 0 )
-                               {
-                               WARN();
-                               printf("*** strtoumax modified errno ***\n");
-                               status = EXIT_FAILURE;
-                               }
-
-                        if ( strcmp(sdp->nptr, saved) != 0 )
-                               {
-                               WARN();
-                               printf("*** strtoumax"
-                                      " modified its input ***\n"
-                                     );
-                               status = EXIT_FAILURE;
-                               strcpy(saved, sdp->nptr);
-                               }
-                       }
-
-               /*
-                       7.8.2.4 The wcstoimax and wcstoumax functions
-               */
-
-               for ( i = 0; i < 64; ++i )
-                       if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
-                               break;
-
-               errno = 0;              /* shouldn't be changed */
-
-               if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base))
-                 != sdp->exp_val
-                  )    {
-                       int     save = errno;
-
-                       printf("*** wcstoimax(%s,,%d) failed; should be: %"
-                              PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
-                              sdp->base, sdp->exp_val, intmax
-                             );
-                       status = EXIT_FAILURE;
-                       errno = save;
-                       }
-               else if ( wendptr != wnptr + sdp->exp_len )
-                       {
-                       int     save = errno;
-
-                       printf("*** wcstoimax(%s,,%d) returned wrong endptr"
-                              " ***\n", sdp->nptr, sdp->base
-                             );
-                       status = EXIT_FAILURE;
-                       errno = save;
-                       }
-
-               if ( errno != 0 )
-                       {
-                       printf("*** wcstoimax modified errno ***\n");
-                       status = EXIT_FAILURE;
-                       }
-
-               for ( i = 0; i < 64; ++i )
-                       if ( wnptr[i] != sdp->nptr[i] )
-                               {
-                               printf("*** wcstoimax modified its input ***\n"
-                                     );
-                               status = EXIT_FAILURE;
-
-                               for ( ; i < 64; ++i )
-                                       if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
-                                               break;
-
-                               break;
-                               }
-                       else if ( wnptr[i] == '\0' )
-                               break;
-
-               if ( sdp->exp_val >= 0 )        /* else some sign extension */
-                       {
-                       errno = 0;      /* shouldn't be changed */
-
-                       if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base)
-                            ) != sdp->exp_val
-                          )    {
-                               int     save = errno;
-
-                               printf("*** wcstoumax(%s,,%d) failed; "
-                                      "should be: %"PRIuMAX", was: %"PRIuMAX
-                                      " ***\n", sdp->nptr, sdp->base,
-                                      sdp->exp_val, uintmax
-                                     );
-                               status = EXIT_FAILURE;
-                               errno = save;
-                               }
-                       else if ( wendptr != wnptr + sdp->exp_len )
-                               {
-                               int     save = errno;
-
-                               printf("*** wcstoumax(%s,,%d) returned wrong "
-                                      "endptr ***\n", sdp->nptr, sdp->base
-                                     );
-                               status = EXIT_FAILURE;
-                               errno = save;
-                               }
-
-                       if ( errno != 0 )
-                               {
-                               printf("*** wcstoumax modified errno ***\n");
-                               status = EXIT_FAILURE;
-                               }
-
-                       for ( i = 0; i < 64; ++i )
-                               if ( wnptr[i] != sdp->nptr[i] )
-                                       {
-                                       printf("*** wcstoumax"
-                                              " modified its input ***\n"
-                                             );
-                                       status = EXIT_FAILURE;
-
-                                       for ( ; i < 64; ++i )
-                                               if ( (wnptr[i] = sdp->nptr[i])
-                                                 == '\0'
-                                                  )
-                                                       break;
-
-                                       break;
-                                       }
-                               else if ( wnptr[i] == '\0' )
-                                       break;
-                       }
-
-               /* tests for null endptr */
-
-               warned = 0;
-               errno = 0;              /* shouldn't be changed */
-
-               if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base))
-                 != sdp->exp_val
-                  )    {
-                       int     save = errno;
-
-                       WARN();
-                       printf("*** wcstoimax(%s,NULL,%d) failed; should be: %"
-                              PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
-                              sdp->base, sdp->exp_val, intmax
-                             );
-                       status = EXIT_FAILURE;
-                       errno = save;
-                       }
-
-               if ( errno != 0 )
-                       {
-                       WARN();
-                       printf("*** wcstoimax modified errno ***\n");
-                       status = EXIT_FAILURE;
-                       }
-
-               for ( i = 0; i < 64; ++i )
-                       if ( wnptr[i] != sdp->nptr[i] )
-                               {
-                               WARN();
-                               printf("*** wcstoimax modified its input ***\n"
-                                     );
-                               status = EXIT_FAILURE;
-
-                               for ( ; i < 64; ++i )
-                                       if ( (wnptr[i] = sdp->nptr[i])
-                                         == '\0'
-                                          )
-                                               break;
-
-                               break;
-                               }
-                       else if ( wnptr[i] == '\0' )
-                               break;
-
-               if ( sdp->exp_val >= 0 )        /* else some sign extension */
-                       {
-                       errno = 0;      /* shouldn't be changed */
-
-                       if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL,
-                                                 sdp->base
-                                                )
-                            ) != sdp->exp_val
-                          )    {
-                               int     save = errno;
-
-                               WARN();
-                               printf("*** wcstoumax(%s,NULL,%d) failed; "
-                                      "should be: %"PRIuMAX", was: %"PRIuMAX
-                                      " ***\n", sdp->nptr, sdp->base,
-                                      sdp->exp_val, uintmax
-                                     );
-                               status = EXIT_FAILURE;
-                               errno = save;
-                               }
-
-                        if ( errno != 0 )
-                               {
-                               WARN();
-                               printf("*** wcstoumax modified errno ***\n");
-                               status = EXIT_FAILURE;
-                               }
-
-                       for ( i = 0; i < 64; ++i )
-                               if ( wnptr[i] != sdp->nptr[i] )
-                                       {
-                                       WARN();
-                                       printf("*** wcstoumax"
-                                              " modified its input ***\n"
-                                             );
-                                       status = EXIT_FAILURE;
-
-                                       for ( ; i < 64; ++i )
-                                               if ( (wnptr[i] = sdp->nptr[i])
-                                                 == '\0'
-                                                  )
-                                                       break;
-
-                                       break;
-                                       }
-                               else if ( wnptr[i] == '\0' )
-                                       break;
-                       }
-               }
-
-       /*
-               7.8.2.3 The strtoimax and strtoumax functions (continued)
-       */
-
-       if ( (intmax = strtoimax("1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890",
-                                &endptr, 0
-                               )
-            ) != INTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** strtoimax failed overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (intmax = strtoimax("+1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890",
-                                &endptr, 0
-                               )
-            ) != INTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** strtoimax failed +overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (intmax = strtoimax("-1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890",
-                                &endptr, 0
-                               )
-            ) != INTMAX_MIN || errno != ERANGE
-          )    {
-               printf("*** strtoimax failed -overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (uintmax = strtoumax("1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890",
-                                &endptr, 0
-                               )
-            ) != UINTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** strtoumax failed overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890",
-                                &endptr, 0
-                               )
-            ) != UINTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** strtoumax failed +overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890"
-                                "1234567890123456789012345678901234567890",
-                                &endptr, 0
-                               )
-            ) != UINTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** strtoumax failed -overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       /*
-               7.8.2.4 The wcstoimax and wcstoumax functions (continued)
-       */
-
-#ifdef NO_INTERNAL_WCHAR
-               printf("NO_INTERNAL_WCHAR\n");
-#else
-
-       if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890",
-                                &wendptr, 0
-                               )
-            ) != INTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** wcstoimax failed overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890",
-                                &wendptr, 0
-                               )
-            ) != INTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** wcstoimax failed +overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890",
-                                &wendptr, 0
-                               )
-            ) != INTMAX_MIN || errno != ERANGE
-          )    {
-               printf("*** wcstoimax failed -overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890",
-                                &wendptr, 0
-                               )
-            ) != UINTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** wcstoumax failed overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890",
-                                &wendptr, 0
-                               )
-            ) != UINTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** wcstoumax failed +overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-
-       if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890"
-                                L"1234567890123456789012345678901234567890",
-                                &wendptr, 0
-                               )
-            ) != UINTMAX_MAX || errno != ERANGE
-          )    {
-               printf("*** wcstoumax failed -overflow test ***\n");
-               status = EXIT_FAILURE;
-               }
-#endif // NO_INTERNAL_WCHAR
-       }
-#endif /* defined(INTMAX_MAX) */
-
-       if ( status != 0 )
-               printf("sitest failed.\n");
-
-       return status;
-}
-
-#endif
\ No newline at end of file