summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-04-21 20:58:53 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2011-04-21 20:58:53 (GMT)
commit50c643f6ceca1dd1862f9ae05aa7f9cef186d3ed (patch)
tree8741bc7e402de2adffcea03f54887e01361d489f
parent83cb85be93ffc1adbd64a9268349d44ec52a43b6 (diff)
downloadlibparserutils-50c643f6ceca1dd1862f9ae05aa7f9cef186d3ed.tar.gz
libparserutils-50c643f6ceca1dd1862f9ae05aa7f9cef186d3ed.tar.bz2
Require iconv by default, as this is the most useful configuration
svn path=/trunk/libparserutils/; revision=12215
-rw-r--r--Makefile.config4
-rw-r--r--README26
-rw-r--r--src/input/filter.c18
-rw-r--r--test/regression/filter-badenc-segv.c2
4 files changed, 22 insertions, 28 deletions
diff --git a/Makefile.config b/Makefile.config
index e2a29ff..15c0a48 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -1,7 +1,7 @@
# Configuration Makefile fragment
-# Use iconv directly in the input filter
-# CFLAGS := $(CFLAGS) -DWITH_ICONV_FILTER
+# Disable use of iconv in the input filter
+# CFLAGS := $(CFLAGS) -DWITHOUT_ICONV_FILTER
# Cater for local configuration changes
-include Makefile.config.override
diff --git a/README b/README
index 15c0959..36c3cf0 100644
--- a/README
+++ b/README
@@ -24,8 +24,10 @@ Requirements
+ Pkg-config (for the testcases)
+ doxygen (for the API documentation)
- For enhanced charset support, LibParserUtils may also be configured to use
- an iconv() implementation, see the "Enabling iconv() support" section, below.
+ For enhanced charset support, LibParserUtils requires an iconv()
+ implementation. If you don't have an implementation of iconv(),
+ this requirement may be disabled: see the "Disabling iconv()
+ support" section, below.
Compilation
-----------
@@ -100,10 +102,11 @@ API documentation
The test driver code in test/ may also provide some useful pointers.
-Enabling iconv() support
-------------------------
+Disabling iconv() support
+-------------------------
- By default, libparserutils only supports the following character sets:
+ Without iconv() support enabled, libparserutils only supports the
+ following character sets:
+ UTF-16 (platform-native endian)
+ UTF-8
@@ -111,19 +114,10 @@ Enabling iconv() support
+ Windows-125n
+ US-ASCII
- Support for more character sets may be enabled through the use of iconv().
- To enable iconv() support in libparserutils, do the following:
+ To disable iconv() support in libparserutils, do the following:
- $ echo "CFLAGS += -DWITH_ICONV_FILTER" \
+ $ echo "CFLAGS += -DWITHOUT_ICONV_FILTER" \
>build/Makefile.config.override
Then build libparserutils as normal.
-A note on character set aliases
--------------------------------
-
- Libparserutils uses an external mapping file to encode relationships between
- character set names. This is the "Aliases" file. A copy may be found at
- test/data/Aliases. The path to this file is required when calling
- parserutils_initialise().
-
diff --git a/src/input/filter.c b/src/input/filter.c
index fef7b9c..b24ab56 100644
--- a/src/input/filter.c
+++ b/src/input/filter.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
#include <iconv.h>
#endif
@@ -22,7 +22,7 @@
/** Input filter */
struct parserutils_filter {
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
iconv_t cd; /**< Iconv conversion descriptor */
uint16_t int_enc; /**< The internal encoding */
#else
@@ -73,7 +73,7 @@ parserutils_error parserutils__filter_create(const char *int_enc,
if (f == NULL)
return PARSERUTILS_NOMEM;
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
f->cd = (iconv_t) -1;
f->int_enc = parserutils_charset_mibenum_from_name(
int_enc, strlen(int_enc));
@@ -96,7 +96,7 @@ parserutils_error parserutils__filter_create(const char *int_enc,
return error;
}
-#ifndef WITH_ICONV_FILTER
+#ifdef WITHOUT_ICONV_FILTER
error = parserutils_charset_codec_create(int_enc, alloc, pw,
&f->write_codec);
if (error != PARSERUTILS_OK) {
@@ -125,7 +125,7 @@ parserutils_error parserutils__filter_destroy(parserutils_filter *input)
if (input == NULL)
return PARSERUTILS_BADPARM;
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
if (input->cd != (iconv_t) -1) {
iconv_close(input->cd);
input->cd = (iconv_t) -1;
@@ -193,7 +193,7 @@ parserutils_error parserutils__filter_process_chunk(parserutils_filter *input,
output == NULL || *output == NULL || outlen == NULL)
return PARSERUTILS_BADPARM;
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
if (iconv(input->cd, (void *) data, len,
(char **) output, outlen) == (size_t) -1) {
switch (errno) {
@@ -314,7 +314,7 @@ parserutils_error parserutils__filter_reset(parserutils_filter *input)
if (input == NULL)
return PARSERUTILS_BADPARM;
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
iconv(input->cd, NULL, 0, NULL, 0);
#else
/* Clear pivot buffer leftovers */
@@ -349,7 +349,7 @@ parserutils_error filter_set_defaults(parserutils_filter *input)
if (input == NULL)
return PARSERUTILS_BADPARM;
-#ifndef WITH_ICONV_FILTER
+#ifdef WITHOUT_ICONV_FILTER
input->read_codec = NULL;
input->write_codec = NULL;
#endif
@@ -386,7 +386,7 @@ parserutils_error filter_set_encoding(parserutils_filter *input,
if (input->settings.encoding == mibenum)
return PARSERUTILS_OK;
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
if (input->cd != (iconv_t) -1) {
iconv_close(input->cd);
input->cd = (iconv_t) -1;
diff --git a/test/regression/filter-badenc-segv.c b/test/regression/filter-badenc-segv.c
index 874123b..f44ac59 100644
--- a/test/regression/filter-badenc-segv.c
+++ b/test/regression/filter-badenc-segv.c
@@ -20,7 +20,7 @@ int main(int argc, char **argv)
parserutils_filter_optparams params;
parserutils_error expected;
-#ifdef WITH_ICONV_FILTER
+#ifndef WITHOUT_ICONV_FILTER
expected = PARSERUTILS_OK;
#else
expected = PARSERUTILS_BADENCODING;