git: 2326db40a1d2 - main - MFV: libucl: Update to 0.9.2

From: Muhammad Moinur Rahman <bofh_at_FreeBSD.org>
Date: Wed, 27 Aug 2025 18:37:27 UTC
The branch main has been updated by bofh:

URL: https://cgit.FreeBSD.org/src/commit/?id=2326db40a1d2dd98631d70aae200ca52575139fb

commit 2326db40a1d2dd98631d70aae200ca52575139fb
Merge: e0bc44b5898a 1e2f270469c6
Author:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2025-08-27 18:36:12 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2025-08-27 18:36:57 +0000

    MFV: libucl: Update to 0.9.2
    
    - Add FREEBSD-upgrade instructions
    - Add FREEBSD-Xlist file
    - Remove all unnecessary files which are not required for in-tree build
    
    Approved by: bapt
    Differential Revision:  https://reviews.freebsd.org/D50472
    Event: Oslo Hackathon 202508
    Sponsored by: The FreeBSD Foundation

 contrib/libucl/CMakeLists.txt                  | 314 -----------
 contrib/libucl/ChangeLog.md                    | 103 ----
 contrib/libucl/FREEBSD-Xlist                   |  40 ++
 contrib/libucl/FREEBSD-upgrade                 |  39 ++
 contrib/libucl/Makefile.am                     |  81 ---
 contrib/libucl/Makefile.unix                   |  89 ---
 contrib/libucl/Makefile.w32                    |  92 ---
 contrib/libucl/README.md                       | 418 --------------
 contrib/libucl/autogen.sh                      |   2 -
 contrib/libucl/configure.ac                    | 188 -------
 contrib/libucl/doc/Makefile.am                 |   9 -
 contrib/libucl/doc/api.md                      | 506 -----------------
 contrib/libucl/doc/lua_api.md                  | 196 -------
 contrib/libucl/doc/pandoc.template             |  12 -
 contrib/libucl/examples/ucl_cpp.cc             |  26 -
 contrib/libucl/haskell/hucl.hs                 | 123 ----
 contrib/libucl/include/ucl.h                   |   4 +-
 contrib/libucl/libucl.pc                       |  11 -
 contrib/libucl/libucl.pc.in                    |  11 -
 contrib/libucl/lua/Makefile.am                 |  26 -
 contrib/libucl/lua/libucl.rockspec.in          |  26 -
 contrib/libucl/lua/lua_ucl.c                   |  83 ++-
 contrib/libucl/m4/ax_lua.m4                    | 664 ----------------------
 contrib/libucl/m4/gcov.m4                      |  89 ---
 contrib/libucl/python/MANIFEST.in              |   5 -
 contrib/libucl/python/setup.py                 |  75 ---
 contrib/libucl/python/src/uclmodule.c          | 335 -----------
 contrib/libucl/python/tests/__init__.py        |   0
 contrib/libucl/python/tests/compat.py          |   8 -
 contrib/libucl/python/tests/test_dump.py       |  66 ---
 contrib/libucl/python/tests/test_example.py    |  59 --
 contrib/libucl/python/tests/test_load.py       | 122 ----
 contrib/libucl/python/tests/test_validation.py |  50 --
 contrib/libucl/python/ucl.pyi                  |  15 -
 contrib/libucl/src/Makefile.am                 |  30 -
 contrib/libucl/src/mum.h                       |   2 -
 contrib/libucl/src/ucl_emitter.c               |  80 ++-
 contrib/libucl/src/ucl_emitter_streamline.c    |   9 +-
 contrib/libucl/src/ucl_hash.c                  | 146 +++--
 contrib/libucl/src/ucl_msgpack.c               |   4 +-
 contrib/libucl/src/ucl_parser.c                | 214 +++++--
 contrib/libucl/src/ucl_schema.c                |   1 +
 contrib/libucl/src/ucl_util.c                  |  87 +--
 contrib/libucl/stamp-h.in                      |   1 -
 contrib/libucl/tests/.gitignore                |  10 +
 contrib/libucl/tests/Makefile.am               |  45 --
 contrib/libucl/tests/schema/definitions.json   |  32 --
 contrib/libucl/tests/schema/ref.json           |  16 -
 contrib/libucl/tests/schema/refRemote.json     |  76 ---
 contrib/libucl/tests/test_speed.c              |   2 +-
 contrib/libucl/tests/test_streamline.c         |  43 +-
 contrib/libucl/uthash/utlist.h                 | 749 ++++++++++++++++++-------
 contrib/libucl/utils/CMakeLists.txt            |  12 -
 contrib/libucl/utils/Makefile.am               |  23 -
 contrib/libucl/utils/chargen.c                 | 128 -----
 contrib/libucl/utils/objdump.c                 | 185 ------
 contrib/libucl/utils/ucl-tool.c                | 170 ------
 57 files changed, 1072 insertions(+), 4880 deletions(-)

