Skip to content

Commit

Permalink
merge changes from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
obiltschnig committed Mar 23, 2024
1 parent 5de4e46 commit f8be52a
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 60 deletions.
6 changes: 6 additions & 0 deletions platform/Foundation/include/Poco/MemoryStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ class BasicMemoryStreamBuf: public std::basic_streambuf<ch, tr>
return newoff;
}

virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
{
const off_type off = pos;
return seekoff(off, std::ios::beg, which);
}

virtual int sync()
{
return 0;
Expand Down
8 changes: 8 additions & 0 deletions platform/Foundation/testsuite/src/MemoryStreamTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ void MemoryStreamTest::testInputSeek()
assertTrue (istr.good());
assertTrue (9 == istr.tellg());


istr.seekg(5);
assertTrue (istr.good());
assertTrue (5 == istr.tellg());
istr >> c;
assertTrue (c == '6');


{
Poco::MemoryInputStream istr2(buffer.begin(), buffer.size());
istr2.seekg(10, std::ios_base::beg);
Expand Down
9 changes: 9 additions & 0 deletions platform/Util/include/Poco/Util/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ class Util_API Timer: protected Poco::Runnable
};


//
// inlines
//
inline bool Timer::idle() const
{
return _queue.empty();
}


} } // namespace Poco::Util


Expand Down
5 changes: 3 additions & 2 deletions platform/XML/include/Poco/XML/expat.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Copyright (c) 2022 Thijs Schreijer <thijs@thijsschreijer.nl>
Copyright (c) 2023 Hanno Böck <hanno@gentoo.org>
Copyright (c) 2023 Sony Corporation / Snild Dolkow <snild@sony.com>
Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
Expand Down Expand Up @@ -1042,7 +1043,7 @@ typedef struct {
XMLPARSEAPI(const XML_Feature *)
XML_GetFeatureList(void);

#if XML_GE == 1
#if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1)
/* Added in Expat 2.4.0 for XML_DTD defined and
* added in Expat 2.6.0 for XML_GE == 1. */
XMLPARSEAPI(XML_Bool)
Expand All @@ -1065,7 +1066,7 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
*/
#define XML_MAJOR_VERSION 2
#define XML_MINOR_VERSION 6
#define XML_MICRO_VERSION 0
#define XML_MICRO_VERSION 2

#ifdef __cplusplus
}
Expand Down
17 changes: 12 additions & 5 deletions platform/XML/src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2016-2023 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016-2024 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2023 Sony Corporation / Snild Dolkow <snild@sony.com>
Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <snild@sony.com>
Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
Expand Down Expand Up @@ -155,14 +156,20 @@ extern "C" {
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);

#if XML_GE == 1
#if defined(XML_GE) && XML_GE == 1
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
const char *unsignedCharToPrintable(unsigned char c);
#endif

extern XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c
extern unsigned int g_parseAttempts; // used for testing only
extern
#if ! defined(XML_TESTING)
const
#endif
XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c
#if defined(XML_TESTING)
extern unsigned int g_bytesScanned; // used for testing only
#endif

#ifdef __cplusplus
}
Expand Down
30 changes: 21 additions & 9 deletions platform/XML/src/xmlparse.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* 628e24d4966bedbd4800f6ed128d06d29703765b4bce12d3b7f099f90f842fc9 (2.6.0+)
/* 2a14271ad4d35e82bde8ba210b4edb7998794bcbae54deab114046a300f9639a (2.6.2+)
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
Expand Down Expand Up @@ -38,7 +38,7 @@
Copyright (c) 2022 Jann Horn <jannh@google.com>
Copyright (c) 2022 Sean McBride <sean@rogue-research.com>
Copyright (c) 2023 Owain Davies <owaind@bath.edu>
Copyright (c) 2023 Sony Corporation / Snild Dolkow <snild@sony.com>
Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <snild@sony.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
Expand Down Expand Up @@ -217,7 +217,7 @@ typedef char ICHAR;
#endif

/* Round up n to be a multiple of sz, where sz is a power of 2. */
#define ROUND_UP(n, sz) (((n) + ((sz)-1)) & ~((sz)-1))
#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))

/* Do safe (NULL-aware) pointer arithmetic */
#define EXPAT_SAFE_PTR_DIFF(p, q) (((p) && (q)) ? ((p) - (q)) : 0)
Expand Down Expand Up @@ -255,7 +255,7 @@ static void copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key);
it odd, since odd numbers are always relative prime to a power of 2.
*/
#define SECOND_HASH(hash, mask, power) \
((((hash) & ~(mask)) >> ((power)-1)) & ((mask) >> 2))
((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2))
#define PROBE_STEP(hash, mask, power) \
((unsigned char)((SECOND_HASH(hash, mask, power)) | 1))

Expand Down Expand Up @@ -636,8 +636,14 @@ static unsigned long getDebugLevel(const char *variableName,
? 0 \
: ((*((pool)->ptr)++ = c), 1))

