1.1 --- a/bookloupe/pending.c Mon Sep 23 21:18:27 2013 +0100
1.2 +++ b/bookloupe/pending.c Tue Sep 24 22:31:04 2013 +0100
1.3 @@ -1,6 +1,7 @@
1.4 #include <stdlib.h>
1.5 #include <string.h>
1.6 #include <glib.h>
1.7 +#include <bl/bl.h>
1.8 #include "bookloupe.h"
1.9 #include "pending.h"
1.10
1.11 @@ -15,20 +16,9 @@
1.12 void print_pending(const char *aline,const char *parastart,
1.13 struct pending *pending)
1.14 {
1.15 - const char *s;
1.16 - gunichar c;
1.17 if (aline)
1.18 - {
1.19 - s=aline;
1.20 - while (*s==' ')
1.21 - s++;
1.22 - c=g_utf8_get_char(s);
1.23 - }
1.24 - else
1.25 - {
1.26 - s=NULL;
1.27 - c='\0';
1.28 - }
1.29 + while (g_unichar_isspace(g_utf8_get_char(aline)))
1.30 + aline=g_utf8_next_char(aline);
1.31 if (pending->illustration.warning_text)
1.32 {
1.33 if (aline)
1.34 @@ -54,7 +44,8 @@
1.35 }
1.36 if (pending->dquote)
1.37 {
1.38 - if (c!=CHAR_DQUOTE || pswit[QPARA_SWITCH])
1.39 + if (!pending->continuing_quote || !aline ||
1.40 + !g_str_has_prefix(aline,pending->continuing_quote))
1.41 {
1.42 if (!pswit[OVERVIEW_SWITCH])
1.43 {
1.44 @@ -70,7 +61,8 @@
1.45 }
1.46 if (pending->squote)
1.47 {
1.48 - if (!CHAR_IS_SQUOTE(c) || pswit[QPARA_SWITCH] || pending->squot)
1.49 + if (!pending->continuing_quote ||
1.50 + !g_str_has_prefix(aline,pending->continuing_quote))
1.51 {
1.52 if (!pswit[OVERVIEW_SWITCH])
1.53 {
1.54 @@ -84,6 +76,8 @@
1.55 g_free(pending->squote);
1.56 pending->squote=NULL;
1.57 }
1.58 + g_free(pending->continuing_quote);
1.59 + pending->continuing_quote=NULL;
1.60 if (pending->rbrack)
1.61 {
1.62 if (!pswit[OVERVIEW_SWITCH])
1.63 @@ -159,34 +153,58 @@
1.64 * quotes on _every_ paragraph, whether the next begins with a
1.65 * quote or not.
1.66 */
1.67 -void check_for_mismatched_quotes(const struct counters *counters,
1.68 +void check_for_mismatched_quotes(struct counters *counters,
1.69 struct pending *pending)
1.70 {
1.71 - int squote_straight,squote_curved,difference;
1.72 - if (counters->quot%2)
1.73 + int quote_straight,quote_curved,difference;
1.74 + quote_straight=matching_difference(counters,CHAR_DQUOTE);
1.75 + quote_curved=matching_difference(counters,CHAR_LD_QUOTE);
1.76 + if (quote_straight || quote_curved)
1.77 + {
1.78 pending->dquote=
1.79 g_strdup_printf(" Line %ld - Mismatched quotes",linecnt);
1.80 + if (pswit[QPARA_SWITCH] || quote_curved && quote_curved!=1 ||
1.81 + quote_straight && quote_curved)
1.82 + /*
1.83 + * Flag it to be noted regardless of the
1.84 + * first line of the next para.
1.85 + */
1.86 + pending->continuing_quote=NULL;
1.87 + else if (quote_straight)
1.88 + pending->continuing_quote=utf8_strnfill(quote_straight,CHAR_DQUOTE);
1.89 + else
1.90 + pending->continuing_quote=utf8_strnfill(quote_curved,CHAR_LD_QUOTE);
1.91 + }
1.92 if (pswit[SQUOTE_SWITCH])
1.93 {
1.94 if (matching_count(counters,CHAR_SQUOTE,TRUE))
1.95 - squote_straight=matching_difference(counters,CHAR_SQUOTE);
1.96 + quote_straight=matching_difference(counters,CHAR_SQUOTE);
1.97 else
1.98 - squote_straight=0;
1.99 + quote_straight=0;
1.100 if (matching_count(counters,CHAR_LS_QUOTE,TRUE))
1.101 - squote_curved=matching_difference(counters,CHAR_LS_QUOTE);
1.102 + quote_curved=matching_difference(counters,CHAR_LS_QUOTE);
1.103 else
1.104 - squote_curved=0;
1.105 - if (squote_straight || squote_curved)
1.106 + quote_curved=0;
1.107 + if (quote_straight || quote_curved)
1.108 pending->squote=
1.109 g_strdup_printf(" Line %ld - Mismatched singlequotes?",
1.110 linecnt);
1.111 - if (squote_straight && squote_straight!=1 ||
1.112 - squote_curved && squote_curved!=1)
1.113 + if (pending->continuing_quote)
1.114 + {
1.115 /*
1.116 * Flag it to be noted regardless of the
1.117 - * first char of the next para.
1.118 + * first line of the next para.
1.119 */
1.120 - pending->squot=1;
1.121 + g_free(pending->continuing_quote);
1.122 + pending->continuing_quote=NULL;
1.123 + }
1.124 + if (pswit[QPARA_SWITCH] || quote_straight && quote_straight!=1 ||
1.125 + quote_curved && quote_curved!=1 || quote_straight && quote_curved)
1.126 + pending->continuing_quote=NULL;
1.127 + else if (quote_straight)
1.128 + pending->continuing_quote=utf8_strnfill(quote_straight,CHAR_SQUOTE);
1.129 + else
1.130 + pending->continuing_quote=utf8_strnfill(quote_curved,CHAR_LS_QUOTE);
1.131 }
1.132 difference=matching_difference(counters,COUNTER_ILLUSTRATION);
1.133 if (difference)