diff --cc contrib/libucl/FREEBSD-Xlist
index 000000000000,000000000000..6d8cb4ff8f5b
new file mode 100644
--- /dev/null
+++ b/contrib/libucl/FREEBSD-Xlist
@@@ -1,0 -1,0 +1,40 @@@
++.github
++.gitignore
++CMakeLists.txt
++ChangeLog.md
++Makefile.am
++Makefile.unix
++Makefile.w32
++README.md
++autogen.sh
++configure.ac
++doc/Makefile.am
++doc/api.md
++doc/lua_api.md
++doc/pandoc.template
++examples/ucl_cpp.cc
++haskell/hucl.hs
++libucl.pc.in
++lua/Makefile.am
++lua/libucl.rockspec.in
++m4/.gitignore
++m4/ax_lua.m4
++m4/gcov.m4
++python/MANIFEST.in
++python/setup.py
++python/src/uclmodule.c
++python/tests/__init__.py
++python/tests/compat.py
++python/tests/test_dump.py
++python/tests/test_example.py
++python/tests/test_load.py
++python/tests/test_validation.py
++python/ucl.pyi
++src/Makefile.am
++stamp-h.in
++tests/Makefile.am
++utils/CMakeLists.txt
++utils/Makefile.am
++utils/chargen.c
++utils/objdump.c
++utils/ucl-tool.c
diff --cc contrib/libucl/FREEBSD-upgrade
index 000000000000,000000000000..b80736d7877b
new file mode 100644
--- /dev/null
+++ b/contrib/libucl/FREEBSD-upgrade
@@@ -1,0 -1,0 +1,39 @@@
++# FreeBSD libucl import instruction
++#
++# At least the following ports are required when importing libucl:
++# - devel/autoconf
++# - devel/automake
++# - devel/git
++# - devel/gmake
++# - devel/libtool
++#
++# 1. Vendor import
++#
++# $ git clone https://github.com/vstakhov/libucl.git /tmp/libucl
++# $ cd /tmp/libucl
++# $ git checkout <REF_BRANCH_TO_BE_IMPORTED>
++# $ cd /usr/src
++# $ git checkout vendor/libucl
++# $ rsync -va --delete --exclude=.git /tmp/libucl/ /usr/src/contrib/libucl/
++# $ git add .
++# $ git commit -m "vendor import libucl <REF_BRANCH_TO_BE_IMPORTED>"
++# $ git tag -a vendor/libucl/<REF_BRANCH_TO_BE_IMPORTED> -m "vendor import libucl <REF_BRANCH_TO_BE_IMPORTED>"
++# $ git push --follow-tags freebsd vendor/libucl/<REF_BRANCH_TO_BE_IMPORTED>
++#
++# 2. Test
++#
++# $ cd /usr/src
++# $ git checkout vendor/libucl/<REF_BRANCH_TO_BE_IMPORTED>
++# $ ./autogen.sh
++# $ ./configure
++# $ gmake
++# $ gmake check
++# $ gmake clean
++#
++# 3. Merge vendor tree
++#
++# $ git subtree merge -P contrib/libucl vendor/libucl/<REF_BRANCH_TO_BE_IMPORTED>
++# $ sh -c 'for F in `cat FREEBSD-Xlist | grep -v FreeBSD`; do rm -rf ./$F ; done'
++#
++# Recheck if there were any new files were added which are not necessary in the
++# contrib tree. If so, remove them and also add them to the FREEBSD-Xlist file.
diff --cc contrib/libucl/src/ucl_msgpack.c
index 08e690a4728a,3335e39cd9e7..628ed2be993d
--- a/contrib/libucl/src/ucl_msgpack.c
+++ b/contrib/libucl/src/ucl_msgpack.c
@@@ -1246,8 -1246,8 +1246,8 @@@ ucl_msgpack_consume (struct ucl_parser 
  		/* Empty container at the end */
  		if (len != 0) {
  			ucl_create_err (&parser->err,
--					"invalid non-empty container at the end; len=%zu",
- 					(size_t)len);
++					"invalid non-empty container at the end; len=%ju",
+ 					(uintmax_t)len);
  
  			return false;
  		}
