diff options
-rw-r--r-- | compat_err.c | 12 | ||||
-rwxr-xr-x | configure | 1 | ||||
-rw-r--r-- | mansearch.c | 15 |
3 files changed, 22 insertions, 6 deletions
diff --git a/compat_err.c b/compat_err.c index f996c31a..46f360da 100644 --- a/compat_err.c +++ b/compat_err.c @@ -77,6 +77,18 @@ err(int eval, const char *fmt, ...) } void +errx(int eval, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vwarnxi(fmt, ap); + va_end(ap); + fputc('\n', stderr); + exit(eval); +} + +void warn(const char *fmt, ...) { va_list ap; @@ -339,6 +339,7 @@ __HEREDOC__ if [ ${HAVE_ERR} -eq 0 ]; then echo "extern void err(int, const char *, ...);" + echo "extern void errx(int, const char *, ...);" echo "extern void warn(const char *, ...);" echo "extern void warnx(const char *, ...);" fi diff --git a/mansearch.c b/mansearch.c index 37b1e6b3..0db8edbf 100644 --- a/mansearch.c +++ b/mansearch.c @@ -54,17 +54,17 @@ extern const char *const mansearch_keynames[]; #define SQL_BIND_TEXT(_db, _s, _i, _v) \ do { if (SQLITE_OK != sqlite3_bind_text \ ((_s), (_i)++, (_v), -1, SQLITE_STATIC)) \ - warnx("%s", sqlite3_errmsg((_db))); \ + errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \ } while (0) #define SQL_BIND_INT64(_db, _s, _i, _v) \ do { if (SQLITE_OK != sqlite3_bind_int64 \ ((_s), (_i)++, (_v))) \ - warnx("%s", sqlite3_errmsg((_db))); \ + errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \ } while (0) #define SQL_BIND_BLOB(_db, _s, _i, _v) \ do { if (SQLITE_OK != sqlite3_bind_blob \ ((_s), (_i)++, (&_v), sizeof(_v), SQLITE_STATIC)) \ - warnx("%s", sqlite3_errmsg((_db))); \ + errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \ } while (0) struct expr { @@ -262,7 +262,8 @@ mansearch(const struct mansearch *search, j = 1; c = sqlite3_prepare_v2(db, sql, -1, &s, NULL); if (SQLITE_OK != c) - warnx("%s", sqlite3_errmsg(db)); + errx((int)MANDOCLEVEL_SYSERR, + "%s", sqlite3_errmsg(db)); for (ep = e; NULL != ep; ep = ep->next) { if (NULL == ep->substr) { @@ -312,14 +313,16 @@ mansearch(const struct mansearch *search, "WHERE pageid=? ORDER BY sec, arch, name", -1, &s, NULL); if (SQLITE_OK != c) - warnx("%s", sqlite3_errmsg(db)); + errx((int)MANDOCLEVEL_SYSERR, + "%s", sqlite3_errmsg(db)); c = sqlite3_prepare_v2(db, "SELECT bits, key, pageid FROM keys " "WHERE pageid=? AND bits & ?", -1, &s2, NULL); if (SQLITE_OK != c) - warnx("%s", sqlite3_errmsg(db)); + errx((int)MANDOCLEVEL_SYSERR, + "%s", sqlite3_errmsg(db)); for (mp = ohash_first(&htab, &idx); NULL != mp; |