1.1 --- a/bookloupe/bookloupe.c Sun May 26 22:37:16 2013 +0100
1.2 +++ b/bookloupe/bookloupe.c Sun May 26 22:43:45 2013 +0100
1.3 @@ -992,6 +992,34 @@
1.4 }
1.5
1.6 /*
1.7 + * check_for_control_characters:
1.8 + *
1.9 + * Check for invalid or questionable characters in the line
1.10 + * Anything above 127 is invalid for plain ASCII, and
1.11 + * non-printable control characters should also be flagged.
1.12 + * Tabs should generally not be there.
1.13 + */
1.14 +void check_for_control_characters(const char *aline)
1.15 +{
1.16 + unsigned char c;
1.17 + const char *s;
1.18 + for (s=aline;*s;s++)
1.19 + {
1.20 + c=*(unsigned char *)s;
1.21 + if (c<CHAR_SPACE && c!=CHAR_LF && c!=CHAR_CR && c!=CHAR_TAB)
1.22 + {
1.23 + if (pswit[ECHO_SWITCH])
1.24 + printf("\n%s\n",aline);
1.25 + if (!pswit[OVERVIEW_SWITCH])
1.26 + printf(" Line %ld column %d - Control character %d\n",
1.27 + linecnt,(int)(s-aline)+1,c);
1.28 + else
1.29 + cnt_bin++;
1.30 + }
1.31 + }
1.32 +}
1.33 +
1.34 +/*
1.35 * check_for_odd_characters:
1.36 *
1.37 * Check for binary and other odd characters.
1.38 @@ -2645,26 +2673,7 @@
1.39 ;
1.40 if (s>=aline && *s=='-')
1.41 enddash=1;
1.42 - /*
1.43 - * Check for invalid or questionable characters in the line
1.44 - * Anything above 127 is invalid for plain ASCII, and
1.45 - * non-printable control characters should also be flagged.
1.46 - * Tabs should generally not be there.
1.47 - */
1.48 - for (s=aline;*s;s++)
1.49 - {
1.50 - i=(unsigned char)*s;
1.51 - if (i<CHAR_SPACE && i!=CHAR_LF && i!=CHAR_CR && i!=CHAR_TAB)
1.52 - {
1.53 - if (pswit[ECHO_SWITCH])
1.54 - printf("\n%s\n",aline);
1.55 - if (!pswit[OVERVIEW_SWITCH])
1.56 - printf(" Line %ld column %d - Control character %d\n",
1.57 - linecnt,(int)(s-aline)+1,i);
1.58 - else
1.59 - cnt_bin++;
1.60 - }
1.61 - }
1.62 + check_for_control_characters(aline);
1.63 if (warnings->bin)
1.64 check_for_odd_characters(aline,warnings,isemptyline);
1.65 if (warnings->longline)