You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/02/18 21:33:11 UTC

cvs commit: xml-xalan/c/src/XPath XPathExpression.cpp

dbertoni    00/02/18 12:33:10

  Modified:    c/src/XPath XPathExpression.cpp
  Log:
  Changed code to use ostrstream instead of sprintf().
  
  Revision  Changes    Path
  1.2       +41 -44    xml-xalan/c/src/XPath/XPathExpression.cpp
  
  Index: XPathExpression.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathExpression.cpp	1999/12/18 19:47:55	1.1
  +++ XPathExpression.cpp	2000/02/18 20:33:10	1.2
  @@ -60,6 +60,7 @@
   
   
   #include <cstdio>
  +#include <strstream>
   
   
   
  @@ -101,20 +102,18 @@
   std::string
   XPathExpression::InvalidOpCodeException::FormatErrorMessage(int		theOpCode)
   {
  -	// $$$ ToDo: This can be changed to C++-style
  -	// formatting with a stringstream if we can
  -	// get the Microsoft library and the SGI STL to
  -	// coexist.
  -	char	theBuffer[256];
  -
  -	const char*		theMessage =
  -				"Invalid op code %d was detected.";
  -
  -	sprintf(theBuffer,
  -			theMessage,
  -			theOpCode);
  +#if !defined(XALAN_NO_NAMESPACES)
  +	using std::ostrstream;
  +#endif
  +
  +	ostrstream	theFormatter;
  +
  +	theFormatter << "Invalid op code "
  +				 << theOpCode
  +				 << " was detected."
  +				 << '\0';
   
  -	return theBuffer;
  +	return theFormatter.str();
   }
   
   
  @@ -141,24 +140,23 @@
   			int		theExpectedCount,
   			int		theSuppliedCount)
   {
  -	// $$$ ToDo: This can be changed to C++-style
  -	// formatting with a stringstream if we can
  -	// get the Microsoft library and the SGI STL to
  -	// coexist.
  -	char	theBuffer[256];
  -
  -	const char*		theMessage =
  -				"An invalid number of arguments for op code %d was detected. "
  -				"The required number of argument(s) is %d, but %d arguments(s) were "
  -				"supplied.";
  -
  -	sprintf(theBuffer,
  -			theMessage,
  -			theOpCode,
  -			theExpectedCount,
  -			theSuppliedCount);
  +#if !defined(XALAN_NO_NAMESPACES)
  +	using std::ostrstream;
  +#endif
  +
  +	ostrstream	theFormatter;
  +
  +	theFormatter << "An invalid number of arguments for op code "
  +				 << theOpCode
  +				 << " was detected.  "
  +				 << "The required number of arguments is "
  +				 << theExpectedCount
  +				 << ", but "
  +				 << theSuppliedCount
  +				 << " arguments(s) were supplied."
  +				 << '\0';
   
  -	return theBuffer;
  +	return theFormatter.str();
   }
   
   
  @@ -183,21 +181,20 @@
   				int		theOpCode,
   				int		theValue)
   {
  -	// $$$ ToDo: This can be changed to C++-style
  -	// formatting with a stringstream if we can
  -	// get the Microsoft library and the SGI STL to
  -	// coexist.
  -	char	theBuffer[256];
  -
  -	const char*		theMessage =
  -				"An invalid argument of %d was supplied for op code %d.";
  -
  -	sprintf(theBuffer,
  -			theMessage,
  -			theValue,
  -			theOpCode);
  +#if !defined(XALAN_NO_NAMESPACES)
  +	using std::ostrstream;
  +#endif
  +
  +	ostrstream	theFormatter;
  +
  +	theFormatter << "An invalid argument of "
  +				 << theValue
  +				 << " was supplied for op code "
  +				 << theOpCode
  +				 << "."
  +				 << '\0';
   
  -	return theBuffer;
  +	return theFormatter.str();
   }