diff --cc contrib/libucl/tests/.gitignore
index 000000000000,464482434f22..464482434f22
mode 000000,100644..100644
--- a/contrib/libucl/tests/.gitignore
+++ b/contrib/libucl/tests/.gitignore
diff --cc contrib/libucl/uthash/utlist.h
index c82dd916e2ed,08fc59ae6bef..7cda1ca0ecac
--- a/contrib/libucl/uthash/utlist.h
+++ b/contrib/libucl/uthash/utlist.h
@@@ -126,35 -132,35 +132,35 @@@ do 
          _ls_psize = 0;                                                                         \
          for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
            _ls_psize++;                                                                         \
-           _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list);                          \
 -          UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list);        \
++	  UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list);        \
            if (!_ls_q) break;                                                                   \
          }                                                                                      \
          _ls_qsize = _ls_insize;                                                                \
          while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
            if (_ls_psize == 0) {                                                                \
-             _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-               _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
 -            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
 -              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
++	    _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
++	      UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
            } else if (_ls_qsize == 0 || !_ls_q) {                                               \
-             _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-               _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
 -            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
 -              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
++	    _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
++	      UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
            } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
-             _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-               _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
 -            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
 -              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
++	    _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
++	      UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
            } else {                                                                             \
-             _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-               _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
 -            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
 -              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
++	    _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
++	      UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
            }                                                                                    \
            if (_ls_tail) {                                                                      \
-             _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
 -            UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
++	    UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
            } else {                                                                             \
-             _CASTASGN(list,_ls_e);                                                             \
 -            UTLIST_CASTASGN(list,_ls_e);                                                       \
++	    UTLIST_CASTASGN(list,_ls_e);                                                       \
            }                                                                                    \
            _ls_tail = _ls_e;                                                                    \
          }                                                                                      \
          _ls_p = _ls_q;                                                                         \
        }                                                                                        \
        if (_ls_tail) {                                                                          \
-         _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list);                     \
 -        UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list);   \
++	UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,NULL,next); UTLIST_RS(list);   \
        }                                                                                        \
        if (_ls_nmerges <= 1) {                                                                  \
          _ls_looping=0;                                                                         \
@@@ -189,30 -196,30 +196,30 @@@ do 
          _ls_psize = 0;                                                                         \
          for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
            _ls_psize++;                                                                         \
-           _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list);                          \
 -          UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list);        \
++	  UTLIST_SV(_ls_q,list); _ls_q = UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list);        \
            if (!_ls_q) break;                                                                   \
          }                                                                                      \
          _ls_qsize = _ls_insize;                                                                \
