summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2016-07-28 10:48:23 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2016-07-28 10:48:23 (GMT)
commitcda4f4b9026f80af50289a56706877dfa6ef41e5 (patch) (side-by-side diff)
tree34a032bc64ff7d82140d3121c568a886c0a36d55
parentb071adbbfbfbd3b63e75818c0850d0fa1f8c8faa (diff)
downloaddico-cda4f4b9026f80af50289a56706877dfa6ef41e5.tar.gz
dico-cda4f4b9026f80af50289a56706877dfa6ef41e5.tar.bz2
Minor fixes
* dicod/tests/echo.c: Avoid pointer-to-integer conversions. * modinc: Fix docs. * modules/pcre/module.ac: Make sure -lpcre is not added to LIBS.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--dicod/tests/echo.c38
-rwxr-xr-xmodinc10
-rw-r--r--modules/pcre/Makefile.am2
-rw-r--r--modules/pcre/module.ac4
4 files changed, 35 insertions, 19 deletions
diff --git a/dicod/tests/echo.c b/dicod/tests/echo.c
index ac7571b..579eaf4 100644
--- a/dicod/tests/echo.c
+++ b/dicod/tests/echo.c
@@ -23,9 +23,14 @@
/* This module either returns query strings without any changes (echo mode),
or denies any queries (null mode). */
-/* These constants are used as dico_handle_t, returned by echo_init_db: */
-#define ECHO_ECHO 1 /* Operate in echo mode */
-#define ECHO_NULL 2 /* Operate in null mode */
+enum echo_mode {
+ ECHO_ECHO, /* Operate in echo mode */
+ ECHO_NULL /* Operate in null mode */
+};
+
+struct echo_handle {
+ enum echo_mode mode;
+};
static int
echo_init(int argc, char **argv)
@@ -36,22 +41,29 @@ echo_init(int argc, char **argv)
static dico_handle_t
echo_init_db(const char *dbname, int argc, char **argv)
{
- int mode = 0;
-
+ int null_mode = 0;
+ struct echo_handle *hp;
+
struct dico_option init_db_option[] = {
- { DICO_OPTSTR(null), dico_opt_bool, &mode },
+ { DICO_OPTSTR(null), dico_opt_bool, &null_mode },
{ NULL }
};
if (dico_parseopt(init_db_option, argc, argv, 0, NULL))
return NULL;
- return (dico_handle_t) (mode + 1);
+ hp = malloc(sizeof(*hp));
+ if (hp)
+ hp->mode = null_mode ? ECHO_NULL : ECHO_ECHO;
+ else
+ dico_log(L_ERR, 0, "not enough memory");
+ return (dico_handle_t)hp;
}
static int
echo_free_db(dico_handle_t hp)
{
+ free(hp);
return 0;
}
@@ -70,6 +82,7 @@ echo_close(dico_handle_t hp)
static char *
echo_info(dico_handle_t hp)
{
+ struct echo_handle *ep = (struct echo_handle*)hp;
static char *echo_info_str[2] = {
"\
ECHO database.\n\n\
@@ -79,23 +92,25 @@ NULL database.\n\n\
This database returns NULL (no result) to any match and define\n\
requests.\n"
};
- return strdup(echo_info_str[(int)hp == ECHO_NULL]);
+ return strdup(echo_info_str[ep->mode]);
}
static char *
echo_descr(dico_handle_t hp)
{
+ struct echo_handle *ep = (struct echo_handle*)hp;
static char *echo_descr_str[2] = {
"GNU Dico ECHO database",
"GNU Dico NULL database"
};
- return strdup(echo_descr_str[(int)hp == ECHO_NULL]);
+ return strdup(echo_descr_str[ep->mode]);
}
static dico_result_t
echo_match(dico_handle_t hp, const dico_strategy_t strat, const char *word)
{
- if ((int) hp == ECHO_NULL)
+ struct echo_handle *ep = (struct echo_handle*)hp;
+ if (ep->mode == ECHO_NULL)
return NULL;
return (dico_result_t) strdup(word);
}
@@ -103,7 +118,8 @@ echo_match(dico_handle_t hp, const dico_strategy_t strat, const char *word)
static dico_result_t
echo_define(dico_handle_t hp, const char *word)
{
- if ((int) hp == ECHO_NULL)
+ struct echo_handle *ep = (struct echo_handle*)hp;
+ if (ep->mode == ECHO_NULL)
return NULL;
return (dico_result_t) strdup(word);
}
diff --git a/modinc b/modinc
index 6fe9191..7c1c5e1 100755
--- a/modinc
+++ b/modinc
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# This file is part of GNU Dico
-# Copyright (C) 2014 Sergey Poznyakoff
+# Copyright (C) 2014, 2016 Sergey Poznyakoff
#
# GNU Dico is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -242,19 +242,19 @@ Expands to the name of the module.
=over 4
-=item 0
+=item B<0>
Successful termination.
-=item 64
+=item B<64>
Command line usage error.
-=item 66
+=item B<66>
Can't open input file.
-=item 73
+=item B<73>
Can't create output file.
diff --git a/modules/pcre/Makefile.am b/modules/pcre/Makefile.am
index a379108..5ff67ca 100644
--- a/modules/pcre/Makefile.am
+++ b/modules/pcre/Makefile.am
@@ -1,5 +1,5 @@
# This file is part of GNU Dico
-# Copyright (C) 2010, 2012 Sergey Poznyakoff
+# Copyright (C) 2010, 2012, 2016 Sergey Poznyakoff
#
# GNU Dico is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/modules/pcre/module.ac b/modules/pcre/module.ac
index 819ab34..fa5b963 100644
--- a/modules/pcre/module.ac
+++ b/modules/pcre/module.ac
@@ -1,5 +1,5 @@
## This file is part of GNU Dico
-## Copyright (C) 2014 Sergey Poznyakoff
+## Copyright (C) 2014, 2016 Sergey Poznyakoff
##
## GNU Dico is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ esac],[status_pcre=yes])
if test $status_pcre = yes; then
AC_CHECK_HEADER([pcre.h], [], [status_pcre=no])
if test $status_pcre = yes; then
- DICO_CHECK_LIB(pcre, main, [],
+ DICO_CHECK_LIB(pcre, main, [:],
[],
[status_pcre=no])
fi

Return to:

Send suggestions and report system problems to the System administrator.