2022-10-04 14:47:23 +11:00
|
|
|
/*
|
|
|
|
* nonascii.c
|
|
|
|
*
|
|
|
|
* new Mon 03 Oct 2022 05:42:42 PM CEST
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int input, linenum, count;
|
|
|
|
int flagline;
|
|
|
|
|
2022-10-05 04:31:50 +11:00
|
|
|
linenum = 1; /* humans start line count at 1 */
|
2022-10-04 14:47:23 +11:00
|
|
|
count = 0;
|
|
|
|
|
|
|
|
while (EOF != (input=getc(stdin))) {
|
|
|
|
if ('\n' == input) {
|
|
|
|
linenum++;
|
|
|
|
flagline = 0;
|
|
|
|
}
|
|
|
|
if ((input < 0) || (input>127)) {
|
|
|
|
if (!flagline) {
|
|
|
|
fprintf(stderr, "non ascii 0x%x line %d\n",
|
|
|
|
input, linenum);
|
|
|
|
flagline = 1;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count) {
|
2022-10-05 04:31:50 +11:00
|
|
|
fprintf(stderr, "at least %d non-ascii characters found\n", count);
|
2022-10-04 14:47:23 +11:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|