1.1 --- a/bookloupe/bookloupe.c Sun May 26 19:55:11 2013 +0100
1.2 +++ b/bookloupe/bookloupe.c Sun May 26 20:12:48 2013 +0100
1.3 @@ -2161,6 +2161,62 @@
1.4 }
1.5
1.6 /*
1.7 + * check_end_of_line:
1.8 + *
1.9 + * Now check special cases - start and end of line -
1.10 + * for single and double quotes. Start is sometimes [sic]
1.11 + * but better to query it anyway.
1.12 + * While we're here, check for dash at end of line.
1.13 + */
1.14 +void check_end_of_line(const char *aline,struct warnings *warnings)
1.15 +{
1.16 + int i,llen;
1.17 + llen=strlen(aline);
1.18 + if (llen>1)
1.19 + {
1.20 + if (aline[llen-1]==CHAR_DQUOTE || aline[llen-1]==CHAR_SQUOTE ||
1.21 + aline[llen-1]==CHAR_OPEN_SQUOTE)
1.22 + if (aline[llen-2]==CHAR_SPACE)
1.23 + {
1.24 + if (pswit[ECHO_SWITCH])
1.25 + printf("\n%s\n",aline);
1.26 + if (!pswit[OVERVIEW_SWITCH])
1.27 + printf(" Line %ld column %d - Spaced quote?\n",
1.28 + linecnt,llen);
1.29 + else
1.30 + cnt_punct++;
1.31 + }
1.32 + if ((aline[0]==CHAR_SQUOTE || aline[0]==CHAR_OPEN_SQUOTE) &&
1.33 + aline[1]==CHAR_SPACE)
1.34 + {
1.35 + if (pswit[ECHO_SWITCH])
1.36 + printf("\n%s\n",aline);
1.37 + if (!pswit[OVERVIEW_SWITCH])
1.38 + printf(" Line %ld column 1 - Spaced quote?\n",linecnt);
1.39 + else
1.40 + cnt_punct++;
1.41 + }
1.42 + /*
1.43 + * Dash at end of line may well be legit - paranoid mode only
1.44 + * and don't report em-dash at line-end.
1.45 + */
1.46 + if (pswit[PARANOID_SWITCH] && warnings->hyphen)
1.47 + {
1.48 + for (i=llen-1;i>0 && (unsigned char)aline[i]<=CHAR_SPACE;i--)
1.49 + ;
1.50 + if (aline[i]=='-' && aline[i-1]!='-')
1.51 + {
1.52 + if (pswit[ECHO_SWITCH])
1.53 + printf("\n%s\n",aline);
1.54 + if (!pswit[OVERVIEW_SWITCH])
1.55 + printf(" Line %ld column %d - Hyphen at end of line?\n",
1.56 + linecnt,i);
1.57 + }
1.58 + }
1.59 + }
1.60 +}
1.61 +
1.62 +/*
1.63 * procfile:
1.64 *
1.65 * Process one file.
1.66 @@ -2404,55 +2460,7 @@
1.67 check_for_double_punctuation(aline,warnings);
1.68 check_for_spaced_quotes(aline);
1.69 check_for_miscased_genative(aline);
1.70 - /*
1.71 - * Now check special cases - start and end of line -
1.72 - * for single and double quotes. Start is sometimes [sic]
1.73 - * but better to query it anyway.
1.74 - * While we're here, check for dash at end of line.
1.75 - */
1.76 - llen=strlen(aline);
1.77 - if (llen>1)
1.78 - {
1.79 - if (aline[llen-1]==CHAR_DQUOTE || aline[llen-1]==CHAR_SQUOTE ||
1.80 - aline[llen-1]==CHAR_OPEN_SQUOTE)
1.81 - if (aline[llen-2]==CHAR_SPACE)
1.82 - {
1.83 - if (pswit[ECHO_SWITCH])
1.84 - printf("\n%s\n",aline);
1.85 - if (!pswit[OVERVIEW_SWITCH])
1.86 - printf(" Line %ld column %d - Spaced quote?\n",
1.87 - linecnt,llen);
1.88 - else
1.89 - cnt_punct++;
1.90 - }
1.91 - if ((aline[0]==CHAR_SQUOTE || aline[0]==CHAR_OPEN_SQUOTE) &&
1.92 - aline[1]==CHAR_SPACE)
1.93 - {
1.94 - if (pswit[ECHO_SWITCH])
1.95 - printf("\n%s\n",aline);
1.96 - if (!pswit[OVERVIEW_SWITCH])
1.97 - printf(" Line %ld column 1 - Spaced quote?\n",linecnt);
1.98 - else
1.99 - cnt_punct++;
1.100 - }
1.101 - /*
1.102 - * Dash at end of line may well be legit - paranoid mode only
1.103 - * and don't report em-dash at line-end.
1.104 - */
1.105 - if (pswit[PARANOID_SWITCH] && warnings->hyphen)
1.106 - {
1.107 - for (i=llen-1;i>0 && (unsigned char)aline[i]<=CHAR_SPACE;i--)
1.108 - ;
1.109 - if (aline[i]=='-' && aline[i-1]!='-')
1.110 - {
1.111 - if (pswit[ECHO_SWITCH])
1.112 - printf("\n%s\n",aline);
1.113 - if (!pswit[OVERVIEW_SWITCH])
1.114 - printf(" Line %ld column %d - "
1.115 - "Hyphen at end of line?\n",linecnt,i);
1.116 - }
1.117 - }
1.118 - }
1.119 + check_end_of_line(aline,warnings);
1.120 /*
1.121 * Brackets are often unspaced, but shouldn't be surrounded by alpha.
1.122 * If so, suspect a scanno like "a]most".