From: Bruno Haible Date: Mon, 19 Feb 2024 22:25:12 +0000 (+0100) Subject: Remove support for OS/2 (based on EMX directly). X-Git-Tag: v0.23~273 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=742caba5824e66cf5e4f749e1b7be5b922554df3;p=thirdparty%2Fgettext.git Remove support for OS/2 (based on EMX directly). Nowadays, KO Myung-Hun uses an approach based on kLIBC instead of emx+gcc. This kLIBC (https://github.com/bitwiseworks/libc) contains iconv already. * os2: Remove directory. --- diff --git a/os2/Makefile b/os2/Makefile deleted file mode 100644 index 5824dee41..000000000 --- a/os2/Makefile +++ /dev/null @@ -1,241 +0,0 @@ -# -# OS/2 GNU Makefile for building gettext with GNU Make and GNU C compiler -# -# OS/2 still supports the regular configure/make building mechanism, but its -# way more clumsy, complicated and error prone. It is highly recommended to -# use this makefile instead, because : -# - this makefile builds an optimized static and dynamic version of the -# library -# - it is able to build both optimized and debug versions of the library -# without any reconfiguring -# - this makefile builds an backward compatible DLL. When building with -# configure you will get a DLL which is compatible only with the 0.10.40 -# and later DLLs of gettext; this makefile builds a DLL which is binary -# compatible with gettext 0.10.35 (exports by ordinal matter). -# - it is able to generate a complete OS/2 binary distribution (make distr) -# - besides its simply alot faster than configure generated makefiles -# -# The makefile is designed to be more or less gettext version independent, -# so it is likely to work with future versions of gettext as well. -# -# If you get unresolved dependencies (e.g. "don't know how to make somefile.h -# which is required for zzz.o) remove (or rebuild, if you have the makedep tool) -# the depend.mak file which contains all the dependencies. -# - -# Use CMD.EXE as shell since its way faster -SHELL = $(COMSPEC) -# An Unix-like shell (needed for running config.charset) -UNIXSHELL = sh.exe - -# Debug mode (1) or optimize mode (0) -DEBUG = 0 - -# The version of INTL.DLL (the name suffix) -INTLDLLVER = - -# Pack the DLL and executables with lxlite -LXLITE = 1 - -# Output directory -OUT = out/$(OUT.SUFFIX)/ -# Root package directory -ROOT = ../ -# The base directory for distribution archive (emx/ or usr/) -INST = emx/ - -# Tools -CC = gcc -c -CFLAGS = -Wall -Zmt $(INCLUDE) $(DEFS) -INCLUDE = -I. -I$(ROOT) -I$(ROOT)intl -I$(ROOT)src -I$(ROOT)lib -DEFS = -DHAVE_CONFIG_H -DLIBDIR=\"/usr/lib\" \ - -DLOCALEDIR=\"/usr/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/share/locale\" \ - -DGETTEXTDATADIR=\"/usr/share/gettext\" \ - -DPROJECTSDIR=\"/usr/share/gettext/projects\" \ - -DGETTEXTJAR=\"/usr/share/gettext/gettext.jar\" - - -LD = gcc -LDFLAGS = -Zmt -Zcrtdll -LDFLAGS.SHARED = -Zmt -Zcrtdll -Zdll -LIBS = -liconv -liberty -lgcc - -AR = ar -ARFLAGS = crs - -MKDIR = mkdir.exe -p -COPY = cp -p - -LINKINTL = $(OUT)intl.a - -ifeq ($(DEBUG),0) - CFLAGS += -s -O2 - LDFLAGS += -s -Zexe - LDFLAGS.SHARED += -s - OUT.SUFFIX = release -else - CFLAGS += -g - LDFLAGS += -g -Zexe - LDFLAGS.SHARED += -g - OUT.SUFFIX = debug - LXLITE := 0 - LINKINTL = $(OUT)intl_s.a -endif - -# Languages with encodings unsupported by OS/2 API (BIG5) -BAD.LINGUAS=zh - -# The list of languages to be included in binary distribution -LINGUAS = $(filter-out $(BAD.LINGUAS),$(shell sed -e "/^\#/d" $(ROOT)po/LINGUAS)) - -# Fetch version number from configure.in -VERSION = $(shell sed ../configure.in -ne "/AM_INIT_AUTOMAKE/{" -e "s/.*(gettext, *\\(.*\\))/\\1/" -e "p" -e "}") - -# Fetch the list of source files for libintl from intl/Makefile.in -INTL.SOURCES = $(addprefix $(ROOT)intl/,\ - $(subst $$lo,c,\ - $(subst @INTLOBJS@,intl-compat.c,\ - $(subst OBJECTS = ,,\ - $(subst \,,\ - $(shell sed $(ROOT)intl/Makefile.in -ne "/^OBJECTS =/,/[^\]$$/p")))))) -INTL.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(INTL.SOURCES:.c=.o))) - -PROGRAMS = $(addsuffix .exe,$(subst bin_PROGRAMS = ,,\ - $(subst \,,\ - $(shell sed $(ROOT)src/Makefile.am -ne "/^bin_PROGRAMS =/,/[^\]$$/p")))) -PROGRAMS.EXE = $(addprefix $(OUT),$(PROGRAMS)) -SRC.SOURCES = $(filter-out $(addprefix $(ROOT)src/,$(PROGRAMS:.exe=.c)),\ - $(wildcard $(ROOT)src/*.c)) -SRC.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(SRC.SOURCES:.c=.o))) -LIB.SOURCES = $(addprefix $(ROOT)lib/, error.c stpcpy.c stpncpy.c mkdtemp.c getline.c \ - $(subst libgettextlib_la_SOURCES = ,,\ - $(subst \,,\ - $(patsubst %.h,,\ - $(patsubst getopt%.c,,\ - $(shell sed $(ROOT)lib/Makefile.am -ne "/^libgettextlib_la_SOURCES =/,/[^\]$$/p")))))) -LIB.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIB.SOURCES:.c=.o))) - -OUTDIRS = $(OUT) $(sort $(dir $(INTL.OBJECTS) $(SRC.OBJECTS) $(LIB.OBJECTS) \ - $(LIBUNINAME.OBJECTS) $(INSTALL.FILES))) - -INSTALL.FILES = $(addprefix $(INST)bin/,$(PROGRAMS)) \ - $(INST)lib/intl.a $(INST)lib/intl_s.a $(INST)include/libintl.h \ - $(INST)dll/intl.dll $(INST)share/locale/charset.alias \ - $(INST)share/locale/locale.alias $(INST)doc/gettext-$(VERSION)/README.OS2 \ - $(INST)doc/gettext-$(VERSION)/COPYING $(INST)doc/gettext-$(VERSION)/README \ - $(addsuffix /LC_MESSAGES/gettext.mo,$(addprefix $(INST)share/locale/,$(LINGUAS))) \ - $(INSTALL.DIFF) - -.SUFFIXES: -.SUFFIXES: .o .a .def .exe .dll .po .mo -.PRECIOUS: $(OUT)%.o $(OUT)%.a - -.PHONY: all depend clean distr rmzip - -$(OUT)%.o: $(ROOT)%.c - $(CC) $(CFLAGS) -o $@ $< - -# To avoid playing with object file lists for every program we will build -# instead a library containing all the object files from src directory, and -# then link the library against the main program module, so that linker can -# pull all the required functions from there -$(OUT)%.exe: $(OUT)src/%.o $(OUT)util.a $(OUT)uniname.a $(LINKINTL) - $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) -ifeq ($(LXLITE),1) - lxlite /b- $@ -endif - -all: config.h $(OUTDIRS) $(ROOT)src/po-gram-gen2.h $(ROOT)lib/stdbool.h \ - $(ROOT)intl/libintl.h $(OUT)intl.a $(OUT)intl_s.a $(OUT)intl$(INTLDLLVER).dll \ - $(PROGRAMS.EXE) - -define MAKEDEP - echo $(OUT)PATH = FILENAME - makedep $(INCLUDE) $(DEFS) -p $$(OUT)PATH -r -a FILENAME -c -f depend.mak - -endef - -depend: $(INTL.SOURCES) $(SRC.SOURCES) -# Remove all dependencies - rm -f depend.mak -# Build dependencies, by one file (to avoid 1024 chars command line length limit) - @$(foreach fn,$^,$(subst PATH,$(subst ../,,$(dir $(fn))),$(subst FILENAME,$(fn),$(MAKEDEP)))) - -clean: - rm -rf out emx config.h - -distr: all rmzip gettext-os2-$(VERSION)-bin.zip - -rmzip: - rm -f gettext-os2-$(VERSION)-bin.zip - -# How to configure without configure... -config.h: ../config.h.in ./configure.awk - gawk -f configure.awk -v PACKAGE=gettext -v VERSION=$(VERSION) $< >config.h - -$(OUTDIRS): - $(MKDIR) $(@:/=) - -$(OUT)intl_s.a: $(INTL.OBJECTS) - $(AR) $(ARFLAGS) $@ $^ - -$(OUT)intl.def: $(INTL.OBJECTS) - @echo LIBRARY INTL$(INTLDLLVER) INITINSTANCE TERMINSTANCE>$@ - @echo DESCRIPTION "GNU gettext internationalization library version $(VERSION)">>$@ - @echo DATA MULTIPLE NONSHARED>>$@ - @echo EXPORTS>>$@ - type backward.def>>$@ - emxexp -u $^ >>$@ - -$(OUT)intl$(INTLDLLVER).dll: $(INTL.OBJECTS) $(OUT)intl.def - @echo ********************************************************* - @echo *** YOU CAN SAFELY IGNORE WARNINGS FROM EMXBIND BELOW *** - @echo ********************************************************* - $(LD) $(LDFLAGS.SHARED) -o $@ $^ $(LIBS) -ifeq ($(LXLITE),1) - lxlite $@ -endif - -# How to build an import library from a .DEF file -$(OUT)%.a: $(OUT)%.def - emximp -o $@ $< - -$(OUT)util.a: $(SRC.OBJECTS) $(LIB.OBJECTS) - $(AR) $(ARFLAGS) $@ $^ - -$(OUT)uniname.a: $(LIBUNINAME.OBJECTS) - $(AR) $(ARFLAGS) $@ $^ - -$(ROOT)src/po-gram-gen2.h: $(ROOT)src/po-gram-gen.h - sed -e "s/[yY][yY]/po_gram_/g" $< > $@ - -$(ROOT)intl/libintl.h: $(ROOT)intl/libgnuintl.h - $(COPY) $< $@ - -$(ROOT)lib/stdbool.h: $(ROOT)lib/stdbool.h.in - $(COPY) $< $@ - -gettext-os2-$(VERSION)-bin.zip: $(INSTALL.FILES) - @rm -f $@ - zip -9XD $@ $^ - -# The following rules are for `make distr' target only - -$(INST)share/locale/charset.alias: $(ROOT)lib/config.charset - $(UNIXSHELL) $< i386-pc-os2-emx >$@ -$(INST)share/locale/locale.alias: $(ROOT)intl/locale.alias - $(COPY) $< $@ -$(INST)bin/% $(INST)lib/% $(INST)dll/%: $(OUT)% - $(COPY) $< $@ -$(INST)include/%: $(ROOT)intl/% - $(COPY) $< $@ -$(INST)doc/gettext-$(VERSION)/%: $(ROOT)% - $(COPY) $< $@ -$(INST)doc/gettext-$(VERSION)/% $(INST)include/%: % - $(COPY) $< $@ -$(INST)share/locale/%/LC_MESSAGES/gettext.mo: $(ROOT)po/%.po - $(MKDIR) $(dir $@) - $(COMSPEC) /c "$(subst /,\\,set BEGINLIBPATH=$(OUT:/=) && \ - $(OUT)msgfmt.exe) --statistics --verbose -o $@ $<" - --include depend.mak diff --git a/os2/README.OS2 b/os2/README.OS2 deleted file mode 100644 index 732942ef0..000000000 --- a/os2/README.OS2 +++ /dev/null @@ -1,182 +0,0 @@ - -Welcome! -======== - -This is the OS/2 port of GNU gettext internationalization library. - - -Compatibility -============= - -The library has been compiled with -Zmt flag, but it doesn't matter as soon -as you use the EMX single-threaded runtime fix (emx-strt-fix-0.0.2.zip). - -The library is fully compatible with the previous port of gettext library -(0.10.35) which is largely used especialy by XFree86/2 programs. All the -old programs that I have with gettext support run fine with the new version -of the DLL. - - -Installation -============ - -If you set the GNULOCALEDIR environment variable to point to your -x:/xxx/share/locale directory, it will override any other setting. That is, -unpack the binary distribution over /emx, set GNULOCALEDIR=x:/emx/share/locale -(where x: is the drive letter of your EMX installation) and that's all. - -If you use the UNIXROOT environment variable, the default catalogue search -paths will be like on Unices, e.g. $(UNIXROOT)/usr/lib and -$(UNIXROOT)/usr/share/locale. GNULOCALEDIR always overrides this. - -Now if you haven't did it earlier, set the language identifier that you use. -This is done by adding a "SET LANG=xxx" environment setting to your CONFIG.SYS, -where xxx is the identifier of your language (example: en_UK for English in UK, -ru_RU for Russian in Russia. Also you can use names like "russian", "italian" -and so on - see the share/locale/locale.alias file). - -This port of gettext supports character set conversions. This means that if -your .mo files were written using new gettext guidelines, e.g. they contain a -message like this: - -msgid "" -msgstr "Content-Type: text/plain; charset=koi8-r\n" - -the messages will be properly converted to your active codepage using OS/2 -Unicode API. For example, russian message catalog gettext.mo is in the -KOI8-R (codepage 878) encoding while OS/2 uses codepage 866. Now when you -run any of these tools it detects that the active OS/2 codepage is 866 and -performs the translation from CP878 -> CP866 for every message. - -If you want to override the character set used to output messages (for example -in XFree86 for Russian the KOI8-R encoding (codepage 878) is used) you can -set the output character set by adding a postfix to the LANG environment -variable, this way: - -set LANG=ru_RU.KOI8-R - -or (equivalent): - -set LANG=ru_RU.CP878 - -or (same effect): - -set LANG=ru_RU.IBM-878 - -If the output character set is ommited from the LANG variable, the default -codepage is ALWAYS taken from the operating system (e.g. the codepage setting -from locale.alias is always ignored, so "russian" stays just for "ru_RU" and -not for "ru_RU.ISO-8859-5"); you may want to set it just if you want to -override the active OS/2 codepage. - - -XFree86 setup -============= - -If you use XFree86 and the OS/2 default character set is different from the -XFree86 default character set (e.g. for Russain CP866 vs KOI8-R), you can add -the following (or similar) statement to your startx.cmd file (after the -commands dealing with HOME and X11SHELL): - -call VALUE 'LANG', 'ru_RU.KOI8-R', env - -Otherwise you can get incorrect (wrong codepage) output from programs that -previously worked (e.g. GIMP 1.22). This is because earlier versions of gettext -didn't support character set translations. - - -Implementation remarks -====================== - -The codepage conversion code uses OS/2 Unicode API, thus it falls under the -limits that OS/2 Unicode API has. For example, OS/2 Unicode API does not -support the BIG5 East Asian character set nor ISO-8859-X where X > 9 (at -least with Warp4 with fixpack 14 that I have). If someone knows the -OS/2 API identifiers for BIG5 or ISO8859-10,... encodings, please tell me! - -Since gettext 0.11 iconv emulation layer supports correctly UTF-8. Also -I have added theoretical support for the following East Asian encodings: -EUC-JP, EUC-KR, EUC-TW, EUC-CN. However, these encodings are (I believe) -supported only on East Asian editions of OS/2. The code pages for them are -listed in the \language\codepage\ucstbl.lst file but the codepage files -themselves are missing; I believe they are ommited from European OS/2's -due to their large size. - -Also I have added "support" for the BIG5 codeset as an alias for IBM-950 -codepage. However, I'm not very sure about this; in any case OS/2 does not -support (as far as I know) anything closer to BIG5. - - -Additional API -============== - -This package provides additionaly the iconv() API that can be used by -developers for doing more feature-full Unix ports. The iconv() API is used -to convert text between various codepages. The intl.h header file contains -the prototypes and definitions needed for iconv(); if you configure software -with autoconf it possibly will find intl.h and set up the software accordingly. - -All these functions are exported from INTL.DLL. The iconv.a import library -imports all the iconv* functions from INTL.DLL. So, like on Unix, now you can -#include , then link with -liconv and you will get a fully functional -iconv implementation. - - -Rebuilding the library -====================== - -The library is quite easy to rebuild. Since the OS/2 support is provided now -out-of-the-box in gettext, you just have to download and unpack the source -archive. Now there are two ways to rebuild the gettext library: - -1. If you're a masochist you can go the clumsy configure/make Unix way. This -is not recommended however as I found no way to tell libtool to generate a -slightly non-standard DLL which will be backward compatible with gettext -0.10.35. The compatibility is achieved by prepending backward.def to the -export definition file generated with emximp or somehow else. Thus it is -highly recommended you build using the second way, if it is possible. - -2. Go to os2 and just run `make'. If you have all the required tools, -it should painlessly compile. Finally, if you want a binary distribution -archive, do `make distr'. The weak side of building this way is that makefile -is somewhat fragile. This means that if the makefile is left unmodified and -a new version of gettext is rolled out, it *may* not work. But every possible -attempt was made to ensure that the makefile takes most important build -parameters from their autoconf counterparts. - -WARNING: Due to bugs in GNU Make 3.76.1 (at least in its OS/2 port) you can -get sometimes (depending on make version and makefile modification :) funny -messages like these: - -zip warning: name not matched: emx/src/gettext-0.10.40/support/os2/iconv.h - -or even: - -*** No rule to make target `out/release/intl.a', needed by `all'. Stop. - -Such messages are a bad joke. Ignore it, and re-run make. This is a -long-standing bug in GNU make, alas. - -If you want a debug version of library, you can do `make DEBUG=1'. - -If you don't have the LxLite tool installed, do `make LXLITE=0' - -NB: For best results, it is highly recommended that you use at least emxbind.exe -and ld.exe from gcc 3.0.2 or later, since they contain a number of fixes that -will help you generate a more optimal DLL. - - -Contributors -============ - -Hung-Chi Chu - the original port of gettext (0.10.35) - -Jun SAWATAISHI - some more work on it and submitted the patches to GNU team, although - they were not completely integrated. - -Andrew Zabolotny - Succeeded to remove almost all OS/2-specific #ifdef's from mainstream - source code, wrote the dedicated OS/2 makefile, wrote the iconv wrapper - around OS/2 Unicode API, added support for locale translations. diff --git a/os2/backward.def b/os2/backward.def deleted file mode 100644 index 3183f9f23..000000000 --- a/os2/backward.def +++ /dev/null @@ -1,13 +0,0 @@ -; These exports are for backward compatibility with older ports -; of gettext for OS/2 that export everything by ordinals. - _$gettext=gettext @1 NONAME - _$gettext__=gettext__ @2 NONAME - _$dgettext=dgettext @3 NONAME - _$dgettext__=dgettext__ @4 NONAME - _$dcgettext=dcgettext @5 NONAME - _$dcgettext__=dcgettext__ @6 NONAME - _$textdomain=textdomain @7 NONAME - _$textdomain__=textdomain__ @8 NONAME - _$bindtextdomain=bindtextdomain @9 NONAME - _$bindtextdomain__=bindtextdomain__ @10 NONAME - _$_nl_msg_cat_cntr=_nl_msg_cat_cntr @11 NONAME diff --git a/os2/configure.awk b/os2/configure.awk deleted file mode 100644 index f40e517be..000000000 --- a/os2/configure.awk +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/gawk -f -# A script for emulating configure on OS/2 without having even a Unix-like -# shell. Designed specifically for compiling gettext with gcc+emx. - -BEGIN{ - print "/* config.h. Generated automatically by configure.awk. */" - - cfg["HAVE_ALLOCA"] = 1; - cfg["HAVE_ALLOCA_H"] = 1; - cfg["HAVE_LONG_FILE_NAMES"] = 1; - cfg["STDC_HEADERS"] = 1; - cfg["HAVE_GETCWD"] = 1; - cfg["HAVE_GETEGID"] = 1; - cfg["HAVE_GETEUID"] = 1; - cfg["HAVE_GETGID"] = 1; - cfg["HAVE_GETPAGESIZE"] = 1; - cfg["HAVE_GETUID"] = 1; - cfg["HAVE_ISASCII"] = 1; - cfg["HAVE_MBLEN"] = 1; - cfg["HAVE_MEMCPY"] = 1; - cfg["HAVE_MEMMOVE"] = 1; - cfg["HAVE_MEMSET"] = 1; - cfg["HAVE_PUTENV"] = 1; - cfg["HAVE_STRCHR"] = 1; - cfg["HAVE_STRCSPN"] = 1; - cfg["HAVE_STRDUP"] = 1; - cfg["HAVE_STRERROR"] = 1; - cfg["HAVE_STRSTR"] = 1; - cfg["HAVE_STRTOUL"] = 1; - cfg["HAVE_UNAME"] = 1; - cfg["HAVE_LIMITS_H"] = 1; - cfg["HAVE_LOCALE_H"] = 1; - cfg["HAVE_MALLOC_H"] = 1; - cfg["HAVE_STDDEF_H"] = 1; - cfg["HAVE_STDLIB_H"] = 1; - cfg["HAVE_STRING_H"] = 1; - cfg["HAVE_SYS_PARAM_H"] = 1; - cfg["HAVE_UNISTD_H"] = 1; - cfg["HAVE_GETTIMEOFDAY"] = 1; - cfg["HAVE_PATHCONF"] = 1; - cfg["HAVE_RAISE"] = 1; - cfg["HAVE_SELECT"] = 1; - cfg["HAVE_STRPBRK"] = 1; - cfg["HAVE_UTIME"] = 1; - cfg["HAVE_UTIMES"] = 1; - cfg["HAVE_WAITPID"] = 1; - cfg["HAVE_ARPA_INET_H"] = 1; - cfg["HAVE_DIRENT_H"] = 1; - cfg["HAVE_FCNTL_H"] = 1; - cfg["HAVE_SYS_TIME_H"] = 1; - cfg["HAVE_TIME_H"] = 1; - cfg["HAVE_POSIX_SIGNALBLOCKING"] = 1; - cfg["HAVE_ERRNO_DECL"] = 1; - cfg["HAVE_ICONV"] = 1; - cfg["ICONV_CONST"] = "const"; - cfg["_GNU_SOURCE"] = 1; - cfg["HAVE_UNSIGNED_LONG_LONG"] = 1; - cfg["HAVE_PTRDIFF_T"] = 1; - cfg["vfork"] = "fork"; - cfg["uintmax_t"] = "unsigned long long"; - cfg["HAVE_DECL_WCWIDTH"] = 0; - cfg["mbstate_t"] = "int"; - cfg["SETLOCALE_CONST"] = "const"; - cfg["ENABLE_NLS"] = 1; - - cfg["PACKAGE"] = "\""PACKAGE"\""; - cfg["VERSION"] = "\""VERSION"\""; -} - -/^#undef/ { - if (cfg[$2] != "") - print "#define "$2" "cfg[$2]; - else - print "/* #undef "$2" */"; - next -} - -{ - print $0 -} diff --git a/os2/iconv/Makefile b/os2/iconv/Makefile deleted file mode 100644 index 268932ea3..000000000 --- a/os2/iconv/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# -# OS/2 GNU Makefile for building libiconv with GNU Make and GNU C compiler -# -# This makefile will build iconv.dll, iconv.a (the import library for ICONV.DLL) -# and iconv_s.a (static library). -# -# You will need the Unicode API add-on for EMX, which is included with latest -# distributions of gcc for OS/2 (gcc 3.0 and later). -# - -# Use CMD.EXE as shell since its way faster -SHELL = $(COMSPEC) - -# Pack the DLL and executables with lxlite -LXLITE = 1 - -# Tools -CC = gcc -c -CFLAGS = -s -O2 -Wall -Zmt $(INCLUDE) $(DEFS) -INCLUDE = -I. - -LD = gcc -LDFLAGS.SHARED = -s -Zmt -Zcrtdll -Zdll -LIBS = -lgcc - -AR = ar -ARFLAGS = crs - -.SUFFIXES: -.SUFFIXES: .o .a .def .dll - -.PHONY: all clean - -ICONV.VERSION = 0.0.1 -ICONV.OBJECTS = iconv.o - -# How to compile a .c file -$(OUT)%.o: %.c - $(CC) $(CFLAGS) -o $@ $< - -# How to build an import library from a .DEF file -$(OUT)%.a: $(OUT)%.def - emximp -o $@ $< - -all: iconv.dll iconv.a iconv_s.a - -clean: - rm -rf *.o iconv.dll iconv*.a iconv.def - -iconv_s.a: $(ICONV.OBJECTS) - $(AR) $(ARFLAGS) $@ $^ - -$(OUT)iconv.def: $(ICONV.OBJECTS) - @echo LIBRARY ICONV INITINSTANCE TERMINSTANCE>$@ - @echo DESCRIPTION "iconv API library version $(ICONV.VERSION)">>$@ - @echo DATA MULTIPLE NONSHARED>>$@ - @echo EXPORTS>>$@ - emxexp $^ >>$@ - -$(OUT)iconv.dll: $(ICONV.OBJECTS) $(OUT)iconv.def - $(LD) $(LDFLAGS.SHARED) -o $@ $^ $(LIBS) -ifeq ($(LXLITE),1) - lxlite $@ -endif diff --git a/os2/iconv/README b/os2/iconv/README deleted file mode 100644 index 2dc449c97..000000000 --- a/os2/iconv/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory implements the POSIX iconv() function family, based on the -OS/2 Unicode API. It is independent of GNU gettext. diff --git a/os2/iconv/iconv.c b/os2/iconv/iconv.c deleted file mode 100644 index 23922de75..000000000 --- a/os2/iconv/iconv.c +++ /dev/null @@ -1,191 +0,0 @@ -/* OS/2 iconv() implementation through OS/2 Unicode API - Copyright (C) 2001-2002 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -/* - This file implements an iconv wrapper based on OS/2 Unicode API. -*/ - -#include - -typedef struct _iconv_t -{ - UconvObject from; /* "From" conversion handle */ - UconvObject to; /* "To" conversion handle */ -} *iconv_t; - -/* Tell "iconv.h" to not define iconv_t by itself. */ -#define _ICONV_T -#include "iconv.h" - -#include -#include -#include -#include - -/* Convert an encoding name to te form understood by UniCreateUconvObject. */ -static inline void -cp_convert (const char *cp, UniChar *ucp) -{ - size_t sl = 0; - - if (!stricmp (cp, "EUC-JP")) - memcpy (ucp, L"IBM-954", 8*2); - else if (!stricmp (cp, "EUC-KR")) - memcpy (ucp, L"IBM-970", 8*2); - else if (!stricmp (cp, "EUC-TW")) - memcpy (ucp, L"IBM-964", 8*2); - else if (!stricmp (cp, "EUC-CN")) - memcpy (ucp, L"IBM-1383", 9*2); - else if (!stricmp (cp, "BIG5")) - memcpy (ucp, L"IBM-950", 8*2); - else - { - /* Transform CPXXX naming style to IBM-XXX style */ - if ((cp[0] == 'C' || cp[0] == 'c') && (cp[1] == 'P' || cp[1] == 'p')) - { - ucp[sl++] = 'I'; - ucp[sl++] = 'B'; - ucp[sl++] = 'M'; - ucp[sl++] = '-'; - cp += 2; - } - - while (*cp != '\0') - ucp[sl++] = *cp++; - ucp[sl] = 0; - } -} - -iconv_t -iconv_open (const char *cp_to, const char *cp_from) -{ - UniChar *ucp; - iconv_t conv; - uconv_attribute_t attr; - - conv = (iconv_t) malloc (sizeof (struct _iconv_t)); - if (conv == NULL) - { - errno = ENOMEM; - return (iconv_t)(-1); - } - - ucp = (UniChar *) alloca ((strlen (cp_from) + 2 + 1) * sizeof (UniChar)); - cp_convert (cp_from, ucp); - if (UniCreateUconvObject (ucp, &conv->from)) - { - free (conv); - errno = EINVAL; - return (iconv_t)(-1); - } - - ucp = (UniChar *) alloca ((strlen (cp_to) + 2 + 1) * sizeof (UniChar)); - cp_convert (cp_to, ucp); - if (UniCreateUconvObject (ucp, &conv->to)) - { - UniFreeUconvObject (conv->from); - free (conv); - errno = EINVAL; - return (iconv_t)(-1); - } - - UniQueryUconvObject (conv->from, &attr, sizeof (attr), NULL, NULL, NULL); - /* Do not treat 0x7f as a control character - (don't understand what it exactly means but without it MBCS prefix - character detection sometimes could fail (when 0x7f is a prefix)). - And don't treat the string as a path (the docs also don't explain - what it exactly means, but I'm pretty sure converted texts will - mostly not be paths). */ - attr.converttype &= ~(CVTTYPE_CTRL7F | CVTTYPE_PATH); - UniSetUconvObject (conv->from, &attr); - - return conv; -} - -size_t -iconv (iconv_t conv, - const char **in, size_t *in_left, - char **out, size_t *out_left) -{ - int rc; - size_t sl = *in_left, nonid; - UniChar *ucs = (UniChar *) alloca (sl * sizeof (UniChar)); - UniChar *orig_ucs = ucs; - size_t retval = 0; - - rc = UniUconvToUcs (conv->from, (void **)in, in_left, &ucs, &sl, &retval); - if (rc) - goto error; - sl = ucs - orig_ucs; - ucs = orig_ucs; - /* UniUconvFromUcs will stop at first nul byte (huh? indeed?) - while we want ALL the bytes converted. */ -#if 1 - rc = UniUconvFromUcs (conv->to, &ucs, &sl, (void **)out, out_left, &nonid); - if (rc) - goto error; - retval += nonid; -#else - while (sl) - { - size_t usl = 0; - while (sl && (ucs[usl] != 0)) - usl++, sl--; - rc = UniUconvFromUcs (conv->to, &ucs, &usl, (void **)out, out_left, &nonid); - if (rc) - goto error; - retval += nonid; - if (sl && *out_left) - { - *(*out)++ = 0; - (*out_left)--; - ucs++; sl--; - } - } -#endif - return 0; - -error: - /* Convert OS/2 error code to errno. */ - switch (rc) - { - case ULS_ILLEGALSEQUENCE: - errno = EILSEQ; - break; - case ULS_INVALID: - errno = EINVAL; - break; - case ULS_BUFFERFULL: - errno = E2BIG; - break; - default: - errno = EBADF; - break; - } - return (size_t)(-1); -} - -int -iconv_close (iconv_t conv) -{ - if (conv != (iconv_t)(-1)) - { - UniFreeUconvObject (conv->to); - UniFreeUconvObject (conv->from); - free (conv); - } - return 0; -} diff --git a/os2/iconv/iconv.h b/os2/iconv/iconv.h deleted file mode 100644 index a6c66efaa..000000000 --- a/os2/iconv/iconv.h +++ /dev/null @@ -1,41 +0,0 @@ -/* OS/2 iconv() implementation through OS/2 Unicode API - Copyright (C) 2001 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ - -#ifndef __ICONV_H__ -#define __ICONV_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* FIXME: This belongs in . */ -#define EILSEQ 1729 - -#ifndef _ICONV_T -typedef void *iconv_t; -#endif - -extern iconv_t iconv_open (const char *, const char *); -extern size_t iconv (iconv_t, const char **, size_t *, char **, size_t *); -extern int iconv_close (iconv_t); - -#ifdef __cplusplus -} -#endif - -#endif /* __ICONV_H__ */