Skip to content

Commit

Permalink
=zetjsoncpp 2.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jespa007 committed Nov 1, 2023
1 parent 5cc4d93 commit a843418
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 13 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@


----------------------------
Date: 1/11/2023
Version: 2.4.3

- [x] Fix compile on MAC

----------------------------
Date: 1/11/2023
Version: 2.4.2
Expand Down
10 changes: 9 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ cmake_minimum_required(VERSION 3.15)

project(zetjsoncpp)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
endif()

IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Release )
ENDIF()
Expand Down Expand Up @@ -96,8 +100,12 @@ if(MSVC)

else()

SET( CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS -std=gnu++0x -I -Wall -Wextra -pedantic -static-libstdc++ ")
SET( CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS -std=gnu++0x -I -Wall -Wextra -pedantic ")

if(NOT MACOSX)
SET( CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -static-libstdc++ ")
endif()

if (MINGW)
MESSAGE("-- Plataform: MINGW" )
else()
Expand Down
8 changes: 5 additions & 3 deletions src/deserialize_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
*/
#pragma once

#define ZJ_EXCEPTION_MAX_ERROR_MESSAGE 4096

namespace zetjsoncpp {

class deserialize_exception: public std::exception
{
std::string description;
int line;
std::string file;
char what_msg[4096];
char what_msg[ZJ_EXCEPTION_MAX_ERROR_MESSAGE];
public:

deserialize_exception(const char * _file, int _line, const std::string & _description){
Expand All @@ -22,9 +24,9 @@ namespace zetjsoncpp {

if(_file != NULL && *_file != 0){
file=_file;
sprintf(what_msg,"[file:%s line:%i] %s",_file, _line, (char *)description.c_str());
snprintf(what_msg,ZJ_EXCEPTION_MAX_ERROR_MESSAGE,"[file:%s line:%i] %s",_file, _line, (char *)description.c_str());
}else{
sprintf(what_msg,"[line:%i] %s",_line,(char *)description.c_str());
snprintf(what_msg,ZJ_EXCEPTION_MAX_ERROR_MESSAGE,"[line:%i] %s",_line,(char *)description.c_str());
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/jsonvar/ArrayBooleanJsonVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ namespace zetjsoncpp{
private:
void copy(const std::vector<bool> & v){
this->__zj_vector_data__.clear();
for(auto it=v.begin(); it != v.end();it++){
this->__zj_vector_data__.push_back(*it);
for(size_t i=0;i<v.size();i++){
bool b=v[i];
this->__zj_vector_data__.push_back(b);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/jsonvar/JsonVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace zetjsoncpp {
}

JsonVar *JsonVar::newJsonVar(const std::string & key){
ZJ_UNUSUED_PARAM(key);
throw std::runtime_error("internal error: newJsonVar not implemented");
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/string_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace zetjsoncpp{
char _sformat_buffer[ZJ_MAX_STR_BUFFER] = { 0 };
va_list ap;
va_start(ap, input_text);
vsprintf(_sformat_buffer, input_text, ap);
vsnprintf(_sformat_buffer, ZJ_MAX_STR_BUFFER, input_text, ap);
va_end(ap);

return std::string(_sformat_buffer);
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace zetjsoncpp{
std::string floatToString(float number){

char buff[100];
sprintf(buff, "%f",number);
snprintf(buff,100, "%f",number);
std::string ss = buff;
return ss;//return a string with the contents of the stream
}
Expand Down
2 changes: 1 addition & 1 deletion src/zetjsoncpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#define ZETJSONCPP_VERSION_MAJOR 2
#define ZETJSONCPP_VERSION_MINOR 4
#define ZETJSONCPP_VERSION_PATCH 2
#define ZETJSONCPP_VERSION_PATCH 3

#ifdef __MEMMANAGER__
#include "memmgr.h"
Expand Down
6 changes: 3 additions & 3 deletions src/zetjsoncpp_deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include "zetjsoncpp.h"

// Util to capture args by ...
#define ZJ_CAPTURE_VARIABLE_ARGS(text_out, text_in)\
#define ZJ_CAPTURE_VARIABLE_ARGS(text_out,text_out_length, text_in)\
{va_list ap;\
va_start(ap, text_in);\
vsprintf(text_out, text_in, ap);\
vsnprintf(text_out, text_out_length, text_in, ap);\
va_end(ap);}


Expand All @@ -24,7 +24,7 @@ namespace zetjsoncpp{
char where[1024]={0};
char text[ZJ_MAX_C_STRING]={0};
char temp_buff[1024]={0};
ZJ_CAPTURE_VARIABLE_ARGS(text, string_text);
ZJ_CAPTURE_VARIABLE_ARGS(text,ZJ_MAX_C_STRING,string_text);
char *aux=(char *)str_current-1;
char captured[100]={0};
std::string filename="";
Expand Down
4 changes: 3 additions & 1 deletion src/zetjsoncpp_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ namespace zetjsoncpp{
,_discard_non_serialized
);
break;
default:
break;
}

if (_minimized == false){
Expand All @@ -228,7 +230,7 @@ namespace zetjsoncpp{
_str_result += "}";

if (_minimized == false){
"\n";
_str_result += "\n";
}
}

Expand Down

0 comments on commit a843418

Please sign in to comment.