1.1 --- a/bookloupe/bookloupe.c Sun May 26 22:30:38 2013 +0100
1.2 +++ b/bookloupe/bookloupe.c Sun May 26 22:37:16 2013 +0100
1.3 @@ -2481,6 +2481,60 @@
1.4 }
1.5
1.6 /*
1.7 + * check_for_omitted_punctuation:
1.8 + *
1.9 + * Check for omitted punctuation at end of paragraph by working back
1.10 + * through prevline. DW.
1.11 + * Need to check this only for "normal" paras.
1.12 + * So what is a "normal" para?
1.13 + * Not normal if one-liner (chapter headings, etc.)
1.14 + * Not normal if doesn't contain at least one locase letter
1.15 + * Not normal if starts with space
1.16 + */
1.17 +void check_for_omitted_punctuation(const char *prevline,
1.18 + struct line_properties *last,int start_para_line)
1.19 +{
1.20 + int i;
1.21 + const char *s;
1.22 + for (s=prevline,i=0;*s && !i;s++)
1.23 + if (gcisletter(*s))
1.24 + /* use i to indicate the presence of a letter on the line */
1.25 + i=1;
1.26 + /*
1.27 + * This next "if" is a problem.
1.28 + * If we say "start_para_line <= linecnt - 1", that includes
1.29 + * one-line "paragraphs" like chapter heads. Lotsa false positives.
1.30 + * If we say "start_para_line < linecnt - 1" it doesn't, but then it
1.31 + * misses genuine one-line paragraphs.
1.32 + */
1.33 + if (i && last->blen>2 && start_para_line<linecnt-1 && *prevline>CHAR_SPACE)
1.34 + {
1.35 + for (i=strlen(prevline)-1;
1.36 + (prevline[i]==CHAR_DQUOTE || prevline[i]==CHAR_SQUOTE) &&
1.37 + prevline[i]>CHAR_SPACE && i>0;
1.38 + i--)
1.39 + ;
1.40 + for (;i>0;i--)
1.41 + {
1.42 + if (gcisalpha(prevline[i]))
1.43 + {
1.44 + if (pswit[ECHO_SWITCH])
1.45 + printf("\n%s\n",prevline);
1.46 + if (!pswit[OVERVIEW_SWITCH])
1.47 + printf(" Line %ld column %d - "
1.48 + "No punctuation at para end?\n",
1.49 + linecnt-1,strlen(prevline));
1.50 + else
1.51 + cnt_punct++;
1.52 + break;
1.53 + }
1.54 + if (strchr("-.:!([{?}])",prevline[i]))
1.55 + break;
1.56 + }
1.57 + }
1.58 +}
1.59 +
1.60 +/*
1.61 * procfile:
1.62 *
1.63 * Process one file.
1.64 @@ -2650,56 +2704,7 @@
1.65 memset(&counters,0,sizeof(counters));
1.66 /* let the next iteration know that it's starting a new para */
1.67 isnewpara=1;
1.68 - }
1.69 - /*
1.70 - * Check for omitted punctuation at end of paragraph by working back
1.71 - * through prevline. DW.
1.72 - * Need to check this only for "normal" paras.
1.73 - * So what is a "normal" para?
1.74 - * Not normal if one-liner (chapter headings, etc.)
1.75 - * Not normal if doesn't contain at least one locase letter
1.76 - * Not normal if starts with space
1.77 - */
1.78 - if (isemptyline)
1.79 - {
1.80 - /* end of para */
1.81 - for (s=prevline,i=0;*s && !i;s++)
1.82 - if (gcisletter(*s))
1.83 - /* use i to indicate the presence of a letter on the line */
1.84 - i=1;
1.85 - /*
1.86 - * This next "if" is a problem.
1.87 - * If we say "start_para_line <= linecnt - 1", that includes
1.88 - * one-line "paragraphs" like chapter heads. Lotsa false positives.
1.89 - * If we say "start_para_line < linecnt - 1" it doesn't, but then it
1.90 - * misses genuine one-line paragraphs.
1.91 - */
1.92 - if (i && last.blen>2 && start_para_line<linecnt-1 &&
1.93 - *prevline>CHAR_SPACE)
1.94 - {
1.95 - for (i=strlen(prevline)-1;
1.96 - (prevline[i]==CHAR_DQUOTE || prevline[i]==CHAR_SQUOTE) &&
1.97 - prevline[i]>CHAR_SPACE && i>0;
1.98 - i--)
1.99 - ;
1.100 - for (;i>0;i--)
1.101 - {
1.102 - if (gcisalpha(prevline[i]))
1.103 - {
1.104 - if (pswit[ECHO_SWITCH])
1.105 - printf("\n%s\n",prevline);
1.106 - if (!pswit[OVERVIEW_SWITCH])
1.107 - printf(" Line %ld column %d - "
1.108 - "No punctuation at para end?\n",
1.109 - linecnt-1,strlen(prevline));
1.110 - else
1.111 - cnt_punct++;
1.112 - break;
1.113 - }
1.114 - if (strchr("-.:!([{?}])",prevline[i]))
1.115 - break;
1.116 - }
1.117 - }
1.118 + check_for_omitted_punctuation(prevline,&last,start_para_line);
1.119 }
1.120 strcpy(prevline,aline);
1.121 }