diff -r adc06e9e8470 -r 7f0bbee5c8b0 bookloupe/pending.c --- a/bookloupe/pending.c Mon Sep 23 21:18:27 2013 +0100 +++ b/bookloupe/pending.c Wed Oct 30 17:11:11 2013 +0000 @@ -1,6 +1,7 @@ #include #include #include +#include #include "bookloupe.h" #include "pending.h" @@ -15,20 +16,9 @@ void print_pending(const char *aline,const char *parastart, struct pending *pending) { - const char *s; - gunichar c; if (aline) - { - s=aline; - while (*s==' ') - s++; - c=g_utf8_get_char(s); - } - else - { - s=NULL; - c='\0'; - } + while (g_unichar_isspace(g_utf8_get_char(aline))) + aline=g_utf8_next_char(aline); if (pending->illustration.warning_text) { if (aline) @@ -52,38 +42,25 @@ pending->illustration.queried_line=NULL; } } - if (pending->dquote) + if (pending->quote) { - if (c!=CHAR_DQUOTE || pswit[QPARA_SWITCH]) + if (!pending->continuing_quote || !aline || + !g_str_has_prefix(aline,pending->continuing_quote)) { if (!pswit[OVERVIEW_SWITCH]) { if (pswit[ECHO_SWITCH]) g_print("\n%s\n",parastart); - g_print("%s\n",pending->dquote); + g_print("%s\n",pending->quote); } else - cnt_dquot++; + cnt_quote++; } - g_free(pending->dquote); - pending->dquote=NULL; + g_free(pending->quote); + pending->quote=NULL; } - if (pending->squote) - { - if (!CHAR_IS_SQUOTE(c) || pswit[QPARA_SWITCH] || pending->squot) - { - if (!pswit[OVERVIEW_SWITCH]) - { - if (pswit[ECHO_SWITCH]) - g_print("\n%s\n",parastart); - g_print("%s\n",pending->squote); - } - else - cnt_squot++; - } - g_free(pending->squote); - pending->squote=NULL; - } + g_free(pending->continuing_quote); + pending->continuing_quote=NULL; if (pending->rbrack) { if (!pswit[OVERVIEW_SWITCH]) @@ -159,34 +136,35 @@ * quotes on _every_ paragraph, whether the next begins with a * quote or not. */ -void check_for_mismatched_quotes(const struct counters *counters, +void check_for_mismatched_quotes(struct counters *counters, struct pending *pending) { - int squote_straight,squote_curved,difference; - if (counters->quot%2) - pending->dquote= - g_strdup_printf(" Line %ld - Mismatched quotes",linecnt); - if (pswit[SQUOTE_SWITCH]) + gboolean all_single; + gunichar c; + int difference; + const char *quote_type; + GString *str; + if (counters->open_quotes) { - if (matching_count(counters,CHAR_SQUOTE,TRUE)) - squote_straight=matching_difference(counters,CHAR_SQUOTE); + str=g_string_new(NULL); + counters->open_quotes=g_slist_reverse(counters->open_quotes); + all_single=TRUE; + while(counters->open_quotes) + { + c=GPOINTER_TO_INT(counters->open_quotes->data); + if (!CHAR_IS_SQUOTE(c)) + all_single=FALSE; + g_string_append_unichar(str,c); + counters->open_quotes=g_slist_delete_link(counters->open_quotes, + counters->open_quotes); + } + pending->continuing_quote=g_string_free(str,FALSE); + if (all_single) + quote_type="singlequotes?"; else - squote_straight=0; - if (matching_count(counters,CHAR_LS_QUOTE,TRUE)) - squote_curved=matching_difference(counters,CHAR_LS_QUOTE); - else - squote_curved=0; - if (squote_straight || squote_curved) - pending->squote= - g_strdup_printf(" Line %ld - Mismatched singlequotes?", - linecnt); - if (squote_straight && squote_straight!=1 || - squote_curved && squote_curved!=1) - /* - * Flag it to be noted regardless of the - * first char of the next para. - */ - pending->squot=1; + quote_type="quotes"; + pending->quote=g_strdup_printf(" Line %ld - Mismatched %s",linecnt, + quote_type); } difference=matching_difference(counters,COUNTER_ILLUSTRATION); if (difference)