# HG changeset patch # User ali # Date 1369595568 -3600 # Node ID 5d1e411a5400e86d3bc9d54a851f3f4e7ab2d4ed # Parent 11c6d93eebd9193d680928a8943b339e15407b53 Break check_end_of_line() out diff -r 11c6d93eebd9 -r 5d1e411a5400 bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sun May 26 19:55:11 2013 +0100 +++ b/bookloupe/bookloupe.c Sun May 26 20:12:48 2013 +0100 @@ -2161,6 +2161,62 @@ } /* + * check_end_of_line: + * + * Now check special cases - start and end of line - + * for single and double quotes. Start is sometimes [sic] + * but better to query it anyway. + * While we're here, check for dash at end of line. + */ +void check_end_of_line(const char *aline,struct warnings *warnings) +{ + int i,llen; + llen=strlen(aline); + if (llen>1) + { + if (aline[llen-1]==CHAR_DQUOTE || aline[llen-1]==CHAR_SQUOTE || + aline[llen-1]==CHAR_OPEN_SQUOTE) + if (aline[llen-2]==CHAR_SPACE) + { + if (pswit[ECHO_SWITCH]) + printf("\n%s\n",aline); + if (!pswit[OVERVIEW_SWITCH]) + printf(" Line %ld column %d - Spaced quote?\n", + linecnt,llen); + else + cnt_punct++; + } + if ((aline[0]==CHAR_SQUOTE || aline[0]==CHAR_OPEN_SQUOTE) && + aline[1]==CHAR_SPACE) + { + if (pswit[ECHO_SWITCH]) + printf("\n%s\n",aline); + if (!pswit[OVERVIEW_SWITCH]) + printf(" Line %ld column 1 - Spaced quote?\n",linecnt); + else + cnt_punct++; + } + /* + * Dash at end of line may well be legit - paranoid mode only + * and don't report em-dash at line-end. + */ + if (pswit[PARANOID_SWITCH] && warnings->hyphen) + { + for (i=llen-1;i>0 && (unsigned char)aline[i]<=CHAR_SPACE;i--) + ; + if (aline[i]=='-' && aline[i-1]!='-') + { + if (pswit[ECHO_SWITCH]) + printf("\n%s\n",aline); + if (!pswit[OVERVIEW_SWITCH]) + printf(" Line %ld column %d - Hyphen at end of line?\n", + linecnt,i); + } + } + } +} + +/* * procfile: * * Process one file. @@ -2404,55 +2460,7 @@ check_for_double_punctuation(aline,warnings); check_for_spaced_quotes(aline); check_for_miscased_genative(aline); - /* - * Now check special cases - start and end of line - - * for single and double quotes. Start is sometimes [sic] - * but better to query it anyway. - * While we're here, check for dash at end of line. - */ - llen=strlen(aline); - if (llen>1) - { - if (aline[llen-1]==CHAR_DQUOTE || aline[llen-1]==CHAR_SQUOTE || - aline[llen-1]==CHAR_OPEN_SQUOTE) - if (aline[llen-2]==CHAR_SPACE) - { - if (pswit[ECHO_SWITCH]) - printf("\n%s\n",aline); - if (!pswit[OVERVIEW_SWITCH]) - printf(" Line %ld column %d - Spaced quote?\n", - linecnt,llen); - else - cnt_punct++; - } - if ((aline[0]==CHAR_SQUOTE || aline[0]==CHAR_OPEN_SQUOTE) && - aline[1]==CHAR_SPACE) - { - if (pswit[ECHO_SWITCH]) - printf("\n%s\n",aline); - if (!pswit[OVERVIEW_SWITCH]) - printf(" Line %ld column 1 - Spaced quote?\n",linecnt); - else - cnt_punct++; - } - /* - * Dash at end of line may well be legit - paranoid mode only - * and don't report em-dash at line-end. - */ - if (pswit[PARANOID_SWITCH] && warnings->hyphen) - { - for (i=llen-1;i>0 && (unsigned char)aline[i]<=CHAR_SPACE;i--) - ; - if (aline[i]=='-' && aline[i-1]!='-') - { - if (pswit[ECHO_SWITCH]) - printf("\n%s\n",aline); - if (!pswit[OVERVIEW_SWITCH]) - printf(" Line %ld column %d - " - "Hyphen at end of line?\n",linecnt,i); - } - } - } + check_end_of_line(aline,warnings); /* * Brackets are often unspaced, but shouldn't be surrounded by alpha. * If so, suspect a scanno like "a]most".