# HG changeset patch # User ali # Date 1369592911 -3600 # Node ID 1e89f47e56dfb9726a31309ded1dae575462ad71 # Parent 8ade5460e2205a5161ea3ca67f43fb9cec67220f Break check_for_double_punctuation() out diff -r 8ade5460e220 -r 1e89f47e56df bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sun May 26 17:23:48 2013 +0100 +++ b/bookloupe/bookloupe.c Sun May 26 19:28:31 2013 +0100 @@ -2028,6 +2028,70 @@ } /* + * check_for_double_punctuation: + * + * Look for double punctuation like ,. or ,, + * Thanks to DW for the suggestion! + * In books with references, ".," and ".;" are common + * e.g. "etc., etc.," and vol. 1.; vol 3.; + * OTOH, from my initial tests, there are also fairly + * common errors. What to do? Make these cases paranoid? + * ".," is the most common, so warnings->dotcomma is used + * to suppress detailed reporting if it occurs often. + */ +void check_for_double_punctuation(const char *aline,struct warnings *warnings) +{ + int i,llen; + llen=strlen(aline); + for (i=0;idotcomma && aline[i]=='.' && aline[i+1]==',' || + warnings->isFrench && !strncmp(aline+i,",...",4) || + warnings->isFrench && !strncmp(aline+i,"...,",4) || + warnings->isFrench && !strncmp(aline+i,";...",4) || + warnings->isFrench && !strncmp(aline+i,"...;",4) || + warnings->isFrench && !strncmp(aline+i,":...",4) || + warnings->isFrench && !strncmp(aline+i,"...:",4) || + warnings->isFrench && !strncmp(aline+i,"!...",4) || + warnings->isFrench && !strncmp(aline+i,"...!",4) || + warnings->isFrench && !strncmp(aline+i,"?...",4) || + warnings->isFrench && !strncmp(aline+i,"...?",4)) + { + if (warnings->isFrench && !strncmp(aline+i,",...",4) || + warnings->isFrench && !strncmp(aline+i,"...,",4) || + warnings->isFrench && !strncmp(aline+i,";...",4) || + warnings->isFrench && !strncmp(aline+i,"...;",4) || + warnings->isFrench && !strncmp(aline+i,":...",4) || + warnings->isFrench && !strncmp(aline+i,"...:",4) || + warnings->isFrench && !strncmp(aline+i,"!...",4) || + warnings->isFrench && !strncmp(aline+i,"...!",4) || + warnings->isFrench && !strncmp(aline+i,"?...",4) || + warnings->isFrench && !strncmp(aline+i,"...?",4)) + i+=4; + ; /* do nothing for .. !! and ?? which can be legit */ + } + else + { + if (pswit[ECHO_SWITCH]) + printf("\n%s\n",aline); + if (!pswit[OVERVIEW_SWITCH]) + printf(" Line %ld column %d - Double punctuation?\n", + linecnt,i+1); + else + cnt_punct++; + } + } + } +} + +/* * procfile: * * Process one file. @@ -2268,63 +2332,7 @@ check_for_following_punctuation(aline); check_for_typos(aline,warnings); check_for_misspaced_punctuation(aline,&parities,isemptyline); - /* - * Look for double punctuation like ,. or ,, - * Thanks to DW for the suggestion! - * In books with references, ".," and ".;" are common - * e.g. "etc., etc.," and vol. 1.; vol 3.; - * OTOH, from my initial tests, there are also fairly - * common errors. What to do? Make these cases paranoid? - * ".," is the most common, so warnings->dotcomma is used - * to suppress detailed reporting if it occurs often. - */ - llen=strlen(aline); - for (i=0;idotcomma && aline[i]=='.' && aline[i+1]==',' || - warnings->isFrench && !strncmp(aline+i,",...",4) || - warnings->isFrench && !strncmp(aline+i,"...,",4) || - warnings->isFrench && !strncmp(aline+i,";...",4) || - warnings->isFrench && !strncmp(aline+i,"...;",4) || - warnings->isFrench && !strncmp(aline+i,":...",4) || - warnings->isFrench && !strncmp(aline+i,"...:",4) || - warnings->isFrench && !strncmp(aline+i,"!...",4) || - warnings->isFrench && !strncmp(aline+i,"...!",4) || - warnings->isFrench && !strncmp(aline+i,"?...",4) || - warnings->isFrench && !strncmp(aline+i,"...?",4)) - { - if (warnings->isFrench && !strncmp(aline+i,",...",4) || - warnings->isFrench && !strncmp(aline+i,"...,",4) || - warnings->isFrench && !strncmp(aline+i,";...",4) || - warnings->isFrench && !strncmp(aline+i,"...;",4) || - warnings->isFrench && !strncmp(aline+i,":...",4) || - warnings->isFrench && !strncmp(aline+i,"...:",4) || - warnings->isFrench && !strncmp(aline+i,"!...",4) || - warnings->isFrench && !strncmp(aline+i,"...!",4) || - warnings->isFrench && !strncmp(aline+i,"?...",4) || - warnings->isFrench && !strncmp(aline+i,"...?",4)) - i+=4; - ; /* do nothing for .. !! and ?? which can be legit */ - } - else - { - if (pswit[ECHO_SWITCH]) - printf("\n%s\n",aline); - if (!pswit[OVERVIEW_SWITCH]) - printf(" Line %ld column %d - Double punctuation?\n", - linecnt,i+1); - else - cnt_punct++; - } - } - } + check_for_double_punctuation(aline,warnings); s=aline; while (strstr(s," \" ")) {