Skip to content

Commit 3af9cd3

Browse files
committed
Import from libiconv-0.3.
0 parents  commit 3af9cd3

File tree

144 files changed

+57775
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+57775
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bruno Haible <haible@clisp.cons.org>

COPYING.LIB

Lines changed: 482 additions & 0 deletions
Large diffs are not rendered by default.

DESIGN

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
While some other iconv(3) implementations - like FreeBSD iconv(3) - choose
2+
the "many small shared libraries" and dlopen(3) approach, this implementation
3+
packs everything into a single shared library. Here is a comparison of the
4+
two designs.
5+
6+
* Run-time efficiency
7+
1. A dlopen() based approach needs a cache of loaded shared libraries.
8+
Otherwise, every iconv_open() call will result in a call to dlopen()
9+
and thus to file system related system calls - which is prohibitive
10+
because some applications use the iconv_open/iconv/iconv_close sequence
11+
for every single filename, string, or piece of text.
12+
2. In terms of virtual memory use, both approaches are on par. Being shared
13+
libraries, the tables are shared between any processes that use them.
14+
And because of the demand loading used by Unix systems (and because libiconv
15+
does not have initialization functions), only those parts of the tables
16+
which are needed (typically very few kilobytes) will be read from disk and
17+
paged into main memory.
18+
3. Even with a cache of loaded shared libraries, the dlopen() based approach
19+
makes more system calls, because it has to load one or two shared libraries
20+
for every encoding in use.
21+
22+
* Total size
23+
In the dlopen(3) approach, every shared library has a symbol table and
24+
relocation offset. All together, FreeBSD iconv installs more than 200 shared
25+
libraries with a total size of 2.3 MB. Whereas libiconv installs 0.45 MB.
26+
27+
* Extensibility
28+
The dlopen(3) approach is good for guaranteeing extensibility if the iconv
29+
implementation is distributed without source. (Or when, as in glibc, you
30+
cannot rebuild iconv without rebuilding your libc, thus possibly
31+
destabilizing your system.)
32+
The libiconv package achieves extensibility through the LGPL license:
33+
Every user has access to the source of the package and can extend and
34+
replace just libiconv.so.
35+
The places which have to be modified when a new encoding is added are as
36+
follows: add an #include statement in iconv.c, add an entry in the table in
37+
iconv.c, and of course, update the README and iconv_open.3 manual page.
38+
39+
* Use within other packages
40+
If you want to incorporate an iconv implementation into another package
41+
(such as a mail user agent or web browser), the single library approach
42+
is easier, because:
43+
1. In the shared library approach you have to provide the right directory
44+
prefix which will be used at run time.
45+
2. Incorporating iconv as a static library into the executable is easy -
46+
it won't need dynamic loading. (This assumes that your package is under
47+
the LGPL or GPL license.)
48+
49+
50+
All conversions go through Unicode. This is possible because most of the
51+
world's characters have already been allocated in the Unicode standard.
52+
Therefore we have for each encoding two functions:
53+
- For conversion from the encoding to Unicode, a function called xxx_mbtowc.
54+
- For conversion from Unicode to the encoding, a function called xxx_wctomb,
55+
and for stateful encodings, a function called xxx_reset which returns to
56+
the initial shift state.
57+
58+
59+
All our functions operate on a single Unicode character at a time. This is
60+
obviously less efficient than operating on an entire buffer of characters at
61+
a time, but it makes the coding considerably easier and less bug-prone. Those
62+
who wish best performance should install the Real Thing (TM): GNU libc 2.1
63+
or newer.
64+

Makefile.devel

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This is the developer's makefile, not the user's makefile.
2+
# Don't use it unless you know exactly what you do!
3+
4+
SHELL = /bin/sh
5+
MAKE = make
6+
7+
8+
all : configures src/config.h.msvc include/libiconv.h.msvc
9+
10+
11+
# Before making a new release:
12+
# - check that the encoding lists in README and iconv_open.3 are up to date,
13+
# - increment the version number in libiconv.h.in.
14+
# - do "make -f Makefile.devel".
15+
16+
17+
CONFIGURES = configure
18+
CONFIGURES_IN = configure.in
19+
20+
CLISP_DIR = /home/bruno/clisp
21+
ACLOCAL = $(CLISP_DIR)/src/autoconf/aclocal.m4
22+
ACSELECT = $(CLISP_DIR)/src/autoconf/acselect
23+
OTHERMACROS = $(CLISP_DIR)/src/autoconf/libtool.m4
24+
25+
autoconf/aclocal.m4 : $(ACLOCAL)
26+
($(ACSELECT) `cat $(CONFIGURES_IN) | grep '^[A-Z][A-Z]_' | sed 's,[^A-Z_].*$$,,g' | sort | uniq` < $(ACLOCAL) ; cat $(OTHERMACROS) | sed -e 's,AC_CANONICAL_HOST,CL_CANONICAL_HOST,g' -e 's,AC_PROG_RANLIB,CL_PROG_RANLIB,g') > autoconf/aclocal.m4
27+
28+
configures : $(CONFIGURES)
29+
30+
AUTOCONF_FILES = autoconf/aclocal.m4 autoconf/acgeneral.m4 autoconf/acspecific.m4
31+
32+
configure : configure.in $(AUTOCONF_FILES)
33+
autoconf/autoconf -m autoconf
34+
35+
check-configures : $(CONFIGURES)
36+
set -e; for f in $(CONFIGURES); do bash -x -n $$f; done
37+
38+
39+
src/config.h.msvc : src/config.h.in
40+
sed -e 's/#undef WORDS_LITTLEENDIAN$$/#define WORDS_LITTLEENDIAN 1/' < $< > $@
41+
42+
include/libiconv.h.msvc : include/libiconv.h.in
43+
sed -e 's/@INCLUDE_ICONV_H@//g' -e 's/@HAVE_ICONV_H@/0/' -e 's/@ICONV_CONST@/const/g' < $< > $@
44+
45+
46+
force :

