10 * If we are in a state of unbalanced quotes, and this line
11 * doesn't begin with a quote, output the stored error message.
12 * If the -p switch was used, print the warning even if the
13 * new para starts with quotes.
15 void print_pending(const char *aline,const char *parastart,
16 struct pending *pending)
32 if (pending->illustration.warning_text)
36 if (pswit[ECHO_SWITCH] && !pending->illustration.queried_line)
37 pending->illustration.queried_line=g_strdup(parastart);
41 if (!pswit[OVERVIEW_SWITCH])
43 if (pending->illustration.queried_line)
44 g_print("\n%s\n",pending->illustration.queried_line);
45 g_print("%s\n",pending->illustration.warning_text);
49 g_free(pending->illustration.warning_text);
50 pending->illustration.warning_text=NULL;
51 g_free(pending->illustration.queried_line);
52 pending->illustration.queried_line=NULL;
57 if (c!=CHAR_DQUOTE || pswit[QPARA_SWITCH])
59 if (!pswit[OVERVIEW_SWITCH])
61 if (pswit[ECHO_SWITCH])
62 g_print("\n%s\n",parastart);
63 g_print("%s\n",pending->dquote);
68 g_free(pending->dquote);
73 if (!CHAR_IS_SQUOTE(c) || pswit[QPARA_SWITCH] || pending->squot)
75 if (!pswit[OVERVIEW_SWITCH])
77 if (pswit[ECHO_SWITCH])
78 g_print("\n%s\n",parastart);
79 g_print("%s\n",pending->squote);
84 g_free(pending->squote);
89 if (!pswit[OVERVIEW_SWITCH])
91 if (pswit[ECHO_SWITCH])
92 g_print("\n%s\n",parastart);
93 g_print("%s\n",pending->rbrack);
97 g_free(pending->rbrack);
102 if (!pswit[OVERVIEW_SWITCH])
104 if (pswit[ECHO_SWITCH])
105 g_print("\n%s\n",parastart);
106 g_print("%s\n",pending->sbrack);
110 g_free(pending->sbrack);
111 pending->sbrack=NULL;
115 if (!pswit[OVERVIEW_SWITCH])
117 if (pswit[ECHO_SWITCH])
118 g_print("\n%s\n",parastart);
119 g_print("%s\n",pending->cbrack);
123 g_free(pending->cbrack);
124 pending->cbrack=NULL;
128 if (!pswit[OVERVIEW_SWITCH])
130 if (pswit[ECHO_SWITCH])
131 g_print("\n%s\n",parastart);
132 g_print("%s\n",pending->unders);
136 g_free(pending->unders);
137 pending->unders=NULL;
141 void reset_pending(struct pending *pending)
143 memset(pending,0,sizeof(*pending));
147 * check_for_mismatched_quotes:
149 * At end of paragraph, check for mismatched quotes.
151 * We don't want to report an error immediately, since it is a
152 * common convention to omit the quotes at end of paragraph if
153 * the next paragraph is a continuation of the same speaker.
154 * Where this is the case, the next para should begin with a
155 * quote, so we store the warning message and only display it
156 * at the top of the next iteration if the new para doesn't
157 * start with a quote.
158 * The -p switch overrides this default, and warns of unclosed
159 * quotes on _every_ paragraph, whether the next begins with a
162 void check_for_mismatched_quotes(const struct counters *counters,
163 struct pending *pending)
165 int squote_straight,squote_curved,difference;
166 if (counters->quot%2)
168 g_strdup_printf(" Line %ld - Mismatched quotes",linecnt);
169 if (pswit[SQUOTE_SWITCH])
171 if (matching_count(counters,CHAR_SQUOTE,TRUE))
172 squote_straight=matching_difference(counters,CHAR_SQUOTE);
175 if (matching_count(counters,CHAR_LS_QUOTE,TRUE))
176 squote_curved=matching_difference(counters,CHAR_LS_QUOTE);
179 if (squote_straight || squote_curved)
181 g_strdup_printf(" Line %ld - Mismatched singlequotes?",
183 if (squote_straight && squote_straight!=1 ||
184 squote_curved && squote_curved!=1)
186 * Flag it to be noted regardless of the
187 * first char of the next para.
191 difference=matching_difference(counters,COUNTER_ILLUSTRATION);
194 if (difference<0 && pending->illustration.warning_text)
197 g_free(pending->illustration.queried_line);
198 pending->illustration.queried_line=NULL;
199 g_free(pending->illustration.warning_text);
200 pending->illustration.warning_text=NULL;
204 increment_matching(counters,CHAR_OPEN_SBRACK,FALSE);
209 if (pending->illustration.warning_text)
211 if (!pswit[OVERVIEW_SWITCH])
213 if (pending->illustration.queried_line)
214 g_print("\n%s\n",pending->illustration.queried_line);
215 g_print("%s\n",pending->illustration.warning_text);
219 g_free(pending->illustration.warning_text);
221 pending->illustration.warning_text=g_strdup_printf(
222 " Line %ld - Mismatched illustration tag?",linecnt);
223 g_free(pending->illustration.queried_line);
224 pending->illustration.queried_line=NULL;
227 if (matching_difference(counters,CHAR_OPEN_RBRACK))
229 g_strdup_printf(" Line %ld - Mismatched round brackets?",linecnt);
230 if (matching_difference(counters,CHAR_OPEN_SBRACK))
232 g_strdup_printf(" Line %ld - Mismatched square brackets?",linecnt);
233 if (matching_difference(counters,CHAR_OPEN_CBRACK))
235 g_strdup_printf(" Line %ld - Mismatched curly brackets?",linecnt);
236 if (counters->c_unders%2)
238 g_strdup_printf(" Line %ld - Mismatched underscores?",linecnt);