Fix bug #21: False positive: Opening slanted double-quote, followed by single slanted quote, should be accepted by BL
authorali <ali@juiblex.co.uk>
Sat Oct 05 21:37:31 2013 +0100 (2013-10-05)
changeset 99783eff3047bc
parent 98 37da646396b9
child 100 ad92d11d59b8
Fix bug #21: False positive: Opening slanted double-quote, followed by single slanted quote, should be accepted by BL
bookloupe/bookloupe.c
test/bookloupe/curved-quotes.tst
     1.1 --- a/bookloupe/bookloupe.c	Tue Oct 15 07:57:45 2013 +0100
     1.2 +++ b/bookloupe/bookloupe.c	Sat Oct 05 21:37:31 2013 +0100
     1.3 @@ -1478,7 +1478,7 @@
     1.4  	    }
     1.5  	    s1=g_utf8_next_char(g_utf8_next_char(t));
     1.6  	    while (*s1 && !g_unichar_isalpha(g_utf8_get_char(s1)) &&
     1.7 -	      !isdigit(g_utf8_get_char(s1)))
     1.8 +	      !g_unichar_isdigit(g_utf8_get_char(s1)))
     1.9  		s1=g_utf8_next_char(s1);
    1.10  	    if (g_unichar_islower(g_utf8_get_char(s1)))
    1.11  	    {
    1.12 @@ -2036,7 +2036,7 @@
    1.13  	    if (!parity)
    1.14  	    {
    1.15  		/* parity even */
    1.16 -		if (!g_utf8_strchr("_-.'`/,;:!?)]} ",-1,nc))
    1.17 +		if (!g_utf8_strchr("_-.'`‘’/,;:!?)]} ",-1,nc))
    1.18  		{
    1.19  		    if (pswit[ECHO_SWITCH])
    1.20  			g_print("\n%s\n",aline);
    1.21 @@ -2051,8 +2051,8 @@
    1.22  	    else
    1.23  	    {
    1.24  		/* parity odd */
    1.25 -		if (!g_unichar_isalpha(nc) && !isdigit(nc) &&
    1.26 -		  !g_utf8_strchr("_-/.'`([{$",-1,nc) || !nc)
    1.27 +		if (!g_unichar_isalpha(nc) && !g_unichar_isdigit(nc) &&
    1.28 +		  !g_utf8_strchr("_-/.'`‘’([{$",-1,nc) || !nc)
    1.29  		{
    1.30  		    if (pswit[ECHO_SWITCH])
    1.31  			g_print("\n%s\n",aline);
    1.32 @@ -2111,7 +2111,7 @@
    1.33  		else
    1.34  		{
    1.35  		    /* parity odd */
    1.36 -		    if (!g_unichar_isalpha(nc) && !isdigit(nc) &&
    1.37 +		    if (!g_unichar_isalpha(nc) && !g_unichar_isdigit(nc) &&
    1.38  		      !g_utf8_strchr("_-/\".'`",-1,nc) || !nc)
    1.39  		    {
    1.40  			if (pswit[ECHO_SWITCH])
    1.41 @@ -2777,9 +2777,27 @@
    1.42      for (;;)
    1.43      {
    1.44  	c=g_utf8_get_char(*etext);
    1.45 +	if (!c)
    1.46 +	{
    1.47 +	    if (*etext==theline)
    1.48 +		return NULL;
    1.49 +	    else if (pswit[LINE_END_SWITCH])
    1.50 +	    {
    1.51 +		if (pswit[ECHO_SWITCH])
    1.52 +		{
    1.53 +		    s=g_strndup(theline,eos-theline);
    1.54 +		    g_print("\n%s\n",s);
    1.55 +		    g_free(s);
    1.56 +		}
    1.57 +		if (!pswit[OVERVIEW_SWITCH])
    1.58 +		    /* There may, or may not, have been a CR */
    1.59 +		    g_print("    Line %ld - No LF?\n",lcnt);
    1.60 +		else
    1.61 +		    cnt_lineend++;
    1.62 +	    }
    1.63 +	    break;
    1.64 +	}
    1.65  	*etext=g_utf8_next_char(*etext);
    1.66 -	if (!c)
    1.67 -	    return NULL;
    1.68  	/* either way, it's end of line */
    1.69  	if (c=='\n')
    1.70  	{
     2.1 --- a/test/bookloupe/curved-quotes.tst	Tue Oct 15 07:57:45 2013 +0100
     2.2 +++ b/test/bookloupe/curved-quotes.tst	Sat Oct 05 21:37:31 2013 +0100
     2.3 @@ -19,6 +19,16 @@
     2.4  you’d like to come.”
     2.5  
     2.6  “Sure! they chorused.
     2.7 +
     2.8 +* * *
     2.9 +
    2.10 +“‘Think I want to lug a bear two mile into camp?’ says he. ‘No, sir, I
    2.11 +lured this here bear in so’s I could kill him handy to where I wanted
    2.12 +him. I jest figgered to make him carry himself into camp,’ says he.”
    2.13 +
    2.14 +The widow shook her head. “’Tain’t nothin’ but a memento no more. Husbands
    2.15 +is all right, but enough’s enough. Let me make you acquainted with Miss
    2.16 +Ducharme, Mr. Ashe.”
    2.17  **************** WARNINGS ****************
    2.18  <expected>
    2.19    <error>