Makefile.in

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Makefile for libiconv
2+
3+
#### Start of system configuration section. ####
4+
5+
# Directories used by "make":
6+
srcdir = @srcdir@
7+
8+
# Directories used by "make install":
9+
prefix = @prefix@
10+
local_prefix = /usr/local
11+
exec_prefix = $(prefix)
12+
libdir = $(exec_prefix)/lib
13+
includedir = $(prefix)/include
14+
mandir = $(prefix)/man
15+
16+
# Programs used by "make":
17+
RM = rm -f
18+
@SET_MAKE@
19+
20+
# Programs used by "make install":
21+
INSTALL = @INSTALL@
22+
INSTALL_PROGRAM = @INSTALL_PROGRAM@
23+
INSTALL_DATA = @INSTALL_DATA@
24+
25+
#### End of system configuration section. ####
26+
27+
SHELL = /bin/sh
28+
29+
all : force
30+
cd src; $(MAKE) -r all
31+
cd man; $(MAKE) -r all
32+
33+
# Installs the library and include files only. Typically called with only
34+
# $(libdir) and $(includedir) - don't use $(prefix) and $(exec_prefix) here.
35+
install-lib : all force
36+
cd src; $(MAKE) -r install-lib libdir='$(libdir)' includedir='$(includedir)'
37+
if [ ! -d $(includedir) ] ; then mkdir $(includedir) ; fi
38+
$(INSTALL_DATA) include/libiconv.h $(includedir)/iconv.h
39+
40+
install : force
41+
cd src; $(MAKE) -r install prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)'
42+
if [ ! -d $(prefix) ] ; then mkdir $(prefix) ; fi
43+
if [ ! -d $(exec_prefix) ] ; then mkdir $(exec_prefix) ; fi
44+
if [ ! -d $(includedir) ] ; then mkdir $(includedir) ; fi
45+
$(INSTALL_DATA) include/libiconv.h $(includedir)/iconv.h
46+
cd man; $(MAKE) -r install prefix='$(prefix)' exec_prefix='$(exec_prefix)' mandir='$(mandir)'
47+
48+
installdirs : force
49+
cd src; $(MAKE) -r installdirs prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)'
50+
if [ ! -d $(prefix) ] ; then mkdir $(prefix) ; fi
51+
if [ ! -d $(exec_prefix) ] ; then mkdir $(exec_prefix) ; fi
52+
if [ ! -d $(includedir) ] ; then mkdir $(includedir) ; fi
53+
cd man; $(MAKE) -r installdirs prefix='$(prefix)' exec_prefix='$(exec_prefix)' mandir='$(mandir)'
54+
55+
uninstall : force
56+
cd src; $(MAKE) -r uninstall prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)'
57+
$(RM) $(includedir)/iconv.h
58+
cd man; $(MAKE) -r uninstall prefix='$(prefix)' exec_prefix='$(exec_prefix)' mandir='$(mandir)'
59+
60+
check : force
61+
cd src; $(MAKE) -r check
62+
cd man; $(MAKE) -r check
63+
64+
mostlyclean : force
65+
cd src; $(MAKE) -r mostlyclean
66+
cd man; $(MAKE) -r mostlyclean
67+
68+
clean : force
69+
cd src; $(MAKE) -r clean
70+
cd man; $(MAKE) -r clean
71+
72+
distclean : force
73+
cd src; if test -f Makefile; then $(MAKE) -r distclean; fi
74+
cd man; if test -f Makefile; then $(MAKE) -r distclean; fi
75+
$(RM) config.status config.log config.cache Makefile libtool
76+
$(RM) include/libiconv.h
77+
78+
maintainer-clean : force
79+
cd src; if test -f Makefile; then $(MAKE) -r maintainer-clean; fi
80+
cd man; if test -f Makefile; then $(MAKE) -r maintainer-clean; fi
81+
$(RM) config.status config.log config.cache Makefile libtool
82+
$(RM) include/libiconv.h
83+
84+
force :
85+

