Break check_for_html_tag() out
authorali <ali@juiblex.co.uk>
Sun May 26 21:33:49 2013 +0100 (2013-05-26)
changeset 630a4f8d73b27f
parent 62 d4a66d961a69
child 64 a83ca5ff8511
Break check_for_html_tag() out
bookloupe/bookloupe.c
     1.1 --- a/bookloupe/bookloupe.c	Sun May 26 21:27:50 2013 +0100
     1.2 +++ b/bookloupe/bookloupe.c	Sun May 26 21:33:49 2013 +0100
     1.3 @@ -2267,6 +2267,41 @@
     1.4  }
     1.5  
     1.6  /*
     1.7 + * check_for_html_tag:
     1.8 + *
     1.9 + * Check for <HTML TAG>.
    1.10 + *
    1.11 + * If there is a < in the line, followed at some point
    1.12 + * by a > then we suspect HTML.
    1.13 + */
    1.14 +void check_for_html_tag(const char *aline)
    1.15 +{
    1.16 +    int i;
    1.17 +    const char *open,*close;
    1.18 +    open=strstr(aline,"<");
    1.19 +    if (open)
    1.20 +    {
    1.21 +	close=strstr(aline,">");
    1.22 +	if (close)
    1.23 +	{
    1.24 +	    i=(signed int)(close-open+1);
    1.25 +	    if (i>0)
    1.26 +	    {
    1.27 +		strncpy(wrk,open,i);
    1.28 +		wrk[i]=0;
    1.29 +		if (pswit[ECHO_SWITCH])
    1.30 +		    printf("\n%s\n",aline);
    1.31 +		if (!pswit[OVERVIEW_SWITCH])
    1.32 +		    printf("    Line %ld column %d - HTML Tag? %s \n",
    1.33 +		      linecnt,(int)(open-aline)+1,wrk);
    1.34 +		else
    1.35 +		    cnt_html++;
    1.36 +	    }
    1.37 +	}
    1.38 +    }
    1.39 +}
    1.40 +
    1.41 +/*
    1.42   * procfile:
    1.43   *
    1.44   * Process one file.
    1.45 @@ -2514,27 +2549,7 @@
    1.46  	check_for_unspaced_bracket(aline);
    1.47          if (warnings->endquote)
    1.48  	    check_for_unpunctuated_endquote(aline);
    1.49 -	/*
    1.50 -         * Check for <HTML TAG>.
    1.51 -         * If there is a < in the line, followed at some point
    1.52 -         * by a > then we suspect HTML.
    1.53 -	 */
    1.54 -        if (strstr(aline,"<") && strstr(aline,">"))
    1.55 -	{
    1.56 -            i=(signed int)(strstr(aline,">")-strstr(aline,"<")+1);
    1.57 -            if (i>0)
    1.58 -	    {
    1.59 -                strncpy(wrk,strstr(aline,"<"),i);
    1.60 -                wrk[i]=0;
    1.61 -                if (pswit[ECHO_SWITCH])
    1.62 -		    printf("\n%s\n",aline);
    1.63 -                if (!pswit[OVERVIEW_SWITCH])
    1.64 -                    printf("    Line %ld column %d - HTML Tag? %s \n",
    1.65 -		      linecnt,(int)(strstr(aline,"<")-aline)+1,wrk);
    1.66 -                else
    1.67 -                    cnt_html++;
    1.68 -	    }
    1.69 -	}
    1.70 +	check_for_html_tag(aline);
    1.71          /*
    1.72  	 * Check for &symbol; HTML.
    1.73           * If there is a & in the line, followed at