mirror of
https://https.git.savannah.gnu.org/git/gettext.git
synced 2026-01-26 15:39:11 +00:00
build: Remove expat dependency
* DEPENDENCIES: Suggest libxml2 instead of expat. * gnulib-local/lib/markup.c: New file. * gnulib-local/lib/markup.h: New file. * gnulib-local/modules/markup: New file. * autogen.sh (GNULIB_MODULES_LIBGETTEXTPO): Add markup module. * gettext-tools/configure.ac: Remove checks for expat. * gettext-tools/gnulib-lib/.gitignore: Ignore modules pulled by gnulib-tool due to the markup module usage. * gettext-tools/gnulib-tests/.gitignore: Likewise. * gettext-tools/libgettextpo/.gitignore: Likewise. * gettext-tools/libgettextpo/Makefile.am (libgettextpo_la_AUXSOURCES): Remove ../src/libexpat-compat.c. (libgettextpo_la_LDFLAGS): Remove @LTLIBEXPAT@. * gettext-tools/src/Makefile.am (noinst_HEADERS): Remove libexpat-compat.h. (libgettextsrc_la_SOURCES): Remove libexpat-compat.c. (libgettextsrc_la_LDFLAGS): Remove @LTLIBEXPAT@. * gettext-tools/src/format-kde-kuit.c: Use functions from markup.h, when the file is being compiled as part of libgettextpo. Otherwise use libxml2. * gettext-tools/src/libexpat-compat.c: Remove. * gettext-tools/src/libexpat-compat.h: Remove.
This commit is contained in:
parent
f6dde6baee
commit
898e184a59
1
.gitignore
vendored
1
.gitignore
vendored
@ -43,6 +43,7 @@ Makefile
|
||||
/gettext-tools/examples/ChangeLog
|
||||
/gettext-tools/po/ChangeLog
|
||||
|
||||
/build-aux/ar-lib
|
||||
/build-aux/git-version-gen
|
||||
/build-aux/gitlog-to-changelog
|
||||
/build-aux/snippet
|
||||
|
||||
10
DEPENDENCIES
10
DEPENDENCIES
@ -28,15 +28,15 @@ The following packages should be installed before GNU gettext is installed
|
||||
+ If it is installed in a nonstandard directory, pass the option
|
||||
--with-ncurses-prefix=DIR or --with-libtermcap-prefix to 'configure'.
|
||||
|
||||
* expat 1.95 or newer
|
||||
* libxml
|
||||
+ Recommended.
|
||||
Needed for 'xgettext', so that it can parse Glade XML files.
|
||||
Needed for 'xgettext' and 'msgfmt', so that it can parse XML files.
|
||||
+ Homepage:
|
||||
http://expat.sourceforge.net/
|
||||
http://xmlsoft.org/
|
||||
+ Download:
|
||||
http://sourceforge.net/project/showfiles.php?group_id=10127
|
||||
ftp://xmlsoft.org/
|
||||
+ If it is installed in a nonstandard directory, pass the option
|
||||
--with-libexpat-prefix to 'configure'.
|
||||
--with-libxml2-prefix to 'configure'.
|
||||
|
||||
* A Java runtime and compiler (e.g. GNU gcj or kaffe).
|
||||
+ Recommended.
|
||||
|
||||
@ -342,6 +342,7 @@ if ! $skip_gnulib; then
|
||||
hash
|
||||
iconv
|
||||
libunistring-optional
|
||||
markup
|
||||
minmax
|
||||
open
|
||||
ostream
|
||||
|
||||
@ -291,25 +291,6 @@ AH_BOTTOM([
|
||||
#endif
|
||||
])
|
||||
|
||||
dnl Check for the expat XML parser.
|
||||
dnl On operating systems where binary distribution vendors are likely to
|
||||
dnl ship both gettext and expat, we use dynamic loading to avoid a hard
|
||||
dnl dependency from gettext to expat.
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_DEFINE([DYNLOAD_LIBEXPAT], [1],
|
||||
[Define to 1 if libexpat shall be dynamically loaded via dlopen().])
|
||||
LIBEXPAT="-ldl"
|
||||
LTLIBEXPAT="-ldl"
|
||||
AC_SUBST([LIBEXPAT])
|
||||
AC_SUBST([LTLIBEXPAT])
|
||||
;;
|
||||
*)
|
||||
AC_LIB_HAVE_LINKFLAGS([expat], [],
|
||||
[#include <expat.h>], [XML_ExpatVersion();])
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Check for nm output filter that yields the exported symbols.
|
||||
gt_GLOBAL_SYMBOL_PIPE
|
||||
|
||||
|
||||
92
gettext-tools/gnulib-lib/.gitignore
vendored
92
gettext-tools/gnulib-lib/.gitignore
vendored
@ -10,7 +10,14 @@
|
||||
/uniwidth
|
||||
|
||||
# Files brought in by gnulib-tool:
|
||||
|
||||
|
||||
|
||||
# Files generated by gperf:
|
||||
# Files generated by moopp:
|
||||
# Files generated by the autotools:
|
||||
/Makefile.gnulib
|
||||
/Makefile.in
|
||||
/acl-errno-valid.c
|
||||
/acl-internal.c
|
||||
/acl-internal.h
|
||||
@ -90,13 +97,21 @@
|
||||
/fcntl.in.h
|
||||
/fd-hook.c
|
||||
/fd-hook.h
|
||||
/fd-ostream.c
|
||||
/fd-ostream.h
|
||||
/fd-ostream.oo.c
|
||||
/fd-ostream.oo.h
|
||||
/fd-safer-flag.c
|
||||
/fd-safer.c
|
||||
/fd_ostream.priv.h
|
||||
/fd_ostream.vt.h
|
||||
/file-has-acl.c
|
||||
/file-ostream.c
|
||||
/file-ostream.h
|
||||
/file-ostream.oo.c
|
||||
/file-ostream.oo.h
|
||||
/file_ostream.priv.h
|
||||
/file_ostream.vt.h
|
||||
/filename.h
|
||||
/findprog.c
|
||||
/findprog.h
|
||||
@ -132,6 +147,8 @@
|
||||
/gl_anylinked_list2.h
|
||||
/gl_array_list.c
|
||||
/gl_array_list.h
|
||||
/gl_linked_list.c
|
||||
/gl_linked_list.h
|
||||
/gl_linkedhash_list.c
|
||||
/gl_linkedhash_list.h
|
||||
/gl_list.c
|
||||
@ -142,18 +159,31 @@
|
||||
/glibconfig.in.h
|
||||
/hash.c
|
||||
/hash.h
|
||||
/html-ostream.c
|
||||
/html-ostream.h
|
||||
/html-ostream.oo.c
|
||||
/html-ostream.oo.h
|
||||
/html-styled-ostream.c
|
||||
/html-styled-ostream.h
|
||||
/html-styled-ostream.oo.c
|
||||
/html-styled-ostream.oo.h
|
||||
/html_ostream.priv.h
|
||||
/html_ostream.vt.h
|
||||
/html_styled_ostream.priv.h
|
||||
/html_styled_ostream.vt.h
|
||||
/iconv.c
|
||||
/iconv.in.h
|
||||
/iconv_close.c
|
||||
/iconv_open-aix.gperf
|
||||
/iconv_open-aix.h
|
||||
/iconv_open-hpux.gperf
|
||||
/iconv_open-hpux.h
|
||||
/iconv_open-irix.gperf
|
||||
/iconv_open-irix.h
|
||||
/iconv_open-osf.gperf
|
||||
/iconv_open-osf.h
|
||||
/iconv_open-solaris.gperf
|
||||
/iconv_open-solaris.h
|
||||
/iconv_open.c
|
||||
/iconveh.h
|
||||
/ignore-value.h
|
||||
@ -180,6 +210,8 @@
|
||||
/malloca.c
|
||||
/malloca.h
|
||||
/malloca.valgrind
|
||||
/markup.c
|
||||
/markup.h
|
||||
/mbchar.c
|
||||
/mbchar.h
|
||||
/mbiter.c
|
||||
@ -210,8 +242,12 @@
|
||||
/obstack.h
|
||||
/open.c
|
||||
/opendir.c
|
||||
/ostream.c
|
||||
/ostream.h
|
||||
/ostream.oo.c
|
||||
/ostream.oo.h
|
||||
/ostream.priv.h
|
||||
/ostream.vt.h
|
||||
/pathmax.h
|
||||
/pipe-filter-aux.c
|
||||
/pipe-filter-aux.h
|
||||
@ -319,8 +355,12 @@
|
||||
/strstr.c
|
||||
/strtol.c
|
||||
/strtoul.c
|
||||
/styled-ostream.c
|
||||
/styled-ostream.h
|
||||
/styled-ostream.oo.c
|
||||
/styled-ostream.oo.h
|
||||
/styled_ostream.priv.h
|
||||
/styled_ostream.vt.h
|
||||
/sys_select.in.h
|
||||
/sys_socket.in.h
|
||||
/sys_stat.in.h
|
||||
@ -329,10 +369,18 @@
|
||||
/sys_wait.in.h
|
||||
/tempname.c
|
||||
/tempname.h
|
||||
/term-ostream.c
|
||||
/term-ostream.h
|
||||
/term-ostream.oo.c
|
||||
/term-ostream.oo.h
|
||||
/term-styled-ostream.c
|
||||
/term-styled-ostream.h
|
||||
/term-styled-ostream.oo.c
|
||||
/term-styled-ostream.oo.h
|
||||
/term_ostream.priv.h
|
||||
/term_ostream.vt.h
|
||||
/term_styled_ostream.priv.h
|
||||
/term_styled_ostream.vt.h
|
||||
/terminfo.h
|
||||
/time.in.h
|
||||
/tmpdir.c
|
||||
@ -389,47 +437,3 @@
|
||||
/xstriconveh.h
|
||||
/xvasprintf.c
|
||||
/xvasprintf.h
|
||||
|
||||
# Files generated by the autotools:
|
||||
/Makefile.in
|
||||
|
||||
# Files generated by gperf:
|
||||
/iconv_open-aix.h
|
||||
/iconv_open-hpux.h
|
||||
/iconv_open-irix.h
|
||||
/iconv_open-osf.h
|
||||
/iconv_open-solaris.h
|
||||
|
||||
# Files generated by moopp:
|
||||
/fd-ostream.c
|
||||
/fd-ostream.h
|
||||
/fd_ostream.priv.h
|
||||
/fd_ostream.vt.h
|
||||
/file-ostream.c
|
||||
/file-ostream.h
|
||||
/file_ostream.priv.h
|
||||
/file_ostream.vt.h
|
||||
/html-ostream.c
|
||||
/html-ostream.h
|
||||
/html-styled-ostream.c
|
||||
/html-styled-ostream.h
|
||||
/html_ostream.priv.h
|
||||
/html_ostream.vt.h
|
||||
/html_styled_ostream.priv.h
|
||||
/html_styled_ostream.vt.h
|
||||
/ostream.c
|
||||
/ostream.h
|
||||
/ostream.priv.h
|
||||
/ostream.vt.h
|
||||
/styled-ostream.c
|
||||
/styled-ostream.h
|
||||
/styled_ostream.priv.h
|
||||
/styled_ostream.vt.h
|
||||
/term-ostream.c
|
||||
/term-ostream.h
|
||||
/term-styled-ostream.c
|
||||
/term-styled-ostream.h
|
||||
/term_ostream.priv.h
|
||||
/term_ostream.vt.h
|
||||
/term_styled_ostream.priv.h
|
||||
/term_styled_ostream.vt.h
|
||||
|
||||
1
gettext-tools/gnulib-tests/.gitignore
vendored
1
gettext-tools/gnulib-tests/.gitignore
vendored
@ -116,6 +116,7 @@
|
||||
/test-inttypes.c
|
||||
/test-iswblank.c
|
||||
/test-langinfo.c
|
||||
/test-linked_list.c
|
||||
/test-linkedhash_list.c
|
||||
/test-locale.c
|
||||
/test-localename.c
|
||||
|
||||
56
gettext-tools/libgettextpo/.gitignore
vendored
56
gettext-tools/libgettextpo/.gitignore
vendored
@ -11,15 +11,13 @@
|
||||
# Files brought in by gnulib-tool:
|
||||
/Makefile.gnulib
|
||||
/alignof.h
|
||||
/alloca.h
|
||||
/alloca.in.h
|
||||
/arg-nonnull.h
|
||||
/asnprintf.c
|
||||
/asprintf.c
|
||||
/basename.c
|
||||
/basename.h
|
||||
/charset.alias
|
||||
/close.c
|
||||
/configmake.h
|
||||
/c++defs.h
|
||||
/c-ctype.c
|
||||
/c-ctype.h
|
||||
@ -29,9 +27,12 @@
|
||||
/c-strncasecmp.c
|
||||
/c-strstr.c
|
||||
/c-strstr.h
|
||||
/charset.alias
|
||||
/close.c
|
||||
/concat-filename.c
|
||||
/concat-filename.h
|
||||
/config.charset
|
||||
/configmake.h
|
||||
/diffseq.h
|
||||
/dosname.h
|
||||
/errno.in.h
|
||||
@ -42,6 +43,7 @@
|
||||
/exitfail.c
|
||||
/exitfail.h
|
||||
/exported.sh
|
||||
/fcntl.h
|
||||
/fcntl.in.h
|
||||
/fd-hook.c
|
||||
/fd-hook.h
|
||||
@ -61,12 +63,21 @@
|
||||
/gcd.h
|
||||
/getdelim.c
|
||||
/getline.c
|
||||
/gettext.h
|
||||
/gettext-po.h
|
||||
/gettext.h
|
||||
/gettimeofday.c
|
||||
/gl_anylinked_list1.h
|
||||
/gl_anylinked_list2.h
|
||||
/gl_linked_list.c
|
||||
/gl_linked_list.h
|
||||
/gl_list.c
|
||||
/gl_list.h
|
||||
/gl_xlist.c
|
||||
/gl_xlist.h
|
||||
/hash.c
|
||||
/hash.h
|
||||
/iconv.c
|
||||
/iconv.h
|
||||
/iconv.in.h
|
||||
/iconv_close.c
|
||||
/iconv_open-aix.gperf
|
||||
@ -85,6 +96,8 @@
|
||||
/malloca.c
|
||||
/malloca.h
|
||||
/malloca.valgrind
|
||||
/markup.c
|
||||
/markup.h
|
||||
/mbrtowc.c
|
||||
/mbsinit.c
|
||||
/mbswidth.c
|
||||
@ -113,10 +126,13 @@
|
||||
/rawmemchr.c
|
||||
/rawmemchr.valgrind
|
||||
/realloc.c
|
||||
/ref-add.sed
|
||||
/ref-add.sin
|
||||
/ref-del.sed
|
||||
/ref-del.sin
|
||||
/relocatable.c
|
||||
/relocatable.h
|
||||
/signal.h
|
||||
/signal.in.h
|
||||
/sigprocmask.c
|
||||
/size_max.h
|
||||
@ -126,7 +142,10 @@
|
||||
/stddef.in.h
|
||||
/stdint.in.h
|
||||
/stdio-write.c
|
||||
/stdio.c
|
||||
/stdio.h
|
||||
/stdio.in.h
|
||||
/stdlib.h
|
||||
/stdlib.in.h
|
||||
/stpcpy.c
|
||||
/stpncpy.c
|
||||
@ -143,15 +162,19 @@
|
||||
/striconveh.h
|
||||
/striconveha.c
|
||||
/striconveha.h
|
||||
/string.h
|
||||
/string.in.h
|
||||
/strstr.c
|
||||
/sys_stat.in.h
|
||||
/sys_time.in.h
|
||||
/sys_types.in.h
|
||||
/time.h
|
||||
/time.in.h
|
||||
/uniconv.in.h
|
||||
/unictype.in.h
|
||||
/unilbrk.in.h
|
||||
/unistd.c
|
||||
/unistd.h
|
||||
/unistd.in.h
|
||||
/unistr.in.h
|
||||
/unitypes.in.h
|
||||
@ -163,9 +186,11 @@
|
||||
/vasprintf.c
|
||||
/verify.h
|
||||
/warn-on-use.h
|
||||
/wchar.h
|
||||
/wchar.in.h
|
||||
/wctype.in.h
|
||||
/wctype-h.c
|
||||
/wctype.h
|
||||
/wctype.in.h
|
||||
/wcwidth.c
|
||||
/xalloc.h
|
||||
/xasprintf.c
|
||||
@ -185,21 +210,12 @@
|
||||
|
||||
# Files generated by the autotools:
|
||||
/Makefile.in
|
||||
/alloca.h
|
||||
/fcntl.h
|
||||
/iconv.h
|
||||
/ref-add.sed
|
||||
/ref-del.sed
|
||||
/signal.h
|
||||
/stdio.c
|
||||
/stdio.h
|
||||
/stdlib.h
|
||||
/string.h
|
||||
/time.h
|
||||
/unistd.c
|
||||
/unistd.h
|
||||
/wchar.h
|
||||
/wctype.h
|
||||
/uniconv.h
|
||||
/unictype.h
|
||||
/unilbrk.h
|
||||
/unistr.h
|
||||
/unitypes.h
|
||||
/uniwidth.h
|
||||
|
||||
# Files generated by gperf:
|
||||
/iconv_open-aix.h
|
||||
|
||||
@ -41,6 +41,8 @@ AM_CPPFLAGS = \
|
||||
-I../src -I$(top_srcdir)/src \
|
||||
-I../intl -I$(top_srcdir)/../gettext-runtime/intl
|
||||
|
||||
DEFS = -DIN_LIBGETTEXTPO=1 @DEFS@
|
||||
|
||||
# libgettextpo contains the public API for PO files.
|
||||
libgettextpo_la_SOURCES = \
|
||||
gettext-po.c \
|
||||
@ -93,8 +95,7 @@ libgettextpo_la_AUXSOURCES = \
|
||||
../src/plural-exp.c \
|
||||
../src/plural-eval.c \
|
||||
../src/msgl-check.c \
|
||||
../src/sentence.c \
|
||||
../src/libexpat-compat.c
|
||||
../src/sentence.c
|
||||
|
||||
# Libtool's library version information for libgettextpo.
|
||||
# See the libtool documentation, section "Library interface versions".
|
||||
@ -109,7 +110,7 @@ libgettextpo_la_LIBADD = libgnu.la $(WOE32_LIBADD) $(LTLIBUNISTRING)
|
||||
libgettextpo_la_LDFLAGS = \
|
||||
-version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \
|
||||
-rpath $(libdir) \
|
||||
@LTLIBINTL@ @LTLIBICONV@ @LTLIBEXPAT@ -lc -no-undefined
|
||||
@LTLIBINTL@ @LTLIBICONV@ -lc -no-undefined
|
||||
|
||||
# Tell the mingw or Cygwin linker which symbols to export.
|
||||
if WOE32DLL
|
||||
@ -155,7 +156,7 @@ config.h: $(BUILT_SOURCES)
|
||||
sf=`echo "$$f" | sed -e 's,\\.[^.]*$$,,'`.c; \
|
||||
test -f $$sf || sf=$(srcdir)/$$sf; \
|
||||
of=`echo "$$f" | sed -e 's,^.*/,,' -e 's,\\.[^.]*$$,,'`.$(OBJEXT); \
|
||||
$(COMPILE) -c $$sf || { rm -f config.h; exit 1; }; \
|
||||
$(COMPILE) $(DEFS) -c $$sf || { rm -f config.h; exit 1; }; \
|
||||
sh ./exported.sh $$of 1>&5; \
|
||||
rm -f $$of `echo "$$of" | sed -e 's,\\.$(OBJEXT)$$,.lo,'`; \
|
||||
;; \
|
||||
|
||||
@ -56,7 +56,7 @@ po-time.h plural-table.h lang-table.h format.h filters.h \
|
||||
xgettext.h x-c.h x-po.h x-sh.h x-python.h x-lisp.h x-elisp.h x-librep.h \
|
||||
x-scheme.h x-smalltalk.h x-java.h x-properties.h x-csharp.h x-awk.h x-ycp.h \
|
||||
x-tcl.h x-perl.h x-php.h x-stringtable.h x-rst.h x-glade.h x-lua.h \
|
||||
x-javascript.h x-vala.h x-gsettings.h x-desktop.h x-appdata.h libexpat-compat.h
|
||||
x-javascript.h x-vala.h x-gsettings.h x-desktop.h x-appdata.h
|
||||
|
||||
EXTRA_DIST += FILES project-id
|
||||
|
||||
@ -152,7 +152,7 @@ $(COMMON_SOURCE) read-catalog.c \
|
||||
color.c write-catalog.c write-properties.c write-stringtable.c write-po.c \
|
||||
msgl-ascii.c msgl-iconv.c msgl-equal.c msgl-cat.c msgl-header.c msgl-english.c \
|
||||
msgl-check.c file-list.c msgl-charset.c po-time.c plural-exp.c plural-eval.c \
|
||||
plural-table.c quote.h sentence.h sentence.c libexpat-compat.c \
|
||||
plural-table.c quote.h sentence.h sentence.c \
|
||||
$(FORMAT_SOURCE) \
|
||||
read-desktop.c locating-rule.c its.c
|
||||
|
||||
@ -254,7 +254,7 @@ cldr_plurals_LDADD = libgettextsrc.la $(LDADD)
|
||||
# use iconv().
|
||||
libgettextsrc_la_LDFLAGS = \
|
||||
-release @VERSION@ \
|
||||
../gnulib-lib/libgettextlib.la $(LTLIBUNISTRING) @LTLIBINTL@ @LTLIBICONV@ @LTLIBEXPAT@ -lc -no-undefined
|
||||
../gnulib-lib/libgettextlib.la $(LTLIBUNISTRING) @LTLIBINTL@ @LTLIBICONV@ -lc -no-undefined
|
||||
|
||||
libgettextsrc_la_CPPFLAGS = $(AM_CPPFLAGS) $(INCXML)
|
||||
|
||||
|
||||
@ -24,12 +24,28 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "format.h"
|
||||
#include "libexpat-compat.h"
|
||||
#include "unistr.h"
|
||||
#include "xalloc.h"
|
||||
#include "xvasprintf.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#if IN_LIBGETTEXTPO
|
||||
/* Use included markup parser to avoid extra dependency from
|
||||
libgettextpo to libxml2. */
|
||||
# ifndef FORMAT_KDE_KUIT_FALLBACK_MARKUP
|
||||
# define FORMAT_KDE_KUIT_USE_FALLBACK_MARKUP 1
|
||||
# endif
|
||||
#else
|
||||
# define FORMAT_KDE_KUIT_USE_LIBXML2 1
|
||||
#endif
|
||||
|
||||
#if FORMAT_KDE_KUIT_USE_LIBXML2
|
||||
# include <libxml/parser.h>
|
||||
#elif FORMAT_KDE_KUIT_USE_FALLBACK_MARKUP
|
||||
# include "markup.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define _(str) gettext (str)
|
||||
|
||||
#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
@ -48,26 +64,8 @@ struct spec
|
||||
void *base;
|
||||
};
|
||||
|
||||
#if DYNLOAD_LIBEXPAT || HAVE_LIBEXPAT
|
||||
|
||||
#define XML_NS "https://www.gnu.org/s/gettext/kde"
|
||||
|
||||
/* Callback called when <element> is seen. */
|
||||
static void
|
||||
start_element_handler (void *data, const char *name,
|
||||
const char **attributes)
|
||||
{
|
||||
/* Nothing to do for now. We could check text outside of a
|
||||
structuring tag, etc. */
|
||||
}
|
||||
|
||||
/* Callback called when </element> is seen. */
|
||||
static void
|
||||
end_element_handler (void *data, const char *name)
|
||||
{
|
||||
/* Nothing to do. */
|
||||
}
|
||||
|
||||
struct char_range
|
||||
{
|
||||
ucs4_t start;
|
||||
@ -182,8 +180,6 @@ is_reference (const char *input)
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void *
|
||||
format_parse (const char *format, bool translated, char *fdi,
|
||||
@ -191,83 +187,99 @@ format_parse (const char *format, bool translated, char *fdi,
|
||||
{
|
||||
struct spec spec;
|
||||
struct spec *result;
|
||||
const char *str;
|
||||
const char *str_limit;
|
||||
size_t amp_count;
|
||||
char *buffer, *bp;
|
||||
|
||||
spec.base = NULL;
|
||||
|
||||
#if DYNLOAD_LIBEXPAT || HAVE_LIBEXPAT
|
||||
if (LIBEXPAT_AVAILABLE ())
|
||||
/* Preprocess the input, putting the content in a <gt:kuit> element. */
|
||||
str = format;
|
||||
str_limit = str + strlen (format);
|
||||
|
||||
for (amp_count = 0; str < str_limit; amp_count++)
|
||||
{
|
||||
XML_Parser parser;
|
||||
const char *str = format;
|
||||
const char *str_limit = str + strlen (format);
|
||||
size_t amp_count;
|
||||
char *buffer, *bp;
|
||||
const char *amp = strchrnul (str, '&');
|
||||
if (*amp != '&')
|
||||
break;
|
||||
str = amp + 1;
|
||||
}
|
||||
|
||||
for (amp_count = 0; str < str_limit; amp_count++)
|
||||
buffer = xmalloc (amp_count * 4
|
||||
+ strlen (format)
|
||||
+ strlen ("<gt:kuit xmlns:gt=\"" XML_NS "\"></gt:kuit>")
|
||||
+ 1);
|
||||
*buffer = '\0';
|
||||
|
||||
bp = buffer;
|
||||
bp = stpcpy (bp, "<gt:kuit xmlns:gt=\"" XML_NS "\">");
|
||||
str = format;
|
||||
while (str < str_limit)
|
||||
{
|
||||
const char *amp = strchrnul (str, '&');
|
||||
|
||||
bp = stpncpy (bp, str, amp - str);
|
||||
if (*amp != '&')
|
||||
break;
|
||||
|
||||
bp = stpcpy (bp, is_reference (amp) ? "&" : "&");
|
||||
str = amp + 1;
|
||||
}
|
||||
stpcpy (bp, "</gt:kuit>");
|
||||
|
||||
#if FORMAT_KDE_KUIT_USE_LIBXML2
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
|
||||
doc = xmlReadMemory (buffer, strlen (buffer), "", NULL,
|
||||
XML_PARSE_NONET
|
||||
| XML_PARSE_NOWARNING
|
||||
| XML_PARSE_NOERROR
|
||||
| XML_PARSE_NOBLANKS);
|
||||
if (doc == NULL)
|
||||
{
|
||||
const char *amp = strchrnul (str, '&');
|
||||
if (*amp != '&')
|
||||
break;
|
||||
str = amp + 1;
|
||||
xmlError *err = xmlGetLastError ();
|
||||
*invalid_reason =
|
||||
xasprintf (_("error while parsing: %s"),
|
||||
err->message);
|
||||
}
|
||||
|
||||
buffer = xmalloc (amp_count * 4
|
||||
+ strlen (format)
|
||||
+ strlen ("<gt:kuit xmlns:gt=\"" XML_NS "\"></gt:kuit>")
|
||||
+ 1);
|
||||
*buffer = '\0';
|
||||
free (buffer);
|
||||
xmlFreeDoc (doc);
|
||||
}
|
||||
#elif FORMAT_KDE_KUIT_FALLBACK_MARKUP
|
||||
{
|
||||
markup_parser_ty parser;
|
||||
markup_parse_context_ty *context;
|
||||
|
||||
bp = buffer;
|
||||
bp = stpcpy (bp, "<gt:kuit xmlns:gt=\"" XML_NS "\">");
|
||||
str = format;
|
||||
while (str < str_limit)
|
||||
{
|
||||
const char *amp = strchrnul (str, '&');
|
||||
|
||||
bp = stpncpy (bp, str, amp - str);
|
||||
if (*amp != '&')
|
||||
break;
|
||||
|
||||
bp = stpcpy (bp, is_reference (amp) ? "&" : "&");
|
||||
str = amp + 1;
|
||||
}
|
||||
stpcpy (bp, "</gt:kuit>");
|
||||
|
||||
parser = XML_ParserCreate (NULL);
|
||||
if (parser == NULL)
|
||||
{
|
||||
*invalid_reason = xasprintf (_("memory exhausted"));
|
||||
free (buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XML_SetElementHandler (parser,
|
||||
start_element_handler,
|
||||
end_element_handler);
|
||||
|
||||
if (XML_Parse (parser, buffer, strlen (buffer), 0) == 0)
|
||||
memset (&parser, 0, sizeof (markup_parser_ty));
|
||||
context = markup_parse_context_new (&parser, 0, NULL);
|
||||
if (!markup_parse_context_parse (context, buffer, strlen (buffer)))
|
||||
{
|
||||
*invalid_reason =
|
||||
xasprintf (_("error while parsing: %s"),
|
||||
XML_ErrorString (XML_GetErrorCode (parser)));
|
||||
markup_parse_context_get_error (context));
|
||||
free (buffer);
|
||||
XML_ParserFree (parser);
|
||||
markup_parse_context_free (context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (XML_Parse (parser, NULL, 0, 1) == 0)
|
||||
if (!markup_parse_context_end_parse (context))
|
||||
{
|
||||
*invalid_reason =
|
||||
xasprintf (_("error while parsing: %s"),
|
||||
XML_ErrorString (XML_GetErrorCode (parser)));
|
||||
markup_parse_context_get_error (context));
|
||||
free (buffer);
|
||||
XML_ParserFree (parser);
|
||||
markup_parse_context_free (context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
free (buffer);
|
||||
XML_ParserFree (parser);
|
||||
markup_parse_context_free (context);
|
||||
}
|
||||
#else
|
||||
/* No support for XML. */
|
||||
#endif
|
||||
|
||||
spec.base = formatstring_kde.parse (format, translated, fdi, invalid_reason);
|
||||
|
||||
@ -1,327 +0,0 @@
|
||||
/* xgettext libexpat compatibility.
|
||||
Copyright (C) 2002-2003, 2005-2009, 2013, 2015 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
|
||||
|
||||
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/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if DYNLOAD_LIBEXPAT
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# if HAVE_LIBEXPAT
|
||||
# include <expat.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Keep the references to XML_GetCurrent{Line,Column}Number symbols
|
||||
before loading libexpat-compat.h, since they are redefined to
|
||||
rpl_XML_GetCurrent{Line,Column}Number . */
|
||||
#if !DYNLOAD_LIBEXPAT && XML_MAJOR_VERSION >= 2
|
||||
static void *p_XML_GetCurrentLineNumber = (void *) &XML_GetCurrentLineNumber;
|
||||
static void *p_XML_GetCurrentColumnNumber = (void *) &XML_GetCurrentColumnNumber;
|
||||
#endif
|
||||
|
||||
#include "libexpat-compat.h"
|
||||
|
||||
/* ======================= Different libexpat ABIs. ======================= */
|
||||
|
||||
/* There are three different ABIs of libexpat, regarding the functions
|
||||
XML_GetCurrentLineNumber and XML_GetCurrentColumnNumber.
|
||||
In expat < 2.0, they return an 'int'.
|
||||
In expat >= 2.0, they return
|
||||
- a 'long' if expat was compiled with the default flags, or
|
||||
- a 'long long' if expat was compiled with -DXML_LARGE_SIZE.
|
||||
But the <expat.h> include file does not contain the information whether
|
||||
expat was compiled with -DXML_LARGE_SIZE; so the include file is lying!
|
||||
For this information, we need to call XML_GetFeatureList(), for
|
||||
expat >= 2.0.1; for expat = 2.0.0, we have to assume the default flags. */
|
||||
|
||||
#if !DYNLOAD_LIBEXPAT && XML_MAJOR_VERSION >= 2
|
||||
|
||||
/* expat >= 2.0 -> Return type is 'int64_t' worst-case. */
|
||||
|
||||
/* Return true if libexpat was compiled with -DXML_LARGE_SIZE. */
|
||||
static bool
|
||||
is_XML_LARGE_SIZE_ABI (void)
|
||||
{
|
||||
static bool tested;
|
||||
static bool is_large;
|
||||
|
||||
if (!tested)
|
||||
{
|
||||
const XML_Feature *features;
|
||||
|
||||
is_large = false;
|
||||
for (features = XML_GetFeatureList (); features->name != NULL; features++)
|
||||
if (strcmp (features->name, "XML_LARGE_SIZE") == 0)
|
||||
{
|
||||
is_large = true;
|
||||
break;
|
||||
}
|
||||
|
||||
tested = true;
|
||||
}
|
||||
return is_large;
|
||||
}
|
||||
|
||||
int64_t
|
||||
rpl_XML_GetCurrentLineNumber (XML_Parser parser)
|
||||
{
|
||||
if (is_XML_LARGE_SIZE_ABI ())
|
||||
return ((int64_t (*) (XML_Parser)) p_XML_GetCurrentLineNumber) (parser);
|
||||
else
|
||||
return ((long (*) (XML_Parser)) p_XML_GetCurrentLineNumber) (parser);
|
||||
}
|
||||
|
||||
int64_t
|
||||
rpl_XML_GetCurrentColumnNumber (XML_Parser parser)
|
||||
{
|
||||
if (is_XML_LARGE_SIZE_ABI ())
|
||||
return ((int64_t (*) (XML_Parser)) p_XML_GetCurrentColumnNumber) (parser);
|
||||
else
|
||||
return ((long (*) (XML_Parser)) p_XML_GetCurrentColumnNumber) (parser);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* ===================== Dynamic loading of libexpat. ===================== */
|
||||
|
||||
#if DYNLOAD_LIBEXPAT
|
||||
|
||||
static XML_Expat_Version (*p_XML_ExpatVersionInfo) (void);
|
||||
|
||||
XML_Expat_Version
|
||||
XML_ExpatVersionInfo (void)
|
||||
{
|
||||
return (*p_XML_ExpatVersionInfo) ();
|
||||
}
|
||||
|
||||
static const XML_Feature * (*p_XML_GetFeatureList) (void);
|
||||
|
||||
const XML_Feature *
|
||||
XML_GetFeatureList (void)
|
||||
{
|
||||
return (*p_XML_GetFeatureList) ();
|
||||
}
|
||||
|
||||
enum XML_Size_ABI
|
||||
get_XML_Size_ABI (void)
|
||||
{
|
||||
static bool tested;
|
||||
static enum XML_Size_ABI abi;
|
||||
|
||||
if (!tested)
|
||||
{
|
||||
if (XML_ExpatVersionInfo () .major >= 2)
|
||||
/* expat >= 2.0 -> XML_Size is 'int64_t' or 'long'. */
|
||||
{
|
||||
const XML_Feature *features;
|
||||
|
||||
abi = is_long;
|
||||
for (features = XML_GetFeatureList ();
|
||||
features->name != NULL;
|
||||
features++)
|
||||
if (strcmp (features->name, "XML_LARGE_SIZE") == 0)
|
||||
{
|
||||
abi = is_int64_t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* expat < 2.0 -> XML_Size is 'int'. */
|
||||
abi = is_int;
|
||||
tested = true;
|
||||
}
|
||||
return abi;
|
||||
}
|
||||
|
||||
static XML_Parser (*p_XML_ParserCreate) (const XML_Char *encoding);
|
||||
|
||||
XML_Parser
|
||||
XML_ParserCreate (const XML_Char *encoding)
|
||||
{
|
||||
return (*p_XML_ParserCreate) (encoding);
|
||||
}
|
||||
|
||||
static void (*p_XML_SetElementHandler) (XML_Parser parser,
|
||||
XML_StartElementHandler start,
|
||||
XML_EndElementHandler end);
|
||||
|
||||
void
|
||||
XML_SetElementHandler (XML_Parser parser,
|
||||
XML_StartElementHandler start,
|
||||
XML_EndElementHandler end)
|
||||
{
|
||||
(*p_XML_SetElementHandler) (parser, start, end);
|
||||
}
|
||||
|
||||
|
||||
static void (*p_XML_SetCharacterDataHandler) (XML_Parser parser,
|
||||
XML_CharacterDataHandler handler);
|
||||
|
||||
void
|
||||
XML_SetCharacterDataHandler (XML_Parser parser,
|
||||
XML_CharacterDataHandler handler)
|
||||
{
|
||||
(*p_XML_SetCharacterDataHandler) (parser, handler);
|
||||
}
|
||||
|
||||
|
||||
static void (*p_XML_SetCommentHandler) (XML_Parser parser,
|
||||
XML_CommentHandler handler);
|
||||
|
||||
void
|
||||
XML_SetCommentHandler (XML_Parser parser, XML_CommentHandler handler)
|
||||
{
|
||||
(*p_XML_SetCommentHandler) (parser, handler);
|
||||
}
|
||||
|
||||
|
||||
static int (*p_XML_Parse) (XML_Parser parser, const char *s,
|
||||
int len, int isFinal);
|
||||
|
||||
int
|
||||
XML_Parse (XML_Parser parser, const char *s, int len, int isFinal)
|
||||
{
|
||||
return (*p_XML_Parse) (parser, s, len, isFinal);
|
||||
}
|
||||
|
||||
|
||||
static enum XML_Error (*p_XML_GetErrorCode) (XML_Parser parser);
|
||||
|
||||
enum XML_Error
|
||||
XML_GetErrorCode (XML_Parser parser)
|
||||
{
|
||||
return (*p_XML_GetErrorCode) (parser);
|
||||
}
|
||||
|
||||
|
||||
static void *p_XML_GetCurrentLineNumber;
|
||||
|
||||
int64_t
|
||||
XML_GetCurrentLineNumber (XML_Parser parser)
|
||||
{
|
||||
switch (get_XML_Size_ABI ())
|
||||
{
|
||||
case is_int:
|
||||
return ((int (*) (XML_Parser)) p_XML_GetCurrentLineNumber) (parser);
|
||||
case is_long:
|
||||
return ((long (*) (XML_Parser)) p_XML_GetCurrentLineNumber) (parser);
|
||||
case is_int64_t:
|
||||
return ((int64_t (*) (XML_Parser)) p_XML_GetCurrentLineNumber) (parser);
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
static void *p_XML_GetCurrentColumnNumber;
|
||||
|
||||
int64_t
|
||||
XML_GetCurrentColumnNumber (XML_Parser parser)
|
||||
{
|
||||
switch (get_XML_Size_ABI ())
|
||||
{
|
||||
case is_int:
|
||||
return ((int (*) (XML_Parser)) p_XML_GetCurrentColumnNumber) (parser);
|
||||
case is_long:
|
||||
return ((long (*) (XML_Parser)) p_XML_GetCurrentColumnNumber) (parser);
|
||||
case is_int64_t:
|
||||
return ((int64_t (*) (XML_Parser)) p_XML_GetCurrentColumnNumber) (parser);
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const XML_LChar * (*p_XML_ErrorString) (int code);
|
||||
|
||||
const XML_LChar *
|
||||
XML_ErrorString (int code)
|
||||
{
|
||||
return (*p_XML_ErrorString) (code);
|
||||
}
|
||||
|
||||
static void (*p_XML_ParserFree) (XML_Parser parser);
|
||||
|
||||
void
|
||||
XML_ParserFree (XML_Parser parser)
|
||||
{
|
||||
return (*p_XML_ParserFree) (parser);
|
||||
}
|
||||
|
||||
static int libexpat_loaded = 0;
|
||||
|
||||
bool
|
||||
load_libexpat ()
|
||||
{
|
||||
if (libexpat_loaded == 0)
|
||||
{
|
||||
void *handle;
|
||||
|
||||
/* Try to load libexpat-2.x. */
|
||||
handle = dlopen ("libexpat.so.1", RTLD_LAZY);
|
||||
if (handle == NULL)
|
||||
/* Try to load libexpat-1.x. */
|
||||
handle = dlopen ("libexpat.so.0", RTLD_LAZY);
|
||||
if (handle != NULL
|
||||
&& (p_XML_ExpatVersionInfo =
|
||||
(XML_Expat_Version (*) (void))
|
||||
dlsym (handle, "XML_ExpatVersionInfo")) != NULL
|
||||
&& (p_XML_GetFeatureList =
|
||||
(const XML_Feature * (*) (void))
|
||||
dlsym (handle, "XML_GetFeatureList")) != NULL
|
||||
&& (p_XML_ParserCreate =
|
||||
(XML_Parser (*) (const XML_Char *))
|
||||
dlsym (handle, "XML_ParserCreate")) != NULL
|
||||
&& (p_XML_SetElementHandler =
|
||||
(void (*) (XML_Parser, XML_StartElementHandler, XML_EndElementHandler))
|
||||
dlsym (handle, "XML_SetElementHandler")) != NULL
|
||||
&& (p_XML_SetCharacterDataHandler =
|
||||
(void (*) (XML_Parser, XML_CharacterDataHandler))
|
||||
dlsym (handle, "XML_SetCharacterDataHandler")) != NULL
|
||||
&& (p_XML_SetCommentHandler =
|
||||
(void (*) (XML_Parser, XML_CommentHandler))
|
||||
dlsym (handle, "XML_SetCommentHandler")) != NULL
|
||||
&& (p_XML_Parse =
|
||||
(int (*) (XML_Parser, const char *, int, int))
|
||||
dlsym (handle, "XML_Parse")) != NULL
|
||||
&& (p_XML_GetErrorCode =
|
||||
(enum XML_Error (*) (XML_Parser))
|
||||
dlsym (handle, "XML_GetErrorCode")) != NULL
|
||||
&& (p_XML_GetCurrentLineNumber =
|
||||
dlsym (handle, "XML_GetCurrentLineNumber")) != NULL
|
||||
&& (p_XML_GetCurrentColumnNumber =
|
||||
dlsym (handle, "XML_GetCurrentColumnNumber")) != NULL
|
||||
&& (p_XML_ParserFree =
|
||||
(void (*) (XML_Parser))
|
||||
dlsym (handle, "XML_ParserFree")) != NULL
|
||||
&& (p_XML_ErrorString =
|
||||
(const XML_LChar * (*) (int))
|
||||
dlsym (handle, "XML_ErrorString")) != NULL)
|
||||
libexpat_loaded = 1;
|
||||
else
|
||||
libexpat_loaded = -1;
|
||||
}
|
||||
return libexpat_loaded >= 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,95 +0,0 @@
|
||||
/* xgettext libexpat compatibility.
|
||||
Copyright (C) 2002-2003, 2005-2009, 2013, 2015 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
|
||||
|
||||
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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#if DYNLOAD_LIBEXPAT
|
||||
# include <dlfcn.h>
|
||||
#else
|
||||
# if HAVE_LIBEXPAT
|
||||
# include <expat.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !DYNLOAD_LIBEXPAT && XML_MAJOR_VERSION >= 2
|
||||
int64_t rpl_XML_GetCurrentLineNumber (XML_Parser parser);
|
||||
# undef XML_GetCurrentLineNumber
|
||||
# define XML_GetCurrentLineNumber rpl_XML_GetCurrentLineNumber
|
||||
|
||||
int64_t rpl_XML_GetCurrentColumnNumber (XML_Parser parser);
|
||||
# undef XML_GetCurrentColumnNumber
|
||||
# define XML_GetCurrentColumnNumber rpl_XML_GetCurrentColumnNumber
|
||||
#endif
|
||||
|
||||
/* ===================== Dynamic loading of libexpat. ===================== */
|
||||
|
||||
#if DYNLOAD_LIBEXPAT
|
||||
typedef struct
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
int micro;
|
||||
}
|
||||
XML_Expat_Version;
|
||||
enum XML_FeatureEnum { XML_FEATURE_END = 0 };
|
||||
typedef struct
|
||||
{
|
||||
enum XML_FeatureEnum feature;
|
||||
const char *name;
|
||||
long int value;
|
||||
}
|
||||
XML_Feature;
|
||||
typedef void *XML_Parser;
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
enum XML_Error { XML_ERROR_NONE };
|
||||
typedef void (*XML_StartElementHandler) (void *userData, const XML_Char *name, const XML_Char **atts);
|
||||
typedef void (*XML_EndElementHandler) (void *userData, const XML_Char *name);
|
||||
typedef void (*XML_CharacterDataHandler) (void *userData, const XML_Char *s, int len);
|
||||
typedef void (*XML_CommentHandler) (void *userData, const XML_Char *data);
|
||||
|
||||
XML_Expat_Version XML_ExpatVersionInfo (void);
|
||||
const XML_Feature * XML_GetFeatureList (void);
|
||||
|
||||
enum XML_Size_ABI { is_int, is_long, is_int64_t };
|
||||
enum XML_Size_ABI get_XML_Size_ABI (void);
|
||||
|
||||
XML_Parser XML_ParserCreate (const XML_Char *encoding);
|
||||
void XML_SetElementHandler (XML_Parser parser,
|
||||
XML_StartElementHandler start,
|
||||
XML_EndElementHandler end);
|
||||
void XML_SetCharacterDataHandler (XML_Parser parser,
|
||||
XML_CharacterDataHandler handler);
|
||||
void XML_SetCommentHandler (XML_Parser parser, XML_CommentHandler handler);
|
||||
int XML_Parse (XML_Parser parser, const char *s, int len, int isFinal);
|
||||
enum XML_Error XML_GetErrorCode (XML_Parser parser);
|
||||
int64_t XML_GetCurrentLineNumber (XML_Parser parser);
|
||||
int64_t XML_GetCurrentColumnNumber (XML_Parser parser);
|
||||
const XML_LChar * XML_ErrorString (int code);
|
||||
void XML_ParserFree (XML_Parser parser);
|
||||
|
||||
bool load_libexpat ();
|
||||
|
||||
#define LIBEXPAT_AVAILABLE() (load_libexpat ())
|
||||
|
||||
#elif HAVE_LIBEXPAT
|
||||
|
||||
#define LIBEXPAT_AVAILABLE() true
|
||||
|
||||
#endif
|
||||
1523
gnulib-local/lib/markup.c
Normal file
1523
gnulib-local/lib/markup.c
Normal file
File diff suppressed because it is too large
Load Diff
164
gnulib-local/lib/markup.h
Normal file
164
gnulib-local/lib/markup.h
Normal file
@ -0,0 +1,164 @@
|
||||
/* markup.h -- simple XML-like string parser
|
||||
Copyright (C) 2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is not part of the GNU gettext program, but is used with
|
||||
GNU gettext.
|
||||
|
||||
This is a stripped down version of GLib's gmarkup.h. The original
|
||||
copyright notice is as follows:
|
||||
*/
|
||||
|
||||
/* gmarkup.h - Simple XML-like string parser/writer
|
||||
*
|
||||
* Copyright 2000 Red Hat, Inc.
|
||||
*
|
||||
* GLib 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.
|
||||
*
|
||||
* GLib 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 GLib; see the file COPYING.LIB. If not,
|
||||
* see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MARKUP_H__
|
||||
#define __MARKUP_H__ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* markup_parse_flags_ty:
|
||||
* @MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use
|
||||
* @MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked
|
||||
* sections are not passed literally to the @passthrough function of
|
||||
* the parser. Instead, the content of the section (without the
|
||||
* `<![CDATA[` and `]]>`) is
|
||||
* passed to the @text function. This flag was added in GLib 2.12
|
||||
* @MARKUP_PREFIX_ERROR_POSITION: Normally errors caught by GMarkup
|
||||
* itself have line/column information prefixed to them to let the
|
||||
* caller know the location of the error. When this flag is set the
|
||||
* location information is also prefixed to errors generated by the
|
||||
* #GMarkupParser implementation functions
|
||||
* @MARKUP_IGNORE_QUALIFIED: Ignore (don't report) qualified
|
||||
* attributes and tags, along with their contents. A qualified
|
||||
* attribute or tag is one that contains ':' in its name (ie: is in
|
||||
* another namespace). Since: 2.40.
|
||||
*
|
||||
* Flags that affect the behaviour of the parser.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
|
||||
MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1,
|
||||
MARKUP_PREFIX_ERROR_POSITION = 1 << 2,
|
||||
MARKUP_IGNORE_QUALIFIED = 1 << 3
|
||||
} markup_parse_flags_ty;
|
||||
|
||||
/**
|
||||
* markup_parse_context_ty:
|
||||
*
|
||||
* A parse context is used to parse a stream of bytes that
|
||||
* you expect to contain marked-up text.
|
||||
*
|
||||
* See markup_parse_context_new(), #markup_parser_ty, and so
|
||||
* on for more details.
|
||||
*/
|
||||
typedef struct _markup_parse_context_ty markup_parse_context_ty;
|
||||
typedef struct _markup_parser_ty markup_parser_ty;
|
||||
|
||||
/**
|
||||
* markup_parser_ty:
|
||||
* @start_element: Callback to invoke when the opening tag of an element
|
||||
* is seen. The callback's @attribute_names and @attribute_values parameters
|
||||
* are %NULL-terminated.
|
||||
* @end_element: Callback to invoke when the closing tag of an element
|
||||
* is seen. Note that this is also called for empty tags like
|
||||
* `<empty/>`.
|
||||
* @text: Callback to invoke when some text is seen (text is always
|
||||
* inside an element). Note that the text of an element may be spread
|
||||
* over multiple calls of this function. If the
|
||||
* %MARKUP_TREAT_CDATA_AS_TEXT flag is set, this function is also
|
||||
* called for the content of CDATA marked sections.
|
||||
* @passthrough: Callback to invoke for comments, processing instructions
|
||||
* and doctype declarations; if you're re-writing the parsed document,
|
||||
* write the passthrough text back out in the same position. If the
|
||||
* %MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also
|
||||
* called for CDATA marked sections.
|
||||
* @error: Callback to invoke when an error occurs.
|
||||
*
|
||||
* Any of the fields in #markup_parser_ty can be %NULL, in which case they
|
||||
* will be ignored. Except for the @error function, any of these callbacks
|
||||
* can set an error; in particular the %MARKUP_ERROR_UNKNOWN_ELEMENT,
|
||||
* %MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %MARKUP_ERROR_INVALID_CONTENT
|
||||
* errors are intended to be set from these callbacks. If you set an error
|
||||
* from a callback, markup_parse_context_parse() will report that error
|
||||
* back to its caller.
|
||||
*/
|
||||
struct _markup_parser_ty
|
||||
{
|
||||
/* Called for open tags <foo bar="baz"> */
|
||||
bool (*start_element) (markup_parse_context_ty *context,
|
||||
const char *element_name,
|
||||
const char **attribute_names,
|
||||
const char **attribute_values,
|
||||
void *user_data);
|
||||
|
||||
/* Called for close tags </foo> */
|
||||
bool (*end_element) (markup_parse_context_ty *context,
|
||||
const char *element_name,
|
||||
void *user_data);
|
||||
|
||||
/* Called for character data */
|
||||
/* text is not nul-terminated */
|
||||
bool (*text) (markup_parse_context_ty *context,
|
||||
const char *text,
|
||||
size_t text_len,
|
||||
void *user_data);
|
||||
|
||||
/* Called for strings that should be re-saved verbatim in this same
|
||||
* position, but are not otherwise interpretable. At the moment
|
||||
* this includes comments and processing instructions.
|
||||
*/
|
||||
/* text is not nul-terminated. */
|
||||
bool (*passthrough) (markup_parse_context_ty *context,
|
||||
const char *passthrough_text,
|
||||
size_t text_len,
|
||||
void *user_data);
|
||||
|
||||
/* Called on error, including one set by other
|
||||
* methods in the vtable. The GError should not be freed.
|
||||
*/
|
||||
void (*error) (markup_parse_context_ty *context,
|
||||
const char *error_text,
|
||||
void *user_data);
|
||||
};
|
||||
|
||||
extern markup_parse_context_ty *
|
||||
markup_parse_context_new (const markup_parser_ty *parser,
|
||||
markup_parse_flags_ty flags,
|
||||
void *user_data);
|
||||
extern void markup_parse_context_free (markup_parse_context_ty *context);
|
||||
extern bool markup_parse_context_parse (markup_parse_context_ty *context,
|
||||
const char *text,
|
||||
ssize_t text_len);
|
||||
extern bool markup_parse_context_end_parse (markup_parse_context_ty *context);
|
||||
extern const char *
|
||||
markup_parse_context_get_error (markup_parse_context_ty *context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MARKUP_H__ */
|
||||
31
gnulib-local/modules/markup
Normal file
31
gnulib-local/modules/markup
Normal file
@ -0,0 +1,31 @@
|
||||
Description:
|
||||
Simple XML-like parser
|
||||
|
||||
Files:
|
||||
lib/markup.h
|
||||
lib/markup.c
|
||||
|
||||
Depends-on:
|
||||
c-ctype
|
||||
linked-list
|
||||
unistr/u8-mbtouc
|
||||
unistr/u8-next
|
||||
unictype/ctype-alpha
|
||||
xalloc
|
||||
xlist
|
||||
xvasprintf
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
lib_SOURCES += markup.h markup.c
|
||||
|
||||
Include:
|
||||
"markup.h"
|
||||
|
||||
License:
|
||||
LGPL
|
||||
|
||||
Maintainer:
|
||||
Daiki Ueno
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user