integrated changes from main repository

This commit is contained in:
Guenter Obiltschnig 2006-12-27 15:16:22 +00:00
parent 13f73441e2
commit d9d531350d
9 changed files with 113 additions and 17 deletions

View File

@ -1,7 +1,7 @@
// //
// Format.h // Format.h
// //
// $Id: //poco/1.3/Foundation/include/Poco/Format.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Format.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@ -93,6 +93,7 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
/// * E signed floating-point value in the form [-]d.ddddE[<sign>]dd[d] /// * E signed floating-point value in the form [-]d.ddddE[<sign>]dd[d]
/// * f signed floating-point value in the form [-]dddd.dddd /// * f signed floating-point value in the form [-]dddd.dddd
/// * s std::string /// * s std::string
/// * z std::size_t
/// ///
/// The following flags are supported: /// The following flags are supported:
/// ///
@ -108,6 +109,7 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
/// * l argument is long (d, i), unsigned long (o, u, x, X) or long double (e, E, f, g, G) /// * l argument is long (d, i), unsigned long (o, u, x, X) or long double (e, E, f, g, G)
/// * L argument is long long (d, i), unsigned long long (o, u, x, X) /// * L argument is long long (d, i), unsigned long long (o, u, x, X)
/// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G) /// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G)
/// * * argument is any signed or unsigned integer (d, i, o, x, X)
/// ///
/// The width argument is a nonnegative decimal integer controlling the minimum number of characters printed. /// The width argument is a nonnegative decimal integer controlling the minimum number of characters printed.
/// If the number of characters in the output value is less than the specified width, blanks or /// If the number of characters in the output value is less than the specified width, blanks or

View File

@ -1,7 +1,7 @@
// //
// TaskNotification.h // TaskNotification.h
// //
// $Id: //poco/1.3/Foundation/include/Poco/TaskNotification.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/TaskNotification.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Tasks // Package: Tasks
@ -146,7 +146,7 @@ class TaskCustomNotification: public TaskNotification
/// mechanism between the task and its observer(s). /// mechanism between the task and its observer(s).
{ {
public: public:
TaskCustomNotification(Task* pTask, C& custom): TaskCustomNotification(Task* pTask, const C& custom):
TaskNotification(pTask), TaskNotification(pTask),
_custom(custom) _custom(custom)
{ {

View File

@ -1,7 +1,7 @@
// //
// Format.cpp // Format.cpp
// //
// $Id: //poco/1.3/Foundation/src/Format.cpp#1 $ // $Id: //poco/1.3/Foundation/src/Format.cpp#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@ -50,7 +50,8 @@
#include "Poco/Format.h" #include "Poco/Format.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <sstream> #include <sstream>
#include <ctype.h> #include <cctype>
#include <cstddef>
namespace Poco { namespace Poco {
@ -111,7 +112,8 @@ namespace
{ {
case 'l': case 'l':
case 'h': case 'h':
case 'L': mod = *itFmt++; break; case 'L':
case '*': mod = *itFmt++; break;
} }
} }
return mod; return mod;
@ -134,6 +136,33 @@ namespace
} }
void writeAnyInt(std::ostream& str, const Any& any)
{
if (any.type() == typeid(char))
str << static_cast<int>(AnyCast<char>(any));
else if (any.type() == typeid(signed char))
str << static_cast<int>(AnyCast<signed char>(any));
else if (any.type() == typeid(unsigned char))
str << static_cast<unsigned>(AnyCast<unsigned char>(any));
else if (any.type() == typeid(short))
str << AnyCast<short>(any);
else if (any.type() == typeid(unsigned short))
str << AnyCast<unsigned short>(any);
else if (any.type() == typeid(int))
str << AnyCast<int>(any);
else if (any.type() == typeid(unsigned int))
str << AnyCast<unsigned int>(any);
else if (any.type() == typeid(long))
str << AnyCast<long>(any);
else if (any.type() == typeid(unsigned long))
str << AnyCast<unsigned long>(any);
else if (any.type() == typeid(Int64))
str << AnyCast<Int64>(any);
else if (any.type() == typeid(UInt64))
str << AnyCast<UInt64>(any);
}
void formatOne(std::string& result, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector<Any>::const_iterator& itVal) void formatOne(std::string& result, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector<Any>::const_iterator& itVal)
{ {
std::ostringstream str; std::ostringstream str;
@ -157,6 +186,7 @@ namespace
case 'l': str << AnyCast<long>(*itVal++); break; case 'l': str << AnyCast<long>(*itVal++); break;
case 'L': str << AnyCast<Int64>(*itVal++); break; case 'L': str << AnyCast<Int64>(*itVal++); break;
case 'h': str << AnyCast<short>(*itVal++); break; case 'h': str << AnyCast<short>(*itVal++); break;
case '*': writeAnyInt(str, *itVal++); break;
default: str << AnyCast<int>(*itVal++); break; default: str << AnyCast<int>(*itVal++); break;
} }
break; break;
@ -169,6 +199,7 @@ namespace
case 'l': str << AnyCast<unsigned long>(*itVal++); break; case 'l': str << AnyCast<unsigned long>(*itVal++); break;
case 'L': str << AnyCast<UInt64>(*itVal++); break; case 'L': str << AnyCast<UInt64>(*itVal++); break;
case 'h': str << AnyCast<unsigned short>(*itVal++); break; case 'h': str << AnyCast<unsigned short>(*itVal++); break;
case '*': writeAnyInt(str, *itVal++); break;
default: str << AnyCast<unsigned>(*itVal++); break; default: str << AnyCast<unsigned>(*itVal++); break;
} }
break; break;
@ -186,6 +217,11 @@ namespace
case 's': case 's':
str << RefAnyCast<std::string>(*itVal++); str << RefAnyCast<std::string>(*itVal++);
break; break;
case 'z':
str << AnyCast<std::size_t>(*itVal++);
break;
case 'I':
case 'D':
default: default:
str << type; str << type;
} }

