summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2026-03-03 20:00:05 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2026-03-03 20:00:05 +0900
commit53f603f284e8a36a764855f80b0ddaadfee818b8 (patch)
treea81eb704747d62b204f207d549f4ac5eb5b91540
parent26914d6b97d50cb87a41b4a51a037dfdd4e824ed (diff)
downloadtdelibs-drop/custom-vsnprintf.tar.gz
tdelibs-drop/custom-vsnprintf.zip
vsnprintf/snprintf are part of the c++ standard, so there is no need to keep around custom implementations for themdrop/custom-vsnprintf
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--CMakeLists.txt6
-rw-r--r--config.h.cmake50
-rw-r--r--tdecore/CMakeLists.txt8
-rw-r--r--tdecore/Makefile.am16
-rw-r--r--tdecore/kdebug.cpp3
-rw-r--r--tdecore/libtdecore.nmcheck2
-rw-r--r--tdecore/vsnprintf.c170
-rw-r--r--tdemarkdown/md4c/md2html/cmdline.c5
-rw-r--r--tdemarkdown/md4c/src/md4c-html.c4
-rw-r--r--win/tdelibs_global_win.h4
10 files changed, 12 insertions, 256 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2aeda5792..ab7ea76c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -337,9 +337,6 @@ check_function_exists( setegid HAVE_SETEGID )
check_function_exists( gethostname HAVE_GETHOSTNAME )
check_symbol_exists( gethostname "unistd.h" HAVE_GETHOSTNAME_PROTO )
-check_function_exists( vsnprintf HAVE_VSNPRINTF )
-check_function_exists( snprintf HAVE_SNPRINTF )
-
check_function_exists( setenv HAVE_SETENV )
check_symbol_exists( setenv "stdlib.h" HAVE_SETENV_PROTO )
@@ -399,9 +396,6 @@ check_symbol_exists( basename "libgen.h" HAVE_BASENAME_PROTO )
check_symbol_exists( ffs "string.h" HAVE_FFS_PROTO )
check_symbol_exists( asprintf "stdio.h" HAVE_ASPRINTF_PROTO )
check_symbol_exists( vasprintf "stdio.h" HAVE_VASPRINTF_PROTO )
-check_symbol_exists( snprintf "stdio.h" HAVE_SNPRINTF_PROTO )
-check_symbol_exists( vsnprintf "stdarg.h;stdio.h" HAVE_VSNPRINTF_PROTO )
-check_symbol_exists( strvercmp "string.h" HAVE_STRVERCMP_PROTO )
check_function_exists( usleep HAVE_USLEEP )
diff --git a/config.h.cmake b/config.h.cmake
index 1893d8ce3..6c30c3085 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -49,15 +49,6 @@
/* Define if you have vasprintf prototype */
#cmakedefine HAVE_VASPRINTF_PROTO 1
-/* Define if you have snsprintf prototype */
-#cmakedefine HAVE_SNPRINTF_PROTO 1
-
-/* Define if you have vsnsprintf prototype */
-#cmakedefine HAVE_VSNPRINTF_PROTO 1
-
-/* Define if you have strvercmp prototype */
-#cmakedefine HAVE_STRVERCMP_PROTO 1
-
/* Define to 1 if GLIBC >= 2.1 compatible backtrace facility exists */
#cmakedefine HAVE_BACKTRACE 1
#ifdef HAVE_BACKTRACE
@@ -91,18 +82,6 @@
#define HAVE_DECL_VASPRINTF 1
#endif /* HAVE_VASPRINTF_PROTO */
-#ifdef HAVE_SNPRINTF_PROTO
-#define HAVE_DECL_SNPRINTF 1
-#endif /* HAVE_SNPRINTF_PROTO */
-
-#ifdef HAVE_VSNPRINTF_PROTO
-#define HAVE_DECL_VSNPRINTF 1
-#endif /* HAVE_VSNPRINTF_PROTO */
-
-#ifdef HAVE_STRVERCMP_PROTO
-#define HAVE_DECL_STRVERCMP 1
-#endif /* HAVE_STRVERCMP_PROTO */
-
#endif /* HAVE_BASENAME_PROTO */
/* Define to 1 if libbfd provides demangle.h header */
@@ -508,9 +487,6 @@
/* Define if libasound has snd_pcm_resume() */
#undef HAVE_SND_PCM_RESUME
-/* Define to 1 if you have the `snprintf' function. */
-#cmakedefine HAVE_SNPRINTF 1
-
/* Define to 1 if you have the `socket' function. */
#cmakedefine HAVE_SOCKET 1
@@ -710,9 +686,6 @@
/* Define, to enable volume management (Solaris 2.x), if you have -lvolmgt */
#undef HAVE_VOLMGT
-/* Define to 1 if you have the `vsnprintf' function. */
-#cmakedefine HAVE_VSNPRINTF 1
-
/* Define to 1 if you have the <X11/extensions/shape.h> header file. */
#cmakedefine HAVE_X11_EXTENSIONS_SHAPE_H 1
@@ -1138,29 +1111,6 @@ __END_DECLS
-#if !defined(HAVE_VSNPRINTF_PROTO) || !defined(HAVE_SNPRINTF_PROTO)
-#if __STDC__
-#include <stdarg.h>
-#include <stdlib.h>
-#else
-#include <varargs.h>
-#endif
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-#if !defined(HAVE_VSNPRINTF_PROTO)
-int vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
-#endif
-#if !defined(HAVE_SNPRINTF_PROTO)
-int snprintf(char *str, size_t n, char const *fmt, ...);
-#endif
-#ifdef __cplusplus
-}
-#endif
-#endif
-
-
/* TDE bindir */
#define __TDE_BINDIR "@BIN_INSTALL_DIR@"
diff --git a/tdecore/CMakeLists.txt b/tdecore/CMakeLists.txt
index 96032d616..3ebbe8add 100644
--- a/tdecore/CMakeLists.txt
+++ b/tdecore/CMakeLists.txt
@@ -123,7 +123,7 @@ set( ${target}_SRCS
kaudioplayer.cpp kdcoppropertyproxy.cpp ksockaddr.cpp
kextsock.cpp netsupp.cpp tdeprocio.cpp kbufferedio.cpp
kpixmapprovider.cpp kurldrag.cpp kmdcodec.cpp ksocks.cpp
- fakes.c vsnprintf.c tdesycoca.cpp tdesycocadict.cpp tdesycoca.skel
+ fakes.c tdesycoca.cpp tdesycocadict.cpp tdesycoca.skel
tdesycocafactory.cpp kxmessages.cpp tdestartupinfo.cpp
kcatalogue.cpp kasyncio.cpp tdemultipledrag.cpp kstaticdeleter.cpp
tdeappdcopinterface.cpp tdeappdcopinterface.skel kclipboard.cpp
@@ -154,7 +154,7 @@ tde_add_library( ${target} SHARED AUTOMOC
set( target tdefakes_nonpic )
set( ${target}_SRCS
- fakes.c vsnprintf.c
+ fakes.c
)
tde_add_library( ${target} STATIC
@@ -167,7 +167,7 @@ tde_add_library( ${target} STATIC
set( target tdefakes_pic )
set( ${target}_SRCS
- fakes.c vsnprintf.c
+ fakes.c
)
tde_add_library( ${target} STATIC_PIC
@@ -181,7 +181,7 @@ tde_add_library( ${target} STATIC_PIC
set( target tdefakes )
set( ${target}_SRCS
- fakes.c vsnprintf.c
+ fakes.c
)
tde_add_library( ${target} SHARED
diff --git a/tdecore/Makefile.am b/tdecore/Makefile.am
index 0997aad45..c41b25bd6 100644
--- a/tdecore/Makefile.am
+++ b/tdecore/Makefile.am
@@ -61,24 +61,20 @@ include_HEADERS = tdeconfig.h tdeconfigskeleton.h \
kidna.h ktempdir.h kshell.h fixx11h.h kxerrorhandler.h tdelibs_export.h \
tdemacros.h kde_file.h ktimezones.h
-libtdefakes_la_SOURCES = fakes.c vsnprintf.c
+libtdefakes_la_SOURCES = fakes.c
libtdefakes_la_LDFLAGS = -version-info 6:0:2
libtdefakes_la_LIBADD = $(LIBSOCKET)
-libtdefakes_nonpic_a_SOURCES = fakes_nonpic.c vsnprintf_nonpic.c
+libtdefakes_nonpic_a_SOURCES = fakes_nonpic.c
fakes_nonpic.c:$(srcdir)/fakes.c
-rm -f fakes_nonpic.c
$(LN_S) $(srcdir)/fakes.c fakes_nonpic.c
-vsnprintf_nonpic.c: $(srcdir)/vsnprintf.c
- -rm -f vsnprintf_nonpic.c
- $(LN_S) $(srcdir)/vsnprintf.c vsnprintf_nonpic.c
-
libtdefakes_pic.a: libtdefakes.la
- -rm -f libtdefakes_pic.a fakes_pic.o vsnprintf_pic.o
- cp -f .libs/fakes.o fakes_pic.o; cp -f .libs/vsnprintf.o vsnprintf_pic.o
- ar cru libtdefakes_pic.a fakes_pic.o vsnprintf_pic.o
+ -rm -f libtdefakes_pic.a fakes_pic.o
+ cp -f .libs/fakes.o fakes_pic.o
+ ar cru libtdefakes_pic.a fakes_pic.o
ranlib libtdefakes_pic.a
noinst_HEADERS = tdeaccelaction.h tdeaccelbase.h tdeaccelprivate.h kckey.h \
@@ -107,7 +103,7 @@ libtdecore_la_SOURCES = libintl.cpp tdeapplication.cpp \
kaudioplayer.cpp kdcoppropertyproxy.cpp \
ksockaddr.cpp kextsock.cpp netsupp.cpp tdeprocio.cpp kbufferedio.cpp \
kpixmapprovider.cpp kurldrag.cpp \
- kmdcodec.cpp ksocks.cpp fakes.c vsnprintf.c \
+ kmdcodec.cpp ksocks.cpp fakes.c \
tdesycoca.cpp tdesycocadict.cpp tdesycocafactory.cpp tdesycoca.skel \
kxmessages.cpp tdestartupinfo.cpp kcatalogue.cpp kasyncio.cpp \
tdemultipledrag.cpp kstaticdeleter.cpp tdeappdcopinterface.cpp \
diff --git a/tdecore/kdebug.cpp b/tdecore/kdebug.cpp
index 18af9c030..64f59555f 100644
--- a/tdecore/kdebug.cpp
+++ b/tdecore/kdebug.cpp
@@ -50,9 +50,10 @@
#include <stdlib.h> // abort
#include <unistd.h> // getpid
#include <stdarg.h> // vararg stuff
-#include <ctype.h> // isprint
+#include <ctype.h> // isprint
#include <syslog.h>
#include <errno.h>
+#include <cstdio>
#include <cstring>
#include <tdeconfig.h>
#include "kstaticdeleter.h"
diff --git a/tdecore/libtdecore.nmcheck b/tdecore/libtdecore.nmcheck
index 92ec3ff8f..bac46877d 100644
--- a/tdecore/libtdecore.nmcheck
+++ b/tdecore/libtdecore.nmcheck
@@ -62,8 +62,6 @@ mkstemp
revoke
strlcpy
strlcat
-vsnprintf
-snprintf
# from malloc
malloc
diff --git a/tdecore/vsnprintf.c b/tdecore/vsnprintf.c
deleted file mode 100644
index 257392aa4..000000000
--- a/tdecore/vsnprintf.c
+++ /dev/null
@@ -1,170 +0,0 @@
-#include "config.h"
-#ifndef HAVE_VSNPRINTF
-
-/*
- * Revision 12: http://theos.com/~deraadt/snprintf.c
- *
- * Copyright (c) 1997 Theo de Raadt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#if __STDC__
-#include <stdarg.h>
-#include <stdlib.h>
-#else
-#include <varargs.h>
-#endif
-#include <setjmp.h>
-
-#ifndef roundup
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#endif
-
-static int pgsize;
-static char *curobj;
-static sigjmp_buf bail;
-
-#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */
-
-static char *
-msetup(str, n)
- char *str;
- size_t n;
-{
- char *e;
-
- if (n == 0)
- return NULL;
- if (pgsize == 0)
- pgsize = getpagesize();
- curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2);
- if (curobj == NULL)
- return NULL;
- e = curobj + n + EXTRABYTES;
- e = (char *)roundup((unsigned long)e, pgsize);
- if (mprotect(e, pgsize, PROT_NONE) == -1) {
- free(curobj);
- curobj = NULL;
- return NULL;
- }
- e = e - n - EXTRABYTES;
- *e = '\0';
- return (e);
-}
-
-static void
-mcatch()
-{
- siglongjmp(bail, 1);
-}
-
-static void
-mcleanup(str, n, p)
- char *str;
- size_t n;
- char *p;
-{
- int l = strlen(p);
-
- if (l > n - 1)
- l = n - 1;
- memcpy(str, p, l);
- str[l] = '\0';
- if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
- PROT_READ|PROT_WRITE|PROT_EXEC) == -1)
- mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
- PROT_READ|PROT_WRITE);
- free(curobj);
-}
-
-int
-#if __STDC__
-vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
-#else
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- char *fmt;
- char *ap;
-#endif
-{
- struct sigaction osa, nsa;
- char *p;
- int ret = n + 1; /* if we bail, indicated we overflowed */
-
- memset(&nsa, 0, sizeof nsa);
- nsa.sa_handler = mcatch;
- sigemptyset(&nsa.sa_mask);
-
- p = msetup(str, n);
- if (p == NULL) {
- *str = '\0';
- return 0;
- }
- if (sigsetjmp(bail, 1) == 0) {
- if (sigaction(SIGSEGV, &nsa, &osa) == -1) {
- mcleanup(str, n, p);
- return (0);
- }
- ret = vsprintf(p, fmt, ap);
- }
- mcleanup(str, n, p);
- (void) sigaction(SIGSEGV, &osa, NULL);
- return (ret);
-}
-
-int
-#if __STDC__
-snprintf(char *str, size_t n, char const *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
- char *str;
- size_t n;
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
-
- return (vsnprintf(str, n, fmt, ap));
- va_end(ap);
-}
-
-
-#endif
-
-/* ANSI C forbids an empty source file... */
-static void dummy_func() {
- dummy_func();
-}
diff --git a/tdemarkdown/md4c/md2html/cmdline.c b/tdemarkdown/md4c/md2html/cmdline.c
index c3fddfaa4..43d68b52c 100644
--- a/tdemarkdown/md4c/md2html/cmdline.c
+++ b/tdemarkdown/md4c/md2html/cmdline.c
@@ -29,11 +29,6 @@
#include <string.h>
-#ifdef _WIN32
- #define snprintf _snprintf
-#endif
-
-
#define CMDLINE_AUXBUF_SIZE 32
diff --git a/tdemarkdown/md4c/src/md4c-html.c b/tdemarkdown/md4c/src/md4c-html.c
index d604aecb0..4995dfad2 100644
--- a/tdemarkdown/md4c/src/md4c-html.c
+++ b/tdemarkdown/md4c/src/md4c-html.c
@@ -41,10 +41,6 @@
#endif
#endif
-#ifdef _WIN32
- #define snprintf _snprintf
-#endif
-
typedef struct MD_HTML_tag MD_HTML;
diff --git a/win/tdelibs_global_win.h b/win/tdelibs_global_win.h
index 06e31e067..1828bfb58 100644
--- a/win/tdelibs_global_win.h
+++ b/win/tdelibs_global_win.h
@@ -111,10 +111,6 @@ int kde_start
typedef char* caddr_t;
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
-
-
/* should be in <sys/types.h> */
typedef int mode_t;