# HG changeset patch # User ali # Date 1369604236 -3600 # Node ID a5ef278feb34b6b2b95b32ac79aabb06e9301edb # Parent 1b0e1aaf180067ab4afbd21700cfd1269c114be0 Break check_for_omitted_punctuation() out diff -r 1b0e1aaf1800 -r a5ef278feb34 bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sun May 26 22:30:38 2013 +0100 +++ b/bookloupe/bookloupe.c Sun May 26 22:37:16 2013 +0100 @@ -2481,6 +2481,60 @@ } /* + * check_for_omitted_punctuation: + * + * Check for omitted punctuation at end of paragraph by working back + * through prevline. DW. + * Need to check this only for "normal" paras. + * So what is a "normal" para? + * Not normal if one-liner (chapter headings, etc.) + * Not normal if doesn't contain at least one locase letter + * Not normal if starts with space + */ +void check_for_omitted_punctuation(const char *prevline, + struct line_properties *last,int start_para_line) +{ + int i; + const char *s; + for (s=prevline,i=0;*s && !i;s++) + if (gcisletter(*s)) + /* use i to indicate the presence of a letter on the line */ + i=1; + /* + * This next "if" is a problem. + * If we say "start_para_line <= linecnt - 1", that includes + * one-line "paragraphs" like chapter heads. Lotsa false positives. + * If we say "start_para_line < linecnt - 1" it doesn't, but then it + * misses genuine one-line paragraphs. + */ + if (i && last->blen>2 && start_para_lineCHAR_SPACE) + { + for (i=strlen(prevline)-1; + (prevline[i]==CHAR_DQUOTE || prevline[i]==CHAR_SQUOTE) && + prevline[i]>CHAR_SPACE && i>0; + i--) + ; + for (;i>0;i--) + { + if (gcisalpha(prevline[i])) + { + if (pswit[ECHO_SWITCH]) + printf("\n%s\n",prevline); + if (!pswit[OVERVIEW_SWITCH]) + printf(" Line %ld column %d - " + "No punctuation at para end?\n", + linecnt-1,strlen(prevline)); + else + cnt_punct++; + break; + } + if (strchr("-.:!([{?}])",prevline[i])) + break; + } + } +} + +/* * procfile: * * Process one file. @@ -2650,56 +2704,7 @@ memset(&counters,0,sizeof(counters)); /* let the next iteration know that it's starting a new para */ isnewpara=1; - } - /* - * Check for omitted punctuation at end of paragraph by working back - * through prevline. DW. - * Need to check this only for "normal" paras. - * So what is a "normal" para? - * Not normal if one-liner (chapter headings, etc.) - * Not normal if doesn't contain at least one locase letter - * Not normal if starts with space - */ - if (isemptyline) - { - /* end of para */ - for (s=prevline,i=0;*s && !i;s++) - if (gcisletter(*s)) - /* use i to indicate the presence of a letter on the line */ - i=1; - /* - * This next "if" is a problem. - * If we say "start_para_line <= linecnt - 1", that includes - * one-line "paragraphs" like chapter heads. Lotsa false positives. - * If we say "start_para_line < linecnt - 1" it doesn't, but then it - * misses genuine one-line paragraphs. - */ - if (i && last.blen>2 && start_para_lineCHAR_SPACE) - { - for (i=strlen(prevline)-1; - (prevline[i]==CHAR_DQUOTE || prevline[i]==CHAR_SQUOTE) && - prevline[i]>CHAR_SPACE && i>0; - i--) - ; - for (;i>0;i--) - { - if (gcisalpha(prevline[i])) - { - if (pswit[ECHO_SWITCH]) - printf("\n%s\n",prevline); - if (!pswit[OVERVIEW_SWITCH]) - printf(" Line %ld column %d - " - "No punctuation at para end?\n", - linecnt-1,strlen(prevline)); - else - cnt_punct++; - break; - } - if (strchr("-.:!([{?}])",prevline[i])) - break; - } - } + check_for_omitted_punctuation(prevline,&last,start_para_line); } strcpy(prevline,aline); }