-         while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
 -        while ((_ls_psize > 0) || ((_ls_qsize > 0) && _ls_q)) {                                \
++	while ((_ls_psize > 0) || ((_ls_qsize > 0) && _ls_q)) {                                \
            if (_ls_psize == 0) {                                                                \
-             _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-               _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
-           } else if (_ls_qsize == 0 || !_ls_q) {                                               \
-             _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-               _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
 -            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
 -              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
 -          } else if ((_ls_qsize == 0) || (!_ls_q)) {                                           \
 -            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
 -              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
++	    _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
++	      UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
++	  } else if ((_ls_qsize == 0) || (!_ls_q)) {                                           \
++	    _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
++	      UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
            } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
-             _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-               _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
 -            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
 -              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
++	    _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
++	      UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
            } else {                                                                             \
-             _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-               _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
 -            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
 -              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
++	    _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
++	      UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
            }                                                                                    \
            if (_ls_tail) {                                                                      \
-             _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
 -            UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
++	    UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
            } else {                                                                             \
-             _CASTASGN(list,_ls_e);                                                             \
 -            UTLIST_CASTASGN(list,_ls_e);                                                       \
++	    UTLIST_CASTASGN(list,_ls_e);                                                       \
            }                                                                                    \
-           _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list);                     \
 -          UTLIST_SV(_ls_e,list); UTLIST_PREVASGN(_ls_e,list,_ls_tail,prev); UTLIST_RS(list);   \
++	  UTLIST_SV(_ls_e,list); UTLIST_PREVASGN(_ls_e,list,_ls_tail,prev); UTLIST_RS(list);   \
            _ls_tail = _ls_e;                                                                    \
          }                                                                                      \
          _ls_p = _ls_q;                                                                         \
@@@ -254,40 -261,40 +261,40 @@@ do 
          _ls_psize = 0;                                                                         \
          for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
            _ls_psize++;                                                                         \
-           _SV(_ls_q,list);                                                                     \
-           if (_NEXT(_ls_q,list,next) == _ls_oldhead) {                                         \
 -          UTLIST_SV(_ls_q,list);                                                               \
 -          if (UTLIST_NEXT(_ls_q,list,next) == _ls_oldhead) {                                   \
++	  UTLIST_SV(_ls_q,list);                                                               \
++	  if (UTLIST_NEXT(_ls_q,list,next) == _ls_oldhead) {                                   \
              _ls_q = NULL;                                                                      \
            } else {                                                                             \
-             _ls_q = _NEXT(_ls_q,list,next);                                                    \
 -            _ls_q = UTLIST_NEXT(_ls_q,list,next);                                              \
++	    _ls_q = UTLIST_NEXT(_ls_q,list,next);                                              \
            }                                                                                    \
-           _RS(list);                                                                           \
 -          UTLIST_RS(list);                                                                     \
++	  UTLIST_RS(list);                                                                     \
            if (!_ls_q) break;                                                                   \
          }                                                                                      \
          _ls_qsize = _ls_insize;                                                                \
          while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
            if (_ls_psize == 0) {                                                                \
-             _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-               _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
 -            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
 -              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
++	    _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
++	      UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
              if (_ls_q == _ls_oldhead) { _ls_q = NULL; }                                        \
            } else if (_ls_qsize == 0 || !_ls_q) {                                               \
-             _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-               _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
 -            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
 -              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
++	    _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
++	      UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
              if (_ls_p == _ls_oldhead) { _ls_p = NULL; }                                        \
            } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
-             _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-               _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
 -            _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
 -              UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
++	    _ls_e = _ls_p; UTLIST_SV(_ls_p,list); _ls_p =                                      \
++	      UTLIST_NEXT(_ls_p,list,next); UTLIST_RS(list); _ls_psize--;                      \
              if (_ls_p == _ls_oldhead) { _ls_p = NULL; }                                        \
            } else {                                                                             \
-             _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-               _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
 -            _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
 -              UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
++	    _ls_e = _ls_q; UTLIST_SV(_ls_q,list); _ls_q =                                      \
++	      UTLIST_NEXT(_ls_q,list,next); UTLIST_RS(list); _ls_qsize--;                      \
              if (_ls_q == _ls_oldhead) { _ls_q = NULL; }                                        \
            }                                                                                    \
            if (_ls_tail) {                                                                      \
-             _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
 -            UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
++	    UTLIST_SV(_ls_tail,list); UTLIST_NEXTASGN(_ls_tail,list,_ls_e,next); UTLIST_RS(list); \
            } else {                                                                             \
-             _CASTASGN(list,_ls_e);                                                             \
 -            UTLIST_CASTASGN(list,_ls_e);                                                       \
++	    UTLIST_CASTASGN(list,_ls_e);                                                       \
            }                                                                                    \
