| 1 |
/* input2int.c: read two or three integers from text files. These |
| 2 |
routines are only used in patgen. Public domain. */ |
| 3 |
|
| 4 |
#include <w2c/config.h> |
| 5 |
#include "lib.h" |
| 6 |
|
| 7 |
#ifdef INTEGER_IS_INT |
| 8 |
#define SCAN2INT "%d %d" |
| 9 |
#define SCAN3INT "%d %d %d" |
| 10 |
#else |
| 11 |
#define SCAN2INT "%ld %ld" |
| 12 |
#define SCAN3INT "%ld %ld %ld" |
| 13 |
#endif |
| 14 |
|
| 15 |
/* Read two integers from stdin. */ |
| 16 |
|
| 17 |
void |
| 18 |
zinput2ints (integer *a, integer *b) |
| 19 |
{ |
| 20 |
int ch; |
| 21 |
|
| 22 |
while (scanf (SCAN2INT, a, b) != 2) |
| 23 |
{ |
| 24 |
while ((ch = getchar ()) != EOF && ch != '\n'); |
| 25 |
if (ch == EOF) return; |
| 26 |
fprintf (stderr, "Please enter two integers.\n"); |
| 27 |
} |
| 28 |
|
| 29 |
while ((ch = getchar ()) != EOF && ch != '\n'); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
/* Read three integers from stdin. */ |
| 34 |
|
| 35 |
void |
| 36 |
zinput3ints (integer *a, integer *b, integer *c) |
| 37 |
{ |
| 38 |
int ch; |
| 39 |
|
| 40 |
while (scanf (SCAN3INT, a, b, c) != 3) |
| 41 |
{ |
| 42 |
while ((ch = getchar ()) != EOF && ch != '\n'); |
| 43 |
if (ch == EOF) return; |
| 44 |
fprintf (stderr, "Please enter three integers.\n"); |
| 45 |
} |
| 46 |
|
| 47 |
while ((ch = getchar ()) != EOF && ch != '\n'); |
| 48 |
} |