This file is part of MXE. See LICENSE.md for licensing information. Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tony Theodore Date: Sat, 24 Feb 2018 15:54:48 +1100 Subject: [PATCH 1/2] fixes diff --git a/CMakeLists.txt b/CMakeLists.txt index 1111111..2222222 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,10 @@ endif (WIN32) # BUILD_SHARED_LIBS is cmake variable. Need to change default value. option(BUILD_SHARED_LIBS "Build shared library" ON) +if(NOT BUILD_SHARED_LIBS) + set(PC_CFLAGS "-DQJSON_STATIC") +endif() + OPTION(OSX_FRAMEWORK "Build a Mac OS X Framework") SET(FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/Library/Frameworks" CACHE PATH "Where to place qjson.framework if OSX_FRAMEWORK is selected") @@ -96,13 +100,13 @@ set(QJSON_LIB_VERSION_STRING "${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSI set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) # pkg-config -IF (NOT WIN32) +IF (MINGW OR NOT WIN32) CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/QJson.pc.in ${CMAKE_CURRENT_BINARY_DIR}/QJson${QJSON_SUFFIX}.pc @ONLY) INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/QJson${QJSON_SUFFIX}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -ENDIF (NOT WIN32) +ENDIF (MINGW OR NOT WIN32) # Subdirs ADD_SUBDIRECTORY(src) diff --git a/QJson.pc.in b/QJson.pc.in index 1111111..2222222 100644 --- a/QJson.pc.in +++ b/QJson.pc.in @@ -7,5 +7,5 @@ Name: QJson Description: QJson is a qt-based library that maps JSON data to QVariant objects Version: @QJSON_LIB_MAJOR_VERSION@.@QJSON_LIB_MINOR_VERSION@.@QJSON_LIB_PATCH_VERSION@ Requires: @PC_Requires@ -Libs: -L${libdir} -lqjson -Cflags: -I${includedir} \ No newline at end of file +Libs: -L${libdir} -lqjson@QJSON_SUFFIX@ +Cflags: -I${includedir} @PC_CFLAGS@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1111111..2222222 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,7 @@ INSTALL(TARGETS qjson${QJSON_SUFFIX} EXPORT qjson-export RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ARCHIVE DESTINATION ${LIB_INSTALL_DIR} FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} - PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/qjson${QJSON_SUFFIX} + PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}/qjson ) if(MSVC) From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Ivan Romanov Date: Fri, 27 Jul 2018 13:32:18 +0500 Subject: [PATCH 2/2] Fix numbers parsing This patch has been taken from: https://github.com/flavio/qjson/issues/48#ref-pullrequest-345139226 strtoll and strtoull may not reset errno for valid input. Need to check actual returned value as sayed in strtoll documentation. Fix #48 diff --git a/src/json_scanner.cc b/src/json_scanner.cc index 1111111..2222222 100644 --- a/src/json_scanner.cc +++ b/src/json_scanner.cc @@ -3393,8 +3393,9 @@ YY_RULE_SETUP #line 82 "json_scanner.yy" { m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoull(yytext, NULL, 10)); - if (errno == ERANGE) { + unsigned long long val = strtoull(yytext, NULL, 10); + *m_yylval = QVariant(val); + if (val == ULLONG_MAX && errno == ERANGE) { qCritical() << "Number is out of range: " << yytext; return yy::json_parser::token::INVALID; } @@ -3408,8 +3409,9 @@ YY_RULE_SETUP #line 93 "json_scanner.yy" { m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoll(yytext, NULL, 10)); - if (errno == ERANGE) { + long long val = strtoll(yytext, NULL, 10); + *m_yylval = QVariant(val); + if ((val == LLONG_MAX || val == LLONG_MIN) && errno == ERANGE) { qCritical() << "Number is out of range: " << yytext; return yy::json_parser::token::INVALID; } diff --git a/src/json_scanner.yy b/src/json_scanner.yy index 1111111..2222222 100644 --- a/src/json_scanner.yy +++ b/src/json_scanner.yy @@ -81,8 +81,9 @@ null { [0-9] | [1-9][0-9]+ { m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoull(yytext, NULL, 10)); - if (errno == ERANGE) { + unsigned long long val = strtoull(yytext, NULL, 10); + *m_yylval = QVariant(val); + if (val == ULLONG_MAX && errno == ERANGE) { qCritical() << "Number is out of range: " << yytext; return yy::json_parser::token::INVALID; } @@ -92,8 +93,9 @@ null { -[0-9] | -[1-9][0-9]+ { m_yylloc->columns(yyleng); - *m_yylval = QVariant(strtoll(yytext, NULL, 10)); - if (errno == ERANGE) { + long long val = strtoll(yytext, NULL, 10); + *m_yylval = QVariant(val); + if ((val == LLONG_MAX || val == LLONG_MIN) && errno == ERANGE) { qCritical() << "Number is out of range: " << yytext; return yy::json_parser::token::INVALID; }