# HG changeset patch # User ali # Date 1369582788 -3600 # Node ID 23b2ea51b029a4c26908ec0c2b048b274b44952f # Parent 4c8606eb60c1ddfa4ed62e05b77248208efa426f Break check_for_following_punctuation() out diff -r 4c8606eb60c1 -r 23b2ea51b029 bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sun May 26 01:46:33 2013 +0100 +++ b/bookloupe/bookloupe.c Sun May 26 16:39:48 2013 +0100 @@ -357,7 +357,7 @@ char running_from[MAX_PATH]; int mixdigit(char *); -char *getaword(char *,char *); +const char *getaword(const char *,char *); int matchword(char *,char *); char *flgets(char *,int,FILE *,long); void lowerit(char *); @@ -564,7 +564,8 @@ */ struct first_pass_results *first_pass(FILE *infile) { - char laststart=CHAR_SPACE,*s; + char laststart=CHAR_SPACE; + const char *s; signed int i,llen; unsigned int lastlen=0,lastblen=0; long spline=0,nspline=0; @@ -1516,13 +1517,66 @@ } /* + * check_for_following_punctuation: + * + * Check for words usually not followed by punctuation. + */ +void check_for_following_punctuation(const char *aline) +{ + int i; + const char *s,*wordstart; + char inword[MAXWORDLEN]; + if (pswit[TYPO_SWITCH]) + { + for (s=aline;*s;) + { + wordstart=s; + s=getaword(s,inword); + if (!*inword) + continue; + lowerit(inword); + for (i=0;*nocomma[i];i++) + if (!strcmp(inword,nocomma[i])) + { + if (*s==',' || *s==';' || *s==':') + { + if (pswit[ECHO_SWITCH]) + printf("\n%s\n",aline); + if (!pswit[OVERVIEW_SWITCH]) + printf(" Line %ld column %d - " + "Query punctuation after %s?\n", + linecnt,(int)(s-aline)+1,inword); + else + cnt_punct++; + } + } + for (i=0;*noperiod[i];i++) + if (!strcmp(inword,noperiod[i])) + { + if (*s=='.' || *s=='!') + { + if (pswit[ECHO_SWITCH]) + printf("\n%s\n",aline); + if (!pswit[OVERVIEW_SWITCH]) + printf(" Line %ld column %d - " + "Query punctuation after %s?\n", + linecnt,(int)(s-aline)+1,inword); + else + cnt_punct++; + } + } + } + } +} + +/* * procfile: * * Process one file. */ void procfile(char *filename) { - char *s,*t,*wordstart; + const char *s,*t,*wordstart; char inword[MAXWORDLEN],testword[MAXWORDLEN]; char parastart[81]; /* first line of current para */ FILE *infile; @@ -1758,48 +1812,7 @@ check_for_orphan_character(aline); check_for_pling_scanno(aline); check_for_extra_period(aline,warnings); - if (pswit[TYPO_SWITCH]) - { - /* Check for words usually not followed by punctuation. */ - for (s=aline;*s;) - { - wordstart=s; - s=getaword(s,inword); - if (!*inword) - continue; - lowerit(inword); - for (i=0;*nocomma[i];i++) - if (!strcmp(inword,nocomma[i])) - { - if (*s==',' || *s==';' || *s==':') - { - if (pswit[ECHO_SWITCH]) - printf("\n%s\n",aline); - if (!pswit[OVERVIEW_SWITCH]) - printf(" Line %ld column %d - " - "Query punctuation after %s?\n", - linecnt,(int)(s-aline)+1,inword); - else - cnt_punct++; - } - } - for (i=0;*noperiod[i];i++) - if (!strcmp(inword,noperiod[i])) - { - if (*s=='.' || *s=='!') - { - if (pswit[ECHO_SWITCH]) - printf("\n%s\n",aline); - if (!pswit[OVERVIEW_SWITCH]) - printf(" Line %ld column %d - " - "Query punctuation after %s?\n", - linecnt,(int)(s-aline)+1,inword); - else - cnt_punct++; - } - } - } - } + check_for_following_punctuation(aline); /* * Check for commonly mistyped words, * and digits like 0 for O in a word. @@ -2730,10 +2743,10 @@ * Returns: a pointer to the position in the line where we will start * looking for the next word. */ -char *getaword(char *fromline,char *thisword) +const char *getaword(const char *fromline,char *thisword) { int i,wordlen; - char *s; + const char *s; wordlen=0; for (;!gcisdigit(*fromline) && !gcisalpha(*fromline) && *fromline; fromline++)