From 6e425a9de8c003b5a733621a6b6730ec3cc902b8 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Sat, 23 Dec 2006 00:30:12 +0000 Subject: 20061220 --- appl/lib/xml.b | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'appl/lib/xml.b') diff --git a/appl/lib/xml.b b/appl/lib/xml.b index 5e10608d..f93cad8a 100644 --- a/appl/lib/xml.b +++ b/appl/lib/xml.b @@ -94,16 +94,22 @@ blankparser: Parser; open(srcfile: string, warning: chan of (Locator, string), preelem: string): (ref Parser, string) { - x := ref blankparser; - x.in = bufio->open(srcfile, Bufio->OREAD); - if (x.in == nil) + fd := bufio->open(srcfile, Bufio->OREAD); + if(fd == nil) return (nil, sys->sprint("cannot open %s: %r", srcfile)); - # ignore utf16 intialisation character (yuck) + return fopen(fd, srcfile, warning, preelem); +} + +fopen(fd: ref Bufio->Iobuf, name: string, warning: chan of (Locator, string), preelem: string): (ref Parser, string) +{ + x := ref blankparser; + x.in = fd; + # ignore utf16 initialisation character (yuck) c := x.in.getc(); if (c != 16rfffe && c != 16rfeff) x.in.ungetc(); x.estack = nil; - x.loc = Locator(1, srcfile, ""); + x.loc = Locator(1, name, ""); x.warning = warning; x.preelem = preelem; return (x, ""); @@ -235,9 +241,8 @@ getparcel(x: ref Parser): ref Parcel if (p == nil) p = ref Parcel.EOF; return p; - } - exception e{ - "sax:*" => + }exception e{ + "sax:*" => return ref Parcel.Error(x.loc, x.errormsg); } } -- cgit v1.2.3