There is only one remaining unconditional snprintf usage in the library,
which implements the cdecl__strlcpy function. Replacing this with an
alternate implementation means we no longer need snprintf at all except
when NLS is enabled (in that case, we assume snprintf is available --
possibly provided by GNU libintl).
So we can drop quite a lot of gnulib code potentially going into the
library. The usual gnulib behaviour is to substitute complete re-
implementations for almost any possible problem, even ones that are
totally irrelevant to the usage at hand.
Bumping dxcommon removes snprintf from the applications too so we can
drop all of this nonsense. On systems that used the snprintf fallback,
this reduces the overall library size by about 30%.
exec 3>lib/symfiles.tmp 4<lib/symfiles.tmp
rm -f lib/symfiles.tmp
- shared_modules='lock tls snprintf'
+ shared_modules='lock tls'
set x --extract-recursive-dependencies $shared_modules; shift
(set -x; $GNULIB/gnulib-tool "$@" >&3 ) || die "gnulib-tool failed"
shared_modules=`LC_ALL=C sort -u <&4`
-Subproject commit 4081782832b7dc8b7426cedcec9a4495229dda6c
+Subproject commit 11dfda46d8834955846372602441bbcec6a9047f
# lock \
# mbswidth \
# readline \
-# snprintf \
# tls
# Specification in the form of a few gnulib-tool.m4 macro invocations:
lock
mbswidth
readline
- snprintf
tls
])
gl_AVOID([gperf std-gnu11])
size_t cdecl__strlcpy(char *dst, const char *src, size_t dstlen)
{
- if (dst)
- snprintf(dst, dstlen, "%s", src);
- return strlen(src);
+ size_t srclen = strlen(src);
+
+ if (dstlen > 0) {
+ memcpy(dst, src, MIN(dstlen, srclen+1));
+ if (dstlen <= srclen)
+ dst[dstlen-1] = 0;
+ }
+
+ return srclen;
}
size_t cdecl__emit(struct output_state *dst, const char *src)