diff options
| author | Nat Goodspeed <nat@lindenlab.com> | 2022-12-06 16:30:35 -0500 | 
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2022-12-06 16:30:35 -0500 | 
| commit | 590e158cf36b6e6fca07f54837db084fe8a163c6 (patch) | |
| tree | 87cd47f925780ae9cf980d28dbbec40b38a8e420 /indra | |
| parent | 761d8337fb70cea9cfb326f06a8b1b35438ed96b (diff) | |
SL-18330: Adapt LLSDSerialize and tests to llssize max_bytes params.
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llcommon/llsdserialize.cpp | 2 | ||||
| -rw-r--r-- | indra/llcommon/tests/llsdserialize_test.cpp | 16 | 
2 files changed, 9 insertions, 9 deletions
| diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index 97bf51eeaa..c1b24d8138 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -128,7 +128,7 @@ bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, S32 max_bytes)  	 * specified buffer. In the usual case when max_bytes exceeds  	 * sizeof(hdr_buf), get() will read no more than sizeof(hdr_buf)-2.  	 */ -	str.get(hdr_buf, std::min(max_bytes+1, sizeof(hdr_buf)-1), '\n'); +	str.get(hdr_buf, llmin(max_bytes+1, sizeof(hdr_buf)-1), '\n');  	auto inbuf = str.gcount();  	// https://en.cppreference.com/w/cpp/io/basic_istream/get  	// When the get() above sees the specified delimiter '\n', it stops there diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index 6e5d8a26e1..29e3007aff 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -63,7 +63,7 @@ using namespace boost::phoenix;  #include <functional>  typedef std::function<void(const LLSD& data, std::ostream& str)> FormatterFunction; -typedef std::function<bool(std::istream& istr, LLSD& data, size_t max_bytes)> ParserFunction; +typedef std::function<bool(std::istream& istr, LLSD& data, llssize max_bytes)> ParserFunction;  std::vector<U8> string_to_vector(const std::string& str)  { @@ -263,7 +263,7 @@ namespace tut  			};  			// this lambda must be mutable since otherwise the bound 'parser'  			// is assumed to point to a const LLSDParser -			mParser = [parser](std::istream& istr, LLSD& data, size_t max_bytes) mutable +			mParser = [parser](std::istream& istr, LLSD& data, llssize max_bytes) mutable  			{  				// reset() call is needed since test code re-uses parser object  				parser->reset(); @@ -271,10 +271,10 @@ namespace tut  			};  		} -		void setParser(bool (*parser)(LLSD&, std::istream&, size_t)) +		void setParser(bool (*parser)(LLSD&, std::istream&, llssize))  		{  			// why does LLSDSerialize::deserialize() reverse the parse() params?? -			mParser = [parser](std::istream& istr, LLSD& data, size_t max_bytes) +			mParser = [parser](std::istream& istr, LLSD& data, llssize max_bytes)  			{  				return (parser(data, istr, max_bytes) > 0);  			}; @@ -2059,7 +2059,7 @@ namespace tut      // helper for test<8> - test<12>      void fromPythonUsing(const std::string& pyformatter,                           const ParserFunction& parse= -                         [](std::istream& istr, LLSD& data, size_t max_bytes) +                         [](std::istream& istr, LLSD& data, llssize max_bytes)                           { return LLSDSerialize::deserialize(data, istr, max_bytes); })      {          // Create an empty data file. This is just a placeholder for our @@ -2140,7 +2140,7 @@ namespace tut          set_test_name("from Python XML using fromXML()");          // fromXML()'s optional 3rd param isn't max_bytes, it's emit_errors          fromPythonUsing("format_xml", -                        [](std::istream& istr, LLSD& data, size_t) +                        [](std::istream& istr, LLSD& data, llssize)                          { return LLSDSerialize::fromXML(data, istr) > 0; });      } @@ -2149,7 +2149,7 @@ namespace tut      {          set_test_name("from Python notation using fromNotation()");          fromPythonUsing("format_notation", -                        [](std::istream& istr, LLSD& data, size_t max_bytes) +                        [](std::istream& istr, LLSD& data, llssize max_bytes)                          { return LLSDSerialize::fromNotation(data, istr, max_bytes) > 0; });      } @@ -2161,7 +2161,7 @@ namespace tut          // We don't expect this to work because format_binary() emits a          // header, but fromBinary() won't recognize a header.          fromPythonUsing("format_binary", -                        [](std::istream& istr, LLSD& data, size_t max_bytes) +                        [](std::istream& istr, LLSD& data, llssize max_bytes)                          { return LLSDSerialize::fromBinary(data, istr, max_bytes) > 0; });      }  |*==========================================================================*/ | 
