aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-07-28 13:48:23 +0300
committerSergey Poznyakoff <gray@gnu.org>2016-07-28 13:48:23 +0300
commitcda4f4b9026f80af50289a56706877dfa6ef41e5 (patch)
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.
-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
@@ -20,41 +20,53 @@
#include <dico.h>
#include <string.h>
/* 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)
{
return 0;
}
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;
}
static int
echo_open(dico_handle_t dp)
{
@@ -67,46 +79,50 @@ echo_close(dico_handle_t hp)
return 0;
}
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\
This database echoes each query.\n",
"\
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);
}
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);
}
static int
echo_output_result (dico_result_t rp, size_t n, dico_stream_t str)
diff --git a/modinc b/modinc
index 6fe9191..7c1c5e1 100755
--- a/modinc
+++ b/modinc
@@ -1,9 +1,9 @@
#! /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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
@@ -239,25 +239,25 @@ Expands to the name of the module.
=back
=head1 EXIT CODES
=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.
=back
=head1 BUGS
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,8 +1,8 @@
# 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
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
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,8 +1,8 @@
## 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
## the Free Software Foundation; either version 3, or (at your option)
## any later version.
##
@@ -26,12 +26,12 @@ case "${withval}" in
*) AC_MSG_ERROR(bad value ${withval} for --with-pcre) ;;
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
fi
AM_CONDITIONAL([PCRE_COND],[test $status_pcre = yes])

Return to:

Send suggestions and report system problems to the System administrator.