View File

@ -1,7 +1,7 @@
// //
// PurgeStrategy.cpp // PurgeStrategy.cpp
// //
// $Id: //poco/1.3/Foundation/src/PurgeStrategy.cpp#1 $ // $Id: //poco/1.3/Foundation/src/PurgeStrategy.cpp#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging
@ -66,7 +66,7 @@ void PurgeStrategy::list(const std::string& path, std::vector<File>& files)
std::string baseName = p.getFileName(); std::string baseName = p.getFileName();
baseName.append("."); baseName.append(".");
DirectoryIterator it(Path::current()); DirectoryIterator it(parent);
DirectoryIterator end; DirectoryIterator end;
while (it != end) while (it != end)
{ {

View File

@ -1,7 +1,7 @@
// //
// FormatTest.cpp // FormatTest.cpp
// //
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.cpp#1 $ // $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.cpp#2 $
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// All rights reserved. // All rights reserved.
@ -208,7 +208,62 @@ void FormatTest::testInt()
catch (BadCastException&) catch (BadCastException&)
{ {
} }
}
void FormatTest::testAnyInt()
{
char c = 42;
std::string s(format("%*i", c));
assert (s == "42");
signed char sc = -42;
s = format("%*i", sc);
assert (s == "-42");
unsigned char uc = 65;
s = format("%*i", uc);
assert (s == "65");
short ss = -134;
s = format("%*i", ss);
assert (s == "-134");
unsigned short us = 200;
s = format("%*i", us);
assert (s == "200");
int i = -12345;
s = format("%*i", i);
assert (s == "-12345");
unsigned ui = 12345;
s = format("%*i", ui);
assert (s == "12345");
long l = -54321;
s = format("%*i", l);
assert (s == "-54321");
unsigned long ul = 54321;
s = format("%*i", ul);
assert (s == "54321");
Int64 i64 = -12345678;
s = format("%*i", i64);
assert (s == "-12345678");
UInt64 ui64 = 12345678;
s = format("%*i", ui64);
assert (s == "12345678");
ss = 0x42;
s = format("%*x", ss);
assert (s == "42");
ss = 042;
s = format("%*o", ss);
assert (s == "42");
} }
@ -301,6 +356,7 @@ CppUnit::Test* FormatTest::suite()
CppUnit_addTest(pSuite, FormatTest, testChar); CppUnit_addTest(pSuite, FormatTest, testChar);
CppUnit_addTest(pSuite, FormatTest, testInt); CppUnit_addTest(pSuite, FormatTest, testInt);
CppUnit_addTest(pSuite, FormatTest, testAnyInt);
CppUnit_addTest(pSuite, FormatTest, testFloatFix); CppUnit_addTest(pSuite, FormatTest, testFloatFix);
CppUnit_addTest(pSuite, FormatTest, testFloatSci); CppUnit_addTest(pSuite, FormatTest, testFloatSci);
CppUnit_addTest(pSuite, FormatTest, testString); CppUnit_addTest(pSuite, FormatTest, testString);

