Commit 8d588698 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Prepare to use readline

parent 4b96b39c
Pipeline #66929 passed with stage
in 50 seconds
......@@ -16,8 +16,6 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
!m4/ax_code_coverage.m4
#*#
*.a
*.dirstamp
*.gcda
......
......@@ -3,7 +3,7 @@ image: tarotbis/build:latest
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget gengetopt help2man
- apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget gengetopt help2man libreadline-dev libunistring-dev
stages:
- deploy
......
FROM debian:stable
RUN apt-get update
RUN apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget gengetopt help2man
RUN apt-get install -y --no-install-recommends texlive-base texlive-latex-base git ca-certificates texlive-fonts-recommended texlive-generic-recommended autoconf automake gettext autopoint libtool texinfo gnulib autoconf-archive gobject-introspection make gcc valac valac-vapi gtk-doc-tools flex bison gperf nettle-dev libgtk-3-dev libgirepository1.0-dev emacs org-mode indent doxygen graphviz lcov dejagnu check libxml2-utils xsltproc wget gengetopt help2man libreadline-dev libunistring-dev
RUN apt-get upgrade -y
MAINTAINER framagit.org/gugurumbe/tarot
\ No newline at end of file
......@@ -18,6 +18,7 @@ AC_PREREQ([2.69])
AC_INIT([tarot], [devel], [vivien@planete-kraus.eu])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_MACRO_DIRS([custom-m4])
AC_PROG_CC
AC_PROG_CC_STDC
......@@ -25,44 +26,12 @@ AM_INIT_AUTOMAKE
AM_PROG_AR
LT_INIT
AX_CODE_COVERAGE
AC_ARG_ENABLE([gperf], AS_HELP_STRING([--disable-gperf],
[Do not use the gperf hash table generator]))
AS_IF([test "x$enable_gperf" != "xno"], [
dnl Do not AC_PROG_LEX, since it cannot be conditionalized
AC_PATH_PROG([GPERF], [gperf], [no])
AS_IF([test "x$GPERF" != xno], [
GPERF_FOUND="yes"
])
])
AM_CONDITIONAL([HAVE_GPERF], [test "x$GPERF_FOUND" = xyes])
AC_ARG_ENABLE([flex], AS_HELP_STRING([--disable-flex],
[Do not use the flex scanner generator]))
AS_IF([test "x$enable_flex" != "xno"], [
dnl Do not AC_PROG_LEX, since it cannot be conditionalized
AC_PATH_PROG([FLEX], [flex], [no])
AS_IF([test "x$FLEX" != xno], [
FLEX_FOUND="yes"
])
])
AM_CONDITIONAL([HAVE_FLEX], [test "x$FLEX_FOUND" = xyes])
AC_ARG_ENABLE([bison], AS_HELP_STRING([--disable-bison],
[Do not use the bison parser generator]))
AS_IF([test "x$enable_bison" != "xno"], [
AC_PATH_PROG([BISON], [bison], [no])
AS_IF([test "x$BISON" != xno], [
BISON_FOUND="yes"
])
])
AM_CONDITIONAL([HAVE_BISON], [test "x$BISON_FOUND" = xyes])
AC_ARG_ENABLE([gengetopt], AS_HELP_STRING([--disable-gengetopt],
[Do not use the gengetopt parser generator]))
AS_IF([test "x$enable_gengetopt" != "xno"], [
AC_PATH_PROG([GENGETOPT], [gengetopt], [no])
AS_IF([test "x$GENGETOPT" != xno], [
GENGETOPT_FOUND="yes"
])
])
AM_CONDITIONAL([HAVE_GENGETOPT], [test "x$GENGETOPT_FOUND" = xyes])
AM_MISSING_PROG([GPERF], [gperf])
AM_MISSING_PROG([FLEX], [flex])
AM_MISSING_PROG([BISON], [bison])
AM_MISSING_PROG([GENGETOPT], [gengetopt])
AM_MISSING_PROG([HELP2MAN], [help2man])
AM_MISSING_PROG([INDENT], [indent])
AC_ARG_ENABLE([valgrind], AS_HELP_STRING([--enable-valgrind=yes],
[Run the unit tests under valgrind (slow, incompatible with asan)]))
AS_IF([test "x$enable_valgrind" = "xyes"], [
......@@ -75,19 +44,6 @@ AS_IF([test "x$enable_valgrind" = "xyes"], [
])
])
AM_CONDITIONAL([HAVE_VALGRIND], [test "x$HAVE_VALGRIND" = "xyes"])
AC_ARG_ENABLE([help2man], AS_HELP_STRING([--disable-help2man],
[Do not use the help2man generator for manual pages]))
AS_IF([test "x$enable_help2man" != "xno"], [
AC_PATH_PROG([HELP2MAN], [help2man], [no])
AS_IF([test "x$HELP2MAN" != xno], [
HELP2MAN_FOUND="yes"
])
])
AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN_FOUND" = xyes])
AC_ARG_ENABLE([indent],
AS_HELP_STRING([--disable-indent], [Disable GNU indent]))
AS_IF([test "x$enable_indent" != "xno"],
[AC_PATH_PROG([INDENT], [indent], [indent])])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.19])
......@@ -95,58 +51,27 @@ AM_GNU_GETTEXT_VERSION([0.19])
AC_ARG_WITH([asan], AS_HELP_STRING([--with-asan=yes],
[Enforce AddressSanitizer]))
AS_IF([test "$with_asan" = "xyes"], [
PKG_CHECK_MODULES([asan], [asan], [], [
AC_MSG_WARN([Could not find asan in pkg-config...])
])
NORMAL_CFLAGS="$CFLAGS"
NORMAL_LIBS="$LIBS"
CFLAGS="$NORMAL_CFLAGS $asan_CFLAGS"
LIBS="$NORMAL_LIBS $asan_LIBS"
FOUND_HEADERS="yes"
FOUND_FUNCTIONS="yes"
AC_CHECK_FUNC([malloc], [], [FOUND_FUNCTIONS="no"])
AS_IF([test "x$FOUND_HEADERS" != xno && test "x$FOUND_FUNCTIONS" != xno], [
FOUND="yes"
], [
FOUND="no"
])
CFLAGS="$NORMAL_CFLAGS"
LIBS="$NORMAL_LIBS"
AS_IF([test "x$FOUND" = "xno"], [
AC_MSG_ERROR([ASAN is not working, pass --without-asan (you may want to try valgrind).])
AX_TAROT_PACKAGE([asan], [asan], [-fsanitize=address], [-lasan], [], [malloc], [], [
AC_MSG_ERROR([ASAN is not working.])
])
])
AC_ARG_WITH([libunistring], AS_HELP_STRING([--with-libunistring=yex],
AC_ARG_WITH([libunistring], AS_HELP_STRING([--with-libunistring=yes],
[Try to link with libunistring (default: if available)]))
AS_IF([test "x$with_libunistring" != "xno"], [
PKG_CHECK_MODULES([libunistring], [libunistring], [], [
AC_MSG_WARN([Could not find libunistring in pkg-config...])
])
NORMAL_CFLAGS="$CFLAGS"
NORMAL_LIBS="$LIBS"
CFLAGS="$NORMAL_CFLAGS $libunistring_CFLAGS"
LIBS="$NORMAL_LIBS $libunistring_LIBS"
FOUND_HEADERS="yes"
FOUND_FUNCTIONS="yes"
AC_CHECK_HEADER([unistr.h], [], [FOUND_HEADERS="no"])
AC_CHECK_FUNC([u8_mblen], [], [FOUND_FUNCTIONS="no"])
AS_IF([test "x$FOUND_HEADERS" != xno && test "x$FOUND_FUNCTIONS" != xno], [
FOUND="yes"
], [
FOUND="no"
])
CFLAGS="$NORMAL_CFLAGS"
LIBS="$NORMAL_LIBS"
AS_IF([test "x$FOUND" = "xno" && test "x$with_libunistring" = "xyes"], [
AC_MSG_ERROR([Libunistring is requested, but not usable. Pass --without-libunistring.])
])
AX_TAROT_PACKAGE([libunistring], [libunistring], [], [-lunistring],
[], [u8_mblen], [
AC_DEFINE([HAVE_LIBUNISTRING], [1], [Headers and functions of libunistring are available])
], [
AC_DEFINE([HAVE_LIBUNISTRING], [0], [Some headers or functions of libunistring are not available])
AS_IF([test "x$with_libunistring" = "xyes"], [
AC_MSG_ERROR([libunistring is not working.])
])
])
])
AS_IF([test "x$FOUND" = "xyes"], [
AC_DEFINE([HAVE_LIBUNISTRING], [1], [Headers and functions of libunistring are available])
], [
AC_DEFINE([HAVE_LIBUNISTRING], [0], [Some headers or functions of libunistring are not available])
AX_TAROT_PACKAGE([readline], [readline], [], [-lreadline], [readline/readline.h], [readline], [], [
AC_MSG_ERROR([readline is not working.])
])
AC_MSG_CHECKING([for a way to recover from an unused but set variable])
......
dnl AX_TAROT_PACKAGE(package_var, package, sensible_cflags,
dnl sensible_libs, headers, functions, action_if_found,
dnl action_if_not_found)
AC_DEFUN([AX_TAROT_PACKAGE], [
SAVED_CFLAGS="$CFLAGS"
SAVED_LIBS="$LIBS"
PKG_CHECK_MODULES([$1], [$2], [], [
AC_MSG_WARN([Could not find [$1] with pkg-config... Trying sensible defaults.])
$1_CFLAGS="[$3]"
$1_LIBS="[$4]"
])
CFLAGS="$SAVED_FLAGS $$1_CFLAGS"
LIBS="$SAVED_LIBS $$1_LIBS"
FOUND_HEADERS="yes"
FOUND_FUNCTION="yes"
m4_foreach_w([header], [$5], [
AC_CHECK_HEADER([header], [], [FOUND_HEADERS="no"])
])
m4_foreach_w([function], [$6], [
AC_CHECK_FUNC([function], [], [FOUND_FUNCTIONS="no"])
])
CFLAGS="$SAVED_CFLAGS"
LIBS="$SAVED_LIBS"
AC_SUBST([$1_CFLAGS])
AC_SUBST([$1_LIBS])
AS_IF([test "x$FOUND_HEADERS" != "xno" && test "x$FOUND_FUNCTIONS" != "xno"], [$7], [$8])
])
......@@ -5,10 +5,8 @@
# First, install on the system
./configure CFLAGS="-Wall -Wextra -g -O0" \
YFLAGS="--report=all" \
GUILE_2_0_CFLAGS="$(/usr/bin/guile-config compile)" \
GUILE_2_0_LIBS="$(/usr/bin/guile-config link)" \
--enable-silent-rules=yes \
|| exit 1
|| (cat config.log ; exit 1)
make -j 16
# Do not dist nor check!
make -j 16 install
......@@ -17,15 +15,13 @@ make -j 16 install
export PATH="$PATH:/usr/local/bin"
./configure CFLAGS="-Wall -Wextra -g -O0" \
YFLAGS="--report=all" \
GUILE_2_0_CFLAGS="$(/usr/bin/guile-config compile)" \
GUILE_2_0_LIBS="$(/usr/bin/guile-config link)" \
--enable-asan=yes \
--prefix="$PWD/public" \
--enable-silent-rules=yes \
--enable-code-coverage=yes \
|| exit 1
|| (cat config.log; exit 1)
make -j 16 || exit 1
make -j 16 check || (cat test-suite.log && exit 1)
make -j 16 check || (cat test-suite.log; exit 1)
make -j 16 distcheck || exit 1
make -j 16 install-html || exit 1
make -j 16 install-pdf || exit 1
......
......@@ -24,10 +24,11 @@ EXTRA_DIST += \
%reldir%/cards.csv \
%reldir%/tarot.l.prefix \
%reldir%/tarot.l \
%reldir%/tarot.c \
%reldir%/cards.c
%canon_reldir%_liblibtarot_cards_la_SOURCES = \
%reldir%/tarot.c
%reldir%/implementation.c
%canon_reldir%_liblibtarot_cards_la_CFLAGS = \
$(asan_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
......@@ -81,6 +82,8 @@ LIBLIBTAROT_CARDS_LA = %reldir%/liblibtarot-cards.la
$(srcdir)/%reldir%/tarot.l.prefix \
$(srcdir)/%reldir%/cards.csv
%reldir%/implementation.c: %reldir%/tarot.c
%reldir%/cards.c: %reldir%/cards.csv Makefile.am
$(AM_V_GEN) ( \
echo "/* Generated from %reldir%/tarot.csv */" > $(srcdir)/%reldir%/cards.c \
......@@ -91,14 +94,6 @@ LIBLIBTAROT_CARDS_LA = %reldir%/liblibtarot-cards.la
&& echo " };" >> $(srcdir)/%reldir%/cards.c \
)
if HAVE_GPERF
%reldir%/tarot.c: %reldir%/tarot.l %reldir%/cards.c
$(AM_V_GEN) $(GPERF) $(PFLAGS) --output $(srcdir)/%reldir%/tarot.c \
$(srcdir)/%reldir%/tarot.l
else
%reldir%/tarot.c: %reldir%/tarot.l %reldir%/cards.c
@ >&2 echo "Error: gperf is required to update the card lookup function." \
&& >&2 echo "Re-run configure with --enable-gperf=yes" \
&& >&2 echo "If you were running \`make distcheck', this is a bug." \
&& exit 1
endif
/**
* file implementation libtarot gperf definitions.
*
* Copyright (C) 2018 Vivien Kraus <vivien@planete-kraus.eu>
*
* This program 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 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "tarot.c"
TarotCard
tarot_string_to_card (const char *text)
{
const struct record *rec = in_word_set (text, strlen (text));
if (rec == NULL)
{
return (TarotCard) (-1);
}
return rec->card;
}
size_t
tarot_card_to_string (TarotCard c, size_t max, char *dest)
{
if (c < 78)
{
const char *value = names[c];
size_t i = 0, len = strlen (value);
for (i = 0; i < max && i < len; i++)
{
if (i < max)
{
dest[i] = value[i];
}
}
if (len < max)
{
dest[len] = '\0';
}
else if (max > 0)
{
dest[max - 1] = '\0';
}
return len;
}
return 0;
}
......@@ -31,46 +31,6 @@ struct record
TarotCard card;
};
static const struct record *in_word_set (const char *, unsigned int);
TarotCard
tarot_string_to_card (const char *text)
{
const struct record *rec = in_word_set (text, strlen (text));
if (rec == NULL)
{
return (TarotCard) (-1);
}
return rec->card;
}
size_t
tarot_card_to_string (TarotCard c, size_t max, char *dest)
{
if (c < 78)
{
const char *value = names[c];
size_t i = 0, len = strlen (value);
for (i = 0; i < max && i < len; i++)
{
if (i < max)
{
dest[i] = value[i];
}
}
if (len < max)
{
dest[len] = '\0';
}
else if (max > 0)
{
dest[max - 1] = '\0';
}
return len;
}
return 0;
}
/* *INDENT-OFF* */
%}
......
......@@ -74,14 +74,6 @@ LIBLIBTAROT_LEXER_LA = %reldir%/liblibtarot-lexer.la
%reldir%/implementation.c: %reldir%/tarot.c
if HAVE_FLEX
%reldir%/tarot.c: %reldir%/tarot.l
$(AM_V_GEN) $(FLEX) $(LEXFLAGS) --outfile=$(srcdir)/%reldir%/tarot.c \
$(srcdir)/%reldir%/tarot.l
else
%reldir%/tarot.c: %reldir%/tarot.l
@ >&2 echo "Error: flex is required to update the lexer." \
&& >&2 echo "Re-run configure with --enable-flex=yes" \
&& >&2 echo "If you were running \`make distcheck', this is a bug." \
&& exit 1
endif
......@@ -74,14 +74,6 @@ LIBLIBTAROT_PARSER_LA = %reldir%/liblibtarot-parser.la
%reldir%/implementation.c: %reldir%/tarot.c
if HAVE_BISON
%reldir%/tarot.c: %reldir%/tarot.y
$(AM_V_GEN) $(BISON) $(YFLAGS) -o $(srcdir)/%reldir%/tarot.c \
$(srcdir)/%reldir%/tarot.y
else
%reldir%/tarot.c: %reldir%/tarot.y
@ >&2 echo "Error: bison is required to update the parser." \
&& >&2 echo "Re-run configure with --enable-bison=yes" \
&& >&2 echo "If you were running \`make distcheck', this is a bug." \
&& exit 1
endif
......@@ -70,28 +70,11 @@ INDENTED += \
$(%canon_reldir%_libcmdline_la_SOURCES) \
$(%canon_reldir%_tarot_SOURCES)
if HAVE_GENGETOPT
%reldir%/cmdline.c %reldir%/cmdline.h: %reldir%/tarot.gg
$(AM_V_GEN) (cd $(srcdir)/%reldir% && $(GENGETOPT) < tarot.gg)
else
%reldir%/cmdline.c %reldir%/cmdline.h: %reldir%/tarot.gg
@ >&2 echo "Error: gengetopt is required to update the parser." \
&& >&2 echo "Re-run configure with --enable-gengetopt=yes" \
&& >&2 echo "If you were running \`make distcheck', this is a bug." \
&& exit 1
endif
if HAVE_HELP2MAN
%reldir%/tarot.6.gz: $(%canon_reldir%_tarot_SOURCES) $(%canon_reldir%_libcmdline_la_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) %reldir%/tarot
$(AM_V_GEN) ($(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=execute $(HELP2MAN) %reldir%/tarot \
| GZIP=$(GZIP_ENV) gzip > $(srcdir)/%reldir%/tarot.6.gz) \
|| (>&2 echo "Please refer to README regarding introspection and cross-compilation." \
&& exit 1)
else
%reldir%/tarot.6.gz: $(%canon_reldir%_tarot_SOURCES) $(%canon_reldir%_libcmdline_la_SOURCES)
@ >&2 echo "Error: help2man is required to update the man page." \
&& >&2 echo "Re-run configure with --enable-gengetopt=yes" \
&& exit 1
endif
| GZIP=$(GZIP_ENV) gzip > $(srcdir)/%reldir%/tarot.6.gz)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment