aboutsummaryrefslogtreecommitdiff
path: root/iconv
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-04-21 20:37:08 +0000
committerUlrich Drepper <drepper@redhat.com>1998-04-21 20:37:08 +0000
commit28f1c862ddaa3515d0f74102379301048c76cf0f (patch)
tree98874b1daaca4421269c74932665dabe74f9b69c /iconv
parent9ce5071a3d3af1b7837b1a081548fdd945a66efe (diff)
downloadglibc-28f1c862ddaa3515d0f74102379301048c76cf0f.zip
glibc-28f1c862ddaa3515d0f74102379301048c76cf0f.tar.gz
glibc-28f1c862ddaa3515d0f74102379301048c76cf0f.tar.bz2
Update.
1998-04-21 20:32 Ulrich Drepper <drepper@cygnus.com> * iconv/loop.c: Allow EXTRA_LOOP_DECLS be defined and use it in function declaration. * iconv/skeleton.c: Allow PREPARE_LOOP and EXTRA_LOOP_ARGS be defined and use them in conversion function. * iconvdata/Makefile (modules): Re-add ISO6446. * iconvdata/TEST: Add tests for ASCII variants. * iconvdata/iso646.c: Rewrite to use loop.c and skeleton.c. * iconvdata/testdata/ANSI_X3.4-1968: New file. * iconvdata/testdata/BS_4730: New file. * iconvdata/testdata/BS_4730..UTF8: New file.
Diffstat (limited to 'iconv')
-rw-r--r--iconv/loop.c12
-rw-r--r--iconv/skeleton.c27
2 files changed, 34 insertions, 5 deletions
diff --git a/iconv/loop.c b/iconv/loop.c
index e1c1ab6..f818887 100644
--- a/iconv/loop.c
+++ b/iconv/loop.c
@@ -43,6 +43,8 @@
BODY this is supposed to expand to the body of the loop.
The user must provide this.
+
+ EXTRA_LOOP_DECLS Extra arguments passed from converion loop call.
*/
#include <gconv.h>
@@ -106,11 +108,18 @@
#endif
+/* If no arguments have to passed to the loop function define the macro
+ as empty. */
+#ifndef EXTRA_LOOP_DECLS
+# define EXTRA_LOOP_DECLS
+#endif
+
+
/* The function returns the status, as defined in gconv.h. */
static inline int
LOOPFCT (const unsigned char **inptrp, const unsigned char *inend,
unsigned char **outptrp, unsigned char *outend, mbstate_t *state,
- void *data, size_t *converted)
+ void *data, size_t *converted EXTRA_LOOP_DECLS)
{
int result = GCONV_OK;
const unsigned char *inptr = *inptrp;
@@ -222,3 +231,4 @@ LOOPFCT (const unsigned char **inptrp, const unsigned char *inend,
#undef COUNT_CONVERTED
#undef BODY
#undef LOOPFCT
+#undef EXTRA_LOOP_DECLS
diff --git a/iconv/skeleton.c b/iconv/skeleton.c
index 36cc33c..8421941 100644
--- a/iconv/skeleton.c
+++ b/iconv/skeleton.c
@@ -67,6 +67,12 @@
to cover only those characters up to the error.
FUNCTION_NAME if not set the conversion function is named `gconv'.
+
+ PREPARE_LOOP optional code preparing the conversion loop. Can
+ contain variable definitions.
+
+ EXTRA_LOOP_ARGS optional macro specifying extra arguments passed
+ to loop function.
*/
#include <assert.h>
@@ -161,6 +167,13 @@ gconv_init (struct gconv_step *step)
#endif
+/* If no arguments have to passed to the loop function define the macro
+ as empty. */
+#ifndef EXTRA_LOOP_ARGS
+# define EXTRA_LOOP_ARGS
+#endif
+
+
/* This is the actual conversion function. */
#ifndef FUNCTION_NAME
# define FUNCTION_NAME gconv
@@ -210,6 +223,10 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
char *outend = data->outbufend;
char *outptr;
+#ifdef PREPARE_LOOP
+ PREPARE_LOOP
+#endif
+
do
{
/* Remember the start value for this round. */
@@ -229,14 +246,16 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
(const unsigned char *) inbufend,
(unsigned char **) &outbuf,
(unsigned char *) outend,
- data->statep, step->data, &converted);
+ data->statep, step->data, &converted
+ EXTRA_LOOP_ARGS);
else
/* Run the conversion loop. */
status = TO_LOOP ((const unsigned char **) inbuf,
(const unsigned char *) inbufend,
(unsigned char **) &outbuf,
(unsigned char *) outend,
- data->statep, step->data, &converted);
+ data->statep, step->data, &converted
+ EXTRA_LOOP_ARGS);
/* If this is the last step leave the loop, there is nothgin
we can do. */
@@ -284,7 +303,7 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
(unsigned char **) &outbuf,
(unsigned char *) outerr,
data->statep, step->data,
- &converted);
+ &converted EXTRA_LOOP_ARGS);
else
/* Run the conversion loop. */
nstatus = TO_LOOP ((const unsigned char **) inbuf,
@@ -292,7 +311,7 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
(unsigned char **) &outbuf,
(unsigned char *) outerr,
data->statep, step->data,
- &converted);
+ &converted EXTRA_LOOP_ARGS);
/* We must run out of output buffer space in this
rerun. */