diff options
Diffstat (limited to 'Build/source/texk/web2c/lib/input2int.c')
-rw-r--r-- | Build/source/texk/web2c/lib/input2int.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/lib/input2int.c b/Build/source/texk/web2c/lib/input2int.c new file mode 100644 index 00000000000..0ed5cf94686 --- /dev/null +++ b/Build/source/texk/web2c/lib/input2int.c @@ -0,0 +1,47 @@ +/* input2int.c: read two or three integers from text files. These + routines are only used in patgen. Public domain. */ + +#include "config.h" + +#ifdef INTEGER_IS_INT +#define SCAN2INT "%d %d" +#define SCAN3INT "%d %d %d" +#else +#define SCAN2INT "%ld %ld" +#define SCAN3INT "%ld %ld %ld" +#endif + +/* Read two integers from stdin. */ + +void +zinput2ints P2C(integer *, a, integer *, b) +{ + int ch; + + while (scanf (SCAN2INT, a, b) != 2) + { + while ((ch = getchar ()) != EOF && ch != '\n'); + if (ch == EOF) return; + (void) fprintf (stderr, "Please enter two integers.\n"); + } + + while ((ch = getchar ()) != EOF && ch != '\n'); +} + + +/* Read three integers from stdin. */ + +void +zinput3ints P3C(integer *, a, integer *, b, integer *, c) +{ + int ch; + + while (scanf (SCAN3INT, a, b, c) != 3) + { + while ((ch = getchar ()) != EOF && ch != '\n'); + if (ch == EOF) return; + (void) fprintf (stderr, "Please enter three integers.\n"); + } + + while ((ch = getchar ()) != EOF && ch != '\n'); +} |