XML_Bool g_reparseDeferralEnabledDefault = XML_TRUE; // write ONLY in runtests.c
unsigned int g_parseAttempts = 0; // used for testing only
#if ! defined(XML_TESTING)
const
#endif
XML_Bool g_reparseDeferralEnabledDefault
= XML_TRUE; // write ONLY in runtests.c
#if defined(XML_TESTING)
unsigned int g_bytesScanned = 0; // used for testing only
#endif

struct XML_ParserStruct {
/* The first member must be m_userData so that the XML_GetUserData
Expand Down Expand Up @@ -1035,7 +1041,9 @@ callProcessor(XML_Parser parser, const char *start, const char *end,
return XML_ERROR_NONE;
}
}
g_parseAttempts += 1;
#if defined(XML_TESTING)
g_bytesScanned += (unsigned)have_now;
#endif
const enum XML_Error ret = parser->m_processor(parser, start, end, endPtr);
if (ret == XML_ERROR_NONE) {
// if we consumed nothing, remember what we had on this parse attempt.
Expand Down Expand Up @@ -6250,7 +6258,7 @@ storeEntityValue(XML_Parser parser, const ENCODING *enc,
dtd->keepProcessing = dtd->standalone;
goto endEntityValue;
}
if (entity->open) {
if (entity->open || (entity == parser->m_declEntity)) {
if (enc == parser->m_encoding)
parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_RECURSIVE_ENTITY_REF;
Expand Down Expand Up @@ -7797,14 +7805,18 @@ copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) {

static float
accountingGetCurrentAmplification(XML_Parser rootParser) {
// 1.........1.........12 => 22
const size_t lenOfShortestInclude = sizeof("<!ENTITY a SYSTEM 'b'>") - 1;
const XmlBigCount countBytesOutput
= rootParser->m_accounting.countBytesDirect
+ rootParser->m_accounting.countBytesIndirect;
const float amplificationFactor
= rootParser->m_accounting.countBytesDirect
? (countBytesOutput
/ (float)(rootParser->m_accounting.countBytesDirect))
: 1.0f;
: ((lenOfShortestInclude
+ rootParser->m_accounting.countBytesIndirect)
/ (float)lenOfShortestInclude);
assert(! rootParser->m_parentParser);
return amplificationFactor;
}
Expand Down
7 changes: 4 additions & 3 deletions protocols/Modbus/RTU/src/BundleActivator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class BundleActivator: public Poco::OSP::BundleActivator
{
}

void createModbusRTUMaster(const std::string& uid, Poco::SharedPtr<Poco::Serial::SerialPort> pSerialPort, Poco::Timespan timeout, Poco::Timespan frameTimeout, std::size_t maxAsyncQueueSize)
void createModbusRTUMaster(const std::string& uid, Poco::SharedPtr<Poco::Serial::SerialPort> pSerialPort, Poco::Timespan timeout, Poco::Timespan frameTimeout, std::size_t maxAsyncQueueSize, Poco::Timespan frameSpacing)
{
Poco::SharedPtr<ModbusMaster> pModbusMaster = new ModbusMasterImpl<RTUMasterPort>(new RTUMasterPort(pSerialPort, frameTimeout), timeout, maxAsyncQueueSize);
Poco::SharedPtr<ModbusMaster> pModbusMaster = new ModbusMasterImpl<RTUMasterPort>(new RTUMasterPort(pSerialPort, frameTimeout), timeout, maxAsyncQueueSize, frameSpacing);
std::string symbolicName = "io.macchina.modbus.rtu"s;
Poco::RemotingNG::Identifiable::ObjectId oid = symbolicName;
oid += '#';
Expand Down Expand Up @@ -88,6 +88,7 @@ class BundleActivator: public Poco::OSP::BundleActivator
const int speed = _pPrefs->configuration()->getInt(baseKey + ".speed", 9600);
const Poco::Timespan timeout = 1000*_pPrefs->configuration()->getInt(baseKey + ".timeout"s, 2000);
const Poco::Timespan frameTimeout = _pPrefs->configuration()->getInt(baseKey + ".frameTimeout"s, 10000);
const Poco::Timespan frameSpacing = _pPrefs->configuration()->getInt(baseKey + ".frameSpacing"s, 3000);
const std::size_t maxAsyncQueueSize = _pPrefs->configuration()->getUInt32(baseKey + ".maxAsyncQueueSize"s, 32);

try
Expand All @@ -113,7 +114,7 @@ class BundleActivator: public Poco::OSP::BundleActivator
pSerialPort->configureRS485(rs485Params);
}

createModbusRTUMaster(*it, pSerialPort, timeout, frameTimeout, maxAsyncQueueSize);
createModbusRTUMaster(*it, pSerialPort, timeout, frameTimeout, maxAsyncQueueSize, frameSpacing);
}
catch (Poco::Exception& exc)
{
Expand Down
Loading

0 comments on commit f8be52a

Please sign in to comment.