View File

@ -1,7 +1,7 @@
// //
// FormatTest.h // FormatTest.h
// //
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.h#1 $ // $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.h#2 $
// //
// Definition of the FormatTest class. // Definition of the FormatTest class.
// //
@ -61,6 +61,7 @@ public:
void testChar(); void testChar();
void testInt(); void testInt();
void testAnyInt();
void testFloatFix(); void testFloatFix();
void testFloatSci(); void testFloatSci();
void testString(); void testString();

View File

@ -1,7 +1,7 @@
// //
// HTTPRequest.cpp // HTTPRequest.cpp
// //
// $Id: //poco/1.3/Net/src/HTTPRequest.cpp#1 $ // $Id: //poco/1.3/Net/src/HTTPRequest.cpp#2 $
// //
// Library: Net // Library: Net
// Package: HTTP // Package: HTTP
@ -211,10 +211,10 @@ void HTTPRequest::read(std::istream& istr)
while (isspace(ch)) ch = istr.get(); while (isspace(ch)) ch = istr.get();
if (ch == eof) throw MessageException("No HTTP request header"); if (ch == eof) throw MessageException("No HTTP request header");
while (!isspace(ch) && ch != eof && method.length() < MAX_METHOD_LENGTH) { method += (char) ch; ch = istr.get(); } while (!isspace(ch) && ch != eof && method.length() < MAX_METHOD_LENGTH) { method += (char) ch; ch = istr.get(); }
if (!isspace(ch)) throw MessageException("HTTP request method too long"); if (!isspace(ch)) throw MessageException("HTTP request method invalid or too long");
while (isspace(ch)) ch = istr.get(); while (isspace(ch)) ch = istr.get();
while (!isspace(ch) && ch != eof && uri.length() < MAX_URI_LENGTH) { uri += (char) ch; ch = istr.get(); } while (!isspace(ch) && ch != eof && uri.length() < MAX_URI_LENGTH) { uri += (char) ch; ch = istr.get(); }
if (!isspace(ch)) throw MessageException("HTTP request URI too long"); if (!isspace(ch)) throw MessageException("HTTP request URI invalid or too long");
while (isspace(ch)) ch = istr.get(); while (isspace(ch)) ch = istr.get();
while (!isspace(ch) && ch != eof && version.length() < MAX_VERSION_LENGTH) { version += (char) ch; ch = istr.get(); } while (!isspace(ch) && ch != eof && version.length() < MAX_VERSION_LENGTH) { version += (char) ch; ch = istr.get(); }
if (!isspace(ch)) throw MessageException("Invalid HTTP version string"); if (!isspace(ch)) throw MessageException("Invalid HTTP version string");

View File

@ -1,7 +1,7 @@
// //
// HTTPServerSession.cpp // HTTPServerSession.cpp
// //
// $Id: //poco/1.3/Net/src/HTTPServerSession.cpp#1 $ // $Id: //poco/1.3/Net/src/HTTPServerSession.cpp#2 $
// //
// Library: Net // Library: Net
// Package: HTTPServer // Package: HTTPServer
@ -64,8 +64,9 @@ bool HTTPServerSession::hasMoreRequests()
--_maxKeepAliveRequests; --_maxKeepAliveRequests;
return socket().poll(getTimeout(), Socket::SELECT_READ); return socket().poll(getTimeout(), Socket::SELECT_READ);
} }
else if (_maxKeepAliveRequests > 0 && getKeepAlive()) else if (_maxKeepAliveRequests != 0 && getKeepAlive())
{ {
if (_maxKeepAliveRequests > 0)
--_maxKeepAliveRequests; --_maxKeepAliveRequests;
return socket().poll(_keepAliveTimeout, Socket::SELECT_READ); return socket().poll(_keepAliveTimeout, Socket::SELECT_READ);
} }

View File

@ -1 +1 @@
1.3-20061222 (2006-12-22) 1.3-20061227 (2006-12-27)