diff --git a/Makefile b/Makefile index 8ad3de2..dd54890 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ ifeq ($(MYSQL),YES) OPT_FILES += ucsqlite.o endif -example : libuc.a example.o +example : example.o libuc.a $(LINKXX) -o $@ $^ diff --git a/buffer_curl.cpp b/buffer_curl.cpp index 925ac59..43e79a8 100644 --- a/buffer_curl.cpp +++ b/buffer_curl.cpp @@ -9,8 +9,9 @@ /* Routines to use Buffers with curl. */ -#include #include "buffer.h" +#include +#include namespace JAD { diff --git a/ucontainer.cpp b/ucontainer.cpp index fbcd7f3..818797e 100644 --- a/ucontainer.cpp +++ b/ucontainer.cpp @@ -7,6 +7,8 @@ * http://www.greatpanic.com/code.html */ +#include +#include #include #include #include @@ -310,9 +312,19 @@ namespace JAD { if (type == uc_Map) ismap = true; else { errno = 0; - idx = strtol(piece1.c_str(),NULL,10); - if (errno) ismap = true; - else ismap = false; + char* ptr = NULL; + idx = strtol(piece1.c_str(), &ptr, 10); + if (errno == 0 && idx == 0) { + // This could have been a completely non-numeric string, or could have been a string representation of zero + // Find first non-whitespace char of piece1 + std::string::iterator it_first_nonspace = std::find_if(piece1.begin(), piece1.end(), std::not1(std::ptr_fun(std::isspace))); + // e.g. number of blank characters to skip + size_t chars_to_skip = it_first_nonspace - piece1.begin(); + + // If the start of the numeric string is the start of non-whitespace, there wasn't an array index at all (which means this is a map) + ismap = ptr == piece1.c_str() + chars_to_skip; + } else + ismap = false; } if (ismap) {