-           _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list);                     \
 -          UTLIST_SV(_ls_e,list); UTLIST_PREVASGN(_ls_e,list,_ls_tail,prev); UTLIST_RS(list);   \
++	  UTLIST_SV(_ls_e,list); UTLIST_PREVASGN(_ls_e,list,_ls_tail,prev); UTLIST_RS(list);   \
            _ls_tail = _ls_e;                                                                    \
          }                                                                                      \
          _ls_p = _ls_q;                                                                         \
@@@ -365,27 -368,28 +368,28 @@@ do 
    }                                                                                            \
  } while (0)
  
- /* Here are VS2008 replacements for LL_APPEND and LL_DELETE */
- #define LL_APPEND_VS2008(head,add)                                                             \
-     LL_APPEND2_VS2008(head,add,next)
+ #define LL_LOWER_BOUND(head,elt,like,cmp)                                                      \
+     LL_LOWER_BOUND2(head,elt,like,cmp,next)
  
- #define LL_APPEND2_VS2008(head,add,next)                                                       \
- do {                                                                                           \
-   if (head) {                                                                                  \
-     (add)->next = head;     /* use add->next as a temp variable */                             \
-     while ((add)->next->next) { (add)->next = (add)->next->next; }                             \
-     (add)->next->next=(add);                                                                   \
-   } else {                                                                                     \
-     (head)=(add);                                                                              \
-   }                                                                                            \
-   (add)->next=NULL;                                                                            \
- } while (0)
+ #define LL_LOWER_BOUND2(head,elt,like,cmp,next)                                                \
+   do {                                                                                         \
+     if ((head) == NULL || (cmp(head, like)) >= 0) {                                            \
+       (elt) = NULL;                                                                            \
+     } else {                                                                                   \
+       for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) {                         \
 -        if (cmp((elt)->next, like) >= 0) {                                                     \
 -          break;                                                                               \
 -        }                                                                                      \
++	if (cmp((elt)->next, like) >= 0) {                                                     \
++	  break;                                                                               \
++	}                                                                                      \
+       }                                                                                        \
+     }                                                                                          \
+   } while (0)
  
- #define LL_DELETE_VS2008(head,del)                                                             \
-     LL_DELETE2_VS2008(head,del,next)
+ #define LL_DELETE(head,del)                                                                    \
+     LL_DELETE2(head,del,next)
  
- #define LL_DELETE2_VS2008(head,del,next)                                                       \
+ #define LL_DELETE2(head,del,next)                                                              \
  do {                                                                                           \
+   LDECLTYPE(head) _tmp;                                                                        \
    if ((head) == (del)) {                                                                       \
      (head)=(head)->next;                                                                       \
    } else {                                                                                     \
@@@ -477,26 -464,158 +464,158 @@@ do 
   }                                                                                             \
  } while (0)
  
