Merge branch 'devel' of github.com:pocoproject/poco into devel

This commit is contained in:
Günter Obiltschnig 2023-01-16 13:51:44 +01:00
commit 0b19ffb628
7 changed files with 46 additions and 23 deletions

View File

@ -4,20 +4,37 @@
# Makefile fragment for finding MySQL library # Makefile fragment for finding MySQL library
# #
ifndef POCO_MYSQL_INCLUDE
ifeq (0, $(shell test -d /usr/local/include/mysql; echo $$?))
POCO_MYSQL_INCLUDE = /usr/local/include
else
ifeq (0, $(shell test -d /usr/local/opt/mysql-client/include; echo $$?))
POCO_MYSQL_INCLUDE = /usr/local/opt/mysql-client/include
else
ifeq (0, $(shell test -d /opt/homebrew/opt/mysql-client/include; echo $$?))
POCO_MYSQL_INCLUDE = /opt/homebrew/opt/mysql-client/include
endif
endif
endif
endif
# Note: linking order is important, do not change it. ifndef POCO_MYSQL_LIB
ifeq (0, $(shell test -d /usr/local/include/mysql; echo $$?))
POCO_MYSQL_LIB = /usr/local/lib
else
ifeq (0, $(shell test -d /usr/local/opt/mysql-client/lib; echo $$?))
POCO_MYSQL_LIB = /usr/local/opt/mysql-client/lib
else
ifeq (0, $(shell test -d /opt/homebrew/opt/mysql-client/lib; echo $$?))
POCO_MYSQL_LIB = /opt/homebrew/opt/mysql-client/lib
endif
endif
endif
endif
ifdef POCO_MYSQL_INCLUDE ifdef POCO_MYSQL_INCLUDE
INCLUDE += -I$(POCO_MYSQL_INCLUDE) INCLUDE += -I$(POCO_MYSQL_INCLUDE)
else
INCLUDE += -I./../include -I/usr/local/include/mysql -I/usr/include/mysql/ -I/usr/mysql/include/mysql -I/usr/local/mysql/include -I/usr/local/opt/mysql-client/include -I/usr/local/opt/mysql-client/include/mysql
endif endif
ifdef POCO_MYSQL_LIB ifdef POCO_MYSQL_LIB
SYSLIBS += -L$(POCO_MYSQL_LIB) SYSLIBS += -L$(POCO_MYSQL_LIB)
else
SYSLIBS += -L/usr/local/lib -L/usr/local/lib$(LIB64SUFFIX)/mysql -L/usr/lib$(LIB64SUFFIX)/mysql -L/usr/mysql/lib$(LIB64SUFFIX) -L/usr/mysql/lib$(LIB64SUFFIX)/mysql -L/usr/local/mysql/lib$(LIB64SUFFIX) -L/usr/local/opt/mysql-client/lib
endif endif
# Note: linking order is important, do not change it.
SYSLIBS += -lmysqlclient -lz -lpthread -ldl

View File

