a new tool from tth

This commit is contained in:
tTh 2022-10-04 19:31:50 +02:00
parent 5a610e0926
commit 9e8a6b3411
3 changed files with 13 additions and 5 deletions

4
code/misctools/Makefile Normal file
View File

@ -0,0 +1,4 @@
nonascii: nonascii.c Makefile
gcc -Wall $< -o $@

7
code/misctools/README.md Normal file
View File

@ -0,0 +1,7 @@
# Outils divers
OK, let's go for a few nice tools.
## non ascii ?

View File

@ -12,16 +12,14 @@ int main(int argc, char *argv[])
int input, linenum, count; int input, linenum, count;
int flagline; int flagline;
linenum = 1; linenum = 1; /* humans start line count at 1 */
count = 0; count = 0;
while (EOF != (input=getc(stdin))) { while (EOF != (input=getc(stdin))) {
if ('\n' == input) { if ('\n' == input) {
linenum++; linenum++;
flagline = 0; flagline = 0;
} }
if ((input < 0) || (input>127)) { if ((input < 0) || (input>127)) {
if (!flagline) { if (!flagline) {
fprintf(stderr, "non ascii 0x%x line %d\n", fprintf(stderr, "non ascii 0x%x line %d\n",
@ -32,9 +30,8 @@ while (EOF != (input=getc(stdin))) {
} }
} }
if (count) { if (count) {
fprintf(stderr, "%d non-ascii chars\n", count); fprintf(stderr, "at least %d non-ascii characters found\n", count);
exit(1); exit(1);
} }
return 0; return 0;
} }