- CFLAGS="-O0 -g" QMAKEFLAGS="-config debug" PATH=/opt/qt56/bin:/usr/local/opt/qt5/bin:$PATH
install:
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
- sudo apt-add-repository -y ppa:beineri/opt-qt561;
+ sudo apt-add-repository -y ppa:beineri/opt-qt562;
sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test;
sudo apt-get update -qq;
sudo apt-get install -y qt56base valgrind g++-5;
endif
endif
-# json2cbor depends on an external library (cJSON)
+# json2cbor depends on an external library (cjson)
ifneq ($(cjson-pass)$(system-cjson-pass),)
JSON2CBOR_SOURCES = tools/json2cbor/json2cbor.c
INSTALL_TARGETS += $(bindir)/json2cbor
ifeq ($(system-cjson-pass),1)
- LDFLAGS_CJSON = -lcJSON
+ LDFLAGS_CJSON = -lcjson
else
JSON2CBOR_SOURCES += src/cjson/cJSON.c
json2cbor_CCFLAGS = -I$(SRCDIR)src/cjson
.config: Makefile.configure
$(MAKE) -f $(SRCDIR)Makefile.configure OUT='>&9' configure 9> $@
-lib bin:
- $(MKDIR) $@
-
-lib/libtinycbor.a: $(TINYCBOR_SOURCES:.c=.o) | lib
+lib/libtinycbor.a: $(TINYCBOR_SOURCES:.c=.o)
+ @$(MKDIR) -p lib
$(AR) cqs $@ $^
-bin/cbordump: $(CBORDUMP_SOURCES:.c=.o) lib/libtinycbor.a | bin
+bin/cbordump: $(CBORDUMP_SOURCES:.c=.o) lib/libtinycbor.a
+ @$(MKDIR) -p bin
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS) -lm
-bin/json2cbor: $(JSON2CBOR_SOURCES:.c=.o) lib/libtinycbor.a | bin
+bin/json2cbor: $(JSON2CBOR_SOURCES:.c=.o) lib/libtinycbor.a
+ @$(MKDIR) -p bin
$(CC) -o $@ $(LDFLAGS) $(LDFLAGS_CJSON) $^ $(LDLIBS) -lm
tinycbor.pc: tinycbor.pc.in
cd $${TMPDIR-/tmp}/tinycbor-distcheck && $(MAKE) silentcheck
$(RM) -r $${TMPDIR-/tmp}/tinycbor-distcheck
-release: .git
- $(MAKE) -f $(MAKEFILE) distcheck
-ifeq ($(VERSION),)
- git -C $(SRCDIR). show HEAD:VERSION | \
- perl -l -n -e '@_ = split /\./; print "$$_[0]." . ($$_[1] + 1)' > $(SRCDIR)VERSION
-else
- echo "$(VERSION)" > VERSION
-endif
- if test -n "`git diff VERSION`"; then \
- git -C $(SRCDIR). commit -s -m "Update version number" VERSION; \
- fi
- { echo "TinyCBOR release `cat $(SRCDIR)VERSION`"; \
- echo; \
- echo '# Write something nice about this release here'; \
- tmpl=`git -C $(SRCDIR). config --get commit.template` && \
- cat "$$tmpl"; \
- echo '# Commit log:'; \
- git -C $(SRCDIR). shortlog -e --no-merges HEAD --not `git -C $(SRCDIR). tag` | sed 's,^,# ,'; \
- echo '# Header diff:'; \
- git -C $(SRCDIR). diff HEAD --not `git -C $(SRCDIR). tag` -- 'src/*.h' ':!*_p.h' | sed 's,^,# ,'; \
- } > $(SRCDIR).git/TAG_EDITMSG
- @`git -C $(SRCDIR). var GIT_EDITOR` $(SRCDIR).git/TAG_EDITMSG
- git -C $(SRCDIR). tag -a -F $(SRCDIR).git/TAG_EDITMSG $(GITTAGFLAGS) v`cat $(SRCDIR)VERSION`
+tag: distcheck
+ @cd $(SRCDIR). && perl maketag.pl
.PHONY: all check silentcheck configure install uninstall
.PHONY: mostlyclean clean distclean
.SECONDARY:
cflags := $(CPPFLAGS) -I$(SRCDIR)src
-cflags += -DTINYCBOR_VERSION=\"$(VERSION)$(DIRTYSRC)\"
+cflags += -DTINYCBOR_VERSION_SUFFIX=\"$(DIRTYSRC)\"
cflags += -std=c99 $(CFLAGS)
%.o: %.c
@test -d $(@D) || $(MKDIR) $(@D)
CCFLAGS-gc_sections = -Wl,--gc-sections
PROGRAM-cjson = \#include <stdlib.h>\n
-PROGRAM-cjson += \#include <cJSON.h>\n
+PROGRAM-cjson += \#include <cjson/cJSON.h>\n
PROGRAM-cjson += int main() { return cJSON_False; }
CCFLAGS-cjson = -I$(dir $(MAKEFILE))src/cjson
PROGRAM-system-cjson = $(PROGRAM-cjson)
-CCFLAGS-system-cjson = -lcJSON
+CCFLAGS-system-cjson = -lcjson
sink:
@echo >&2 Please run from the top-level Makefile.
if exist tests\Makefile (cd tests & $(MAKE) clean)
distclean: clean
if exist tests\Makefile (cd tests & $(MAKE) distclean)
+tag:
+ @perl maketag.pl
{src\}.c{src\}.obj:
- $(CC) -nologo $(CFLAGS) -Isrc -DTINYCBOR_VERSION="" -c -Fo$@ $<
+ $(CC) -nologo $(CFLAGS) -Isrc -DTINYCBOR_VERSION_SUFFIX="" -c -Fo$@ $<
--- /dev/null
+#!perl
+use strict;
+sub run(@) {
+ open PROC, "-|", @_ or die("Cannot run $_[0]: $!");
+ my @out;
+ while (<PROC>) {
+ chomp;
+ push @out, $_;
+ }
+ close PROC;
+ return @out;
+}
+
+my @tags = run("git", "tag");
+my @v = run("git", "show", "HEAD:VERSION");
+my $v = $v[0];
+
+my $tagfile = ".git/TAG_EDITMSG";
+open TAGFILE, ">", $tagfile
+ or die("Cannot create file for editing tag message: $!");
+select TAGFILE;
+print "TinyCBOR release $v\n";
+print "\n";
+print "# Write something nice about this release here\n";
+
+# Do we have a commit template?
+my @result = run("git", "config", "--get", "commit.template");
+if (scalar @result) {
+ open TEMPLATE, "<", $result[0];
+ map { print $_; } <TEMPLATE>;
+ close TEMPLATE;
+}
+
+print "\n";
+print "# Commit log\n";
+open LOG, "-|", "git", "shortlog", "-e", "--no-merges", "--not", @tags;
+map { print "# $_"; } <LOG>;
+close LOG;
+
+print "# Header diff:\n";
+open DIFF, "-|", "git", "diff", "HEAD", "--not", @tags, "--", 'src/*.h', ':!*_p.h';
+map { print "# $_"; } <DIFF>;
+close DIFF;
+
+select STDOUT;
+close TAGFILE;
+
+# Run the editor.
+# We use system so that stdin, stdout and stderr are forwarded.
+@result = run("git", "var", "GIT_EDITOR");
+@result = ($result[0], $tagfile);
+system @result;
+exit ($? >> 8) if $?;
+
+# Create the tag
+# Also using system so that hte user can see the output.
+system("git", "tag", "-a", "-F", $tagfile, split(' ', $ENV{GITTAGFLAGS}), "v$v");
+exit ($? >> 8) if $?;
+
+# Update the version file for the next patch release
+@v = split(/\./, $v);
+if (scalar @v < 3) {
+ push @v, '1';
+} else {
+ ++$v[-1];
+}
+$v = join('.', @v);
+open VERSION, ">", "VERSION" or die("Cannot open VERSION file: $!");
+print VERSION "$v\n";
CborErrorJsonObjectKeyNotString,
CborErrorJsonNotImplemented,
- CborErrorOutOfMemory = ~0U / 2 + 1,
- CborErrorInternalError = ~0U
+ CborErrorOutOfMemory = (int) (~0U / 2 + 1),
+ CborErrorInternalError = (int) ~0U
} CborError;
CBOR_API const char *cbor_error_string(CborError error);
IndefiniteLength = 31U,
MajorTypeShift = SmallValueBitLength,
- MajorTypeMask = ~0U << MajorTypeShift,
+ MajorTypeMask = (int) (~0U << MajorTypeShift),
BreakByte = (unsigned)Break | (SimpleTypesType << MajorTypeShift)
};
return memcmp(s1, (const char *)s2, len) == 0;
}
+static uintptr_t iterate_memcpy(char *dest, const uint8_t *src, size_t len)
+{
+ return (uintptr_t)memcpy(dest, src, len);
+}
+
static CborError iterate_string_chunks(const CborValue *value, char *buffer, size_t *buflen,
bool *result, CborValue *next, IterateFunction func)
{
}
/* is there enough room for the ending NUL byte? */
- if (*result && *buflen > total)
- *result = !!func(buffer + total, (const uint8_t *)"", 1);
+ if (*result && *buflen > total) {
+ uint8_t nul[] = { 0 };
+ *result = !!func(buffer + total, nul, 1);
+ }
*buflen = total;
if (next) {
{
bool copied_all;
CborError err = iterate_string_chunks(value, (char*)buffer, buflen, &copied_all, next,
- buffer ? (IterateFunction)memcpy : iterate_noop);
+ buffer ? iterate_memcpy : iterate_noop);
return err ? err :
copied_all ? CborNoError : CborErrorOutOfMemory;
}
#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L || __cpp_static_assert >= 200410
# define cbor_static_assert(x) static_assert(x, #x)
-#elif !defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+#elif !defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && (__STDC_VERSION__ > 199901L)
# define cbor_static_assert(x) _Static_assert(x, #x)
#else
# define cbor_static_assert(x) ((void)sizeof(char[2*!!(x) - 1]))
#include "cbor.h"
#include "compilersupport_p.h"
-#include <cJSON.h>
+#include <cjson/cJSON.h>
#include <errno.h>
#include <math.h>