RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: popt rpm                         Date:   17-Jun-2016 10:07:28
  Branch: rpm-5_4 HEAD                     Handle: 2016061708072602

  Modified files:
    popt                    configure.ac
  Modified files:           (Branch: rpm-5_4)
    rpm                     CHANGES autogen.sh configure.ac
    rpm/build               Makefile.am
    rpm/lib                 Makefile.am
    rpm/m4                  .cvsignore
    rpm/misc                Makefile.am
    rpm/rpmdb               Makefile.am
    rpm/rpmio               Makefile.am bson.h librpmio.vers microjson.c
                            mongoc.h rpmdir.h rpmsq.c
    rpm/tools               rpmfind.c rpmmtree.c

  Log:
    - vs: stub in dll *.def generation.
    - cygwin: add portability fixes.
    - gnulib: add glob/fts modules.

  Summary:
    Revision    Changes     Path
    1.96        +5  -5      popt/configure.ac
    1.3501.2.491+3  -0      rpm/CHANGES
    2.110.2.13  +3  -1      rpm/autogen.sh
    2.80.2.10   +8  -0      rpm/build/Makefile.am
    2.472.2.146 +6  -6      rpm/configure.ac
    2.203.2.16  +8  -0      rpm/lib/Makefile.am
    1.1.8.2     +34 -0      rpm/m4/.cvsignore
    1.56.2.14   +8  -0      rpm/misc/Makefile.am
    1.134.2.33  +8  -0      rpm/rpmdb/Makefile.am
    1.293.2.70  +14 -2      rpm/rpmio/Makefile.am
    2.3.4.16    +1  -0      rpm/rpmio/bson.h
    2.199.2.55  +2  -0      rpm/rpmio/librpmio.vers
    1.1.2.3     +699 -46    rpm/rpmio/microjson.c
    1.1.2.11    +1  -1      rpm/rpmio/mongoc.h
    2.4.4.2     +1  -1      rpm/rpmio/rpmdir.h
    1.42.6.9    +1  -1      rpm/rpmio/rpmsq.c
    2.15.2.9    +4  -4      rpm/tools/rpmfind.c
    2.17.2.8    +1  -1      rpm/tools/rpmmtree.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: popt/configure.ac
  ============================================================================
  $ cvs diff -u -r1.95 -r1.96 configure.ac
  --- popt/configure.ac 20 Apr 2016 09:59:35 -0000      1.95
  +++ popt/configure.ac 17 Jun 2016 08:07:27 -0000      1.96
  @@ -34,25 +34,25 @@
   AM_GNU_GETTEXT([external])
   AM_ICONV
   AM_MAINTAINER_MODE
  +
   # Libtool library interface versions 
   # Library code modified:                              REVISION++
   # Interfaces changed/added/removed:   CURRENT++       REVISION=0
   # Interfaces added:                             AGE++
   # Interfaces removed:                           AGE=0
  -AC_SUBST(LT_CURRENT, 0)
  +AC_SUBST(LT_CURRENT, 8)
   AC_SUBST(LT_REVISION, 0)
   AC_SUBST(LT_AGE, 8)
  +DLL_VERSION=$(expr $(LT_CURRENT) - $(LT_AGE))
  +AC_SUBST(DLL_VERSION)
   
  -
  -
  -AC_PROG_CC
   AC_PROG_CC_STDC
  +AC_PROG_CC
   AC_SYS_LARGEFILE
   AC_PROG_MAKE_SET
   AC_PROG_INSTALL
   AM_PROG_AR
   AC_PROG_LIBTOOL
  -AM_PROG_CC_C_O
   
   # Turn gcc warning
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.3501.2.490 -r1.3501.2.491 CHANGES
  --- rpm/CHANGES       17 Jun 2016 05:30:22 -0000      1.3501.2.490
  +++ rpm/CHANGES       17 Jun 2016 08:07:26 -0000      1.3501.2.491
  @@ -1,4 +1,7 @@
   5.4.17 -> 5.4.18:
  +    - jbj: vs: stub in dll *.def generation.
  +    - jbj: cygwin: add portability fixes.
  +    - jbj: gnulib: add glob/fts modules.
       - jbj: gnulib: stub in the AutoFU.
       - jbj: start rpm-5.4.18 development.
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/autogen.sh
  ============================================================================
  $ cvs diff -u -r2.110.2.12 -r2.110.2.13 autogen.sh
  --- rpm/autogen.sh    17 Jun 2016 05:30:22 -0000      2.110.2.12
  +++ rpm/autogen.sh    17 Jun 2016 08:07:26 -0000      2.110.2.13
  @@ -49,10 +49,13 @@
   base64
   fnmatch-gnu
   ffs
  +fts
   getcwd-lgpl
   getline
   getpass
  +glob
   hash
  +lib-msvc-compat
   mkdtemp
   mkstemp
   regex
  @@ -76,7 +79,6 @@
     case $dir in
     .gnulib)
       $gnulib_tool                    \
  -      --lgpl=2                      \
         --m4-base=m4                  \
         --aux-dir=build-aux           \
         --source-base=gnulib          \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/Makefile.am
  ============================================================================
  $ cvs diff -u -r2.80.2.9 -r2.80.2.10 Makefile.am
  --- rpm/build/Makefile.am     15 Jun 2016 17:01:35 -0000      2.80.2.9
  +++ rpm/build/Makefile.am     17 Jun 2016 08:07:26 -0000      2.80.2.10
  @@ -5,6 +5,7 @@
   LINT = splint
   MCCABE = pmccabe
   
  +DISTCLEANFILES =
   CLEANFILES = *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
   EXTRA_DIST = librpmbuild.vers
   
  @@ -44,6 +45,13 @@
   if HAVE_LD_VERSION_SCRIPT
   librpmbuild_la_LDFLAGS += 
