Re: [xml] xmlIO enhancements?

On Tue, Apr 05, 2005 at 01:22:50PM -0400, Joel Reed wrote:
I'm reviewing xmlFileOpen_real and xmlGzfileOpen_real in xmlIO.c and have
two quick questions/possible improvements (i'll fire off a patch if no

1) xmlFileOpen_real does a

  if (!xmlCheckFilename(path)) return(NULL);

before the fopen(path, "r") call. This quick-out prevents library users
from ever seeing a message in their structure error handler like
"No such file or directory." By deleting this check, we can let fopen call
fail and set errno, then let normal libxml error handling bubble the
error back up to library users. Any reason why not to do this?

after poking around alot in xmlIO.c it seems like far too much 
work to report "No such file or directory" errors to the 
structured or generic error handlers - i'm pretty sure its not even
possible to do correctly without impacting the ABI, such that the 
existing places in libxml2 which rely on such errors not being
passed to the error handlers continue to work as-is while everyone
else can process such errors.

while i was in there i did look at the stat() call reduction,
as DV suggested. i've attached a patch that reduces the number of stat 
calls by 1 on platforms with HAVE_ERRNO_H. 

3) xmlGzfileOpen_real does not have anything like: 

    if (fd == NULL) xmlIOErr(0, path);

after the gzopen(path, "rb") call, unlike xmlFileOpen_real. this
minor inconsistency could be addressed easily enough. Any reason not to?

the 2nd hunk in the patch corrects xmlIO.c xmlGzfileOpen_real
to act like xmlFileOpen_real in reporting IO errors to the handles
on a NULL fd - EXCEPT when its due to ENOENT - a non existant file.


Attachment: stat-less-2.6.19.patch
Description: Text document

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