1.1 --- a/bookloupe/bookloupe.c Sun May 26 01:46:33 2013 +0100
1.2 +++ b/bookloupe/bookloupe.c Sun May 26 16:39:48 2013 +0100
1.3 @@ -357,7 +357,7 @@
1.4 char running_from[MAX_PATH];
1.5
1.6 int mixdigit(char *);
1.7 -char *getaword(char *,char *);
1.8 +const char *getaword(const char *,char *);
1.9 int matchword(char *,char *);
1.10 char *flgets(char *,int,FILE *,long);
1.11 void lowerit(char *);
1.12 @@ -564,7 +564,8 @@
1.13 */
1.14 struct first_pass_results *first_pass(FILE *infile)
1.15 {
1.16 - char laststart=CHAR_SPACE,*s;
1.17 + char laststart=CHAR_SPACE;
1.18 + const char *s;
1.19 signed int i,llen;
1.20 unsigned int lastlen=0,lastblen=0;
1.21 long spline=0,nspline=0;
1.22 @@ -1516,13 +1517,66 @@
1.23 }
1.24
1.25 /*
1.26 + * check_for_following_punctuation:
1.27 + *
1.28 + * Check for words usually not followed by punctuation.
1.29 + */
1.30 +void check_for_following_punctuation(const char *aline)
1.31 +{
1.32 + int i;
1.33 + const char *s,*wordstart;
1.34 + char inword[MAXWORDLEN];
1.35 + if (pswit[TYPO_SWITCH])
1.36 + {
1.37 + for (s=aline;*s;)
1.38 + {
1.39 + wordstart=s;
1.40 + s=getaword(s,inword);
1.41 + if (!*inword)
1.42 + continue;
1.43 + lowerit(inword);
1.44 + for (i=0;*nocomma[i];i++)
1.45 + if (!strcmp(inword,nocomma[i]))
1.46 + {
1.47 + if (*s==',' || *s==';' || *s==':')
1.48 + {
1.49 + if (pswit[ECHO_SWITCH])
1.50 + printf("\n%s\n",aline);
1.51 + if (!pswit[OVERVIEW_SWITCH])
1.52 + printf(" Line %ld column %d - "
1.53 + "Query punctuation after %s?\n",
1.54 + linecnt,(int)(s-aline)+1,inword);
1.55 + else
1.56 + cnt_punct++;
1.57 + }
1.58 + }
1.59 + for (i=0;*noperiod[i];i++)
1.60 + if (!strcmp(inword,noperiod[i]))
1.61 + {
1.62 + if (*s=='.' || *s=='!')
1.63 + {
1.64 + if (pswit[ECHO_SWITCH])
1.65 + printf("\n%s\n",aline);
1.66 + if (!pswit[OVERVIEW_SWITCH])
1.67 + printf(" Line %ld column %d - "
1.68 + "Query punctuation after %s?\n",
1.69 + linecnt,(int)(s-aline)+1,inword);
1.70 + else
1.71 + cnt_punct++;
1.72 + }
1.73 + }
1.74 + }
1.75 + }
1.76 +}
1.77 +
1.78 +/*
1.79 * procfile:
1.80 *
1.81 * Process one file.
1.82 */
1.83 void procfile(char *filename)
1.84 {
1.85 - char *s,*t,*wordstart;
1.86 + const char *s,*t,*wordstart;
1.87 char inword[MAXWORDLEN],testword[MAXWORDLEN];
1.88 char parastart[81]; /* first line of current para */
1.89 FILE *infile;
1.90 @@ -1758,48 +1812,7 @@
1.91 check_for_orphan_character(aline);
1.92 check_for_pling_scanno(aline);
1.93 check_for_extra_period(aline,warnings);
1.94 - if (pswit[TYPO_SWITCH])
1.95 - {
1.96 - /* Check for words usually not followed by punctuation. */
1.97 - for (s=aline;*s;)
1.98 - {
1.99 - wordstart=s;
1.100 - s=getaword(s,inword);
1.101 - if (!*inword)
1.102 - continue;
1.103 - lowerit(inword);
1.104 - for (i=0;*nocomma[i];i++)
1.105 - if (!strcmp(inword,nocomma[i]))
1.106 - {
1.107 - if (*s==',' || *s==';' || *s==':')
1.108 - {
1.109 - if (pswit[ECHO_SWITCH])
1.110 - printf("\n%s\n",aline);
1.111 - if (!pswit[OVERVIEW_SWITCH])
1.112 - printf(" Line %ld column %d - "
1.113 - "Query punctuation after %s?\n",
1.114 - linecnt,(int)(s-aline)+1,inword);
1.115 - else
1.116 - cnt_punct++;
1.117 - }
1.118 - }
1.119 - for (i=0;*noperiod[i];i++)
1.120 - if (!strcmp(inword,noperiod[i]))
1.121 - {
1.122 - if (*s=='.' || *s=='!')
1.123 - {
1.124 - if (pswit[ECHO_SWITCH])
1.125 - printf("\n%s\n",aline);
1.126 - if (!pswit[OVERVIEW_SWITCH])
1.127 - printf(" Line %ld column %d - "
1.128 - "Query punctuation after %s?\n",
1.129 - linecnt,(int)(s-aline)+1,inword);
1.130 - else
1.131 - cnt_punct++;
1.132 - }
1.133 - }
1.134 - }
1.135 - }
1.136 + check_for_following_punctuation(aline);
1.137 /*
1.138 * Check for commonly mistyped words,
1.139 * and digits like 0 for O in a word.
1.140 @@ -2730,10 +2743,10 @@
1.141 * Returns: a pointer to the position in the line where we will start
1.142 * looking for the next word.
1.143 */
1.144 -char *getaword(char *fromline,char *thisword)
1.145 +const char *getaword(const char *fromline,char *thisword)
1.146 {
1.147 int i,wordlen;
1.148 - char *s;
1.149 + const char *s;
1.150 wordlen=0;
1.151 for (;!gcisdigit(*fromline) && !gcisalpha(*fromline) && *fromline;
1.152 fromline++)