From dd714b8aad61bcff68a67ff3570018d946f09067 Mon Sep 17 00:00:00 2001 From: ms Date: Sat, 30 Sep 2006 16:33:03 +0000 Subject: [PATCH] Habe IPFire auf LFS 6.2 gebracht. Das hier ist der erste Teil. Nur Toolchain bisher. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@297 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/etc/nsswitch.conf | 12 +- lfs/bash | 19 +- lfs/binutils | 22 +- lfs/bzip2 | 18 +- lfs/ccache | 4 +- lfs/cleanup-toolchain | 56 + lfs/coreutils | 35 +- lfs/diffutils | 2 +- lfs/expect | 20 +- lfs/findutils | 21 +- lfs/gawk | 31 +- lfs/gcc | 100 +- lfs/gettext | 23 +- lfs/glibc | 52 +- lfs/grep | 21 +- lfs/gzip | 30 +- lfs/linux-libc-header | 86 + lfs/m4 | 24 +- lfs/make | 10 +- lfs/ncurses | 36 +- lfs/patch | 10 +- lfs/perl | 42 +- lfs/sed | 24 +- lfs/tar | 29 +- lfs/tcl | 18 +- lfs/texinfo | 20 +- lfs/util-linux | 47 +- make.sh | 74 +- src/patches/bash-3.1-fixes-8.patch | 723 +++ .../bzip2-1.0.3-bzgrep_security-1.patch | 35 + .../{ccache-2.3.patch => ccache-2.4.patch} | 0 src/patches/coreutils-5.96-i18n-1.patch | 4052 +++++++++++++++++ ...utils-5.96-suppress_uptime_kill_su-1.patch | 272 ++ src/patches/coreutils-5.96-uname-1.patch | 182 + src/patches/expect-5.43.0-spawn-1.patch | 217 + src/patches/gawk-3.1.5-segfault_fix-1.patch | 43 + src/patches/gcc-4.0.3-specs-1.patch | 336 ++ src/patches/glibc-2.3.6-inotify-1.patch | 45 + src/patches/glibc-2.3.6-linux_types-1.patch | 33 + src/patches/grep-2.5.1a-redhat_fixes-2.patch | 2109 +++++++++ src/patches/gzip-1.3.5-security_fixes-1.patch | 63 + src/patches/ncurses-5.5-fixes-1.patch | 225 + src/patches/perl-5.8.8-libc-2.patch | 32 + src/patches/tar-1.15.1-gcc4_fix_tests-1.patch | 25 + src/patches/tar-1.15.1-security_fixes-1.patch | 128 + src/patches/tar-1.15.1-sparse_fix-1.patch | 26 + src/patches/texinfo-4.8-multibyte-1.patch | 44 + src/patches/texinfo-4.8-tempfile_fix-2.patch | 80 + src/patches/util-linux-2.12r-cramfs-1.patch | 93 + src/scripts/langcache | 9 + src/scripts/updatelang | 6 - tools/version-check.sh | 52 + 52 files changed, 9251 insertions(+), 465 deletions(-) create mode 100644 lfs/cleanup-toolchain create mode 100644 lfs/linux-libc-header create mode 100644 src/patches/bash-3.1-fixes-8.patch create mode 100644 src/patches/bzip2-1.0.3-bzgrep_security-1.patch rename src/patches/{ccache-2.3.patch => ccache-2.4.patch} (100%) create mode 100644 src/patches/coreutils-5.96-i18n-1.patch create mode 100644 src/patches/coreutils-5.96-suppress_uptime_kill_su-1.patch create mode 100644 src/patches/coreutils-5.96-uname-1.patch create mode 100644 src/patches/expect-5.43.0-spawn-1.patch create mode 100644 src/patches/gawk-3.1.5-segfault_fix-1.patch create mode 100644 src/patches/gcc-4.0.3-specs-1.patch create mode 100644 src/patches/glibc-2.3.6-inotify-1.patch create mode 100644 src/patches/glibc-2.3.6-linux_types-1.patch create mode 100644 src/patches/grep-2.5.1a-redhat_fixes-2.patch create mode 100644 src/patches/gzip-1.3.5-security_fixes-1.patch create mode 100644 src/patches/ncurses-5.5-fixes-1.patch create mode 100644 src/patches/perl-5.8.8-libc-2.patch create mode 100644 src/patches/tar-1.15.1-gcc4_fix_tests-1.patch create mode 100644 src/patches/tar-1.15.1-security_fixes-1.patch create mode 100644 src/patches/tar-1.15.1-sparse_fix-1.patch create mode 100644 src/patches/texinfo-4.8-multibyte-1.patch create mode 100644 src/patches/texinfo-4.8-tempfile_fix-2.patch create mode 100644 src/patches/util-linux-2.12r-cramfs-1.patch create mode 100644 src/scripts/langcache delete mode 100644 src/scripts/updatelang create mode 100644 tools/version-check.sh diff --git a/config/etc/nsswitch.conf b/config/etc/nsswitch.conf index 7d86691543..067e63b48f 100644 --- a/config/etc/nsswitch.conf +++ b/config/etc/nsswitch.conf @@ -4,16 +4,12 @@ passwd: files group: files shadow: files -publickey: files - hosts: files dns networks: files -protocols: db files -services: db files -ethers: db files -rpc: db files - -netgroup: db files +protocols: files +services: files +ethers: files +rpc: files # End /etc/nsswitch.conf diff --git a/lfs/bash b/lfs/bash index e033880942..e5aa780956 100644 --- a/lfs/bash +++ b/lfs/bash @@ -26,7 +26,7 @@ include Config -VER = 2.05b +VER = 3.1 THISAPP = bash-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -37,12 +37,14 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) # ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) - EXTRA_CONFIG = --prefix=/usr --bindir=/bin --disable-nls + EXTRA_CONFIG = --prefix=/usr --bindir=/bin \ + --without-bash-malloc --with-installed-readline \ + --disable-nls EXTRA_MAKE = EXTRA_INSTALL = else TARGET = $(DIR_INFO)/$(THISAPP)-tools - EXTRA_CONFIG = --prefix=/tools --disable-nls + EXTRA_CONFIG = --prefix=/tools --without-bash-malloc --disable-nls EXTRA_MAKE = EXTRA_INSTALL = endif @@ -50,13 +52,12 @@ endif ############################################################################### # Top-level Rules ############################################################################### -objects = $(DL_FILE) $(THISAPP)-2.patch + +objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(THISAPP)-2.patch = $(URL_LFS)/bash/$(THISAPP)-2.patch -$(DL_FILE)_MD5 = 5238251b4926d778dfe162f6ce729733 -$(THISAPP)-2.patch_MD5 = dfc7399bb57798e18fbb99f9edce4da0 +$(DL_FILE)_MD5 = ef5304c4b22aaa5088972c792ed45d72 install : $(TARGET) @@ -86,9 +87,9 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-2.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/bash-3.1-fixes-8.patch cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install ln -sf bash /bin/sh ifneq "$(ROOT)" "" diff --git a/lfs/binutils b/lfs/binutils index 4cdc94b631..bd140c4db1 100644 --- a/lfs/binutils +++ b/lfs/binutils @@ -26,7 +26,7 @@ include Config -VER = 2.15.90.0.3 +VER = 2.16.1 THISAPP = binutils-$(VER) DL_FILE = $(THISAPP).tar.bz2 @@ -48,7 +48,7 @@ ifeq "$(LFS_PASS)" "1" EXTRA_INSTALL = else TARGET = $(DIR_INFO)/$(THISAPP)-tools2 - EXTRA_CONFIG = --prefix=/tools --enable-shared --with-lib-path=/tools/lib --disable-nls + EXTRA_CONFIG = --prefix=/tools --with-lib-path=/tools/lib --disable-nls EXTRA_MAKE = EXTRA_INSTALL = endif @@ -62,7 +62,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 1c1af0064ebd3d7bd99905874656a21e +$(DL_FILE)_MD5 = 6a9d529efb285071dad10e1f3d2b2967 install : $(TARGET) @@ -95,14 +95,24 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @mkdir $(DIR_SRC)/binutils-build cd $(DIR_SRC)/binutils-build && $(DIR_APP)/configure $(EXTRA_CONFIG) ifeq "$(ROOT)" "" - cd $(DIR_SRC)/binutils-build && make -j 3 $(EXTRA_MAKE) + cd $(DIR_SRC)/binutils-build && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_SRC)/binutils-build && make $(EXTRA_INSTALL) install else ifeq "$(LFS_PASS)" "1" - cd $(DIR_SRC)/binutils-build && make configure-host + cd $(DIR_SRC)/binutils-build && make $(MAKETUNING) + cd $(DIR_SRC)/binutils-build && make $(MAKETUNING) clean + cd $(DIR_SRC)/binutils-build && make $(MAKETUNING) $(EXTRA_MAKE) +else + cd $(DIR_SRC)/binutils-build && make $(MAKETUNING) $(EXTRA_MAKE) endif - cd $(DIR_SRC)/binutils-build && make -j 3 $(EXTRA_MAKE) cd $(DIR_SRC)/binutils-build && make $(EXTRA_INSTALL) install + cd $(DIR_SRC)/binutils-build && make -C ld clean +ifeq "$(LFS_PASS)" "1" + cd $(DIR_SRC)/binutils-build && make -C ld LIB_PATH=/tools/lib +else + cd $(DIR_SRC)/binutils-build && make -C ld LIB_PATH=/usr/lib:/lib +endif + cd $(DIR_SRC)/binutils-build && cp -v ld/ld-new /tools/bin endif @rm -rf $(DIR_APP) $(DIR_SRC)/binutils-build @$(POSTBUILD) diff --git a/lfs/bzip2 b/lfs/bzip2 index 2f26be0e16..ed3e1ed71c 100644 --- a/lfs/bzip2 +++ b/lfs/bzip2 @@ -80,22 +80,22 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/bzip2-1.0.2-use_mktemp-1.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/bzip2-1.0.2-chmod.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/bzip2-1.0.3-bzgrep_security-1.patch ifeq "$(ROOT)" "" + cd $(DIR_APP) && sed -i 's@tempfile -d /tmp -p bz@mktemp -p /tmp@' bzdiff cd $(DIR_APP) && make -f Makefile-libbz2_so cd $(DIR_APP) && make clean cd $(DIR_APP) && make rm -f /usr/bin/{bzgrep,bzegrep,bzfgrep,bzcmp,bzless} cd $(DIR_APP) && make install - cd $(DIR_APP) && cp bzip2-shared /bin/bzip2 - cd $(DIR_APP) && cp -a libbz2.so* /lib - ln -sf ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so - rm /usr/bin/{bunzip2,bzcat,bzip2} - mv /usr/bin/{bzip2recover,bzless,bzmore} /bin - ln -sf bzip2 /bin/bunzip2 - ln -sf bzip2 /bin/bzcat + cp -v bzip2-shared /bin/bzip2 + cp -av libbz2.so* /lib + ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so + rm -v /usr/bin/{bunzip2,bzcat,bzip2} + ln -sv bzip2 /bin/bunzip2 + ln -sv bzip2 /bin/bzcat else + cd $(DIR_APP) && make rm -f /tools/bin/{bzgrep,bzegrep,bzfgrep,bzcmp,bzless} cd $(DIR_APP) && make PREFIX=/tools install endif diff --git a/lfs/ccache b/lfs/ccache index e87d13de2c..834da8e214 100644 --- a/lfs/ccache +++ b/lfs/ccache @@ -26,7 +26,7 @@ include Config -VER = 2.3 +VER = 2.4 THISAPP = ccache-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -42,7 +42,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 5e4afc0b170bf282d1813aeaf3d577d2 +$(DL_FILE)_MD5 = 73c1ed1e767c1752dd0f548ec1e66ce7 install : $(TARGET) diff --git a/lfs/cleanup-toolchain b/lfs/cleanup-toolchain new file mode 100644 index 0000000000..c9b652a199 --- /dev/null +++ b/lfs/cleanup-toolchain @@ -0,0 +1,56 @@ +############################################################################### +# This file is part of the IPCop Firewall. # +# # +# IPCop 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 of the License, or # +# (at your option) any later version. # +# # +# IPCop 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 IPCop; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Makefiles are based on LFSMake, which is # +# Copyright (C) 2002 Rod Roard # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +THISAPP = cleanup-toolchain +TARGET = $(DIR_INFO)/$(THISAPP)-tools + +############################################################################### +# Top-level Rules +############################################################################### + +objects = + +install : $(TARGET) + +check : + +download : + +md5 : + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + -strip --strip-debug /tools/lib/* + -strip --strip-unneeded /tools/{,s}bin/* + rm -rfv /tools/{info,man} + chown -R root:root /tools + @$(POSTBUILD) diff --git a/lfs/coreutils b/lfs/coreutils index 349eb52ddb..dfd3cdf6ee 100644 --- a/lfs/coreutils +++ b/lfs/coreutils @@ -26,7 +26,7 @@ include Config -VER = 5.93 +VER = 5.96 THISAPP = coreutils-$(VER) DL_FILE = $(THISAPP).tar.bz2 @@ -50,13 +50,12 @@ endif ############################################################################### # Top-level Rules ############################################################################### -objects =$(DL_FILE) $(THISAPP)-uname-1.patch + +objects =$(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(THISAPP)-uname-1.patch = $(URL_LFS)/coreutils/$(THISAPP)-uname-1.patch -$(DL_FILE)_MD5 = 955d8abfd3dd8af2ca3af51480f1f9af -$(THISAPP)-uname-1.patch_MD5 = c05b735710fbd62239588c07084852a0 +$(DL_FILE)_MD5 = bf55d069d82128fd754a090ce8b5acff install : $(TARGET) @@ -86,23 +85,23 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-uname-1.patch -ifneq "$(ROOT)" "" - #previous patch of uname implies rebuild of doc/uname.1 which fails; remove doc&man build from toolchain - cd $(DIR_APP) && sed -i "s/SUBDIRS = lib src doc man po tests/SUBDIRS = lib src po tests/g" Makefile.in -endif - cd $(DIR_APP) && DEFAULT_POSIX2_VERSION=199209 ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make -j 3 $(EXTRA_MAKE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-uname-1.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-suppress_uptime_kill_su-1.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-i18n-1.patch + cd $(DIR_APP) && chmod +x tests/sort/sort-mb-tests + cd $(DIR_APP) && sed -i 's/_LEN 6/_LEN 20/' src/who.c + + cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install #use hostname from inet-tools ifeq "$(ROOT)" "" rm /usr/bin/hostname - mv -f /usr/bin/{basename,cat,chgrp,chmod,chown,cp,dd,df} /bin - mv -f /usr/bin/{dir,dircolors,du,date,echo,false,head} /bin - mv -f /usr/bin/{install,ln,ls,mkdir,mkfifo,mknod,mv,pwd} /bin - mv -f /usr/bin/{rm,rmdir,shred,sync,sleep,stty,su,test} /bin - mv -f /usr/bin/{touch,true,uname,vdir} /bin - mv -f /usr/bin/chroot /usr/sbin + mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin + mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin + mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin + mv -v /usr/bin/chroot /usr/sbin + mv -v /usr/bin/{head,sleep,nice} /bin ln -sf test /bin/[ ln -sf ../../bin/install /usr/bin mv -f /bin/uname /bin/uname.bak diff --git a/lfs/diffutils b/lfs/diffutils index dc252f2b40..0b61e0ec1c 100644 --- a/lfs/diffutils +++ b/lfs/diffutils @@ -86,7 +86,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/expect b/lfs/expect index ee6e055dc6..289cad35c8 100644 --- a/lfs/expect +++ b/lfs/expect @@ -26,24 +26,23 @@ include Config -VER = 5.41.0 +VER = 5.43.0 THISAPP = expect-$(VER) DL_FILE = $(THISAPP).tar.gz DL_FROM = $(URL_IPFIRE) -DIR_APP = $(DIR_SRC)/expect-5.41 +DIR_APP = $(DIR_SRC)/expect-5.43 TARGET = $(DIR_INFO)/$(THISAPP)-tools ############################################################################### # Top-level Rules ############################################################################### -objects=$(DL_FILE) $(THISAPP)-spawn-1.patch -$(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(THISAPP)-spawn-1.patch = $(URL_LFS)/expect/$(THISAPP)-spawn-1.patch +objects=$(DL_FILE) -$(DL_FILE)_MD5 = 490664773286690d111d9cd055c50700 -$(THISAPP)-spawn-1.patch_MD5 = ef6d0d0221c571fb420afb7033b3bbba +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = 43e1dc0e0bc9492cf2e1a6f59f276bc3 install : $(TARGET) @@ -73,10 +72,9 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) $(DIR_SRC)/tcl* && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_SRC) && tar zxf $(DIR_DL)/tcl8.4.6*.tar.gz - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-spawn-1.patch - cd $(DIR_APP) && ./configure --prefix=/tools --with-tcl=/tools/lib --with-x=no --disable-nls - cd $(DIR_APP) && make + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-spawn-1.patch + cd $(DIR_APP) && ./configure --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=/tools/include --with-x=no --disable-nls + cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make SCRIPTS="" install @rm -rf $(DIR_APP) $(DIR_SRC)/tcl* @$(POSTBUILD) diff --git a/lfs/findutils b/lfs/findutils index f856cc30f3..a6f6647c0d 100644 --- a/lfs/findutils +++ b/lfs/findutils @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: findutils,v 1.3.2.3 2005/02/26 12:26:43 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,18 +26,19 @@ include Config -VER = 4.1.20 +VER = 4.2.27 THISAPP = findutils-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/findutils +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. # ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) - EXTRA_CONFIG = --prefix=/usr --libexecdir=/usr/bin --disable-nls + EXTRA_CONFIG = --prefix=/usr --libexecdir=/usr/lib/findutils \ + --localstatedir=/var/lib/locate --disable-nls EXTRA_MAKE = EXTRA_INSTALL = else @@ -61,7 +56,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = e90ce7222daadeb8616b8db461e17cbc +$(DL_FILE)_MD5 = f1e0ddf09f28f8102ff3b90f3b5bc920 install : $(TARGET) @@ -92,7 +87,11 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install +ifeq "$(ROOT)" "" + mv -v /usr/bin/find /bin + sed -i -e 's/find:=${BINDIR}/find:=\/bin/' /usr/bin/updatedb +endif @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/gawk b/lfs/gawk index de4ff82afc..b074081370 100644 --- a/lfs/gawk +++ b/lfs/gawk @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: gawk,v 1.3.2.5 2005/02/05 15:38:14 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,18 +26,18 @@ include Config -VER = 3.1.3 +VER = 3.1.5 THISAPP = gawk-$(VER) -DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/gawk +DL_FILE = $(THISAPP).tar.bz2 +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. # ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) - EXTRA_CONFIG = --prefix=/usr --libexecdir=/usr/bin --disable-nls + EXTRA_CONFIG = --prefix=/usr --libexecdir=/usr/lib --disable-nls EXTRA_MAKE = EXTRA_INSTALL = else @@ -57,13 +51,11 @@ endif # Top-level Rules ############################################################################### -objects = $(DL_FILE) $(THISAPP)-libexecdir-1.patch +objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(THISAPP)-libexecdir-1.patch = $(URL_LFS)/gawk/$(THISAPP)-libexecdir-1.patch -$(DL_FILE)_MD5 = b637b454005f9e72a9a8eecfacd07ca0 -$(THISAPP)-libexecdir-1.patch_MD5 = af3f30cc056f7959cbbfd0341e7b0146 +$(DL_FILE)_MD5 = 5703f72d0eea1d463f735aad8222655f install : $(TARGET) @@ -92,13 +84,12 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) -ifeq "$(ROOT)" "" - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-libexecdir-1.patch -endif + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-segfault_fix-1.patch cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) - cd $(DIR_APP) && make $(EXTRA_MAKE) check + cd $(DIR_APP) && echo "#define HAVE_LANGINFO_CODESET 1" >> config.h + cd $(DIR_APP) && echo "#define HAVE_LC_MESSAGES 1" >> config.h + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/gcc b/lfs/gcc index b8fee4792b..df9187db92 100644 --- a/lfs/gcc +++ b/lfs/gcc @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: gcc,v 1.18.2.9 2006/01/22 21:58:23 franck78 Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 3.3.3 +VER = 4.0.3 THISAPP = gcc-$(VER) -DL_FILE = gcc-core-$(VER).tar.bz2 -DL_FROM = $(URL_GNU)/gcc/releases/gcc-$(VER) +DL_FILE = $(THISAPP).tar.bz2 +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) CFLAGS = CXXFLAGS = @@ -54,16 +48,18 @@ ifeq "$(ROOT)" "" else ifeq "$(LFS_PASS)" "1" TARGET = $(DIR_INFO)/$(THISAPP)-tools1 - EXTRA_CONFIG = --prefix=/tools --with-local-prefix=/tools \ - --disable-nls --enable-shared --enable-languages=c + EXTRA_CONFIG = --prefix=/tools \ + --with-local-prefix=/tools --disable-nls --enable-shared \ + --enable-languages=c EXTRA_MAKE = BOOT_LDFLAGS="-static" bootstrap EXTRA_INSTALL = else TARGET = $(DIR_INFO)/$(THISAPP)-tools2 - EXTRA_CONFIG = --prefix=/tools --with-local-prefix=/tools \ - --enable-clocale=gnu --enable-shared \ - --enable-threads=posix --enable-__cxa_atexit \ - --enable-languages=c,c++ --disable-nls + EXTRA_CONFIG = --prefix=/tools \ + --with-local-prefix=/tools --enable-clocale=gnu \ + --enable-shared --enable-threads=posix \ + --enable-__cxa_atexit --enable-languages=c,c++ \ + --disable-libstdcxx-pch EXTRA_MAKE = EXTRA_INSTALL = endif @@ -72,23 +68,11 @@ endif ############################################################################### # Top-level Rules ############################################################################### -objects = $(DL_FILE) \ - gcc-g++-$(VER).tar.bz2 \ - $(THISAPP)-specs-1.patch \ - $(THISAPP)-no_fixincludes-1.patch \ - gcc-3.3-ssp-4.patch +objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -gcc-g++-$(VER).tar.bz2 = $(URL_GNU)/gcc/releases/gcc-$(VER)/gcc-g++-$(VER).tar.bz2 -$(THISAPP)-specs-1.patch = $(URL_LFS)/gcc/$(THISAPP)-specs-1.patch -$(THISAPP)-no_fixincludes-1.patch = $(URL_LFS)/gcc/$(THISAPP)-no_fixincludes-1.patch -gcc-3.3-ssp-4.patch = $(URL_LFS)/gcc/gcc-3.3-ssp-4.patch -$(DL_FILE)_MD5 = f878a455b14b3830aaf2da0a17f003c0 -gcc-g++-$(VER).tar.bz2_MD5 = 29830b52f2c112fc660d662427660641 -$(THISAPP)-specs-1.patch_MD5 = 74cb9822f21774ae1c9a8ef1fa133f49 -$(THISAPP)-no_fixincludes-1.patch_MD5 = 5f764c74b3e9c36252fe4f9a14598ee4 -gcc-3.3-ssp-4.patch_MD5 = d31cccd0afbaaeeb95264164360ea135 +$(DL_FILE)_MD5 = 6ff1af12c53cbb3f79b27f2d6a9a3d50 install : $(TARGET) @@ -118,57 +102,25 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_SRC) && tar jxf $(DIR_DL)/gcc-g++-$(VER).tar.bz2 - # fix a macro in gcc3.3.3 hurting gcc4.x ! - cd $(DIR_APP) && sed -i "s/\*((void \*\*)__o.*;/*((void **)__o->next_free) = ((void *)datum); __o->next_free += sizeof(void *);/" include/obstack.h - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/gcc-3.3-ssp-4.patch - cd $(DIR_APP) && sed -i -e 's|^\(LIBGCC2_CFLAGS.*\)$$|\1 -D_LIBC_PROVIDES_SSP_|' gcc/Makefile.in + @mkdir $(DIR_SRC)/gcc-build ifeq "$(ROOT)" "" - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-no_fixincludes-1.patch + else -ifeq "$(LFS_PASS)" "2" - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-no_fixincludes-1.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-specs-1.patch -endif -endif - @mkdir $(DIR_SRC)/gcc-build +ifeq "$(LFS_PASS)" "1" cd $(DIR_SRC)/gcc-build && /bin/bash $(DIR_APP)/configure $(EXTRA_CONFIG) - cd $(DIR_SRC)/gcc-build && make -j 3 $(EXTRA_MAKE) + cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install -ifeq "$(ROOT)" "" - GCC_SPECS_DIR="`/usr/bin/gcc --print-libgcc-file-name`"; \ - GCC_SPECS="`dirname $$GCC_SPECS_DIR`/specs"; \ - if [ "$(MACHINE)" = "i386" ]; then \ - SSP_PROT_ALL_STRING="%(cc1_cpu) %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } } %{profile:-p}"; \ - elif [ "$(MACHINE)" = "alpha" ]; then \ - SSP_PROT_ALL_STRING="%{G*} %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } }"; \ - fi; \ - mv -f $${GCC_SPECS} $${GCC_SPECS}.noprot; \ - sed "/cc1:/{n;d}" $${GCC_SPECS}.noprot > $${GCC_SPECS}.tmp; \ - sed "s/cc1:/cc1:\n$${SSP_PROT_ALL_STRING}/" $${GCC_SPECS}.tmp > $${GCC_SPECS}.prot; \ - rm -f $${GCC_SPECS}.tmp; \ - cp -f $${GCC_SPECS}.prot $${GCC_SPECS} + ln -vs gcc /tools/bin/cc else -ifeq "$(LFS_PASS)" "2" - GCC_SPECS_DIR="`/tools/bin/gcc --print-libgcc-file-name`"; \ - GCC_SPECS="`dirname $$GCC_SPECS_DIR`/specs"; \ - if [ "$(MACHINE)" = "i386" ]; then \ - SSP_PROT_ALL_STRING="%(cc1_cpu) %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } } %{profile:-p}"; \ - elif [ "$(MACHINE)" = "alpha" ]; then \ - SSP_PROT_ALL_STRING="%{G*} %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } }"; \ - fi; \ - mv -f $${GCC_SPECS} $${GCC_SPECS}.noprot; \ - sed "/cc1:/{n;d}" $${GCC_SPECS}.noprot > $${GCC_SPECS}.tmp; \ - sed "s/cc1:/cc1:\n$${SSP_PROT_ALL_STRING}/" $${GCC_SPECS}.tmp > $${GCC_SPECS}.prot; \ - rm -f $${GCC_SPECS}.tmp; \ - cp -f $${GCC_SPECS}.prot $${GCC_SPECS} -endif + cd $(DIR_APP) && cp -v gcc/Makefile.in{,.orig} + cd $(DIR_APP) && sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in + cd $(DIR_APP) && cp -v gcc/Makefile.in{,.tmp} + #cd $(DIR_APP) && sed 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp > gcc/Makefile.in + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.0.3-specs-1.patch + cd $(DIR_SRC)/gcc-build && /bin/bash $(DIR_APP)/configure $(EXTRA_CONFIG) + cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE) + cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install endif -ifeq "$(ROOT)" "" - ln -sf ../usr/bin/cpp /lib - ln -sf gcc /usr/bin/cc -else - ln -sf gcc /tools/bin/cc endif @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build @$(POSTBUILD) diff --git a/lfs/gettext b/lfs/gettext index e28d5e0468..cc8c038562 100644 --- a/lfs/gettext +++ b/lfs/gettext @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: gettext,v 1.3.2.3 2005/02/05 15:38:15 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 0.14.1 +VER = 0.14.5 THISAPP = gettext-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/gettext +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -48,7 +42,7 @@ ifeq "$(ROOT)" "" EXTRA_INSTALL = else TARGET = $(DIR_INFO)/$(THISAPP)-tools - EXTRA_CONFIG = --prefix=/tools --disable-nls + EXTRA_CONFIG = --prefix=/tools --disable-shared --disable-nls EXTRA_MAKE = EXTRA_INSTALL = endif @@ -61,7 +55,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 78f4b862510beb2e5d43223dd610e77d +$(DL_FILE)_MD5 = e2f6581626a22a0de66dce1d81d00de3 install : $(TARGET) @@ -91,8 +85,15 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) +ifeq "$(ROOT)" "" cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install +else + cd $(DIR_APP)/gettext-tools && ./configure $(EXTRA_CONFIG) + cd $(DIR_APP)/gettext-tools && make -C lib $(MAKETUNING) + cd $(DIR_APP)/gettext-tools && make -C src msgfmt $(MAKETUNING) + cd $(DIR_APP)/gettext-tools && cp -v src/msgfmt /tools/bin +endif @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/glibc b/lfs/glibc index 1ad2ca6c93..0f6f774ed1 100644 --- a/lfs/glibc +++ b/lfs/glibc @@ -26,9 +26,9 @@ include Config -VER = 2.3.3 +VER = 2.3.6 -THISAPP = glibc-$(VER)-lfs-5.1 +THISAPP = glibc-$(VER) DL_FILE = $(THISAPP).tar.bz2 DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) @@ -40,18 +40,17 @@ CXXFLAGS = ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) EXTRA_CONFIG = --prefix=/usr \ - --disable-profile --enable-add-ons=linuxthreads \ - --libexecdir=/usr/lib --with-headers=/usr/include \ - --without-cvs --disable-nls + --disable-profile --enable-add-ons \ + --enable-kernel=2.6.0 --libexecdir=/usr/lib/glibc EXTRA_MAKE = EXTRA_INSTALL = else TARGET = $(DIR_INFO)/$(THISAPP)-tools EXTRA_CONFIG = --prefix=/tools \ - --disable-profile --enable-add-ons=linuxthreads \ - --with-headers=/tools/include \ - --with-binutils=/tools/bin --without-gd \ - --without-cvs --disable-nls + --disable-profile --enable-add-ons \ + --enable-kernel=2.6.0 --with-binutils=/tools/bin \ + --without-gd --with-headers=/tools/include \ + --without-selinux EXTRA_MAKE = EXTRA_INSTALL = endif @@ -60,11 +59,14 @@ endif # Top-level Rules ############################################################################### -objects = $(DL_FILE) +objects = $(DL_FILE) \ + glibc-libidn-$(VER).tar.bz2 $(DL_FILE) = $(DL_FROM)/$(DL_FILE) +glibc-libidn-$(VER).tar.bz2 = $(DL_FROM)/glibc-libidn-$(VER).tar.bz2 -$(DL_FILE)_MD5 = cd11fabdf5162ad68329e7b28b308278 +$(DL_FILE)_MD5 = bfdce99f82d6dbcb64b7f11c05d6bc96 +glibc-libidn-$(VER).tar.bz2_MD5 = 49dbe06ce830fc73874d6b38bdc5b4db install : $(TARGET) @@ -94,30 +96,25 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) $(DIR_SRC)/glibc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/glibc-2.3.3-ssp_frandom-2.patch @mkdir $(DIR_SRC)/glibc-build + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/glibc-2.3.6-linux_types-1.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/glibc-2.3.6-inotify-1.patch + # This locale causes a loop on bash login - exclude it + cd $(DIR_APP) && sed -i '/vi_VN.TCVN/d' localedata/SUPPORTED + cd $(DIR_APP) && sed -i 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=/lib/ld-linux.so.2 -o|' \ + scripts/test-installation.pl + cd $(DIR_SRC)/glibc-build && $(DIR_APP)/configure $(EXTRA_CONFIG) ifeq "$(ROOT)" "" touch /etc/ld.so.conf - cd $(DIR_SRC)/glibc-build && make $(EXTRA_MAKE) + cd $(DIR_SRC)/glibc-build && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_SRC)/glibc-build && make $(EXTRA_INSTALL) install + cp -v $(DIR_APP)/sysdeps/unix/sysv/linux/inotify.h /usr/include/sys else -mkdir /tools/etc touch /tools/etc/ld.so.conf - cd $(DIR_SRC)/glibc-build && make $(EXTRA_MAKE) AUTOCONF=no - cd $(DIR_SRC)/glibc-build && make $(EXTRA_INSTALL) AUTOCONF=no install -endif - - # Locking in the toolchain -ifeq "$(ROOT)" "" - SPECFILE=/tools/lib/gcc-lib/*/*/specs && \ - sed -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \ - $$SPECFILE > newspecfile && mv -f newspecfile $$SPECFILE -else - SPECFILE=/tools/lib/gcc-lib/*/*/specs && \ - sed -e 's@/lib/ld-linux.so.2@/tools/lib/ld-linux.so.2@g' \ - $$SPECFILE > tempspecfile && mv -f tempspecfile $$SPECFILE - rm -f /tools/lib/gcc-lib/*/*/include/{pthread.h,bits/sigthread.h} + cd $(DIR_SRC)/glibc-build && make $(MAKETUNING) $(EXTRA_MAKE) + cd $(DIR_SRC)/glibc-build && make $(EXTRA_INSTALL) install endif # Creating the locales @@ -128,6 +125,7 @@ else endif cd $(DIR_SRC)/glibc-build && localedef -i en_US -f ISO-8859-1 en_US cd $(DIR_SRC)/glibc-build && localedef -i en_US -f UTF-8 en_US.utf8 + cd $(DIR_SRC)/glibc-build && make localedata/install-locales # Configuring Glibc ifeq "$(ROOT)" "" diff --git a/lfs/grep b/lfs/grep index 3e89e584f5..9d9a9bf266 100644 --- a/lfs/grep +++ b/lfs/grep @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: grep,v 1.3.2.3 2005/02/26 20:13:20 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,25 +26,24 @@ include Config -VER = 2.5.1 +VER = 2.5.1a THISAPP = grep-$(VER) DL_FILE = $(THISAPP).tar.bz2 -DL_FROM = $(URL_GNU)/grep +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. # ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) - EXTRA_CONFIG = --prefix=/usr --bindir=/bin \ - --with-included-regex --disable-nls + EXTRA_CONFIG = --prefix=/usr --bindir=/bin --disable-nls EXTRA_MAKE = EXTRA_INSTALL = else TARGET = $(DIR_INFO)/$(THISAPP)-tools EXTRA_CONFIG = --prefix=/tools --disable-nls \ - --disable-perl-regexp --with-included-regex + --disable-perl-regexp EXTRA_MAKE = EXTRA_INSTALL = endif @@ -63,7 +56,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = ddd99e2d5d4f4611357e31e97f080cf2 +$(DL_FILE)_MD5 = 52202fe462770fa6be1bb667bd6cf30c install : $(TARGET) @@ -93,8 +86,10 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-redhat_fixes-2.patch + cd $(DIR_APP) && chmod +x tests/fmbtest.sh cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/gzip b/lfs/gzip index 5c814082ae..46960c671c 100644 --- a/lfs/gzip +++ b/lfs/gzip @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: gzip,v 1.3.2.4 2005/07/18 20:40:37 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -36,7 +30,7 @@ VER = 1.3.5 THISAPP = gzip-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_AGNU)/gzip +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -91,24 +85,20 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - #only gzip is include, so fix only this part - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gzip-1.3.5-asm-execstack.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gzip-1.3.3-window-size.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gzip-1.3.5-perm.patch # CAN-2005-0988 - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gzip-1.3.5-gunzip-dir.patch # CAN-2005-1228 + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gzip-1.3.5-security_fixes-1.patch cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) ifeq "$(ROOT)" "" - cd $(DIR_APP) && cp gzexe.in{,.backup} - cd $(DIR_APP) && sed 's%"BINDIR"%/bin%' gzexe.in.backup > gzexe.in + cd $(DIR_APP) && sed -i 's@"BINDIR"@/bin@g' gzexe.in endif - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install ifeq "$(ROOT)" "" - mv /usr/bin/gzip /bin - rm /usr/bin/{gunzip,zcat} - ln -sf gzip /bin/gunzip - ln -sf gzip /bin/zcat - ln -sf gunzip /bin/uncompress + mv -v /usr/bin/gzip /bin + rm -v /usr/bin/{gunzip,zcat} + ln -sv gzip /bin/gunzip + ln -sv gzip /bin/zcat + ln -sv gzip /bin/compress + ln -sv gunzip /bin/uncompress endif @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/linux-libc-header b/lfs/linux-libc-header new file mode 100644 index 0000000000..2f968bceb9 --- /dev/null +++ b/lfs/linux-libc-header @@ -0,0 +1,86 @@ +############################################################################### +# This file is part of the IPCop Firewall. # +# # +# IPCop 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 of the License, or # +# (at your option) any later version. # +# # +# IPCop 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 IPCop; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Makefiles are based on LFSMake, which is # +# Copyright (C) 2002 Rod Roard # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 2.6.12.0 + +THISAPP = linux-libc-headers-$(VER) +DL_FILE = $(THISAPP).tar.bz2 +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) + +ifeq "$(ROOT)" "" + TARGET = $(DIR_INFO)/$(THISAPP) +else + TARGET = $(DIR_INFO)/$(THISAPP)-tools1 +endif + +############################################################################### +# Top-level Rules +############################################################################### +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = eae2f562afe224ad50f65a6acfb4252c + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) +ifeq "$(ROOT)" "" + +else + cd $(DIR_APP) && cp -Rv include/asm-i386 /tools/include/asm + cd $(DIR_APP) && cp -Rv include/linux /tools/include +endif + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/lfs/m4 b/lfs/m4 index 806f332e43..016b72d032 100644 --- a/lfs/m4 +++ b/lfs/m4 @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: m4,v 1.4.2.5 2005/02/05 15:38:15 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 1.4 +VER = 1.4.4 THISAPP = m4-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/m4 +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -48,19 +42,11 @@ ifeq "$(ROOT)" "" EXTRA_MAKE = EXTRA_INSTALL = else -ifeq "$(LFS_PASS)" "1" - TARGET = $(DIR_INFO)/$(THISAPP)-tools1 + TARGET = $(DIR_INFO)/$(THISAPP)-tools EXTRA_CONFIG = --prefix=/tools --disable-nls EXTRA_LDFLAGS = -static EXTRA_MAKE = EXTRA_INSTALL = -else - TARGET = $(DIR_INFO)/$(THISAPP)-tools2 - EXTRA_CONFIG = --prefix=/tools --disable-nls - EXTRA_LDFLAGS = - EXTRA_MAKE = - EXTRA_INSTALL = -endif endif ############################################################################### @@ -71,7 +57,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 9eb2dd07740b2d2f3c7adb3e8d299bda +$(DL_FILE)_MD5 = 8d1d64dbecf1494690a0f3ba8db4482a install : $(TARGET) @@ -102,7 +88,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && LDFLAGS="$(EXTRA_LDFLAGS)" ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/make b/lfs/make index 1a225de087..5dff2cf5d0 100644 --- a/lfs/make +++ b/lfs/make @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: make,v 1.3.2.2 2005/02/05 15:38:15 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -36,7 +30,7 @@ VER = 3.80 THISAPP = make-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/make +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -92,7 +86,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/ncurses b/lfs/ncurses index e5ccea6812..ea14faef82 100644 --- a/lfs/ncurses +++ b/lfs/ncurses @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: ncurses,v 1.3.2.5 2005/02/05 15:38:15 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 5.4 +VER = 5.5 THISAPP = ncurses-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/ncurses +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -44,7 +38,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) EXTRA_CONFIG = --prefix=/usr --with-shared \ - --without-debug --disable-nls + --without-debug --enable-widec --disable-nls EXTRA_MAKE = EXTRA_INSTALL = else @@ -64,7 +58,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 069c8880072060373290a4fefff43520 +$(DL_FILE)_MD5 = e73c1ac10b4bfc46db43b2ddfd6244ef install : $(TARGET) @@ -94,15 +88,25 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/ncurses-5.5-fixes-1.patch cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install ifeq "$(ROOT)" "" - chmod 755 /usr/lib/*.$(VER) - chmod 644 /usr/lib/libncurses++.a - mv /usr/lib/libncurses.so.5* /lib - ln -sf ../../lib/libncurses.so.5 /usr/lib/libncurses.so - ln -sf libncurses.so /usr/lib/libcurses.so + chmod -v 755 /usr/lib/*.5.5 + chmod -v 644 /usr/lib/libncurses++w.a + mv -v /usr/lib/libncursesw.so.5* /lib + ln -sfv ../../lib/libncursesw.so.5 /usr/lib/libncursesw.so + cd $(DIR_APP) && for lib in curses ncurses form panel menu ; do \ + rm -vf /usr/lib/lib${lib}.so ; \ + echo "INPUT(-l${lib}w)" >/usr/lib/lib${lib}.so ; \ + ln -sfv lib${lib}w.a /usr/lib/lib${lib}.a ; \ + done + ln -sfv libncurses++w.a /usr/lib/libncurses++.a4 + echo "INPUT(-lncursesw)" >/usr/lib/libcursesw.so && + ln -sfv libncurses.so /usr/lib/libcurses.so && + ln -sfv libncursesw.a /usr/lib/libcursesw.a && + ln -sfv libncurses.a /usr/lib/libcurses.a endif @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/patch b/lfs/patch index 6d7212ff97..1c0568e8c3 100644 --- a/lfs/patch +++ b/lfs/patch @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: patch,v 1.3.2.2 2005/02/05 15:38:15 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -36,7 +30,7 @@ VER = 2.5.4 THISAPP = patch-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/patch +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -92,7 +86,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && CPPFLAGS=-D_GNU_SOURCE ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/perl b/lfs/perl index 127f12044f..8b0d30a931 100644 --- a/lfs/perl +++ b/lfs/perl @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: perl,v 1.9.2.13 2005/02/27 15:23:03 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 5.8.5 +VER = 5.8.8 THISAPP = perl-$(VER) -DL_FILE = $(THISAPP).tar.gz -DL_FROM = http://www.cpan.org/src +DL_FILE = $(THISAPP).tar.bz2 +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -51,13 +45,11 @@ endif # Top-level Rules ############################################################################### -objects = $(DL_FILE) perl-5.8.4-libc-1.patch +objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -perl-5.8.4-libc-1.patch = $(URL_LFS)/perl/perl-5.8.4-libc-1.patch -$(DL_FILE)_MD5 = 49baa8d7d29b4a9713c06edeb81e6b1b -perl-5.8.4-libc-1.patch_MD5 = f033161efa8b4b174ec6667e4e739efa +$(DL_FILE)_MD5 = a377c0c67ab43fd96eeec29ce19e8382 install : $(TARGET) @@ -86,23 +78,19 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/perl-5.8.4-libc-1.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/perl.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/perl-5.8.5-perlio_debug_security.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/perl-5.8.5-tempfiles.patch + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-libc-2.patch ifeq "$(ROOT)" "" - cd $(DIR_APP) && ./configure.gnu --prefix=/usr -Dpager="/bin/less -isR" -Dd_dosuid -Ui_db -Ui_gdbm -Ui_ndbm -Ui_dbm -Dmyhostname=localhost - cd $(DIR_APP) && make depend - cd $(DIR_APP) && make + cd $(DIR_APP) && ./configure.gnu --prefix=/usr -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 \ + -Dpager="/usr/bin/less -isR" -Dmyhostname=localhost + cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make install else - cd $(DIR_APP) && ./configure.gnu --prefix=/tools -Dstatic_ext='IO Fcntl POSIX' -Dd_dosuid -Ui_db -Ui_gdbm -Ui_ndbm -Ui_dbm -Dmyhostname=localhost - cd $(DIR_APP) && make depend - cd $(DIR_APP) && make - cd $(DIR_APP) && cp -f perl pod/pod2man /tools/bin - -mkdir -p /tools/lib/perl5/$(VER) - cd $(DIR_APP) && cp -Rf lib/* /tools/lib/perl5/$(VER) + cd $(DIR_APP) && ./configure.gnu --prefix=/tools -Dstatic_ext='Data/Dumper Fcntl IO POSIX' -Dmyhostname=localhost + cd $(DIR_APP) && make $(MAKETUNING) perl utilities + cd $(DIR_APP) && cp -v perl pod/pod2man /tools/bin + cd $(DIR_APP) && mkdir -pv /tools/lib/perl5/$(VER) + cd $(DIR_APP) && cp -Rv lib/* /tools/lib/perl5/$(VER) endif @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/sed b/lfs/sed index 04c2c6bb68..9af7b4eb2d 100644 --- a/lfs/sed +++ b/lfs/sed @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: sed,v 1.6.2.3 2005/02/05 15:38:15 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 4.0.9 +VER = 4.1.5 THISAPP = sed-$(VER) DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/sed +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -48,20 +42,12 @@ ifeq "$(ROOT)" "" EXTRA_MAKE = EXTRA_INSTALL = else -ifeq "$(LFS_PASS)" "1" - TARGET = $(DIR_INFO)/$(THISAPP)-tools1 - EXTRA_CONFIG = --prefix=/tools --disable-nls - EXTRA_LDFLAGS = -static - EXTRA_MAKE = - EXTRA_INSTALL = -else - TARGET = $(DIR_INFO)/$(THISAPP)-tools2 + TARGET = $(DIR_INFO)/$(THISAPP)-tools EXTRA_CONFIG = --prefix=/tools --disable-nls EXTRA_LDFLAGS = EXTRA_MAKE = EXTRA_INSTALL = endif -endif ############################################################################### # Top-level Rules @@ -71,7 +57,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = d8fb554bc6577aaedd39b94b3cb3df70 +$(DL_FILE)_MD5 = 7a1cbbbb3341287308e140bd4834c3ba install : $(TARGET) @@ -102,7 +88,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && LDFLAGS="$(EXTRA_LDFLAGS)" ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/tar b/lfs/tar index 04e27d18ad..65fe6508df 100644 --- a/lfs/tar +++ b/lfs/tar @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: tar,v 1.3.2.5 2006/01/30 19:46:45 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 1.13.25 +VER = 1.15.1 THISAPP = tar-$(VER) -DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_AGNU)/tar +DL_FILE = $(THISAPP).tar.bz2 +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -44,7 +38,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) EXTRA_CONFIG = --prefix=/usr --bindir=/bin \ - --libexecdir=/usr/bin --disable-nls + --libexecdir=/usr/sbin --disable-nls EXTRA_MAKE = EXTRA_INSTALL = else @@ -58,14 +52,11 @@ endif # Top-level Rules ############################################################################### -objects = $(DL_FILE) \ - tar-1.13.25-dot_dot-1.patch +objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -tar-1.13.25-dot_dot-1.patch = $(URL_LFS)/tar/tar-1.13.25-dot_dot-1.patch -$(DL_FILE)_MD5 = 6ef8c906e81eee441f8335652670ac4a -tar-1.13.25-dot_dot-1.patch_MD5 = 56ab09592243847e7410c4fde8d37f62 +$(DL_FILE)_MD5 = 57da3c38f8e06589699548a34d5a5d07 install : $(TARGET) @@ -94,10 +85,12 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/tar-1.13.25-dot_dot-1.patch + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-gcc4_fix_tests-1.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-sparse_fix-1.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-security_fixes-1.patch cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/tcl b/lfs/tcl index 5cfb57c65f..e6dc3d8024 100644 --- a/lfs/tcl +++ b/lfs/tcl @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: tcl,v 1.4.2.4 2006/01/20 13:59:20 franck78 Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 8.4.6 +VER = 8.4.13 THISAPP = tcl$(VER) DL_FILE = $(THISAPP)-src.tar.gz -DL_FROM = $(URL_SFNET)/tcl +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP)-tools @@ -48,7 +42,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 9009a92dc648775fb8a9b0789b995756 +$(DL_FILE)_MD5 = c6b655ad5db095ee73227113220c0523 install : $(TARGET) @@ -78,12 +72,10 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - #remove a syntax error in tcl. Appears with recent bash. - #tcl 8.4.13 will correct this bug, so next line can go away - cd $(DIR_APP) && sed -i "s/relid'/relid/g" unix/configure cd $(DIR_APP)/unix && ./configure --prefix=/tools --disable-nls - cd $(DIR_APP)/unix && make + cd $(DIR_APP)/unix && make $(MAKETUNING) cd $(DIR_APP)/unix && make install + cd $(DIR_APP)/unix && make install-private-headers ln -sf tclsh8.4 /tools/bin/tclsh @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/texinfo b/lfs/texinfo index c5d7540732..e6f53fe64b 100644 --- a/lfs/texinfo +++ b/lfs/texinfo @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: texinfo,v 1.3.2.3 2005/02/05 15:38:16 gespinasse Exp $ -# # ############################################################################### ############################################################################### @@ -32,11 +26,11 @@ include Config -VER = 4.7 +VER = 4.8 THISAPP = texinfo-$(VER) -DL_FILE = $(THISAPP).tar.gz -DL_FROM = $(URL_GNU)/texinfo +DL_FILE = $(THISAPP).tar.bz2 +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. @@ -61,7 +55,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(DL_FILE)_MD5 = 72a57e378efb9898c9e41ca839554dae +$(DL_FILE)_MD5 = 6ba369bbfe4afaa56122e65b3ee3a68c install : $(TARGET) @@ -90,9 +84,11 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-multibyte-1.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-tempfile_fix-2.patch cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) - cd $(DIR_APP) && make $(EXTRA_MAKE) + cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/util-linux b/lfs/util-linux index 924b21461b..411316b667 100644 --- a/lfs/util-linux +++ b/lfs/util-linux @@ -18,12 +18,6 @@ # Makefiles are based on LFSMake, which is # # Copyright (C) 2002 Rod Roard # # # -# Modifications by: # -# ??-12-2003 Mark Wormgoor < mark@wormgoor.com> # -# - Modified Makefile for IPCop build # -# # -# $Id: util-linux,v 1.8.2.7 2006/01/20 14:31:47 franck78 Exp $ -# # ############################################################################### ############################################################################### @@ -36,17 +30,13 @@ VER = 2.12r THISAPP = util-linux-$(VER) DL_FILE = $(THISAPP).tar.bz2 -DL_FROM = $(URL_KERNEL)/linux/utils/util-linux +DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) # Normal build or /tools build. # ifeq "$(ROOT)" "" -ifeq "$(LFS_PASS)" "install" - TARGET = $(DIR_INFO)/$(THISAPP)-install -else TARGET = $(DIR_INFO)/$(THISAPP) -endif else TARGET = $(DIR_INFO)/$(THISAPP)-tools endif @@ -60,6 +50,7 @@ objects = $(DL_FILE) $(DL_FILE) = $(DL_FROM)/$(DL_FILE) $(DL_FILE)_MD5 = af9d9e03038481fbf79ea3ac33f116f9 + install : $(TARGET) check : $(patsubst %,$(DIR_CHK)/%,$(objects)) @@ -89,35 +80,19 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) ifeq "$(ROOT)" "" -ifeq "$(LFS_PASS)" "install" - -mkdir -p /install/misc/bin - cd $(DIR_APP) && CFLAGS="-Os -fomit-frame-pointer" ./configure - cd $(DIR_APP)/fdisk && sed -i 's+setlocale+// setlocale+' sfdisk.c - cd $(DIR_APP)/fdisk && make sfdisk - cd $(DIR_APP)/fdisk && install -m 0755 sfdisk /install/misc/bin - if [ "$(MACHINE)" = "alpha" ]; then \ - cd $(DIR_APP)/fdisk && make fdisk; \ - cd $(DIR_APP)/fdisk && install -m 0755 fdisk /install/misc/bin; \ - fi -else - cd $(DIR_APP) && cp hwclock/hwclock.c{,.backup} - cd $(DIR_APP) && sed 's%etc/adjtime%var/lib/hwclock/adjtime%' \ - hwclock/hwclock.c.backup > hwclock/hwclock.c + cd $(DIR_APP) && sed -i 's@etc/adjtime@var/lib/hwclock/adjtime@g' \ + hwclock/hwclock.c -mkdir -p /var/lib/hwclock + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-cramfs-1.patch cd $(DIR_APP) && ./configure - cd $(DIR_APP) && make HAVE_SLN=yes - cd $(DIR_APP) && make HAVE_SLN=yes install - chmod u-s /bin/mount /bin/umount - touch /var/lib/hwclock/adjtime -endif + cd $(DIR_APP) && make $(MAKETUNING) HAVE_KILL=yes HAVE_SLN=yes + cd $(DIR_APP) && make HAVE_KILL=yes HAVE_SLN=yes install else - cd $(DIR_APP) && cp configure configure.backup - cd $(DIR_APP) && sed "s@/usr/include@/tools/include@g" configure.backup > configure - cd $(DIR_APP) && chmod 755 configure + cd $(DIR_APP) && sed -i 's@/usr/include@/tools/include@g' configure cd $(DIR_APP) && ./configure - cd $(DIR_APP) && make -C lib - cd $(DIR_APP) && make -C mount mount umount - cd $(DIR_APP) && make -C text-utils more + cd $(DIR_APP) && make $(MAKETUNING) -C lib + cd $(DIR_APP) && make $(MAKETUNING) -C mount mount umount + cd $(DIR_APP) && make $(MAKETUNING) -C text-utils more cd $(DIR_APP) && cp mount/{,u}mount text-utils/more /tools/bin endif @rm -rf $(DIR_APP) diff --git a/make.sh b/make.sh index bde7ae960f..66d054005c 100644 --- a/make.sh +++ b/make.sh @@ -64,16 +64,11 @@ fi if [ 'x86_64' = $MACHINE -o 'i686' = $MACHINE -o 'i586' = $MACHINE -o 'i486' = $MACHINE -o 'i386' = $MACHINE ]; then - echo "`date -u '+%b %e %T'`: Machine is ix86 (or equivalent)" >> $LOGFILE - MACHINE=i386 - BUILDTARGET=i386-pc-linux-gnu - CFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer" - CXXFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer" - elif [ 'alpha' = $MACHINE ]; then - echo "`date -u '+%b %e %T'`: Machine is Alpha AXP" >> $LOGFILE - BUILDTARGET=alpha-unknown-linux-gnu - CFLAGS="-O2 -mcpu=ev4 -mieee -pipe" - CXXFLAGS="-O2 -mcpu=ev4 -mieee -pipe" + echo "`date -u '+%b %e %T'`: Machine is i486 (or equivalent)" >> $LOGFILE + MACHINE=i486 + BUILDTARGET=i486-pc-linux-gnu + CFLAGS="-O2 -mcpu=i486 -march=i486 -pipe -fomit-frame-pointer" + CXXFLAGS="-O2 -mcpu=i486 -march=i486 -pipe -fomit-frame-pointer" else echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" >> $LOGFILE exit 1 @@ -217,7 +212,8 @@ prepareenv() { # Setup environment set +h LC_ALL=POSIX - export LFS LC_ALL CFLAGS CXXFLAGS + MAKETUNING="-j8" + export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD # Make some extra directories @@ -268,6 +264,7 @@ lfsmake1() { LFS_BASEDIR=$BASEDIR \ ROOT=$LFS \ KVER=$KVER \ + MAKETUNING=$MAKETUNING \ install >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Building $*"; @@ -297,7 +294,7 @@ lfsmake2() { NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \ CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \ CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \ - KVER=$KVER \ + KVER=$KVER MAKETUNING=$MAKETUNING \ BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \ /tools/bin/bash -x -c "cd /usr/src/lfs && \ make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 @@ -329,7 +326,7 @@ ipcopmake() { NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \ CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \ CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \ - KVER=$KVER \ + KVER=$KVER MAKETUNING=$MAKETUNING \ BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \ /bin/bash -x -c "cd /usr/src/lfs && \ make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 @@ -344,7 +341,6 @@ ipcopmake() { ipfiredist() { if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then -# if [ ! `ls -w1 $BASEDIR/packages/*.ipfire | grep $1` ]; then echo "`date -u '+%b %e %T'`: Packaging $1" | tee -a $LOGFILE chroot $LFS /tools/bin/env -i HOME=/root \ TERM=$TERM PS1='\u:\w\$ ' \ @@ -361,9 +357,6 @@ ipfiredist() { if [ $? -ne 0 ]; then exiterror "Packaging $1" fi -# else -# echo "`date -u '+%b %e %T'`: Packaging: The package $1 already exists" -# fi else exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1" fi @@ -412,42 +405,37 @@ buildtoolchain() { ORG_PATH=$PATH NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}` export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1} + echo -ne "`date -u '+%b %e %T'`: Native GCC: $NATIVEGCC\n" lfsmake1 ccache - lfsmake1 sed LFS_PASS=1 - lfsmake1 m4 LFS_PASS=1 - lfsmake1 bison LFS_PASS=1 - lfsmake1 flex LFS_PASS=1 - lfsmake1 binutils LFS_PASS=1 - lfsmake1 gcc LFS_PASS=1 + lfsmake1 binutils LFS_PASS=1 + lfsmake1 gcc LFS_PASS=1 export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH - - lfsmake1 linux + lfsmake1 linux-libc-header + lfsmake1 glibc lfsmake1 tcl lfsmake1 expect - lfsmake1 glibc lfsmake1 dejagnu - lfsmake1 gcc LFS_PASS=2 - lfsmake1 binutils LFS_PASS=2 - lfsmake1 gawk - lfsmake1 coreutils + lfsmake1 gcc LFS_PASS=2 + lfsmake1 binutils LFS_PASS=2 + lfsmake1 ncurses + lfsmake1 bash lfsmake1 bzip2 - lfsmake1 gzip + lfsmake1 coreutils lfsmake1 diffutils lfsmake1 findutils - lfsmake1 make - lfsmake1 grep - lfsmake1 sed LFS_PASS=2 - lfsmake1 m4 LFS_PASS=2 - lfsmake1 bison LFS_PASS=2 - lfsmake1 flex LFS_PASS=2 + lfsmake1 gawk lfsmake1 gettext - lfsmake1 ncurses + lfsmake1 grep + lfsmake1 gzip + lfsmake1 m4 + lfsmake1 make lfsmake1 patch + lfsmake1 perl + lfsmake1 sed lfsmake1 tar lfsmake1 texinfo - lfsmake1 bash lfsmake1 util-linux - lfsmake1 perl + lfsmake1 cleanup-toolchain export PATH=$ORG_PATH } @@ -924,7 +912,7 @@ build) BUILDMACHINE=`uname -m` PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1` #only restore on a clean disk - if [ ! -f log/perl-*-tools ]; then + if [ ! -f log/cleanup-toolchain-*-tools ]; then if [ ! -n "$PACKAGE" ]; then echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE prepareenv @@ -1549,8 +1537,8 @@ unattended) echo "### SAVING TIME" export IPFIRE_START_TIME=`date` - echo "### GETTING TOOLCHAIN" - $0 gettoolchain + #echo "### GETTING TOOLCHAIN" + #$0 gettoolchain echo "### RUNNING SVN-UPDATE" $0 svn update diff --git a/src/patches/bash-3.1-fixes-8.patch b/src/patches/bash-3.1-fixes-8.patch new file mode 100644 index 0000000000..449f076536 --- /dev/null +++ b/src/patches/bash-3.1-fixes-8.patch @@ -0,0 +1,723 @@ +Submitted By: Jeremy Huntwork (jhuntwork at linuxfromscratch dot org) +Date: 2006-04-11 +Initial Package Version: 3.1 +Origin: http://ftp.gnu.org/gnu/bash/bash-3.1-patches/ +Upstream Status: From Upstream +Description: Contains patches 001-017 from upstream + +diff -Naur bash-3.1.orig/arrayfunc.c bash-3.1/arrayfunc.c +--- bash-3.1.orig/arrayfunc.c 2005-07-04 17:25:58.000000000 -0700 ++++ bash-3.1/arrayfunc.c 2006-04-19 15:59:29.000000000 -0700 +@@ -592,11 +592,7 @@ + exp = (char *)xmalloc (len); + strncpy (exp, s, len - 1); + exp[len - 1] = '\0'; +-#if 0 +- t = expand_string_to_string (exp, 0); +-#else +- t = expand_string_to_string (exp, Q_DOUBLE_QUOTES); +-#endif ++ t = expand_arith_string (exp, 0); + this_command_name = (char *)NULL; + val = evalexp (t, &expok); + free (t); +diff -Naur bash-3.1.orig/doc/bash.1 bash-3.1/doc/bash.1 +--- bash-3.1.orig/doc/bash.1 2005-10-12 08:40:52.000000000 -0700 ++++ bash-3.1/doc/bash.1 2006-04-19 15:58:34.000000000 -0700 +@@ -6,12 +6,12 @@ + .\" Case Western Reserve University + .\" chet@po.cwru.edu + .\" +-.\" Last Change: Sat Aug 27 13:28:44 EDT 2005 ++.\" Last Change: Wed Dec 28 19:58:45 EST 2005 + .\" + .\" bash_builtins, strip all but Built-Ins section + .if \n(zZ=1 .ig zZ + .if \n(zY=1 .ig zY +-.TH BASH 1 "2005 Aug 27" "GNU Bash-3.1-beta1" ++.TH BASH 1 "2005 Dec 28" "GNU Bash-3.1" + .\" + .\" There's some problem with having a `@' + .\" in a tagged paragraph with the BSD man macros. +@@ -677,8 +677,8 @@ + .B nocasematch + is enabled, the match is performed without regard to the case + of alphabetic characters. +-The return value is 0 if the string matches or does not match +-the pattern, respectively, and 1 otherwise. ++The return value is 0 if the string matches (\fB==\fP) or does not match ++(\fB!=\fP) the pattern, and 1 otherwise. + Any part of the pattern may be quoted to force it to be matched as a + string. + .if t .sp 0.5 +@@ -807,6 +807,12 @@ + as for pathname expansion (see + .B Pathname Expansion + below). ++The \fIword\fP is expanded using tilde ++expansion, parameter and variable expansion, arithmetic substituion, ++command substitution, process substitution and quote removal. ++Each \fIpattern\fP examined is expanded using tilde ++expansion, parameter and variable expansion, arithmetic substituion, ++command substitution, and process substitution. + If the shell option + .B nocasematch + is enabled, the match is performed without regard to the case +@@ -8484,7 +8490,7 @@ + returns true if any of the arguments are found, false if + none are found. + .TP +-\fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]] ++\fBulimit\fP [\fB\-SHacdfilmnpqstuvx\fP [\fIlimit\fP]] + Provides control over the resources available to the shell and to + processes started by it, on systems that allow such control. + The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is +@@ -8523,6 +8529,9 @@ + .B \-f + The maximum size of files created by the shell + .TP ++.B \-i ++The maximum number of pending signals ++.TP + .B \-l + The maximum size that may be locked into memory + .TP +@@ -8536,6 +8545,9 @@ + .B \-p + The pipe size in 512-byte blocks (this may not be set) + .TP ++.B \-q ++The maximum number of bytes in POSIX message queues ++.TP + .B \-s + The maximum stack size + .TP +@@ -8547,6 +8559,9 @@ + .TP + .B \-v + The maximum amount of virtual memory available to the shell ++.TP ++.B \-x ++The maximum number of file locks + .PD + .PP + If +diff -Naur bash-3.1.orig/doc/bashref.texi bash-3.1/doc/bashref.texi +--- bash-3.1.orig/doc/bashref.texi 2005-10-03 12:07:21.000000000 -0700 ++++ bash-3.1/doc/bashref.texi 2006-04-19 15:58:34.000000000 -0700 +@@ -961,8 +961,8 @@ + (see the description of @code{shopt} in @ref{Bash Builtins}) + is enabled, the match is performed without regard to the case + of alphabetic characters. +-The return value is 0 if the string matches or does not match +-the pattern, respectively, and 1 otherwise. ++The return value is 0 if the string matches (@samp{==}) or does not ++match (@samp{!=})the pattern, and 1 otherwise. + Any part of the pattern may be quoted to force it to be matched as a + string. + +@@ -2598,7 +2598,7 @@ + Builtin commands are necessary to implement functionality impossible + or inconvenient to obtain with separate utilities. + +-This section briefly the builtins which Bash inherits from ++This section briefly describes the builtins which Bash inherits from + the Bourne Shell, as well as the builtin commands which are unique + to or have been extended in Bash. + +@@ -3833,7 +3833,7 @@ + @item ulimit + @btindex ulimit + @example +-ulimit [-acdflmnpstuvSH] [@var{limit}] ++ulimit [-acdfilmnpqstuvxSH] [@var{limit}] + @end example + @code{ulimit} provides control over the resources available to processes + started by the shell, on systems that allow such control. If an +@@ -3857,6 +3857,9 @@ + @item -f + The maximum size of files created by the shell. + ++@item -i ++The maximum number of pending signals. ++ + @item -l + The maximum size that may be locked into memory. + +@@ -3869,6 +3872,9 @@ + @item -p + The pipe buffer size. + ++@item -q ++The maximum number of bytes in POSIX message queues. ++ + @item -s + The maximum stack size. + +@@ -3881,6 +3887,9 @@ + @item -v + The maximum amount of virtual memory available to the process. + ++@item -x ++The maximum number of file locks. ++ + @end table + + If @var{limit} is given, it is the new value of the specified resource; +@@ -4089,8 +4098,8 @@ + Print shell input lines as they are read. + + @item -x +-Print a trace of simple commands, \fBfor\fP commands, \fBcase\fP +-commands, \fBselect\fP commands, and arithmetic \fBfor\fP commands ++Print a trace of simple commands, @code{for} commands, @code{case} ++commands, @code{select} commands, and arithmetic @code{for} commands + and their arguments or associated word lists after they are + expanded and before they are executed. The value of the @env{PS4} + variable is expanded and the resultant value is printed before +diff -Naur bash-3.1.orig/doc/version.texi bash-3.1/doc/version.texi +--- bash-3.1.orig/doc/version.texi 2005-09-20 11:52:56.000000000 -0700 ++++ bash-3.1/doc/version.texi 2006-04-19 15:58:34.000000000 -0700 +@@ -2,9 +2,9 @@ + Copyright (C) 1988-2005 Free Software Foundation, Inc. + @end ignore + +-@set LASTCHANGE Mon Sep 5 11:47:04 EDT 2005 ++@set LASTCHANGE Fri Dec 30 10:50:51 EST 2005 + +-@set EDITION 3.1-beta1 +-@set VERSION 3.1-beta1 +-@set UPDATED 5 September 2005 +-@set UPDATED-MONTH September 2005 ++@set EDITION 3.1 ++@set VERSION 3.1 ++@set UPDATED 30 December 2005 ++@set UPDATED-MONTH December 2005 +diff -Naur bash-3.1.orig/jobs.c bash-3.1/jobs.c +--- bash-3.1.orig/jobs.c 2005-11-11 20:13:27.000000000 -0800 ++++ bash-3.1/jobs.c 2006-04-19 15:58:34.000000000 -0700 +@@ -619,8 +619,11 @@ + * once in the parent and once in each child. This is where + * the parent gives it away. + * ++ * Don't give the terminal away if this shell is an asynchronous ++ * subshell. ++ * + */ +- if (job_control && newjob->pgrp) ++ if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0) + give_terminal_to (newjob->pgrp, 0); + } + } +@@ -844,9 +847,10 @@ + realloc_jobs_list () + { + sigset_t set, oset; +- int nsize, i, j; ++ int nsize, i, j, ncur, nprev; + JOB **nlist; + ++ ncur = nprev = NO_JOB; + nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS); + nsize *= JOB_SLOTS; + i = js.j_njobs % JOB_SLOTS; +@@ -854,17 +858,51 @@ + nsize += JOB_SLOTS; + + BLOCK_CHILD (set, oset); +- nlist = (JOB **) xmalloc (nsize * sizeof (JOB *)); ++ nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *)); ++ + for (i = j = 0; i < js.j_jobslots; i++) + if (jobs[i]) +- nlist[j++] = jobs[i]; ++ { ++ if (i == js.j_current) ++ ncur = j; ++ if (i == js.j_previous) ++ nprev = j; ++ nlist[j++] = jobs[i]; ++ } ++ ++#if defined (DEBUG) ++ itrace ("realloc_jobs_list: resize jobs list from %d to %d", js.j_jobslots, nsize); ++ itrace ("realloc_jobs_list: j_lastj changed from %d to %d", js.j_lastj, (j > 0) ? j - 1 : 0); ++ itrace ("realloc_jobs_list: j_njobs changed from %d to %d", js.j_njobs, (j > 0) ? j - 1 : 0); ++#endif + + js.j_firstj = 0; +- js.j_lastj = (j > 0) ? j - 1: 0; ++ js.j_lastj = (j > 0) ? j - 1 : 0; ++ js.j_njobs = j; + js.j_jobslots = nsize; + +- free (jobs); +- jobs = nlist; ++ /* Zero out remaining slots in new jobs list */ ++ for ( ; j < nsize; j++) ++ nlist[j] = (JOB *)NULL; ++ ++ if (jobs != nlist) ++ { ++ free (jobs); ++ jobs = nlist; ++ } ++ ++ if (ncur != NO_JOB) ++ js.j_current = ncur; ++ if (nprev != NO_JOB) ++ js.j_previous = nprev; ++ ++ /* Need to reset these */ ++ if (js.j_current == NO_JOB || js.j_previous == NO_JOB || js.j_current > js.j_lastj || js.j_previous > js.j_lastj) ++ reset_current (); ++ ++#ifdef DEBUG ++ itrace ("realloc_jobs_list: reset js.j_current (%d) and js.j_previous (%d)", js.j_current, js.j_previous); ++#endif + + UNBLOCK_CHILD (oset); + } +@@ -1655,7 +1693,7 @@ + In this case, we don't want to give the terminal to the + shell's process group (we could be in the middle of a + pipeline, for example). */ +- if (async_p == 0 && pipeline_pgrp != shell_pgrp) ++ if (async_p == 0 && pipeline_pgrp != shell_pgrp && ((subshell_environment&SUBSHELL_ASYNC) == 0)) + give_terminal_to (pipeline_pgrp, 0); + + #if defined (PGRP_PIPE) +@@ -2198,7 +2236,11 @@ + /* This is possibly a race condition -- should it go in stop_pipeline? */ + wait_sigint_received = 0; + if (job_control == 0) +- old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); ++ { ++ old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); ++ if (old_sigint_handler == SIG_IGN) ++ set_signal_handler (SIGINT, old_sigint_handler); ++ } + + termination_state = last_command_exit_value; + +diff -Naur bash-3.1.orig/lib/glob/glob.c bash-3.1/lib/glob/glob.c +--- bash-3.1.orig/lib/glob/glob.c 2005-03-24 09:42:27.000000000 -0800 ++++ bash-3.1/lib/glob/glob.c 2006-04-19 15:58:34.000000000 -0700 +@@ -360,6 +360,7 @@ + count = lose = skip = 0; + + firstmalloc = 0; ++ nalloca = 0; + + /* If PAT is empty, skip the loop, but return one (empty) filename. */ + if (pat == 0 || *pat == '\0') +@@ -546,6 +547,8 @@ + firstmalloc = 0; + tmplink = lastlink; + } ++ else ++ tmplink = 0; + free (lastlink->name); + lastlink = lastlink->next; + FREE (tmplink); +diff -Naur bash-3.1.orig/lib/glob/sm_loop.c bash-3.1/lib/glob/sm_loop.c +--- bash-3.1.orig/lib/glob/sm_loop.c 2005-10-16 18:21:04.000000000 -0700 ++++ bash-3.1/lib/glob/sm_loop.c 2006-04-19 15:58:34.000000000 -0700 +@@ -638,12 +638,13 @@ + CHAR *psub; /* pointer to sub-pattern */ + CHAR *pnext; /* pointer to next sub-pattern */ + CHAR *srest; /* pointer to rest of string */ +- int m1, m2; ++ int m1, m2, xflags; /* xflags = flags passed to recursive matches */ + + #if DEBUG_MATCHING + fprintf(stderr, "extmatch: xc = %c\n", xc); + fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se); + fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe); ++fprintf(stderr, "extmatch: flags = %d\n", flags); + #endif + + prest = PATSCAN (p + (*p == L('(')), pe, 0); /* ) */ +@@ -677,8 +678,12 @@ + string matches the rest of the pattern. Also handle + multiple matches of the pattern. */ + if (m1) +- m2 = (GMATCH (srest, se, prest, pe, flags) == 0) || +- (s != srest && GMATCH (srest, se, p - 1, pe, flags) == 0); ++ { ++ /* if srest > s, we are not at start of string */ ++ xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; ++ m2 = (GMATCH (srest, se, prest, pe, xflags) == 0) || ++ (s != srest && GMATCH (srest, se, p - 1, pe, xflags) == 0); ++ } + if (m1 && m2) + return (0); + } +@@ -704,8 +709,10 @@ + srest = (prest == pe) ? se : s; + for ( ; srest <= se; srest++) + { ++ /* if srest > s, we are not at start of string */ ++ xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; + if (GMATCH (s, srest, psub, pnext - 1, flags) == 0 && +- GMATCH (srest, se, prest, pe, flags) == 0) ++ GMATCH (srest, se, prest, pe, xflags) == 0) + return (0); + } + if (pnext == prest) +@@ -726,7 +733,9 @@ + if (pnext == prest) + break; + } +- if (m1 == 0 && GMATCH (srest, se, prest, pe, flags) == 0) ++ /* if srest > s, we are not at start of string */ ++ xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; ++ if (m1 == 0 && GMATCH (srest, se, prest, pe, xflags) == 0) + return (0); + } + return (FNM_NOMATCH); +diff -Naur bash-3.1.orig/lib/readline/display.c bash-3.1/lib/readline/display.c +--- bash-3.1.orig/lib/readline/display.c 2005-11-30 11:05:02.000000000 -0800 ++++ bash-3.1/lib/readline/display.c 2006-04-19 15:58:34.000000000 -0700 +@@ -1983,11 +1983,15 @@ + int pchar; + { + int len; +- char *pmt; ++ char *pmt, *p; + + rl_save_prompt (); + +- if (saved_local_prompt == 0) ++ /* We've saved the prompt, and can do anything with the various prompt ++ strings we need before they're restored. We want the unexpanded ++ portion of the prompt string after any final newline. */ ++ p = rl_prompt ? strrchr (rl_prompt, '\n') : 0; ++ if (p == 0) + { + len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; + pmt = (char *)xmalloc (len + 2); +@@ -1998,19 +2002,17 @@ + } + else + { +- len = *saved_local_prompt ? strlen (saved_local_prompt) : 0; ++ p++; ++ len = strlen (p); + pmt = (char *)xmalloc (len + 2); + if (len) +- strcpy (pmt, saved_local_prompt); ++ strcpy (pmt, p); + pmt[len] = pchar; + pmt[len+1] = '\0'; +- local_prompt = savestring (pmt); +- prompt_last_invisible = saved_last_invisible; +- prompt_visible_length = saved_visible_length + 1; +- } ++ } + ++ /* will be overwritten by expand_prompt, called from rl_message */ + prompt_physical_chars = saved_physical_chars + 1; +- + return pmt; + } + +diff -Naur bash-3.1.orig/lib/readline/readline.c bash-3.1/lib/readline/readline.c +--- bash-3.1.orig/lib/readline/readline.c 2005-07-04 19:29:35.000000000 -0700 ++++ bash-3.1/lib/readline/readline.c 2006-04-19 15:58:34.000000000 -0700 +@@ -282,6 +282,7 @@ + { + FREE (rl_prompt); + rl_prompt = prompt ? savestring (prompt) : (char *)NULL; ++ rl_display_prompt = rl_prompt ? rl_prompt : ""; + + rl_visible_prompt_length = rl_expand_prompt (rl_prompt); + return 0; +diff -Naur bash-3.1.orig/lib/readline/terminal.c bash-3.1/lib/readline/terminal.c +--- bash-3.1.orig/lib/readline/terminal.c 2005-11-12 17:46:54.000000000 -0800 ++++ bash-3.1/lib/readline/terminal.c 2006-04-19 15:58:34.000000000 -0700 +@@ -122,7 +122,7 @@ + static char *_rl_visible_bell; + + /* Non-zero means the terminal can auto-wrap lines. */ +-int _rl_term_autowrap; ++int _rl_term_autowrap = -1; + + /* Non-zero means that this terminal has a meta key. */ + static int term_has_meta; +@@ -274,6 +274,9 @@ + _rl_set_screen_size (rows, cols) + int rows, cols; + { ++ if (_rl_term_autowrap == -1) ++ _rl_init_terminal_io (rl_terminal_name); ++ + if (rows > 0) + _rl_screenheight = rows; + if (cols > 0) +diff -Naur bash-3.1.orig/parse.y bash-3.1/parse.y +--- bash-3.1.orig/parse.y 2005-11-11 20:14:18.000000000 -0800 ++++ bash-3.1/parse.y 2006-04-19 15:58:34.000000000 -0700 +@@ -2716,6 +2716,7 @@ + #define P_ALLOWESC 0x02 + #define P_DQUOTE 0x04 + #define P_COMMAND 0x08 /* parsing a command, so look for comments */ ++#define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */ + + static char matched_pair_error; + static char * +@@ -2725,12 +2726,12 @@ + int *lenp, flags; + { + int count, ch, was_dollar, in_comment, check_comment; +- int pass_next_character, nestlen, ttranslen, start_lineno; ++ int pass_next_character, backq_backslash, nestlen, ttranslen, start_lineno; + char *ret, *nestret, *ttrans; + int retind, retsize, rflags; + + count = 1; +- pass_next_character = was_dollar = in_comment = 0; ++ pass_next_character = backq_backslash = was_dollar = in_comment = 0; + check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0; + + /* RFLAGS is the set of flags we want to pass to recursive calls. */ +@@ -2742,11 +2743,8 @@ + start_lineno = line_number; + while (count) + { +-#if 0 +- ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0); +-#else +- ch = shell_getc (qc != '\'' && pass_next_character == 0); +-#endif ++ ch = shell_getc (qc != '\'' && pass_next_character == 0 && backq_backslash == 0); ++ + if (ch == EOF) + { + free (ret); +@@ -2771,9 +2769,16 @@ + continue; + } + /* Not exactly right yet */ +- else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1]))) ++ else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1]))) + in_comment = 1; + ++ /* last char was backslash inside backquoted command substitution */ ++ if (backq_backslash) ++ { ++ backq_backslash = 0; ++ /* Placeholder for adding special characters */ ++ } ++ + if (pass_next_character) /* last char was backslash */ + { + pass_next_character = 0; +@@ -2814,6 +2819,8 @@ + { + if MBTEST((flags & P_ALLOWESC) && ch == '\\') + pass_next_character++; ++ else if MBTEST((flags & P_BACKQUOTE) && ch == '\\') ++ backq_backslash++; + continue; + } + +@@ -2898,7 +2905,11 @@ + } + else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0) + { +- nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags); ++ /* Add P_BACKQUOTE so backslash quotes the next character and ++ shell_getc does the right thing with \. We do this for ++ a measure of backwards compatibility -- it's not strictly the ++ right POSIX thing. */ ++ nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_BACKQUOTE); + goto add_nestret; + } + else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ +@@ -2907,7 +2918,7 @@ + if (open == ch) /* undo previous increment */ + count--; + if (ch == '(') /* ) */ +- nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags); ++ nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags & ~P_DQUOTE); + else if (ch == '{') /* } */ + nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags); + else if (ch == '[') /* ] */ +@@ -3578,7 +3589,7 @@ + FREE (ttok); + all_digit_token = 0; + compound_assignment = 1; +-#if 0 ++#if 1 + goto next_character; + #else + goto got_token; /* ksh93 seems to do this */ +@@ -3695,7 +3706,9 @@ + struct builtin *b; + b = builtin_address_internal (token, 0); + if (b && (b->flags & ASSIGNMENT_BUILTIN)) +- parser_state |= PST_ASSIGNOK; ++ parser_state |= PST_ASSIGNOK; ++ else if (STREQ (token, "eval") || STREQ (token, "let")) ++ parser_state |= PST_ASSIGNOK; + } + + yylval.word = the_word; +@@ -4686,18 +4699,21 @@ + int *retlenp; + { + WORD_LIST *wl, *rl; +- int tok, orig_line_number, orig_token_size; ++ int tok, orig_line_number, orig_token_size, orig_last_token, assignok; + char *saved_token, *ret; + + saved_token = token; + orig_token_size = token_buffer_size; + orig_line_number = line_number; ++ orig_last_token = last_read_token; + + last_read_token = WORD; /* WORD to allow reserved words here */ + + token = (char *)NULL; + token_buffer_size = 0; + ++ assignok = parser_state&PST_ASSIGNOK; /* XXX */ ++ + wl = (WORD_LIST *)NULL; /* ( */ + parser_state |= PST_COMPASSIGN; + +@@ -4740,7 +4756,7 @@ + jump_to_top_level (DISCARD); + } + +- last_read_token = WORD; ++ last_read_token = orig_last_token; /* XXX - was WORD? */ + if (wl) + { + rl = REVERSE_LIST (wl, WORD_LIST *); +@@ -4752,6 +4768,10 @@ + + if (retlenp) + *retlenp = (ret && *ret) ? strlen (ret) : 0; ++ ++ if (assignok) ++ parser_state |= PST_ASSIGNOK; ++ + return ret; + } + +diff -Naur bash-3.1.orig/patchlevel.h bash-3.1/patchlevel.h +--- bash-3.1.orig/patchlevel.h 2005-07-20 10:58:20.000000000 -0700 ++++ bash-3.1/patchlevel.h 2006-04-19 15:59:29.000000000 -0700 +@@ -25,6 +25,6 @@ + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh + looks for to find the patch level (for the sccs version string). */ + +-#define PATCHLEVEL 0 ++#define PATCHLEVEL 17 + + #endif /* _PATCHLEVEL_H_ */ +diff -Naur bash-3.1.orig/subst.c bash-3.1/subst.c +--- bash-3.1.orig/subst.c 2005-10-24 06:51:13.000000000 -0700 ++++ bash-3.1/subst.c 2006-04-19 15:59:29.000000000 -0700 +@@ -2187,7 +2187,7 @@ + if (mklocal && variable_context) + { + v = find_variable (name); +- if (v == 0 || array_p (v) == 0) ++ if (v == 0 || array_p (v) == 0 || v->context != variable_context) + v = make_local_array_variable (name); + v = assign_array_var_from_string (v, value, flags); + } +@@ -2575,6 +2575,13 @@ + return (expand_string_to_string_internal (string, quoted, expand_string_assignment)); + } + ++char * ++expand_arith_string (string, quoted) ++ char *string; ++{ ++ return (expand_string_if_necessary (string, quoted, expand_string)); ++} ++ + #if defined (COND_COMMAND) + /* Just remove backslashes in STRING. Returns a new string. */ + char * +@@ -5248,7 +5255,7 @@ + else + t = (char *)0; + +- temp1 = expand_string_if_necessary (substr, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (substr, Q_DOUBLE_QUOTES); + *e1p = evalexp (temp1, &expok); + free (temp1); + if (expok == 0) +@@ -5293,7 +5300,7 @@ + { + t++; + temp2 = savestring (t); +- temp1 = expand_string_if_necessary (temp2, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES); + free (temp2); + t[-1] = ':'; + *e2p = evalexp (temp1, &expok); +@@ -6435,7 +6442,7 @@ + temp2[t_index] = '\0'; + + /* Expand variables found inside the expression. */ +- temp1 = expand_string_if_necessary (temp2, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES); + free (temp2); + + arithsub: +@@ -6477,7 +6484,7 @@ + zindex = t_index; + + /* Do initial variable expansion. */ +- temp1 = expand_string_if_necessary (temp, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (temp, Q_DOUBLE_QUOTES); + + goto arithsub; + +@@ -6795,6 +6802,12 @@ + if (temp && *temp && t_index > 0) + { + temp1 = bash_tilde_expand (temp, tflag); ++ if (temp1 && *temp1 == '~' && STREQ (temp, temp1)) ++ { ++ FREE (temp); ++ FREE (temp1); ++ goto add_character; /* tilde expansion failed */ ++ } + free (temp); + temp = temp1; + sindex += t_index; +diff -Naur bash-3.1.orig/subst.h bash-3.1/subst.h +--- bash-3.1.orig/subst.h 2004-11-07 12:12:28.000000000 -0800 ++++ bash-3.1/subst.h 2006-04-19 15:59:29.000000000 -0700 +@@ -151,6 +151,9 @@ + extern char *expand_string_unsplit_to_string __P((char *, int)); + extern char *expand_assignment_string_to_string __P((char *, int)); + ++/* Expand an arithmetic expression string */ ++extern char *expand_arith_string __P((char *, int)); ++ + /* De-quoted quoted characters in STRING. */ + extern char *dequote_string __P((char *)); + +diff -Naur bash-3.1.orig/variables.c bash-3.1/variables.c +--- bash-3.1.orig/variables.c 2005-11-12 18:22:37.000000000 -0800 ++++ bash-3.1/variables.c 2006-04-19 15:58:34.000000000 -0700 +@@ -860,9 +860,11 @@ + { + char val[INT_STRLEN_BOUND(int) + 1], *v; + ++#if defined (READLINE) + /* If we are currently assigning to LINES or COLUMNS, don't do anything. */ + if (winsize_assignment) + return; ++#endif + + v = inttostr (lines, val, sizeof (val)); + bind_variable ("LINES", v, 0); diff --git a/src/patches/bzip2-1.0.3-bzgrep_security-1.patch b/src/patches/bzip2-1.0.3-bzgrep_security-1.patch new file mode 100644 index 0000000000..dab627db36 --- /dev/null +++ b/src/patches/bzip2-1.0.3-bzgrep_security-1.patch @@ -0,0 +1,35 @@ +Submitted By: Ken Moffat +Date: 2005-08-09 +Initial Package Version: 1.0.3 +Upstream Status: Unknown. +Origin: Jyri Ryska (RedHat) for fedora3 +Description: Fixes filename sanitisation in bzgrep. + This fixes CAN-2005-0758 (if a user can be tricked into running +bzgrep in an untrusted directory containing files with carefully +crafted filenames, arbitrary commands could be executed as the user +running bzgrep). Risk is reported as low. I've modified it to force +the interpreter to be bash, some of the other shells in use won't +like the bash syntax. + +diff -Naur bzip2-1.0.3/bzgrep bzip2-1.0.3-new/bzgrep +--- bzip2-1.0.3/bzgrep 2004-10-09 12:29:32.000000000 +0100 ++++ bzip2-1.0.3-new/bzgrep 2005-08-09 21:36:37.000000000 +0100 +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!/bin/bash + + # Bzgrep wrapped for bzip2, + # adapted from zgrep by Philippe Troin for Debian GNU/Linux. +@@ -63,7 +63,11 @@ + bzip2 -cdfq "$i" | $grep $opt "$pat" + r=$? + else +- bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|" ++ j=${i//\\/\\\\} ++ j=${j//|/\\|} ++ j=${j//&/\\&} ++ j=`printf "%s" "$j" | tr '\n' ' '` ++ bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|" + r=$? + fi + test "$r" -ne 0 && res="$r" diff --git a/src/patches/ccache-2.3.patch b/src/patches/ccache-2.4.patch similarity index 100% rename from src/patches/ccache-2.3.patch rename to src/patches/ccache-2.4.patch diff --git a/src/patches/coreutils-5.96-i18n-1.patch b/src/patches/coreutils-5.96-i18n-1.patch new file mode 100644 index 0000000000..d1c8cf0447 --- /dev/null +++ b/src/patches/coreutils-5.96-i18n-1.patch @@ -0,0 +1,4052 @@ +Submitted by: Alexander E. Patrakov +Date: 2005-11-12 +Initial Package Version: 5.93 +Upstream Status: Not accepted, but planned for 6.0 +Origin: RedHat CVS, see below how to regenerate +http://cvs.fedora.redhat.com/viewcvs/*checkout*/devel/coreutils/coreutils-i18n.patch?rev=1.14 +Description: This patch fixes various problems with multibyte character support. +LSB >= 2.0 tests for features added by this patch, but only Coreutils-5.2.1 plus +http://www.linuxfromscratch.org/~alexander/patches/coreutils-5.2.1-i18n_fixes-1.patch +actually pass the Li18nux2000-level1 testsuite. + +To regenerate: +Get http://cvs.fedora.redhat.com/viewcvs/*checkout*/devel/coreutils/coreutils-i18n.patch?rev=1.14 +Replace the coreutils-5.93/tests/sort/Makefile.in hunk with that from rev 1.13 +Add this header. + +--- coreutils-5.93/lib/linebuffer.h.i18n 2005-05-14 08:58:06.000000000 +0100 ++++ coreutils-5.93/lib/linebuffer.h 2005-12-23 08:53:01.000000000 +0000 +@@ -22,6 +22,11 @@ + + # include + ++/* Get mbstate_t. */ ++# if HAVE_WCHAR_H ++# include ++# endif ++ + /* A `struct linebuffer' holds a line of text. */ + + struct linebuffer +@@ -29,6 +34,9 @@ + size_t size; /* Allocated. */ + size_t length; /* Used. */ + char *buffer; ++# if HAVE_WCHAR_H ++ mbstate_t state; ++# endif + }; + + /* Initialize linebuffer LINEBUFFER for use. */ +--- coreutils-5.93/src/cut.c.i18n 2005-08-12 08:16:25.000000000 +0100 ++++ coreutils-5.93/src/cut.c 2005-12-23 08:53:01.000000000 +0000 +@@ -29,6 +29,11 @@ + #include + #include + #include ++ ++/* Get mbstate_t, mbrtowc(). */ ++#if HAVE_WCHAR_H ++# include ++#endif + #include "system.h" + + #include "error.h" +@@ -37,6 +42,18 @@ + #include "quote.h" + #include "xstrndup.h" + ++/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC ++ installation; work around this configuration error. */ ++#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 ++# undef MB_LEN_MAX ++# define MB_LEN_MAX 16 ++#endif ++ ++/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ ++#if HAVE_MBRTOWC && defined mbstate_t ++# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) ++#endif ++ + /* The official name of this program (e.g., no `g' prefix). */ + #define PROGRAM_NAME "cut" + +@@ -67,6 +84,52 @@ + } \ + while (0) + ++/* Refill the buffer BUF to get a multibyte character. */ ++#define REFILL_BUFFER(BUF, BUFPOS, BUFLEN, STREAM) \ ++ do \ ++ { \ ++ if (BUFLEN < MB_LEN_MAX && !feof (STREAM) && !ferror (STREAM)) \ ++ { \ ++ memmove (BUF, BUFPOS, BUFLEN); \ ++ BUFLEN += fread (BUF + BUFLEN, sizeof(char), BUFSIZ, STREAM); \ ++ BUFPOS = BUF; \ ++ } \ ++ } \ ++ while (0) ++ ++/* Get wide character on BUFPOS. BUFPOS is not included after that. ++ If byte sequence is not valid as a character, CONVFAIL is 1. Otherwise 0. */ ++#define GET_NEXT_WC_FROM_BUFFER(WC, BUFPOS, BUFLEN, MBLENGTH, STATE, CONVFAIL) \ ++ do \ ++ { \ ++ mbstate_t state_bak; \ ++ \ ++ if (BUFLEN < 1) \ ++ { \ ++ WC = WEOF; \ ++ break; \ ++ } \ ++ \ ++ /* Get a wide character. */ \ ++ CONVFAIL = 0; \ ++ state_bak = STATE; \ ++ MBLENGTH = mbrtowc ((wchar_t *)&WC, BUFPOS, BUFLEN, &STATE); \ ++ \ ++ switch (MBLENGTH) \ ++ { \ ++ case (size_t)-1: \ ++ case (size_t)-2: \ ++ CONVFAIL++; \ ++ STATE = state_bak; \ ++ /* Fall througn. */ \ ++ \ ++ case 0: \ ++ MBLENGTH = 1; \ ++ break; \ ++ } \ ++ } \ ++ while (0) ++ + struct range_pair + { + size_t lo; +@@ -85,7 +148,7 @@ + /* The number of bytes allocated for FIELD_1_BUFFER. */ + static size_t field_1_bufsize; + +-/* The largest field or byte index used as an endpoint of a closed ++/* The largest byte, character or field index used as an endpoint of a closed + or degenerate range specification; this doesn't include the starting + index of right-open-ended ranges. For example, with either range spec + `2-5,9-', `2-3,5,9-' this variable would be set to 5. */ +@@ -97,10 +160,11 @@ + + /* This is a bit vector. + In byte mode, which bytes to output. ++ In character mode, which characters to output. + In field mode, which DELIM-separated fields to output. +- Both bytes and fields are numbered starting with 1, ++ Bytes, characters and fields are numbered starting with 1, + so the zeroth bit of this array is unused. +- A field or byte K has been selected if ++ A byte, character or field K has been selected if + (K <= MAX_RANGE_ENDPOINT and is_printable_field(K)) + || (EOL_RANGE_START > 0 && K >= EOL_RANGE_START). */ + static unsigned char *printable_field; +@@ -109,9 +173,12 @@ + { + undefined_mode, + +- /* Output characters that are in the given bytes. */ ++ /* Output bytes that are at the given positions. */ + byte_mode, + ++ /* Output characters that are at the given positions. */ ++ character_mode, ++ + /* Output the given delimeter-separated fields. */ + field_mode + }; +@@ -121,6 +188,13 @@ + + static enum operating_mode operating_mode; + ++/* If nonzero, when in byte mode, don't split multibyte characters. */ ++static int byte_mode_character_aware; ++ ++/* If nonzero, the function for single byte locale is work ++ if this program runs on multibyte locale. */ ++static int force_singlebyte_mode; ++ + /* If true do not output lines containing no delimeter characters. + Otherwise, all such lines are printed. This option is valid only + with field mode. */ +@@ -132,6 +206,9 @@ + + /* The delimeter character for field mode. */ + static unsigned char delim; ++#if HAVE_WCHAR_H ++static wchar_t wcdelim; ++#endif + + /* True if the --output-delimiter=STRING option was specified. */ + static bool output_delimiter_specified; +@@ -205,7 +282,7 @@ + -f, --fields=LIST select only these fields; also print any line\n\ + that contains no delimiter character, unless\n\ + the -s option is specified\n\ +- -n (ignored)\n\ ++ -n with -b: don't split multibyte characters\n\ + "), stdout); + fputs (_("\ + --complement complement the set of selected bytes, characters\n\ +@@ -360,7 +437,7 @@ + in_digits = false; + /* Starting a range. */ + if (dash_found) +- FATAL_ERROR (_("invalid byte or field list")); ++ FATAL_ERROR (_("invalid byte, character or field list")); + dash_found = true; + fieldstr++; + +@@ -385,14 +462,16 @@ + if (value == 0) + { + /* `n-'. From `initial' to end of line. */ +- eol_range_start = initial; ++ if (eol_range_start == 0 || ++ (eol_range_start != 0 && eol_range_start > initial)) ++ eol_range_start = initial; + field_found = true; + } + else + { + /* `m-n' or `-n' (1-n). */ + if (value < initial) +- FATAL_ERROR (_("invalid byte or field list")); ++ FATAL_ERROR (_("invalid byte, character or field list")); + + /* Is there already a range going to end of line? */ + if (eol_range_start != 0) +@@ -465,6 +544,9 @@ + if (operating_mode == byte_mode) + error (0, 0, + _("byte offset %s is too large"), quote (bad_num)); ++ else if (operating_mode == character_mode) ++ error (0, 0, ++ _("character offset %s is too large"), quote (bad_num)); + else + error (0, 0, + _("field number %s is too large"), quote (bad_num)); +@@ -475,7 +557,7 @@ + fieldstr++; + } + else +- FATAL_ERROR (_("invalid byte or field list")); ++ FATAL_ERROR (_("invalid byte, character or field list")); + } + + max_range_endpoint = 0; +@@ -568,6 +650,63 @@ + } + } + ++#if HAVE_MBRTOWC ++/* This function is in use for the following case. ++ ++ 1. Read from the stream STREAM, printing to standard output any selected ++ characters. ++ ++ 2. Read from stream STREAM, printing to standard output any selected bytes, ++ without splitting multibyte characters. */ ++ ++static void ++cut_characters_or_cut_bytes_no_split (FILE *stream) ++{ ++ int idx; /* number of bytes or characters in the line so far. */ ++ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ ++ char *bufpos; /* Next read position of BUF. */ ++ size_t buflen; /* The length of the byte sequence in buf. */ ++ wint_t wc; /* A gotten wide character. */ ++ size_t mblength; /* The byte size of a multibyte character which shows ++ as same character as WC. */ ++ mbstate_t state; /* State of the stream. */ ++ int convfail; /* 1, when conversion is failed. Otherwise 0. */ ++ ++ idx = 0; ++ buflen = 0; ++ bufpos = buf; ++ memset (&state, '\0', sizeof(mbstate_t)); ++ ++ while (1) ++ { ++ REFILL_BUFFER (buf, bufpos, buflen, stream); ++ ++ GET_NEXT_WC_FROM_BUFFER (wc, bufpos, buflen, mblength, state, convfail); ++ ++ if (wc == WEOF) ++ { ++ if (idx > 0) ++ putchar ('\n'); ++ break; ++ } ++ else if (wc == L'\n') ++ { ++ putchar ('\n'); ++ idx = 0; ++ } ++ else ++ { ++ idx += (operating_mode == byte_mode) ? mblength : 1; ++ if (print_kth (idx, NULL)) ++ fwrite (bufpos, mblength, sizeof(char), stdout); ++ } ++ ++ buflen -= mblength; ++ bufpos += mblength; ++ } ++} ++#endif ++ + /* Read from stream STREAM, printing to standard output any selected fields. */ + + static void +@@ -689,13 +828,192 @@ + } + } + ++#if HAVE_MBRTOWC ++static void ++cut_fields_mb (FILE *stream) ++{ ++ int c; ++ unsigned int field_idx; ++ int found_any_selected_field; ++ int buffer_first_field; ++ int empty_input; ++ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ ++ char *bufpos; /* Next read position of BUF. */ ++ size_t buflen; /* The length of the byte sequence in buf. */ ++ wint_t wc = 0; /* A gotten wide character. */ ++ size_t mblength; /* The byte size of a multibyte character which shows ++ as same character as WC. */ ++ mbstate_t state; /* State of the stream. */ ++ int convfail; /* 1, when conversion is failed. Otherwise 0. */ ++ ++ found_any_selected_field = 0; ++ field_idx = 1; ++ bufpos = buf; ++ buflen = 0; ++ memset (&state, '\0', sizeof(mbstate_t)); ++ ++ c = getc (stream); ++ empty_input = (c == EOF); ++ if (c != EOF) ++ ungetc (c, stream); ++ else ++ wc = WEOF; ++ ++ /* To support the semantics of the -s flag, we may have to buffer ++ all of the first field to determine whether it is `delimited.' ++ But that is unnecessary if all non-delimited lines must be printed ++ and the first field has been selected, or if non-delimited lines ++ must be suppressed and the first field has *not* been selected. ++ That is because a non-delimited line has exactly one field. */ ++ buffer_first_field = (suppress_non_delimited ^ !print_kth (1, NULL)); ++ ++ while (1) ++ { ++ if (field_idx == 1 && buffer_first_field) ++ { ++ int len = 0; ++ ++ while (1) ++ { ++ REFILL_BUFFER (buf, bufpos, buflen, stream); ++ ++ GET_NEXT_WC_FROM_BUFFER ++ (wc, bufpos, buflen, mblength, state, convfail); ++ ++ if (wc == WEOF) ++ break; ++ ++ field_1_buffer = xrealloc (field_1_buffer, len + mblength); ++ memcpy (field_1_buffer + len, bufpos, mblength); ++ len += mblength; ++ buflen -= mblength; ++ bufpos += mblength; ++ ++ if (!convfail && (wc == L'\n' || wc == wcdelim)) ++ break; ++ } ++ ++ if (wc == WEOF) ++ break; ++ ++ /* If the first field extends to the end of line (it is not ++ delimited) and we are printing all non-delimited lines, ++ print this one. */ ++ if (convfail || (!convfail && wc != wcdelim)) ++ { ++ if (suppress_non_delimited) ++ { ++ /* Empty. */ ++ } ++ else ++ { ++ fwrite (field_1_buffer, sizeof (char), len, stdout); ++ /* Make sure the output line is newline terminated. */ ++ if (convfail || (!convfail && wc != L'\n')) ++ putchar ('\n'); ++ } ++ continue; ++ } ++ ++ if (print_kth (1, NULL)) ++ { ++ /* Print the field, but not the trailing delimiter. */ ++ fwrite (field_1_buffer, sizeof (char), len - 1, stdout); ++ found_any_selected_field = 1; ++ } ++ ++field_idx; ++ } ++ ++ if (wc != WEOF) ++ { ++ if (print_kth (field_idx, NULL)) ++ { ++ if (found_any_selected_field) ++ { ++ fwrite (output_delimiter_string, sizeof (char), ++ output_delimiter_length, stdout); ++ } ++ found_any_selected_field = 1; ++ } ++ ++ while (1) ++ { ++ REFILL_BUFFER (buf, bufpos, buflen, stream); ++ ++ GET_NEXT_WC_FROM_BUFFER ++ (wc, bufpos, buflen, mblength, state, convfail); ++ ++ if (wc == WEOF) ++ break; ++ else if (!convfail && (wc == wcdelim || wc == L'\n')) ++ { ++ buflen -= mblength; ++ bufpos += mblength; ++ break; ++ } ++ ++ if (print_kth (field_idx, NULL)) ++ fwrite (bufpos, mblength, sizeof(char), stdout); ++ ++ buflen -= mblength; ++ bufpos += mblength; ++ } ++ } ++ ++ if ((!convfail || wc == L'\n') && buflen < 1) ++ wc = WEOF; ++ ++ if (!convfail && wc == wcdelim) ++ ++field_idx; ++ else if (wc == WEOF || (!convfail && wc == L'\n')) ++ { ++ if (found_any_selected_field ++ || (!empty_input && !(suppress_non_delimited && field_idx == 1))) ++ putchar ('\n'); ++ if (wc == WEOF) ++ break; ++ field_idx = 1; ++ found_any_selected_field = 0; ++ } ++ } ++} ++#endif ++ + static void + cut_stream (FILE *stream) + { +- if (operating_mode == byte_mode) +- cut_bytes (stream); ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1 && !force_singlebyte_mode) ++ { ++ switch (operating_mode) ++ { ++ case byte_mode: ++ if (byte_mode_character_aware) ++ cut_characters_or_cut_bytes_no_split (stream); ++ else ++ cut_bytes (stream); ++ break; ++ ++ case character_mode: ++ cut_characters_or_cut_bytes_no_split (stream); ++ break; ++ ++ case field_mode: ++ cut_fields_mb (stream); ++ break; ++ ++ default: ++ abort (); ++ } ++ } + else +- cut_fields (stream); ++#endif ++ { ++ if (operating_mode == field_mode) ++ cut_fields (stream); ++ else ++ cut_bytes (stream); ++ } + } + + /* Process file FILE to standard output. +@@ -745,6 +1063,8 @@ + bool ok; + bool delim_specified = false; + char *spec_list_string IF_LINT(= NULL); ++ char mbdelim[MB_LEN_MAX + 1]; ++ size_t delimlen = 0; + + initialize_main (&argc, &argv); + program_name = argv[0]; +@@ -767,7 +1087,6 @@ + switch (optc) + { + case 'b': +- case 'c': + /* Build the byte list. */ + if (operating_mode != undefined_mode) + FATAL_ERROR (_("only one type of list may be specified")); +@@ -775,6 +1094,14 @@ + spec_list_string = optarg; + break; + ++ case 'c': ++ /* Build the character list. */ ++ if (operating_mode != undefined_mode) ++ FATAL_ERROR (_("only one type of list may be specified")); ++ operating_mode = character_mode; ++ spec_list_string = optarg; ++ break; ++ + case 'f': + /* Build the field list. */ + if (operating_mode != undefined_mode) +@@ -786,10 +1113,35 @@ + case 'd': + /* New delimiter. */ + /* Interpret -d '' to mean `use the NUL byte as the delimiter.' */ +- if (optarg[0] != '\0' && optarg[1] != '\0') +- FATAL_ERROR (_("the delimiter must be a single character")); +- delim = optarg[0]; +- delim_specified = true; ++#if HAVE_MBRTOWC ++ { ++ if(MB_CUR_MAX > 1) ++ { ++ mbstate_t state; ++ ++ memset (&state, '\0', sizeof(mbstate_t)); ++ delimlen = mbrtowc (&wcdelim, optarg, strnlen(optarg, MB_LEN_MAX), &state); ++ ++ if (delimlen == (size_t)-1 || delimlen == (size_t)-2) ++ ++force_singlebyte_mode; ++ else ++ { ++ delimlen = (delimlen < 1) ? 1 : delimlen; ++ if (wcdelim != L'\0' && *(optarg + delimlen) != '\0') ++ FATAL_ERROR (_("the delimiter must be a single character")); ++ memcpy (mbdelim, optarg, delimlen); ++ } ++ } ++ ++ if (MB_CUR_MAX <= 1 || force_singlebyte_mode) ++#endif ++ { ++ if (optarg[0] != '\0' && optarg[1] != '\0') ++ FATAL_ERROR (_("the delimiter must be a single character")); ++ delim = (unsigned char) optarg[0]; ++ } ++ delim_specified = true; ++ } + break; + + case OUTPUT_DELIMITER_OPTION: +@@ -802,6 +1154,7 @@ + break; + + case 'n': ++ byte_mode_character_aware = 1; + break; + + case 's': +@@ -824,7 +1177,7 @@ + if (operating_mode == undefined_mode) + FATAL_ERROR (_("you must specify a list of bytes, characters, or fields")); + +- if (delim != '\0' && operating_mode != field_mode) ++ if (delim_specified && operating_mode != field_mode) + FATAL_ERROR (_("an input delimiter may be specified only\ + when operating on fields")); + +@@ -851,15 +1204,34 @@ + } + + if (!delim_specified) +- delim = '\t'; ++ { ++ delim = '\t'; ++#ifdef HAVE_MBRTOWC ++ wcdelim = L'\t'; ++ mbdelim[0] = '\t'; ++ mbdelim[1] = '\0'; ++ delimlen = 1; ++#endif ++ } + + if (output_delimiter_string == NULL) + { +- static char dummy[2]; +- dummy[0] = delim; +- dummy[1] = '\0'; +- output_delimiter_string = dummy; +- output_delimiter_length = 1; ++#ifdef HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1 && !force_singlebyte_mode) ++ { ++ output_delimiter_string = xstrdup(mbdelim); ++ output_delimiter_length = delimlen; ++ } ++ ++ if (MB_CUR_MAX <= 1 || force_singlebyte_mode) ++#endif ++ { ++ static char dummy[2]; ++ dummy[0] = delim; ++ dummy[1] = '\0'; ++ output_delimiter_string = dummy; ++ output_delimiter_length = 1; ++ } + } + + if (optind == argc) +--- coreutils-5.93/src/pr.c.i18n 2005-09-16 08:50:33.000000000 +0100 ++++ coreutils-5.93/src/pr.c 2005-12-23 08:53:01.000000000 +0000 +@@ -313,6 +313,32 @@ + + #include + #include ++ ++/* Get MB_LEN_MAX. */ ++#include ++/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC ++ installation; work around this configuration error. */ ++#if !defined MB_LEN_MAX || MB_LEN_MAX == 1 ++# define MB_LEN_MAX 16 ++#endif ++ ++/* Get MB_CUR_MAX. */ ++#include ++ ++/* Solaris 2.5 has a bug: must be included before . */ ++/* Get mbstate_t, mbrtowc(), wcwidth(). */ ++#if HAVE_WCHAR_H ++# include ++#endif ++ ++/* Get iswprint(). -- for wcwidth(). */ ++#if HAVE_WCTYPE_H ++# include ++#endif ++#if !defined iswprint && !HAVE_ISWPRINT ++# define iswprint(wc) 1 ++#endif ++ + #include "system.h" + #include "error.h" + #include "hard-locale.h" +@@ -324,6 +350,18 @@ + #include "strftime.h" + #include "xstrtol.h" + ++/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ ++#if HAVE_MBRTOWC && defined mbstate_t ++# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) ++#endif ++ ++#ifndef HAVE_DECL_WCWIDTH ++"this configure-time declaration test was not run" ++#endif ++#if !HAVE_DECL_WCWIDTH ++extern int wcwidth (); ++#endif ++ + /* The official name of this program (e.g., no `g' prefix). */ + #define PROGRAM_NAME "pr" + +@@ -416,7 +454,20 @@ + + #define NULLCOL (COLUMN *)0 + +-static int char_to_clump (char c); ++/* Funtion pointers to switch functions for single byte locale or for ++ multibyte locale. If multibyte functions do not exist in your sysytem, ++ these pointers always point the function for single byte locale. */ ++static void (*print_char) (char c); ++static int (*char_to_clump) (char c); ++ ++/* Functions for single byte locale. */ ++static void print_char_single (char c); ++static int char_to_clump_single (char c); ++ ++/* Functions for multibyte locale. */ ++static void print_char_multi (char c); ++static int char_to_clump_multi (char c); ++ + static bool read_line (COLUMN *p); + static bool print_page (void); + static bool print_stored (COLUMN *p); +@@ -426,6 +477,7 @@ + static void pad_across_to (int position); + static void add_line_number (COLUMN *p); + static void getoptarg (char *arg, char switch_char, char *character, ++ int *character_length, int *character_width, + int *number); + void usage (int status); + static void print_files (int number_of_files, char **av); +@@ -440,7 +492,6 @@ + static void pad_down (int lines); + static void read_rest_of_line (COLUMN *p); + static void skip_read (COLUMN *p, int column_number); +-static void print_char (char c); + static void cleanup (void); + static void print_sep_string (void); + static void separator_string (const char *optarg_S); +@@ -455,7 +506,7 @@ + we store the leftmost columns contiguously in buff. + To print a line from buff, get the index of the first character + from line_vector[i], and print up to line_vector[i + 1]. */ +-static char *buff; ++static unsigned char *buff; + + /* Index of the position in buff where the next character + will be stored. */ +@@ -559,7 +610,7 @@ + static bool untabify_input = false; + + /* (-e) The input tab character. */ +-static char input_tab_char = '\t'; ++static char input_tab_char[MB_LEN_MAX] = "\t"; + + /* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ... + where the leftmost column is 1. */ +@@ -569,7 +620,10 @@ + static bool tabify_output = false; + + /* (-i) The output tab character. */ +-static char output_tab_char = '\t'; ++static char output_tab_char[MB_LEN_MAX] = "\t"; ++ ++/* (-i) The byte length of output tab character. */ ++static int output_tab_char_length = 1; + + /* (-i) The width of the output tab. */ + static int chars_per_output_tab = 8; +@@ -643,7 +697,13 @@ + static bool numbered_lines = false; + + /* (-n) Character which follows each line number. */ +-static char number_separator = '\t'; ++static char number_separator[MB_LEN_MAX] = "\t"; ++ ++/* (-n) The byte length of the character which follows each line number. */ ++static int number_separator_length = 1; ++ ++/* (-n) The character width of the character which follows each line number. */ ++static int number_separator_width = 0; + + /* (-n) line counting starts with 1st line of input file (not with 1st + line of 1st page printed). */ +@@ -696,6 +756,7 @@ + -a|COLUMN|-m is a `space' and with the -J option a `tab'. */ + static char *col_sep_string = ""; + static int col_sep_length = 0; ++static int col_sep_width = 0; + static char *column_separator = " "; + static char *line_separator = "\t"; + +@@ -852,6 +913,13 @@ + col_sep_length = (int) strlen (optarg_S); + col_sep_string = xmalloc (col_sep_length + 1); + strcpy (col_sep_string, optarg_S); ++ ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ col_sep_width = mbswidth (col_sep_string, 0); ++ else ++#endif ++ col_sep_width = col_sep_length; + } + + int +@@ -877,6 +945,21 @@ + + atexit (close_stdout); + ++/* Define which functions are used, the ones for single byte locale or the ones ++ for multibyte locale. */ ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ print_char = print_char_multi; ++ char_to_clump = char_to_clump_multi; ++ } ++ else ++#endif ++ { ++ print_char = print_char_single; ++ char_to_clump = char_to_clump_single; ++ } ++ + n_files = 0; + file_names = (argc > 1 + ? xmalloc ((argc - 1) * sizeof (char *)) +@@ -949,8 +1032,12 @@ + break; + case 'e': + if (optarg) +- getoptarg (optarg, 'e', &input_tab_char, +- &chars_per_input_tab); ++ { ++ int dummy_length, dummy_width; ++ ++ getoptarg (optarg, 'e', input_tab_char, &dummy_length, ++ &dummy_width, &chars_per_input_tab); ++ } + /* Could check tab width > 0. */ + untabify_input = true; + break; +@@ -963,8 +1050,12 @@ + break; + case 'i': + if (optarg) +- getoptarg (optarg, 'i', &output_tab_char, +- &chars_per_output_tab); ++ { ++ int dummy_width; ++ ++ getoptarg (optarg, 'i', output_tab_char, &output_tab_char_length, ++ &dummy_width, &chars_per_output_tab); ++ } + /* Could check tab width > 0. */ + tabify_output = true; + break; +@@ -991,8 +1082,8 @@ + case 'n': + numbered_lines = true; + if (optarg) +- getoptarg (optarg, 'n', &number_separator, +- &chars_per_number); ++ getoptarg (optarg, 'n', number_separator, &number_separator_length, ++ &number_separator_width, &chars_per_number); + break; + case 'N': + skip_count = false; +@@ -1031,7 +1122,7 @@ + old_s = false; + /* Reset an additional input of -s, -S dominates -s */ + col_sep_string = ""; +- col_sep_length = 0; ++ col_sep_length = col_sep_width = 0; + use_col_separator = true; + if (optarg) + separator_string (optarg); +@@ -1188,10 +1279,45 @@ + a number. */ + + static void +-getoptarg (char *arg, char switch_char, char *character, int *number) ++getoptarg (char *arg, char switch_char, char *character, int *character_length, ++ int *character_width, int *number) + { + if (!ISDIGIT (*arg)) +- *character = *arg++; ++ { ++#ifdef HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) /* for multibyte locale. */ ++ { ++ wchar_t wc; ++ size_t mblength; ++ int width; ++ mbstate_t state = {'\0'}; ++ ++ mblength = mbrtowc (&wc, arg, strnlen(arg, MB_LEN_MAX), &state); ++ ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ *character_length = 1; ++ *character_width = 1; ++ } ++ else ++ { ++ *character_length = (mblength < 1) ? 1 : mblength; ++ width = wcwidth (wc); ++ *character_width = (width < 0) ? 0 : width; ++ } ++ ++ strncpy (character, arg, *character_length); ++ arg += *character_length; ++ } ++ else /* for single byte locale. */ ++#endif ++ { ++ *character = *arg++; ++ *character_length = 1; ++ *character_width = 1; ++ } ++ } ++ + if (*arg) + { + long int tmp_long; +@@ -1256,7 +1382,7 @@ + else + col_sep_string = column_separator; + +- col_sep_length = 1; ++ col_sep_length = col_sep_width = 1; + use_col_separator = true; + } + /* It's rather pointless to define a TAB separator with column +@@ -1288,11 +1414,11 @@ + TAB_WIDTH (chars_per_input_tab, chars_per_number); */ + + /* Estimate chars_per_text without any margin and keep it constant. */ +- if (number_separator == '\t') ++ if (number_separator[0] == '\t') + number_width = chars_per_number + + TAB_WIDTH (chars_per_default_tab, chars_per_number); + else +- number_width = chars_per_number + 1; ++ number_width = chars_per_number + number_separator_width; + + /* The number is part of the column width unless we are + printing files in parallel. */ +@@ -1307,7 +1433,7 @@ + } + + chars_per_column = (chars_per_line - chars_used_by_number - +- (columns - 1) * col_sep_length) / columns; ++ (columns - 1) * col_sep_width) / columns; + + if (chars_per_column < 1) + error (EXIT_FAILURE, 0, _("page width too narrow")); +@@ -1432,7 +1558,7 @@ + + /* Enlarge p->start_position of first column to use the same form of + padding_not_printed with all columns. */ +- h = h + col_sep_length; ++ h = h + col_sep_width; + + /* This loop takes care of all but the rightmost column. */ + +@@ -1466,7 +1592,7 @@ + } + else + { +- h = h_next + col_sep_length; ++ h = h_next + col_sep_width; + h_next = h + chars_per_column; + } + } +@@ -1756,9 +1882,9 @@ + align_column (COLUMN *p) + { + padding_not_printed = p->start_position; +- if (padding_not_printed - col_sep_length > 0) ++ if (padding_not_printed - col_sep_width > 0) + { +- pad_across_to (padding_not_printed - col_sep_length); ++ pad_across_to (padding_not_printed - col_sep_width); + padding_not_printed = ANYWHERE; + } + +@@ -2029,13 +2155,13 @@ + /* May be too generous. */ + buff = X2REALLOC (buff, &buff_allocated); + } +- buff[buff_current++] = c; ++ buff[buff_current++] = (unsigned char) c; + } + + static void + add_line_number (COLUMN *p) + { +- int i; ++ int i, j; + char *s; + int left_cut; + +@@ -2058,22 +2184,24 @@ + /* Tabification is assumed for multiple columns, also for n-separators, + but `default n-separator = TAB' hasn't been given priority over + equal column_width also specified by POSIX. */ +- if (number_separator == '\t') ++ if (number_separator[0] == '\t') + { + i = number_width - chars_per_number; + while (i-- > 0) + (p->char_func) (' '); + } + else +- (p->char_func) (number_separator); ++ for (j = 0; j < number_separator_length; j++) ++ (p->char_func) (number_separator[j]); + } + else + /* To comply with POSIX, we avoid any expansion of default TAB + separator with a single column output. No column_width requirement + has to be considered. */ + { +- (p->char_func) (number_separator); +- if (number_separator == '\t') ++ for (j = 0; j < number_separator_length; j++) ++ (p->char_func) (number_separator[j]); ++ if (number_separator[0] == '\t') + output_position = POS_AFTER_TAB (chars_per_output_tab, + output_position); + } +@@ -2234,7 +2362,7 @@ + while (goal - h_old > 1 + && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) + { +- putchar (output_tab_char); ++ fwrite (output_tab_char, sizeof(char), output_tab_char_length, stdout); + h_old = h_new; + } + while (++h_old <= goal) +@@ -2254,6 +2382,7 @@ + { + char *s; + int l = col_sep_length; ++ int not_space_flag; + + s = col_sep_string; + +@@ -2267,6 +2396,7 @@ + { + for (; separators_not_printed > 0; --separators_not_printed) + { ++ not_space_flag = 0; + while (l-- > 0) + { + /* 3 types of sep_strings: spaces only, spaces and chars, +@@ -2280,12 +2410,15 @@ + } + else + { ++ not_space_flag = 1; + if (spaces_not_printed > 0) + print_white_space (); + putchar (*s++); +- ++output_position; + } + } ++ if (not_space_flag) ++ output_position += col_sep_width; ++ + /* sep_string ends with some spaces */ + if (spaces_not_printed > 0) + print_white_space (); +@@ -2313,7 +2446,7 @@ + required number of tabs and spaces. */ + + static void +-print_char (char c) ++print_char_single (char c) + { + if (tabify_output) + { +@@ -2337,6 +2470,74 @@ + putchar (c); + } + ++#ifdef HAVE_MBRTOWC ++static void ++print_char_multi (char c) ++{ ++ static size_t mbc_pos = 0; ++ static unsigned char mbc[MB_LEN_MAX] = {'\0'}; ++ static mbstate_t state = {'\0'}; ++ mbstate_t state_bak; ++ wchar_t wc; ++ size_t mblength; ++ int width; ++ ++ if (tabify_output) ++ { ++ state_bak = state; ++ mbc[mbc_pos++] = (unsigned char)c; ++ mblength = mbrtowc (&wc, mbc, mbc_pos, &state); ++ ++ while (mbc_pos > 0) ++ { ++ switch (mblength) ++ { ++ case (size_t)-2: ++ state = state_bak; ++ return; ++ ++ case (size_t)-1: ++ state = state_bak; ++ ++output_position; ++ putchar (mbc[0]); ++ memmove (mbc, mbc + 1, MB_CUR_MAX - 1); ++ --mbc_pos; ++ break; ++ ++ case 0: ++ mblength = 1; ++ ++ default: ++ if (wc == L' ') ++ { ++ memmove (mbc, mbc + mblength, MB_CUR_MAX - mblength); ++ --mbc_pos; ++ ++spaces_not_printed; ++ return; ++ } ++ else if (spaces_not_printed > 0) ++ print_white_space (); ++ ++ /* Nonprintables are assumed to have width 0, except L'\b'. */ ++ if ((width = wcwidth (wc)) < 1) ++ { ++ if (wc == L'\b') ++ --output_position; ++ } ++ else ++ output_position += width; ++ ++ fwrite (mbc, sizeof(char), mblength, stdout); ++ memmove (mbc, mbc + mblength, MB_CUR_MAX - mblength); ++ mbc_pos -= mblength; ++ } ++ } ++ return; ++ } ++ putchar (c); ++} ++#endif ++ + /* Skip to page PAGE before printing. + PAGE may be larger than total number of pages. */ + +@@ -2517,9 +2718,9 @@ + align_empty_cols = false; + } + +- if (padding_not_printed - col_sep_length > 0) ++ if (padding_not_printed - col_sep_width > 0) + { +- pad_across_to (padding_not_printed - col_sep_length); ++ pad_across_to (padding_not_printed - col_sep_width); + padding_not_printed = ANYWHERE; + } + +@@ -2620,9 +2821,9 @@ + } + } + +- if (padding_not_printed - col_sep_length > 0) ++ if (padding_not_printed - col_sep_width > 0) + { +- pad_across_to (padding_not_printed - col_sep_length); ++ pad_across_to (padding_not_printed - col_sep_width); + padding_not_printed = ANYWHERE; + } + +@@ -2635,8 +2836,8 @@ + if (spaces_not_printed == 0) + { + output_position = p->start_position + end_vector[line]; +- if (p->start_position - col_sep_length == chars_per_margin) +- output_position -= col_sep_length; ++ if (p->start_position - col_sep_width == chars_per_margin) ++ output_position -= col_sep_width; + } + + return true; +@@ -2655,7 +2856,7 @@ + number of characters is 1.) */ + + static int +-char_to_clump (char c) ++char_to_clump_single (char c) + { + unsigned char uc = c; + char *s = clump_buff; +@@ -2665,10 +2866,10 @@ + int chars; + int chars_per_c = 8; + +- if (c == input_tab_char) ++ if (c == input_tab_char[0]) + chars_per_c = chars_per_input_tab; + +- if (c == input_tab_char || c == '\t') ++ if (c == input_tab_char[0] || c == '\t') + { + width = TAB_WIDTH (chars_per_c, input_position); + +@@ -2739,6 +2940,154 @@ + return chars; + } + ++#ifdef HAVE_MBRTOWC ++static int ++char_to_clump_multi (char c) ++{ ++ static size_t mbc_pos = 0; ++ static char mbc[MB_LEN_MAX] = {'\0'}; ++ static mbstate_t state = {'\0'}; ++ mbstate_t state_bak; ++ wchar_t wc; ++ size_t mblength; ++ int wc_width; ++ register int *s = clump_buff; ++ register int i, j; ++ char esc_buff[4]; ++ int width; ++ int chars; ++ int chars_per_c = 8; ++ ++ state_bak = state; ++ mbc[mbc_pos++] = c; ++ mblength = mbrtowc (&wc, mbc, mbc_pos, &state); ++ ++ width = 0; ++ chars = 0; ++ while (mbc_pos > 0) ++ { ++ switch (mblength) ++ { ++ case (size_t)-2: ++ state = state_bak; ++ return 0; ++ ++ case (size_t)-1: ++ state = state_bak; ++ mblength = 1; ++ ++ if (use_esc_sequence || use_cntrl_prefix) ++ { ++ width = +4; ++ chars = +4; ++ *s++ = '\\'; ++ sprintf (esc_buff, "%03o", mbc[0]); ++ for (i = 0; i <= 2; ++i) ++ *s++ = (int) esc_buff[i]; ++ } ++ else ++ { ++ width += 1; ++ chars += 1; ++ *s++ = mbc[0]; ++ } ++ break; ++ ++ case 0: ++ mblength = 1; ++ /* Fall through */ ++ ++ default: ++ if (memcmp (mbc, input_tab_char, mblength) == 0) ++ chars_per_c = chars_per_input_tab; ++ ++ if (memcmp (mbc, input_tab_char, mblength) == 0 || c == '\t') ++ { ++ int width_inc; ++ ++ width_inc = TAB_WIDTH (chars_per_c, input_position); ++ width += width_inc; ++ ++ if (untabify_input) ++ { ++ for (i = width_inc; i; --i) ++ *s++ = ' '; ++ chars += width_inc; ++ } ++ else ++ { ++ for (i = 0; i < mblength; i++) ++ *s++ = mbc[i]; ++ chars += mblength; ++ } ++ } ++ else if ((wc_width = wcwidth (wc)) < 1) ++ { ++ if (use_esc_sequence) ++ { ++ for (i = 0; i < mblength; i++) ++ { ++ width += 4; ++ chars += 4; ++ *s++ = '\\'; ++ sprintf (esc_buff, "%03o", c); ++ for (j = 0; j <= 2; ++j) ++ *s++ = (int) esc_buff[j]; ++ } ++ } ++ else if (use_cntrl_prefix) ++ { ++ if (wc < 0200) ++ { ++ width += 2; ++ chars += 2; ++ *s++ = '^'; ++ *s++ = wc ^ 0100; ++ } ++ else ++ { ++ for (i = 0; i < mblength; i++) ++ { ++ width += 4; ++ chars += 4; ++ *s++ = '\\'; ++ sprintf (esc_buff, "%03o", c); ++ for (j = 0; j <= 2; ++j) ++ *s++ = (int) esc_buff[j]; ++ } ++ } ++ } ++ else if (wc == L'\b') ++ { ++ width += -1; ++ chars += 1; ++ *s++ = c; ++ } ++ else ++ { ++ width += 0; ++ chars += mblength; ++ for (i = 0; i < mblength; i++) ++ *s++ = mbc[i]; ++ } ++ } ++ else ++ { ++ width += wc_width; ++ chars += mblength; ++ for (i = 0; i < mblength; i++) ++ *s++ = mbc[i]; ++ } ++ } ++ memmove (mbc, mbc + mblength, MB_CUR_MAX - mblength); ++ mbc_pos -= mblength; ++ } ++ ++ input_position += width; ++ return chars; ++} ++#endif ++ + /* We've just printed some files and need to clean up things before + looking for more options and printing the next batch of files. + +--- coreutils-5.93/src/uniq.c.i18n 2005-07-05 07:32:54.000000000 +0100 ++++ coreutils-5.93/src/uniq.c 2005-12-23 08:53:01.000000000 +0000 +@@ -23,6 +23,16 @@ + #include + #include + ++/* Get mbstate_t, mbrtowc(). */ ++#if HAVE_WCHAR_H ++# include ++#endif ++ ++/* Get isw* functions. */ ++#if HAVE_WCTYPE_H ++# include ++#endif ++ + #include "system.h" + #include "argmatch.h" + #include "linebuffer.h" +@@ -32,7 +42,19 @@ + #include "quote.h" + #include "xmemcoll.h" + #include "xstrtol.h" +-#include "memcasecmp.h" ++#include "xmemcoll.h" ++ ++/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC ++ installation; work around this configuration error. */ ++#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 ++# define MB_LEN_MAX 16 ++#endif ++ ++/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ ++#if HAVE_MBRTOWC && defined mbstate_t ++# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) ++#endif ++ + + /* The official name of this program (e.g., no `g' prefix). */ + #define PROGRAM_NAME "uniq" +@@ -109,6 +131,10 @@ + /* Select whether/how to delimit groups of duplicate lines. */ + static enum delimit_method delimit_groups; + ++/* Function pointers. */ ++static char * ++(*find_field) (struct linebuffer *line); ++ + static struct option const longopts[] = + { + {"count", no_argument, NULL, 'c'}, +@@ -189,7 +215,7 @@ + return a pointer to the beginning of the line's field to be compared. */ + + static char * +-find_field (const struct linebuffer *line) ++find_field_uni (struct linebuffer *line) + { + size_t count; + char *lp = line->buffer; +@@ -210,6 +236,83 @@ + return lp + i; + } + ++#if HAVE_MBRTOWC ++ ++# define MBCHAR_TO_WCHAR(WC, MBLENGTH, LP, POS, SIZE, STATEP, CONVFAIL) \ ++ do \ ++ { \ ++ mbstate_t state_bak; \ ++ \ ++ CONVFAIL = 0; \ ++ state_bak = *STATEP; \ ++ \ ++ MBLENGTH = mbrtowc (&WC, LP + POS, SIZE - POS, STATEP); \ ++ \ ++ switch (MBLENGTH) \ ++ { \ ++ case (size_t)-2: \ ++ case (size_t)-1: \ ++ *STATEP = state_bak; \ ++ CONVFAIL++; \ ++ /* Fall through */ \ ++ case 0: \ ++ MBLENGTH = 1; \ ++ } \ ++ } \ ++ while (0) ++ ++static char * ++find_field_multi (struct linebuffer *line) ++{ ++ size_t count; ++ char *lp = line->buffer; ++ size_t size = line->length - 1; ++ size_t pos; ++ size_t mblength; ++ wchar_t wc; ++ mbstate_t *statep; ++ int convfail; ++ ++ pos = 0; ++ statep = &(line->state); ++ ++ /* skip fields. */ ++ for (count = 0; count < skip_fields && pos < size; count++) ++ { ++ while (pos < size) ++ { ++ MBCHAR_TO_WCHAR (wc, mblength, lp, pos, size, statep, convfail); ++ ++ if (convfail || !iswblank (wc)) ++ { ++ pos += mblength; ++ break; ++ } ++ pos += mblength; ++ } ++ ++ while (pos < size) ++ { ++ MBCHAR_TO_WCHAR (wc, mblength, lp, pos, size, statep, convfail); ++ ++ if (!convfail && iswblank (wc)) ++ break; ++ ++ pos += mblength; ++ } ++ } ++ ++ /* skip fields. */ ++ for (count = 0; count < skip_chars && pos < size; count++) ++ { ++ MBCHAR_TO_WCHAR (wc, mblength, lp, pos, size, statep, convfail); ++ pos += mblength; ++ } ++ ++ return lp + pos; ++} ++#endif ++ + /* Return false if two strings OLD and NEW match, true if not. + OLD and NEW point not to the beginnings of the lines + but rather to the beginnings of the fields to compare. +@@ -218,6 +321,8 @@ + static bool + different (char *old, char *new, size_t oldlen, size_t newlen) + { ++ char *copy_old, *copy_new; ++ + if (check_chars < oldlen) + oldlen = check_chars; + if (check_chars < newlen) +@@ -225,14 +330,92 @@ + + if (ignore_case) + { +- /* FIXME: This should invoke strcoll somehow. */ +- return oldlen != newlen || memcasecmp (old, new, oldlen); ++ size_t i; ++ ++ copy_old = alloca (oldlen + 1); ++ copy_new = alloca (oldlen + 1); ++ ++ for (i = 0; i < oldlen; i++) ++ { ++ copy_old[i] = toupper (old[i]); ++ copy_new[i] = toupper (new[i]); ++ } + } +- else if (hard_LC_COLLATE) +- return xmemcoll (old, oldlen, new, newlen) != 0; + else +- return oldlen != newlen || memcmp (old, new, oldlen); ++ { ++ copy_old = (char *)old; ++ copy_new = (char *)new; ++ } ++ ++ return xmemcoll (copy_old, oldlen, copy_new, newlen); ++} ++ ++#if HAVE_MBRTOWC ++static int ++different_multi (const char *old, const char *new, size_t oldlen, size_t newlen, mbstate_t oldstate, mbstate_t newstate) ++{ ++ size_t i, j, chars; ++ const char *str[2]; ++ char *copy[2]; ++ size_t len[2]; ++ mbstate_t state[2]; ++ size_t mblength; ++ wchar_t wc, uwc; ++ mbstate_t state_bak; ++ ++ str[0] = old; ++ str[1] = new; ++ len[0] = oldlen; ++ len[1] = newlen; ++ state[0] = oldstate; ++ state[1] = newstate; ++ ++ for (i = 0; i < 2; i++) ++ { ++ copy[i] = alloca (len[i] + 1); ++ ++ for (j = 0, chars = 0; j < len[i] && chars < check_chars; chars++) ++ { ++ state_bak = state[i]; ++ mblength = mbrtowc (&wc, str[i] + j, len[i] - j, &(state[i])); ++ ++ switch (mblength) ++ { ++ case (size_t)-1: ++ case (size_t)-2: ++ state[i] = state_bak; ++ /* Fall through */ ++ case 0: ++ mblength = 1; ++ break; ++ ++ default: ++ if (ignore_case) ++ { ++ uwc = towupper (wc); ++ ++ if (uwc != wc) ++ { ++ mbstate_t state_wc; ++ ++ memset (&state_wc, '\0', sizeof(mbstate_t)); ++ wcrtomb (copy[i] + j, uwc, &state_wc); ++ } ++ else ++ memcpy (copy[i] + j, str[i] + j, mblength); ++ } ++ else ++ memcpy (copy[i] + j, str[i] + j, mblength); ++ } ++ j += mblength; ++ } ++ copy[i][j] = '\0'; ++ len[i] = j; ++ } ++ ++ return xmemcoll (copy[0], len[0], copy[1], len[1]); + } ++#endif + + /* Output the line in linebuffer LINE to standard output + provided that the switches say it should be output. +@@ -286,15 +469,43 @@ + { + char *prevfield IF_LINT (= NULL); + size_t prevlen IF_LINT (= 0); ++#if HAVE_MBRTOWC ++ mbstate_t prevstate; ++ ++ memset (&prevstate, '\0', sizeof (mbstate_t)); ++#endif + + while (!feof (stdin)) + { + char *thisfield; + size_t thislen; ++#if HAVE_MBRTOWC ++ mbstate_t thisstate; ++#endif ++ + if (readlinebuffer (thisline, stdin) == 0) + break; + thisfield = find_field (thisline); + thislen = thisline->length - 1 - (thisfield - thisline->buffer); ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ thisstate = thisline->state; ++ ++ if (prevline->length == 0 || different_multi ++ (thisfield, prevfield, thislen, prevlen, thisstate, prevstate)) ++ { ++ fwrite (thisline->buffer, sizeof (char), ++ thisline->length, stdout); ++ ++ SWAP_LINES (prevline, thisline); ++ prevfield = thisfield; ++ prevlen = thislen; ++ prevstate = thisstate; ++ } ++ } ++ else ++#endif + if (prevline->length == 0 + || different (thisfield, prevfield, thislen, prevlen)) + { +@@ -313,17 +524,26 @@ + size_t prevlen; + uintmax_t match_count = 0; + bool first_delimiter = true; ++#if HAVE_MBRTOWC ++ mbstate_t prevstate; ++#endif + + if (readlinebuffer (prevline, stdin) == 0) + goto closefiles; + prevfield = find_field (prevline); + prevlen = prevline->length - 1 - (prevfield - prevline->buffer); ++#if HAVE_MBRTOWC ++ prevstate = prevline->state; ++#endif + + while (!feof (stdin)) + { + bool match; + char *thisfield; + size_t thislen; ++#if HAVE_MBRTOWC ++ mbstate_t thisstate; ++#endif + if (readlinebuffer (thisline, stdin) == 0) + { + if (ferror (stdin)) +@@ -332,6 +552,15 @@ + } + thisfield = find_field (thisline); + thislen = thisline->length - 1 - (thisfield - thisline->buffer); ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ thisstate = thisline->state; ++ match = !different_multi (thisfield, prevfield, ++ thislen, prevlen, thisstate, prevstate); ++ } ++ else ++#endif + match = !different (thisfield, prevfield, thislen, prevlen); + match_count += match; + +@@ -364,6 +593,9 @@ + SWAP_LINES (prevline, thisline); + prevfield = thisfield; + prevlen = thislen; ++#if HAVE_MBRTOWC ++ prevstate = thisstate; ++#endif + if (!match) + match_count = 0; + } +@@ -408,6 +640,19 @@ + + atexit (close_stdout); + ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ find_field = find_field_multi; ++ } ++ else ++#endif ++ { ++ find_field = find_field_uni; ++ } ++ ++ ++ + skip_chars = 0; + skip_fields = 0; + check_chars = SIZE_MAX; +--- coreutils-5.93/src/expand.c.i18n 2005-08-12 08:16:25.000000000 +0100 ++++ coreutils-5.93/src/expand.c 2005-12-23 08:53:01.000000000 +0000 +@@ -38,11 +38,28 @@ + #include + #include + #include ++ ++/* Get mbstate_t, mbrtowc(), wcwidth(). */ ++#if HAVE_WCHAR_H ++# include ++#endif ++ + #include "system.h" + #include "error.h" + #include "quote.h" + #include "xstrndup.h" + ++/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC ++ installation; work around this configuration error. */ ++#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 ++# define MB_LEN_MAX 16 ++#endif ++ ++/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ ++#if HAVE_MBRTOWC && defined mbstate_t ++# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) ++#endif ++ + /* The official name of this program (e.g., no `g' prefix). */ + #define PROGRAM_NAME "expand" + +@@ -182,6 +199,7 @@ + stops = num_start + len - 1; + } + } ++ + else + { + error (0, 0, _("tab size contains invalid character(s): %s"), +@@ -364,6 +382,142 @@ + } + } + ++#if HAVE_MBRTOWC ++static void ++expand_multibyte (void) ++{ ++ FILE *fp; /* Input strem. */ ++ mbstate_t i_state; /* Current shift state of the input stream. */ ++ mbstate_t i_state_bak; /* Back up the I_STATE. */ ++ mbstate_t o_state; /* Current shift state of the output stream. */ ++ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ ++ char *bufpos; /* Next read position of BUF. */ ++ size_t buflen = 0; /* The length of the byte sequence in buf. */ ++ wchar_t wc; /* A gotten wide character. */ ++ size_t mblength; /* The byte size of a multibyte character ++ which shows as same character as WC. */ ++ int tab_index = 0; /* Index in `tab_list' of next tabstop. */ ++ int column = 0; /* Column on screen of the next char. */ ++ int next_tab_column; /* Column the next tab stop is on. */ ++ int convert = 1; /* If nonzero, perform translations. */ ++ ++ fp = next_file ((FILE *) NULL); ++ if (fp == NULL) ++ return; ++ ++ memset (&o_state, '\0', sizeof(mbstate_t)); ++ memset (&i_state, '\0', sizeof(mbstate_t)); ++ ++ for (;;) ++ { ++ /* Refill the buffer BUF. */ ++ if (buflen < MB_LEN_MAX && !feof(fp) && !ferror(fp)) ++ { ++ memmove (buf, bufpos, buflen); ++ buflen += fread (buf + buflen, sizeof(char), BUFSIZ, fp); ++ bufpos = buf; ++ } ++ ++ /* No character is left in BUF. */ ++ if (buflen < 1) ++ { ++ fp = next_file (fp); ++ ++ if (fp == NULL) ++ break; /* No more files. */ ++ else ++ { ++ memset (&i_state, '\0', sizeof(mbstate_t)); ++ continue; ++ } ++ } ++ ++ /* Get a wide character. */ ++ i_state_bak = i_state; ++ mblength = mbrtowc (&wc, bufpos, buflen, &i_state); ++ ++ switch (mblength) ++ { ++ case (size_t)-1: /* illegal byte sequence. */ ++ case (size_t)-2: ++ mblength = 1; ++ i_state = i_state_bak; ++ if (convert) ++ { ++ ++column; ++ if (convert_entire_line == 0) ++ convert = 0; ++ } ++ putchar (*bufpos); ++ break; ++ ++ case 0: /* null. */ ++ mblength = 1; ++ if (convert && convert_entire_line == 0) ++ convert = 0; ++ putchar ('\0'); ++ break; ++ ++ default: ++ if (wc == L'\n') /* LF. */ ++ { ++ tab_index = 0; ++ column = 0; ++ convert = 1; ++ putchar ('\n'); ++ } ++ else if (wc == L'\t' && convert) /* Tab. */ ++ { ++ if (tab_size == 0) ++ { ++ /* Do not let tab_index == first_free_tab; ++ stop when it is 1 less. */ ++ while (tab_index < first_free_tab - 1 ++ && column >= tab_list[tab_index]) ++ tab_index++; ++ next_tab_column = tab_list[tab_index]; ++ if (tab_index < first_free_tab - 1) ++ tab_index++; ++ if (column >= next_tab_column) ++ next_tab_column = column + 1; ++ } ++ else ++ next_tab_column = column + tab_size - column % tab_size; ++ ++ while (column < next_tab_column) ++ { ++ putchar (' '); ++ ++column; ++ } ++ } ++ else /* Others. */ ++ { ++ if (convert) ++ { ++ if (wc == L'\b') ++ { ++ if (column > 0) ++ --column; ++ } ++ else ++ { ++ int width; /* The width of WC. */ ++ ++ width = wcwidth (wc); ++ column += (width > 0) ? width : 0; ++ if (convert_entire_line == 0) ++ convert = 0; ++ } ++ } ++ fwrite (bufpos, sizeof(char), mblength, stdout); ++ } ++ } ++ buflen -= mblength; ++ bufpos += mblength; ++ } ++} ++#endif ++ + int + main (int argc, char **argv) + { +@@ -428,7 +582,12 @@ + + file_list = (optind < argc ? &argv[optind] : stdin_argv); + +- expand (); ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ expand_multibyte (); ++ else ++#endif ++ expand (); + + if (have_read_stdin && fclose (stdin) != 0) + error (EXIT_FAILURE, errno, "-"); +--- coreutils-5.93/src/fold.c.i18n 2005-08-12 08:29:38.000000000 +0100 ++++ coreutils-5.93/src/fold.c 2005-12-23 08:53:01.000000000 +0000 +@@ -23,11 +23,33 @@ + #include + #include + ++/* Get mbstate_t, mbrtowc(), wcwidth(). */ ++#if HAVE_WCHAR_H ++# include ++#endif ++ ++/* Get iswprint(), iswblank(), wcwidth(). */ ++#if HAVE_WCTYPE_H ++# include ++#endif ++ + #include "system.h" + #include "error.h" + #include "quote.h" + #include "xstrtol.h" + ++/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC ++ installation; work around this configuration error. */ ++#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 ++# undef MB_LEN_MAX ++# define MB_LEN_MAX 16 ++#endif ++ ++/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ ++#if HAVE_MBRTOWC && defined mbstate_t ++# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) ++#endif ++ + #define TAB_WIDTH 8 + + /* The official name of this program (e.g., no `g' prefix). */ +@@ -35,23 +57,44 @@ + + #define AUTHORS "David MacKenzie" + ++#define FATAL_ERROR(Message) \ ++ do \ ++ { \ ++ error (0, 0, (Message)); \ ++ usage (2); \ ++ } \ ++ while (0) ++ ++enum operating_mode ++{ ++ /* Fold texts by columns that are at the given positions. */ ++ column_mode, ++ ++ /* Fold texts by bytes that are at the given positions. */ ++ byte_mode, ++ ++ /* Fold texts by characters that are at the given positions. */ ++ character_mode, ++}; ++ + /* The name this program was run with. */ + char *program_name; + ++/* The argument shows current mode. (Default: column_mode) */ ++static enum operating_mode operating_mode; ++ + /* If nonzero, try to break on whitespace. */ + static bool break_spaces; + +-/* If nonzero, count bytes, not column positions. */ +-static bool count_bytes; +- + /* If nonzero, at least one of the files we read was standard input. */ + static bool have_read_stdin; + +-static char const shortopts[] = "bsw:0::1::2::3::4::5::6::7::8::9::"; ++static char const shortopts[] = "bcsw:0::1::2::3::4::5::6::7::8::9::"; + + static struct option const longopts[] = + { + {"bytes", no_argument, NULL, 'b'}, ++ {"characters", no_argument, NULL, 'c'}, + {"spaces", no_argument, NULL, 's'}, + {"width", required_argument, NULL, 'w'}, + {GETOPT_HELP_OPTION_DECL}, +@@ -81,6 +124,7 @@ + "), stdout); + fputs (_("\ + -b, --bytes count bytes rather than columns\n\ ++ -c, --characters count characters rather than columns\n\ + -s, --spaces break at spaces\n\ + -w, --width=WIDTH use WIDTH columns instead of 80\n\ + "), stdout); +@@ -98,7 +142,7 @@ + static size_t + adjust_column (size_t column, char c) + { +- if (!count_bytes) ++ if (operating_mode != byte_mode) + { + if (c == '\b') + { +@@ -117,35 +161,14 @@ + return column; + } + +-/* Fold file FILENAME, or standard input if FILENAME is "-", +- to stdout, with maximum line length WIDTH. +- Return true if successful. */ +- +-static bool +-fold_file (char *filename, size_t width) ++static void ++fold_text (FILE *istream, size_t width, int *saved_errno) + { +- FILE *istream; + int c; + size_t column = 0; /* Screen column where next char will go. */ + size_t offset_out = 0; /* Index in `line_out' for next char. */ + static char *line_out = NULL; + static size_t allocated_out = 0; +- int saved_errno; +- +- if (STREQ (filename, "-")) +- { +- istream = stdin; +- have_read_stdin = true; +- } +- else +- istream = fopen (filename, "r"); +- +- if (istream == NULL) +- { +- error (0, errno, "%s", filename); +- return false; +- } +- + while ((c = getc (istream)) != EOF) + { + if (offset_out + 1 >= allocated_out) +@@ -172,6 +195,15 @@ + bool found_blank = false; + size_t logical_end = offset_out; + ++ /* If LINE_OUT has no wide character, ++ put a new wide character in LINE_OUT ++ if column is bigger than width. */ ++ if (offset_out == 0) ++ { ++ line_out[offset_out++] = c; ++ continue; ++ } ++ + /* Look for the last blank. */ + while (logical_end) + { +@@ -218,11 +250,225 @@ + line_out[offset_out++] = c; + } + +- saved_errno = errno; ++ *saved_errno = errno; ++ ++ if (offset_out) ++ fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); ++ ++ free(line_out); ++} ++ ++#if HAVE_MBRTOWC ++static void ++fold_multibyte_text (FILE *istream, int width, int *saved_errno) ++{ ++ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ ++ size_t buflen = 0; /* The length of the byte sequence in buf. */ ++ char *bufpos; /* Next read position of BUF. */ ++ wint_t wc; /* A gotten wide character. */ ++ size_t mblength; /* The byte size of a multibyte character which shows ++ as same character as WC. */ ++ mbstate_t state, state_bak; /* State of the stream. */ ++ int convfail; /* 1, when conversion is failed. Otherwise 0. */ ++ ++ char *line_out = NULL; ++ size_t offset_out = 0; /* Index in `line_out' for next char. */ ++ size_t allocated_out = 0; ++ ++ int increment; ++ size_t column = 0; ++ ++ size_t last_blank_pos; ++ size_t last_blank_column; ++ int is_blank_seen; ++ int last_blank_increment; ++ int is_bs_following_last_blank; ++ size_t bs_following_last_blank_num; ++ int is_cr_after_last_blank; ++ ++#define CLEAR_FLAGS \ ++ do \ ++ { \ ++ last_blank_pos = 0; \ ++ last_blank_column = 0; \ ++ is_blank_seen = 0; \ ++ is_bs_following_last_blank = 0; \ ++ bs_following_last_blank_num = 0; \ ++ is_cr_after_last_blank = 0; \ ++ } \ ++ while (0) ++ ++#define START_NEW_LINE \ ++ do \ ++ { \ ++ putchar ('\n'); \ ++ column = 0; \ ++ offset_out = 0; \ ++ CLEAR_FLAGS; \ ++ } \ ++ while (0) ++ ++ CLEAR_FLAGS; ++ memset (&state, '\0', sizeof(mbstate_t)); ++ ++ for (;; bufpos += mblength, buflen -= mblength) ++ { ++ if (buflen < MB_LEN_MAX && !feof (istream) && !ferror (istream)) ++ { ++ memmove (buf, bufpos, buflen); ++ buflen += fread (buf + buflen, sizeof(char), BUFSIZ, istream); ++ bufpos = buf; ++ } ++ ++ if (buflen < 1) ++ break; ++ ++ /* Get a wide character. */ ++ convfail = 0; ++ state_bak = state; ++ mblength = mbrtowc ((wchar_t *)&wc, bufpos, buflen, &state); ++ ++ switch (mblength) ++ { ++ case (size_t)-1: ++ case (size_t)-2: ++ convfail++; ++ state = state_bak; ++ /* Fall through. */ ++ ++ case 0: ++ mblength = 1; ++ break; ++ } ++ ++rescan: ++ if (operating_mode == byte_mode) /* byte mode */ ++ increment = mblength; ++ else if (operating_mode == character_mode) /* character mode */ ++ increment = 1; ++ else /* column mode */ ++ { ++ if (convfail) ++ increment = 1; ++ else ++ { ++ switch (wc) ++ { ++ case L'\n': ++ fwrite (line_out, sizeof(char), offset_out, stdout); ++ START_NEW_LINE; ++ continue; ++ ++ case L'\b': ++ increment = (column > 0) ? -1 : 0; ++ break; ++ ++ case L'\r': ++ increment = -1 * column; ++ break; ++ ++ case L'\t': ++ increment = 8 - column % 8; ++ break; ++ ++ default: ++ increment = wcwidth (wc); ++ increment = (increment < 0) ? 0 : increment; ++ } ++ } ++ } ++ ++ if (column + increment > width && break_spaces && last_blank_pos) ++ { ++ fwrite (line_out, sizeof(char), last_blank_pos, stdout); ++ putchar ('\n'); ++ ++ offset_out = offset_out - last_blank_pos; ++ column = column - last_blank_column + ((is_cr_after_last_blank) ++ ? last_blank_increment : bs_following_last_blank_num); ++ memmove (line_out, line_out + last_blank_pos, offset_out); ++ CLEAR_FLAGS; ++ goto rescan; ++ } ++ ++ if (column + increment > width && column != 0) ++ { ++ fwrite (line_out, sizeof(char), offset_out, stdout); ++ START_NEW_LINE; ++ goto rescan; ++ } ++ ++ if (allocated_out < offset_out + mblength) ++ { ++ allocated_out += 1024; ++ line_out = xrealloc (line_out, allocated_out); ++ } ++ ++ memcpy (line_out + offset_out, bufpos, mblength); ++ offset_out += mblength; ++ column += increment; ++ ++ if (is_blank_seen && !convfail && wc == L'\r') ++ is_cr_after_last_blank = 1; ++ ++ if (is_bs_following_last_blank && !convfail && wc == L'\b') ++ ++bs_following_last_blank_num; ++ else ++ is_bs_following_last_blank = 0; ++ ++ if (break_spaces && !convfail && iswblank (wc)) ++ { ++ last_blank_pos = offset_out; ++ last_blank_column = column; ++ is_blank_seen = 1; ++ last_blank_increment = increment; ++ is_bs_following_last_blank = 1; ++ bs_following_last_blank_num = 0; ++ is_cr_after_last_blank = 0; ++ } ++ } ++ ++ *saved_errno = errno; + + if (offset_out) + fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); + ++ free(line_out); ++} ++#endif ++ ++/* Fold file FILENAME, or standard input if FILENAME is "-", ++ to stdout, with maximum line length WIDTH. ++ Return 0 if successful, 1 if an error occurs. */ ++ ++static int ++fold_file (char *filename, int width) ++{ ++ FILE *istream; ++ int saved_errno; ++ ++ if (STREQ (filename, "-")) ++ { ++ istream = stdin; ++ have_read_stdin = 1; ++ } ++ else ++ istream = fopen (filename, "r"); ++ ++ if (istream == NULL) ++ { ++ error (0, errno, "%s", filename); ++ return 1; ++ } ++ ++ /* Define how ISTREAM is being folded. */ ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ fold_multibyte_text (istream, width, &saved_errno); ++ else ++#endif ++ fold_text (istream, width, &saved_errno); ++ + if (ferror (istream)) + { + error (0, saved_errno, "%s", filename); +@@ -255,7 +501,8 @@ + + atexit (close_stdout); + +- break_spaces = count_bytes = have_read_stdin = false; ++ operating_mode = column_mode; ++ break_spaces = have_read_stdin = false; + + while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1) + { +@@ -264,7 +511,15 @@ + switch (optc) + { + case 'b': /* Count bytes rather than columns. */ +- count_bytes = true; ++ if (operating_mode != column_mode) ++ FATAL_ERROR (_("only one way of folding may be specified")); ++ operating_mode = byte_mode; ++ break; ++ ++ case 'c': ++ if (operating_mode != column_mode) ++ FATAL_ERROR (_("only one way of folding may be specified")); ++ operating_mode = character_mode; + break; + + case 's': /* Break at word boundaries. */ +--- coreutils-5.93/src/join.c.i18n 2005-08-12 08:16:25.000000000 +0100 ++++ coreutils-5.93/src/join.c 2005-12-23 08:53:01.000000000 +0000 +@@ -23,16 +23,30 @@ + #include + #include + ++/* Get mbstate_t, mbrtowc(), mbrtowc(), wcwidth(). */ ++#if HAVE_WCHAR_H ++# include ++#endif ++ ++/* Get iswblank(), towupper. */ ++#if HAVE_WCTYPE_H ++# include ++#endif ++ + #include "system.h" + #include "error.h" + #include "hard-locale.h" + #include "linebuffer.h" +-#include "memcasecmp.h" + #include "quote.h" + #include "stdio--.h" + #include "xmemcoll.h" + #include "xstrtol.h" + ++/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ ++#if HAVE_MBRTOWC && defined mbstate_t ++# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) ++#endif ++ + /* The official name of this program (e.g., no `g' prefix). */ + #define PROGRAM_NAME "join" + +@@ -104,10 +118,12 @@ + /* Last element in `outlist', where a new element can be added. */ + static struct outlist *outlist_end = &outlist_head; + +-/* Tab character separating fields. If negative, fields are separated +- by any nonempty string of blanks, otherwise by exactly one +- tab character whose value (when cast to unsigned char) equals TAB. */ +-static int tab = -1; ++/* Tab character separating fields. If NULL, fields are separated ++ by any nonempty string of blanks. */ ++static char *tab = NULL; ++ ++/* The number of bytes used for tab. */ ++static size_t tablen = 0; + + static struct option const longopts[] = + { +@@ -197,6 +213,8 @@ + + /* Fill in the `fields' structure in LINE. */ + ++/* Fill in the `fields' structure in LINE. */ ++ + static void + xfields (struct line *line) + { +@@ -206,10 +224,11 @@ + if (ptr == lim) + return; + +- if (0 <= tab) ++ if (tab != NULL) + { ++ unsigned char t = tab[0]; + char *sep; +- for (; (sep = memchr (ptr, tab, lim - ptr)) != NULL; ptr = sep + 1) ++ for (; (sep = memchr (ptr, t, lim - ptr)) != NULL; ptr = sep + 1) + extract_field (line, ptr, sep - ptr); + } + else +@@ -236,6 +255,148 @@ + extract_field (line, ptr, lim - ptr); + } + ++#if HAVE_MBRTOWC ++static void ++xfields_multibyte (struct line *line) ++{ ++ char *ptr = line->buf.buffer; ++ char const *lim = ptr + line->buf.length - 1; ++ wchar_t wc = 0; ++ size_t mblength = 1; ++ mbstate_t state, state_bak; ++ ++ memset (&state, 0, sizeof (mbstate_t)); ++ ++ if (ptr == lim) ++ return; ++ ++ if (tab != NULL) ++ { ++ unsigned char t = tab[0]; ++ char *sep = ptr; ++ for (; ptr < lim; ptr = sep + mblength) ++ { ++ sep = ptr; ++ while (sep < lim) ++ { ++ state_bak = state; ++ mblength = mbrtowc (&wc, sep, lim - sep + 1, &state); ++ ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ mblength = 1; ++ state = state_bak; ++ } ++ mblength = (mblength < 1) ? 1 : mblength; ++ ++ if (mblength == tablen && !memcmp (sep, tab, mblength)) ++ break; ++ else ++ { ++ sep += mblength; ++ continue; ++ } ++ } ++ ++ if (sep == lim) ++ break; ++ ++ extract_field (line, ptr, sep - ptr); ++ } ++ } ++ else ++ { ++ /* Skip leading blanks before the first field. */ ++ while(ptr < lim) ++ { ++ state_bak = state; ++ mblength = mbrtowc (&wc, ptr, lim - ptr + 1, &state); ++ ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ mblength = 1; ++ state = state_bak; ++ break; ++ } ++ mblength = (mblength < 1) ? 1 : mblength; ++ ++ if (!iswblank(wc)) ++ break; ++ ptr += mblength; ++ } ++ ++ do ++ { ++ char *sep; ++ state_bak = state; ++ mblength = mbrtowc (&wc, ptr, lim - ptr + 1, &state); ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ mblength = 1; ++ state = state_bak; ++ break; ++ } ++ mblength = (mblength < 1) ? 1 : mblength; ++ ++ sep = ptr + mblength; ++ while (sep != lim) ++ { ++ state_bak = state; ++ mblength = mbrtowc (&wc, sep, lim - sep + 1, &state); ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ mblength = 1; ++ state = state_bak; ++ break; ++ } ++ mblength = (mblength < 1) ? 1 : mblength; ++ ++ if (iswblank (wc)) ++ break; ++ ++ sep += mblength; ++ } ++ ++ extract_field (line, ptr, sep - ptr); ++ if (sep == lim) ++ return; ++ ++ state_bak = state; ++ mblength = mbrtowc (&wc, sep, lim - sep + 1, &state); ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ mblength = 1; ++ state = state_bak; ++ break; ++ } ++ mblength = (mblength < 1) ? 1 : mblength; ++ ++ ptr = sep + mblength; ++ while (ptr != lim) ++ { ++ state_bak = state; ++ mblength = mbrtowc (&wc, ptr, lim - ptr + 1, &state); ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ mblength = 1; ++ state = state_bak; ++ break; ++ } ++ mblength = (mblength < 1) ? 1 : mblength; ++ ++ if (!iswblank (wc)) ++ break; ++ ++ ptr += mblength; ++ } ++ } ++ while (ptr != lim); ++ } ++ ++ extract_field (line, ptr, lim - ptr); ++} ++#endif ++ + /* Read a line from FP into LINE and split it into fields. + Return true if successful. */ + +@@ -256,6 +417,11 @@ + line->nfields_allocated = 0; + line->nfields = 0; + line->fields = NULL; ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ xfields_multibyte (line); ++ else ++#endif + xfields (line); + return true; + } +@@ -310,56 +476,114 @@ + keycmp (struct line const *line1, struct line const *line2) + { + /* Start of field to compare in each file. */ +- char *beg1; +- char *beg2; +- +- size_t len1; +- size_t len2; /* Length of fields to compare. */ ++ char *beg[2]; ++ char *copy[2]; ++ size_t len[2]; /* Length of fields to compare. */ + int diff; ++ int i, j; + + if (join_field_1 < line1->nfields) + { +- beg1 = line1->fields[join_field_1].beg; +- len1 = line1->fields[join_field_1].len; ++ beg[0] = line1->fields[join_field_1].beg; ++ len[0] = line1->fields[join_field_1].len; + } + else + { +- beg1 = NULL; +- len1 = 0; ++ beg[0] = NULL; ++ len[0] = 0; + } + + if (join_field_2 < line2->nfields) + { +- beg2 = line2->fields[join_field_2].beg; +- len2 = line2->fields[join_field_2].len; ++ beg[1] = line2->fields[join_field_2].beg; ++ len[1] = line2->fields[join_field_2].len; + } + else + { +- beg2 = NULL; +- len2 = 0; ++ beg[1] = NULL; ++ len[1] = 0; + } + +- if (len1 == 0) +- return len2 == 0 ? 0 : -1; +- if (len2 == 0) ++ if (len[0] == 0) ++ return len[1] == 0 ? 0 : -1; ++ if (len[1] == 0) + return 1; + + if (ignore_case) + { +- /* FIXME: ignore_case does not work with NLS (in particular, +- with multibyte chars). */ +- diff = memcasecmp (beg1, beg2, MIN (len1, len2)); ++#ifdef HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ size_t mblength; ++ wchar_t wc, uwc; ++ mbstate_t state, state_bak; ++ ++ memset (&state, '\0', sizeof (mbstate_t)); ++ ++ for (i = 0; i < 2; i++) ++ { ++ copy[i] = alloca (len[i] + 1); ++ ++ for (j = 0; j < MIN (len[0], len[1]);) ++ { ++ state_bak = state; ++ mblength = mbrtowc (&wc, beg[i] + j, len[i] - j, &state); ++ ++ switch (mblength) ++ { ++ case (size_t) -1: ++ case (size_t) -2: ++ state = state_bak; ++ /* Fall through */ ++ case 0: ++ mblength = 1; ++ break; ++ ++ default: ++ uwc = towupper (wc); ++ ++ if (uwc != wc) ++ { ++ mbstate_t state_wc; ++ ++ memset (&state_wc, '\0', sizeof (mbstate_t)); ++ wcrtomb (copy[i] + j, uwc, &state_wc); ++ } ++ else ++ memcpy (copy[i] + j, beg[i] + j, mblength); ++ } ++ j += mblength; ++ } ++ copy[i][j] = '\0'; ++ } ++ } ++ else ++#endif ++ { ++ for (i = 0; i < 2; i++) ++ { ++ copy[i] = alloca (len[i] + 1); ++ ++ for (j = 0; j < MIN (len[0], len[1]); j++) ++ copy[i][j] = toupper (beg[i][j]); ++ ++ copy[i][j] = '\0'; ++ } ++ } + } + else + { +- if (hard_LC_COLLATE) +- return xmemcoll (beg1, len1, beg2, len2); +- diff = memcmp (beg1, beg2, MIN (len1, len2)); ++ copy[0] = (unsigned char *) beg[0]; ++ copy[1] = (unsigned char *) beg[1]; + } + ++ if (HAVE_SETLOCALE && hard_LC_COLLATE) ++ return xmemcoll ((char *) copy[0], len[0], (char *) copy[1], len[1]); ++ diff = memcmp (copy[0], copy[1], MIN (len[0], len[1])); ++ + if (diff) + return diff; +- return len1 < len2 ? -1 : len1 != len2; ++ return len[0] - len[1]; + } + + /* Print field N of LINE if it exists and is nonempty, otherwise +@@ -384,11 +608,18 @@ + + /* Print the join of LINE1 and LINE2. */ + ++#define PUT_TAB_CHAR \ ++ do \ ++ { \ ++ (tab != NULL) ? \ ++ fwrite(tab, sizeof(char), tablen, stdout) : putchar (' '); \ ++ } \ ++ while (0) ++ + static void + prjoin (struct line const *line1, struct line const *line2) + { + const struct outlist *outlist; +- char output_separator = tab < 0 ? ' ' : tab; + + outlist = outlist_head.next; + if (outlist) +@@ -404,12 +635,12 @@ + if (o->file == 0) + { + if (line1 == &uni_blank) +- { ++ { + line = line2; + field = join_field_2; + } + else +- { ++ { + line = line1; + field = join_field_1; + } +@@ -423,7 +654,7 @@ + o = o->next; + if (o == NULL) + break; +- putchar (output_separator); ++ PUT_TAB_CHAR; + } + putchar ('\n'); + } +@@ -441,23 +672,23 @@ + prfield (join_field_1, line1); + for (i = 0; i < join_field_1 && i < line1->nfields; ++i) + { +- putchar (output_separator); ++ PUT_TAB_CHAR; + prfield (i, line1); + } + for (i = join_field_1 + 1; i < line1->nfields; ++i) + { +- putchar (output_separator); ++ PUT_TAB_CHAR; + prfield (i, line1); + } + + for (i = 0; i < join_field_2 && i < line2->nfields; ++i) + { +- putchar (output_separator); ++ PUT_TAB_CHAR; + prfield (i, line2); + } + for (i = join_field_2 + 1; i < line2->nfields; ++i) + { +- putchar (output_separator); ++ PUT_TAB_CHAR; + prfield (i, line2); + } + putchar ('\n'); +@@ -869,20 +1100,41 @@ + + case 't': + { +- unsigned char newtab = optarg[0]; +- if (! newtab) ++ char *newtab; ++ size_t newtablen; ++ if (! optarg[0]) + error (EXIT_FAILURE, 0, _("empty tab")); +- if (optarg[1]) ++ newtab = xstrdup (optarg); ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ mbstate_t state; ++ ++ memset (&state, 0, sizeof (mbstate_t)); ++ newtablen = mbrtowc (NULL, newtab, ++ strnlen (newtab, MB_LEN_MAX), ++ &state); ++ if (newtablen == (size_t) 0 ++ || newtablen == (size_t) -1 ++ || newtablen == (size_t) -2) ++ newtablen = 1; ++ } ++ else ++#endif ++ newtablen = 1; ++ ++ if (newtablen == 1 && newtab[1]) ++ { ++ if (STREQ (newtab, "\\0")) ++ newtab[0] = '\0'; ++ } ++ if (tab != NULL && strcmp (tab, newtab)) + { +- if (STREQ (optarg, "\\0")) +- newtab = '\0'; +- else +- error (EXIT_FAILURE, 0, _("multi-character tab %s"), +- quote (optarg)); ++ free (newtab); ++ error (EXIT_FAILURE, 0, _("incompatible tabs")); + } +- if (0 <= tab && tab != newtab) +- error (EXIT_FAILURE, 0, _("incompatible tabs")); + tab = newtab; ++ tablen = newtablen; + } + break; + +--- coreutils-5.93/src/unexpand.c.i18n 2005-08-12 08:16:25.000000000 +0100 ++++ coreutils-5.93/src/unexpand.c 2005-12-23 08:53:01.000000000 +0000 +@@ -39,11 +39,28 @@ + #include + #include + #include ++ ++/* Get mbstate_t, mbrtowc(), wcwidth(). */ ++#if HAVE_WCHAR_H ++# include ++#endif ++ + #include "system.h" + #include "error.h" + #include "quote.h" + #include "xstrndup.h" + ++/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC ++ installation; work around this configuration error. */ ++#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 ++# define MB_LEN_MAX 16 ++#endif ++ ++/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ ++#if HAVE_MBRTOWC && defined mbstate_t ++# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) ++#endif ++ + /* The official name of this program (e.g., no `g' prefix). */ + #define PROGRAM_NAME "unexpand" + +@@ -110,6 +127,208 @@ + {NULL, 0, NULL, 0} + }; + ++static FILE *next_file (FILE *fp); ++ ++#if HAVE_MBRTOWC ++static void ++unexpand_multibyte (void) ++{ ++ FILE *fp; /* Input stream. */ ++ mbstate_t i_state; /* Current shift state of the input stream. */ ++ mbstate_t i_state_bak; /* Back up the I_STATE. */ ++ mbstate_t o_state; /* Current shift state of the output stream. */ ++ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ ++ char *bufpos; /* Next read position of BUF. */ ++ size_t buflen = 0; /* The length of the byte sequence in buf. */ ++ wint_t wc; /* A gotten wide character. */ ++ size_t mblength; /* The byte size of a multibyte character ++ which shows as same character as WC. */ ++ ++ /* Index in `tab_list' of next tabstop: */ ++ int tab_index = 0; /* For calculating width of pending tabs. */ ++ int print_tab_index = 0; /* For printing as many tabs as possible. */ ++ unsigned int column = 0; /* Column on screen of next char. */ ++ int next_tab_column; /* Column the next tab stop is on. */ ++ int convert = 1; /* If nonzero, perform translations. */ ++ unsigned int pending = 0; /* Pending columns of blanks. */ ++ ++ fp = next_file ((FILE *) NULL); ++ if (fp == NULL) ++ return; ++ ++ memset (&o_state, '\0', sizeof(mbstate_t)); ++ memset (&i_state, '\0', sizeof(mbstate_t)); ++ ++ for (;;) ++ { ++ if (buflen < MB_LEN_MAX && !feof(fp) && !ferror(fp)) ++ { ++ memmove (buf, bufpos, buflen); ++ buflen += fread (buf + buflen, sizeof(char), BUFSIZ, fp); ++ bufpos = buf; ++ } ++ ++ /* Get a wide character. */ ++ if (buflen < 1) ++ { ++ mblength = 1; ++ wc = WEOF; ++ } ++ else ++ { ++ i_state_bak = i_state; ++ mblength = mbrtowc ((wchar_t *)&wc, bufpos, buflen, &i_state); ++ } ++ ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ i_state = i_state_bak; ++ wc = L'\0'; ++ } ++ ++ if (wc == L' ' && convert && column < INT_MAX) ++ { ++ ++pending; ++ ++column; ++ } ++ else if (wc == L'\t' && convert) ++ { ++ if (tab_size == 0) ++ { ++ /* Do not let tab_index == first_free_tab; ++ stop when it is 1 less. */ ++ while (tab_index < first_free_tab - 1 ++ && column >= tab_list[tab_index]) ++ tab_index++; ++ next_tab_column = tab_list[tab_index]; ++ if (tab_index < first_free_tab - 1) ++ tab_index++; ++ if (column >= next_tab_column) ++ { ++ convert = 0; /* Ran out of tab stops. */ ++ goto flush_pend_mb; ++ } ++ } ++ else ++ { ++ next_tab_column = column + tab_size - column % tab_size; ++ } ++ pending += next_tab_column - column; ++ column = next_tab_column; ++ } ++ else ++ { ++flush_pend_mb: ++ /* Flush pending spaces. Print as many tabs as possible, ++ then print the rest as spaces. */ ++ if (pending == 1) ++ { ++ putchar (' '); ++ pending = 0; ++ } ++ column -= pending; ++ while (pending > 0) ++ { ++ if (tab_size == 0) ++ { ++ /* Do not let print_tab_index == first_free_tab; ++ stop when it is 1 less. */ ++ while (print_tab_index < first_free_tab - 1 ++ && column >= tab_list[print_tab_index]) ++ print_tab_index++; ++ next_tab_column = tab_list[print_tab_index]; ++ if (print_tab_index < first_free_tab - 1) ++ print_tab_index++; ++ } ++ else ++ { ++ next_tab_column = ++ column + tab_size - column % tab_size; ++ } ++ if (next_tab_column - column <= pending) ++ { ++ putchar ('\t'); ++ pending -= next_tab_column - column; ++ column = next_tab_column; ++ } ++ else ++ { ++ --print_tab_index; ++ column += pending; ++ while (pending != 0) ++ { ++ putchar (' '); ++ pending--; ++ } ++ } ++ } ++ ++ if (wc == WEOF) ++ { ++ fp = next_file (fp); ++ if (fp == NULL) ++ break; /* No more files. */ ++ else ++ { ++ memset (&i_state, '\0', sizeof(mbstate_t)); ++ continue; ++ } ++ } ++ ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ if (convert) ++ { ++ ++column; ++ if (convert_entire_line == 0) ++ convert = 0; ++ } ++ mblength = 1; ++ putchar (buf[0]); ++ } ++ else if (mblength == 0) ++ { ++ if (convert && convert_entire_line == 0) ++ convert = 0; ++ mblength = 1; ++ putchar ('\0'); ++ } ++ else ++ { ++ if (convert) ++ { ++ if (wc == L'\b') ++ { ++ if (column > 0) ++ --column; ++ } ++ else ++ { ++ int width; /* The width of WC. */ ++ ++ width = wcwidth (wc); ++ column += (width > 0) ? width : 0; ++ if (convert_entire_line == 0) ++ convert = 0; ++ } ++ } ++ ++ if (wc == L'\n') ++ { ++ tab_index = print_tab_index = 0; ++ column = pending = 0; ++ convert = 1; ++ } ++ fwrite (bufpos, sizeof(char), mblength, stdout); ++ } ++ } ++ buflen -= mblength; ++ bufpos += mblength; ++ } ++} ++#endif ++ ++ + void + usage (int status) + { +@@ -532,7 +751,12 @@ + + file_list = (optind < argc ? &argv[optind] : stdin_argv); + +- unexpand (); ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ unexpand_multibyte (); ++ else ++#endif ++ unexpand (); + + if (have_read_stdin && fclose (stdin) != 0) + error (EXIT_FAILURE, errno, "-"); +--- coreutils-5.93/src/sort.c.i18n 2005-10-07 19:48:28.000000000 +0100 ++++ coreutils-5.93/src/sort.c 2005-12-23 10:38:44.000000000 +0000 +@@ -23,9 +23,18 @@ + + #include + ++#include + #include + #include + #include ++#if HAVE_WCHAR_H ++# include ++#endif ++/* Get isw* functions. */ ++#if HAVE_WCTYPE_H ++# include ++#endif ++ + #include "system.h" + #include "error.h" + #include "hard-locale.h" +@@ -95,14 +104,38 @@ + /* Thousands separator; if -1, then there isn't one. */ + static int thousands_sep; + ++static int force_general_numcompare = 0; ++ + /* Nonzero if the corresponding locales are hard. */ + static bool hard_LC_COLLATE; +-#if HAVE_NL_LANGINFO ++#if HAVE_LANGINFO_CODESET + static bool hard_LC_TIME; + #endif + + #define NONZERO(x) ((x) != 0) + ++/* get a multibyte character's byte length. */ ++#define GET_BYTELEN_OF_CHAR(LIM, PTR, MBLENGTH, STATE) \ ++ do \ ++ { \ ++ wchar_t wc; \ ++ mbstate_t state_bak; \ ++ \ ++ state_bak = STATE; \ ++ mblength = mbrtowc (&wc, PTR, LIM - PTR, &STATE); \ ++ \ ++ switch (MBLENGTH) \ ++ { \ ++ case (size_t)-1: \ ++ case (size_t)-2: \ ++ STATE = state_bak; \ ++ /* Fall through. */ \ ++ case 0: \ ++ MBLENGTH = 1; \ ++ } \ ++ } \ ++ while (0) ++ + /* The kind of blanks for '-b' to skip in various options. */ + enum blanktype { bl_start, bl_end, bl_both }; + +@@ -239,13 +272,11 @@ + they were read if all keys compare equal. */ + static bool stable; + +-/* If TAB has this value, blanks separate fields. */ +-enum { TAB_DEFAULT = CHAR_MAX + 1 }; +- +-/* Tab character separating fields. If TAB_DEFAULT, then fields are ++/* Tab character separating fields. If tab_length is 0, then fields are + separated by the empty string between a non-blank character and a blank + character. */ +-static int tab = TAB_DEFAULT; ++static char tab[MB_LEN_MAX + 1]; ++static size_t tab_length = 0; + + /* Flag to remove consecutive duplicate lines from the output. + Only the last of a sequence of equal lines will be output. */ +@@ -392,6 +423,44 @@ + static struct tempnode *volatile temphead; + static struct tempnode *volatile *temptail = &temphead; + ++/* Function pointers. */ ++static void ++(*inittables) (void); ++static char * ++(*begfield) (const struct line*, const struct keyfield *); ++static char * ++(*limfield) (const struct line*, const struct keyfield *); ++static int ++(*getmonth) (char const *, size_t); ++static int ++(*keycompare) (const struct line *, const struct line *); ++static int ++(*numcompare) (const char *, const char *); ++ ++/* Test for white space multibyte character. ++ Set LENGTH the byte length of investigated multibyte character. */ ++#if HAVE_MBRTOWC ++static int ++ismbblank (const char *str, size_t len, size_t *length) ++{ ++ size_t mblength; ++ wchar_t wc; ++ mbstate_t state; ++ ++ memset (&state, '\0', sizeof(mbstate_t)); ++ mblength = mbrtowc (&wc, str, len, &state); ++ ++ if (mblength == (size_t)-1 || mblength == (size_t)-2) ++ { ++ *length = 1; ++ return 0; ++ } ++ ++ *length = (mblength < 1) ? 1 : mblength; ++ return iswblank (wc); ++} ++#endif ++ + /* Clean up any remaining temporary files. */ + + static void +@@ -545,7 +614,7 @@ + free (node); + } + +-#if HAVE_NL_LANGINFO ++#if HAVE_LANGINFO_CODESET + + static int + struct_month_cmp (const void *m1, const void *m2) +@@ -560,7 +629,7 @@ + /* Initialize the character class tables. */ + + static void +-inittables (void) ++inittables_uni (void) + { + size_t i; + +@@ -572,7 +641,7 @@ + fold_toupper[i] = (ISLOWER (i) ? toupper (i) : i); + } + +-#if HAVE_NL_LANGINFO ++#if HAVE_LANGINFO_CODESET + /* If we're not in the "C" locale, read different names for months. */ + if (hard_LC_TIME) + { +@@ -598,6 +667,64 @@ + #endif + } + ++#if HAVE_MBRTOWC ++static void ++inittables_mb (void) ++{ ++ int i, j, k, l; ++ char *name, *s; ++ size_t s_len, mblength; ++ char mbc[MB_LEN_MAX]; ++ wchar_t wc, pwc; ++ mbstate_t state_mb, state_wc; ++ ++ for (i = 0; i < MONTHS_PER_YEAR; i++) ++ { ++ s = (char *) nl_langinfo (ABMON_1 + i); ++ s_len = strlen (s); ++ monthtab[i].name = name = (char *) xmalloc (s_len + 1); ++ monthtab[i].val = i + 1; ++ ++ memset (&state_mb, '\0', sizeof (mbstate_t)); ++ memset (&state_wc, '\0', sizeof (mbstate_t)); ++ ++ for (j = 0; j < s_len;) ++ { ++ if (!ismbblank (s + j, s_len - j, &mblength)) ++ break; ++ j += mblength; ++ } ++ ++ for (k = 0; j < s_len;) ++ { ++ mblength = mbrtowc (&wc, (s + j), (s_len - j), &state_mb); ++ assert (mblength != (size_t)-1 && mblength != (size_t)-2); ++ if (mblength == 0) ++ break; ++ ++ pwc = towupper (wc); ++ if (pwc == wc) ++ { ++ memcpy (mbc, s + j, mblength); ++ j += mblength; ++ } ++ else ++ { ++ j += mblength; ++ mblength = wcrtomb (mbc, pwc, &state_wc); ++ assert (mblength != (size_t)0 && mblength != (size_t)-1); ++ } ++ ++ for (l = 0; l < mblength; l++) ++ name[k++] = mbc[l]; ++ } ++ name[k] = '\0'; ++ } ++ qsort ((void *) monthtab, MONTHS_PER_YEAR, ++ sizeof (struct month), struct_month_cmp); ++} ++#endif ++ + /* Specify the amount of main memory to use when sorting. */ + static void + specify_sort_size (char const *s) +@@ -808,7 +935,7 @@ + by KEY in LINE. */ + + static char * +-begfield (const struct line *line, const struct keyfield *key) ++begfield_uni (const struct line *line, const struct keyfield *key) + { + char *ptr = line->text, *lim = ptr + line->length - 1; + size_t sword = key->sword; +@@ -818,10 +945,10 @@ + /* The leading field separator itself is included in a field when -t + is absent. */ + +- if (tab != TAB_DEFAULT) ++ if (tab_length) + while (ptr < lim && sword--) + { +- while (ptr < lim && *ptr != tab) ++ while (ptr < lim && *ptr != tab[0]) + ++ptr; + if (ptr < lim) + ++ptr; +@@ -849,11 +976,70 @@ + return ptr; + } + ++#if HAVE_MBRTOWC ++static char * ++begfield_mb (const struct line *line, const struct keyfield *key) ++{ ++ int i; ++ char *ptr = line->text, *lim = ptr + line->length - 1; ++ size_t sword = key->sword; ++ size_t schar = key->schar; ++ size_t mblength; ++ mbstate_t state; ++ ++ memset (&state, '\0', sizeof(mbstate_t)); ++ ++ if (tab_length) ++ while (ptr < lim && sword--) ++ { ++ while (ptr < lim && memcmp (ptr, tab, tab_length) != 0) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ptr += mblength; ++ } ++ if (ptr < lim) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ptr += mblength; ++ } ++ } ++ else ++ while (ptr < lim && sword--) ++ { ++ while (ptr < lim && ismbblank (ptr, lim - ptr, &mblength)) ++ ptr += mblength; ++ if (ptr < lim) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ptr += mblength; ++ } ++ while (ptr < lim && !ismbblank (ptr, lim - ptr, &mblength)) ++ ptr += mblength; ++ } ++ ++ if (key->skipsblanks) ++ while (ptr < lim && ismbblank (ptr, lim - ptr, &mblength)) ++ ptr += mblength; ++ ++ for (i = 0; i < schar; i++) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ++ if (ptr + mblength > lim) ++ break; ++ else ++ ptr += mblength; ++ } ++ ++ return ptr; ++} ++#endif ++ + /* Return the limit of (a pointer to the first character after) the field + in LINE specified by KEY. */ + + static char * +-limfield (const struct line *line, const struct keyfield *key) ++limfield_uni (const struct line *line, const struct keyfield *key) + { + char *ptr = line->text, *lim = ptr + line->length - 1; + size_t eword = key->eword, echar = key->echar; +@@ -866,10 +1052,10 @@ + `beginning' is the first character following the delimiting TAB. + Otherwise, leave PTR pointing at the first `blank' character after + the preceding field. */ +- if (tab != TAB_DEFAULT) ++ if (tab_length) + while (ptr < lim && eword--) + { +- while (ptr < lim && *ptr != tab) ++ while (ptr < lim && *ptr != tab[0]) + ++ptr; + if (ptr < lim && (eword | echar)) + ++ptr; +@@ -915,10 +1101,10 @@ + */ + + /* Make LIM point to the end of (one byte past) the current field. */ +- if (tab != TAB_DEFAULT) ++ if (tab_length) + { + char *newlim; +- newlim = memchr (ptr, tab, lim - ptr); ++ newlim = memchr (ptr, tab[0], lim - ptr); + if (newlim) + lim = newlim; + } +@@ -951,6 +1137,107 @@ + return ptr; + } + ++#if HAVE_MBRTOWC ++static char * ++limfield_mb (const struct line *line, const struct keyfield *key) ++{ ++ char *ptr = line->text, *lim = ptr + line->length - 1; ++ size_t eword = key->eword, echar = key->echar; ++ int i; ++ size_t mblength; ++ mbstate_t state; ++ ++ memset (&state, '\0', sizeof(mbstate_t)); ++ ++ if (tab_length) ++ while (ptr < lim && eword--) ++ { ++ while (ptr < lim && memcmp (ptr, tab, tab_length) != 0) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ptr += mblength; ++ } ++ if (ptr < lim && (eword | echar)) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ptr += mblength; ++ } ++ } ++ else ++ while (ptr < lim && eword--) ++ { ++ while (ptr < lim && ismbblank (ptr, lim - ptr, &mblength)) ++ ptr += mblength; ++ if (ptr < lim) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ptr += mblength; ++ } ++ while (ptr < lim && !ismbblank (ptr, lim - ptr, &mblength)) ++ ptr += mblength; ++ } ++ ++ ++# ifdef POSIX_UNSPECIFIED ++ /* Make LIM point to the end of (one byte past) the current field. */ ++ if (tab_length) ++ { ++ char *newlim, *p; ++ ++ newlim = NULL; ++ for (p = ptr; p < lim;) ++ { ++ if (memcmp (p, tab, tab_length) == 0) ++ { ++ newlim = p; ++ break; ++ } ++ ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ p += mblength; ++ } ++ } ++ else ++ { ++ char *newlim; ++ newlim = ptr; ++ ++ while (newlim < lim && ismbblank (newlim, lim - newlim, &mblength)) ++ newlim += mblength; ++ if (ptr < lim) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ptr += mblength; ++ } ++ while (newlim < lim && !ismbblank (newlim, lim - newlim, &mblength)) ++ newlim += mblength; ++ lim = newlim; ++ } ++# endif ++ ++ /* If we're skipping leading blanks, don't start counting characters ++ * until after skipping past any leading blanks. */ ++ if (key->skipsblanks) ++ while (ptr < lim && ismbblank (ptr, lim - ptr, &mblength)) ++ ptr += mblength; ++ ++ memset (&state, '\0', sizeof(mbstate_t)); ++ ++ /* Advance PTR by ECHAR (if possible), but no further than LIM. */ ++ for (i = 0; i < echar; i++) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ ++ if (ptr + mblength > lim) ++ break; ++ else ++ ptr += mblength; ++ } ++ ++ return ptr; ++} ++#endif ++ + /* Fill BUF reading from FP, moving buf->left bytes from the end + of buf->buf to the beginning first. If EOF is reached and the + file wasn't terminated by a newline, supply one. Set up BUF's line +@@ -1067,7 +1354,7 @@ + hideously fast. */ + + static int +-numcompare (const char *a, const char *b) ++numcompare_uni (const char *a, const char *b) + { + while (blanks[to_uchar (*a)]) + a++; +@@ -1077,6 +1364,25 @@ + return strnumcmp (a, b, decimal_point, thousands_sep); + } + ++#if HAVE_MBRTOWC ++static int ++numcompare_mb (const char *a, const char *b) ++{ ++ size_t mblength, len; ++ len = strlen (a); /* okay for UTF-8 */ ++ while (*a && ismbblank (a, len > MB_CUR_MAX ? MB_CUR_MAX : len, &mblength)) ++ { ++ a += mblength; ++ len -= mblength; ++ } ++ len = strlen (b); /* okay for UTF-8 */ ++ while (*b && ismbblank (b, len > MB_CUR_MAX ? MB_CUR_MAX : len, &mblength)) ++ b += mblength; ++ ++ return strnumcmp (a, b, decimal_point, thousands_sep); ++} ++#endif /* HAV_EMBRTOWC */ ++ + static int + general_numcompare (const char *sa, const char *sb) + { +@@ -1110,7 +1416,7 @@ + Return 0 if the name in S is not recognized. */ + + static int +-getmonth (char const *month, size_t len) ++getmonth_uni (char const *month, size_t len) + { + size_t lo = 0; + size_t hi = MONTHS_PER_YEAR; +@@ -1152,11 +1458,79 @@ + return 0; + } + ++#if HAVE_MBRTOWC ++static int ++getmonth_mb (const char *s, size_t len) ++{ ++ char *month; ++ register size_t i; ++ register int lo = 0, hi = MONTHS_PER_YEAR, result; ++ char *tmp; ++ size_t wclength, mblength; ++ const char **pp; ++ const wchar_t **wpp; ++ wchar_t *month_wcs; ++ mbstate_t state; ++ ++ while (len > 0 && ismbblank (s, len, &mblength)) ++ { ++ s += mblength; ++ len -= mblength; ++ } ++ ++ if (len == 0) ++ return 0; ++ ++ month = (char *) alloca (len + 1); ++ ++ tmp = (char *) alloca (len + 1); ++ memcpy (tmp, s, len); ++ tmp[len] = '\0'; ++ pp = (const char **)&tmp; ++ month_wcs = (wchar_t *) alloca ((len + 1) * sizeof (wchar_t)); ++ memset (&state, '\0', sizeof(mbstate_t)); ++ ++ wclength = mbsrtowcs (month_wcs, pp, len + 1, &state); ++ assert (wclength != (size_t)-1 && *pp == NULL); ++ ++ for (i = 0; i < wclength; i++) ++ { ++ month_wcs[i] = towupper(month_wcs[i]); ++ if (iswblank (month_wcs[i])) ++ { ++ month_wcs[i] = L'\0'; ++ break; ++ } ++ } ++ ++ wpp = (const wchar_t **)&month_wcs; ++ ++ mblength = wcsrtombs (month, wpp, len + 1, &state); ++ assert (mblength != (-1) && *wpp == NULL); ++ ++ do ++ { ++ int ix = (lo + hi) / 2; ++ ++ if (strncmp (month, monthtab[ix].name, strlen (monthtab[ix].name)) < 0) ++ hi = ix; ++ else ++ lo = ix; ++ } ++ while (hi - lo > 1); ++ ++ result = (!strncmp (month, monthtab[lo].name, strlen (monthtab[lo].name)) ++ ? monthtab[lo].val : 0); ++ ++ return result; ++} ++#endif ++ + /* Compare two lines A and B trying every key in sequence until there + are no more keys or a difference is found. */ + + static int +-keycompare (const struct line *a, const struct line *b) ++keycompare_uni (const struct line *a, const struct line *b) + { + struct keyfield const *key = keylist; + +@@ -1326,6 +1700,177 @@ + return key->reverse ? -diff : diff; + } + ++#if HAVE_MBRTOWC ++static int ++keycompare_mb (const struct line *a, const struct line *b) ++{ ++ struct keyfield *key = keylist; ++ ++ /* For the first iteration only, the key positions have been ++ precomputed for us. */ ++ char *texta = a->keybeg; ++ char *textb = b->keybeg; ++ char *lima = a->keylim; ++ char *limb = b->keylim; ++ ++ size_t mblength_a, mblength_b; ++ wchar_t wc_a, wc_b; ++ mbstate_t state_a, state_b; ++ ++ int diff; ++ ++ memset (&state_a, '\0', sizeof(mbstate_t)); ++ memset (&state_b, '\0', sizeof(mbstate_t)); ++ ++ for (;;) ++ { ++ unsigned char *translate = (unsigned char *) key->translate; ++ bool const *ignore = key->ignore; ++ ++ /* Find the lengths. */ ++ size_t lena = lima <= texta ? 0 : lima - texta; ++ size_t lenb = limb <= textb ? 0 : limb - textb; ++ ++ /* Actually compare the fields. */ ++ if (key->numeric | key->general_numeric) ++ { ++ char savea = *lima, saveb = *limb; ++ ++ *lima = *limb = '\0'; ++ if (force_general_numcompare) ++ diff = general_numcompare (texta, textb); ++ else ++ diff = ((key->numeric ? numcompare : general_numcompare) ++ (texta, textb)); ++ *lima = savea, *limb = saveb; ++ } ++ else if (key->month) ++ diff = getmonth (texta, lena) - getmonth (textb, lenb); ++ else ++ { ++ if (ignore || translate) ++ { ++ char *copy_a = (char *) alloca (lena + 1 + lenb + 1); ++ char *copy_b = copy_a + lena + 1; ++ size_t new_len_a, new_len_b; ++ size_t i, j; ++ ++ /* Ignore and/or translate chars before comparing. */ ++# define IGNORE_CHARS(NEW_LEN, LEN, TEXT, COPY, WC, MBLENGTH, STATE) \ ++ do \ ++ { \ ++ wchar_t uwc; \ ++ char mbc[MB_LEN_MAX]; \ ++ mbstate_t state_wc; \ ++ \ ++ for (NEW_LEN = i = 0; i < LEN;) \ ++ { \ ++ mbstate_t state_bak; \ ++ \ ++ state_bak = STATE; \ ++ MBLENGTH = mbrtowc (&WC, TEXT + i, LEN - i, &STATE); \ ++ \ ++ if (MBLENGTH == (size_t)-2 || MBLENGTH == (size_t)-1 \ ++ || MBLENGTH == 0) \ ++ { \ ++ if (MBLENGTH == (size_t)-2 || MBLENGTH == (size_t)-1) \ ++ STATE = state_bak; \ ++ if (!ignore) \ ++ COPY[NEW_LEN++] = TEXT[i++]; \ ++ continue; \ ++ } \ ++ \ ++ if (ignore) \ ++ { \ ++ if ((ignore == nonprinting && !iswprint (WC)) \ ++ || (ignore == nondictionary \ ++ && !iswalnum (WC) && !iswblank (WC))) \ ++ { \ ++ i += MBLENGTH; \ ++ continue; \ ++ } \ ++ } \ ++ \ ++ if (translate) \ ++ { \ ++ \ ++ uwc = towupper(WC); \ ++ if (WC == uwc) \ ++ { \ ++ memcpy (mbc, TEXT + i, MBLENGTH); \ ++ i += MBLENGTH; \ ++ } \ ++ else \ ++ { \ ++ i += MBLENGTH; \ ++ WC = uwc; \ ++ memset (&state_wc, '\0', sizeof (mbstate_t)); \ ++ \ ++ MBLENGTH = wcrtomb (mbc, WC, &state_wc); \ ++ assert (MBLENGTH != (size_t)-1 && MBLENGTH != 0); \ ++ } \ ++ \ ++ for (j = 0; j < MBLENGTH; j++) \ ++ COPY[NEW_LEN++] = mbc[j]; \ ++ } \ ++ else \ ++ for (j = 0; j < MBLENGTH; j++) \ ++ COPY[NEW_LEN++] = TEXT[i++]; \ ++ } \ ++ COPY[NEW_LEN] = '\0'; \ ++ } \ ++ while (0) ++ IGNORE_CHARS (new_len_a, lena, texta, copy_a, ++ wc_a, mblength_a, state_a); ++ IGNORE_CHARS (new_len_b, lenb, textb, copy_b, ++ wc_b, mblength_b, state_b); ++ diff = xmemcoll (copy_a, new_len_a, copy_b, new_len_b); ++ } ++ else if (lena == 0) ++ diff = - NONZERO (lenb); ++ else if (lenb == 0) ++ goto greater; ++ else ++ diff = xmemcoll (texta, lena, textb, lenb); ++ } ++ ++ if (diff) ++ goto not_equal; ++ ++ key = key->next; ++ if (! key) ++ break; ++ ++ /* Find the beginning and limit of the next field. */ ++ if (key->eword != -1) ++ lima = limfield (a, key), limb = limfield (b, key); ++ else ++ lima = a->text + a->length - 1, limb = b->text + b->length - 1; ++ ++ if (key->sword != -1) ++ texta = begfield (a, key), textb = begfield (b, key); ++ else ++ { ++ texta = a->text, textb = b->text; ++ if (key->skipsblanks) ++ { ++ while (texta < lima && ismbblank (texta, lima - texta, &mblength_a)) ++ texta += mblength_a; ++ while (textb < limb && ismbblank (textb, limb - textb, &mblength_b)) ++ textb += mblength_b; ++ } ++ } ++ } ++ ++ return 0; ++ ++greater: ++ diff = 1; ++not_equal: ++ return key->reverse ? -diff : diff; ++} ++#endif ++ + /* Compare two lines A and B, returning negative, zero, or positive + depending on whether A compares less than, equal to, or greater than B. */ + +@@ -2127,7 +2672,7 @@ + atexit (close_stdout); + + hard_LC_COLLATE = hard_locale (LC_COLLATE); +-#if HAVE_NL_LANGINFO ++#if HAVE_LANGINFO_CODESET + hard_LC_TIME = hard_locale (LC_TIME); + #endif + +@@ -2148,6 +2693,27 @@ + thousands_sep = -1; + } + ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ inittables = inittables_mb; ++ begfield = begfield_mb; ++ limfield = limfield_mb; ++ getmonth = getmonth_mb; ++ keycompare = keycompare_mb; ++ numcompare = numcompare_mb; ++ } ++ else ++#endif ++ { ++ inittables = inittables_uni; ++ begfield = begfield_uni; ++ limfield = limfield_uni; ++ getmonth = getmonth_uni; ++ keycompare = keycompare_uni; ++ numcompare = numcompare_uni; ++ } ++ + have_read_stdin = false; + inittables (); + +@@ -2349,13 +2915,35 @@ + + case 't': + { +- char newtab = optarg[0]; +- if (! newtab) ++ char newtab[MB_LEN_MAX + 1]; ++ size_t newtab_length = 1; ++ strncpy (newtab, optarg, MB_LEN_MAX); ++ if (! newtab[0]) + error (SORT_FAILURE, 0, _("empty tab")); +- if (optarg[1]) ++#if HAVE_MBRTOWC ++ if (MB_CUR_MAX > 1) ++ { ++ wchar_t wc; ++ mbstate_t state; ++ size_t i; ++ ++ memset (&state, '\0', sizeof (mbstate_t)); ++ newtab_length = mbrtowc (&wc, newtab, strnlen (newtab, ++ MB_LEN_MAX), ++ &state); ++ switch (newtab_length) ++ { ++ case (size_t) -1: ++ case (size_t) -2: ++ case 0: ++ newtab_length = 1; ++ } ++ } ++#endif ++ if (newtab_length == 1 && optarg[1]) + { + if (STREQ (optarg, "\\0")) +- newtab = '\0'; ++ newtab[0] = '\0'; + else + { + /* Provoke with `sort -txx'. Complain about +@@ -2366,9 +2954,12 @@ + quote (optarg)); + } + } +- if (tab != TAB_DEFAULT && tab != newtab) ++ if (tab_length ++ && (tab_length != newtab_length ++ || memcmp (tab, newtab, tab_length) != 0)) + error (SORT_FAILURE, 0, _("incompatible tabs")); +- tab = newtab; ++ memcpy (tab, newtab, newtab_length); ++ tab_length = newtab_length; + } + break; + +--- /dev/null 2005-10-10 09:36:06.437701000 +0100 ++++ coreutils-5.93/tests/sort/sort-mb-tests 2005-12-23 08:53:01.000000000 +0000 +@@ -0,0 +1,58 @@ ++#! /bin/sh ++case $# in ++ 0) xx='../../src/sort';; ++ *) xx="$1";; ++esac ++test "$VERBOSE" && echo=echo || echo=: ++$echo testing program: $xx ++errors=0 ++test "$srcdir" || srcdir=. ++test "$VERBOSE" && $xx --version 2> /dev/null ++ ++export LC_ALL=en_US.UTF-8 ++locale -k LC_CTYPE 2>&1 | grep -q charmap.*UTF-8 || exit 77 ++errors=0 ++ ++$xx -t @ -k2 -n mb1.I > mb1.O ++code=$? ++if test $code != 0; then ++ $echo "Test mb1 failed: $xx return code $code differs from expected value 0" 1>&2 ++ errors=`expr $errors + 1` ++else ++ cmp mb1.O $srcdir/mb1.X > /dev/null 2>&1 ++ case $? in ++ 0) if test "$VERBOSE"; then $echo "passed mb1"; fi;; ++ 1) $echo "Test mb1 failed: files mb1.O and $srcdir/mb1.X differ" 1>&2 ++ (diff -c mb1.O $srcdir/mb1.X) 2> /dev/null ++ errors=`expr $errors + 1`;; ++ 2) $echo "Test mb1 may have failed." 1>&2 ++ $echo The command "cmp mb1.O $srcdir/mb1.X" failed. 1>&2 ++ errors=`expr $errors + 1`;; ++ esac ++fi ++ ++$xx -t @ -k4 -n mb2.I > mb2.O ++code=$? ++if test $code != 0; then ++ $echo "Test mb2 failed: $xx return code $code differs from expected value 0" 1>&2 ++ errors=`expr $errors + 1` ++else ++ cmp mb2.O $srcdir/mb2.X > /dev/null 2>&1 ++ case $? in ++ 0) if test "$VERBOSE"; then $echo "passed mb2"; fi;; ++ 1) $echo "Test mb2 failed: files mb2.O and $srcdir/mb2.X differ" 1>&2 ++ (diff -c mb2.O $srcdir/mb2.X) 2> /dev/null ++ errors=`expr $errors + 1`;; ++ 2) $echo "Test mb2 may have failed." 1>&2 ++ $echo The command "cmp mb2.O $srcdir/mb2.X" failed. 1>&2 ++ errors=`expr $errors + 1`;; ++ esac ++fi ++ ++if test $errors = 0; then ++ $echo Passed all 113 tests. 1>&2 ++else ++ $echo Failed $errors tests. 1>&2 ++fi ++test $errors = 0 || errors=1 ++exit $errors +--- /dev/null 2005-10-10 09:36:06.437701000 +0100 ++++ coreutils-5.93/tests/sort/mb1.I 2005-12-23 08:53:01.000000000 +0000 +@@ -0,0 +1,4 @@ ++Apple@10 ++Banana@5 ++Citrus@20 ++Cherry@30 +--- /dev/null 2005-10-10 09:36:06.437701000 +0100 ++++ coreutils-5.93/tests/sort/mb2.I 2005-12-23 08:53:01.000000000 +0000 +@@ -0,0 +1,4 @@ ++Apple@AA10@@20 ++Banana@AA5@@30 ++Citrus@AA20@@5 ++Cherry@AA30@@10 +--- /dev/null 2005-10-10 09:36:06.437701000 +0100 ++++ coreutils-5.93/tests/sort/mb1.X 2005-12-23 08:53:01.000000000 +0000 +@@ -0,0 +1,4 @@ ++Banana@5 ++Apple@10 ++Citrus@20 ++Cherry@30 +--- /dev/null 2005-10-10 09:36:06.437701000 +0100 ++++ coreutils-5.93/tests/sort/mb2.X 2005-12-23 08:53:01.000000000 +0000 +@@ -0,0 +1,4 @@ ++Citrus@AA20@@5 ++Cherry@AA30@@10 ++Apple@AA10@@20 ++Banana@AA5@@30 +--- coreutils-5.93/tests/sort/Makefile.am.i18n 2005-10-24 22:02:25.000000000 +0100 ++++ coreutils-5.93/tests/sort/Makefile.am 2005-12-23 08:53:01.000000000 +0000 +@@ -43,14 +43,16 @@ + nul-nls.E use-nl.O use-nl.E o2.O o2.E nul-tab.O nul-tab.E + ##test-files-end + +-EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen) +-noinst_SCRIPTS = $x-tests ++run_gen += mb1.O mb2.O ++ ++EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen) mb1.I mb1.X mb2.I mb2.X ++noinst_SCRIPTS = $x-tests # $x-mb-tests + TESTS_ENVIRONMENT = \ + PATH="`pwd`/../../src$(PATH_SEPARATOR)$$PATH" + + editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,$(srcdir),g' + +-TESTS = $x-tests ++TESTS = $x-tests $x-mb-tests + + mk_script = $(srcdir)/../mk-script + $(srcdir)/$x-tests: $(mk_script) Test.pm Makefile.am +--- coreutils-5.93/tests/sort/Makefile.in.i18n 2005-10-22 19:13:23.000000000 +0100 ++++ coreutils-5.93/tests/sort/Makefile.in 2005-10-26 22:17:04.000000000 +0100 +@@ -338,13 +338,15 @@ + o-no-file1.E create-empty.O create-empty.E neg-nls.O neg-nls.E nul-nls.O \ + nul-nls.E use-nl.O use-nl.E o2.O o2.E nul-tab.O nul-tab.E + +-EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen) +-noinst_SCRIPTS = $x-tests ++run_gen += mb1.O mb2.O ++ ++EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen) mb1.I mb1.X mb2.I mb2.X ++noinst_SCRIPTS = $x-tests # $x-mb-tests + TESTS_ENVIRONMENT = \ + PATH="`pwd`/../../src$(PATH_SEPARATOR)$$PATH" + + editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,$(srcdir),g' +-TESTS = $x-tests ++TESTS = $x-tests $x-mb-tests + mk_script = $(srcdir)/../mk-script + MAINTAINERCLEANFILES = $x-tests $(maint_gen) + CLEANFILES = $(run_gen) diff --git a/src/patches/coreutils-5.96-suppress_uptime_kill_su-1.patch b/src/patches/coreutils-5.96-suppress_uptime_kill_su-1.patch new file mode 100644 index 0000000000..6a089092dc --- /dev/null +++ b/src/patches/coreutils-5.96-suppress_uptime_kill_su-1.patch @@ -0,0 +1,272 @@ +Submitted By: Matthew Burgess +Date: 2006-03-15 +Initial Package Version: 5.94 +Origin: original suppress_hotname_uptame_kill_su patch (Robert Connolly) +Upstream Status: N/A +Description: This patch supresses the building of uptime, and kill. The su +command is built so the testsuite can run, use './src/su', but it will not +be installed. Also see: + http://www.linuxfromscratch.org/patches/downloads/coreutils/ + coreutils-5.0-dupes-2.patch + +diff -Naur coreutils-5.94.orig/AUTHORS coreutils-5.94/AUTHORS +--- coreutils-5.94.orig/AUTHORS 2004-11-03 23:10:50.000000000 +0000 ++++ coreutils-5.94/AUTHORS 2006-03-15 22:20:49.000000000 +0000 +@@ -34,7 +34,6 @@ + hostname: Jim Meyering + id: Arnold Robbins, David MacKenzie + join: Mike Haertel +-kill: Paul Eggert + link: Michael Stone + ln: Mike Parker, David MacKenzie + logname: FIXME: unknown +@@ -83,7 +82,6 @@ + unexpand: David MacKenzie + uniq: Richard Stallman, David MacKenzie + unlink: Michael Stone +-uptime: Joseph Arceneaux, David MacKenzie, Kaveh Ghazi + users: Joseph Arceneaux, David MacKenzie + vdir: Richard Stallman, David MacKenzie + wc: Paul Rubin, David MacKenzie +diff -Naur coreutils-5.94.orig/Makefile.in coreutils-5.94/Makefile.in +--- coreutils-5.94.orig/Makefile.in 2006-02-13 12:52:03.000000000 +0000 ++++ coreutils-5.94/Makefile.in 2006-03-15 22:20:49.000000000 +0000 +@@ -148,7 +148,7 @@ + $(top_srcdir)/m4/ullong_max.m4 $(top_srcdir)/m4/ulonglong.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ +- $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ ++ $(top_srcdir)/m4/unlocked-io.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ + $(top_srcdir)/m4/utime.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes-null.m4 \ +diff -Naur coreutils-5.94.orig/README coreutils-5.94/README +--- coreutils-5.94.orig/README 2005-09-28 18:34:26.000000000 +0000 ++++ coreutils-5.94/README 2006-03-15 22:20:49.000000000 +0000 +@@ -9,11 +9,11 @@ + + [ basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd + df dir dircolors dirname du echo env expand expr factor false fmt fold +- ginstall groups head hostid hostname id join kill link ln logname ls ++ ginstall groups head hostid hostname id join link ln logname ls + md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr + printenv printf ptx pwd readlink rm rmdir seq sha1sum shred sleep sort + split stat stty su sum sync tac tail tee test touch tr true tsort tty +- uname unexpand uniq unlink uptime users vdir wc who whoami yes ++ uname unexpand uniq unlink users vdir wc who whoami yes + + See the file NEWS for a list of major changes in the current release. + +diff -Naur coreutils-5.94.orig/configure coreutils-5.94/configure +--- coreutils-5.94.orig/configure 2006-02-13 12:52:04.000000000 +0000 ++++ coreutils-5.94/configure 2006-03-15 22:20:49.000000000 +0000 +@@ -50418,8 +50418,7 @@ + { echo "$as_me:$LINENO: result: $gnulib_cv_have_boot_time" >&5 + echo "${ECHO_T}$gnulib_cv_have_boot_time" >&6; } + if test $gnulib_cv_have_boot_time = yes; then +- OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uptime\$(EXEEXT)" +- MAN="$MAN uptime.1" ++echo "uptime is suppressed" + fi + + +diff -Naur coreutils-5.94.orig/man/Makefile.in coreutils-5.94/man/Makefile.in +--- coreutils-5.94.orig/man/Makefile.in 2006-02-13 12:51:58.000000000 +0000 ++++ coreutils-5.94/man/Makefile.in 2006-03-15 22:20:50.000000000 +0000 +@@ -142,7 +142,7 @@ + $(top_srcdir)/m4/ullong_max.m4 $(top_srcdir)/m4/ulonglong.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ +- $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ ++ $(top_srcdir)/m4/unlocked-io.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ + $(top_srcdir)/m4/utime.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes-null.m4 \ +@@ -303,13 +303,13 @@ + basename.1 cat.1 chgrp.1 chmod.1 chown.1 chroot.1 cksum.1 comm.1 \ + cp.1 csplit.1 cut.1 date.1 dd.1 df.1 dir.1 dircolors.1 dirname.1 du.1 \ + echo.1 env.1 expand.1 expr.1 factor.1 false.1 fmt.1 fold.1 groups.1 \ +- head.1 hostid.1 hostname.1 id.1 install.1 join.1 kill.1 \ ++ head.1 hostid.1 hostname.1 id.1 install.1 join.1 \ + link.1 ln.1 logname.1 \ + ls.1 md5sum.1 mkdir.1 mkfifo.1 mknod.1 mv.1 nice.1 nl.1 nohup.1 od.1 \ + paste.1 pathchk.1 pinky.1 pr.1 printenv.1 printf.1 ptx.1 pwd.1 readlink.1 \ + rm.1 rmdir.1 seq.1 sha1sum.1 shred.1 sleep.1 sort.1 split.1 stat.1 stty.1 \ +- su.1 sum.1 sync.1 tac.1 tail.1 tee.1 test.1 touch.1 tr.1 true.1 tsort.1 \ +- tty.1 uname.1 unexpand.1 uniq.1 unlink.1 uptime.1 users.1 vdir.1 wc.1 \ ++ sum.1 sync.1 tac.1 tail.1 tee.1 test.1 touch.1 tr.1 true.1 tsort.1 \ ++ tty.1 uname.1 unexpand.1 uniq.1 unlink.1 users.1 vdir.1 wc.1 \ + who.1 whoami.1 yes.1 + + man_aux = $(dist_man_MANS:.1=.x) +@@ -575,7 +575,6 @@ + id.1: $(common_dep) $(srcdir)/id.x ../src/id.c + install.1: $(common_dep) $(srcdir)/install.x ../src/install.c + join.1: $(common_dep) $(srcdir)/join.x ../src/join.c +-kill.1: $(common_dep) $(srcdir)/kill.x ../src/kill.c + link.1: $(common_dep) $(srcdir)/link.x ../src/link.c + ln.1: $(common_dep) $(srcdir)/ln.x ../src/ln.c + logname.1: $(common_dep) $(srcdir)/logname.x ../src/logname.c +@@ -608,7 +607,6 @@ + split.1: $(common_dep) $(srcdir)/split.x ../src/split.c + stat.1: $(common_dep) $(srcdir)/stat.x ../src/stat.c + stty.1: $(common_dep) $(srcdir)/stty.x ../src/stty.c +-su.1: $(common_dep) $(srcdir)/su.x ../src/su.c + sum.1: $(common_dep) $(srcdir)/sum.x ../src/sum.c + sync.1: $(common_dep) $(srcdir)/sync.x ../src/sync.c + tac.1: $(common_dep) $(srcdir)/tac.x ../src/tac.c +@@ -624,7 +622,6 @@ + unexpand.1: $(common_dep) $(srcdir)/unexpand.x ../src/unexpand.c + uniq.1: $(common_dep) $(srcdir)/uniq.x ../src/uniq.c + unlink.1: $(common_dep) $(srcdir)/unlink.x ../src/unlink.c +-uptime.1: $(common_dep) $(srcdir)/uptime.x ../src/uptime.c + users.1: $(common_dep) $(srcdir)/users.x ../src/users.c + vdir.1: $(common_dep) $(srcdir)/vdir.x ../src/ls.c + wc.1: $(common_dep) $(srcdir)/wc.x ../src/wc.c +@@ -656,7 +653,7 @@ + check-x-vs-1: + PATH=../src$(PATH_SEPARATOR)$$PATH; export PATH; \ + t=ls-files.$$$$; \ +- (cd $(srcdir) && ls -1 *.x) | sed 's/\.x$$//' | $(ASSORT) > $$t;\ ++ (cd $(srcdir) && ls -1 *.x) | grep -v -e 'kill.x' -e 'su.x' -e 'uptime.x' | sed 's/\.x$$//' | $(ASSORT) > $$t;\ + echo $(dist_man_MANS) | tr -s ' ' '\n' | sed 's/\.1$$//' \ + | $(ASSORT) | diff - $$t || { rm $$t; exit 1; }; \ + rm $$t +diff -Naur coreutils-5.94.orig/src/Makefile.in coreutils-5.94/src/Makefile.in +--- coreutils-5.94.orig/src/Makefile.in 2006-02-13 13:08:11.000000000 +0000 ++++ coreutils-5.94/src/Makefile.in 2006-03-15 22:20:50.000000000 +0000 +@@ -39,7 +39,7 @@ + host_triplet = @host@ + EXTRA_PROGRAMS = chroot$(EXEEXT) df$(EXEEXT) hostid$(EXEEXT) \ + nice$(EXEEXT) pinky$(EXEEXT) stty$(EXEEXT) su$(EXEEXT) \ +- uname$(EXEEXT) uptime$(EXEEXT) users$(EXEEXT) who$(EXEEXT) ++ uname$(EXEEXT) users$(EXEEXT) who$(EXEEXT) + bin_PROGRAMS = [$(EXEEXT) chgrp$(EXEEXT) chown$(EXEEXT) chmod$(EXEEXT) \ + cp$(EXEEXT) dd$(EXEEXT) dircolors$(EXEEXT) du$(EXEEXT) \ + ginstall$(EXEEXT) link$(EXEEXT) ln$(EXEEXT) dir$(EXEEXT) \ +@@ -56,7 +56,7 @@ + uniq$(EXEEXT) wc$(EXEEXT) basename$(EXEEXT) date$(EXEEXT) \ + dirname$(EXEEXT) echo$(EXEEXT) env$(EXEEXT) expr$(EXEEXT) \ + factor$(EXEEXT) false$(EXEEXT) hostname$(EXEEXT) id$(EXEEXT) \ +- kill$(EXEEXT) logname$(EXEEXT) pathchk$(EXEEXT) \ ++ logname$(EXEEXT) pathchk$(EXEEXT) \ + printenv$(EXEEXT) printf$(EXEEXT) pwd$(EXEEXT) seq$(EXEEXT) \ + sleep$(EXEEXT) tee$(EXEEXT) test$(EXEEXT) true$(EXEEXT) \ + tty$(EXEEXT) whoami$(EXEEXT) yes$(EXEEXT) $(am__EXEEXT_1) \ +@@ -169,7 +169,7 @@ + $(top_srcdir)/m4/ullong_max.m4 $(top_srcdir)/m4/ulonglong.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ +- $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ ++ $(top_srcdir)/m4/unlocked-io.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ + $(top_srcdir)/m4/utime.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes-null.m4 \ +@@ -350,11 +350,6 @@ + join_LDADD = $(LDADD) + join_DEPENDENCIES = ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ + ../lib/libcoreutils.a +-kill_SOURCES = kill.c +-kill_OBJECTS = kill.$(OBJEXT) +-kill_LDADD = $(LDADD) +-kill_DEPENDENCIES = ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ +- ../lib/libcoreutils.a + link_SOURCES = link.c + link_OBJECTS = link.$(OBJEXT) + link_LDADD = $(LDADD) +@@ -577,9 +572,6 @@ + unlink_LDADD = $(LDADD) + unlink_DEPENDENCIES = ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ + ../lib/libcoreutils.a +-uptime_SOURCES = uptime.c +-uptime_OBJECTS = uptime.$(OBJEXT) +-uptime_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) + users_SOURCES = users.c + users_OBJECTS = users.$(OBJEXT) + users_LDADD = $(LDADD) +@@ -622,28 +614,28 @@ + csplit.c cut.c date.c dd.c df.c $(dir_SOURCES) dircolors.c \ + dirname.c du.c echo.c env.c expand.c expr.c factor.c false.c \ + fmt.c fold.c $(ginstall_SOURCES) head.c hostid.c hostname.c \ +- id.c join.c kill.c link.c ln.c logname.c $(ls_SOURCES) \ ++ id.c join.c link.c ln.c logname.c $(ls_SOURCES) \ + $(md5sum_SOURCES) mkdir.c mkfifo.c mknod.c $(mv_SOURCES) \ + nice.c nl.c nohup.c od.c paste.c pathchk.c pinky.c pr.c \ + printenv.c printf.c ptx.c pwd.c readlink.c $(rm_SOURCES) \ + rmdir.c seq.c setuidgid.c $(sha1sum_SOURCES) shred.c sleep.c \ + sort.c split.c stat.c stty.c su.c sum.c sync.c tac.c tail.c \ + tee.c test.c touch.c tr.c true.c tsort.c tty.c uname.c \ +- unexpand.c uniq.c unlink.c uptime.c users.c $(vdir_SOURCES) \ ++ unexpand.c uniq.c unlink.c users.c $(vdir_SOURCES) \ + wc.c who.c whoami.c yes.c + DIST_SOURCES = $(__SOURCES) basename.c cat.c $(chgrp_SOURCES) chmod.c \ + $(chown_SOURCES) chroot.c cksum.c comm.c $(cp_SOURCES) \ + csplit.c cut.c date.c dd.c df.c $(dir_SOURCES) dircolors.c \ + dirname.c du.c echo.c env.c expand.c expr.c factor.c false.c \ + fmt.c fold.c $(ginstall_SOURCES) head.c hostid.c hostname.c \ +- id.c join.c kill.c link.c ln.c logname.c $(ls_SOURCES) \ ++ id.c join.c link.c ln.c logname.c $(ls_SOURCES) \ + $(md5sum_SOURCES) mkdir.c mkfifo.c mknod.c $(mv_SOURCES) \ + nice.c nl.c nohup.c od.c paste.c pathchk.c pinky.c pr.c \ + printenv.c printf.c ptx.c pwd.c readlink.c $(rm_SOURCES) \ + rmdir.c seq.c setuidgid.c $(sha1sum_SOURCES) shred.c sleep.c \ + sort.c split.c stat.c stty.c su.c sum.c sync.c tac.c tail.c \ + tee.c test.c touch.c tr.c true.c tsort.c tty.c uname.c \ +- unexpand.c uniq.c unlink.c uptime.c users.c $(vdir_SOURCES) \ ++ unexpand.c uniq.c unlink.c users.c $(vdir_SOURCES) \ + wc.c who.c whoami.c yes.c + HEADERS = $(noinst_HEADERS) + ETAGS = etags +@@ -840,7 +832,6 @@ + nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP) + sleep_LDADD = $(nanosec_libs) + tail_LDADD = $(nanosec_libs) +-uptime_LDADD = $(LDADD) $(GETLOADAVG_LIBS) + su_LDADD = $(LDADD) $(LIB_CRYPT) + SUFFIXES = .sh + installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'` +@@ -1076,9 +1067,6 @@ + join$(EXEEXT): $(join_OBJECTS) $(join_DEPENDENCIES) + @rm -f join$(EXEEXT) + $(LINK) $(join_LDFLAGS) $(join_OBJECTS) $(join_LDADD) $(LIBS) +-kill$(EXEEXT): $(kill_OBJECTS) $(kill_DEPENDENCIES) +- @rm -f kill$(EXEEXT) +- $(LINK) $(kill_LDFLAGS) $(kill_OBJECTS) $(kill_LDADD) $(LIBS) + link$(EXEEXT): $(link_OBJECTS) $(link_DEPENDENCIES) + @rm -f link$(EXEEXT) + $(LINK) $(link_LDFLAGS) $(link_OBJECTS) $(link_LDADD) $(LIBS) +@@ -1226,9 +1214,6 @@ + unlink$(EXEEXT): $(unlink_OBJECTS) $(unlink_DEPENDENCIES) + @rm -f unlink$(EXEEXT) + $(LINK) $(unlink_LDFLAGS) $(unlink_OBJECTS) $(unlink_LDADD) $(LIBS) +-uptime$(EXEEXT): $(uptime_OBJECTS) $(uptime_DEPENDENCIES) +- @rm -f uptime$(EXEEXT) +- $(LINK) $(uptime_LDFLAGS) $(uptime_OBJECTS) $(uptime_LDADD) $(LIBS) + users$(EXEEXT): $(users_OBJECTS) $(users_DEPENDENCIES) + @rm -f users$(EXEEXT) + $(LINK) $(users_LDFLAGS) $(users_OBJECTS) $(users_LDADD) $(LIBS) +@@ -1322,7 +1307,6 @@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/id.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/install.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/join.Po@am__quote@ +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kill.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lbracket.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ln.Po@am__quote@ +@@ -1378,7 +1362,6 @@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unexpand.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uniq.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@ +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uptime.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/users.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wc.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/who.Po@am__quote@ +@@ -1606,7 +1589,7 @@ + && can_create_suid_root_executable=yes; \ + rm -f $$TMPFILE; \ + if test $$can_create_suid_root_executable = yes; then \ +- $(INSTALL_SU); \ ++ echo "Installation of su is suppressed"; \ + else \ + echo "WARNING: insufficient access; not installing su"; \ + echo "NOTE: to install su, run 'make install-root' as root"; \ diff --git a/src/patches/coreutils-5.96-uname-1.patch b/src/patches/coreutils-5.96-uname-1.patch new file mode 100644 index 0000000000..a05ae041ef --- /dev/null +++ b/src/patches/coreutils-5.96-uname-1.patch @@ -0,0 +1,182 @@ +Submitted By: Matthew Burgess +Date: 2005-10-23 +Initial Package Version: 5.92 +Upstream Status: pending +Origin: Scot McPherson +Description: Fix the output of uname once and for all. + + $ uname -m # This always worked. + i686 + $ uname -i # Used to report 'unknown'. + i386 + $ uname -p # Likewise. + athlon-4 + +diff -Naur coreutils-5.92.orig/src/uname.c coreutils-5.92/src/uname.c +--- coreutils-5.92.orig/src/uname.c 2005-09-15 20:34:42.000000000 +0000 ++++ coreutils-5.92/src/uname.c 2005-10-23 10:14:06.000000000 +0000 +@@ -29,6 +29,12 @@ + # include + #endif + ++#ifdef linux ++#define cpuid(in,a,b,c,d)\ ++ asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in)); ++int has_sse( void ); ++#endif ++ + #if HAVE_SYS_SYSCTL_H + # if HAVE_SYS_PARAM_H + # include /* needed for OpenBSD 3.0 */ +@@ -256,6 +262,96 @@ + if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) + element = processor; + } ++#else ++ { ++ struct utsname u; ++ uname (&u); ++ element = u.machine; ++#ifdef linux ++/****************************************************************************** ++ * ++ * Hello, major hack. I shouldn't have to do this. struct utsname should ++ * have another element with this info in it. There's probably a struct ++ * somewhere that has this info, I just don't know where it is. ++ * ++ *****************************************************************************/ ++ ++ if( !strcmp( element, "i586" ) || !strcmp( element, "i686" ) ) { ++ int eax, ebx, ecx, edx, unused; ++ int model, family, sse; ++ ++ cpuid(0,unused,ebx,ecx,edx); ++ cpuid(1,eax,unused,unused,unused); ++ model = (eax >> 4) & 0xf; ++ family = (eax >> 8) & 0xf; ++ ++ switch(ebx) { ++ case 0x756e6547: // Intel ++ switch( family ) { ++ case 5: // Pentium ++ if( model <= 3 ) ++ element="pentium"; ++ if( model > 3 ) ++ element="pentium-mmx"; ++ break; ++ case 6: // PentiumPro - Pentium III ++ if( model == 1 ) // Pentium Pro ++ element="pentiumpro"; ++ if( ( model == 3 ) || ( model == 5 ) || ++ ( model == 6 ) ) // Pentium II ++ element="pentium2"; ++ if( ( model == 7 ) || ( model == 8 ) || ++ ( model == 10 ) || ( model == 11 ) ) // These are all Pentium III ++ element="pentium3"; ++ break; ++ case 15: // Pentium4 ++ element="pentium4"; ++ break; ++ default: ++ break; ++ } // end switch( family ) ++ break; ++ case 0x68747541: // AMD ++ switch(family) { ++ case 5: ++ if( ( model == 0 ) || ( model == 1 ) || ++ ( model == 2 ) || ( model == 3 ) ) // K5 ++ element="i586"; ++ if( ( model == 6 ) || ( model == 7 ) ) // K6 ++ element="k6"; ++ if( model == 8 ) // K6-2 ++ element="k6-2"; ++ if( model == 9 ) // K6-3 ++ element="k6-3"; ++ break; ++ case 6: ++ if( model <= 4 ) ++ element="athlon"; ++ if( model > 4 ) { ++ sse = has_sse(); ++ if( sse == 0 ) ++ element="athlon"; ++ if( sse == 1 ) ++ element="athlon-4"; ++ } ++ break; ++ case 15: ++ element="athlon-4"; ++ break; ++ default: ++ break; ++ } // end switch( family ) ++ break; ++ case 0x69727943: // Cyrix ++ element="i386"; // who knows what cyrix supports, lets be safe ++ break; ++ default: ++ break; ++ } // end switch(ebx) ++ } ++ ++#endif ++ } + #endif + #ifdef UNAME_PROCESSOR + if (element == unknown) +@@ -293,7 +389,7 @@ + + if (toprint & PRINT_HARDWARE_PLATFORM) + { +- char const *element = unknown; ++ char *element = unknown; + #if HAVE_SYSINFO && defined SI_PLATFORM + { + static char hardware_platform[257]; +@@ -301,6 +397,15 @@ + hardware_platform, sizeof hardware_platform)) + element = hardware_platform; + } ++#else ++ { ++ struct utsname u; ++ uname (&u); ++ element = u.machine; ++ if (strlen (element) == 4 && element[0] == 'i' && element[2] == '8' ++ && element[3] == '6') ++ element[1] = '3'; ++ } + #endif + #ifdef UNAME_HARDWARE_PLATFORM + if (element == unknown) +@@ -323,3 +428,29 @@ + + exit (EXIT_SUCCESS); + } ++ ++#ifdef linux ++ ++/****************************************************************************** ++ * ++ * int has_sse( void ) ++ * Checks Athlon CPU's to see if they support SSE. ++ * ++ *****************************************************************************/ ++ ++int has_sse( void ) ++{ ++ unsigned long edx, unused; ++ int sse; ++ cpuid(1,unused,unused,unused,edx); ++ // I think, I need this tested on a Duron with SSE ++ // and one without it. ++ sse = edx & 0x2000000; ++ if( sse == 0 ) { ++ return 0; ++ } else { ++ return 1; ++ } ++ ++} ++#endif diff --git a/src/patches/expect-5.43.0-spawn-1.patch b/src/patches/expect-5.43.0-spawn-1.patch new file mode 100644 index 0000000000..c2033c0d20 --- /dev/null +++ b/src/patches/expect-5.43.0-spawn-1.patch @@ -0,0 +1,217 @@ +Submitted By: LFS Book +Date: 2003-10-05 +Initial Package Version: 5.38 +Origin: Redhat RPM (Patch by HJ Lu) +Description: NA +diff -uNr expect-5.38.orig/exp_chan.c expect-5.38/exp_chan.c +--- expect-5.38.orig/exp_chan.c 2002-02-12 13:00:55.000000000 +1100 ++++ expect-5.38/exp_chan.c 2003-03-01 10:36:18.000000000 +1100 +@@ -519,6 +519,7 @@ + esPtr->buffer = Tcl_NewStringObj("",0); + Tcl_IncrRefCount(esPtr->buffer); + esPtr->umsize = exp_default_match_max; ++ esPtr->umsize_changed = exp_default_match_max_changed; + /* this will reallocate object with an appropriate sized buffer */ + expAdjust(esPtr); + +diff -uNr expect-5.38.orig/exp_command.h expect-5.38/exp_command.h +--- expect-5.38.orig/exp_command.h 2002-04-08 08:57:20.000000000 +1000 ++++ expect-5.38/exp_command.h 2003-03-01 10:36:18.000000000 +1100 +@@ -25,6 +25,7 @@ + EXTERN char * exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *)); + + EXTERN int exp_default_match_max; ++EXTERN int exp_default_match_max_changed; + EXTERN int exp_default_parity; + EXTERN int exp_default_rm_nulls; + +@@ -97,6 +98,7 @@ + int msize; /* # of bytes that buffer can hold (max) */ + int umsize; /* # of bytes (min) that is guaranteed to match */ + /* this comes from match_max command */ ++ int umsize_changed; /* is umsize changed by user? */ + int printed; /* # of bytes written to stdout (if logging on) */ + /* but not actually returned via a match yet */ + int echoed; /* additional # of bytes (beyond "printed" above) */ +diff -uNr expect-5.38.orig/expect.c expect-5.38/expect.c +--- expect-5.38.orig/expect.c 2002-04-08 09:00:33.000000000 +1000 ++++ expect-5.38/expect.c 2003-03-01 10:36:18.000000000 +1100 +@@ -41,8 +41,17 @@ + #include "tcldbg.h" + #endif + ++/* The initial length is 2000. We increment it by 2000. The maximum ++ is 8MB (0x800000). */ ++#define EXP_MATCH_MAX 2000 ++#define EXP_MATCH_INC 2000 ++#define EXP_MATCH_STEP_LIMIT 0x700000 ++#define EXP_MATCH_LIMIT 0x800000 ++#define EXP_MATCH_LIMIT_QUOTE "0x800000" ++ + /* initial length of strings that we can guarantee patterns can match */ +-int exp_default_match_max = 2000; ++int exp_default_match_max = EXP_MATCH_MAX; ++int exp_default_match_max_changed = 0; + #define INIT_EXPECT_TIMEOUT_LIT "10" /* seconds */ + #define INIT_EXPECT_TIMEOUT 10 /* seconds */ + int exp_default_parity = TRUE; +@@ -1618,6 +1627,76 @@ + return newsize; + } + ++/* returns # of bytes until we see a newline at the end or EOF. */ ++/*ARGSUSED*/ ++static int ++expReadNewLine(interp,esPtr,save_flags) /* INTL */ ++Tcl_Interp *interp; ++ExpState *esPtr; ++int save_flags; ++{ ++ int size; ++ int exp_size; ++ int full_size; ++ int count; ++ char *str; ++ ++ count = 0; ++ for (;;) { ++ exp_size = expSizeGet(esPtr); ++ ++ /* When we reach the limit, we will only read one char at a ++ time. */ ++ if (esPtr->umsize >= EXP_MATCH_STEP_LIMIT) ++ size = TCL_UTF_MAX; ++ else ++ size = exp_size; ++ ++ if (exp_size + TCL_UTF_MAX >= esPtr->msize) { ++ if (esPtr->umsize >= EXP_MATCH_LIMIT) { ++ expDiagLogU("WARNING: interact buffer is full. probably your program\r\n"); ++ expDiagLogU("is not interactive or has a very long output line. The\r\n"); ++ expDiagLogU("current limit is " EXP_MATCH_LIMIT_QUOTE ".\r\n"); ++ expDiagLogU("Dumping first half of buffer in order to continue\r\n"); ++ expDiagLogU("Recommend you enlarge the buffer.\r\n"); ++ exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect"); ++ return count; ++ } ++ else { ++ esPtr->umsize += EXP_MATCH_INC; ++ expAdjust(esPtr); ++ } ++ } ++ ++ full_size = esPtr->msize - (size / TCL_UTF_MAX); ++ size = Tcl_ReadChars(esPtr->channel, ++ esPtr->buffer, ++ full_size, ++ 1 /* append */); ++ if (size > 0) { ++ count += size; ++ /* We try again if there are more to read and we haven't ++ seen a newline at the end. */ ++ if (size == full_size) { ++ str = Tcl_GetStringFromObj(esPtr->buffer, &size); ++ if (str[size - 1] != '\n') ++ continue; ++ } ++ } ++ else { ++ /* It is even trickier. We got an error from read. We have ++ to recover from it. Let's make sure the size of ++ buffer is correct. It can be corrupted. */ ++ str = Tcl_GetString(esPtr->buffer); ++ Tcl_SetObjLength(esPtr->buffer, strlen(str)); ++ } ++ ++ break; ++ } ++ ++ return count; ++} ++ + /* returns # of bytes read or (non-positive) error of form EXP_XXX */ + /* returns 0 for end of file */ + /* If timeout is non-zero, set an alarm before doing the read, else assume */ +@@ -1632,6 +1711,8 @@ + { + int cc = EXP_TIMEOUT; + int size = expSizeGet(esPtr); ++ int full_size; ++ int count; + + if (size + TCL_UTF_MAX >= esPtr->msize) + exp_buffer_shuffle(interp,esPtr,save_flags,EXPECT_OUT,"expect"); +@@ -1648,11 +1729,43 @@ + } + #endif + +- ++ /* FIXME: If we ask less than what is available in the tcl buffer ++ when tcl has seen EOF, we will throw away the remaining data ++ since the next read will get EOF. Since expect is line-oriented, ++ we exand our buffer to get EOF or the next newline at the end of ++ the input buffer. I don't know if it is the right fix. H.J. */ ++ count = 0; ++ full_size = esPtr->msize - (size / TCL_UTF_MAX); + cc = Tcl_ReadChars(esPtr->channel, +- esPtr->buffer, +- esPtr->msize - (size / TCL_UTF_MAX), +- 1 /* append */); ++ esPtr->buffer, ++ full_size, ++ 1 /* append */); ++ if (cc > 0) { ++ count += cc; ++ /* It gets very tricky. There are more to read. We will expand ++ our buffer and get EOF or a newline at the end unless the ++ buffer length has been changed. */ ++ if (cc == full_size) { ++ char *str; ++ str = Tcl_GetStringFromObj(esPtr->buffer, &size); ++ if (str[size - 1] != '\n') { ++ if (esPtr->umsize_changed) { ++ char buf[20]; /* big enough for 64bit int in hex. */ ++ snprintf(buf,sizeof(buf),"0x%x", esPtr->umsize); ++ expDiagLogU("WARNING: interact buffer is not large enough to hold\r\n"); ++ expDiagLogU("all output. probably your program is not interactive or\r\n"); ++ expDiagLogU("has a very long output line. The current limit is "); ++ expDiagLogU(buf); ++ expDiagLogU(".\r\n"); ++ } ++ else { ++ cc = expReadNewLine(interp,esPtr,save_flags); ++ if (cc > 0) ++ count += cc; ++ } ++ } ++ } ++ } + i_read_errno = errno; + + #ifdef SIMPLE_EVENT +@@ -1673,7 +1786,7 @@ + } + } + #endif +- return cc; ++ return count > 0 ? count : cc; + } + + /* +@@ -2746,8 +2859,14 @@ + return(TCL_ERROR); + } + +- if (Default) exp_default_match_max = size; +- else esPtr->umsize = size; ++ if (Default) { ++ exp_default_match_max = size; ++ exp_default_match_max_changed = 1; ++ } ++ else { ++ esPtr->umsize = size; ++ esPtr->umsize_changed = 1; ++ } + + return(TCL_OK); + } diff --git a/src/patches/gawk-3.1.5-segfault_fix-1.patch b/src/patches/gawk-3.1.5-segfault_fix-1.patch new file mode 100644 index 0000000000..aa2f17b6d3 --- /dev/null +++ b/src/patches/gawk-3.1.5-segfault_fix-1.patch @@ -0,0 +1,43 @@ +Submitted By: Matthew Burgess +Date: 2005-09-24 +Initial Package Version: 3.1.5 +Upstream Status: From Upstream +Origin: http://lists.gnu.org/archive/html/bug-gnu-utils/2005-08/msg00047.html +Description: Fixes a bug which causes gawk to segfault when operating on a non-existent file. + +diff -Naur gawk-3.1.5.orig/io.c gawk-3.1.5/io.c +--- gawk-3.1.5.orig/io.c 2005-07-26 18:07:43.000000000 +0000 ++++ gawk-3.1.5/io.c 2005-09-24 14:43:13.771380264 +0000 +@@ -2480,9 +2480,12 @@ + { + struct stat sbuf; + struct open_hook *oh; ++ int iop_malloced = FALSE; + +- if (iop == NULL) ++ if (iop == NULL) { + emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc"); ++ iop_malloced = TRUE; ++ } + memset(iop, '\0', sizeof(IOBUF)); + iop->flag = 0; + iop->fd = fd; +@@ -2495,7 +2498,8 @@ + } + + if (iop->fd == INVALID_HANDLE) { +- free(iop); ++ if (iop_malloced) ++ free(iop); + return NULL; + } + if (isatty(iop->fd)) +@@ -2503,7 +2507,7 @@ + iop->readsize = iop->size = optimal_bufsize(iop->fd, & sbuf); + iop->sbuf = sbuf; + if (do_lint && S_ISREG(sbuf.st_mode) && sbuf.st_size == 0) +- lintwarn(_("data file `%s' is empty"), name); ++ lintwarn(_("data file `%s' is empty"), name); + errno = 0; + iop->count = iop->scanoff = 0; + emalloc(iop->buf, char *, iop->size += 2, "iop_alloc"); diff --git a/src/patches/gcc-4.0.3-specs-1.patch b/src/patches/gcc-4.0.3-specs-1.patch new file mode 100644 index 0000000000..46521e16ed --- /dev/null +++ b/src/patches/gcc-4.0.3-specs-1.patch @@ -0,0 +1,336 @@ +Submitted By: Robert Connolly (ashes) +Date: 2006-01-16 +Initial Package Version: 4.0.0 +Upstream Status: Not Sent - LFS Specfic +Origin: Idea originally developed by Ryan Oliver and Greg Schafer for + the Pure LFS project. + More architectures added by Zack Winkles. + Further fine tunings by Greg Schafer. + Modified for gcc 3.3.2 by Oliver Brakmann. +Rediffed against gcc 3.4.0 by Zack Winkles. + Rediffed against gcc 3.4.3 by Jim Gifford. + Rediffed against gcc 4.0.0 by Robert Connolly. +Description: This patch modifies the location of the dynamic linker for + the GCC Pass 2 build in LFS Chapter 5. + +diff -Naur gcc-20050116.orig/gcc/config/alpha/linux-elf.h gcc-20050116/gcc/config/alpha/linux-elf.h +--- gcc-20050116.orig/gcc/config/alpha/linux-elf.h 2005-01-17 00:45:16.000000000 +0000 ++++ gcc-20050116/gcc/config/alpha/linux-elf.h 2005-01-17 00:46:14.560651027 +0000 +@@ -27,7 +27,7 @@ + #define SUBTARGET_EXTRA_SPECS \ + { "elf_dynamic_linker", ELF_DYNAMIC_LINKER }, + +-#define ELF_DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define ELF_DYNAMIC_LINKER "/tools/lib/ld-linux.so.2" + + #define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \ + %{O*:-O3} %{!O*:-O1} \ +diff -Naur gcc-20050116.orig/gcc/config/arm/linux-elf.h gcc-20050116/gcc/config/arm/linux-elf.h +--- gcc-20050116.orig/gcc/config/arm/linux-elf.h 2005-01-17 00:45:16.000000000 +0000 ++++ gcc-20050116/gcc/config/arm/linux-elf.h 2005-01-17 00:46:50.538578614 +0000 +@@ -87,7 +87,7 @@ + %{shared:-shared} \ + %{symbolic:-Bsymbolic} \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2} \ + -X \ + %{mbig-endian:-EB}" \ + SUBTARGET_EXTRA_LINK_SPEC +diff -Naur gcc-20050116.orig/gcc/config/frv/linux.h gcc-20050116/gcc/config/frv/linux.h +--- gcc-20050116.orig/gcc/config/frv/linux.h 2005-01-17 00:45:16.000000000 +0000 ++++ gcc-20050116/gcc/config/frv/linux.h 2005-01-17 01:33:50.600805260 +0000 +@@ -41,7 +41,7 @@ + %{mfdpic: -m elf32frvfd -z text} %{shared} %{pie} \ + %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \ + %{static}}" + + /* Support for compile-time default CPU. */ +diff -Naur gcc-20050116.orig/gcc/config/i386/gnu.h gcc-20050116/gcc/config/i386/gnu.h +--- gcc-20050116.orig/gcc/config/i386/gnu.h 2005-01-17 00:45:16.000000000 +0000 ++++ gcc-20050116/gcc/config/i386/gnu.h 2005-01-17 01:34:11.142021939 +0000 +@@ -27,7 +27,7 @@ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so}} \ + %{static:-static}}" + + #undef STARTFILE_SPEC +diff -Naur gcc-20050116.orig/gcc/config/i386/linux.h gcc-20050116/gcc/config/i386/linux.h +--- gcc-20050116.orig/gcc/config/i386/linux.h 2005-01-17 00:45:16.000000000 +0000 ++++ gcc-20050116/gcc/config/i386/linux.h 2005-01-17 00:49:27.412667132 +0000 +@@ -105,7 +105,7 @@ + /* If ELF is the default format, we should not use /lib/elf. */ + + #define LINK_EMULATION "elf_i386" +-#define DYNAMIC_LINKER "/lib/ld-linux.so.2" ++#define DYNAMIC_LINKER "/tools/lib/ld-linux.so.2" + + #undef SUBTARGET_EXTRA_SPECS + #define SUBTARGET_EXTRA_SPECS \ +diff -Naur gcc-20050116.orig/gcc/config/i386/linux64.h gcc-20050116/gcc/config/i386/linux64.h +--- gcc-20050116.orig/gcc/config/i386/linux64.h 2005-01-17 00:45:16.000000000 +0000 ++++ gcc-20050116/gcc/config/i386/linux64.h 2005-01-17 00:50:23.055094690 +0000 +@@ -60,8 +60,8 @@ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ +- %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \ ++ %{m32:%{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \ ++ %{!m32:%{!dynamic-linker:-dynamic-linker /tools/lib64/ld-linux-x86-64.so.2}}} \ + %{static:-static}}" + + #define MULTILIB_DEFAULTS { "m64" } +diff -Naur gcc-20050116.orig/gcc/config/ia64/linux.h gcc-20050116/gcc/config/ia64/linux.h +--- gcc-20050116.orig/gcc/config/ia64/linux.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/ia64/linux.h 2005-01-17 00:50:43.146472133 +0000 +@@ -43,7 +43,7 @@ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux-ia64.so.2}} \ + %{static:-static}}" + + +diff -Naur gcc-20050116.orig/gcc/config/linux.h gcc-20050116/gcc/config/linux.h +--- gcc-20050116.orig/gcc/config/linux.h 2005-01-17 00:45:16.000000000 +0000 ++++ gcc-20050116/gcc/config/linux.h 2005-01-17 00:51:14.101809663 +0000 +@@ -104,3 +104,7 @@ + #define TARGET_C99_FUNCTIONS 1 + + #define TARGET_HAS_F_SETLKW ++ ++/* Remove /usr/include from the end of the include search path. */ ++#undef STANDARD_INCLUDE_DIR ++#define STANDARD_INCLUDE_DIR 0 +diff -Naur gcc-20050116.orig/gcc/config/m32r/linux.h gcc-20050116/gcc/config/m32r/linux.h +--- gcc-20050116.orig/gcc/config/m32r/linux.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/m32r/linux.h 2005-01-17 00:51:39.720640870 +0000 +@@ -66,7 +66,7 @@ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \ + %{static:-static}}}" + #else + #define LINK_SPEC "%(link_cpu) -m m32relf_linux %{shared:-shared} \ +@@ -74,7 +74,7 @@ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \ + %{static:-static}}}" + #endif + +diff -Naur gcc-20050116.orig/gcc/config/m68k/linux.h gcc-20050116/gcc/config/m68k/linux.h +--- gcc-20050116.orig/gcc/config/m68k/linux.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/m68k/linux.h 2005-01-17 00:52:07.633830392 +0000 +@@ -132,7 +132,7 @@ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \ ++ %{!dynamic-linker*:-dynamic-linker /tools/lib/ld.so.1}} \ + %{static}}" + + /* For compatibility with linux/a.out */ +diff -Naur gcc-20050116.orig/gcc/config/mips/linux.h gcc-20050116/gcc/config/mips/linux.h +--- gcc-20050116.orig/gcc/config/mips/linux.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/mips/linux.h 2005-01-17 00:52:28.348034505 +0000 +@@ -115,7 +115,7 @@ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \ + %{static:-static}}}" + + #undef SUBTARGET_ASM_SPEC +diff -Naur gcc-20050116.orig/gcc/config/mips/linux64.h gcc-20050116/gcc/config/mips/linux64.h +--- gcc-20050116.orig/gcc/config/mips/linux64.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/mips/linux64.h 2005-01-17 00:53:04.645878728 +0000 +@@ -60,9 +60,9 @@ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker: \ +- %{mabi=n32: -dynamic-linker /lib32/ld.so.1} \ +- %{mabi=64: -dynamic-linker /lib64/ld.so.1} \ +- %{mabi=32: -dynamic-linker /lib/ld.so.1}}} \ ++ %{mabi=n32: -dynamic-linker /tools/lib32/ld.so.1} \ ++ %{mabi=64: -dynamic-linker /tools/lib64/ld.so.1} \ ++ %{mabi=32: -dynamic-linker /tools/lib/ld.so.1}}} \ + %{static:-static}}} \ + %{mabi=n32:-melf32%{EB:b}%{EL:l}tsmipn32} \ + %{mabi=64:-melf64%{EB:b}%{EL:l}tsmip} \ +diff -Naur gcc-20050116.orig/gcc/config/mn10300/linux.h gcc-20050116/gcc/config/mn10300/linux.h +--- gcc-20050116.orig/gcc/config/mn10300/linux.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/mn10300/linux.h 2005-01-17 00:53:23.477610026 +0000 +@@ -37,7 +37,7 @@ + #define LINK_SPEC "%{mrelax:--relax} %{shared:-shared} \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \ + %{static:-static}" + + #undef LIB_SPEC +diff -Naur gcc-20050116.orig/gcc/config/pa/pa-linux.h gcc-20050116/gcc/config/pa/pa-linux.h +--- gcc-20050116.orig/gcc/config/pa/pa-linux.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/pa/pa-linux.h 2005-01-17 00:53:45.334495141 +0000 +@@ -88,7 +88,7 @@ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \ + %{static:-static}}" + + /* glibc's profiling functions don't need gcc to allocate counters. */ +diff -Naur gcc-20050116.orig/gcc/config/rs6000/linux64.h gcc-20050116/gcc/config/rs6000/linux64.h +--- gcc-20050116.orig/gcc/config/rs6000/linux64.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/rs6000/linux64.h 2005-01-17 00:54:28.524412534 +0000 +@@ -351,11 +351,11 @@ + + #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}" ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}}}" + + #define LINK_OS_LINUX_SPEC64 "-m elf64ppc %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}" ++ %{!dynamic-linker:-dynamic-linker /tools/lib64/ld64.so.1}}}" + + #undef TOC_SECTION_ASM_OP + #define TOC_SECTION_ASM_OP \ +diff -Naur gcc-20050116.orig/gcc/config/rs6000/sysv4.h gcc-20050116/gcc/config/rs6000/sysv4.h +--- gcc-20050116.orig/gcc/config/rs6000/sysv4.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/rs6000/sysv4.h 2005-01-17 01:26:39.126999460 +0000 +@@ -1131,7 +1131,7 @@ + + #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}" ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}}}" + + #if defined(HAVE_LD_EH_FRAME_HDR) + # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " +@@ -1162,7 +1162,7 @@ + + #define LINK_OS_GNU_SPEC "-m elf32ppclinux %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}}}" ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}}}" + + #define CPP_OS_GNU_SPEC "-D__unix__ -D__gnu_hurd__ -D__GNU__ \ + %{!undef: \ +diff -Naur gcc-20050116.orig/gcc/config/s390/linux.h gcc-20050116/gcc/config/s390/linux.h +--- gcc-20050116.orig/gcc/config/s390/linux.h 2005-01-17 00:45:17.000000000 +0000 ++++ gcc-20050116/gcc/config/s390/linux.h 2005-01-17 01:26:58.672523211 +0000 +@@ -86,8 +86,8 @@ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker: \ +- %{m31:-dynamic-linker /lib/ld.so.1} \ +- %{m64:-dynamic-linker /lib/ld64.so.1}}}}" ++ %{m31:-dynamic-linker /tools/lib/ld.so.1} \ ++ %{m64:-dynamic-linker /tools/lib/ld64.so.1}}}}" + + + #define TARGET_ASM_FILE_END file_end_indicate_exec_stack +diff -Naur gcc-20050116.orig/gcc/config/sh/linux.h gcc-20050116/gcc/config/sh/linux.h +--- gcc-20050116.orig/gcc/config/sh/linux.h 2005-01-17 00:45:18.000000000 +0000 ++++ gcc-20050116/gcc/config/sh/linux.h 2005-01-17 01:27:19.588663163 +0000 +@@ -70,7 +70,7 @@ + "%{shared:-shared} \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \ + %{static:-static}" + + #undef LIB_SPEC +diff -Naur gcc-20050116.orig/gcc/config/sparc/linux.h gcc-20050116/gcc/config/sparc/linux.h +--- gcc-20050116.orig/gcc/config/sparc/linux.h 2005-01-17 00:45:18.000000000 +0000 ++++ gcc-20050116/gcc/config/sparc/linux.h 2005-01-17 01:30:07.282688639 +0000 +@@ -131,13 +131,13 @@ + /* If ELF is the default format, we should not use /lib/elf. */ + + #undef LINK_SPEC +-#define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \ ++#define LINK_SPEC "-m elf32_sparc -Y P,/tools/lib %{shared:-shared} \ + %{!mno-relax:%{!r:-relax}} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \ + %{static:-static}}}" + + /* The sun bundled assembler doesn't accept -Yd, (and neither does gas). +diff -Naur gcc-20050116.orig/gcc/config/sparc/linux64.h gcc-20050116/gcc/config/sparc/linux64.h +--- gcc-20050116.orig/gcc/config/sparc/linux64.h 2005-01-17 00:45:18.000000000 +0000 ++++ gcc-20050116/gcc/config/sparc/linux64.h 2005-01-17 01:31:18.242712476 +0000 +@@ -167,21 +167,21 @@ + { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \ + { "link_arch", LINK_ARCH_SPEC }, + +-#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \ ++#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/tools/lib %{shared:-shared} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld-linux.so.2}} \ + %{static:-static}}} \ + " + +-#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \ ++#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/tools/lib64 %{shared:-shared} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib64/ld-linux.so.2}} \ + %{static:-static}}} \ + " + +@@ -257,12 +257,12 @@ + #else /* !SPARC_BI_ARCH */ + + #undef LINK_SPEC +-#define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \ ++#define LINK_SPEC "-m elf64_sparc -Y P,/tools/lib64 %{shared:-shared} \ + %{!shared: \ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib64/ld-linux.so.2}} \ + %{static:-static}}} \ + %{mlittle-endian:-EL} \ + %{!mno-relax:%{!r:-relax}} \ +diff -Naur gcc-20050116.orig/gcc/config/xtensa/linux.h gcc-20050116/gcc/config/xtensa/linux.h +--- gcc-20050116.orig/gcc/config/xtensa/linux.h 2005-01-17 00:45:18.000000000 +0000 ++++ gcc-20050116/gcc/config/xtensa/linux.h 2005-01-17 01:32:08.951429623 +0000 +@@ -50,7 +50,7 @@ + %{!ibcs: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +- %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \ ++ %{!dynamic-linker:-dynamic-linker /tools/lib/ld.so.1}} \ + %{static:-static}}}" + + #undef LOCAL_LABEL_PREFIX diff --git a/src/patches/glibc-2.3.6-inotify-1.patch b/src/patches/glibc-2.3.6-inotify-1.patch new file mode 100644 index 0000000000..30af30c500 --- /dev/null +++ b/src/patches/glibc-2.3.6-inotify-1.patch @@ -0,0 +1,45 @@ +Submitted By: Dan Nicholson +Date: 2006-09-01 +Initial Package Version: 2.3.6 +Origin: udev-096, syscall functions generated by Alexander E. Patrakov +Upstream Status: Added to syscall list in 2.4 +Description: Adds inotify syscall functions for use in userspace. Minimal + syscall functions borrowed from udev local implementation to + provide system inotify support. +Testcase: dovecot-1.0rc2, ./configure --with-notify=inotify + +diff -pNur glibc-2.3.6.orig/sysdeps/unix/sysv/linux/inotify.h glibc-2.3.6/sysdeps/unix/sysv/linux/inotify.h +--- glibc-2.3.6.orig/sysdeps/unix/sysv/linux/inotify.h 1970-01-01 00:00:00.000000000 +0000 ++++ glibc-2.3.6/sysdeps/unix/sysv/linux/inotify.h 2006-08-01 05:48:27.000000000 +0000 +@@ -0,0 +1,31 @@ ++/* ++ * Inode based directory notification for Linux ++ * ++ * Copyright (C) 2005 John McCutchan ++ */ ++ ++#ifndef _SYS_INOTIFY_H ++#define _SYS_INOTIFY_H ++ ++#include ++#include ++#include ++ ++extern long int syscall (long int __sysno, ...) __THROW; ++ ++static inline int inotify_init(void) ++{ ++ return syscall(__NR_inotify_init); ++} ++ ++static inline int inotify_add_watch(int fd, const char *name, uint32_t mask) ++{ ++ return syscall(__NR_inotify_add_watch, fd, name, mask); ++} ++ ++static inline int inotify_rm_watch (int fd, uint32_t wd) ++{ ++ return syscall(__NR_inotify_rm_watch, fd, wd); ++} ++ ++#endif /* _SYS_INOTIFY_H */ diff --git a/src/patches/glibc-2.3.6-linux_types-1.patch b/src/patches/glibc-2.3.6-linux_types-1.patch new file mode 100644 index 0000000000..a365b81d8e --- /dev/null +++ b/src/patches/glibc-2.3.6-linux_types-1.patch @@ -0,0 +1,33 @@ +Submitted By: DJ Lucas +Date: 2006-04-05 +Initial Package Version: 2.3.6 +Upstream Status: Committed +Origin: Glibc CVS +Description: Fixes build errors where linux/types.h is included after sys/kd.h. + +diff -Naur glibc-2.3.6-orig/sysdeps/unix/sysv/linux/sys/kd.h glibc-2.3.6/sysdeps/unix/sysv/linux/sys/kd.h +--- glibc-2.3.6-orig/sysdeps/unix/sysv/linux/sys/kd.h 2001-07-05 23:56:21.000000000 -0500 ++++ glibc-2.3.6/sysdeps/unix/sysv/linux/sys/kd.h 2006-04-04 21:40:50.000000000 -0500 +@@ -1,4 +1,4 @@ +-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. ++/* Copyright (C) 1996, 1997, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or +@@ -21,9 +21,15 @@ + + /* Make sure the header is not loaded. */ + #ifndef _LINUX_TYPES_H +-# define _LINUX_TYPES_H 1 ++# define _LINUX_TYPES_H 1 ++# define __undef_LINUX_TYPES_H + #endif + + #include + ++#ifdef __undef_LINUX_TYPES_H ++# undef _LINUX_TYPES_H ++# undef __undef_LINUX_TYPES_H ++#endif ++ + #endif /* sys/kd.h */ diff --git a/src/patches/grep-2.5.1a-redhat_fixes-2.patch b/src/patches/grep-2.5.1a-redhat_fixes-2.patch new file mode 100644 index 0000000000..9c30342299 --- /dev/null +++ b/src/patches/grep-2.5.1a-redhat_fixes-2.patch @@ -0,0 +1,2109 @@ +Submitted by: Alexander E. Patrakov +Date: 2005-08-13 +Initial Package Version: 2.5.1a +Upstream Status: Partially accepted, partially rejected, but required for LSB >= 2.0 certification +Origin: RedHat +Description: Various fixes from RedHat. Individual patches: + + grep-2.5.1-fgrep.patch + grep-2.5.1-bracket.patch + grep-2.5-i18n.patch + grep-2.5.1-oi.patch + grep-2.5.1-manpage.patch + grep-2.5.1-color.patch + grep-2.5.1-icolor.patch + grep-2.5.1-egf-speedup.patch + grep-2.5.1-dfa-optional.patch + grep-2.5.1-tests.patch + grep-2.5.1-w.patch + +Testcases: + + -fgrep: ???, but required for other patches + -bracket: echo "[" | LANG=en_US.UTF-8 grep "[[:space:]]" + -i18n: many fixes for multibyte locale support, required for LSB. + -oi: echo xxYYzz | LANG=C grep -i -o yy + -manpage: typo + -color: restore the background color correctly + -icolor: ??? echo 'spam foo SPAM FOO' | grep -i --color spam + (but that's also fixed by -oi. Is this patch just a cleanup?) + -egf-speedup: without this, grep is as slow as a snail in UTF-8 locales. + -dfa-optional: disables dfa in multibyte locales by default. + -w: (echo 'foo';echo 'fo') > /tmp/testfile && grep -F -w fo /tmp/testfile + +diff -urN grep-2.5.1a.orig/doc/grep.1 grep-2.5.1a/doc/grep.1 +--- grep-2.5.1a.orig/doc/grep.1 2004-11-12 16:26:37.000000000 +0500 ++++ grep-2.5.1a/doc/grep.1 2005-10-23 09:49:43.000000000 +0600 +@@ -191,6 +191,7 @@ + .I PATTERN + as a list of fixed strings, separated by newlines, + any of which is to be matched. ++.TP + .BR \-P ", " \-\^\-perl-regexp + Interpret + .I PATTERN +@@ -302,7 +303,7 @@ + This is especially useful for tools like zgrep, e.g. + .B "gzip -cd foo.gz |grep --label=foo something" + .TP +-.BR \-\^\-line-buffering ++.BR \-\^\-line-buffered + Use line buffering, it can be a performance penality. + .TP + .BR \-q ", " \-\^\-quiet ", " \-\^\-silent +diff -urN grep-2.5.1a.orig/lib/posix/regex.h grep-2.5.1a/lib/posix/regex.h +--- grep-2.5.1a.orig/lib/posix/regex.h 2001-04-02 23:56:50.000000000 +0600 ++++ grep-2.5.1a/lib/posix/regex.h 2005-10-23 09:49:31.000000000 +0600 +@@ -109,6 +109,10 @@ + If not set, \{, \}, {, and } are literals. */ + #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) + ++/* If this bit is set, then ignore case when matching. ++ If not set, then case is significant. */ ++#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) ++ + /* If this bit is set, +, ? and | aren't recognized as operators. + If not set, they are. */ + #define RE_LIMITED_OPS (RE_INTERVALS << 1) +diff -urN grep-2.5.1a.orig/src/dfa.c grep-2.5.1a/src/dfa.c +--- grep-2.5.1a.orig/src/dfa.c 2001-09-26 22:57:55.000000000 +0600 ++++ grep-2.5.1a/src/dfa.c 2005-10-23 09:49:17.000000000 +0600 +@@ -414,7 +414,7 @@ + + /* This function fetch a wide character, and update cur_mb_len, + used only if the current locale is a multibyte environment. */ +-static wchar_t ++static wint_t + fetch_wc (char const *eoferr) + { + wchar_t wc; +@@ -423,7 +423,7 @@ + if (eoferr != 0) + dfaerror (eoferr); + else +- return -1; ++ return WEOF; + } + + cur_mb_len = mbrtowc(&wc, lexptr, lexleft, &mbs); +@@ -459,7 +459,7 @@ + static void + parse_bracket_exp_mb () + { +- wchar_t wc, wc1, wc2; ++ wint_t wc, wc1, wc2; + + /* Work area to build a mb_char_classes. */ + struct mb_char_classes *work_mbc; +@@ -496,7 +496,7 @@ + work_mbc->invert = 0; + do + { +- wc1 = -1; /* mark wc1 is not initialized". */ ++ wc1 = WEOF; /* mark wc1 is not initialized". */ + + /* Note that if we're looking at some other [:...:] construct, + we just treat it as a bunch of ordinary characters. We can do +@@ -586,7 +586,7 @@ + work_mbc->coll_elems[work_mbc->ncoll_elems++] = elem; + } + } +- wc = -1; ++ wc1 = wc = WEOF; + } + else + /* We treat '[' as a normal character here. */ +@@ -600,7 +600,7 @@ + wc = fetch_wc(("Unbalanced [")); + } + +- if (wc1 == -1) ++ if (wc1 == WEOF) + wc1 = fetch_wc(_("Unbalanced [")); + + if (wc1 == L'-') +@@ -630,17 +630,17 @@ + } + REALLOC_IF_NECESSARY(work_mbc->range_sts, wchar_t, + range_sts_al, work_mbc->nranges + 1); +- work_mbc->range_sts[work_mbc->nranges] = wc; ++ work_mbc->range_sts[work_mbc->nranges] = (wchar_t)wc; + REALLOC_IF_NECESSARY(work_mbc->range_ends, wchar_t, + range_ends_al, work_mbc->nranges + 1); +- work_mbc->range_ends[work_mbc->nranges++] = wc2; ++ work_mbc->range_ends[work_mbc->nranges++] = (wchar_t)wc2; + } +- else if (wc != -1) ++ else if (wc != WEOF) + /* build normal characters. */ + { + REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al, + work_mbc->nchars + 1); +- work_mbc->chars[work_mbc->nchars++] = wc; ++ work_mbc->chars[work_mbc->nchars++] = (wchar_t)wc; + } + } + while ((wc = wc1) != L']'); +@@ -2552,6 +2552,8 @@ + } + + /* match with a character? */ ++ if (case_fold) ++ wc = towlower (wc); + for (i = 0; inchars; i++) + { + if (wc == work_mbc->chars[i]) +diff -urN grep-2.5.1a.orig/src/grep.c grep-2.5.1a/src/grep.c +--- grep-2.5.1a.orig/src/grep.c 2004-11-12 16:25:35.000000000 +0500 ++++ grep-2.5.1a/src/grep.c 2005-10-23 09:50:06.000000000 +0600 +@@ -30,6 +30,12 @@ + # include + # include + #endif ++#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC ++/* We can handle multibyte string. */ ++# define MBS_SUPPORT ++# include ++# include ++#endif + #include + #include "system.h" + #include "getopt.h" +@@ -558,33 +564,6 @@ + { + size_t match_size; + size_t match_offset; +- if(match_icase) +- { +- /* Yuck, this is tricky */ +- char *buf = (char*) xmalloc (lim - beg); +- char *ibeg = buf; +- char *ilim = ibeg + (lim - beg); +- int i; +- for (i = 0; i < lim - beg; i++) +- ibeg[i] = tolower (beg[i]); +- while ((match_offset = (*execute) (ibeg, ilim-ibeg, &match_size, 1)) +- != (size_t) -1) +- { +- char const *b = beg + match_offset; +- if (b == lim) +- break; +- fwrite (beg, sizeof (char), match_offset, stdout); +- printf ("\33[%sm", grep_color); +- fwrite (b, sizeof (char), match_size, stdout); +- fputs ("\33[00m", stdout); +- beg = b + match_size; +- ibeg = ibeg + match_offset + match_size; +- } +- fwrite (beg, 1, lim - beg, stdout); +- free (buf); +- lastout = lim; +- return; +- } + while (lim-beg && (match_offset = (*execute) (beg, lim - beg, &match_size, 1)) + != (size_t) -1) + { +@@ -601,6 +580,7 @@ + fputs ("\33[00m", stdout); + beg = b + match_size; + } ++ fputs ("\33[K", stdout); + } + fwrite (beg, 1, lim - beg, stdout); + if (ferror (stdout)) +@@ -1697,6 +1677,37 @@ + if (!install_matcher (matcher) && !install_matcher ("default")) + abort (); + ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX != 1 && match_icase) ++ { ++ wchar_t wc; ++ mbstate_t cur_state, prev_state; ++ int i, len = strlen(keys); ++ ++ memset(&cur_state, 0, sizeof(mbstate_t)); ++ for (i = 0; i <= len ;) ++ { ++ size_t mbclen; ++ mbclen = mbrtowc(&wc, keys + i, len - i, &cur_state); ++ if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0) ++ { ++ /* An invalid sequence, or a truncated multibyte character. ++ We treat it as a singlebyte character. */ ++ mbclen = 1; ++ } ++ else ++ { ++ if (iswupper((wint_t)wc)) ++ { ++ wc = towlower((wint_t)wc); ++ wcrtomb(keys + i, wc, &cur_state); ++ } ++ } ++ i += mbclen; ++ } ++ } ++#endif /* MBS_SUPPORT */ ++ + (*compile)(keys, keycc); + + if ((argc - optind > 1 && !no_filenames) || with_filenames) +diff -urN grep-2.5.1a.orig/src/search.c grep-2.5.1a/src/search.c +--- grep-2.5.1a.orig/src/search.c 2001-04-19 09:42:14.000000000 +0600 ++++ grep-2.5.1a/src/search.c 2005-10-23 09:51:25.000000000 +0600 +@@ -18,9 +18,13 @@ + + /* Written August 1992 by Mike Haertel. */ + ++#ifndef _GNU_SOURCE ++# define _GNU_SOURCE 1 ++#endif + #ifdef HAVE_CONFIG_H + # include + #endif ++#include + #include + #if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC + /* We can handle multibyte string. */ +@@ -31,7 +35,7 @@ + + #include "system.h" + #include "grep.h" +-#include "regex.h" ++#include + #include "dfa.h" + #include "kwset.h" + #include "error.h" +@@ -39,6 +43,9 @@ + #ifdef HAVE_LIBPCRE + # include + #endif ++#ifdef HAVE_LANGINFO_CODESET ++# include ++#endif + + #define NCHAR (UCHAR_MAX + 1) + +@@ -70,9 +77,10 @@ + call the regexp matcher at all. */ + static int kwset_exact_matches; + +-#if defined(MBS_SUPPORT) +-static char* check_multibyte_string PARAMS ((char const *buf, size_t size)); +-#endif ++/* UTF-8 encoding allows some optimizations that we can't otherwise ++ assume in a multibyte encoding. */ ++static int using_utf8; ++ + static void kwsinit PARAMS ((void)); + static void kwsmusts PARAMS ((void)); + static void Gcompile PARAMS ((char const *, size_t)); +@@ -84,6 +92,15 @@ + static size_t Pexecute PARAMS ((char const *, size_t, size_t *, int)); + + void ++check_utf8 (void) ++{ ++#ifdef HAVE_LANGINFO_CODESET ++ if (strcmp (nl_langinfo (CODESET), "UTF-8") == 0) ++ using_utf8 = 1; ++#endif ++} ++ ++void + dfaerror (char const *mesg) + { + error (2, 0, mesg); +@@ -141,38 +158,6 @@ + } + } + +-#ifdef MBS_SUPPORT +-/* This function allocate the array which correspond to "buf". +- Then this check multibyte string and mark on the positions which +- are not singlebyte character nor the first byte of a multibyte +- character. Caller must free the array. */ +-static char* +-check_multibyte_string(char const *buf, size_t size) +-{ +- char *mb_properties = malloc(size); +- mbstate_t cur_state; +- int i; +- memset(&cur_state, 0, sizeof(mbstate_t)); +- memset(mb_properties, 0, sizeof(char)*size); +- for (i = 0; i < size ;) +- { +- size_t mbclen; +- mbclen = mbrlen(buf + i, size - i, &cur_state); +- +- if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0) +- { +- /* An invalid sequence, or a truncated multibyte character. +- We treat it as a singlebyte character. */ +- mbclen = 1; +- } +- mb_properties[i] = mbclen; +- i += mbclen; +- } +- +- return mb_properties; +-} +-#endif +- + static void + Gcompile (char const *pattern, size_t size) + { +@@ -181,7 +166,8 @@ + size_t total = size; + char const *motif = pattern; + +- re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE); ++ check_utf8 (); ++ re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE | (match_icase ? RE_ICASE : 0)); + dfasyntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE, match_icase, eolbyte); + + /* For GNU regex compiler we have to pass the patterns separately to detect +@@ -233,7 +219,7 @@ + static char const line_end[] = "\\)$"; + static char const word_beg[] = "\\(^\\|[^[:alnum:]_]\\)\\("; + static char const word_end[] = "\\)\\([^[:alnum:]_]\\|$\\)"; +- char *n = malloc (sizeof word_beg - 1 + size + sizeof word_end); ++ char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end); + size_t i; + strcpy (n, match_lines ? line_beg : word_beg); + i = strlen (n); +@@ -257,14 +243,15 @@ + size_t total = size; + char const *motif = pattern; + ++ check_utf8 (); + if (strcmp (matcher, "awk") == 0) + { +- re_set_syntax (RE_SYNTAX_AWK); ++ re_set_syntax (RE_SYNTAX_AWK | (match_icase ? RE_ICASE : 0)); + dfasyntax (RE_SYNTAX_AWK, match_icase, eolbyte); + } + else + { +- re_set_syntax (RE_SYNTAX_POSIX_EGREP); ++ re_set_syntax (RE_SYNTAX_POSIX_EGREP | (match_icase ? RE_ICASE : 0)); + dfasyntax (RE_SYNTAX_POSIX_EGREP, match_icase, eolbyte); + } + +@@ -316,7 +303,7 @@ + static char const line_end[] = ")$"; + static char const word_beg[] = "(^|[^[:alnum:]_])("; + static char const word_end[] = ")([^[:alnum:]_]|$)"; +- char *n = malloc (sizeof word_beg - 1 + size + sizeof word_end); ++ char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end); + size_t i; + strcpy (n, match_lines ? line_beg : word_beg); + i = strlen(n); +@@ -339,15 +326,35 @@ + char eol = eolbyte; + int backref, start, len; + struct kwsmatch kwsm; +- size_t i; ++ size_t i, ret_val; ++ static int use_dfa; ++ static int use_dfa_checked = 0; + #ifdef MBS_SUPPORT +- char *mb_properties = NULL; ++ const char *last_char = NULL; ++ int mb_cur_max = MB_CUR_MAX; ++ mbstate_t mbs; ++ memset (&mbs, '\0', sizeof (mbstate_t)); + #endif /* MBS_SUPPORT */ + ++ if (!use_dfa_checked) ++ { ++ char *grep_use_dfa = getenv ("GREP_USE_DFA"); ++ if (!grep_use_dfa) ++ { + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1 && kwset) +- mb_properties = check_multibyte_string(buf, size); ++ /* Turn off DFA when processing multibyte input. */ ++ use_dfa = (MB_CUR_MAX == 1); ++#else ++ use_dfa = 1; + #endif /* MBS_SUPPORT */ ++ } ++ else ++ { ++ use_dfa = atoi (grep_use_dfa); ++ } ++ ++ use_dfa_checked = 1; ++ } + + buflim = buf + size; + +@@ -358,47 +365,124 @@ + if (kwset) + { + /* Find a possible match using the KWset matcher. */ +- size_t offset = kwsexec (kwset, beg, buflim - beg, &kwsm); ++#ifdef MBS_SUPPORT ++ size_t bytes_left = 0; ++#endif /* MBS_SUPPORT */ ++ size_t offset; ++#ifdef MBS_SUPPORT ++ /* kwsexec doesn't work with match_icase and multibyte input. */ ++ if (match_icase && mb_cur_max > 1) ++ /* Avoid kwset */ ++ offset = 0; ++ else ++#endif /* MBS_SUPPORT */ ++ offset = kwsexec (kwset, beg, buflim - beg, &kwsm); + if (offset == (size_t) -1) +- { ++ goto failure; + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1) +- free(mb_properties); +-#endif +- return (size_t)-1; ++ if (mb_cur_max > 1 && !using_utf8) ++ { ++ bytes_left = offset; ++ while (bytes_left) ++ { ++ size_t mlen = mbrlen (beg, bytes_left, &mbs); ++ ++ last_char = beg; ++ if (mlen == (size_t) -1 || mlen == 0) ++ { ++ /* Incomplete character: treat as single-byte. */ ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ beg++; ++ bytes_left--; ++ continue; ++ } ++ ++ if (mlen == (size_t) -2) ++ /* Offset points inside multibyte character: ++ * no good. */ ++ break; ++ ++ beg += mlen; ++ bytes_left -= mlen; ++ } + } ++ else ++#endif /* MBS_SUPPORT */ + beg += offset; + /* Narrow down to the line containing the candidate, and + run it through DFA. */ + end = memchr(beg, eol, buflim - beg); + end++; + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1 && mb_properties[beg - buf] == 0) ++ if (mb_cur_max > 1 && bytes_left) + continue; +-#endif ++#endif /* MBS_SUPPORT */ + while (beg > buf && beg[-1] != eol) + --beg; +- if (kwsm.index < kwset_exact_matches) +- goto success; +- if (dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1) ++ if ( ++#ifdef MBS_SUPPORT ++ !(match_icase && mb_cur_max > 1) && ++#endif /* MBS_SUPPORT */ ++ (kwsm.index < kwset_exact_matches)) ++ goto success_in_beg_and_end; ++ if (use_dfa && ++ dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1) + continue; + } + else + { + /* No good fixed strings; start with DFA. */ +- size_t offset = dfaexec (&dfa, beg, buflim - beg, &backref); ++#ifdef MBS_SUPPORT ++ size_t bytes_left = 0; ++#endif /* MBS_SUPPORT */ ++ size_t offset = 0; ++ if (use_dfa) ++ offset = dfaexec (&dfa, beg, buflim - beg, &backref); + if (offset == (size_t) -1) + break; + /* Narrow down to the line we've found. */ ++#ifdef MBS_SUPPORT ++ if (mb_cur_max > 1 && !using_utf8) ++ { ++ bytes_left = offset; ++ while (bytes_left) ++ { ++ size_t mlen = mbrlen (beg, bytes_left, &mbs); ++ ++ last_char = beg; ++ if (mlen == (size_t) -1 || mlen == 0) ++ { ++ /* Incomplete character: treat as single-byte. */ ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ beg++; ++ bytes_left--; ++ continue; ++ } ++ ++ if (mlen == (size_t) -2) ++ /* Offset points inside multibyte character: ++ * no good. */ ++ break; ++ ++ beg += mlen; ++ bytes_left -= mlen; ++ } ++ } ++ else ++#endif /* MBS_SUPPORT */ + beg += offset; + end = memchr (beg, eol, buflim - beg); + end++; ++#ifdef MBS_SUPPORT ++ if (mb_cur_max > 1 && bytes_left) ++ continue; ++#endif /* MBS_SUPPORT */ + while (beg > buf && beg[-1] != eol) + --beg; + } + /* Successful, no backreferences encountered! */ +- if (!backref) +- goto success; ++ if (use_dfa && !backref) ++ goto success_in_beg_and_end; + } + else + end = beg + size; +@@ -413,14 +497,11 @@ + end - beg - 1, &(patterns[i].regs)))) + { + len = patterns[i].regs.end[0] - start; +- if (exact) +- { +- *match_size = len; +- return start; +- } ++ if (exact && !match_words) ++ goto success_in_start_and_len; + if ((!match_lines && !match_words) + || (match_lines && len == end - beg - 1)) +- goto success; ++ goto success_in_beg_and_end; + /* If -w, check if the match aligns with word boundaries. + We do this iteratively because: + (a) the line may contain more than one occurence of the +@@ -431,10 +512,84 @@ + if (match_words) + while (start >= 0) + { +- if ((start == 0 || !WCHAR ((unsigned char) beg[start - 1])) +- && (len == end - beg - 1 +- || !WCHAR ((unsigned char) beg[start + len]))) +- goto success; ++ int lword_match = 0; ++ if (start == 0) ++ lword_match = 1; ++ else ++ { ++ assert (start > 0); ++#ifdef MBS_SUPPORT ++ if (mb_cur_max > 1) ++ { ++ const char *s; ++ int mr; ++ wchar_t pwc; ++ ++ if (using_utf8) ++ { ++ s = beg + start - 1; ++ while (s > buf ++ && (unsigned char) *s >= 0x80 ++ && (unsigned char) *s <= 0xbf) ++ --s; ++ } ++ else ++ s = last_char; ++ mr = mbtowc (&pwc, s, beg + start - s); ++ if (mr <= 0) ++ { ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ lword_match = 1; ++ } ++ else if (!(iswalnum (pwc) || pwc == L'_') ++ && mr == (int) (beg + start - s)) ++ lword_match = 1; ++ } ++ else ++#endif /* MBS_SUPPORT */ ++ if (!WCHAR ((unsigned char) beg[start - 1])) ++ lword_match = 1; ++ } ++ ++ if (lword_match) ++ { ++ int rword_match = 0; ++ if (start + len == end - beg - 1) ++ rword_match = 1; ++ else ++ { ++#ifdef MBS_SUPPORT ++ if (mb_cur_max > 1) ++ { ++ wchar_t nwc; ++ int mr; ++ ++ mr = mbtowc (&nwc, beg + start + len, ++ end - beg - start - len - 1); ++ if (mr <= 0) ++ { ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ rword_match = 1; ++ } ++ else if (!iswalnum (nwc) && nwc != L'_') ++ rword_match = 1; ++ } ++ else ++#endif /* MBS_SUPPORT */ ++ if (!WCHAR ((unsigned char) beg[start + len])) ++ rword_match = 1; ++ } ++ ++ if (rword_match) ++ { ++ if (!exact) ++ /* Returns the whole line. */ ++ goto success_in_beg_and_end; ++ else ++ /* Returns just this word match. */ ++ goto success_in_start_and_len; ++ } ++ } + if (len > 0) + { + /* Try a shorter length anchored at the same place. */ +@@ -461,26 +616,154 @@ + } + } /* for Regex patterns. */ + } /* for (beg = end ..) */ +-#ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1 && mb_properties) +- free (mb_properties); +-#endif /* MBS_SUPPORT */ ++ ++ failure: + return (size_t) -1; + +- success: +-#ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1 && mb_properties) +- free (mb_properties); +-#endif /* MBS_SUPPORT */ +- *match_size = end - beg; +- return beg - buf; ++ success_in_beg_and_end: ++ len = end - beg; ++ start = beg - buf; ++ /* FALLTHROUGH */ ++ ++ success_in_start_and_len: ++ *match_size = len; ++ return start; + } + ++#ifdef MBS_SUPPORT ++static int f_i_multibyte; /* whether we're using the new -Fi MB method */ ++static struct ++{ ++ wchar_t **patterns; ++ size_t count, maxlen; ++ unsigned char *match; ++} Fimb; ++#endif ++ + static void + Fcompile (char const *pattern, size_t size) + { ++ int mb_cur_max = MB_CUR_MAX; + char const *beg, *lim, *err; + ++ check_utf8 (); ++#ifdef MBS_SUPPORT ++ /* Support -F -i for UTF-8 input. */ ++ if (match_icase && mb_cur_max > 1) ++ { ++ mbstate_t mbs; ++ wchar_t *wcpattern = xmalloc ((size + 1) * sizeof (wchar_t)); ++ const char *patternend = pattern; ++ size_t wcsize; ++ kwset_t fimb_kwset = NULL; ++ char *starts = NULL; ++ wchar_t *wcbeg, *wclim; ++ size_t allocated = 0; ++ ++ memset (&mbs, '\0', sizeof (mbs)); ++# ifdef __GNU_LIBRARY__ ++ wcsize = mbsnrtowcs (wcpattern, &patternend, size, size, &mbs); ++ if (patternend != pattern + size) ++ wcsize = (size_t) -1; ++# else ++ { ++ char *patterncopy = xmalloc (size + 1); ++ ++ memcpy (patterncopy, pattern, size); ++ patterncopy[size] = '\0'; ++ patternend = patterncopy; ++ wcsize = mbsrtowcs (wcpattern, &patternend, size, &mbs); ++ if (patternend != patterncopy + size) ++ wcsize = (size_t) -1; ++ free (patterncopy); ++ } ++# endif ++ if (wcsize + 2 <= 2) ++ { ++fimb_fail: ++ free (wcpattern); ++ free (starts); ++ if (fimb_kwset) ++ kwsfree (fimb_kwset); ++ free (Fimb.patterns); ++ Fimb.patterns = NULL; ++ } ++ else ++ { ++ if (!(fimb_kwset = kwsalloc (NULL))) ++ error (2, 0, _("memory exhausted")); ++ ++ starts = xmalloc (mb_cur_max * 3); ++ wcbeg = wcpattern; ++ do ++ { ++ int i; ++ size_t wclen; ++ ++ if (Fimb.count >= allocated) ++ { ++ if (allocated == 0) ++ allocated = 128; ++ else ++ allocated *= 2; ++ Fimb.patterns = xrealloc (Fimb.patterns, ++ sizeof (wchar_t *) * allocated); ++ } ++ Fimb.patterns[Fimb.count++] = wcbeg; ++ for (wclim = wcbeg; ++ wclim < wcpattern + wcsize && *wclim != L'\n'; ++wclim) ++ *wclim = towlower (*wclim); ++ *wclim = L'\0'; ++ wclen = wclim - wcbeg; ++ if (wclen > Fimb.maxlen) ++ Fimb.maxlen = wclen; ++ if (wclen > 3) ++ wclen = 3; ++ if (wclen == 0) ++ { ++ if ((err = kwsincr (fimb_kwset, "", 0)) != 0) ++ error (2, 0, err); ++ } ++ else ++ for (i = 0; i < (1 << wclen); i++) ++ { ++ char *p = starts; ++ int j, k; ++ ++ for (j = 0; j < wclen; ++j) ++ { ++ wchar_t wc = wcbeg[j]; ++ if (i & (1 << j)) ++ { ++ wc = towupper (wc); ++ if (wc == wcbeg[j]) ++ continue; ++ } ++ k = wctomb (p, wc); ++ if (k <= 0) ++ goto fimb_fail; ++ p += k; ++ } ++ if ((err = kwsincr (fimb_kwset, starts, p - starts)) != 0) ++ error (2, 0, err); ++ } ++ if (wclim < wcpattern + wcsize) ++ ++wclim; ++ wcbeg = wclim; ++ } ++ while (wcbeg < wcpattern + wcsize); ++ f_i_multibyte = 1; ++ kwset = fimb_kwset; ++ free (starts); ++ Fimb.match = xmalloc (Fimb.count); ++ if ((err = kwsprep (kwset)) != 0) ++ error (2, 0, err); ++ return; ++ } ++ } ++#endif /* MBS_SUPPORT */ ++ ++ + kwsinit (); + beg = pattern; + do +@@ -499,6 +782,76 @@ + error (2, 0, err); + } + ++#ifdef MBS_SUPPORT ++static int ++Fimbexec (const char *buf, size_t size, size_t *plen, int exact) ++{ ++ size_t len, letter, i; ++ int ret = -1; ++ mbstate_t mbs; ++ wchar_t wc; ++ int patterns_left; ++ ++ assert (match_icase && f_i_multibyte == 1); ++ assert (MB_CUR_MAX > 1); ++ ++ memset (&mbs, '\0', sizeof (mbs)); ++ memset (Fimb.match, '\1', Fimb.count); ++ letter = len = 0; ++ patterns_left = 1; ++ while (patterns_left && len <= size) ++ { ++ size_t c; ++ ++ patterns_left = 0; ++ if (len < size) ++ { ++ c = mbrtowc (&wc, buf + len, size - len, &mbs); ++ if (c + 2 <= 2) ++ return ret; ++ ++ wc = towlower (wc); ++ } ++ else ++ { ++ c = 1; ++ wc = L'\0'; ++ } ++ ++ for (i = 0; i < Fimb.count; i++) ++ { ++ if (Fimb.match[i]) ++ { ++ if (Fimb.patterns[i][letter] == L'\0') ++ { ++ /* Found a match. */ ++ *plen = len; ++ if (!exact && !match_words) ++ return 0; ++ else ++ { ++ /* For -w or exact look for longest match. */ ++ ret = 0; ++ Fimb.match[i] = '\0'; ++ continue; ++ } ++ } ++ ++ if (Fimb.patterns[i][letter] == wc) ++ patterns_left = 1; ++ else ++ Fimb.match[i] = '\0'; ++ } ++ } ++ ++ len += c; ++ letter++; ++ } ++ ++ return ret; ++} ++#endif /* MBS_SUPPORT */ ++ + static size_t + Fexecute (char const *buf, size_t size, size_t *match_size, int exact) + { +@@ -506,88 +859,268 @@ + register size_t len; + char eol = eolbyte; + struct kwsmatch kwsmatch; ++ size_t ret_val; + #ifdef MBS_SUPPORT +- char *mb_properties; +- if (MB_CUR_MAX > 1) +- mb_properties = check_multibyte_string (buf, size); ++ int mb_cur_max = MB_CUR_MAX; ++ mbstate_t mbs; ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ const char *last_char = NULL; + #endif /* MBS_SUPPORT */ + + for (beg = buf; beg <= buf + size; ++beg) + { +- size_t offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch); ++ size_t offset; ++ offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch); ++ + if (offset == (size_t) -1) +- { ++ goto failure; + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1) +- free(mb_properties); +-#endif /* MBS_SUPPORT */ +- return offset; ++ if (mb_cur_max > 1 && !using_utf8) ++ { ++ size_t bytes_left = offset; ++ while (bytes_left) ++ { ++ size_t mlen = mbrlen (beg, bytes_left, &mbs); ++ ++ last_char = beg; ++ if (mlen == (size_t) -1 || mlen == 0) ++ { ++ /* Incomplete character: treat as single-byte. */ ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ beg++; ++ bytes_left--; ++ continue; ++ } ++ ++ if (mlen == (size_t) -2) ++ /* Offset points inside multibyte character: no good. */ ++ break; ++ ++ beg += mlen; ++ bytes_left -= mlen; ++ } ++ ++ if (bytes_left) ++ continue; + } +-#ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1 && mb_properties[offset+beg-buf] == 0) +- continue; /* It is a part of multibyte character. */ ++ else + #endif /* MBS_SUPPORT */ + beg += offset; +- len = kwsmatch.size[0]; +- if (exact) +- { +- *match_size = len; + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1) +- free (mb_properties); ++ /* For f_i_multibyte, the string at beg now matches first 3 chars of ++ one of the search strings (less if there are shorter search strings). ++ See if this is a real match. */ ++ if (f_i_multibyte ++ && Fimbexec (beg, buf + size - beg, &kwsmatch.size[0], exact)) ++ goto next_char; + #endif /* MBS_SUPPORT */ +- return beg - buf; +- } ++ len = kwsmatch.size[0]; ++ if (exact && !match_words) ++ goto success_in_beg_and_len; + if (match_lines) + { + if (beg > buf && beg[-1] != eol) +- continue; ++ goto next_char; + if (beg + len < buf + size && beg[len] != eol) +- continue; ++ goto next_char; + goto success; + } + else if (match_words) +- for (try = beg; len; ) +- { +- if (try > buf && WCHAR((unsigned char) try[-1])) +- break; +- if (try + len < buf + size && WCHAR((unsigned char) try[len])) +- { +- offset = kwsexec (kwset, beg, --len, &kwsmatch); +- if (offset == (size_t) -1) +- { ++ { ++ while (len) ++ { ++ int word_match = 0; ++ if (beg > buf) ++ { + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1) +- free (mb_properties); ++ if (mb_cur_max > 1) ++ { ++ const char *s; ++ int mr; ++ wchar_t pwc; ++ ++ if (using_utf8) ++ { ++ s = beg - 1; ++ while (s > buf ++ && (unsigned char) *s >= 0x80 ++ && (unsigned char) *s <= 0xbf) ++ --s; ++ } ++ else ++ s = last_char; ++ mr = mbtowc (&pwc, s, beg - s); ++ if (mr <= 0) ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ else if ((iswalnum (pwc) || pwc == L'_') ++ && mr == (int) (beg - s)) ++ goto next_char; ++ } ++ else + #endif /* MBS_SUPPORT */ +- return offset; +- } +- try = beg + offset; +- len = kwsmatch.size[0]; +- } +- else +- goto success; +- } ++ if (WCHAR ((unsigned char) beg[-1])) ++ goto next_char; ++ } ++#ifdef MBS_SUPPORT ++ if (mb_cur_max > 1) ++ { ++ wchar_t nwc; ++ int mr; ++ ++ mr = mbtowc (&nwc, beg + len, buf + size - beg - len); ++ if (mr <= 0) ++ { ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ word_match = 1; ++ } ++ else if (!iswalnum (nwc) && nwc != L'_') ++ word_match = 1; ++ } ++ else ++#endif /* MBS_SUPPORT */ ++ if (beg + len >= buf + size || !WCHAR ((unsigned char) beg[len])) ++ word_match = 1; ++ if (word_match) ++ { ++ if (!exact) ++ /* Returns the whole line now we know there's a word match. */ ++ goto success; ++ else ++ /* Returns just this word match. */ ++ goto success_in_beg_and_len; ++ } ++ if (len > 0) ++ { ++ /* Try a shorter length anchored at the same place. */ ++ --len; ++ offset = kwsexec (kwset, beg, len, &kwsmatch); ++ ++ if (offset == -1) ++ goto next_char; /* Try a different anchor. */ ++#ifdef MBS_SUPPORT ++ if (mb_cur_max > 1 && !using_utf8) ++ { ++ size_t bytes_left = offset; ++ while (bytes_left) ++ { ++ size_t mlen = mbrlen (beg, bytes_left, &mbs); ++ ++ last_char = beg; ++ if (mlen == (size_t) -1 || mlen == 0) ++ { ++ /* Incomplete character: treat as single-byte. */ ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ beg++; ++ bytes_left--; ++ continue; ++ } ++ ++ if (mlen == (size_t) -2) ++ { ++ /* Offset points inside multibyte character: ++ * no good. */ ++ break; ++ } ++ ++ beg += mlen; ++ bytes_left -= mlen; ++ } ++ ++ if (bytes_left) ++ { ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ goto next_char; /* Try a different anchor. */ ++ } ++ } ++ else ++#endif /* MBS_SUPPORT */ ++ beg += offset; ++#ifdef MBS_SUPPORT ++ /* The string at beg now matches first 3 chars of one of ++ the search strings (less if there are shorter search ++ strings). See if this is a real match. */ ++ if (f_i_multibyte ++ && Fimbexec (beg, len - offset, &kwsmatch.size[0], ++ exact)) ++ goto next_char; ++#endif /* MBS_SUPPORT */ ++ len = kwsmatch.size[0]; ++ } ++ } ++ } + else + goto success; +- } +- ++next_char:; + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1) +- free (mb_properties); ++ /* Advance to next character. For MB_CUR_MAX == 1 case this is handled ++ by ++beg above. */ ++ if (mb_cur_max > 1) ++ { ++ if (using_utf8) ++ { ++ unsigned char c = *beg; ++ if (c >= 0xc2) ++ { ++ if (c < 0xe0) ++ ++beg; ++ else if (c < 0xf0) ++ beg += 2; ++ else if (c < 0xf8) ++ beg += 3; ++ else if (c < 0xfc) ++ beg += 4; ++ else if (c < 0xfe) ++ beg += 5; ++ } ++ } ++ else ++ { ++ size_t l = mbrlen (beg, buf + size - beg, &mbs); ++ ++ last_char = beg; ++ if (l + 2 >= 2) ++ beg += l - 1; ++ else ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ } ++ } + #endif /* MBS_SUPPORT */ ++ } ++ ++ failure: + return -1; + + success: ++#ifdef MBS_SUPPORT ++ if (mb_cur_max > 1 && !using_utf8) ++ { ++ end = beg + len; ++ while (end < buf + size) ++ { ++ size_t mlen = mbrlen (end, buf + size - end, &mbs); ++ if (mlen == (size_t) -1 || mlen == (size_t) -2 || mlen == 0) ++ { ++ memset (&mbs, '\0', sizeof (mbstate_t)); ++ mlen = 1; ++ } ++ if (mlen == 1 && *end == eol) ++ break; ++ ++ end += mlen; ++ } ++ } ++ else ++#endif /* MBS_SUPPORT */ + end = memchr (beg + len, eol, (buf + size) - (beg + len)); ++ + end++; + while (buf < beg && beg[-1] != eol) + --beg; +- *match_size = end - beg; +-#ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1) +- free (mb_properties); +-#endif /* MBS_SUPPORT */ ++ len = end - beg; ++ /* FALLTHROUGH */ ++ ++ success_in_beg_and_len: ++ *match_size = len; + return beg - buf; + } + +diff -urN grep-2.5.1a.orig/src/search.c.orig grep-2.5.1a/src/search.c.orig +--- grep-2.5.1a.orig/src/search.c.orig 1970-01-01 05:00:00.000000000 +0500 ++++ grep-2.5.1a/src/search.c.orig 2005-10-23 09:48:39.000000000 +0600 +@@ -0,0 +1,714 @@ ++/* search.c - searching subroutines using dfa, kwset and regex for grep. ++ Copyright 1992, 1998, 2000 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 program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ++ 02111-1307, USA. */ ++ ++/* Written August 1992 by Mike Haertel. */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++#include ++#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC ++/* We can handle multibyte string. */ ++# define MBS_SUPPORT ++# include ++# include ++#endif ++ ++#include "system.h" ++#include "grep.h" ++#include "regex.h" ++#include "dfa.h" ++#include "kwset.h" ++#include "error.h" ++#include "xalloc.h" ++#ifdef HAVE_LIBPCRE ++# include ++#endif ++ ++#define NCHAR (UCHAR_MAX + 1) ++ ++/* For -w, we also consider _ to be word constituent. */ ++#define WCHAR(C) (ISALNUM(C) || (C) == '_') ++ ++/* DFA compiled regexp. */ ++static struct dfa dfa; ++ ++/* The Regex compiled patterns. */ ++static struct patterns ++{ ++ /* Regex compiled regexp. */ ++ struct re_pattern_buffer regexbuf; ++ struct re_registers regs; /* This is here on account of a BRAIN-DEAD ++ Q@#%!# library interface in regex.c. */ ++} patterns0; ++ ++struct patterns *patterns; ++size_t pcount; ++ ++/* KWset compiled pattern. For Ecompile and Gcompile, we compile ++ a list of strings, at least one of which is known to occur in ++ any string matching the regexp. */ ++static kwset_t kwset; ++ ++/* Number of compiled fixed strings known to exactly match the regexp. ++ If kwsexec returns < kwset_exact_matches, then we don't need to ++ call the regexp matcher at all. */ ++static int kwset_exact_matches; ++ ++#if defined(MBS_SUPPORT) ++static char* check_multibyte_string PARAMS ((char const *buf, size_t size)); ++#endif ++static void kwsinit PARAMS ((void)); ++static void kwsmusts PARAMS ((void)); ++static void Gcompile PARAMS ((char const *, size_t)); ++static void Ecompile PARAMS ((char const *, size_t)); ++static size_t EGexecute PARAMS ((char const *, size_t, size_t *, int )); ++static void Fcompile PARAMS ((char const *, size_t)); ++static size_t Fexecute PARAMS ((char const *, size_t, size_t *, int)); ++static void Pcompile PARAMS ((char const *, size_t )); ++static size_t Pexecute PARAMS ((char const *, size_t, size_t *, int)); ++ ++void ++dfaerror (char const *mesg) ++{ ++ error (2, 0, mesg); ++} ++ ++static void ++kwsinit (void) ++{ ++ static char trans[NCHAR]; ++ int i; ++ ++ if (match_icase) ++ for (i = 0; i < NCHAR; ++i) ++ trans[i] = TOLOWER (i); ++ ++ if (!(kwset = kwsalloc (match_icase ? trans : (char *) 0))) ++ error (2, 0, _("memory exhausted")); ++} ++ ++/* If the DFA turns out to have some set of fixed strings one of ++ which must occur in the match, then we build a kwset matcher ++ to find those strings, and thus quickly filter out impossible ++ matches. */ ++static void ++kwsmusts (void) ++{ ++ struct dfamust const *dm; ++ char const *err; ++ ++ if (dfa.musts) ++ { ++ kwsinit (); ++ /* First, we compile in the substrings known to be exact ++ matches. The kwset matcher will return the index ++ of the matching string that it chooses. */ ++ for (dm = dfa.musts; dm; dm = dm->next) ++ { ++ if (!dm->exact) ++ continue; ++ ++kwset_exact_matches; ++ if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0) ++ error (2, 0, err); ++ } ++ /* Now, we compile the substrings that will require ++ the use of the regexp matcher. */ ++ for (dm = dfa.musts; dm; dm = dm->next) ++ { ++ if (dm->exact) ++ continue; ++ if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0) ++ error (2, 0, err); ++ } ++ if ((err = kwsprep (kwset)) != 0) ++ error (2, 0, err); ++ } ++} ++ ++#ifdef MBS_SUPPORT ++/* This function allocate the array which correspond to "buf". ++ Then this check multibyte string and mark on the positions which ++ are not singlebyte character nor the first byte of a multibyte ++ character. Caller must free the array. */ ++static char* ++check_multibyte_string(char const *buf, size_t size) ++{ ++ char *mb_properties = malloc(size); ++ mbstate_t cur_state; ++ int i; ++ memset(&cur_state, 0, sizeof(mbstate_t)); ++ memset(mb_properties, 0, sizeof(char)*size); ++ for (i = 0; i < size ;) ++ { ++ size_t mbclen; ++ mbclen = mbrlen(buf + i, size - i, &cur_state); ++ ++ if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0) ++ { ++ /* An invalid sequence, or a truncated multibyte character. ++ We treat it as a singlebyte character. */ ++ mbclen = 1; ++ } ++ mb_properties[i] = mbclen; ++ i += mbclen; ++ } ++ ++ return mb_properties; ++} ++#endif ++ ++static void ++Gcompile (char const *pattern, size_t size) ++{ ++ const char *err; ++ char const *sep; ++ size_t total = size; ++ char const *motif = pattern; ++ ++ re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE); ++ dfasyntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE, match_icase, eolbyte); ++ ++ /* For GNU regex compiler we have to pass the patterns separately to detect ++ errors like "[\nallo\n]\n". The patterns here are "[", "allo" and "]" ++ GNU regex should have raise a syntax error. The same for backref, where ++ the backref should have been local to each pattern. */ ++ do ++ { ++ size_t len; ++ sep = memchr (motif, '\n', total); ++ if (sep) ++ { ++ len = sep - motif; ++ sep++; ++ total -= (len + 1); ++ } ++ else ++ { ++ len = total; ++ total = 0; ++ } ++ ++ patterns = realloc (patterns, (pcount + 1) * sizeof (*patterns)); ++ if (patterns == NULL) ++ error (2, errno, _("memory exhausted")); ++ ++ patterns[pcount] = patterns0; ++ ++ if ((err = re_compile_pattern (motif, len, ++ &(patterns[pcount].regexbuf))) != 0) ++ error (2, 0, err); ++ pcount++; ++ ++ motif = sep; ++ } while (sep && total != 0); ++ ++ /* In the match_words and match_lines cases, we use a different pattern ++ for the DFA matcher that will quickly throw out cases that won't work. ++ Then if DFA succeeds we do some hairy stuff using the regex matcher ++ to decide whether the match should really count. */ ++ if (match_words || match_lines) ++ { ++ /* In the whole-word case, we use the pattern: ++ \(^\|[^[:alnum:]_]\)\(userpattern\)\([^[:alnum:]_]|$\). ++ In the whole-line case, we use the pattern: ++ ^\(userpattern\)$. */ ++ ++ static char const line_beg[] = "^\\("; ++ static char const line_end[] = "\\)$"; ++ static char const word_beg[] = "\\(^\\|[^[:alnum:]_]\\)\\("; ++ static char const word_end[] = "\\)\\([^[:alnum:]_]\\|$\\)"; ++ char *n = malloc (sizeof word_beg - 1 + size + sizeof word_end); ++ size_t i; ++ strcpy (n, match_lines ? line_beg : word_beg); ++ i = strlen (n); ++ memcpy (n + i, pattern, size); ++ i += size; ++ strcpy (n + i, match_lines ? line_end : word_end); ++ i += strlen (n + i); ++ pattern = n; ++ size = i; ++ } ++ ++ dfacomp (pattern, size, &dfa, 1); ++ kwsmusts (); ++} ++ ++static void ++Ecompile (char const *pattern, size_t size) ++{ ++ const char *err; ++ const char *sep; ++ size_t total = size; ++ char const *motif = pattern; ++ ++ if (strcmp (matcher, "awk") == 0) ++ { ++ re_set_syntax (RE_SYNTAX_AWK); ++ dfasyntax (RE_SYNTAX_AWK, match_icase, eolbyte); ++ } ++ else ++ { ++ re_set_syntax (RE_SYNTAX_POSIX_EGREP); ++ dfasyntax (RE_SYNTAX_POSIX_EGREP, match_icase, eolbyte); ++ } ++ ++ /* For GNU regex compiler we have to pass the patterns separately to detect ++ errors like "[\nallo\n]\n". The patterns here are "[", "allo" and "]" ++ GNU regex should have raise a syntax error. The same for backref, where ++ the backref should have been local to each pattern. */ ++ do ++ { ++ size_t len; ++ sep = memchr (motif, '\n', total); ++ if (sep) ++ { ++ len = sep - motif; ++ sep++; ++ total -= (len + 1); ++ } ++ else ++ { ++ len = total; ++ total = 0; ++ } ++ ++ patterns = realloc (patterns, (pcount + 1) * sizeof (*patterns)); ++ if (patterns == NULL) ++ error (2, errno, _("memory exhausted")); ++ patterns[pcount] = patterns0; ++ ++ if ((err = re_compile_pattern (motif, len, ++ &(patterns[pcount].regexbuf))) != 0) ++ error (2, 0, err); ++ pcount++; ++ ++ motif = sep; ++ } while (sep && total != 0); ++ ++ /* In the match_words and match_lines cases, we use a different pattern ++ for the DFA matcher that will quickly throw out cases that won't work. ++ Then if DFA succeeds we do some hairy stuff using the regex matcher ++ to decide whether the match should really count. */ ++ if (match_words || match_lines) ++ { ++ /* In the whole-word case, we use the pattern: ++ (^|[^[:alnum:]_])(userpattern)([^[:alnum:]_]|$). ++ In the whole-line case, we use the pattern: ++ ^(userpattern)$. */ ++ ++ static char const line_beg[] = "^("; ++ static char const line_end[] = ")$"; ++ static char const word_beg[] = "(^|[^[:alnum:]_])("; ++ static char const word_end[] = ")([^[:alnum:]_]|$)"; ++ char *n = malloc (sizeof word_beg - 1 + size + sizeof word_end); ++ size_t i; ++ strcpy (n, match_lines ? line_beg : word_beg); ++ i = strlen(n); ++ memcpy (n + i, pattern, size); ++ i += size; ++ strcpy (n + i, match_lines ? line_end : word_end); ++ i += strlen (n + i); ++ pattern = n; ++ size = i; ++ } ++ ++ dfacomp (pattern, size, &dfa, 1); ++ kwsmusts (); ++} ++ ++static size_t ++EGexecute (char const *buf, size_t size, size_t *match_size, int exact) ++{ ++ register char const *buflim, *beg, *end; ++ char eol = eolbyte; ++ int backref, start, len; ++ struct kwsmatch kwsm; ++ size_t i; ++#ifdef MBS_SUPPORT ++ char *mb_properties = NULL; ++#endif /* MBS_SUPPORT */ ++ ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1 && kwset) ++ mb_properties = check_multibyte_string(buf, size); ++#endif /* MBS_SUPPORT */ ++ ++ buflim = buf + size; ++ ++ for (beg = end = buf; end < buflim; beg = end) ++ { ++ if (!exact) ++ { ++ if (kwset) ++ { ++ /* Find a possible match using the KWset matcher. */ ++ size_t offset = kwsexec (kwset, beg, buflim - beg, &kwsm); ++ if (offset == (size_t) -1) ++ goto failure; ++ beg += offset; ++ /* Narrow down to the line containing the candidate, and ++ run it through DFA. */ ++ end = memchr(beg, eol, buflim - beg); ++ end++; ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1 && mb_properties[beg - buf] == 0) ++ continue; ++#endif ++ while (beg > buf && beg[-1] != eol) ++ --beg; ++ if (kwsm.index < kwset_exact_matches) ++ goto success_in_beg_and_end; ++ if (dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1) ++ continue; ++ } ++ else ++ { ++ /* No good fixed strings; start with DFA. */ ++ size_t offset = dfaexec (&dfa, beg, buflim - beg, &backref); ++ if (offset == (size_t) -1) ++ break; ++ /* Narrow down to the line we've found. */ ++ beg += offset; ++ end = memchr (beg, eol, buflim - beg); ++ end++; ++ while (beg > buf && beg[-1] != eol) ++ --beg; ++ } ++ /* Successful, no backreferences encountered! */ ++ if (!backref) ++ goto success_in_beg_and_end; ++ } ++ else ++ end = beg + size; ++ ++ /* If we've made it to this point, this means DFA has seen ++ a probable match, and we need to run it through Regex. */ ++ for (i = 0; i < pcount; i++) ++ { ++ patterns[i].regexbuf.not_eol = 0; ++ if (0 <= (start = re_search (&(patterns[i].regexbuf), beg, ++ end - beg - 1, 0, ++ end - beg - 1, &(patterns[i].regs)))) ++ { ++ len = patterns[i].regs.end[0] - start; ++ if (exact && !match_words) ++ goto success_in_start_and_len; ++ if ((!match_lines && !match_words) ++ || (match_lines && len == end - beg - 1)) ++ goto success_in_beg_and_end; ++ /* If -w, check if the match aligns with word boundaries. ++ We do this iteratively because: ++ (a) the line may contain more than one occurence of the ++ pattern, and ++ (b) Several alternatives in the pattern might be valid at a ++ given point, and we may need to consider a shorter one to ++ find a word boundary. */ ++ if (match_words) ++ while (start >= 0) ++ { ++ if ((start == 0 || !WCHAR ((unsigned char) beg[start - 1])) ++ && (len == end - beg - 1 ++ || !WCHAR ((unsigned char) beg[start + len]))) ++ goto success_in_beg_and_end; ++ if (len > 0) ++ { ++ /* Try a shorter length anchored at the same place. */ ++ --len; ++ patterns[i].regexbuf.not_eol = 1; ++ len = re_match (&(patterns[i].regexbuf), beg, ++ start + len, start, ++ &(patterns[i].regs)); ++ } ++ if (len <= 0) ++ { ++ /* Try looking further on. */ ++ if (start == end - beg - 1) ++ break; ++ ++start; ++ patterns[i].regexbuf.not_eol = 0; ++ start = re_search (&(patterns[i].regexbuf), beg, ++ end - beg - 1, ++ start, end - beg - 1 - start, ++ &(patterns[i].regs)); ++ len = patterns[i].regs.end[0] - start; ++ } ++ } ++ } ++ } /* for Regex patterns. */ ++ } /* for (beg = end ..) */ ++ ++ failure: ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1 && mb_properties) ++ free (mb_properties); ++#endif /* MBS_SUPPORT */ ++ return (size_t) -1; ++ ++ success_in_beg_and_end: ++ len = end - beg; ++ start = beg - buf; ++ /* FALLTHROUGH */ ++ ++ success_in_start_and_len: ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1 && mb_properties) ++ free (mb_properties); ++#endif /* MBS_SUPPORT */ ++ *match_size = len; ++ return start; ++} ++ ++static void ++Fcompile (char const *pattern, size_t size) ++{ ++ char const *beg, *lim, *err; ++ ++ kwsinit (); ++ beg = pattern; ++ do ++ { ++ for (lim = beg; lim < pattern + size && *lim != '\n'; ++lim) ++ ; ++ if ((err = kwsincr (kwset, beg, lim - beg)) != 0) ++ error (2, 0, err); ++ if (lim < pattern + size) ++ ++lim; ++ beg = lim; ++ } ++ while (beg < pattern + size); ++ ++ if ((err = kwsprep (kwset)) != 0) ++ error (2, 0, err); ++} ++ ++static size_t ++Fexecute (char const *buf, size_t size, size_t *match_size, int exact) ++{ ++ register char const *beg, *try, *end; ++ register size_t len; ++ char eol = eolbyte; ++ struct kwsmatch kwsmatch; ++#ifdef MBS_SUPPORT ++ char *mb_properties; ++ if (MB_CUR_MAX > 1) ++ mb_properties = check_multibyte_string (buf, size); ++#endif /* MBS_SUPPORT */ ++ ++ for (beg = buf; beg <= buf + size; ++beg) ++ { ++ size_t offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch); ++ if (offset == (size_t) -1) ++ goto failure; ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1 && mb_properties[offset+beg-buf] == 0) ++ continue; /* It is a part of multibyte character. */ ++#endif /* MBS_SUPPORT */ ++ beg += offset; ++ len = kwsmatch.size[0]; ++ if (exact && !match_words) ++ goto success_in_beg_and_len; ++ if (match_lines) ++ { ++ if (beg > buf && beg[-1] != eol) ++ continue; ++ if (beg + len < buf + size && beg[len] != eol) ++ continue; ++ goto success; ++ } ++ else if (match_words) ++ for (try = beg; len; ) ++ { ++ if (try > buf && WCHAR((unsigned char) try[-1])) ++ break; ++ if (try + len < buf + size && WCHAR((unsigned char) try[len])) ++ { ++ offset = kwsexec (kwset, beg, --len, &kwsmatch); ++ if (offset == (size_t) -1) ++ { ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1) ++ free (mb_properties); ++#endif /* MBS_SUPPORT */ ++ return offset; ++ } ++ try = beg + offset; ++ len = kwsmatch.size[0]; ++ } ++ else ++ goto success; ++ } ++ else ++ goto success; ++ } ++ ++ failure: ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1) ++ free (mb_properties); ++#endif /* MBS_SUPPORT */ ++ return -1; ++ ++ success: ++ end = memchr (beg + len, eol, (buf + size) - (beg + len)); ++ end++; ++ while (buf < beg && beg[-1] != eol) ++ --beg; ++ len = end - beg; ++ /* FALLTHROUGH */ ++ ++ success_in_beg_and_len: ++ *match_size = len; ++#ifdef MBS_SUPPORT ++ if (MB_CUR_MAX > 1) ++ free (mb_properties); ++#endif /* MBS_SUPPORT */ ++ return beg - buf; ++} ++ ++#if HAVE_LIBPCRE ++/* Compiled internal form of a Perl regular expression. */ ++static pcre *cre; ++ ++/* Additional information about the pattern. */ ++static pcre_extra *extra; ++#endif ++ ++static void ++Pcompile (char const *pattern, size_t size) ++{ ++#if !HAVE_LIBPCRE ++ error (2, 0, _("The -P option is not supported")); ++#else ++ int e; ++ char const *ep; ++ char *re = xmalloc (4 * size + 7); ++ int flags = PCRE_MULTILINE | (match_icase ? PCRE_CASELESS : 0); ++ char const *patlim = pattern + size; ++ char *n = re; ++ char const *p; ++ char const *pnul; ++ ++ /* FIXME: Remove this restriction. */ ++ if (eolbyte != '\n') ++ error (2, 0, _("The -P and -z options cannot be combined")); ++ ++ *n = '\0'; ++ if (match_lines) ++ strcpy (n, "^("); ++ if (match_words) ++ strcpy (n, "\\b("); ++ n += strlen (n); ++ ++ /* The PCRE interface doesn't allow NUL bytes in the pattern, so ++ replace each NUL byte in the pattern with the four characters ++ "\000", removing a preceding backslash if there are an odd ++ number of backslashes before the NUL. ++ ++ FIXME: This method does not work with some multibyte character ++ encodings, notably Shift-JIS, where a multibyte character can end ++ in a backslash byte. */ ++ for (p = pattern; (pnul = memchr (p, '\0', patlim - p)); p = pnul + 1) ++ { ++ memcpy (n, p, pnul - p); ++ n += pnul - p; ++ for (p = pnul; pattern < p && p[-1] == '\\'; p--) ++ continue; ++ n -= (pnul - p) & 1; ++ strcpy (n, "\\000"); ++ n += 4; ++ } ++ ++ memcpy (n, p, patlim - p); ++ n += patlim - p; ++ *n = '\0'; ++ if (match_words) ++ strcpy (n, ")\\b"); ++ if (match_lines) ++ strcpy (n, ")$"); ++ ++ cre = pcre_compile (re, flags, &ep, &e, pcre_maketables ()); ++ if (!cre) ++ error (2, 0, ep); ++ ++ extra = pcre_study (cre, 0, &ep); ++ if (ep) ++ error (2, 0, ep); ++ ++ free (re); ++#endif ++} ++ ++static size_t ++Pexecute (char const *buf, size_t size, size_t *match_size, int exact) ++{ ++#if !HAVE_LIBPCRE ++ abort (); ++ return -1; ++#else ++ /* This array must have at least two elements; everything after that ++ is just for performance improvement in pcre_exec. */ ++ int sub[300]; ++ ++ int e = pcre_exec (cre, extra, buf, size, 0, 0, ++ sub, sizeof sub / sizeof *sub); ++ ++ if (e <= 0) ++ { ++ switch (e) ++ { ++ case PCRE_ERROR_NOMATCH: ++ return -1; ++ ++ case PCRE_ERROR_NOMEMORY: ++ error (2, 0, _("Memory exhausted")); ++ ++ default: ++ abort (); ++ } ++ } ++ else ++ { ++ /* Narrow down to the line we've found. */ ++ char const *beg = buf + sub[0]; ++ char const *end = buf + sub[1]; ++ char const *buflim = buf + size; ++ char eol = eolbyte; ++ if (!exact) ++ { ++ end = memchr (end, eol, buflim - end); ++ end++; ++ while (buf < beg && beg[-1] != eol) ++ --beg; ++ } ++ ++ *match_size = end - beg; ++ return beg - buf; ++ } ++#endif ++} ++ ++struct matcher const matchers[] = { ++ { "default", Gcompile, EGexecute }, ++ { "grep", Gcompile, EGexecute }, ++ { "egrep", Ecompile, EGexecute }, ++ { "awk", Ecompile, EGexecute }, ++ { "fgrep", Fcompile, Fexecute }, ++ { "perl", Pcompile, Pexecute }, ++ { "", 0, 0 }, ++}; +diff -urN grep-2.5.1a.orig/tests/fmbtest.sh grep-2.5.1a/tests/fmbtest.sh +--- grep-2.5.1a.orig/tests/fmbtest.sh 1970-01-01 05:00:00.000000000 +0500 ++++ grep-2.5.1a/tests/fmbtest.sh 2005-10-23 09:51:12.000000000 +0600 +@@ -0,0 +1,111 @@ ++#!/bin/sh ++ ++: ${srcdir=.} ++ ++# If cs_CZ.UTF-8 locale doesn't work, skip this test silently ++LC_ALL=cs_CZ.UTF-8 locale -k LC_CTYPE 2>/dev/null | ${GREP} -q charmap.*UTF-8 \ ++ || exit 77 ++ ++failures=0 ++ ++cat > csinput < cspatfile <st_mode & 07777)) { ++ if (fchmod(ofd, ifstat->st_mode & 07777)) { + int e = errno; + WARN((stderr, "%s: ", progname)); + if (!quiet) { +@@ -1734,7 +1735,7 @@ + } + } + #ifndef NO_CHOWN +- chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */ ++ fchown(ofd, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */ + #endif + remove_ofname = 0; + /* It's now safe to remove the input file: */ diff --git a/src/patches/ncurses-5.5-fixes-1.patch b/src/patches/ncurses-5.5-fixes-1.patch new file mode 100644 index 0000000000..73e084d1c7 --- /dev/null +++ b/src/patches/ncurses-5.5-fixes-1.patch @@ -0,0 +1,225 @@ +Submitted by: Alexander E. Patrakov +Date: 2005-12-07 +Initial Package Version: 5.5 +Upstream Status: Backport +Origin: Cherry-picked from ftp://invisible-island.net/ncurses/5.5/*.gz +Description: Fixes the following bugs: + +* memory leak in keyname() +* mishandling of overlapped wide characters, http://bugs.debian.org/316663 +* problems with line-drawing characters on cygwin, http://bugs.debian.org/338234 +* mishandling of EINTR in tcgetattr/tcsetattr, http://bugs.debian.org/339518 +* mishandling of single-column multibyte characters, http://bugs.debian.org/341661 + +--- ncurses-5.5-20051015+/ncurses/base/MKkeyname.awk 2005-04-30 19:26:25.000000000 +0000 ++++ ncurses-5.5-20051022/ncurses/base/MKkeyname.awk 2005-10-22 19:01:23.000000000 +0000 +@@ -97,6 +97,7 @@ + print " break;" + print " }" + print " }" ++ print " free(bound);" + print " if (result != 0)" + print " break;" + print " }" +--- ncurses-5.5-20051022+/ncurses/base/lib_addch.c 2005-03-27 16:52:16.000000000 +0000 ++++ ncurses-5.5-20051029/ncurses/base/lib_addch.c 2005-10-30 00:51:36.000000000 +0000 +@@ -315,7 +315,7 @@ + * setup though. + */ + for (i = 0; i < len; ++i) { +- if (isWidecBase(win->_line[y].text[i])) { ++ if (isWidecBase(win->_line[y].text[x + i])) { + break; + } else if (isWidecExt(win->_line[y].text[x + i])) { + for (j = i; x + j <= win->_maxx; ++j) { +@@ -334,7 +334,9 @@ + for (i = 0; i < len; ++i) { + NCURSES_CH_T value = ch; + SetWidecExt(value, i); +- TR(TRACE_VIRTPUT, ("multicolumn %d:%d", i + 1, len)); ++ TR(TRACE_VIRTPUT, ("multicolumn %d:%d (%d,%d)", ++ i + 1, len, ++ win->_begy + y, win->_begx + x)); + line->text[x] = value; + CHANGED_CELL(line, x); + ++x; +--- ncurses-5.5-20051022+/ncurses/base/lib_bkgd.c 2005-04-16 18:03:48.000000000 +0000 ++++ ncurses-5.5-20051029/ncurses/base/lib_bkgd.c 2005-10-30 00:41:09.000000000 +0000 +@@ -131,11 +131,11 @@ + + for (y = 0; y <= win->_maxy; y++) { + for (x = 0; x <= win->_maxx; x++) { +- if (CharEq(win->_line[y].text[x], old_bkgrnd)) ++ if (CharEq(win->_line[y].text[x], old_bkgrnd)) { + win->_line[y].text[x] = win->_nc_bkgd; +- else { ++ } else { + NCURSES_CH_T wch = win->_line[y].text[x]; +- RemAttr(wch, (~A_ALTCHARSET)); ++ RemAttr(wch, (~(A_ALTCHARSET | A_CHARTEXT))); + win->_line[y].text[x] = _nc_render(win, wch); + } + } +--- ncurses-5.5-20051022+/ncurses/base/lib_erase.c 2001-12-19 01:06:13.000000000 +0000 ++++ ncurses-5.5-20051029/ncurses/base/lib_erase.c 2005-10-30 00:36:36.000000000 +0000 +@@ -58,6 +59,24 @@ + start = win->_line[y].text; + end = &start[win->_maxx]; + ++ /* ++ * If this is a derived window, we have to handle the case where ++ * a multicolumn character extends into the window that we are ++ * erasing. ++ */ ++ if_WIDEC({ ++ if (isWidecExt(start[0])) { ++ int x = (win->_parent != 0) ? (win->_begx) : 0; ++ while (x-- > 0) { ++ if (isWidecBase(start[-1])) { ++ --start; ++ break; ++ } ++ --start; ++ } ++ } ++ }); ++ + for (sp = start; sp <= end; sp++) + *sp = blank; + +--- ncurses-5.5-20051029+/misc/terminfo.src 2005-10-26 23:21:06.000000000 +0000 ++++ ncurses-5.5-20051112/misc/terminfo.src 2005-11-12 23:01:03.000000000 +0000 +@@ -4731,32 +4731,35 @@ + # civis [make cursor invisible] causes everything to stackdump? \E[?25l\E[?1c + # ech [erase characters param] broken \E[%p1%dX + # kcbt [back-tab key] not implemented in cygwin? \E[Z ++# ++# 2005/11/12 -TD ++# Remove cbt since it does not work in current cygwin ++# Add 'mir' and 'in' flags based on tack + cygwin|ansi emulation for Cygwin, +- am, hs, in, msgr, xon, ++ am, hs, mir, msgr, xon, + colors#8, it#8, pairs#64, + acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376, +- bel=^G, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J, cr=^M, +- cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B, +- cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, +- cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, +- dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, fsl=^G, +- home=\E[H, hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@, +- ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=^J, invis=\E[8m, +- kb2=\E[G, kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, +- kcuu1=\E[A, kdch1=\E[3~, kend=\E[4~, kf1=\E[[A, +- kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, +- kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, +- kf18=\E[32~, kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, +- kf3=\E[[C, kf4=\E[[D, kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, +- kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, +- knp=\E[6~, kpp=\E[5~, kspd=^Z, nel=^M^J, op=\E[39;49m, +- rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E[10m, +- rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmpch=\E[10m, +- rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7, +- setab=\E[4%p1%dm, setaf=\E[3%p1%dm, ++ bel=^G, bold=\E[1m, clear=\E[H\E[J, cr=^M, cub=\E[%p1%dD, ++ cub1=^H, cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, ++ cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, ++ cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, ++ dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, fsl=^G, home=\E[H, ++ hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@, ich1=\E[@, ++ il=\E[%p1%dL, il1=\E[L, ind=^J, invis=\E[8m, kb2=\E[G, ++ kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, ++ kdch1=\E[3~, kend=\E[4~, kf1=\E[[A, kf10=\E[21~, ++ kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, ++ kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, ++ kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, ++ kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, ++ khome=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, kspd=^Z, ++ nel=^M^J, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, ++ rmacs=\E[10m, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, ++ rmpch=\E[10m, rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, ++ sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, + sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, +- sgr0=\E[0;10m, smacs=\E11m, smcup=\E7\E[?47h, smir=\E[4h, +- smpch=\E[11m, smso=\E[7m, smul=\E[4m, tsl=\E];, ++ sgr0=\E[0;10m, smacs=\E[11m, smcup=\E7\E[?47h, ++ smir=\E[4h, smpch=\E[11m, smso=\E[7m, smul=\E[4m, tsl=\E];, + u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?6c, u9=\E[c, + vpa=\E[%i%p1%dd, + +--- ncurses-5.5-20051112+/ncurses/tinfo/lib_ttyflags.c 2003-05-17 23:50:37.000000000 +0000 ++++ ncurses-5.5-20051119/ncurses/tinfo/lib_ttyflags.c 2005-11-19 20:36:23.000000000 +0000 +@@ -59,28 +59,51 @@ + NCURSES_EXPORT(int) + _nc_get_tty_mode(TTY * buf) + { +- if (cur_term == 0 +- || GET_TTY(cur_term->Filedes, buf) != 0) { +- memset(buf, 0, sizeof(*buf)); +- return (ERR); ++ int result = OK; ++ ++ if (cur_term == 0) { ++ result = ERR; ++ } else { ++ for (;;) { ++ if (GET_TTY(cur_term->Filedes, buf) != 0) { ++ if (errno == EINTR) ++ continue; ++ result = ERR; ++ } ++ break; ++ } + } ++ ++ if (result == ERR) ++ memset(buf, 0, sizeof(*buf)); ++ + TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s", + cur_term->Filedes, _nc_trace_ttymode(buf))); +- return (OK); ++ return (result); + } + + NCURSES_EXPORT(int) + _nc_set_tty_mode(TTY * buf) + { +- if (cur_term == 0 +- || SET_TTY(cur_term->Filedes, buf) != 0) { +- if ((errno == ENOTTY) && (SP != 0)) +- SP->_notty = TRUE; +- return (ERR); ++ int result = OK; ++ ++ if (cur_term == 0) { ++ result = ERR; ++ } else { ++ for (;;) { ++ if (SET_TTY(cur_term->Filedes, buf) != 0) { ++ if (errno == EINTR) ++ continue; ++ if ((errno == ENOTTY) && (SP != 0)) ++ SP->_notty = TRUE; ++ result = ERR; ++ } ++ break; ++ } + } + TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s", + cur_term->Filedes, _nc_trace_ttymode(buf))); +- return (OK); ++ return (result); + } + + NCURSES_EXPORT(int) +--- ncurses-5.5-20051126+/ncurses/widechar/lib_ins_wch.c 2005-09-17 19:25:13.000000000 +0000 ++++ ncurses-5.5-20051203/ncurses/widechar/lib_ins_wch.c 2005-12-03 20:24:19.000000000 +0000 +@@ -117,7 +117,7 @@ + for (cp = wstr; *cp && ((cp - wstr) < n); cp++) { + int len = wcwidth(*cp); + +- if (len != 1) { ++ if (len != 1 || !is8bits(*cp)) { + cchar_t tmp_cchar; + wchar_t tmp_wchar = *cp; + memset(&tmp_cchar, 0, sizeof(tmp_cchar)); diff --git a/src/patches/perl-5.8.8-libc-2.patch b/src/patches/perl-5.8.8-libc-2.patch new file mode 100644 index 0000000000..f31910b18d --- /dev/null +++ b/src/patches/perl-5.8.8-libc-2.patch @@ -0,0 +1,32 @@ +Submitted By: Anderson Lizardo +Date: 2006-02-15 +Initial Package Version: 5.8.8 +Origin: based on current LFS-BOOK patch (perl-5.8.0-libc-2.patch) +Description: this patch adapts some hard-wired paths to the C library. + It uses the $prefix variable to locate the correct libc. + +diff -Naur perl-5.8.8.orig/hints/linux.sh perl-5.8.8/hints/linux.sh +--- perl-5.8.8.orig/hints/linux.sh 2005-11-18 01:18:45.000000000 +0000 ++++ perl-5.8.8/hints/linux.sh 2006-02-12 12:20:32.000000000 +0000 +@@ -52,9 +52,9 @@ + # We don't use __GLIBC__ and __GLIBC_MINOR__ because they + # are insufficiently precise to distinguish things like + # libc-2.0.6 and libc-2.0.7. +-if test -L /lib/libc.so.6; then +- libc=`ls -l /lib/libc.so.6 | awk '{print $NF}'` +- libc=/lib/$libc ++if test -L ${prefix}/lib/libc.so.6; then ++ libc=`ls -l ${prefix}/lib/libc.so.6 | awk '{print $NF}'` ++ libc=${prefix}/lib/$libc + fi + + # Configure may fail to find lstat() since it's a static/inline +@@ -330,3 +330,8 @@ + libswanted="$*" + ;; + esac ++ ++locincpth="" ++loclibpth="" ++glibpth="${prefix}/lib" ++usrinc="${prefix}/include" diff --git a/src/patches/tar-1.15.1-gcc4_fix_tests-1.patch b/src/patches/tar-1.15.1-gcc4_fix_tests-1.patch new file mode 100644 index 0000000000..5cebec0c33 --- /dev/null +++ b/src/patches/tar-1.15.1-gcc4_fix_tests-1.patch @@ -0,0 +1,25 @@ +Submitted By: Matthew Burgess +Date: 2005-07-15 +Initial Package Version: 1.15.1 +Upstream Status: From Upstream +Origin: Ryan Oliver +Description: Fixes a compilation problem with gcc-4.0.x that results in: + +genfile.c:63: error: static declaration of 'argp_program_version' follows non-static declaration +../lib/argp.h:428: error: previous declaration of 'argp_program_version' was here +genfile.c:64: error: static declaration of 'argp_program_bug_address' follows non-static declaration +../lib/argp.h:444: error: previous declaration of 'argp_program_bug_address' was here + +--- tar-1.15.1/tests/genfile.c-orig 2005-04-25 15:23:47.000000000 +1000 ++++ tar-1.15.1/tests/genfile.c 2005-04-25 15:24:08.000000000 +1000 +@@ -60,8 +60,8 @@ + /* Block buffer for sparse file */ + char *buffer; + +-static const char *argp_program_version = "genfile (" PACKAGE ") " VERSION; +-static const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; ++const char *argp_program_version = "genfile (" PACKAGE ") " VERSION; ++const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; + static char doc[] = N_("genfile generates data files for GNU paxutils test suite"); + + static struct argp_option options[] = { diff --git a/src/patches/tar-1.15.1-security_fixes-1.patch b/src/patches/tar-1.15.1-security_fixes-1.patch new file mode 100644 index 0000000000..085147e4c3 --- /dev/null +++ b/src/patches/tar-1.15.1-security_fixes-1.patch @@ -0,0 +1,128 @@ +Submitted By: Ken Moffat +Date: 2006-04-14 +Initial Package Version: 1.15.1 +Origin: gentoo, backported from CVS, rediffed to apply with -p1 +Description: addresses vulnerability CVE-2006-0300 + +diff -Naurp tar-1.15.1-vanilla/src/xheader.c tar-1.15.1/src/xheader.c +--- tar-1.15.1-vanilla/src/xheader.c 2004-09-06 12:31:14.000000000 +0100 ++++ tar-1.15.1/src/xheader.c 2006-04-14 16:26:26.000000000 +0100 +@@ -783,6 +783,32 @@ code_num (uintmax_t value, char const *k + xheader_print (xhdr, keyword, sbuf); + } + ++static bool ++decode_num (uintmax_t *num, char const *arg, uintmax_t maxval, ++ char const *keyword) ++{ ++ uintmax_t u; ++ char *arg_lim; ++ ++ if (! (ISDIGIT (*arg) ++ && (errno = 0, u = strtoumax (arg, &arg_lim, 10), !*arg_lim))) ++ { ++ ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), ++ keyword, arg)); ++ return false; ++ } ++ ++ if (! (u <= maxval && errno != ERANGE)) ++ { ++ ERROR ((0, 0, _("Extended header %s=%s is out of range"), ++ keyword, arg)); ++ return false; ++ } ++ ++ *num = u; ++ return true; ++} ++ + static void + dummy_coder (struct tar_stat_info const *st __attribute__ ((unused)), + char const *keyword __attribute__ ((unused)), +@@ -821,7 +847,7 @@ static void + gid_decoder (struct tar_stat_info *st, char const *arg) + { + uintmax_t u; +- if (xstrtoumax (arg, NULL, 10, &u, "") == LONGINT_OK) ++ if (decode_num (&u, arg, TYPE_MAXIMUM (gid_t), "gid")) + st->stat.st_gid = u; + } + +@@ -903,7 +929,7 @@ static void + size_decoder (struct tar_stat_info *st, char const *arg) + { + uintmax_t u; +- if (xstrtoumax (arg, NULL, 10, &u, "") == LONGINT_OK) ++ if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), "size")) + st->archive_file_size = st->stat.st_size = u; + } + +@@ -918,7 +944,7 @@ static void + uid_decoder (struct tar_stat_info *st, char const *arg) + { + uintmax_t u; +- if (xstrtoumax (arg, NULL, 10, &u, "") == LONGINT_OK) ++ if (decode_num (&u, arg, TYPE_MAXIMUM (uid_t), "uid")) + st->stat.st_uid = u; + } + +@@ -946,7 +972,7 @@ static void + sparse_size_decoder (struct tar_stat_info *st, char const *arg) + { + uintmax_t u; +- if (xstrtoumax (arg, NULL, 10, &u, "") == LONGINT_OK) ++ if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), "GNU.sparse.size")) + st->stat.st_size = u; + } + +@@ -962,10 +988,10 @@ static void + sparse_numblocks_decoder (struct tar_stat_info *st, char const *arg) + { + uintmax_t u; +- if (xstrtoumax (arg, NULL, 10, &u, "") == LONGINT_OK) ++ if (decode_num (&u, arg, SIZE_MAX, "GNU.sparse.numblocks")) + { + st->sparse_map_size = u; +- st->sparse_map = calloc(st->sparse_map_size, sizeof(st->sparse_map[0])); ++ st->sparse_map = xcalloc (u, sizeof st->sparse_map[0]); + st->sparse_map_avail = 0; + } + } +@@ -982,8 +1008,14 @@ static void + sparse_offset_decoder (struct tar_stat_info *st, char const *arg) + { + uintmax_t u; +- if (xstrtoumax (arg, NULL, 10, &u, "") == LONGINT_OK) ++ if (decode_num (&u, arg, TYPE_MAXIMUM (off_t), "GNU.sparse.offset")) ++ { ++ if (st->sparse_map_avail < st->sparse_map_size) + st->sparse_map[st->sparse_map_avail].offset = u; ++ else ++ ERROR ((0, 0, _("Malformed extended header: excess %s=%s"), ++ "GNU.sparse.offset", arg)); ++ } + } + + static void +@@ -998,15 +1030,13 @@ static void + sparse_numbytes_decoder (struct tar_stat_info *st, char const *arg) + { + uintmax_t u; +- if (xstrtoumax (arg, NULL, 10, &u, "") == LONGINT_OK) ++ if (decode_num (&u, arg, SIZE_MAX, "GNU.sparse.numbytes")) + { + if (st->sparse_map_avail == st->sparse_map_size) +- { +- st->sparse_map_size *= 2; +- st->sparse_map = xrealloc (st->sparse_map, +- st->sparse_map_size +- * sizeof st->sparse_map[0]); +- } ++ st->sparse_map = x2nrealloc (st->sparse_map, ++ &st->sparse_map_size, ++ sizeof st->sparse_map[0]); ++ + st->sparse_map[st->sparse_map_avail++].numbytes = u; + } + } diff --git a/src/patches/tar-1.15.1-sparse_fix-1.patch b/src/patches/tar-1.15.1-sparse_fix-1.patch new file mode 100644 index 0000000000..f8a361306f --- /dev/null +++ b/src/patches/tar-1.15.1-sparse_fix-1.patch @@ -0,0 +1,26 @@ +Submitted By: Jim Gifford (patches at jg555 dot com) +Date: 2005-03-19 +Initial Package Version: 1.15.1 +Origin: Tar Bug Reports List +Upstream Status: Applied +Description: Fixes large file corruptions using option -S + http://lists.gnu.org/archive/html/bug-tar/2005-03/msg00004.html +--- tar-1.15.1/src/sparse.c.orig 2005-03-20 04:23:34.144506120 +0000 ++++ tar-1.15.1/src/sparse.c 2005-03-20 04:23:56.842055568 +0000 +@@ -1,6 +1,6 @@ + /* Functions for dealing with sparse files + +- Copyright (C) 2003, 2004 Free Software Foundation, Inc. ++ Copyright (C) 2003, 2004, 2005 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 +@@ -182,7 +182,7 @@ + { + static char buffer[BLOCKSIZE]; + size_t count; +- size_t offset = 0; ++ off_t offset = 0; + struct sp_array sp = {0, 0}; + + if (!lseek_or_error (file, 0, SEEK_SET)) diff --git a/src/patches/texinfo-4.8-multibyte-1.patch b/src/patches/texinfo-4.8-multibyte-1.patch new file mode 100644 index 0000000000..4676a792bc --- /dev/null +++ b/src/patches/texinfo-4.8-multibyte-1.patch @@ -0,0 +1,44 @@ +Submitted By: Alexander E. Patrakov +Date: 2005-07-12 +Initial Package Version: 4.8 +Upstream Status: Hack, won't submit +Origin: Alexander E. Patrakov +Description: Info assumes that a string width in character cells is the +same as its length in bytes. This patch avoids cases when this assumption +is not true. + +diff -ur texinfo-4.8/info/info.c texinfo-4.8.hacked/info/info.c +--- texinfo-4.8/info/info.c 2004-04-11 23:56:45.000000000 +0600 ++++ texinfo-4.8.hacked/info/info.c 2005-07-12 12:11:34.852485776 +0600 +@@ -154,6 +154,10 @@ + #ifdef HAVE_SETLOCALE + /* Set locale via LC_ALL. */ + setlocale (LC_ALL, ""); ++ /* But don't use translated messages in the case when ++ string width and length can differ */ ++ if (MB_CUR_MAX > 1) ++ setlocale(LC_MESSAGES, "C"); + #endif + + #ifdef ENABLE_NLS +diff -ur texinfo-4.8/info/man.c texinfo-4.8.hacked/info/man.c +--- texinfo-4.8/info/man.c 2004-04-11 23:56:46.000000000 +0600 ++++ texinfo-4.8.hacked/info/man.c 2005-07-12 12:08:40.267026800 +0600 +@@ -325,6 +325,17 @@ + freopen (NULL_DEVICE, "r", stdin); + dup2 (pipes[1], fileno (stdout)); + ++ if (MB_CUR_MAX > 1) ++ { ++ /* Info has trouble wrapping man output if it contains ++ multibyte characters */ ++ setenv("LANGUAGE", "C", 1); ++ setenv("LANG", "C", 1); ++ setenv("LC_MESSAGES", "C", 1); ++ setenv("LC_CTYPE", "C", 1); ++ setenv("LC_ALL", "C", 1); ++ } ++ + execv (formatter_args[0], formatter_args); + + /* If we get here, we couldn't exec, so close out the pipe and diff --git a/src/patches/texinfo-4.8-tempfile_fix-2.patch b/src/patches/texinfo-4.8-tempfile_fix-2.patch new file mode 100644 index 0000000000..0d0b59424d --- /dev/null +++ b/src/patches/texinfo-4.8-tempfile_fix-2.patch @@ -0,0 +1,80 @@ +Updated By: Bruce Dubbs (bdubbs -aT- linuxfromscratch -DoT- org) +Date: 2005-12-12 +Submitted By: Archaic (archaic -aT- linuxfromscratch -DoT- org) +Date: 2005-10-08 +Initial Package Version: 4.8 +Origin: http://gentoo.kems.net/gentoo-portage/sys-apps/texinfo/files/texinfo-4.8-tempfile.patch +Upstream Status: A few patches are floating around in Debian BZ #328365 of which + upstream hasn't made a full commitment on yet. +Description: (CAN-2005-3011) texindex in texinfo 4.8 and earlier allows local + users to overwrite arbitrary files via a symlink attack on + temporary files. +Update: Changed to not pass a constant string to mktemp(). + +diff -Naur texinfo-4.8.orig/util/texindex.c texinfo-4.8/util/texindex.c +--- texinfo-4.8.orig/util/texindex.c 2005-12-11 23:29:08.000000000 -0600 ++++ texinfo-4.8/util/texindex.c 2005-12-11 23:33:31.000000000 -0600 +@@ -99,6 +99,9 @@ + /* Directory to use for temporary files. On Unix, it ends with a slash. */ + char *tempdir; + ++/* Basename for temp files inside of tempdir. */ ++char *tempbase; ++ + /* Number of last temporary file. */ + int tempcount; + +@@ -153,6 +156,7 @@ + main (int argc, char **argv) + { + int i; ++ char template[]="txidxXXXXXX"; + + tempcount = 0; + last_deleted_tempcount = 0; +@@ -190,6 +194,11 @@ + + decode_command (argc, argv); + ++ /* XXX mkstemp not appropriate, as we need to have somewhat predictable ++ * names. But race condition was fixed, see maketempname. ++ */ ++ tempbase = mktemp (template); ++ + /* Process input files completely, one by one. */ + + for (i = 0; i < num_infiles; i++) +@@ -389,21 +398,21 @@ + static char * + maketempname (int count) + { +- static char *tempbase = NULL; + char tempsuffix[10]; +- +- if (!tempbase) +- { +- int fd; +- tempbase = concat (tempdir, "txidxXXXXXX"); +- +- fd = mkstemp (tempbase); +- if (fd == -1) +- pfatal_with_name (tempbase); +- } ++ char *name, *tmp_name; ++ int fd; + + sprintf (tempsuffix, ".%d", count); +- return concat (tempbase, tempsuffix); ++ tmp_name = concat (tempdir, tempbase); ++ name = concat (tmp_name, tempsuffix); ++ free(tmp_name); ++ ++ fd = open (name, O_CREAT|O_EXCL|O_WRONLY, 0600); ++ if (fd == -1) ++ pfatal_with_name (name); ++ ++ close(fd); ++ return name; + } + + diff --git a/src/patches/util-linux-2.12r-cramfs-1.patch b/src/patches/util-linux-2.12r-cramfs-1.patch new file mode 100644 index 0000000000..b8366b335e --- /dev/null +++ b/src/patches/util-linux-2.12r-cramfs-1.patch @@ -0,0 +1,93 @@ +Submitted by: Jeremy Utley +Date: 2004-12-25 +Initial Package Version: 2.12p (should apply to versions back to at least k) +Upstream Status: Not Submitted - Test Version +Origin: Alexander Patrakov, adapted from debian build of cramfs utilities +Description: Util-Linux fails in cramfs compilation due to changes in the +linux-libc-headers package 2.6.9 and after. This patch is a proper fix to the +problem, but may in fact not be accepted upstream. + + +diff -Naur util-linux-2.12p/disk-utils/fsck.cramfs.c util-linux-2.12p-new/disk-utils/fsck.cramfs.c +--- util-linux-2.12p/disk-utils/fsck.cramfs.c 2004-12-11 14:53:16.000000000 +0000 ++++ util-linux-2.12p-new/disk-utils/fsck.cramfs.c 2004-12-26 00:53:10.665199086 +0000 +@@ -76,16 +76,7 @@ + + #define PAD_SIZE 512 + +-#include +-#ifdef PAGE_SIZE +-#define PAGE_CACHE_SIZE ((int) PAGE_SIZE) +-#elif defined __ia64__ +-#define PAGE_CACHE_SIZE (16384) +-#elif defined __alpha__ +-#define PAGE_CACHE_SIZE (8192) +-#else +-#define PAGE_CACHE_SIZE (4096) +-#endif ++#define PAGE_CACHE_SIZE page_size + + /* Guarantee access to at least 8kB at a time */ + #define ROMBUFFER_BITS 13 +@@ -95,11 +86,13 @@ + static unsigned long read_buffer_block = ~0UL; + + /* Uncompressing data structures... */ +-static char outbuffer[PAGE_CACHE_SIZE*2]; ++static char *outbuffer; + z_stream stream; + + #endif /* INCLUDE_FS_TESTS */ + ++static size_t page_size; ++ + /* Input status of 0 to print help and exit without an error. */ + static void usage(int status) + { +@@ -464,9 +457,17 @@ + int c; /* for getopt */ + int start = 0; + ++ page_size = sysconf(_SC_PAGESIZE); ++ + if (argc) + progname = argv[0]; + ++ outbuffer = malloc(page_size * 2); ++ if (!outbuffer) { ++ fprintf(stderr, _("failed to allocate outbuffer\n")); ++ exit(8); ++ } ++ + /* command line options */ + while ((c = getopt(argc, argv, "hx:v")) != EOF) { + switch (c) { +diff -Naur util-linux-2.12p/disk-utils/mkfs.cramfs.c util-linux-2.12p-new/disk-utils/mkfs.cramfs.c +--- util-linux-2.12p/disk-utils/mkfs.cramfs.c 2004-12-11 14:56:01.000000000 +0000 ++++ util-linux-2.12p-new/disk-utils/mkfs.cramfs.c 2004-12-26 00:53:10.666198928 +0000 +@@ -46,16 +46,8 @@ + static const char *progname = "mkcramfs"; + static int verbose = 0; + +-#ifdef __ia64__ +-#define PAGE_CACHE_SIZE (16384) +-#elif defined __alpha__ +-#define PAGE_CACHE_SIZE (8192) +-#else +-#define PAGE_CACHE_SIZE (4096) +-#endif +- + /* The kernel assumes PAGE_CACHE_SIZE as block size. */ +-static unsigned int blksize = PAGE_CACHE_SIZE; /* settable via -b option */ ++static unsigned int blksize; /* settable via -b option */ + static long total_blocks = 0, total_nodes = 1; /* pre-count the root node */ + static int image_length = 0; + +@@ -730,6 +722,7 @@ + u32 crc = crc32(0L, Z_NULL, 0); + int c; + ++ blksize = sysconf(_SC_PAGESIZE); + total_blocks = 0; + + if (argc) { diff --git a/src/scripts/langcache b/src/scripts/langcache new file mode 100644 index 0000000000..359024b0fc --- /dev/null +++ b/src/scripts/langcache @@ -0,0 +1,9 @@ +#!/bin/bash +# +# IPFire SCRIPTs +# +# This code is distributed under the terms of the GPL +# +# (C) Benedikt Correll for IPFire + +perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" diff --git a/src/scripts/updatelang b/src/scripts/updatelang deleted file mode 100644 index 1f89044ecb..0000000000 --- a/src/scripts/updatelang +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# -# IPFire! GPLv2 -# - -perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" diff --git a/tools/version-check.sh b/tools/version-check.sh new file mode 100644 index 0000000000..4f92f42ae3 --- /dev/null +++ b/tools/version-check.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Einfaches Skript zum Auflisten der Versionsnummern wichtiger Werkzeuge + +echo "BENOETIGT - VORHANDEN" +echo -n "Bash-2.05a - " +bash --version | head -n1 | cut -d" " -f2-4 + +echo -n "Binutils-2.12 - " +echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-4 + +echo -n "Bzip2-1.0.2 - " +bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6- + +echo -n "Coreutils-5.0 - " +echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 + +echo -n "Diffutils-2.8 - " +diff --version | head -n1 + +echo -n "Findutils-4.1.20 - " +find --version | head -n1 + +echo -n "Gawk-3.0 - " +gawk --version | head -n1 + +echo -n "Gcc-2.95.3 - " +gcc --version | head -n1 + +echo -n "Glibc-2.2.5 - " +/lib/libc.so.6 | head -n1 | cut -d" " -f1-7 + +echo -n "Grep-2.5 - " +grep --version | head -n1 + +echo -n "Gzip-1.2.4 - " +gzip --version | head -n1 + +echo -n "Linux-Kernel-2.6 - " +cat /proc/version | head -n1 | cut -d" " -f1-3,5-7 + +echo -n "Make-3.79.1 - " +make --version | head -n1 + +echo -n "Patch-2.5.4 - " +patch --version | head -n1 + +echo -n "Sed-3.0.2 - " +sed --version | head -n1 + +echo -n "Tar-1.14 - " +tar --version | head -n1 -- 2.39.2