From 9c039dcd4af2e26b8fd879fb8e1f9f9877ca1fe0 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 3 Oct 2016 14:08:31 +0100 Subject: [PATCH] Be more specific about integer types, so that they work on both i386 and x86_64. --- configure.ac | 4 ++-- include/cgimap/xml_writer.hpp | 10 +++++----- src/xml_writer.cpp | 34 ++++++++++++---------------------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index fa3479622..54d24070a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_INIT([CGImap], - [0.5.0], + [0.5.1], [https://github.com/zerebubuth/openstreetmap-cgimap/issues], - [cgimap-0.5.0], + [cgimap-0.5.1], [https://github.com/zerebubuth/openstreetmap-cgimap]) AM_INIT_AUTOMAKE([subdir-objects parallel-tests]) LT_INIT diff --git a/include/cgimap/xml_writer.hpp b/include/cgimap/xml_writer.hpp index e1f75e16b..a0f42ddc4 100644 --- a/include/cgimap/xml_writer.hpp +++ b/include/cgimap/xml_writer.hpp @@ -6,6 +6,7 @@ #include #include "cgimap/output_buffer.hpp" #include "cgimap/output_writer.hpp" +#include /** * Writes UTF-8 output to a file or stdout. @@ -33,11 +34,10 @@ class xml_writer : public output_writer { // overloaded versions of writeAttribute for convenience void attribute(const std::string &name, double value); - void attribute(const std::string &name, int value); - void attribute(const std::string &name, unsigned long int value); - void attribute(const std::string &name, unsigned long long int value); - void attribute(const std::string &name, long int value); - void attribute(const std::string &name, long long int value); + void attribute(const std::string &name, int32_t value); + void attribute(const std::string &name, int64_t value); + void attribute(const std::string &name, uint32_t value); + void attribute(const std::string &name, uint64_t value); void attribute(const std::string &name, bool value); // write a child text element diff --git a/src/xml_writer.cpp b/src/xml_writer.cpp index 442dde7ad..b78809fed 100644 --- a/src/xml_writer.cpp +++ b/src/xml_writer.cpp @@ -122,45 +122,35 @@ void xml_writer::attribute(const std::string &name, double value) { } } -void xml_writer::attribute(const std::string &name, unsigned long int value) { +void xml_writer::attribute(const std::string &name, int32_t value) { int rc = xmlTextWriterWriteFormatAttribute( - pimpl->writer, BAD_CAST name.c_str(), "%lu", value); + pimpl->writer, BAD_CAST name.c_str(), "%" PRId32, value); if (rc < 0) { - throw write_error("cannot write osm_id_t(unsigned long int) attribute."); + throw write_error("cannot write int32_t attribute."); } } -void xml_writer::attribute(const std::string &name, - unsigned long long int value) { +void xml_writer::attribute(const std::string &name, int64_t value) { int rc = xmlTextWriterWriteFormatAttribute( - pimpl->writer, BAD_CAST name.c_str(), "%llu", value); + pimpl->writer, BAD_CAST name.c_str(), "%" PRId64, value); if (rc < 0) { - throw write_error("cannot write osm_id_t(unsigned long long int) attribute."); + throw write_error("cannot write int64_t attribute."); } } -void xml_writer::attribute(const std::string &name, long int value) { +void xml_writer::attribute(const std::string &name, uint32_t value) { int rc = xmlTextWriterWriteFormatAttribute( - pimpl->writer, BAD_CAST name.c_str(), "%ld", value); + pimpl->writer, BAD_CAST name.c_str(), "%" PRIu32, value); if (rc < 0) { - throw write_error("cannot write osm_id_t(long int) attribute."); + throw write_error("cannot write uint32_t attribute."); } } -void xml_writer::attribute(const std::string &name, - long long int value) { +void xml_writer::attribute(const std::string &name, uint64_t value) { int rc = xmlTextWriterWriteFormatAttribute( - pimpl->writer, BAD_CAST name.c_str(), "%lld", value); + pimpl->writer, BAD_CAST name.c_str(), "%" PRIu64, value); if (rc < 0) { - throw write_error("cannot write osm_id_t(long long int) attribute."); - } -} - -void xml_writer::attribute(const std::string &name, int value) { - int rc = xmlTextWriterWriteFormatAttribute( - pimpl->writer, BAD_CAST name.c_str(), "%d", value); - if (rc < 0) { - throw write_error("cannot write integer attribute."); + throw write_error("cannot write uint64_t attribute."); } }