Makefile.msvc

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Makefile for libiconv
2+
3+
#### Start of system configuration section. ####
4+
5+
# Directories used by "make install":
6+
prefix = /usr/local
7+
local_prefix = /usr/local
8+
exec_prefix = $(prefix)
9+
libdir = $(exec_prefix)/lib
10+
includedir = $(prefix)/include
11+
mandir = $(prefix)/man
12+
13+
# Programs used by "make":
14+
LN = copy
15+
RM = del
16+
17+
#### End of system configuration section. ####
18+
19+
SHELL = /bin/sh
20+
21+
all : force
22+
$(LN) include\libiconv.h.msvc include\libiconv.h
23+
cd src
24+
$(MAKE) -f Makefile.msvc all
25+
cd ..
26+
# cd man
27+
# $(MAKE) -f Makefile.msvc all
28+
# cd ..
29+
30+
install : force
31+
cd src; $(MAKE) -r install prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)'
32+
if [ ! -d $(prefix) ] ; then mkdir $(prefix) ; fi
33+
if [ ! -d $(exec_prefix) ] ; then mkdir $(exec_prefix) ; fi
34+
if [ ! -d $(includedir) ] ; then mkdir $(includedir) ; fi
35+
$(INSTALL_DATA) include/libiconv.h $(includedir)/iconv.h
36+
cd man; $(MAKE) -r install prefix='$(prefix)' exec_prefix='$(exec_prefix)' mandir='$(mandir)'
37+
38+
installdirs : force
39+
cd src; $(MAKE) -r installdirs prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)'
40+
if [ ! -d $(prefix) ] ; then mkdir $(prefix) ; fi
41+
if [ ! -d $(exec_prefix) ] ; then mkdir $(exec_prefix) ; fi
42+
if [ ! -d $(includedir) ] ; then mkdir $(includedir) ; fi
43+
cd man; $(MAKE) -r installdirs prefix='$(prefix)' exec_prefix='$(exec_prefix)' mandir='$(mandir)'
44+
45+
uninstall : force
46+
cd src; $(MAKE) -r uninstall prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)'
47+
$(RM) $(includedir)/iconv.h
48+
cd man; $(MAKE) -r uninstall prefix='$(prefix)' exec_prefix='$(exec_prefix)' mandir='$(mandir)'
49+
50+
check : force
51+
cd src
52+
$(MAKE) -f Makefile.msvc check
53+
cd ..
54+
# cd man
55+
# $(MAKE) -f Makefile.msvc check
56+
# cd ..
57+
58+
mostlyclean : force
59+
cd src
60+
$(MAKE) -f Makefile.msvc mostlyclean
61+
cd ..
62+
# cd man
63+
# $(MAKE) -f Makefile.msvc mostlyclean
64+
# cd ..
65+
66+
clean : force
67+
cd src
68+
$(MAKE) -f Makefile.msvc clean
69+
cd ..
70+
# cd man
71+
# $(MAKE) -f Makefile.msvc clean
72+
# cd ..
73+
74+
distclean : force
75+
cd src
76+
$(MAKE) -f Makefile.msvc distclean
77+
cd ..
78+
# cd man
79+
# $(MAKE) -f Makefile.msvc distclean
80+
# cd ..
81+
$(RM) config.status config.log config.cache Makefile
82+
$(RM) include\libiconv.h
83+
84+
maintainer-clean : force
85+
cd src
86+
$(MAKE) -f Makefile.msvc maintainer-clean
87+
cd ..
88+
# cd man
89+
# $(MAKE) -f Makefile.msvc maintainer-clean
90+
# cd ..
91+
$(RM) config.status config.log config.cache Makefile
92+
$(RM) include\libiconv.h
93+
94+
force :
95+

NEWS

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
New in 0.3:
2+
* Reduced the size of the tables needed for the JOHAB converter.
3+
* Portability to Win32.
4+
5+
New in 0.2:
6+
* Added KOI8-RU, CP850, CP866, CP874, CP950, ISO-2022-CN-EXT, GBK and
7+
ISO-2022-JP-1 converters.
8+
* Added MACINTOSH as an alias for MAC-ROMAN.
9+
* Added ASMO-708 as an alias for ISO-8859-6.
10+
* Added ELOT_928 as an alias for ISO-8859-7.
11+
* Improved the EUC-TW converter: Treat CNS 11643 plane 3.
12+
* Improved the ISO-2022-KR and EUC-KR converters: Hangul characters are
13+
decomposed into Jamo when needed.
14+
* Improved the CP932 converter.
15+
* Updated the CP1133, MULELAO-1 and ARMSCII-8 mappings.
16+
* The EUC-JP and SJIS converters now cover the user-defined range.
17+
* Fixed a possible buffer overrun in the JOHAB converter.
18+
* Fixed a bug in the UTF-7, ISO-2022-*, HZ decoders: a shift sequence a the
19+
end of the input no longer gives an error.
20+
* The HZ encoder now always terminates its output in the ASCII state.
21+
* Use a perfect hash table for looking up the aliases.
22+
23+
New in 0.1:
24+
* Portability to Linux/glibc-2.0.x, Linux/libc5, OSF/1, FreeBSD.
25+
* Fixed a bug in the EUC-JP decoder. Extended the ISO-2022-JP-2 converter.
26+
* Made TIS-620 mapping consistent with glibc-2.1.
27+

0 commit comments

Comments
 (0)