2002-04-21 Joshua Sled <jsled@asynchronous.org>

* src/backend/file/sixtp.c (sixtp_parse_file): Explicitly create
	an xmlParserCtxt and keep it in the sixtp_sax_data, so we can...
	(sixtp_sax_start_handler): retain line/column numbers for stack
	frames, which pays off in...
	* src/backend/file/sixtp-stack.c (sixtp_stack_frame_print):
	printing the line/column numbers of parsing errors when they
	occur.
	* src/backend/file/sixtp.c (sixtp_parse_buffer): Analagous change
	for in-memory-buffer parsing.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6817 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled committed 2002-04-21 17:55:49 +00:00
1 parent 833d4042b4
commit 7e2051e60d
5 files changed
+36 -2

No files matched your search

+12
View File
@@ -1,3 +1,15 @@
2002-04-21 Joshua Sled <jsled@asynchronous.org>
* src/backend/file/sixtp.c (sixtp_parse_file): Explicitly create
an xmlParserCtxt and keep it in the sixtp_sax_data, so we can...
(sixtp_sax_start_handler): retain line/column numbers for stack
frames, which pays off in...
* src/backend/file/sixtp-stack.c (sixtp_stack_frame_print):
printing the line/column numbers of parsing errors when they
occur.
* src/backend/file/sixtp.c (sixtp_parse_buffer): Analagous change
for in-memory-buffer parsing.
2002-04-20 Joshua Sled <jsled@asynchronous.org>
* src/gnome/dialog-sxsincelast.c (process_auto_create_list): Added
+2
View File
@@ -53,6 +53,7 @@ sixtp_stack_frame_new(sixtp* next_parser, char *tag)
new_frame->data_for_children = NULL;
new_frame->data_from_children = NULL;
new_frame->frame_data = NULL;
new_frame->line = new_frame->col = -1;
return new_frame;
}
@@ -63,6 +64,7 @@ sixtp_stack_frame_print(sixtp_stack_frame *sf, gint indent, FILE *f)
gchar *is = g_strnfill(indent, ' ');
fprintf(f, "%s(stack-frame %p\n", is, sf);
fprintf(f, "%s (line %d) (col %d)\n", is, sf->line, sf->col );
fprintf(f, "%s (parser %p)\n", is, sf->parser);
fprintf(f, "%s (tag %s)\n", is, sf->tag ? sf->tag : "(null)");
fprintf(f, "%s (data-for-children %p)\n", is,
+4
View File
@@ -34,6 +34,10 @@ typedef struct sixtp_stack_frame {
gpointer data_for_children;
GSList *data_from_children; /* in reverse chronological order */
gpointer frame_data;
/* Line and column [of the start tag]; set during parsing. */
int line;
int col;
} sixtp_stack_frame;
struct _sixtp_parser_context_struct
+15 -2
View File
@@ -29,6 +29,9 @@
#include <stdarg.h>
#include <sys/types.h>
#include "libxml/SAX.h"
#include "libxml/parser.h"
#include "sixtp.h"
#include "sixtp-stack.h"
@@ -444,6 +447,9 @@ sixtp_sax_start_handler(void *user_data,
/* now allocate the new stack frame and shift to it */
new_frame = sixtp_stack_frame_new(next_parser, g_strdup(name));
new_frame->line = getLineNumber( pdata->saxParserCtxt );
new_frame->col = getColumnNumber( pdata->saxParserCtxt );
pdata->stack = g_slist_prepend(pdata->stack, (gpointer) new_frame);
@@ -700,7 +706,11 @@ sixtp_parse_file(sixtp *sixtp,
return FALSE;
}
xmlSAXUserParseFile(&ctxt->handler, &ctxt->data, filename);
ctxt->data.saxParserCtxt = xmlCreateFileParserCtxt( filename );
ctxt->data.saxParserCtxt->sax = &ctxt->handler;
ctxt->data.saxParserCtxt->userData = &ctxt->data;
xmlParseDocument( ctxt->data.saxParserCtxt );
//xmlSAXUserParseFile(&ctxt->handler, &ctxt->data, filename);
if(ctxt->data.parsing_ok)
{
@@ -736,7 +746,10 @@ sixtp_parse_buffer(sixtp *sixtp,
return FALSE;
}
xmlSAXUserParseMemory(&ctxt->handler, &ctxt->data, bufp, bufsz);
ctxt->data.saxParserCtxt = xmlCreateMemoryParserCtxt( bufp, bufsz );
ctxt->data.saxParserCtxt->sax = &ctxt->handler;
ctxt->data.saxParserCtxt->userData = &ctxt->data;
xmlParseDocument( ctxt->data.saxParserCtxt );
sixtp_context_run_end_handler(ctxt);
+3
View File
@@ -29,6 +29,8 @@
#include <stdarg.h>
#include "libxml/SAX.h"
#include "gnc-xml-helper.h"
typedef struct _sixtp_child_result sixtp_child_result;
@@ -150,6 +152,7 @@ typedef struct sixtp_sax_data {
gboolean parsing_ok;
GSList *stack;
gpointer global_data;
xmlParserCtxtPtr saxParserCtxt;
} sixtp_sax_data;