@ -18,8 +18,8 @@
#include "Poco/Data/MySQL/MySQLException.h" #include "Poco/Data/MySQL/MySQLException.h"
#include <mysql.h> #include "Poco/NumberFormatter.h"
#include <stdio.h> #include <mysql/mysql.h>
namespace Poco { namespace Poco {
@ -71,9 +71,7 @@ std::string ConnectionException::compose(const std::string& text, MYSQL* h)
str += mysql_error(h); str += mysql_error(h);
str += "\t[mysql_errno]: "; str += "\t[mysql_errno]: ";
char buff[30]; Poco::NumberFormatter::append(str, mysql_errno(h));
sprintf(buff, "%d", mysql_errno(h));
str += buff;
str += "\t[mysql_sqlstate]: "; str += "\t[mysql_sqlstate]: ";
str += mysql_sqlstate(h); str += mysql_sqlstate(h);
@ -125,9 +123,7 @@ std::string StatementException::compose(const std::string& text, MYSQL_STMT* h,
str += mysql_stmt_error(h); str += mysql_stmt_error(h);
str += "\t[mysql_stmt_errno]: "; str += "\t[mysql_stmt_errno]: ";
char buff[30]; Poco::NumberFormatter::append(str, mysql_stmt_errno(h));
sprintf(buff, "%d", mysql_stmt_errno(h));
str += buff;
str += "\t[mysql_stmt_sqlstate]: "; str += "\t[mysql_stmt_sqlstate]: ";
str += mysql_stmt_sqlstate(h); str += mysql_stmt_sqlstate(h);

View File

@ -20,6 +20,9 @@ endif
ifeq (0, $(shell test -e /usr/local/opt/libpq/include; echo $$?)) ifeq (0, $(shell test -e /usr/local/opt/libpq/include; echo $$?))
INCLUDE += -I/usr/local/opt/libpq/include INCLUDE += -I/usr/local/opt/libpq/include
endif endif
ifeq (0, $(shell test -e /opt/homebrew/opt/libpq/include; echo $$?))
INCLUDE += -I/opt/homebrew/opt/libpq/include
endif
endif endif
ifndef POCO_PGSQL_LIB ifndef POCO_PGSQL_LIB
@ -41,6 +44,9 @@ endif
ifeq (0, $(shell test -e /usr/local/opt/libpq/lib; echo $$?)) ifeq (0, $(shell test -e /usr/local/opt/libpq/lib; echo $$?))
SYSLIBS += -L/usr/local/opt/libpq/lib$(LIB64SUFFIX) SYSLIBS += -L/usr/local/opt/libpq/lib$(LIB64SUFFIX)
endif endif
ifeq (0, $(shell test -e /opt/homebrew/opt/libpq/lib; echo $$?))
SYSLIBS += -L/opt/homebrew/opt/libpq/lib$(LIB64SUFFIX)
endif
endif endif
SYSLIBS += -lpq SYSLIBS += -lpq

View File

@ -20,7 +20,7 @@
#include "Poco/Environment.h" #include "Poco/Environment.h"
#include "Poco/Version.h" #include "Poco/Version.h"
#include <cstdlib> #include <cstdlib>
#include <cstdio> // sprintf() #include <cstdio> // snprintf()
#if defined(POCO_VXWORKS) #if defined(POCO_VXWORKS)
@ -101,7 +101,7 @@ std::string Environment::nodeId()
NodeId id; NodeId id;
nodeId(id); nodeId(id);
char result[18]; char result[18];
std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x", std::snprintf(result, sizeof(result), "%02x:%02x:%02x:%02x:%02x:%02x",
id[0], id[0],
id[1], id[1],
id[2], id[2],

View File

@ -477,9 +477,9 @@ void NumberFormatter::append(std::string& str, const void* ptr)
{ {
char buffer[24]; char buffer[24];
#if defined(POCO_PTR_IS_64_BIT) #if defined(POCO_PTR_IS_64_BIT)
std::sprintf(buffer, "%016" PRIXPTR, (UIntPtr) ptr); std::snprintf(buffer, sizeof(buffer), "%016" PRIXPTR, (UIntPtr) ptr);
#else #else
std::sprintf(buffer, "%08" PRIXPTR, (UIntPtr) ptr); std::snprintf(buffer, sizeof(buffer), "%08" PRIXPTR, (UIntPtr) ptr);
#endif #endif
str.append(buffer); str.append(buffer);
} }

View File

@ -1238,7 +1238,7 @@ void formatStream(double value, std::string& str)
void formatSprintf(double value, std::string& str) void formatSprintf(double value, std::string& str)
{ {
char buffer[128]; char buffer[128];
std::sprintf(buffer, "%.*g", 16, value); std::snprintf(buffer, sizeof(buffer), "%.*g", 16, value);
str = buffer; str = buffer;
} }

View File

@ -11,11 +11,15 @@
# #
LINKMODE ?= SHARED LINKMODE ?= SHARED
ARCHFLAGS ?= -arch $(OSARCH) ARCHFLAGS ?= -arch $(POCO_HOST_OSARCH)
SANITIZEFLAGS ?= SANITIZEFLAGS ?=
OSFLAGS ?= -mmacosx-version-min=10.11 -isysroot $(shell xcrun --show-sdk-path) OSFLAGS ?= -mmacosx-version-min=10.11 -isysroot $(shell xcrun --show-sdk-path)
ifeq ($(POCO_HOST_OSARCH),arm64)
OPENSSL_DIR ?= /opt/homebrew/opt/openssl
else
OPENSSL_DIR ?= /usr/local/opt/openssl OPENSSL_DIR ?= /usr/local/opt/openssl
endif
# #
# Tools # Tools