# HG changeset patch # User ali # Date 1369529193 -3600 # Node ID 4c8606eb60c1ddfa4ed62e05b77248208efa426f # Parent a1fd8d3f09405b3e28045b776fc7ee302fa07514 Break check_for_extra_period() out diff -r a1fd8d3f0940 -r 4c8606eb60c1 bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sat May 25 23:57:38 2013 +0100 +++ b/bookloupe/bookloupe.c Sun May 26 01:46:33 2013 +0100 @@ -379,7 +379,6 @@ #define MAX_QWORD 50 #define MAX_QWORD_LENGTH 40 char qword[MAX_QWORD][MAX_QWORD_LENGTH]; -char qperiod[MAX_QWORD][MAX_QWORD_LENGTH]; signed int dupcnt[MAX_QWORD]; int main(int argc,char **argv) @@ -1415,13 +1414,115 @@ } /* + * check_for_extra_period: + * + * Check for period without a capital letter. Cut-down from gutspell. + * Only works when it happens on a single line. + */ +void check_for_extra_period(const char *aline,const struct warnings *warnings) +{ + const char *s,*t,*s1; + signed int i,istypo,isdup; + static char qperiod[MAX_QWORD][MAX_QWORD_LENGTH]; + static int qperiod_index=0; + char testword[MAXWORDLEN]=""; + if (pswit[PARANOID_SWITCH]) + { + for (t=s=aline;strstr(t,". ");) + { + t=strstr(t,". "); + if (t==s) + { + t++; + /* start of line punctuation is handled elsewhere */ + continue; + } + if (!gcisalpha(t[-1])) + { + t++; + continue; + } + if (warnings->isDutch) + { + /* For Frank & Jeroen -- 's Middags case */ + if (t[2]==CHAR_SQUOTE && t[3]>='a' && t[3]<='z' && + t[4]==CHAR_SPACE && t[5]>='A' && t[5]<='Z') + { + t++; + continue; + } + } + s1=t+2; + while (*s1 && !gcisalpha(*s1) && !isdigit(*s1)) + s1++; + if (*s1>='a' && *s1<='z') + { + /* we have something to investigate */ + istypo=1; + /* so let's go back and find out */ + for (s1=t-1;s1>=s && + (gcisalpha(*s1) || gcisdigit(*s1) || *s1==CHAR_SQUOTE && + gcisalpha(s1[1]) && gcisalpha(s1[-1]));s1--) + ; + s1++; + for (i=0;*s1 && *s1!='.';s1++,i++) + testword[i]=*s1; + testword[i]=0; + for (i=0;*abbrev[i];i++) + if (!strcmp(testword,abbrev[i])) + istypo=0; + if (gcisdigit(*testword)) + istypo=0; + if (!testword[1]) + istypo=0; + if (isroman(testword)) + istypo=0; + if (istypo) + { + istypo=0; + for (i=0;testword[i];i++) + if (strchr(vowels,testword[i])) + istypo=1; + } + if (istypo) + { + isdup=0; + if (strlen(testword)isDutch) - { - /* For Frank & Jeroen -- 's Middags case */ - if (t[2]==CHAR_SQUOTE && t[3]>='a' && t[3]<='z' && - t[4]==CHAR_SPACE && t[5]>='A' && t[5]<='Z') - { - t++; - continue; - } - } - s1=t+2; - while (*s1 && !gcisalpha(*s1) && !isdigit(*s1)) - s1++; - if (*s1>='a' && *s1<='z') - { - /* we have something to investigate */ - istypo=1; - /* so let's go back and find out */ - for (s1=t-1;s1>=s && - (gcisalpha(*s1) || gcisdigit(*s1) || *s1==CHAR_SQUOTE && - gcisalpha(s1[1]) && gcisalpha(s1[-1]));s1--) - ; - s1++; - for (i=0;*s1 && *s1!='.';s1++,i++) - testword[i]=*s1; - testword[i]=0; - for (i=0;*abbrev[i];i++) - if (!strcmp(testword,abbrev[i])) - istypo=0; - if (gcisdigit(*testword)) - istypo=0; - if (!testword[1]) - istypo=0; - if (isroman(testword)) - istypo=0; - if (istypo) - { - istypo=0; - for (i=0;testword[i];i++) - if (strchr(vowels,testword[i])) - istypo=1; - } - if (istypo) - { - isdup=0; - if (strlen(testword)