From 11d559eadebd0c3e8d31b3b68b99c6c87fd5930b Mon Sep 17 00:00:00 2001 From: tTh Date: Tue, 4 Oct 2022 05:47:23 +0200 Subject: [PATCH] clean output messages --- code/misctools/nonascii.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 code/misctools/nonascii.c diff --git a/code/misctools/nonascii.c b/code/misctools/nonascii.c new file mode 100644 index 0000000..c8dcbb3 --- /dev/null +++ b/code/misctools/nonascii.c @@ -0,0 +1,40 @@ +/* + * nonascii.c + * + * new Mon 03 Oct 2022 05:42:42 PM CEST + */ + +#include +#include + +int main(int argc, char *argv[]) +{ +int input, linenum, count; +int flagline; + +linenum = 1; +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) { + fprintf(stderr, "%d non-ascii chars\n", count); + exit(1); + } + +return 0; +} \ No newline at end of file