source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Since old SQLite versions do not have sqlite3_errstr(), provide
Date: Tue, 5 Aug 2014 08:50:52 -0400 (EDT)	[thread overview]
Message-ID: <201408051250.s75CoqmX015806@krisdoz.my.domain> (raw)

Log Message:
-----------
Since old SQLite versions do not have sqlite3_errstr(),
provide a dummy fallback implementation.
Do not bother to decode the error, SQLite error codes
are not useful enough for that to be worthwhile.
Note that using sqlite3_errmsg(db) would be a bad idea:
On malloc() failure, db is NULL, which would cause a segfault.
Issue noticed by kristaps@.

Modified Files:
--------------
    mdocml:
        Makefile
        config.h.post
        configure

Added Files:
-----------
    mdocml:
        test-sqlite3_errstr.c
        compat_sqlite3_errstr.c

Revision Data
-------------
--- /dev/null
+++ test-sqlite3_errstr.c
@@ -0,0 +1,8 @@
+#include <string.h>
+#include <sqlite3.h>
+
+int
+main(void)
+{
+	return(strcmp(sqlite3_errstr(SQLITE_OK), "not an error"));
+}
--- /dev/null
+++ compat_sqlite3_errstr.c
@@ -0,0 +1,18 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_SQLITE3_ERRSTR
+
+int dummy;
+
+#else
+
+const char *
+sqlite3_errstr(int rc)
+{
+
+	return(rc ? "unknown error" : "not an error");
+}
+
+#endif
Index: configure
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/configure,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lconfigure -Lconfigure -u -p -r1.5 -r1.6
--- configure
+++ configure
@@ -35,6 +35,8 @@ runtest getsubopt GETSUBOPT
 runtest mmap MMAP
 runtest ohash OHASH -lutil
 runtest reallocarray REALLOCARRAY
+runtest sqlite3_errstr SQLITE3_ERRSTR \
+	"-I/usr/local/include -L/usr/local/lib -lsqlite3"
 runtest strcasestr STRCASESTR
 runtest strlcat STRLCAT
 runtest strlcpy STRLCPY
Index: Makefile
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Makefile,v
retrieving revision 1.431
retrieving revision 1.432
diff -LMakefile -LMakefile -u -p -r1.431 -r1.432
--- Makefile
+++ Makefile
@@ -121,6 +121,7 @@ TESTSRCS	 = test-fgetln.c \
 		   test-mmap.c \
 		   test-ohash.c \
 		   test-reallocarray.c \
+		   test-sqlite3_errstr.c \
 		   test-strcasestr.c \
 		   test-strlcat.c \
 		   test-strlcpy.c \
@@ -136,6 +137,7 @@ SRCS		 = apropos.c \
 		   compat_getsubopt.c \
 		   compat_ohash.c \
 		   compat_reallocarray.c \
+		   compat_sqlite3_errstr.c \
 		   compat_strcasestr.c \
 		   compat_strlcat.c \
 		   compat_strlcpy.c \
@@ -281,6 +283,7 @@ COMPAT_OBJS	 = compat_fgetln.o \
 		   compat_getsubopt.o \
 		   compat_ohash.o \
 		   compat_reallocarray.o \
+		   compat_sqlite3_errstr.o \
 		   compat_strcasestr.o \
 		   compat_strlcat.o \
 		   compat_strlcpy.o \
Index: config.h.post
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/config.h.post,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lconfig.h.post -Lconfig.h.post -u -p -r1.10 -r1.11
--- config.h.post
+++ config.h.post
@@ -23,6 +23,9 @@ extern	char	 *suboptarg;
 #ifndef HAVE_REALLOCARRAY
 extern	void	 *reallocarray(void *, size_t, size_t);
 #endif
+#ifndef HAVE_SQLITE3_ERRSTR
+extern	const char *sqlite3_errstr(int);
+#endif
 #ifndef HAVE_STRCASESTR
 extern	char	 *strcasestr(const char *, const char *);
 #endif
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-08-05 12:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201408051250.s75CoqmX015806@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).