+ #define LL_REPLACE_ELEM(head, el, add)                                                         \
+     LL_REPLACE_ELEM2(head, el, add, next)
+ 
+ #define LL_PREPEND_ELEM2(head, el, add, next)                                                  \
+ do {                                                                                           \
+  if (el) {                                                                                     \
+   LDECLTYPE(head) _tmp;                                                                        \
+   assert((head) != NULL);                                                                      \
+   assert((add) != NULL);                                                                       \
+   (add)->next = (el);                                                                          \
+   if ((head) == (el)) {                                                                        \
+    (head) = (add);                                                                             \
+   } else {                                                                                     \
+    _tmp = (head);                                                                              \
+    while (_tmp->next && (_tmp->next != (el))) {                                                \
+     _tmp = _tmp->next;                                                                         \
+    }                                                                                           \
+    if (_tmp->next) {                                                                           \
+      _tmp->next = (add);                                                                       \
+    }                                                                                           \
+   }                                                                                            \
+  } else {                                                                                      \
+   LL_APPEND2(head, add, next);                                                                 \
+  }                                                                                             \
+ } while (0)                                                                                    \
+ 
  #define LL_PREPEND_ELEM(head, el, add)                                                         \
+     LL_PREPEND_ELEM2(head, el, add, next)
+ 
+ #define LL_APPEND_ELEM2(head, el, add, next)                                                   \
  do {                                                                                           \
-  LDECLTYPE(head) _tmp;                                                                         \
-  assert(head != NULL);                                                                         \
-  assert(el != NULL);                                                                           \
-  assert(add != NULL);                                                                          \
-  (add)->next = (el);                                                                           \
-  if ((head) == (el)) {                                                                         \
-   (head) = (add);                                                                              \
+  if (el) {                                                                                     \
+   assert((head) != NULL);                                                                      \
+   assert((add) != NULL);                                                                       \
+   (add)->next = (el)->next;                                                                    \
+   (el)->next = (add);                                                                          \
   } else {                                                                                      \
-   _tmp = head;                                                                                 \
-   while (_tmp->next && (_tmp->next != (el))) {                                                 \
-    _tmp = _tmp->next;                                                                          \
+   LL_PREPEND2(head, add, next);                                                                \
+  }                                                                                             \
+ } while (0)                                                                                    \
+ 
+ #define LL_APPEND_ELEM(head, el, add)                                                          \
+     LL_APPEND_ELEM2(head, el, add, next)
+ 
+ #ifdef NO_DECLTYPE
+ /* Here are VS2008 / NO_DECLTYPE replacements for a few functions */
+ 
+ #undef LL_CONCAT2
+ #define LL_CONCAT2(head1,head2,next)                                                           \
+ do {                                                                                           \
+   char *_tmp;                                                                                  \
+   if (head1) {                                                                                 \
+     _tmp = (char*)(head1);                                                                     \
+     while ((head1)->next) { (head1) = (head1)->next; }                                         \
+     (head1)->next = (head2);                                                                   \
+     UTLIST_RS(head1);                                                                          \
+   } else {                                                                                     \
+     (head1)=(head2);                                                                           \
    }                                                                                            \
-   if (_tmp->next) {                                                                            \
-     _tmp->next = (add);                                                                        \
+ } while (0)
+ 
+ #undef LL_APPEND2
+ #define LL_APPEND2(head,add,next)                                                              \
+ do {                                                                                           \
+   if (head) {                                                                                  \
+     (add)->next = head;     /* use add->next as a temp variable */                             \
+     while ((add)->next->next) { (add)->next = (add)->next->next; }                             \
+     (add)->next->next=(add);                                                                   \
+   } else {                                                                                     \
+     (head)=(add);                                                                              \
+   }                                                                                            \
+   (add)->next=NULL;                                                                            \
+ } while (0)
+ 
+ #undef LL_INSERT_INORDER2
+ #define LL_INSERT_INORDER2(head,add,cmp,next)                                                  \
+ do {                                                                                           \
+   if ((head) == NULL || (cmp(head, add)) >= 0) {                                               \
+     (add)->next = (head);                                                                      \
+     (head) = (add);                                                                            \
+   } else {                                                                                     \
+     char *_tmp = (char*)(head);                                                                \
+     while ((head)->next != NULL && (cmp((head)->next, add)) < 0) {                             \
+       (head) = (head)->next;                                                                   \
+     }                                                                                          \
+     (add)->next = (head)->next;                                                                \
+     (head)->next = (add);                                                                      \
+     UTLIST_RS(head);                                                                           \
+   }                                                                                            \
+ } while (0)
+ 
+ #undef LL_DELETE2
+ #define LL_DELETE2(head,del,next)                                                              \
+ do {                                                                                           \
+   if ((head) == (del)) {                                                                       \
+     (head)=(head)->next;                                                                       \
+   } else {                                                                                     \
+     char *_tmp = (char*)(head);                                                                \
+     while ((head)->next && ((head)->next != (del))) {                                          \
+       (head) = (head)->next;                                                                   \
+     }                                                                                          \
+     if ((head)->next) {                                                                        \
+       (head)->next = ((del)->next);                                                            \
+     }                                                                                          \
+     UTLIST_RS(head);                                                                           \
+   }                                                                                            \
+ } while (0)
+ 
+ #undef LL_REPLACE_ELEM2
+ #define LL_REPLACE_ELEM2(head, el, add, next)                                                  \
+ do {                                                                                           \
+   assert((head) != NULL);                                                                      \
+   assert((el) != NULL);                                                                        \
+   assert((add) != NULL);                                                                       \
+   if ((head) == (el)) {                                                                        \
+     (head) = (add);                                                                            \
+   } else {                                                                                     \
+     (add)->next = head;                                                                        \
+     while ((add)->next->next && ((add)->next->next != (el))) {                                 \
+       (add)->next = (add)->next->next;                                                         \
+     }                                                                                          \
+     if ((add)->next->next) {                                                                   \
+       (add)->next->next = (add);                                                               \
+     }                                                                                          \
+   }                                                                                            \
+   (add)->next = (el)->next;                                                                    \
+ } while (0)
+ 
+ #undef LL_PREPEND_ELEM2
+ #define LL_PREPEND_ELEM2(head, el, add, next)                                                  \
+ do {                                                                                           \
+   if (el) {                                                                                    \
+     assert((head) != NULL);                                                                    \
+     assert((add) != NULL);                                                                     \
+     if ((head) == (el)) {                                                                      \
+       (head) = (add);                                                                          \
+     } else {                                                                                   \
+       (add)->next = (head);                                                                    \
+       while ((add)->next->next && ((add)->next->next != (el))) {                               \
 -        (add)->next = (add)->next->next;                                                       \
++	(add)->next = (add)->next->next;                                                       \
+       }                                                                                        \
+       if ((add)->next->next) {                                                                 \
 -        (add)->next->next = (add);                                                             \
++	(add)->next->next = (add);                                                             \
+       }                                                                                        \
+     }                                                                                          \
+     (add)->next = (el);                                                                        \
+   } else {                                                                                     \
+     LL_APPEND2(head, add, next);                                                               \
    }                                                                                            \
-  }                                                                                             \
  } while (0)                                                                                    \
  
+ #endif /* NO_DECLTYPE */
  
  /******************************************************************************
   * doubly linked list macros (non-circular)                                   *
@@@ -531,7 -650,39 +650,39 @@@ do 
        (head)->prev = (head);                                                                   \
        (head)->next = NULL;                                                                     \
    }                                                                                            \
- } while (0) 
+ } while (0)
+ 
+ #define DL_INSERT_INORDER(head,add,cmp)                                                        \
+     DL_INSERT_INORDER2(head,add,cmp,prev,next)
+ 
+ #define DL_INSERT_INORDER2(head,add,cmp,prev,next)                                             \
+ do {                                                                                           \
+   LDECLTYPE(head) _tmp;                                                                        \
+   if (head) {                                                                                  \
+     DL_LOWER_BOUND2(head, _tmp, add, cmp, next);                                               \
+     DL_APPEND_ELEM2(head, _tmp, add, prev, next);                                              \
+   } else {                                                                                     \
+     (head) = (add);                                                                            \
+     (head)->prev = (head);                                                                     \
+     (head)->next = NULL;                                                                       \
+   }                                                                                            \
+ } while (0)
+ 
+ #define DL_LOWER_BOUND(head,elt,like,cmp)                                                      \
+     DL_LOWER_BOUND2(head,elt,like,cmp,next)
+ 
+ #define DL_LOWER_BOUND2(head,elt,like,cmp,next)                                                \
+ do {                                                                                           \
+   if ((head) == NULL || (cmp(head, like)) >= 0) {                                              \
+     (elt) = NULL;                                                                              \
+   } else {                                                                                     \
+     for ((elt) = (head); (elt)->next != NULL; (elt) = (elt)->next) {                           \
+       if ((cmp((elt)->next, like)) >= 0) {                                                     \
 -        break;                                                                                 \
++	break;                                                                                 \
+       }                                                                                        \
+     }                                                                                          \
+   }                                                                                            \
+ } while (0)
  
  #define DL_CONCAT(head1,head2)                                                                 \
      DL_CONCAT2(head1,head2,prev,next)
@@@ -541,10 -692,10 +692,10 @@@ do 
    LDECLTYPE(head1) _tmp;                                                                       \
    if (head2) {                                                                                 \
      if (head1) {                                                                               \
-         _tmp = (head2)->prev;                                                                  \
 -        UTLIST_CASTASGN(_tmp, (head2)->prev);                                                  \
++	UTLIST_CASTASGN(_tmp, (head2)->prev);                                                  \
          (head2)->prev = (head1)->prev;                                                         \
          (head1)->prev->next = (head2);                                                         \
-         (head1)->prev = _tmp;                                                                  \
 -        UTLIST_CASTASGN((head1)->prev, _tmp);                                                  \
++	UTLIST_CASTASGN((head1)->prev, _tmp);                                                  \
      } else {                                                                                   \
          (head1)=(head2);                                                                       \
      }                                                                                          \
@@@ -659,7 -891,39 +891,39 @@@ do 
     (add)->prev = (add);                                                                        \
     (add)->next = (add);                                                                        \
   }                                                                                             \
- (head)=(add);                                                                                  \
+  (head) = (add);                                                                               \
+ } while (0)
+ 
+ #define CDL_INSERT_INORDER(head,add,cmp)                                                       \
+     CDL_INSERT_INORDER2(head,add,cmp,prev,next)
+ 
+ #define CDL_INSERT_INORDER2(head,add,cmp,prev,next)                                            \
+ do {                                                                                           \
+   LDECLTYPE(head) _tmp;                                                                        \
+   if (head) {                                                                                  \
+     CDL_LOWER_BOUND2(head, _tmp, add, cmp, next);                                              \
+     CDL_APPEND_ELEM2(head, _tmp, add, prev, next);                                             \
+   } else {                                                                                     \
+     (head) = (add);                                                                            \
+     (head)->next = (head);                                                                     \
+     (head)->prev = (head);                                                                     \
+   }                                                                                            \
+ } while (0)
+ 
+ #define CDL_LOWER_BOUND(head,elt,like,cmp)                                                     \
+     CDL_LOWER_BOUND2(head,elt,like,cmp,next)
+ 
+ #define CDL_LOWER_BOUND2(head,elt,like,cmp,next)                                               \
+ do {                                                                                           \
+   if ((head) == NULL || (cmp(head, like)) >= 0) {                                              \
+     (elt) = NULL;                                                                              \
+   } else {                                                                                     \
+     for ((elt) = (head); (elt)->next != (head); (elt) = (elt)->next) {                         \
+       if ((cmp((elt)->next, like)) >= 0) {                                                     \
 -        break;                                                                                 \
++	break;                                                                                 \
+       }                                                                                        \
+     }                                                                                          \
+   }                                                                                            \
  } while (0)
  
  #define CDL_DELETE(head,del)                                                                   \