HTML comments




Patch below is a first attemt to implement
HTML-comments in gzilla.

	hack away,
-- 
---------------------------------------------
Göran Thyni, sysadm, JMS Bildbasen, Kiruna


------------------------ snip ---------------------------------------

*** gzillahtml.c	1997/11/27 17:51:46	1.1
--- gzillahtml.c	1997/11/27 19:31:45
***************
*** 1950,1955 ****
--- 1950,1957 ----
    return 0;
  }
  
+ static int in_comment = 0;
+ 
  static void gzilla_html_write (GzillaByteSink *bytesink,
  			       char *bytes,
  			       gint num) {
***************
*** 2001,2018 ****
    buf_index = 0;
    token_start = buf_index;
    while (buf_index < bufsize) {
 
  #ifdef VERBOSE
      g_print ("handling token %c%c%c\n", buf[buf_index], buf[buf_index + 1],
  	     buf[buf_index + 2]);
  #endif
! 
      /* invariant: buf_index == bufsize || token_start == buf_index */
  
!     if (isspace (buf[buf_index])
! 	&& (html->stack[html->num_states - 1].parse_mode
! 	    != GZILLA_HTML_PARSE_MODE_PRE))
!       {
        /* whitespace : consume all available whitespace */
        do {
  	buf_index++;
--- 2003,2027 ----
    buf_index = 0;
    token_start = buf_index;
    while (buf_index < bufsize) {

  #ifdef VERBOSE
      g_print ("handling token %c%c%c\n", buf[buf_index], buf[buf_index + 1],
  	     buf[buf_index + 2]);
  #endif
!     if (in_comment) {
!       if (!strncmp(buf + buf_index, "-->", 3)) {
! 	in_comment = 0;
! 	buf_index += 3;
! 	token_start = buf_index;
!       }
!       else
! 	buf_index++;
!     }
      /* invariant: buf_index == bufsize || token_start == buf_index */
  
!     else if (isspace (buf[buf_index])
! 	    && (html->stack[html->num_states - 1].parse_mode
! 		!= GZILLA_HTML_PARSE_MODE_PRE)) {
        /* whitespace : consume all available whitespace */
        do {
  	buf_index++;
***************
*** 2020,2025 ****
--- 2029,2037 ----
        gzilla_html_process_space (html, buf + token_start,
  			      buf_index - token_start);
        token_start = buf_index;
+     } else if (!strncmp(buf + buf_index, "<!--", 4)) {
+       in_comment = 1;
+       buf_index += 4;
      } else if (buf[buf_index] == '<') {
        /* a tag : search for close of tag (skipping over quoted strings) */
        buf_index++;
***************
*** 2059,2067 ****
        }
      }
    }
! 
!   /* put partial token in inbuf, if any. */
!   html->size_inbuf = bufsize - token_start;
    if (html->size_inbuf > 0) {
      if (html->size_inbuf_max < html->size_inbuf) {
        do {
--- 2071,2081 ----
        }
      }
    }
!   if (in_comment) { html->size_inbuf = 0; }
!   else {
!     /* put partial token in inbuf, if any. */
!     html->size_inbuf = bufsize - token_start;
!   }
    if (html->size_inbuf > 0) {
      if (html->size_inbuf_max < html->size_inbuf) {
        do {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]