[cairo-commit] libsvg/src svg_parser.c,1.27,1.28

Carl Worth commit at pdx.freedesktop.org
Thu Apr 29 12:51:20 PDT 2004


Committed by: cworth

Update of /cvs/cairo/libsvg/src
In directory pdx:/tmp/cvs-serv21283/src

Modified Files:
	svg_parser.c 
Log Message:

        * src/svg_parser.c: Don't leave ignorableWhitespace NULL (which
        makes newer libxml2 croak).
        (_svg_parser_sax_characters): Do whitespace compaction ala
        xml:space=default.


Index: svg_parser.c
===================================================================
RCS file: /cvs/cairo/libsvg/src/svg_parser.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** a/svg_parser.c	26 Apr 2004 18:53:18 -0000	1.27
--- b/svg_parser.c	29 Apr 2004 19:51:17 -0000	1.28
***************
*** 87,91 ****
      NULL,				/* reference */
      _svg_parser_sax_characters,		/* characters */
!     NULL,				/* ignorableWhitespace */
      NULL,				/* processingInstruction */
      NULL,				/* comment */
--- 87,91 ----
      NULL,				/* reference */
      _svg_parser_sax_characters,		/* characters */
!     _svg_parser_sax_characters,		/* ignorableWhitespace */
      NULL,				/* processingInstruction */
      NULL,				/* comment */
***************
*** 93,97 ****
      _svg_parser_sax_error,		/* xmlParserError */
      _svg_parser_sax_fatal_error,	/* xmlParserFatalError */
!     NULL,			/* getParameterEntity */
  };
  
--- 93,97 ----
      _svg_parser_sax_error,		/* xmlParserError */
      _svg_parser_sax_fatal_error,	/* xmlParserFatalError */
!     NULL,				/* getParameterEntity */
  };
  
***************
*** 433,440 ****
  			    int			len)
  {
      svg_parser_t *parser = closure;
  
      if (parser->state->cb->parse_characters) {
! 	parser->status = (parser->state->cb->parse_characters) (parser, ch, len);
  	if (parser->status)
  	    return;
--- 433,469 ----
  			    int			len)
  {
+     int i;
      svg_parser_t *parser = closure;
+     const xmlChar *src;
+     xmlChar *ch_copy, *dst;
+     int space;
+ 
+     /* XXX: This is the correct default behavior, but we're supposed
+      * to honor xml:space="preserve" if present, (which just means to
+      * not do this replacement).
+      */
+     ch_copy = malloc (len);
+     if (ch_copy == NULL)
+ 	return;
+ 
+     dst = ch_copy;
+     space = 0;
+     for (src=ch, i=0; i < len; i++, src++) {
+ 	if (*src == '\n')
+ 	    continue;
+ 	if (*src == '\t' || *src == ' ') {
+ 	    if (space)
+ 		continue;
+ 	    *dst = ' ';
+ 	    space = 1;
+ 	} else {
+ 	    *dst = *src;
+ 	    space = 0;
+ 	}
+ 	dst++;
+     }
  
      if (parser->state->cb->parse_characters) {
! 	parser->status = (parser->state->cb->parse_characters) (parser, ch_copy, dst - ch_copy);
  	if (parser->status)
  	    return;





More information about the cairo-commit mailing list