From 7d0ba588fc98cc843bb23cdbe38a76da694abef6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 3 Jun 2010 14:10:44 +0000 Subject: [PATCH] 2010-06-03 Tatsuhiro Tsujikawa Fixed the bug that reading Metalink from pipe fails on older libxml2. It only accepts "-" as a special keyword to read stdin. * src/XML2SAXMetalinkProcessor.cc --- ChangeLog | 6 ++++++ src/XML2SAXMetalinkProcessor.cc | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f3b5091bf..865eb436c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-06-03 Tatsuhiro Tsujikawa + + Fixed the bug that reading Metalink from pipe fails on older + libxml2. It only accepts "-" as a special keyword to read stdin. + * src/XML2SAXMetalinkProcessor.cc + 2010-06-03 Tatsuhiro Tsujikawa Added log message when cookies are loaded. Added filename to log diff --git a/src/XML2SAXMetalinkProcessor.cc b/src/XML2SAXMetalinkProcessor.cc index 2cdd5e6a5..ce5c3359d 100644 --- a/src/XML2SAXMetalinkProcessor.cc +++ b/src/XML2SAXMetalinkProcessor.cc @@ -174,8 +174,17 @@ MetalinkProcessor::parseFile(const std::string& filename) { _stm.reset(new MetalinkParserStateMachine()); SharedHandle sessionData(new SessionData(_stm)); + // Old libxml2(at least 2.7.6, Ubuntu 10.04LTS) does not read stdin + // when "/dev/stdin" is passed as filename while 2.7.7 does. So we + // convert DEV_STDIN to "-" for compatibility. + std::string nfilename; + if(filename == DEV_STDIN) { + nfilename = "-"; + } else { + nfilename = filename; + } int retval = xmlSAXUserParseFile(&mySAXHandler, sessionData.get(), - filename.c_str()); + nfilename.c_str()); if(retval != 0) { throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK); }