-Wl,@LD_VERSION_SCRIPT_FLAG@,@top_srcdir@/build/librpmbuild.vers
   endif
  +if HAVE_LD_OUTPUT_DEF
  +librpmbuild_la_LDFLAGS += -Wl,--output-def,librpmbuild-$(DLL_VERSION).def
  +defexecdir = $(bindir)
  +defexec_DATA = librpmbuild-$(DLL_VERSION).def
  +DISTCLEANFILES += $(defexec_DATA)
  +endif
  +
   librpmbuild_la_LIBADD =
   if ENABLE_BUILD_INTLIBDEP
   librpmbuild_la_LIBADD += \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/configure.ac
  ============================================================================
  $ cvs diff -u -r2.472.2.145 -r2.472.2.146 configure.ac
  --- rpm/configure.ac  17 Jun 2016 05:30:22 -0000      2.472.2.145
  +++ rpm/configure.ac  17 Jun 2016 08:07:26 -0000      2.472.2.146
  @@ -15,21 +15,19 @@
   AC_MSG_HEADER([INITIALIZATION])
   AC_CONFIG_SRCDIR([rpmqv.c])
   AC_CONFIG_HEADERS([config.h])
  -AC_CANONICAL_TARGET
   AC_CONFIG_MACRO_DIR([m4])
  -AC_CONFIG_AUX_DIR([build-aux])
   ACLOCAL_AMFLAGS = -I m4
  +AC_CONFIG_AUX_DIR([build-aux])
  +AC_CANONICAL_HOST
  +AC_CANONICAL_TARGET
   AM_INIT_AUTOMAKE([foreign tar-ustar subdir-objects color-tests])
   m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  +AM_MAINTAINER_MODE
   
   # --- libtool-2.4.6 uses "cru" with error msg
   #    /usr/bin/ar: `u' modifier ignored since `D' is the default (see `U')
   AC_SUBST([AR_FLAGS], [cr])
   
  -AC_REQUIRE_AUX_FILE([install-sh])
  -AC_REQUIRE_AUX_FILE([mkinstalldirs])
  -AM_MAINTAINER_MODE
  -
   dnl # allow packagers to override the officially branding name
   RPM_NAME="RPM"
   AC_ARG_WITH(name,
  @@ -54,6 +52,8 @@
   AC_SUBST(LT_CURRENT,  5)
   AC_SUBST(LT_REVISION, 4)
   AC_SUBST(LT_AGE,      0)
  +DLL_VERSION=$(expr $(LT_CURRENT) - $(LT_AGE))
  +AC_SUBST(DLL_VERSION)
   
   dnl # provide RPM exported version
   RPM_VERSION="0,0,_,0,0,_"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/Makefile.am
  ============================================================================
  $ cvs diff -u -r2.203.2.15 -r2.203.2.16 Makefile.am
  --- rpm/lib/Makefile.am       15 Jun 2016 17:01:35 -0000      2.203.2.15
  +++ rpm/lib/Makefile.am       17 Jun 2016 08:07:27 -0000      2.203.2.16
  @@ -44,6 +44,7 @@
        $(top_builddir)/build/librpmbuild.la \
        $(RPM_LDADD_COMMON)
   
  +DISTCLEANFILES =
   CLEANFILES = *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
   EXTRA_DIST = libsql.c librpm.vers
   
  @@ -104,6 +105,13 @@
   if HAVE_LD_VERSION_SCRIPT
   librpm_la_LDFLAGS += 
-Wl,@LD_VERSION_SCRIPT_FLAG@,@top_srcdir@/lib/librpm.vers
   endif
  +if HAVE_LD_OUTPUT_DEF
  +librpm_la_LDFLAGS += -Wl,--output-def,librpm-$(DLL_VERSION).def
  +defexecdir = $(bindir)
  +defexec_DATA = librpm-$(DLL_VERSION).def
  +DISTCLEANFILES += $(defexec_DATA)
  +endif
  +
   librpm_la_LIBADD =
   if ENABLE_BUILD_INTLIBDEP
   librpm_la_LIBADD += \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/m4/.cvsignore
  ============================================================================
  $ cvs diff -u -r1.1.8.1 -r1.1.8.2 .cvsignore
  --- rpm/m4/.cvsignore 17 Jun 2016 05:30:23 -0000      1.1.8.1
  +++ rpm/m4/.cvsignore 17 Jun 2016 08:07:27 -0000      1.1.8.2
  @@ -149,3 +149,37 @@
   progtest.m4
   uintmax_t.m4
   visibility.m4
  +closedir.m4
  +d-type.m4
  +dirent_h.m4
  +dirfd.m4
  +getlogin_r.m4
  +glob.m4
  +ld-output-def.m4
  +opendir.m4
  +readdir.m4
  +chdir-long.m4
  +close.m4
  +cycle-check.m4
  +d-ino.m4
  +dirent-safer.m4
  +dirname.m4
  +double-slash-root.m4
  +dup.m4
  +dup2.m4
  +error.m4
  +fchdir.m4
  +fcntl-safer.m4
  +fcntl.m4
  +fdopendir.m4
  +filenamecat.m4
  +flexmember.m4
  +fts.m4
  +getdtablesize.m4
  +i-ring.m4
  +memrchr.m4
  +mode_t.m4
  +open.m4
  +openat.m4
  +save-cwd.m4
  +unistd-safer.m4
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/misc/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.56.2.13 -r1.56.2.14 Makefile.am
  --- rpm/misc/Makefile.am      15 Jun 2016 17:01:35 -0000      1.56.2.13
  +++ rpm/misc/Makefile.am      17 Jun 2016 08:07:27 -0000      1.56.2.14
  @@ -6,6 +6,7 @@
        -I$(srcdir) \
        -I$(top_srcdir)
   
  +DISTCLEANFILES =
   CLEANFILES = *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
   EXTRA_DIST = librpmmisc.vers \
                        alloca.c \
  @@ -31,6 +32,13 @@
   if HAVE_LD_VERSION_SCRIPT
   librpmmisc_la_LDFLAGS += 
-Wl,@LD_VERSION_SCRIPT_FLAG@,@top_srcdir@/misc/librpmmisc.vers
   endif
  +if HAVE_LD_OUTPUT_DEF
  +librpmmisc_la_LDFLAGS += -Wl,--output-def,librpmmisc-$(DLL_VERSION).def
  +defexecdir = $(bindir)
  +defexec_DATA = librpmmisc-$(DLL_VERSION).def
  +DISTCLEANFILES += $(defexec_DATA)
  +endif
  +
   librpmmisc_la_LDFLAGS += \
        @WITH_DB_LDFLAGS@ \
        @WITH_FILE_LDFLAGS@ \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.134.2.32 -r1.134.2.33 Makefile.am
  --- rpm/rpmdb/Makefile.am     15 Jun 2016 17:01:35 -0000      1.134.2.32
  +++ rpm/rpmdb/Makefile.am     17 Jun 2016 08:07:27 -0000      1.134.2.33
  @@ -28,6 +28,7 @@
   
   AM_CFLAGS = $(OPENMP_CFLAGS)
   
  +DISTCLEANFILES =
   CLEANFILES = *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
   
   EXTRA_DIST = librpmdb.vers \
  @@ -112,6 +113,13 @@
   if HAVE_LD_VERSION_SCRIPT
   librpmdb_la_LDFLAGS += 
-Wl,@LD_VERSION_SCRIPT_FLAG@,@top_srcdir@/rpmdb/librpmdb.vers
   endif
  +if HAVE_LD_OUTPUT_DEF
  +librpmdb_la_LDFLAGS += -Wl,--output-def,librpmdb-$(DLL_VERSION).def
  +defexecdir = $(bindir)
  +defexec_DATA = librpmdb-$(DLL_VERSION).def
  +DISTCLEANFILES += $(defexec_DATA)
  +endif
  +
   librpmdb_la_LIBADD = $(DBLIBOBJS)
   if ENABLE_BUILD_INTLIBDEP
   librpmdb_la_LIBADD += \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.293.2.69 -r1.293.2.70 Makefile.am
  --- rpm/rpmio/Makefile.am     15 Jun 2016 17:01:36 -0000      1.293.2.69
  +++ rpm/rpmio/Makefile.am     17 Jun 2016 08:07:27 -0000      1.293.2.70
  @@ -7,6 +7,7 @@
   
   SUBDIRS = auto # tests
   
  +DISTCLEANFILES =
   CLEANFILES = *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
   
   EXTRA_DIST = librpmio.vers \
  @@ -20,7 +21,7 @@
   
   EXTRA_PROGRAMS = rpmcpio rpmdpkg rpmtar rpmz
   EXTRA_PROGRAMS += bdes thtml tinv tkey tmacro tpw
  -noinst_PROGRAMS = tjsmn duk
  +noinst_PROGRAMS = tjsmn duk tmqtt
   
   EXTRA_PROGRAMS += bsdiff bspatch pcrsed rpmborg rpmcurl \
        rpmgenbasedir rpmgenpkglist rpmgensrclist rpmgpg \
  @@ -137,7 +138,7 @@
        rpmficl.h rpmgc.h rpmgfs.h rpmgit.h rpmhash.h \
        rpmhkp.h rpmhook.h rpmio_internal.h rpmjni.h rpmjs.h rpmjsio.h \
        rpmkeyring.h \
  -     rpmku.h rpmltc.h rpmlua.h rpmmg.h rpmmrb.h rpmnix.h rpmnss.h \
  +     rpmku.h rpmltc.h rpmlua.h rpmmg.h rpmmqtt.h rpmmrb.h rpmnix.h rpmnss.h \
        rpmodbc.h rpmperl.h rpmpgp.h rpmpython.h rpmruby.h rpmsed.h rpmsm.h 
rpmsp.h \
        rpmsq.h rpmsql.h rpmsquirrel.h rpmssl.h rpmsvn.h rpmsw.h rpmsx.h 
rpmsyck.h \
        rpmtcl.h rpmtpm.h rpmurl.h rpmutil.h rpmuuid.h rpmxar.h rpmz.h rpmzq.h \
  @@ -205,6 +206,7 @@
        rpmlua.c \
        rpmmalloc.c \
        rpmmg.c \
  +     rpmmqtt.c \
        rpmmrb.c \
        rpmnss.c \
        rpmperl.c \
  @@ -241,6 +243,13 @@
   if HAVE_LD_VERSION_SCRIPT
   librpmio_la_LDFLAGS += 
-Wl,@LD_VERSION_SCRIPT_FLAG@,@top_srcdir@/rpmio/librpmio.vers
   endif
  +if HAVE_LD_OUTPUT_DEF
  +librpmio_la_LDFLAGS += -Wl,--output-def,librpmio-$(DLL_VERSION).def
  +defexecdir = $(bindir)
  +defexec_DATA = librpmio-$(DLL_VERSION).def
  +DISTCLEANFILES += $(defexec_DATA)
  +endif
  +
   # XXX FIXME: error: inlining failed in call to always_inline ‘__signbit’
   librpmio_la_LIBADD = duktape.o -lm
   if ENABLE_BUILD_INTLIBDEP
  @@ -621,6 +630,9 @@
   tjsmn_SOURCES = tjsmn.c
   tjsmn_LDADD = $(RPMIO_LDADD_COMMON)
   
  +tmqtt_SOURCES = tmqtt.c
  +tmqtt_LDADD = $(RPMIO_LDADD_COMMON)
  +
   github_SOURCES = tjson.c
   github_CFLAGS = -Wall -Werror -std=gnu99 -O2 -DJSMN_GITHUB
   github_LDADD = -lcurl
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/bson.h
  ============================================================================
  $ cvs diff -u -r2.3.4.15 -r2.3.4.16 bson.h
  --- rpm/rpmio/bson.h  12 Mar 2016 19:52:55 -0000      2.3.4.15
  +++ rpm/rpmio/bson.h  17 Jun 2016 08:07:27 -0000      2.3.4.16
  @@ -25,6 +25,7 @@
   #include <stdint.h>
   # include <inttypes.h>
   #include <stdio.h>
  +#include <stdarg.h>
   #include <string.h>
   #include <time.h>
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/librpmio.vers
  ============================================================================
  $ cvs diff -u -r2.199.2.54 -r2.199.2.55 librpmio.vers
  --- rpm/rpmio/librpmio.vers   12 Mar 2016 19:44:01 -0000      2.199.2.54
  +++ rpm/rpmio/librpmio.vers   17 Jun 2016 08:07:27 -0000      2.199.2.55
  @@ -630,6 +630,8 @@
       rpmmgNew;
       rpmmgFile;
       rpmmgBuffer;
  +    _rpmmqtt_debug;
  +    rpmmqttNew;
       _rpmmrb_debug;
       _rpmmrbI;
       _rpmmrbPool;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/microjson.c
  ============================================================================
  $ cvs diff -u -r1.1.2.2 -r1.1.2.3 microjson.c
  --- rpm/rpmio/microjson.c     13 Mar 2016 04:32:36 -0000      1.1.2.2
  +++ rpm/rpmio/microjson.c     17 Jun 2016 08:07:27 -0000      1.1.2.3
  @@ -1,4 +1,3 @@
  -***************************************************************************/
   /* The strptime prototype is not provided unless explicitly requested.
    * We also need to set the value high enough to signal inclusion of
    * newer features (like clock_gettime).  See the POSIX spec for more info:
  @@ -18,6 +17,15 @@
   
   #define      MICROJSON_DEBUG_ENABLE  1
   #define      MICROJSON_TIME_ENABLE   1
  +
  +typedef struct timeval  TSTAMP_t;
  +typedef struct timeval  TDIFF_t;
  +
  +typedef int32_t         FLOAT_t;
  +#define _FSCALE 10000.
  +#define _F2I(_x)        ((FLOAT_t) ((_x) * _FSCALE))
  +#define _I2F(_x)        ((float)   ((_x) / _FSCALE))
  +
   /*==============================================================*/
   /*
    * This file is Copyright (c) 2014 by Eric S. Raymond.
  @@ -35,6 +43,7 @@
              t_string, t_boolean, t_character,
              t_time,
              t_object, t_structobject, t_array,
  +           t_FLOAT, t_TSTAMP, t_TDIFF,
              t_check, t_ignore} 
       json_type;
   
  @@ -68,6 +77,12 @@
        struct {
            bool *store;
        } booleans;
  +     struct {
  +         FLOAT_t *store;
  +     } FLOATS;
  +     struct {
  +         TSTAMP_t *store;
  +     } TSTAMPS;
       } arr;
       int *count, maxlen;
   };
  @@ -76,12 +91,16 @@
       char *attribute;
       json_type type;
       union {
  +     void *pointer;
        int *integer;
        unsigned int *uinteger;
        double *real;
        char *string;
        bool *boolean;
        char *character;
  +     FLOAT_t *FLOAT;
  +     TSTAMP_t *TSTAMP;
  +     TDIFF_t *TDIFF;
        struct json_array_t array;
        size_t offset;
       } addr;
  @@ -91,6 +110,9 @@
        double real;
        bool boolean;
        char character;
  +     FLOAT_t FLOAT;
  +     TSTAMP_t TSTAMP;
  +     TDIFF_t TDIFF;
        char *check;
       } dflt;
       size_t len;
  @@ -108,6 +130,11 @@
                     /*@null@*/const char **);
   int json_read_array(const char *, const struct json_array_t *,
                    /*@null@*/const char **);
  +int json_spew_object(char *b, size_t nb, const struct json_attr_t *attrs,
  +                      /*@null@*/const char **end);
  +int json_spew_array(char *b, size_t nb, const struct json_array_t *arr,
  +                   const char **end);
  +
   const /*@observer@*/char *json_error_string(int);
   
   void json_enable_debug(int, FILE *);
  @@ -287,6 +314,15 @@
        case t_character:
            targetaddr = (char *)&cursor->addr.character[offset];
            break;
  +     case t_FLOAT:
  +         targetaddr = (char *)&cursor->addr.FLOAT[offset];
  +         break;
  +     case t_TSTAMP:
  +         targetaddr = (char *)&cursor->addr.TSTAMP[offset];
  +         break;
  +     case t_TDIFF:
  +         targetaddr = (char *)&cursor->addr.TDIFF[offset];
  +         break;
        default:
            targetaddr = NULL;
            break;
  @@ -349,6 +385,7 @@
       unsigned int u;
       const struct json_enum_t *mp;
       char *lptr;
  +    size_t len;
   
   #ifdef S_SPLINT_S
       /* prevents gripes about buffers not being completely defined */
  @@ -362,18 +399,22 @@
       /* stuff fields with defaults in case they're omitted in the JSON input 
*/
       for (cursor = attrs; cursor->attribute != NULL; cursor++)
        if (!cursor->nodefault) {
  +         size_t len;
            lptr = json_target_address(cursor, parent, offset);
            if (lptr != NULL)
                switch (cursor->type) {
                case t_integer:
  -                 memcpy(lptr, &cursor->dflt.integer, sizeof(int));
  +                 len = (cursor->len ? cursor->len : sizeof(int));
  +                 memcpy(lptr, &cursor->dflt.integer, len);
                    break;
                case t_uinteger:
  -                 memcpy(lptr, &cursor->dflt.uinteger, sizeof(unsigned int));
  +                 len = (cursor->len ? cursor->len : sizeof(unsigned int));
  +                 memcpy(lptr, &cursor->dflt.uinteger, len);
                    break;
                case t_time:
                case t_real:
  -                 memcpy(lptr, &cursor->dflt.real, sizeof(double));
  +                 len = (cursor->len ? cursor->len : sizeof(double));
  +                 memcpy(lptr, &cursor->dflt.real, len);
                    break;
                case t_string:
                    if (parent != NULL
  @@ -383,11 +424,24 @@
                    lptr[0] = '\0';
                    break;
                case t_boolean:
  -                 memcpy(lptr, &cursor->dflt.boolean, sizeof(bool));
  +                 len = (cursor->len ? cursor->len : sizeof(bool));
  +                 memcpy(lptr, &cursor->dflt.boolean, len);
                    break;
                case t_character:
                    lptr[0] = cursor->dflt.character;
                    break;
  +             case t_FLOAT:
  +                 len = sizeof(FLOAT_t);
  +                 memcpy(lptr, &cursor->dflt.FLOAT, len);
  +                 break;
  +             case t_TSTAMP:
  +                 len = sizeof(TSTAMP_t);
  +                 memcpy(lptr, &cursor->dflt.TSTAMP, len);
  +                 break;
  +             case t_TDIFF:
  +                 len = sizeof(TDIFF_t);
  +                 memcpy(lptr, &cursor->dflt.TDIFF, len);
  +                 break;
                case t_object:  /* silences a compiler warning */
                case t_structobject:
                case t_array:
  @@ -628,18 +682,67 @@
                (void)snprintf(valbuf, sizeof(valbuf), "%d", mp->value);
            }
            lptr = json_target_address(cursor, parent, offset);
  +         len = cursor->len;
            if (lptr != NULL)
                switch (cursor->type) {
                case t_integer:
                    {
  -                     int tmp = atoi(valbuf);
  -                     memcpy(lptr, &tmp, sizeof(int));
  +                     int64_t tmp = (int64_t) atoll(valbuf);
  +                     switch (len) {
  +                     default:
  +                     case 0:
  +                         *(int *)lptr = tmp;
  +                         break;
  +                     case sizeof(int64_t):
  +                         *(int64_t *)lptr = tmp;
  +                         break;
  +                     case sizeof(int32_t):
  +                         *(int32_t *)lptr = tmp;
  +                         break;
  +                     case sizeof(int16_t):
  +                         *(int16_t *)lptr = tmp;
  +                         break;
  +                     case sizeof(int8_t):
  +                         *(int8_t *)lptr = tmp;
  +                         break;
  +                     }
                    }
                    break;
                case t_uinteger:
                    {
  -                     unsigned int tmp = (unsigned int)atoi(valbuf);
  -                     memcpy(lptr, &tmp, sizeof(unsigned int));
  +                     uint64_t tmp = (uint64_t) atoll(valbuf);
  +                     switch (len) {
  +                     default:
  +                     case 0:
  +                         *(unsigned int *)lptr = tmp;
  +                         break;
  +                     case sizeof(uint64_t):
  +                         *(uint64_t *)lptr = tmp;
  +                         break;
  +                     case sizeof(uint32_t):
  +                         *(uint32_t *)lptr = tmp;
  +                         break;
  +                     case sizeof(uint16_t):
  +                         *(uint16_t *)lptr = tmp;
  +                         break;
  +                     case sizeof(uint8_t):
  +                         *(uint8_t *)lptr = tmp;
  +                         break;
  +                     }
  +                 }
  +                 break;
  +             case t_FLOAT:
  +                 {
  +                     double tmp = atof(valbuf);
  +                     *(FLOAT_t *)lptr = _F2I(tmp);
  +                 }
  +                 break;
  +             case t_TSTAMP:
  +             case t_TDIFF:
  +                 {
  +                     time_t tv_sec = iso8601_to_unix(valbuf);
  +                     struct timeval tv = {tv_sec, 0};
  +                     memcpy(lptr, &tv, sizeof(tv));
                    }
                    break;
                case t_time:
  @@ -653,7 +756,18 @@
                case t_real:
                    {
                        double tmp = atof(valbuf);
  -                     memcpy(lptr, &tmp, sizeof(double));
  +                     switch (len) {
  +                     default:
  +                     case 0:
  +                         *(double *)lptr = tmp;
  +                         break;
  +                     case sizeof(double):
  +                         *(double *)lptr = tmp;
  +                         break;
  +                     case sizeof(float):
  +                         *(float *)lptr = tmp;
  +                         break;
  +                     }
                    }
                    break;
                case t_string:
  @@ -722,6 +836,257 @@
       /*@ +nullstate +nullderef +mustfreefresh +nullpass +usedef @*/
   }
   
  +static char * json_escape_strncpy(char *t, const char *s, size_t nb)
  +{
  +    static char _hex[] = "0123456789ABCDEF";
  +    static char _raw[] = "\b\t\n\f\r\"\\";
  +    static char _sub[] = "btnfr\"\\";
  +    char *te = t;
  +    int c;
  +
  +    while ((c = (int) *s++) != (int) '\0') {
  +     const char * raw = strchr(_raw, c);
  +     if (raw) {
  +         if (nb <= 1)
  +             break;
  +         *te++ = '\\';
  +         nb--;
  +         c = _sub[raw - _raw];
  +     } else
  +     if (c < 32) {
  +         if (nb <= 6)
  +             break;
  +         nb -= 6;
  +         *te++ = '\\';
  +         *te++ = 'u';
  +         *te++ = '0';
  +         *te++ = '0';
  +         *te++ = _hex[ (c >> 4) & 0x0F ];
  +         *te++ = _hex[ (c     ) & 0x0F ];
  +         continue;
  +     }
  +     if (nb <= 1)
  +         break;
  +     *te++ = c;
  +     nb--;
  +    }
  +    *te = '\0';
  +    return t;
  +}
  +
  +static int json_internal_spew_object(char *b, size_t nb,
  +                                      const struct json_attr_t *attrs,
  +                                      /*@null@ */
  +                                      const struct json_array_t *parent,
  +                                      int offset,
  +                                      /*@null@ */ const char **end)
  +{
  +    char *be = b;
  +    const struct json_attr_t *cursor;
  +    int ix = 0;
  +    int rc = JSON_ERR_MISC;  /* assume failure */
  +
  +    if (nb > 1) {
  +     *be++ = '{';
  +     nb--;
  +    }
  +
  +    for (cursor = attrs; cursor->attribute != NULL; cursor++) {
  +     char *ep = NULL;
  +     size_t nf = 0;
  +     int substatus;
  +     const struct json_enum_t *mp;
  +     char * lptr;
  +     size_t len;
  +
  +     lptr = json_target_address(cursor, parent, offset);
  +     if (lptr == NULL && cursor->type != t_array)
  +         continue;
  +#ifdef       NOTYET
  +     if (cursor->dflt.check != NULL)
  +         continue;
  +#endif
  +
  +     if (ix++ && nb > 1) {
  +         *be++ = ',';
  +         nb--;
  +     }
  +     len = cursor->len;
  +     switch (cursor->type) {
  +     case t_integer:
  +     {   int64_t val;
  +         switch (len) {
  +         default:
  +         case 0:
  +             val = *(int *)lptr;
  +             break;
  +         case sizeof(int64_t):
  +             val = *(int64_t *)lptr;
  +             break;
  +         case sizeof(int32_t):
  +             val = *(int32_t *)lptr;
  +             break;
  +         case sizeof(int16_t):
  +             val = *(int16_t *)lptr;
  +             break;
  +         case sizeof(int8_t):
  +             val = *(int8_t *)lptr;
  +             break;
  +         }
  +         for (mp = cursor->map; mp != NULL && mp->name != NULL; mp++) {
  +             if (mp->value != val)
  +                 continue;
  +             ep = mp->name;
  +             break;
  +         }
  +         if (ep) {
  +             nf = snprintf(be, nb, "\"%s\":\"%s\"", cursor->attribute, ep);
  +         } else {
  +             nf = snprintf(be, nb, "\"%s\":%lld", cursor->attribute, (long 
long)val);
  +         }
  +     }   break;
  +     case t_uinteger:
  +     {   uint64_t val;
  +         switch (len) {
  +         default:
  +         case 0:
  +             val = *(unsigned *)lptr;
  +             break;
  +         case sizeof(uint64_t):
  +             val = *(uint64_t *)lptr;
  +             break;
  +         case sizeof(uint32_t):
  +             val = *(uint32_t *)lptr;
  +             break;
  +         case sizeof(uint16_t):
  +             val = *(uint16_t *)lptr;
  +             break;
  +         case sizeof(uint8_t):
  +             val = *(uint8_t *)lptr;
  +             break;
  +         }
  +         for (mp = cursor->map; mp != NULL && mp->name != NULL; mp++) {
  +             if (mp->value != (int)val)
  +                 continue;
  +             ep = mp->name;
  +             break;
  +         }
  +         if (ep) {
  +             nf = snprintf(be, nb, "\"%s\":\"%s\"", cursor->attribute, ep);
  +         } else {
  +             nf = snprintf(be, nb, "\"%s\":%llu", cursor->attribute, 
(unsigned long long)val);
  +         }
  +     }   break;
  +     case t_FLOAT:
  +     {   FLOAT_t val = *(FLOAT_t *)lptr;
  +         nf = snprintf(be, nb, "\"%s\":%g", cursor->attribute, _I2F(val));
  +     }   break;
  +     case t_TSTAMP:
  +     case t_TDIFF:
  +     {   struct timeval *tvp = (struct timeval *)lptr;
  +         static const char _fmt[] = "\"%Y-%m-%dT%H:%M:%S\"";
  +         struct tm tm;
  +         nf = snprintf(be, nb, "\"%s\":", cursor->attribute);
  +             be += nf;
  +             nb -= nf;
  +         nf = strftime(be, nb, _fmt, gmtime_r(&tvp->tv_sec, &tm));
  +     }   break;
  +     case t_time:
  +#ifdef MICROJSON_TIME_ENABLE
  +     {   double val = *(double *)lptr;
  +         static const char _fmt[] = "\"%Y-%m-%dT%H:%M:%S\"";
  +         struct timeval tv;
  +         struct tm tm;
  +         tv.tv_sec = val;
  +         nf = snprintf(be, nb, "\"%s\":", cursor->attribute);
  +             be += nf;
  +             nb -= nf;
  +         nf = strftime(be, nb, _fmt, gmtime_r(&tv.tv_sec, &tm));
  +     }   break;
  +#else
  +         /*@fallthrough@*/
  +#endif                               /* MICROJSON_TIME_ENABLE */
  +     case t_real:
  +     {   double val;
  +         switch (len) {
  +         default:
  +         case 0:
  +             val = *(double *)lptr;
  +             break;
  +         case sizeof(double):
  +             val = *(double *)lptr;
  +             break;
  +         case sizeof(float):
  +             val = *(float *)lptr;
  +             break;
  +         }
  +         nf = snprintf(be, nb, "\"%s\":%g", cursor->attribute, val);
  +     }   break;
  +     case t_string:
  +#ifdef       NOTYET
  +         if (parent != NULL
  +          && parent->element_type != t_structobject
  +          && offset > 0)
  +             return JSON_ERR_NOPARSTR;
  +         lptr[0] = '\0';
  +#endif
  +     {   char t[BUFSIZ];
  +         const char *val = json_escape_strncpy(t, lptr, sizeof(t));
  +         nf = snprintf(be, nb, "\"%s\":\"%s\"", cursor->attribute, val);
  +     }   break;
  +     case t_boolean:
  +     {   bool val = *(bool *)lptr;
  +         nf = snprintf(be, nb, "\"%s\":%s", cursor->attribute,
  +                     (val ? "true" : "false"));
  +     }   break;
  +     case t_character:
  +     {   const char val = *(const char *)lptr;
  +         nf = snprintf(be, nb, "\"%s\":\"%c\"", cursor->attribute, val);
  +     }   break;
  +     case t_object:
  +         break;
  +     case t_structobject:
  +         break;
  +     case t_array:
  +         nf = snprintf(be, nb, "\"%s\":", cursor->attribute);
  +             be += nf;
  +             nb -= nf;
  +         substatus = json_spew_array(be, nb, &cursor->addr.array, NULL);
  +         nf = strlen(be);
  +         if (substatus) {
  +             rc = substatus;
  +             goto exit;
  +         }
  +         break;
  +     case t_check:
  +         break;
  +     case t_ignore:
  +         break;
  +     }
  +
  +     be += nf;
  +     nb -= nf;
  +     if (ix > 1 && nf == 0) {
  +         /* back up over comma */
  +         ix--;
  +         be--;
  +         nb++;
  +     }
  +    }
  +
  +    if (nb > 1) {
  +     *be++ = '}';
  +     nb--;
  +    }
  +    rc = (nb ? 0 : JSON_ERR_SUBTOOLONG);
  +
  +exit:
  +    *be = '\0';
  +    if (end)
  +     *end = be;
  +    return rc;
  +}
  +
   int json_read_array(const char *cp, const struct json_array_t *arr,
                    const char **end)
   {
  @@ -805,6 +1170,35 @@
            else
                cp = ep;
            break;
  +     case t_FLOAT:
  +     {   double val = strtod(cp, &ep);
  +         arr->arr.FLOATS.store[offset] = _F2I(val);
  +         if (ep == cp)
  +             return JSON_ERR_BADNUM;
  +         else
  +             cp = ep;
  +     }   break;
  +     case t_TSTAMP:
  +     case t_TDIFF:
  +     {   double val;
  +         struct timeval tv;
  +         if (*cp != '"')
  +             return JSON_ERR_BADSTRING;
  +         else
  +             ++cp;
  +         val = iso8601_to_unix((char *)cp);
  +         tv.tv_sec = val;
  +         tv.tv_usec = 0;
  +         arr->arr.TSTAMPS.store[offset] = tv;
  +         if (val >= HUGE_VAL)
  +             return JSON_ERR_BADNUM;
  +         while (*cp && *cp != '"')
  +             cp++;
  +         if (*cp != '"')
  +             return JSON_ERR_BADSTRING;
  +         else
  +             ++cp; 
  +     }   break;
   #ifdef MICROJSON_TIME_ENABLE
        case t_time:
            if (*cp != '"')
  @@ -876,6 +1270,108 @@
       /*@+nullstate +onlytrans@*/
   }
   
  +int json_spew_array(char *b, size_t nb, const struct json_array_t *arr,
  +              const char **end)
  +{
  +    char *be = b;
  +    /*@-nullstate -onlytrans@ */
  +    int arrcount = 0;
  +    int rc = JSON_ERR_MISC;  /* assume failure */
  +
  +    if (end != NULL)
  +     *end = NULL;            /* well-defined value on parse failure */
  +
  +    if (nb > 1) {
  +     *be++ = '[';
  +     nb--;
  +    }
  +
  +    for (int offset = 0; offset < arr->maxlen; offset++) {
  +     const char *ep = NULL;
  +     size_t nf = 0;
  +     int substatus;
  +     if (offset && nb > 1) {
  +         if (--nb == 0)
  +             break;
  +         *be++ = ',';
  +     }
  +     switch (arr->element_type) {
  +     case t_string:
  +         nf = snprintf(be, nb, "\"%s\"", arr->arr.strings.ptrs[offset]);
  +         break;
  +     case t_object:
  +     case t_structobject:
  +         substatus =
  +             json_internal_spew_object(be, nb, arr->arr.objects.subtype,
  +                                     arr, offset, &ep);
  +         nf = strlen(be);    /* XXX (e - be) */
  +         if (substatus) {
  +             rc = substatus;
  +             goto exit;
  +         }
  +         break;
  +     case t_integer:
  +         nf = snprintf(be, nb, "%d", arr->arr.integers.store[offset]);
  +         break;
  +     case t_uinteger:
  +         nf = snprintf(be, nb, "%d", arr->arr.uintegers.store[offset]);
  +         break;
  +     case t_FLOAT:
  +         nf = snprintf(be, nb, "%g", _I2F(arr->arr.FLOATS.store[offset]));
  +         break;
  +     case t_TSTAMP:
  +     case t_TDIFF:
  +     {   static const char _fmt[] = "\"%Y-%m-%dT%H:%M:%S\"";
  +         struct timeval *tvp =
  +                     (struct timeval *)&arr->arr.TSTAMPS.store[offset];
  +         struct tm tm;
  +         nf = strftime(be, nb, _fmt, gmtime_r(&tvp->tv_sec, &tm));
  +     }   break;
  +     case t_time:
  +#ifdef MICROJSON_TIME_ENABLE
  +     {   static const char _fmt[] = "\"%Y-%m-%dT%H:%M:%S\"";
  +         struct timeval tv;
  +         struct tm tm;
  +         tv.tv_sec = arr->arr.reals.store[offset];
  +         nf = strftime(be, nb, _fmt, gmtime_r(&tv.tv_sec, &tm));
  +     }   break;
  +#else
  +         /*@fallthrough@*/
  +#endif                               /* MICROJSON_TIME_ENABLE */
  +     case t_real:
  +         nf = snprintf(be, nb, "%g", arr->arr.reals.store[offset]);
  +         break;
  +     case t_boolean:
  +         nf = snprintf(be, nb, "%s",
  +                     (arr->arr.booleans.store[offset] ? "true" : "false"));
  +         break;
  +     case t_character:
  +     case t_array:
  +     case t_check:
  +     case t_ignore:
  +         json_debug_trace((1, "Invalid array subtype.\n"));
  +         rc = JSON_ERR_SUBTYPE;
  +         goto exit;
  +     }
  +     be += nf;
  +     nb -= nf;
  +     arrcount++;
  +    }
  +
  +    if (nb > 1) {
  +     *be++ = ']';
  +     nb--;
  +    }
  +    rc = (nb ? 0 : JSON_ERR_SUBTOOLONG);
  +
  +exit:
  +    *be = '\0';
  +    if (end)
  +     *end = be;
  +    return rc;
  +    /*@+nullstate +onlytrans@ */
  +}
  +
   int json_read_object(const char *cp, const struct json_attr_t *attrs,
                     /*@null@*/ const char **end)
   {
  @@ -886,6 +1382,14 @@
       return st;
   }
   
  +int json_spew_object(char *b, size_t nb, const struct json_attr_t *attrs,
  +                    /*@null@*/const char **end)
  +{
  +    int st;
  +    st = json_internal_spew_object(b, nb, attrs, NULL, 0, end);
  +    return st;
  +}
  +
   RPM_GNUC_CONST
   const /*@observer@*/ char *json_error_string(int err)
   {
  @@ -1050,6 +1554,9 @@
   static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata,
                         /*@null@*/ const char **endptr)
   {
  +    char b[BUFSIZ];
  +    size_t nb = sizeof(b);
  +    int status;
       /*@ -fullinitblock @*/
       const struct json_attr_t json_attrs_1[] = {
        /* *INDENT-OFF* */
  @@ -1076,11 +1583,11 @@
                                 .dflt.real = NAN},
        {"epv",    t_real,    .addr.real = &gpsdata->fix.epv,
                                 .dflt.real = NAN},
  -     {"track",   t_real,   .addr.real = &gpsdata->fix.track,
  +     {"track",  t_real,    .addr.real = &gpsdata->fix.track,
                                 .dflt.real = NAN},
  -     {"speed",   t_real,   .addr.real = &gpsdata->fix.speed,
  +     {"speed",  t_real,    .addr.real = &gpsdata->fix.speed,
                                 .dflt.real = NAN},
  -     {"climb",   t_real,   .addr.real = &gpsdata->fix.climb,
  +     {"climb",  t_real,    .addr.real = &gpsdata->fix.climb,
                                 .dflt.real = NAN},
        {"epd",    t_real,    .addr.real = &gpsdata->fix.epd,
                                 .dflt.real = NAN},
  @@ -1095,12 +1602,19 @@
       };
       /*@ +fullinitblock @*/
   
  -    return json_read_object(buf, json_attrs_1, endptr);
  +    status = json_read_object(buf, json_attrs_1, endptr);
  +b[0] = '\0';
  +(void) json_spew_object(b, nb, json_attrs_1, NULL);
  +fprintf(stderr, "\t|%s|\n", buf);
  +fprintf(stderr, "\t|%s|\n", b);
  +    return status;
   }
   
   static int json_sky_read(const char *buf, struct gps_data_t *gpsdata,
                         /*@null@*/ const char **endptr)
   {
  +    char b[BUFSIZ];
  +    size_t nb = sizeof(b);
       bool usedflags[MAXCHANNELS];
       /*@ -fullinitblock @*/
       const struct json_attr_t json_attrs_2_1[] = {
  @@ -1148,6 +1662,10 @@
       }
   
       status = json_read_object(buf, json_attrs_2, endptr);
  +b[0] = '\0';
  +(void) json_spew_object(b, nb, json_attrs_2, NULL);
  +fprintf(stderr, "\t|%s|\n", buf);
  +fprintf(stderr, "\t|%s|\n", b);
       if (status != 0)
        return status;
   
  @@ -1169,6 +1687,8 @@
   static int json_devicelist_read(const char *buf, struct gps_data_t *gpsdata,
                                /*@null@*/ const char **endptr)
   {
  +    char b[BUFSIZ];
  +    size_t nb = sizeof(b);
       /*@ -fullinitblock @*/
       const struct json_attr_t json_attrs_subdevices[] = {
        /* *INDENT-OFF* */
  @@ -1210,6 +1730,10 @@
   
       memset(&gpsdata->devices, '\0', sizeof(gpsdata->devices));
       status = json_read_object(buf, json_attrs_devices, endptr);
  +b[0] = '\0';
  +(void) json_spew_object(b, nb, json_attrs_devices, NULL);
  +fprintf(stderr, "\t|%s|\n", buf);
  +fprintf(stderr, "\t|%s|\n", b);
       if (status != 0) {
        return status;
       }
  @@ -1220,6 +1744,8 @@
                     /*@out@*/ struct devconfig_t *dev,
                     /*@null@*/ const char **endptr)
   {
  +    char b[BUFSIZ];
  +    size_t nb = sizeof(b);
       char tbuf[JSON_DATE_MAX+1];
       /*@ -fullinitblock @*/
       /* *INDENT-OFF* */
  @@ -1256,6 +1782,10 @@
   
       tbuf[0] = '\0';
       status = json_read_object(buf, json_attrs_device, endptr);
  +b[0] = '\0';
  +(void) json_spew_object(b, nb, json_attrs_device, NULL);
  +fprintf(stderr, "\t|%s|\n", buf);
  +fprintf(stderr, "\t|%s|\n", b);
       if (status != 0)
        return status;
   
  @@ -1265,6 +1795,8 @@
   static int json_version_read(const char *buf, struct gps_data_t *gpsdata,
                             /*@null@*/ const char **endptr)
   {
  +    char b[BUFSIZ];
  +    size_t nb = sizeof(b);
       /*@ -fullinitblock @*/
       const struct json_attr_t json_attrs_version[] = {
        /* *INDENT-OFF* */
  @@ -1285,7 +1817,10 @@
   
       memset(&gpsdata->version, '\0', sizeof(gpsdata->version));
       status = json_read_object(buf, json_attrs_version, endptr);
  -
  +b[0] = '\0';
  +(void) json_spew_object(b, nb, json_attrs_version, NULL);
  +fprintf(stderr, "\t|%s|\n", buf);
  +fprintf(stderr, "\t|%s|\n", b);
       return status;
   }
   
  @@ -1317,6 +1852,7 @@
        return status;
       }
   #undef STARTSWITH
  +    return 0;
   }
   
   /*@+compdef@*/
  @@ -1394,22 +1930,22 @@
   
   /* *INDENT-OFF* */
   static const char json_str1[] = "{\"class\":\"TPV\",\
  -    \"device\":\"GPS#1\",                            \
  -    \"time\":\"2005-06-19T12:12:42.03Z\",            \
  -    \"lon\":46.498203637,\"lat\":7.568074350,           \
  -    
\"alt\":1327.780,\"epx\":21.000,\"epy\":23.000,\"epv\":124.484,\"mode\":3}";
  +\"device\":\"GPS#1\",\
  +\"time\":\"2005-06-19T12:12:42.03Z\",\
  +\"lon\":46.498203637,\"lat\":7.568074350,\
  +\"alt\":1327.780,\"epx\":21.000,\"epy\":23.000,\"epv\":124.484,\"mode\":3}";
   
   /* Case 2: SKY report */
   
   static const char *json_str2 = "{\"class\":\"SKY\",\
  -         \"satellites\":[\
  -         {\"PRN\":10,\"el\":45,\"az\":196,\"ss\":34,\"used\":true},\
  -         {\"PRN\":29,\"el\":67,\"az\":310,\"ss\":40,\"used\":true},\
  -         {\"PRN\":28,\"el\":59,\"az\":108,\"ss\":42,\"used\":true},\
  -         {\"PRN\":26,\"el\":51,\"az\":304,\"ss\":43,\"used\":true},\
  -         {\"PRN\":8,\"el\":44,\"az\":58,\"ss\":41,\"used\":true},\
  -         {\"PRN\":27,\"el\":16,\"az\":66,\"ss\":39,\"used\":true},\
  -         {\"PRN\":21,\"el\":10,\"az\":301,\"ss\":0,\"used\":false}]}";
  +\"satellites\":[\
  +{\"PRN\":10,\"el\":45,\"az\":196,\"ss\":34,\"used\":true},\
  +{\"PRN\":29,\"el\":67,\"az\":310,\"ss\":40,\"used\":true},\
  +{\"PRN\":28,\"el\":59,\"az\":108,\"ss\":42,\"used\":true},\
  +{\"PRN\":26,\"el\":51,\"az\":304,\"ss\":43,\"used\":true},\
  +{\"PRN\":8,\"el\":44,\"az\":58,\"ss\":41,\"used\":true},\
  +{\"PRN\":27,\"el\":16,\"az\":66,\"ss\":39,\"used\":true},\
  +{\"PRN\":21,\"el\":10,\"az\":301,\"ss\":0,\"used\":false}]}";
   
   /* Case 3: String list syntax */
   
  @@ -1451,18 +1987,18 @@
   /* Case 5: test DEVICE parsing */
   
   static const char *json_str5 = "{\"class\":\"DEVICE\",\
  -           \"path\":\"/dev/ttyUSB0\",\
  -           \"flags\":5,\
  -           \"driver\":\"Foonly\",\"subtype\":\"Foonly Frob\"\
  -           }";
  +\"path\":\"/dev/ttyUSB0\",\
  +\"flags\":5,\
  +\"driver\":\"Foonly\",\"subtype\":\"Foonly Frob\"\
  +}";
   
   /* Case 6: test parsing of subobject list into array of structures */
   
   static const char *json_str6 = "{\"parts\":[\
  -           {\"name\":\"Urgle\", \"flag\":true, \"count\":3},\
  -           {\"name\":\"Burgle\",\"flag\":false,\"count\":1},\
  -           {\"name\":\"Witter\",\"flag\":true, \"count\":4},\
  -           {\"name\":\"Thud\",  \"flag\":false,\"count\":1}]}";
  +{\"name\":\"Urgle\",\"flag\":true,\"count\":3},\
  +{\"name\":\"Burgle\",\"flag\":false,\"count\":1},\
  +{\"name\":\"Witter\",\"flag\":true,\"count\":4},\
  +{\"name\":\"Thud\",\"flag\":false,\"count\":1}]}";
   
   struct dumbstruct_t {
       char name[64];
  @@ -1487,7 +2023,7 @@
                          .addr.array.arr.objects.stride = sizeof(struct 
dumbstruct_t),
                          .addr.array.arr.objects.subtype = 
json_attrs_6_subtype,
                          .addr.array.count = &dumbcount,
  -                       .addr.array.maxlen = 
sizeof(dumbstruck)/sizeof(dumbstruck[0])},
  +                       .addr.array.maxlen = 
sizeof(dumbstruck)/sizeof(dumbstruck[0])-1},
       {NULL},
   };
   /*@+type@*/
  @@ -1495,8 +2031,8 @@
   /* Case 7: test parsing of version response */
   
   static const char *json_str7 = "{\"class\":\"VERSION\",\
  -           \"release\":\"2.40dev\",\"rev\":\"dummy-revision\",\
  -           \"proto_major\":3,\"proto_minor\":1}";
  +\"release\":\"2.40dev\",\"rev\":\"dummy-revision\",\
  +\"proto_major\":3,\"proto_minor\":1}";
   
   /* Case 8: test parsing arrays of enumerated types */
   
  @@ -1527,7 +2063,7 @@
       .element_type = t_integer,
       .arr.integers.store = intstore,
       .count = &intcount,
  -    .maxlen = sizeof(intstore)/sizeof(intstore[0]),
  +    .maxlen = sizeof(intstore)/sizeof(intstore[0])-1,
   };
   /*@+type@*/
   
  @@ -1542,7 +2078,7 @@
       .element_type = t_boolean,
       .arr.booleans.store = boolstore,
       .count = &boolcount,
  -    .maxlen = sizeof(boolstore)/sizeof(boolstore[0]),
  +    .maxlen = sizeof(boolstore)/sizeof(boolstore[0])-1,
   };
   /*@+type@*/
   
  @@ -1557,15 +2093,75 @@
       .element_type = t_real,
       .arr.reals.store = realstore,
       .count = &realcount,
  -    .maxlen = sizeof(realstore)/sizeof(realstore[0]),
  +    .maxlen = sizeof(realstore)/sizeof(realstore[0])-1,
   };
   /*@+type@*/
   
  +/* Case 13: Read struct of variable lenght scalars. */
  +
  +static const char *json_str13 =
  +"{\
  +\"d\":123,\
  +\"d64\":42,\
  +\"d32\":42,\
  +\"ui\":123,\
  +\"i\":-123,\
  +\"ui64\":42,\
  +\"i64\":-42,\
  +\"ui32\":42,\
  +\"i32\":-42,\
  +\"ui16\":42,\
  +\"i16\":-42,\
  +\"ui8\":42,\
  +\"i8\":-42,\
  +}";
  +
  +struct vstruct_t {
  +    double    d;
  +    double    d64;
  +    float     d32;
  +    unsigned ui;
  +    int       i;
  +    uint64_t ui64;
  +    int64_t   i64;
  +    uint32_t ui32;
  +    int32_t   i32;
  +    uint16_t ui16;
  +    int16_t   i16;
  +    uint8_t  ui8;
  +    int8_t    i8;
  +};
  +static struct vstruct_t vs;
  +
  +
  +/*@-type@*/
  +static const struct json_attr_t json_attrs_13[] = {
  +#define _ENTRY(_vN, _sN, _tN) \
  +     {#_sN, t_##_tN, .addr.pointer = &_vN._sN, .len = sizeof(_vN._sN)}
  +    {     "d",  t_real,      .addr.real = &vs.d },
  +    _ENTRY(vs,  d64, real ),
  +    _ENTRY(vs,  d32, real ),
  +    {    "ui",  t_uinteger,  .addr.uinteger = &vs.ui },
  +    {     "i",  t_integer,   .addr.integer = &vs.i },
  +    _ENTRY(vs, ui64, uinteger ),
  +    _ENTRY(vs,  i64, integer ),
  +    _ENTRY(vs, ui32, uinteger ),
  +    _ENTRY(vs,  i32, integer ),
  +    _ENTRY(vs, ui16, uinteger ),
  +    _ENTRY(vs,  i16, integer ),
  +    _ENTRY(vs, ui8,  uinteger ),
  +    _ENTRY(vs,  i8,  integer ),
  +    {NULL},
  +#undef       _ENTRY
  +};
  +
   /*@ +fullinitblock @*/
   /* *INDENT-ON* */
   
   static void jsontest(int i)
   {
  +    char b[BUFSIZ];
  +    size_t nb = sizeof(b);
       int status = 0;
   
       switch (i) 
  @@ -1605,6 +2201,10 @@
        assert(strcmp(stringptrs[0], "foo") == 0);
        assert(strcmp(stringptrs[1], "bar") == 0);
        assert(strcmp(stringptrs[2], "baz") == 0);
  +b[0] = '\0';
  +status = json_spew_array(b, nb, &json_array_3, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str3);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
       case 4:
  @@ -1615,6 +2215,10 @@
        assert_real("dftreal", dftreal, 23.17); /* did the default work? */
        assert_boolean("flag1", flag1, true);
        assert_boolean("flag2", flag2, false);
  +b[0] = '\0';
  +status = json_spew_object(b, nb, json_attrs_4, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str4);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
       case 5:
  @@ -1641,6 +2245,10 @@
        assert_integer("dumbstruck[1].count", dumbstruck[1].count, 1);
        assert_integer("dumbstruck[2].count", dumbstruck[2].count, 4);
        assert_integer("dumbstruck[3].count", dumbstruck[3].count, 1);
  +b[0] = '\0';
  +status = json_spew_object(b, nb, json_attrs_6, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str6);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
       case 7:
  @@ -1658,6 +2266,10 @@
        assert_integer("fee", fee, 3);
        assert_integer("fie", fie, 6);
        assert_integer("foe", foe, 14);
  +b[0] = '\0';
  +status = json_spew_object(b, nb, json_attrs_8, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str8);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
       case 9:
  @@ -1665,6 +2277,10 @@
        status = json_read_object(json_str9, json_attrs_6, NULL);
        assert_case(9, status);
        assert_integer("dumbcount", dumbcount, 0);
  +b[0] = '\0';
  +status = json_spew_object(b, nb, json_attrs_6, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str9);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
       case 10:
  @@ -1674,6 +2290,10 @@
        assert_integer("intstore[1]", intstore[1], -17);
        assert_integer("intstore[2]", intstore[2], 5);
        assert_integer("intstore[3]", intstore[3], 0);
  +b[0] = '\0';
  +status = json_spew_array(b, nb, &json_array_10, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str10);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
       case 11:
  @@ -1683,6 +2303,10 @@
        assert_boolean("boolstore[1]", boolstore[1], false);
        assert_boolean("boolstore[2]", boolstore[2], true);
        assert_boolean("boolstore[3]", boolstore[3], false);
  +b[0] = '\0';
  +status = json_spew_array(b, nb, &json_array_11, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str11);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
       case 12:
  @@ -1692,9 +2316,35 @@
        assert_real("realstore[1]", realstore[1], -17.2);
        assert_real("realstore[2]", realstore[2], 5.3);
        assert_real("realstore[3]", realstore[3], 0);
  +b[0] = '\0';
  +status = json_spew_array(b, nb, &json_array_12, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str12);
  +fprintf(stderr, "\t|%s|\n", b);
        break;
   
  -#define MAXTEST 12
  +    case 13:
  +     status = json_read_object(json_str13, json_attrs_13, NULL);
  +     assert_case(13, status);
  +     assert_real(     "d",   vs.d,    123.);
  +     assert_real(     "d64", vs.d64,  42.);
  +     assert_real(     "d32", vs.d32,  42.);
  +     assert_uinteger("ui",   vs.ui,   123);
  +     assert_integer(  "i",   vs.i,   -123);
  +     assert_uinteger("ui64", vs.ui64, 42);
  +     assert_uinteger( "i64", vs.i64, -42);
  +     assert_uinteger("ui32", vs.ui32, 42);
  +     assert_uinteger( "i32", vs.i32, -42);
  +     assert_uinteger("ui16", vs.ui16, 42);
  +     assert_uinteger( "i16", vs.i16, -42);
  +     assert_uinteger("ui8",  vs.ui8,  42);
  +     assert_uinteger( "i8",  vs.i8,  -42);
  +b[0] = '\0';
  +status = json_spew_object(b, nb, json_attrs_13, NULL);
  +fprintf(stderr, "\t|%s|\n", json_str13);
  +fprintf(stderr, "\t|%s|\n", b);
  +     break;
  +
  +#define MAXTEST 13
   
       default:
        (int)fputs("Unknown test number\n", stderr);
  @@ -1730,14 +2380,17 @@
        }
       }
   
  -    (void)fprintf(stderr, "microjson unit test ");
  +    (void)fprintf(stderr, "microjson unit test\n");
   
  -    if (individual)
  +    if (individual) {
  +fprintf(stderr, "======== test %d\n", individual);
        jsontest(individual);
  -    else {
  +    } else {
        int i;
  -     for (i = 1; i <= MAXTEST; i++)
  +     for (i = 1; i <= MAXTEST; i++) {
  +fprintf(stderr, "======== test %d\n", i);
            jsontest(i);
  +     }
       }
   
       (void)fprintf(stderr, "succeeded.\n");
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/mongoc.h
  ============================================================================
  $ cvs diff -u -r1.1.2.10 -r1.1.2.11 mongoc.h
  --- rpm/rpmio/mongoc.h        8 May 2016 18:47:27 -0000       1.1.2.10
  +++ rpm/rpmio/mongoc.h        17 Jun 2016 08:07:27 -0000      1.1.2.11
  @@ -2457,7 +2457,7 @@
      }
   
      return len;
  -#elif defined(__APPLE__) || defined(__sun)
  +#elif defined(__APPLE__) || defined(__sun) || defined(__CYGWIN__)
      int ncpu;
   
      ncpu = (int) sysconf (_SC_NPROCESSORS_ONLN);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmdir.h
  ============================================================================
  $ cvs diff -u -r2.4.4.1 -r2.4.4.2 rpmdir.h
  --- rpm/rpmio/rpmdir.h        24 Sep 2014 13:03:03 -0000      2.4.4.1
  +++ rpm/rpmio/rpmdir.h        17 Jun 2016 08:07:27 -0000      2.4.4.2
  @@ -21,7 +21,7 @@
   typedef struct __dirstream * AVDIR;
   typedef struct __dirstream * DAVDIR;
   #else
  -# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) 
|| defined(__OpenBSD__)
  +# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) 
|| defined(__OpenBSD__) || defined(__CYGWIN__)
   typedef struct __dirstream * AVDIR;
   typedef struct __dirstream * DAVDIR;
   #else        /* __FreeBSD__ */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmsq.c
  ============================================================================
  $ cvs diff -u -r1.42.6.8 -r1.42.6.9 rpmsq.c
  --- rpm/rpmio/rpmsq.c 5 May 2016 22:22:50 -0000       1.42.6.8
  +++ rpm/rpmio/rpmsq.c 17 Jun 2016 08:07:27 -0000      1.42.6.9
  @@ -59,7 +59,7 @@
   #define sigpause(sig) __RPM_sigpause(sig)
   #endif
   
  -#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__QNX__)
  +#if defined(__MINGW32__) || defined(__QNX__)
   struct qelem {
       struct qelem *q_forw;
       struct qelem *q_back;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/tools/rpmfind.c
  ============================================================================
  $ cvs diff -u -r2.15.2.8 -r2.15.2.9 rpmfind.c
  --- rpm/tools/rpmfind.c       7 May 2016 15:01:13 -0000       2.15.2.8
  +++ rpm/tools/rpmfind.c       17 Jun 2016 08:07:28 -0000      2.15.2.9
  @@ -197,7 +197,7 @@
   /*==============================================================*/
   
   /* XXX *BSD systems already have getmode(3) and setmode(3) */
  -#if defined(__linux__) || defined(__sun) || defined(__LCLINT__) || 
defined(__QNXNTO__)
  +#if defined(__linux__) || defined(__sun) || defined(__LCLINT__) || 
defined(__QNXNTO__) || defined(__CYGWIN__)
   #if !defined(HAVE_GETMODE) || !defined(HAVE_SETMODE)
   
   #define      SET_LEN 6               /* initial # of bitcmd struct to malloc 
*/
  @@ -1179,7 +1179,7 @@
        * and endchar points to the beginning of the string we know we have
        * a syntax error.
        */
  -#if defined(__sun)
  +#if defined(__sun) || defined(__CYGWIN__)
       value = strtoll(str, &endchar, 10);
   #else
       value = strtoq(str, &endchar, 10);
  @@ -1219,7 +1219,7 @@
        break;
       }
   
  -#if defined(__sun)
  +#if defined(__sun) || defined(__CYGWIN__)
       value = strtoll(str, &unit, 10);
   #else
       value = strtoq(str, &unit, 10);
  @@ -1257,7 +1257,7 @@
        str = unit + 1;
        if (*str == '\0')       /* EOS */
            break;
  -#if defined(__sun)
  +#if defined(__sun) || defined(__CYGWIN__)
        value = strtoll(str, &unit, 10);
   #else
        value = strtoq(str, &unit, 10);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/tools/rpmmtree.c
  ============================================================================
  $ cvs diff -u -r2.17.2.7 -r2.17.2.8 rpmmtree.c
  --- rpm/tools/rpmmtree.c      10 May 2016 17:06:18 -0000      2.17.2.7
  +++ rpm/tools/rpmmtree.c      17 Jun 2016 08:07:28 -0000      2.17.2.8
  @@ -986,7 +986,7 @@
   /*==============================================================*/
   
   /* XXX *BSD systems already have getmode(3) and setmode(3) */
  -#if defined(__linux__) || defined(__sun) || defined(__LCLINT__) || 
defined(__QNXNTO__)
  +#if defined(__linux__) || defined(__sun) || defined(__LCLINT__) || 
defined(__QNXNTO__) || defined(__CYGWIN__)
   #if !defined(HAVE_GETMODE) || !defined(HAVE_SETMODE)
   
   #define      SET_LEN 6               /* initial # of bitcmd struct to malloc 
*/
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to