Break check_for_unspaced_bracket() out
authorali <ali@juiblex.co.uk>
Sun May 26 20:24:02 2013 +0100 (2013-05-26)
changeset 6123b81eb371a8
parent 60 5d1e411a5400
child 62 d4a66d961a69
Break check_for_unspaced_bracket() out
bookloupe/bookloupe.c
     1.1 --- a/bookloupe/bookloupe.c	Sun May 26 20:12:48 2013 +0100
     1.2 +++ b/bookloupe/bookloupe.c	Sun May 26 20:24:02 2013 +0100
     1.3 @@ -2217,6 +2217,33 @@
     1.4  }
     1.5  
     1.6  /*
     1.7 + * check_for_unspaced_bracket:
     1.8 + *
     1.9 + * Brackets are often unspaced, but shouldn't be surrounded by alpha.
    1.10 + * If so, suspect a scanno like "a]most".
    1.11 + */
    1.12 +void check_for_unspaced_bracket(const char *aline)
    1.13 +{
    1.14 +    int i,llen;
    1.15 +    llen=strlen(aline);
    1.16 +    for (i=1;i<llen-1;i++)
    1.17 +    {
    1.18 +	/* for each bracket character in the line except 1st & last */
    1.19 +	if (strchr("{[()]}",aline[i]) && gcisalpha(aline[i-1]) &&
    1.20 +	  gcisalpha(aline[i+1]))
    1.21 +	{
    1.22 +	    if (pswit[ECHO_SWITCH])
    1.23 +		printf("\n%s\n",aline);
    1.24 +	    if (!pswit[OVERVIEW_SWITCH])
    1.25 +		printf("    Line %ld column %d - Unspaced bracket?\n",
    1.26 +		  linecnt,i);
    1.27 +	    else
    1.28 +		cnt_punct++;
    1.29 +	}
    1.30 +    }
    1.31 +}
    1.32 +
    1.33 +/*
    1.34   * procfile:
    1.35   *
    1.36   * Process one file.
    1.37 @@ -2461,26 +2488,7 @@
    1.38  	check_for_spaced_quotes(aline);
    1.39  	check_for_miscased_genative(aline);
    1.40  	check_end_of_line(aline,warnings);
    1.41 -        /*
    1.42 -	 * Brackets are often unspaced, but shouldn't be surrounded by alpha.
    1.43 -         * If so, suspect a scanno like "a]most".
    1.44 -	 */
    1.45 -        llen=strlen(aline);
    1.46 -        for (i=1;i<llen-1;i++)
    1.47 -	{
    1.48 -	    /* for each bracket character in the line except 1st & last */
    1.49 -            if (strchr("{[()]}",aline[i]) && gcisalpha(aline[i-1]) &&
    1.50 -	      gcisalpha(aline[i+1]))
    1.51 -	    {
    1.52 -                if (pswit[ECHO_SWITCH])
    1.53 -		    printf("\n%s\n",aline);
    1.54 -                if (!pswit[OVERVIEW_SWITCH])
    1.55 -                    printf("    Line %ld column %d - Unspaced bracket?\n",
    1.56 -		      linecnt,i);
    1.57 -                else
    1.58 -                    cnt_punct++;
    1.59 -	    }
    1.60 -	}
    1.61 +	check_for_unspaced_bracket(aline);
    1.62          llen=strlen(aline);
    1.63          if (warnings->endquote)
    1.64  	{