summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Blandy <jimb@red-bean.com>1999-09-06 09:30:57 +0000
committerJim Blandy <jimb@red-bean.com>1999-09-06 09:30:57 +0000
commit4ab762c64e118e4b5030994adf4bb55b56f5d371 (patch)
tree848c3ae8adc52b9c143c0733c3ef94478ee0a019
parentf6e36d0719698749aa21ea41d0638a2f818d9eed (diff)
downloadguile-4ab762c64e118e4b5030994adf4bb55b56f5d371.tar.gz
* mbbasic.c, mbbasic.h: New files.
* init.c: #include "mbbasic.h" * Makefile.am (libguile_la_SOURCES, BUILT_SOURCES, modinclude_HEADERS): Include the `mbbasic' files in the lists. * Makefile.in: Regenerated.
-rw-r--r--libguile/Makefile.am46
-rw-r--r--libguile/Makefile.in43
-rw-r--r--libguile/init.c2
-rw-r--r--libguile/mbbasic.c287
-rw-r--r--libguile/mbbasic.h1
5 files changed, 335 insertions, 44 deletions
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index fdef34945..afb5011f2 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -41,7 +41,7 @@ libguile_la_SOURCES = \
gh_data.c gh_eval.c gh_funcs.c gh_init.c gh_io.c gh_list.c \
gh_predicates.c gsubr.c guardians.c hash.c hashtab.c init.c \
ioext.c keywords.c lang.c list.c load.c macros.c mallocs.c mb.c \
- mbconv.c modules.c net_db.c numbers.c objects.c objprop.c \
+ mbbasic.c mbconv.c modules.c net_db.c numbers.c objects.c objprop.c \
options.c pairs.c ports.c posix.c print.c procprop.c procs.c \
ramap.c random.c read.c root.c scmsigs.c script.c simpos.c smob.c \
socket.c sort.c srcprop.c stackchk.c stacks.c stime.c strings.c \
@@ -49,17 +49,17 @@ libguile_la_SOURCES = \
unif.c variable.c vectors.c version.c vports.c weaks.c
BUILT_SOURCES = \
- cpp_err_symbols.c cpp_sig_symbols.c libpath.h alist.x arbiters.x \
- async.x backtrace.x boolean.x chars.x continuations.x debug.x \
- dynl.x dynwind.x eq.x error.x eval.x evalext.x feature.x filesys.x \
- fluids.x fports.x gc.x gsubr.x guardians.x hash.x hashtab.x init.x \
- ioext.x iselect.x keywords.x lang.x list.x load.x macros.x \
- mallocs.x mb.x mbconv.x modules.x net_db.x numbers.x objects.x \
- objprop.x options.x pairs.x ports.x posix.x print.x procprop.x \
- procs.x random.x ramap.x read.x regex-posix.x root.x scmsigs.x \
- script.x simpos.x smob.x socket.x sort.x srcprop.x stackchk.x \
- stacks.x stime.x strings.x strop.x strorder.x strports.x struct.x \
- symbols.x tag.x threads.x throw.x unif.x variable.x vectors.x \
+ cpp_err_symbols.c cpp_sig_symbols.c libpath.h alist.x arbiters.x \
+ async.x backtrace.x boolean.x chars.x continuations.x debug.x \
+ dynl.x dynwind.x eq.x error.x eval.x evalext.x feature.x filesys.x \
+ fluids.x fports.x gc.x gsubr.x guardians.x hash.x hashtab.x init.x \
+ ioext.x iselect.x keywords.x lang.x list.x load.x macros.x \
+ mallocs.x mb.x mbbasic.x mbconv.x modules.x net_db.x numbers.x objects.x \
+ objprop.x options.x pairs.x ports.x posix.x print.x procprop.x \
+ procs.x random.x ramap.x read.x regex-posix.x root.x scmsigs.x \
+ script.x simpos.x smob.x socket.x sort.x srcprop.x stackchk.x \
+ stacks.x stime.x strings.x strop.x strorder.x strports.x struct.x \
+ symbols.x tag.x threads.x throw.x unif.x variable.x vectors.x \
version.x vports.x weaks.x
EXTRA_libguile_la_SOURCES = _scm.h \
@@ -85,17 +85,17 @@ pkginclude_HEADERS = gh.h
# These are headers visible as <libguile/mumble.h>.
modincludedir = $(includedir)/libguile
modinclude_HEADERS = \
- __scm.h alist.h arbiters.h async.h backtrace.h boolean.h chars.h \
- continuations.h debug.h dynl.h dynwind.h eq.h error.h eval.h \
- evalext.h feature.h filesys.h fports.h gc.h gdb_interface.h \
- gdbint.h genio.h gsubr.h guardians.h hash.h hashtab.h init.h \
- ioext.h keywords.h kw.h lang.h list.h load.h macros.h mallocs.h \
- mb.h mbconv.h modules.h net_db.h numbers.h objects.h objprop.h \
- options.h pairs.h ports.h posix.h regex-posix.h print.h procprop.h \
- procs.h random.h ramap.h read.h root.h scmsigs.h script.h simpos.h \
- smob.h socket.h sort.h srcprop.h stackchk.h stacks.h stime.h \
- strings.h strop.h strorder.h strports.h struct.h symbols.h tag.h \
- tags.h throw.h unif.h variable.h vectors.h version.h vports.h \
+ __scm.h alist.h arbiters.h async.h backtrace.h boolean.h chars.h \
+ continuations.h debug.h dynl.h dynwind.h eq.h error.h eval.h \
+ evalext.h feature.h filesys.h fports.h gc.h gdb_interface.h \
+ gdbint.h genio.h gsubr.h guardians.h hash.h hashtab.h init.h \
+ ioext.h keywords.h kw.h lang.h list.h load.h macros.h mallocs.h \
+ mb.h mbbasic.h mbconv.h modules.h net_db.h numbers.h objects.h objprop.h \
+ options.h pairs.h ports.h posix.h regex-posix.h print.h procprop.h \
+ procs.h random.h ramap.h read.h root.h scmsigs.h script.h simpos.h \
+ smob.h socket.h sort.h srcprop.h stackchk.h stacks.h stime.h \
+ strings.h strop.h strorder.h strports.h struct.h symbols.h tag.h \
+ tags.h throw.h unif.h variable.h vectors.h version.h vports.h \
weaks.h snarf.h threads.h coop-defs.h fluids.h iselect.h
## This file is generated at configure time. That is why it is DATA
diff --git a/libguile/Makefile.in b/libguile/Makefile.in
index 2e4c47289..67206dc2e 100644
--- a/libguile/Makefile.in
+++ b/libguile/Makefile.in
@@ -103,10 +103,10 @@ bin_PROGRAMS = guile
guile_SOURCES = guile.c
guile_LDADD = libguile.la ${THREAD_LIBS_LOCAL}
-libguile_la_SOURCES = alist.c arbiters.c async.c backtrace.c boolean.c chars.c continuations.c debug.c dynl.c dynwind.c eq.c error.c eval.c evalext.c feature.c filesys.c fluids.c fports.c gc.c gdbint.c gh_data.c gh_eval.c gh_funcs.c gh_init.c gh_io.c gh_list.c gh_predicates.c gsubr.c guardians.c hash.c hashtab.c init.c ioext.c keywords.c lang.c list.c load.c macros.c mallocs.c mb.c mbconv.c modules.c net_db.c numbers.c objects.c objprop.c options.c pairs.c ports.c posix.c print.c procprop.c procs.c ramap.c random.c read.c root.c scmsigs.c script.c simpos.c smob.c socket.c sort.c srcprop.c stackchk.c stacks.c stime.c strings.c strop.c strorder.c strports.c struct.c symbols.c tag.c throw.c unif.c variable.c vectors.c version.c vports.c weaks.c
+libguile_la_SOURCES = alist.c arbiters.c async.c backtrace.c boolean.c chars.c continuations.c debug.c dynl.c dynwind.c eq.c error.c eval.c evalext.c feature.c filesys.c fluids.c fports.c gc.c gdbint.c gh_data.c gh_eval.c gh_funcs.c gh_init.c gh_io.c gh_list.c gh_predicates.c gsubr.c guardians.c hash.c hashtab.c init.c ioext.c keywords.c lang.c list.c load.c macros.c mallocs.c mb.c mbbasic.c mbconv.c modules.c net_db.c numbers.c objects.c objprop.c options.c pairs.c ports.c posix.c print.c procprop.c procs.c ramap.c random.c read.c root.c scmsigs.c script.c simpos.c smob.c socket.c sort.c srcprop.c stackchk.c stacks.c stime.c strings.c strop.c strorder.c strports.c struct.c symbols.c tag.c throw.c unif.c variable.c vectors.c version.c vports.c weaks.c
-BUILT_SOURCES = cpp_err_symbols.c cpp_sig_symbols.c libpath.h alist.x arbiters.x async.x backtrace.x boolean.x chars.x continuations.x debug.x dynl.x dynwind.x eq.x error.x eval.x evalext.x feature.x filesys.x fluids.x fports.x gc.x gsubr.x guardians.x hash.x hashtab.x init.x ioext.x iselect.x keywords.x lang.x list.x load.x macros.x mallocs.x mb.x mbconv.x modules.x net_db.x numbers.x objects.x objprop.x options.x pairs.x ports.x posix.x print.x procprop.x procs.x random.x ramap.x read.x regex-posix.x root.x scmsigs.x script.x simpos.x smob.x socket.x sort.x srcprop.x stackchk.x stacks.x stime.x strings.x strop.x strorder.x strports.x struct.x symbols.x tag.x threads.x throw.x unif.x variable.x vectors.x version.x vports.x weaks.x
+BUILT_SOURCES = cpp_err_symbols.c cpp_sig_symbols.c libpath.h alist.x arbiters.x async.x backtrace.x boolean.x chars.x continuations.x debug.x dynl.x dynwind.x eq.x error.x eval.x evalext.x feature.x filesys.x fluids.x fports.x gc.x gsubr.x guardians.x hash.x hashtab.x init.x ioext.x iselect.x keywords.x lang.x list.x load.x macros.x mallocs.x mb.x mbbasic.x mbconv.x modules.x net_db.x numbers.x objects.x objprop.x options.x pairs.x ports.x posix.x print.x procprop.x procs.x random.x ramap.x read.x regex-posix.x root.x scmsigs.x script.x simpos.x smob.x socket.x sort.x srcprop.x stackchk.x stacks.x stime.x strings.x strop.x strorder.x strports.x struct.x symbols.x tag.x threads.x throw.x unif.x variable.x vectors.x version.x vports.x weaks.x
EXTRA_libguile_la_SOURCES = _scm.h strerror.c inet_aton.c putenv.c threads.c alloca.c regex-posix.c iselect.c
@@ -125,7 +125,7 @@ pkginclude_HEADERS = gh.h
# These are headers visible as <libguile/mumble.h>.
modincludedir = $(includedir)/libguile
-modinclude_HEADERS = __scm.h alist.h arbiters.h async.h backtrace.h boolean.h chars.h continuations.h debug.h dynl.h dynwind.h eq.h error.h eval.h evalext.h feature.h filesys.h fports.h gc.h gdb_interface.h gdbint.h genio.h gsubr.h guardians.h hash.h hashtab.h init.h ioext.h keywords.h kw.h lang.h list.h load.h macros.h mallocs.h mb.h mbconv.h modules.h net_db.h numbers.h objects.h objprop.h options.h pairs.h ports.h posix.h regex-posix.h print.h procprop.h procs.h random.h ramap.h read.h root.h scmsigs.h script.h simpos.h smob.h socket.h sort.h srcprop.h stackchk.h stacks.h stime.h strings.h strop.h strorder.h strports.h struct.h symbols.h tag.h tags.h throw.h unif.h variable.h vectors.h version.h vports.h weaks.h snarf.h threads.h coop-defs.h fluids.h iselect.h
+modinclude_HEADERS = __scm.h alist.h arbiters.h async.h backtrace.h boolean.h chars.h continuations.h debug.h dynl.h dynwind.h eq.h error.h eval.h evalext.h feature.h filesys.h fports.h gc.h gdb_interface.h gdbint.h genio.h gsubr.h guardians.h hash.h hashtab.h init.h ioext.h keywords.h kw.h lang.h list.h load.h macros.h mallocs.h mb.h mbbasic.h mbconv.h modules.h net_db.h numbers.h objects.h objprop.h options.h pairs.h ports.h posix.h regex-posix.h print.h procprop.h procs.h random.h ramap.h read.h root.h scmsigs.h script.h simpos.h smob.h socket.h sort.h srcprop.h stackchk.h stacks.h stime.h strings.h strop.h strorder.h strports.h struct.h symbols.h tag.h tags.h throw.h unif.h variable.h vectors.h version.h vports.h weaks.h snarf.h threads.h coop-defs.h fluids.h iselect.h
modinclude_DATA = scmconfig.h
@@ -170,13 +170,13 @@ error.lo eval.lo evalext.lo feature.lo filesys.lo fluids.lo fports.lo \
gc.lo gdbint.lo gh_data.lo gh_eval.lo gh_funcs.lo gh_init.lo gh_io.lo \
gh_list.lo gh_predicates.lo gsubr.lo guardians.lo hash.lo hashtab.lo \
init.lo ioext.lo keywords.lo lang.lo list.lo load.lo macros.lo \
-mallocs.lo mb.lo mbconv.lo modules.lo net_db.lo numbers.lo objects.lo \
-objprop.lo options.lo pairs.lo ports.lo posix.lo print.lo procprop.lo \
-procs.lo ramap.lo random.lo read.lo root.lo scmsigs.lo script.lo \
-simpos.lo smob.lo socket.lo sort.lo srcprop.lo stackchk.lo stacks.lo \
-stime.lo strings.lo strop.lo strorder.lo strports.lo struct.lo \
-symbols.lo tag.lo throw.lo unif.lo variable.lo vectors.lo version.lo \
-vports.lo weaks.lo
+mallocs.lo mb.lo mbbasic.lo mbconv.lo modules.lo net_db.lo numbers.lo \
+objects.lo objprop.lo options.lo pairs.lo ports.lo posix.lo print.lo \
+procprop.lo procs.lo ramap.lo random.lo read.lo root.lo scmsigs.lo \
+script.lo simpos.lo smob.lo socket.lo sort.lo srcprop.lo stackchk.lo \
+stacks.lo stime.lo strings.lo strop.lo strorder.lo strports.lo \
+struct.lo symbols.lo tag.lo throw.lo unif.lo variable.lo vectors.lo \
+version.lo vports.lo weaks.lo
PROGRAMS = $(bin_PROGRAMS)
guile_OBJECTS = guile.o
@@ -223,17 +223,18 @@ DEP_FILES = .deps/alist.P .deps/alloca.P .deps/arbiters.P .deps/async.P \
.deps/hash.P .deps/hashtab.P .deps/inet_aton.P .deps/init.P \
.deps/ioext.P .deps/iselect.P .deps/keywords.P .deps/lang.P \
.deps/list.P .deps/load.P .deps/macros.P .deps/mallocs.P .deps/mb.P \
-.deps/mbconv.P .deps/modules.P .deps/net_db.P .deps/numbers.P \
-.deps/objects.P .deps/objprop.P .deps/options.P .deps/pairs.P \
-.deps/ports.P .deps/posix.P .deps/print.P .deps/procprop.P \
-.deps/procs.P .deps/putenv.P .deps/ramap.P .deps/random.P .deps/read.P \
-.deps/regex-posix.P .deps/root.P .deps/scmsigs.P .deps/script.P \
-.deps/simpos.P .deps/smob.P .deps/socket.P .deps/sort.P .deps/srcprop.P \
-.deps/stackchk.P .deps/stacks.P .deps/stime.P .deps/strerror.P \
-.deps/strings.P .deps/strop.P .deps/strorder.P .deps/strports.P \
-.deps/struct.P .deps/symbols.P .deps/tag.P .deps/threads.P \
-.deps/throw.P .deps/unif.P .deps/variable.P .deps/vectors.P \
-.deps/version.P .deps/vports.P .deps/weaks.P
+.deps/mbbasic.P .deps/mbconv.P .deps/modules.P .deps/net_db.P \
+.deps/numbers.P .deps/objects.P .deps/objprop.P .deps/options.P \
+.deps/pairs.P .deps/ports.P .deps/posix.P .deps/print.P \
+.deps/procprop.P .deps/procs.P .deps/putenv.P .deps/ramap.P \
+.deps/random.P .deps/read.P .deps/regex-posix.P .deps/root.P \
+.deps/scmsigs.P .deps/script.P .deps/simpos.P .deps/smob.P \
+.deps/socket.P .deps/sort.P .deps/srcprop.P .deps/stackchk.P \
+.deps/stacks.P .deps/stime.P .deps/strerror.P .deps/strings.P \
+.deps/strop.P .deps/strorder.P .deps/strports.P .deps/struct.P \
+.deps/symbols.P .deps/tag.P .deps/threads.P .deps/throw.P .deps/unif.P \
+.deps/variable.P .deps/vectors.P .deps/version.P .deps/vports.P \
+.deps/weaks.P
SOURCES = $(libguile_la_SOURCES) $(EXTRA_libguile_la_SOURCES) $(guile_SOURCES) $(gh_test_c_SOURCES) $(gh_test_repl_SOURCES) $(check_mb_SOURCES)
OBJECTS = $(libguile_la_OBJECTS) $(guile_OBJECTS) $(gh_test_c_OBJECTS) $(gh_test_repl_OBJECTS) $(check_mb_OBJECTS)
diff --git a/libguile/init.c b/libguile/init.c
index 527403074..98273e1bf 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -83,6 +83,7 @@
#include "mallocs.h"
#include "mb.h"
#include "mbconv.h"
+#include "mbbasic.h"
#include "modules.h"
#include "net_db.h"
#include "numbers.h"
@@ -451,6 +452,7 @@ scm_boot_guile_1 (base, closure)
start_stack (base);
scm_init_mb ();
scm_init_mbconv ();
+ scm_init_mbbasic ();
scm_init_gsubr ();
scm_init_feature ();
scm_init_alist ();
diff --git a/libguile/mbbasic.c b/libguile/mbbasic.c
new file mode 100644
index 000000000..07cd2baf2
--- /dev/null
+++ b/libguile/mbbasic.c
@@ -0,0 +1,287 @@
+/* mbbasic.c --- conversions to and from very common encodings.
+
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+ 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 2, 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 software; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+
+ As a special exception, the Free Software Foundation gives permission
+ for additional uses of the text contained in its release of GUILE.
+
+ The exception is that, if you link the GUILE library with other files
+ to produce an executable, this does not by itself cause the
+ resulting executable to be covered by the GNU General Public License.
+ Your use of that executable is in no way restricted on account of
+ linking the GUILE library code into it.
+
+ This exception does not however invalidate any other reasons why
+ the executable file might be covered by the GNU General Public License.
+
+ This exception applies only to the code released by the
+ Free Software Foundation under the name GUILE. If you copy
+ code from other Free Software Foundation releases into a copy of
+ GUILE, as the General Public License permits, the exception does
+ not apply to the code that you add in this way. To avoid misleading
+ anyone as to the status of such modified files, you must delete
+ this exception notice from them.
+
+ If you write modifications of your own for GUILE, it is your choice
+ whether to permit this exception to apply to your modifications.
+ If you do not wish that, delete this exception notice. */
+
+/* Headers. */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "_scm.h"
+#include "mb.h"
+#include "mbconv.h"
+#include "mbemacs.h"
+
+
+/* The Emacs-Mule encoding. */
+
+static struct scm_mb_encoding emacs_mule_encoding;
+
+static enum scm_mb_read_result
+emacs_mule_read (void *cookie,
+ const char **inbuf, size_t *inbytesleft,
+ scm_char_t **outbuf, size_t *outcharsleft)
+{
+ const char *in = *inbuf;
+ const char *in_end = in + *inbytesleft;
+ scm_char_t *out = *outbuf;
+ scm_char_t *out_end = out + *outcharsleft;
+
+ while (in < in_end && out < out_end)
+ {
+ const char *next = in + scm_mb_len (*in);
+ if (next > in_end)
+ {
+ *inbuf = in;
+ *inbytesleft = in_end - in;
+ *outbuf = out;
+ *outcharsleft = out_end - out;
+
+ return scm_mb_read_incomplete;
+ }
+ *out++ = scm_mb_get (in);
+ in = next;
+ }
+
+ *inbuf = in;
+ *inbytesleft = in_end - in;
+ *outbuf = out;
+ *outcharsleft = out_end - out;
+
+ return scm_mb_read_ok;
+}
+
+static enum scm_mb_write_result
+emacs_mule_write (void *cookie,
+ scm_char_t **inbuf, size_t *incharsleft,
+ char **outbuf, size_t *outbytesleft)
+{
+ const scm_char_t *in = *inbuf;
+ const scm_char_t *in_end = in + *incharsleft;
+ char *out = *outbuf;
+ char *out_end = out + *outbytesleft;
+
+ while (in < in_end)
+ {
+ const char *next = out + scm_mb_len_char (*in);
+ if (next > out_end)
+ {
+ *inbuf = in;
+ *incharsleft = in_end - in;
+ *outbuf = out;
+ *outbytesleft = out_end - out;
+
+ return scm_mb_write_more_room;
+ }
+
+ out += scm_mb_put (*in, out);
+ in++;
+ }
+
+ *inbuf = in;
+ *incharsleft = in_end - in;
+ *outbuf = out;
+ *outbytesleft = out_end - out;
+
+ return scm_mb_write_ok;
+}
+
+
+
+/* The ISO 8859 encodings. */
+
+/* Conversions to and from these encodings are trivial. The lower 128
+ characters are identical to ASCII, and can be passed through
+ directly. The upper 128 characters map directly onto the
+ corresponding CHAR1O character codes. No tables needed.
+
+ All these encoding share the same read and write functions; the
+ only thing which varies from one to the next is the init function,
+ which stores the character set number in the context's cookie for
+ this conversion.
+
+ Perhaps we can cram CHARSET_KATAKANA_JISX0201 and
+ CHARSET_LATIN_JISX0201 into this system, too. */
+
+#define ISO8859_INIT(charset, number) \
+static int \
+iso8859_ ## number ## _init (void **privp) \
+{ \
+ static unsigned char = number; \
+ *privp = (void *) &charset_num; \
+ return 1; \
+} \
+static char *iso8859_ ## number ##_names[] = { \
+ "ISO-8859-" ## # number, "Latin-" ## #number, 0 \
+};
+
+ISO8859_INIT(CHARSET_LATIN_ISO8859_1, 1)
+ISO8859_INIT(CHARSET_LATIN_ISO8859_2, 2)
+ISO8859_INIT(CHARSET_LATIN_ISO8859_3, 3)
+ISO8859_INIT(CHARSET_LATIN_ISO8859_4, 4)
+ISO8859_INIT(CHARSET_CYRILLIC_ISO8859_5, 5)
+ISO8859_INIT(CHARSET_ARABIC_ISO8859_6, 6)
+ISO8859_INIT(CHARSET_GREEK_ISO8859_7, 7)
+ISO8859_INIT(CHARSET_HEBREW_ISO8859_8, 8)
+ISO8859_INIT(CHARSET_LATIN_ISO8859_9, 9)
+
+#define ISO8859_ENTRY(number) \
+ { \
+ iso8859_ ## number ## _names, \
+ iso8859_ ## number ## _init, \
+ 0, 0, iso_iso8859_read, iso_iso8859_write, 0 \
+ }
+
+static struct scm_mb_encoding iso8859_encodings[] =
+{
+ ISO8859_ENTRY(1),
+ ISO8859_ENTRY(2),
+ ISO8859_ENTRY(3),
+ ISO8859_ENTRY(4),
+ ISO8859_ENTRY(5),
+ ISO8859_ENTRY(6),
+ ISO8859_ENTRY(7),
+ ISO8859_ENTRY(8),
+ ISO8859_ENTRY(9)
+};
+
+static enum scm_mb_read_result
+iso8859_read (void *priv,
+ const char **inbuf, size_t *inbytesleft,
+ scm_char_t **outbuf, size_t *outcharsleft)
+{
+ unsigned char charset = * (unsigned char *) priv;
+ const char *in = *inbuf;
+ const char *in_end = in + *inbytesleft;
+ scm_char_t *out = *outbuf;
+ scm_char_t *out_end = out + *outcharsleft;
+
+ while (in < in_end && out < out_end)
+ {
+ if (IS_ASCII_CHAR (*in))
+ *out++ = *in;
+ else
+ *out++ = BUILD_CHAR1 (charset, (*in | 0x80));
+ }
+
+ *inbuf = in;
+ *inbytesleft = in_end - in;
+ *outbuf = out;
+ *outcharsleft = out_end - out;
+
+ return scm_mb_read_ok;
+}
+
+static enum scm_mb_write_result
+iso8859_write (void *priv,
+ scm_char_t **inbuf, size_t *incharsleft,
+ char **outbuf, size_t *outbytesleft)
+{
+ unsigned char charset = * (unsigned char *) priv;
+ const scm_char_t *in = *inbuf;
+ const scm_char_t *in_end = in + *incharsleft;
+ char *out = *outbuf;
+ char *out_end = out + *outbytesleft;
+
+ while (in < in_end)
+ {
+ scm_char_t c;
+
+ if (out >= out_end)
+ {
+ *inbuf = in;
+ *incharsleft = in_end - in;
+ *outbuf = out;
+ *outbytesleft = out_end - out;
+
+ return scm_mb_write_more_room;
+ }
+
+ c = *in++;
+ if (IS_ASCII_CHAR (c))
+ *out++ = c;
+ else if (FIRST_CHAR1O <= c && c <= LAST_CHAR1O
+ && CHAR1_SET (c) == charset)
+ *out++ = CHAR1_POS (c) | 0x80;
+ else
+ /* We just eat characters not present in our character set. I
+ hope this doesn't screw anyone. */
+ ;
+ }
+
+ *inbuf = in;
+ *incharsleft = in_end - in;
+ *outbuf = out;
+ *outbytesleft = out_end - out;
+
+ return scm_mb_write_ok;
+}
+
+
+/* Initialization. */
+
+void
+scm_init_mbbasic ()
+{
+ /* The Emacs-Mule encoding.
+ When Guile switches to a UTF-8-like encoding, we'll move the name
+ "Guile" to that encoding. */
+ {
+ static char *names[] = { "Emacs-Mule", "Guile", 0 };
+ memset (&emacs_mule_encoding, 0, sizeof (emacs_mule_encoding));
+ emacs_mule_encoding.names = names;
+ emacs_mule_encoding.read = emacs_mule_read;
+ emacs_mule_encoding.write = emacs_mule_write;
+
+ scm_mb_register_encoding (&emacs_mule_encoding);
+ }
+
+ /* ISO 8859 character sets. */
+ {
+ int i;
+
+ for (i = 0;
+ i < (sizeof (iso8859_encodings) / sizeof (iso8859_encodings[0]));
+ i++)
+ scm_mb_register_encoding (&iso8859_encodings[i]);
+ }
+}
diff --git a/libguile/mbbasic.h b/libguile/mbbasic.h
new file mode 100644
index 000000000..08d1f69f7
--- /dev/null
+++ b/libguile/mbbasic.h
@@ -0,0 +1 @@
+extern void scm_init_mbbasic ();