diff -u2rN sed-3.02/BUGS.MB sed-3.02+mb1.09/BUGS.MB --- sed-3.02/BUGS.MB Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/BUGS.MB Sun Nov 19 17:44:20 2000 @@ -0,0 +1,5 @@ +* KNOWN BUGS + +lコマンドによる改行処理を文字単位で行っている + + diff -u2rN sed-3.02/ChangeLog.MB sed-3.02+mb1.09/ChangeLog.MB --- sed-3.02/ChangeLog.MB Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/ChangeLog.MB Tue Nov 28 22:50:16 2000 @@ -0,0 +1,86 @@ +2000-11-28 okabe katsuyuki + + * Version 3.02 + multi-byte extension 1.09. + + * lib/regex.c: 以下の点を修正。 + "あ*[あ]" が "あ","ああ" などにマッチしない。 + "[あ]*[あ]" が "あ","ああ" などにマッチしない。 + "[^あ]*[い]" が "い","ない" などにマッチしない。 + (Thanks to 河村雅夫さん ) + * sed/sed.c: sedにて実行時には通常のsedと動作するように変更。 + +1999-06-19 okabe katsuyuki + + * Version 3.02 + multi-byte extension 1.08. + + * sed/compile.c (inchar): ファイルからの直接入力時、マルチバイト文字 + の取り込みが異常だったのを修正. (Thanks to しろおかさん + ) + +1999-04-29 okabe katsuyuki + + * Version 3.02 + multi-byte extension 1.07. + + * lib/xargs32.c (find_file): 指定されたパスが実は正規表現だったとき + などの不正なパス指定時のエラー処理がなされていなかったのを修正. + (Thanks to Bruceさん ) + +1999-03-04 okabe katsuyuki + + * sed/execute.c (do_subst): s コマンドの置換文字列で '\あ' のような + '\' + マルチバイト文字に対応していなかったのを修正. + +1999-02-23 okabe katsuyuki + + * Version 3.02 ベースへ移行. + + * UTF8 サポート. + + * EUC での JIS X 0212 サポート. + +1998-06-28 okabe katsuyuki + + * Version 2.05 + multi-byte extension 1.05. WIN32サポート版. + + * WIN32版の追加. + + * xargs32.[ch]をBruce.作 mawk for MBCS より借用. + +1998-06-25 okabe katsuyuki + + * Version 2.05 + multi-byte extension 1.05. + +1998-06-23 okabe katsuyuki + + * sed.c (execute_program): 置換後の文字列に'\'を含むマルチバイト文字 + があると結果がおかしくなるのを修正. (Thanks to しろおかさん + , Bruceさん ) + + * sed.c (execute_program): yコマンドにマルチバイト文字を使用したとき + 異常動作することがあるのを修正. (Thanks to 菅野さん + , ハッシーさん , しろお + かさん , Bruceさん , 渡 + 辺博文さん ) + + * sed.c (execute_program): 文字列とsコマンドの置換文字列の組み合わせ + によっては置換処理が行われないことがあるのを修正. (Thanks to しろお + かさん , Bruceさん , 渡 + 辺博文さん ) + +Thu Jan 29 00:50:55 1998 Katsuyuki Okabe (wills at x68k) + + * rx.c (csetbit): DEL のコードを '\127' のように記述していた. + (Thanks to しろおかさん ) + +Wed Dec 24 02:14:12 1997 Katsuyuki Okabe (wills at x68k) + + * Version 2.05 + multi-byte extension 1.04. + + +Local Variables: +mode: indented-text +left-margin: 8 +fill-column: 72 +fill-prefix: " " +version-control: never +End: diff -u2rN sed-3.02/Makefile.bcc sed-3.02+mb1.09/Makefile.bcc --- sed-3.02/Makefile.bcc Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/Makefile.bcc Sun Nov 19 17:44:20 2000 @@ -0,0 +1,61 @@ +SHELL = command.com +PACKAGE = sed +VERSION = 3.02 +MBVERSION = 1.07 + +DEFS = -DMSDOS -DHAVE_CONFIG_H -I. +CC = bcc -ml -f- +CFLAGS = -A- -O2-i -N -d -w- +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) + +CONFIG_H = config.h + +.SUFFIXES: +.SUFFIXES: .c .obj .lib .exe + +.c.obj: + $(COMPILE) -c $< + +default: all + +all: $(CONFIG_H) + cd lib + gmake -f Makefile.bcc + cd .. + cd sed + gmake -f Makefile.bcc + cd .. + +clean: + cd lib + gmake -f Makefile.bcc clean + cd .. + cd sed + gmake -f Makefile.bcc clean + cd .. + -if exist $(CONFIG_H) del $(CONFIG_H) + +$(CONFIG_H): Makefile.bcc + @echo #define HAVE_VPRINTF 1 > $(CONFIG_H) + @echo #define STDC_HEADERS 1 >>$(CONFIG_H) + @echo #define PACKAGE "$(PACKAGE)" >>$(CONFIG_H) + @echo #define VERSION "$(VERSION)" >>$(CONFIG_H) + @echo #define MBVERSION "$(MBVERSION)" >>$(CONFIG_H) + @echo #define USE_REGEX_GNU_H 1 >>$(CONFIG_H) + @echo #define REGEX_MALLOC 1 >>$(CONFIG_H) + @echo #define SJIS 1 >>$(CONFIG_H) + @echo #define HAVE_ISATTY 1 >>$(CONFIG_H) + @echo #define HAVE_MEMCHR 1 >>$(CONFIG_H) + @echo #define HAVE_MEMCMP 1 >>$(CONFIG_H) + @echo #define HAVE_MEMCPY 1 >>$(CONFIG_H) + @echo #define HAVE_MEMMOVE 1 >>$(CONFIG_H) + @echo #define HAVE_STRICMP 1 >>$(CONFIG_H) + @echo #define HAVE_STRNICMP 1 >>$(CONFIG_H) + @echo #define HAVE_LIMITS_H 1 >>$(CONFIG_H) + @echo #define HAVE_MEMORY_H 1 >>$(CONFIG_H) + @echo #define HAVE_STDLIB_H 1 >>$(CONFIG_H) + @echo #define HAVE_STRING_H 1 >>$(CONFIG_H) + @echo #define HAVE_SYS_TYPES_H 1 >>$(CONFIG_H) + + + diff -u2rN sed-3.02/Makefile.in sed-3.02+mb1.09/Makefile.in --- sed-3.02/Makefile.in Sun Aug 2 10:17:02 1998 +++ sed-3.02+mb1.09/Makefile.in Tue Nov 28 01:02:51 2000 @@ -1,5 +1,5 @@ -# Makefile.in generated automatically by automake 1.3 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -12,5 +12,5 @@ -SHELL = /bin/sh +SHELL = @SHELL@ srcdir = @srcdir@ @@ -33,5 +33,5 @@ oldincludedir = /usr/include -DISTDIR = +DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ @@ -47,5 +47,5 @@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -60,7 +60,9 @@ CC = @CC@ MAKEINFO = @MAKEINFO@ +MBVERSION = @MBVERSION@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ +binsuffix = @binsuffix@ SUBDIRS = djgpp doc lib sed testsuite @@ -71,8 +73,8 @@ CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = -DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ -Makefile.in NEWS THANKS TODO acconfig.h acinclude.m4 aclocal.m4 \ -config_h.in configure configure.in install-sh missing mkinstalldirs \ -stamp-h.in +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ +Makefile.am Makefile.in NEWS THANKS TODO acconfig.h acinclude.m4 \ +aclocal.m4 config_h.in configure configure.in install-sh missing \ +mkinstalldirs @@ -80,12 +82,11 @@ TAR = tar -GZIP = --best -all: all-recursive-am all-am - +GZIP_ENV = --best +all: all-redirect .SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -94,5 +95,5 @@ cd $(srcdir) && $(ACLOCAL) -config.status: $(srcdir)/configure +config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) @@ -100,14 +101,21 @@ config.h: stamp-h - @: + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi stamp-h: $(srcdir)/config_h.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES= CONFIG_HEADERS=config.h:config_h.in \ $(SHELL) ./config.status - @echo timestamp > stamp-h + @echo timestamp > stamp-h 2> /dev/null $(srcdir)/config_h.in: $(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi $(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h cd $(top_srcdir) && $(AUTOHEADER) - @echo timestamp > $(srcdir)/stamp-h.in + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null mostlyclean-hdr: @@ -133,26 +141,44 @@ check-recursive installcheck-recursive info-recursive dvi-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ - target=`echo $@ | sed s/-recursive//`; \ echo "Making $$target in $$subdir"; \ - (cd $$subdir && $(MAKE) $$target) \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ - done && test -z "$$fail" + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ - target=`echo $@ | sed s/-recursive//`; \ echo "Making $$target in $$subdir"; \ - (cd $$subdir && $(MAKE) $$target) \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ - (cd $$subdir && $(MAKE) tags); \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done @@ -160,6 +186,10 @@ ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + && mkid -f$$here/ID $$unique $(LISP) TAGS: tags-recursive $(HEADERS) $(SOURCES) config_h.in $(TAGS_DEPENDENCIES) $(LISP) @@ -167,5 +197,7 @@ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ - test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ done; \ list='$(SOURCES) $(HEADERS)'; \ @@ -193,5 +225,5 @@ distcheck: dist -rm -rf $(distdir) - GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz mkdir $(distdir)/=build mkdir $(distdir)/=inst @@ -199,21 +231,23 @@ cd $(distdir)/=build \ && ../configure --srcdir=.. --prefix=$$dc_install_base \ - && $(MAKE) \ - && $(MAKE) dvi \ - && $(MAKE) check \ - && $(MAKE) install \ - && $(MAKE) installcheck \ - && $(MAKE) dist + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist -rm -rf $(distdir) - @echo "========================"; \ - echo "$(distdir).tar.gz is ready for distribution"; \ - echo "========================" + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" dist: distdir -chmod -R a+r $(distdir) - GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) dist-all: distdir -chmod -R a+r $(distdir) - GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) distdir: $(DISTFILES) @@ -221,77 +255,87 @@ mkdir $(distdir) -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file; \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ done for subdir in $(SUBDIRS); do \ - test -d $(distdir)/$$subdir \ - || mkdir $(distdir)/$$subdir \ - || exit 1; \ - chmod 777 $(distdir)/$$subdir; \ - (cd $$subdir && $(MAKE) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ done +info-am: info: info-recursive +dvi-am: dvi: dvi-recursive -check: all-am - $(MAKE) check-recursive +check-am: all-am +check: check-recursive +installcheck-am: installcheck: installcheck-recursive all-recursive-am: config.h - $(MAKE) all-recursive - -all-am: Makefile config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive +install-exec-am: install-exec: install-exec-recursive - @$(NORMAL_INSTALL) +install-data-am: install-data: install-data-recursive - @$(NORMAL_INSTALL) +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-recursive - @: - +uninstall-am: uninstall: uninstall-recursive - +all-am: Makefile config.h +all-redirect: all-recursive-am install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive +installdirs-am: mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: - -rm -f Makefile $(DISTCLEANFILES) + -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic -clean-am: clean-hdr clean-tags clean-generic mostlyclean-am - -distclean-am: distclean-hdr distclean-tags distclean-generic clean-am +mostlyclean: mostlyclean-recursive -maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ - maintainer-clean-generic distclean-am +clean-am: clean-hdr clean-tags clean-generic mostlyclean-am -mostlyclean: mostlyclean-recursive mostlyclean-am +clean: clean-recursive -clean: clean-recursive clean-am +distclean-am: distclean-hdr distclean-tags distclean-generic clean-am -distclean: distclean-recursive distclean-am +distclean: distclean-recursive -rm -f config.status -maintainer-clean: maintainer-clean-recursive maintainer-clean-am +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ + maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive -rm -f config.status @@ -302,9 +346,10 @@ dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ -distclean-tags clean-tags maintainer-clean-tags distdir info dvi \ -installcheck all-recursive-am all-am install-exec install-data install \ -uninstall all installdirs mostlyclean-generic distclean-generic \ -clean-generic maintainer-clean-generic clean mostlyclean distclean \ -maintainer-clean +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean diff -u2rN sed-3.02/Makefile.vc sed-3.02+mb1.09/Makefile.vc --- sed-3.02/Makefile.vc Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/Makefile.vc Sun Nov 19 17:44:20 2000 @@ -0,0 +1,60 @@ +PACKAGE = sed +VERSION = 3.02 +MBVERSION = 1.07 + +DEFS = -DWIN32 -DHAVE_CONFIG_H -I. +CC = cl +CFLAGS = -W3 -O2 -GF -QI0f -QIfdiv +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) + +CONFIG_H = config.h + +.SUFFIXES: +.SUFFIXES: .c .obj .lib .exe + +.c.obj: + $(COMPILE) -c $< + +default: all + +all: $(CONFIG_H) + cd lib + nmake -f Makefile.vc + cd .. + cd sed + nmake -f Makefile.vc + cd .. + +clean: + cd lib + nmake -f Makefile.vc clean + cd .. + cd sed + nmake -f Makefile.vc clean + cd .. + -if exist $(CONFIG_H) del $(CONFIG_H) + +$(CONFIG_H): Makefile.vc + @echo #define __STDC__ 1 > $(CONFIG_H) + @echo #define HAVE_VPRINTF 1 >>$(CONFIG_H) + @echo #define STDC_HEADERS 1 >>$(CONFIG_H) + @echo #define PACKAGE "$(PACKAGE)" >>$(CONFIG_H) + @echo #define VERSION "$(VERSION)" >>$(CONFIG_H) + @echo #define MBVERSION "$(MBVERSION)" >>$(CONFIG_H) + @echo #define USE_REGEX_GNU_H 1 >>$(CONFIG_H) + @echo #define SJIS 1 >>$(CONFIG_H) + @echo #define HAVE_ISATTY 1 >>$(CONFIG_H) + @echo #define HAVE_MEMCHR 1 >>$(CONFIG_H) + @echo #define HAVE_MEMCMP 1 >>$(CONFIG_H) + @echo #define HAVE_MEMCPY 1 >>$(CONFIG_H) + @echo #define HAVE_MEMMOVE 1 >>$(CONFIG_H) + @echo #define HAVE_STRICMP 1 >>$(CONFIG_H) + @echo #define HAVE_STRNICMP 1 >>$(CONFIG_H) + @echo #define HAVE_LIMITS_H 1 >>$(CONFIG_H) + @echo #define HAVE_MEMORY_H 1 >>$(CONFIG_H) + @echo #define HAVE_STDLIB_H 1 >>$(CONFIG_H) + @echo #define HAVE_STRING_H 1 >>$(CONFIG_H) + @echo #define HAVE_SYS_TYPES_H 1 >>$(CONFIG_H) + + + diff -u2rN sed-3.02/OChangeLog.MB sed-3.02+mb1.09/OChangeLog.MB --- sed-3.02/OChangeLog.MB Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/OChangeLog.MB Sun Nov 19 17:44:20 2000 @@ -0,0 +1,206 @@ +Thu Jun 2 16:56:47 1994 Takahiro Tanimoto (tt@isaac) + + * Version 1.18 + multi-byte extension 1.03 released. + +Sat Mar 5 16:31:53 1994 Takahiro Tanimoto (tt@isaac) + + * README.MSC: PC-9800 シリーズ用 MS-C 6.00A の, ワイルドカード展 + 開ルーチンのバグに対処した. 以前の stdargv.diff をこれに統合し, + 削除した. (Thanks to 福浩邦さん ) + +Sat Aug 21 18:03:33 1993 Takahiro Tanimoto (tt at pc98) + + * Version 1.18 + multi-byte extension 1.02 released. + +Thu Aug 19 03:48:33 1993 Takahiro Tanimoto (tt@isaac) + + * regex.c (re_compile_fastmap): charset_not の fastmap の作成処 + 理が間違っていて, fastmap を使用する場合 (sed も含まれる), 正規 + 表現の先頭の [^A] や [^a] に例えば B がマッチしなかった. + (Thanks to 小屋良祐さん ) + +Tue Aug 10 00:23:37 1993 Takahiro Tanimoto (tt@isaac) + + * regex.c (set_list_bits): 文字クラス中のマルチバイト文字の最適 + 化で, 区間終点の更新処理部分にバグがあり, [A-CE-GB-D] を最 + 適化すると [A-G] だが, これが [A-E] となってしまっていた. + +Fri Jul 23 15:59:26 1993 Takahiro Tanimoto (tt@isaac) + + * Version 1.18 + multi-byte extension 1.01 released. + +Fri Jul 23 02:05:23 1993 Takahiro Tanimoto (tt at pc98) + + * DEFS.dos: strcmpi(), strncmpi() を stricmp(), strnicmp() に変 + 更. + + * sed.c (main): MS-DOS の場合, argv[0] からディレクトリ名, 拡張 + 子を取り除き, 小文字にしてから argv[0], myname へセットするよう + に変更した. + + * stdargv.diff: 追加. + +Sun Jul 11 02:31:13 1993 Takahiro Tanimoto (tt@isaac) + + * sed.c (compare_mbcs): 同じオブジェクトに対するポインタを渡され + た時には 0 を返すように修正. + +Sat Jul 10 17:12:46 1993 Takahiro Tanimoto (tt@isaac) + + * configure.in: strncasecmp のチェックを追加. + + * sed.c (main): マルチバイト文字のタイプ指定オプションの形式を + gawk-2.15.2+mb1.01, grep-2.0+mb1.01 に合わせて変更. + + * grep-2.0+mb1.01 から mbc.[ch] を輸入. regex.[ch], sed.c をそ + れに従って書き換えた. + + * regex.c (print_compiled_pattern): printf() で syntax の出力書 + 式が間違っていた. + + * regex.h: 定数の後に U, UL をつけると old-C でコンパイルできな + い. これらをキャストに変更した. + + * regex.h: RE_DUP_MAX の定義を 16 ビット int のマシンでもオーバ + フローしない書き方に修正. + +Sat Jul 3 06:53:23 1993 Takahiro Tanimoto (tt@isaac) + + * Version 1.18 + multi-byte extension 1.00 released. + +Fri Jul 2 11:33:41 1993 Takahiro Tanimoto (tt@isaac) + + * regex.c (regex_compile): set_list_bits からの返り値の判定にバ + グがあったのを修正. (判定の必要がない部分だったので単に削除した.) + + * sed.c (compile_program), regex.c (set_list_bits): 使用していな + い変数があったので削除した. + +Fri Jul 2 10:34:35 1993 Takahiro Tanimoto (tt at pc98) + + * regex.c (re_match_2): ポインタ同士を int にキャストしてから比 + 較している部分があったが, そのキャストを削除した. オリジナルの + 作者が何のためにキャストしていたのかは不明. + + * utils.c (add1_buffer): 16 ビット int のために修正. + + * sed.c (compile_program): y コマンドの処理を 16 ビット int のた + めに修正. + + * regex.c (regcmp): 変数 syntax の宣言が unsigned となっていたの + を reg_syntax_t に修正した. + + * regex.c (at_endline_loc_p): 引数 syntax の宣言が int となって + いたのを reg_syntax_t に修正した. + + * regex.c (print_compiled_pattern): syntax の表示部分を修正. + + * regex.h (reg_syntax_t, RE_BACKSLASH_ESCAPE_IN_LISTS): 16 ビッ + ト int のマシンでは reg_syntax_t == unsigned ではオーバフローす + るため, unsigned long とした. + + * sed.c (read_file): MSDOS のとき errno, sys_errlist, sys_nerr + を宣言しないように修正. で宣言されていて多重定義エラー + になる. + + * sed.c: MS-C (6.00A) にはプロトタイプ宣言中で + + void foo(int x, int); + + のように変数名を付けた引数と型指定だけの引数を混在させるとエラー + になるというバグがあった. compile_program のプロトタイプ宣言が + このバグのせいで通らなかったため変数名を追加して回避した. + + * Makefile.msc DEFS.dos: DOS サポートのため追加. + +Sat Jun 19 09:53:47 1993 Takahiro Tanimoto (tt@isaac) + + * Version 1.18 + multi-byte extension 0.04 released. + + * sed.c (compile_program): y コマンドの処理が一部 byte order に + 依存していて, little endian のマシンで誤動作していた. (Thanks + to 長田仁志さん ) + +Wed Jun 2 02:10:51 1993 Takahiro Tanimoto (tt@isaac) + + * sed-1.17-1.18.diff を適用. + +Tue Jun 1 20:33:36 1993 Takahiro Tanimoto (tt@isaac) + + * Version 1.17 + multi-byte extension 0.03 released. + + * Version 1.15 → 1.17 の変更を施した. + +Tue May 25 00:12:06 1993 Takahiro Tanimoto (tt@isaac) + + * Version 1.15 + multi-byte extension 0.02 released. + +Mon May 24 15:37:50 1993 Takahiro Tanimoto (tt@isaac) + + * sed.c: 不必要な isascii() を削除した. + + * regex.c (re_search_2): 後方へ advance する際のバグを修正. + + * sed-1.14-1.15.diff を適用. + +Sat May 22 02:05:32 1993 Takahiro Tanimoto (tt@isaac) + + * regex.c (re_match_2): exactn の処理部分で, #if 0 を #if 1 にし + た場合, 正しい処理を行っていなかったのを修正. + +Fri May 21 21:49:36 1993 Takahiro Tanimoto (tt@isaac) + + * Version 1.14b + multi-byte extension 0.01. + + * regex.[ch]: mbcharset, mbcharset_not を廃止. 代わりに + charset, charset_not がマルチバイト文字をも保持する. + + * regex.c (set_list_bits), regex.h (RE_TRANSLATED_RANGE): 廃止. + +Wed May 19 05:27:18 1993 Takahiro Tanimoto (tt@isaac) + + * sed.c (execute_program): l コマンドでマルチバイト文字を出力す + るように変更した. (Shift-JIS の際の半角カナ文字も.) + +Tue May 18 01:36:54 1993 Takahiro Tanimoto (tt@albert) + + * configure.in: memmove() のチェックを追加. + + * regex.h: !__STDC__ のときに const の #define を追加. + + * sed.c (compile_regex): [^]...] の扱いにオリジナルのバグがあっ + たが, マルチバイト対応に変更する際, 自動的に fix された. + +Mon May 17 03:37:51 1993 Takahiro Tanimoto (tt@isaac) + + * regex.h (RE_TRANSLATED_RANGE): 下記の機能の選択のために追加. + + * regex.c (set_list_bits, regex_compile): translate([a-z]) の解 + 釈を新旧どちらの方法で行うかを syntax で選択できるようにした. + +Sun May 16 15:12:18 1993 Takahiro Tanimoto (tt@isaac) + + * regex.c (regex_compile): GNU regex は, 例えば, + translate('A') = 'A', + translate('B') = 'B', + translate('C') = 'C', + translate('a') = 'A', + translate('b') = 'b', + translate('c') = 'C' + となっている場合に, translate([a-z]) を, 以前は [ABC] として解釈 + していたが, 最近のものは [AbC] と解釈するように変更されている. + これを古い解釈に戻した. あまり関係はないが, translate 関連には, + オリジナルのバグがあるようだ. たとえば, x がメタキャラクタ 'Y' + かどうかを判断するのに, translate(x) == 'Y', translate(x) == + translate('Y'), x == 'Y' といった, 様々なテスト方法がソース中に + 散在している. メタキャラクタは translate で変更できないと思って + おいたほうがいい. + + +Local Variables: +mode: indented-text +left-margin: 8 +fill-column: 72 +fill-prefix: " " +version-control: never +End: diff -u2rN sed-3.02/OREADME.MB sed-3.02+mb1.09/OREADME.MB --- sed-3.02/OREADME.MB Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/OREADME.MB Sun Nov 19 17:44:20 2000 @@ -0,0 +1,228 @@ +●●●●● GNU sed version 1.18 + multi-byte extension 1.03 ●●●●● +●●●●● Jun. 2, 1994 by t^2 ●●●●● + + sed-1.18+mb1.03 -- マルチバイト文字対応版 GNU sed + +●概要 + + GNU プロジェクトによる sed をマルチバイト文字対応化したものです. + +●使用法 + + GNU sed からの拡張部分だけを説明します. + + 増えたオプションは以下の通りです. + + -Wctype=ASCII または --ctype=ASCII + マルチバイト文字を考慮しません. このオプションを使用した場 + 合, GNU sed のオリジナルと同じ動作になるはずです. + + -Wctype=EUC または --ctype=EUC + マルチバイト文字として EUC を認識します. + + -Wctype=SJIS または --ctype=SJIS + マルチバイト文字として Shift-JIS を認識します. + + MS-DOS 以外のシステムで, Makefile(.in)? を書き換えずにインストー + ルした場合, デフォルトでは EUC を認識します. MS-DOS ではデフォ + ルトで Shift-JIS を認識します. + + 以下, コマンドなどの変更点です. + + y コマンド バイト毎ではなく文字毎に変換します. + + l コマンド マルチバイト文字を考慮した出力を行います. 特に, + EUC の半角カナの文字幅を考慮しています. + + その他 ラベルにマルチバイト文字が使用できます. + +● SEDM103.LZH (MS-DOS 版実行形式を含むアーカイブ) について (それ以外の + 形態で入手された方は無視してください) + + 1. アーカイブに含まれているファイル + + オリジナルから全く手を加えていないファイル + + CHANGELO オリジナルのソースに含まれている ChangeLog + COPYING オリジナルのソースに含まれている COPYING + COPYING.LIB オリジナルのソースに含まれている COPYING.LIB + README オリジナルのソースに含まれている README + + sed+mb 用のファイル + + CHANGELO.MB sed+mb の変更履歴 + README.MB このファイル + + MS-DOS 版 sed+mb 用のファイル + + SED.EXE MS-DOS 版 sed-1.18+mb1.03 の実行形式 + + 2. SED.EXE について + + sed-1.18+mb1.03 を MS-C 6.00A でコンパイルしたものです. + + デフォルトでは Shift-JIS 漢字コードを含むプログラムやファイルを + 処理できます. + + setargv.obj を組み込んでありますので, MS-DOS でポピュラーなタイ + プのワイルドカードが使用できます. + + 3. コマンドライン引数について + + 前述したとおり MS-C の setargv.obj をリンクしていますので, その + 仕様に従わなければなりません. + + 1つ1つの引数は空白で区切ります. 引数に空白, ", \, <, >, | を + 含むときはクォーティングが必要です. その方法は COMMAND.COM のバ + グ臭い仕様と, さらに setargv.obj にも問題があり, かなり難しいの + でここでは説明を省きます. 各自研究してください. 一番簡単なのは, + sed のプログラムをファイルにして + + sed -f ファイル名 + + とすることです. + +●インストール (MS-DOS 以外) + + デフォルトのマルチバイト文字の設定は, Makefile.in の中で指定します. + デフォルトを Shift-JIS とする場合と, デフォルトでマルチバイト文字を + 使用しない場合は Makefile.in の MBCTYPE_DEF マクロの定義をそれぞれ以 + 下のように変えてください. + + MBCTYPE_DEF = -DSJIS (デフォルトで Shift-JIS の場合) + MBCTYPE_DEF = (デフォルトで使用しない場合) + + いずれの場合でも起動時のオプションによりマルチバイト文字コードの選択 + が可能です. + + その他の作業は, オリジナルの sed と同様ですので INSTALL をお読みくだ + さい. + +●インストール (MS-DOS 版) + + MS-C 6.00A を使用して, デフォルトで Shift-JIS を認識する sed を作成 + する場合は, README.MSC に目を通して, 必要ならライブラリにパッチを当 + てた後, + + A>nmake -f Makefile.msc + + だけでOKです. その他の処理系を使用する場合や, デフォルトを + Shift-JIS 以外にしたい場合は Makefile.msc を参考に Makefile を書いて + ください. + +●バグ + + 1. いわゆる JIS には対応していません. 将来対応する予定もありません. + + 2. マルチバイト文字コードはあまり厳格には考えていません. + + EUC 1バイト目 ... 0x80 - 0xff + EUC 2バイト目 ... 0x01 - 0xff (0x0a を除く) + + Shift-JIS 1バイト目 ... 0x80 - 0x9f, 0xe0 - 0xff + Shift-JIS 2バイト目 ... 0x01 - 0xff (0x0a を除く) + + として処理しています. 半角カナも使えます. EUC の SS3 (0x8f) に + 始まる3バイトコードは使えません. (私はこれをサポートしているシ + ステムを見たことがない...) + +● regex.[ch] の拡張仕様 + + regex.[ch] モジュールは mbc.[ch] モジュールに依存していますので, 使 + 用する場合には, mbc.[ch] モジュールを同時に使用する必要があります. + + マルチバイト文字のタイプは, mbc.[ch] の mbcinit() で設定します. + mbc.h に定義されているマクロ MBCTYPE_ASCII, MBCTYPE_EUC, + MBCTYPE_SJIS のいずれかを mbcinit() に渡してください. + + regex.[ch] は, パターンコンパイル時, マッチング時の両方で mbc.[ch] + の設定を参照します. が, この両者で mbc.[ch] の設定を変更することは + できません. つまり, Shift-JIS で記述されたパターンを, EUC テキスト + から検索するといった動作はできません. 注意してください. + + マルチバイト文字対応に伴って注意すべき正規表現を以下に記します. + + . 任意の1バイト文字, 正当なマルチバイト文字にマッチします. + 「正当なマルチバイト文字」とは, マルチバイト文字の1文字 + 目に, '\0' または '\n' 以外が続く文字のことです. + + [x-y] 文字コード (内部表現) が x から y の範囲にある任意の1文 + 字にマッチします. これも . と同じく, 正当でない文字には + マッチしません. + + [^x-y] 文字コード (内部表現) が x から y の範囲にない任意の1文 + 字にマッチします. 正当でない文字にもマッチします. + + マルチバイト文字の内部表現は単に1バイト目を上位バイト, 2バイト目を + 下位バイトとした16ビット符号なし整数です. Shift-JIS でも EUC でも + + 1バイト ASCII 文字 < 半角カナ文字 < 全角文字 + + という大小関係が成り立っています. + +●条件など + + 1. オリジナルの GNU sed の著作権は Free Software Foundation, Inc. が + 有しています. パッチ部分 (sed-mb.diff) の著作権は私 (t^2) が有し + ています. + + 2. GNU sed のソースコードは各所の ftp サイト, もしくは Nifty-serve + の FUNIX のデータライブラリから入手可能です. GNU sed から sed+mb + への差分 sed-mb.diff は私が Nifty-serve の FUNIX へ登録し, 堂園和 + 郎氏 (dohzono@sdsft.kme.mei.co.jp) が fj.sources へポストしてくだ + さっています. + + 3. 差分 sed-mb.diff の再配布は自由です. これに関しては FSF の規定に + 従う必要もありません. しかし差分を適用した結果のソースコード, お + よび実行形式での再配布の際は GNU GENERAL PUBLIC LICENSE (COPYING + 参照) に従ってください. + + sed+mb に何らかの改変を加えたものを再配布する際も, GNU GENERAL + PUBLIC LICENSE に従うように注意してください. また sed+mb に含まれ + るコード (regex.[ch] など) を利用したプログラムを配布する際も GNU + GENERAL PUBLIC LICENSE または GNU LIBRARY GENERAL PUBLIC LICENSE + (COPYING.LIB 参照) の該当部分に従ってください. + + また義務ではありませんが再配布される方は事後にでも連絡をください. + そして可能な限り, 新しいバージョンへのアップデートに努め, 利用者 + からの連絡が私に届くように配慮してください. + + 4. このプログラムは無保証です. + + 5. sed+mb に何らかの不具合が発生した場合, (FSF や, オリジナルの作者 + ではなく) 私に連絡してください. 配布した人が希望している場合は, + その人に連絡してください. + + 6. ご質問/ご要望/お叱り, その他も大歓迎です. できるかぎりサポートし + ます. + +●謝辞 + + 原作者および FSF に感謝します. + + ドキュメント作成に関して助言をくださった堂園和郎氏 + (dohzono@sdsft.kme.mei.co.jp) に感謝します. + + これまで転載/バグ報告をくださった方々に感謝します. 実名を挙げさせて + 頂きたかったのですがハードディスクのトラブルでほとんどのメールを消失 + させてしまいました. + + 最後に, 貴重なディスクスペースを sed+mb のために割いてご使用頂いてい + るすべての利用者の方々に感謝いたします. + +●「私」の連絡先 + + 〒810 福岡市中央区梅光園団地 7-207 (注: 転居しました) + TEL/FAX: 092-731-4025 (TEL/FAX 自動切替え) + 092-724-6342 (TEL のみ) + E-mail: NBC02362@niftyserve.or.jp 谷本孝浩 + +# Local variables: +# mode: indented-text +# indent-tabs-mode: nil +# tab-stop-list: (4 8 16 24 32 40 48 56 64 72 80) +# left-margin: 4 +# fill-column: 72 +# fill-prefix: " " +# version-control: never +# End: diff -u2rN sed-3.02/README.MB sed-3.02+mb1.09/README.MB --- sed-3.02/README.MB Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/README.MB Tue Nov 28 00:59:39 2000 @@ -0,0 +1,184 @@ +======================================================================== + GNU sed 3.02 + multi-byte extension 1.09 + Nov 28, 2000 by WILLs (okabe katsuyuki) +======================================================================== + + GNU sed-3.02+mb1.09 -- マルチバイト文字対応版 GNU sed + +○概要 + t^2 氏がマルチバイト文字対応化された GNU sed-1.18+mb1.03 を元に + sed-3.02 をマルチバイト文字対応化したものです. + +○使用法 + OREADME.MB の「●使用法」を参照してください. + +○MSDOS 版実行形式を含むアーカイブについて + 1. アーカイブに含まれているファイル + オリジナルソースからのファイル + ANNOUNCE + AUTHORS + BUGS + COPYING + ChangeLog + NEWS + README + THANKS + TODO + + sed+mb 用のファイル + BUGS.MB multi-byte 対応版のバグ + ChangeLog.MB 変更履歴 + README.MB このファイル + OChangeLog.MB sed-1.18+mb1.03 までの変更履歴 + OREADME.MB sed-1.18+mb1.03 までの README.MB + doc/sed.info info ファイル + + MSDOS 版 sed+mb 用のファイル + doc/sed.cat オリジナルソースに含まれているマニュアル + ページ doc/sed.1 を GNU roff でフォーマッ + トしたもの + sed.exe djgpp 版 sed-3.02+mb1.09 の実行ファイル + sedr.exe MSDOS(リアルモード)版 sed-3.02+mb1.09 の + 実行ファイル + sed32.exe WIN32 版 sed-3.02+mb1.09 の実行ファイル + + 2. sed.exe, sedr.exe, sed32.exe について + sed.exe, sedr.exe, sed32.exe は, sed-3.02+mb1.09 をそれぞれ + djgpp-2.01(GNU C 2.7.2.1), Borland C 3.1, Visual C++ 6.0 にてコン + パイルしたものです. + + デフォルトで Shift-JIS 漢字コードを含むプログラムやファイルを処 + 理できますが, オプションにより変更することもできます. + + sed.exe (djgpp 版) のインストールは, そのまま PATH の通ったディ + レクトリにコピーしてください. ただし sed.exe を使用するためには + ご使用のメモリマネージャが DPMI をサポートしている必要があります. + + sedr.exe (リアルモード版), sed32.exe (WIN32 版) のインストールも + djgpp 版と同様に PATH の通ったディレクトリにコピーしてください. そ + の際 djgpp 版を使用しないのであればファイル名を sed.exe に変更して + 構いません. + + 3. コマンドライン引数について + djgpp 版については djgpp の仕様に準じます. + + リアルモード版については serow 氏作の xargs.[ch], WIN32 版では + Bruce. 氏対応 xargs32.[ch] を使用することにより次のような拡張がな + されています. + + - シングルクオート '' で引数を括ることができます. + ただし >, |, < のような command.com に解釈されてしまうよな + 文字を使用するさいには従来のダブルクオート "" を用いてくだ + さい. + + - csh-like なワイルドカード展開ができます. + + 4. 環境変数 + - LFN (djgpp版, リアルモード版) + Windows95/98 において環境変数 LFN に `N' または `n' 以外の文 + 字が設定されているならばロングファイルネームが使用できるよう + になります. + またリアルモード版では環境変数 XARGS に ``LFN'' を設定するこ + とでもロングファイルネームが使用できるようになります. + +○インストール(コンパイル) + 1. unix と cygnus の場合 + デフォルトのマルチバイト文字の設定は, ./configure 実行時に指定し + ます. デフォルトは EUC となっていますので, デフォルトを + Shift-JIS, ASCII に変更するには ./configure 実行時のオプションに + それぞれ --enable-SJIS, --enable-ASCII を加えてください. + + 例) + ./configure --enable-SJIS (デフォルトで Shift-JIS の場合) + ./configure --enable-ASCII (デフォルトで ASCII の場合) + + インストールに関するその他の事項は INSTALL を参照してください. + + 2. MSDOS の場合 + それぞれ + + djgpp-2.01) + C>configure djgpp + C>make + + Borland C 3.1) + C>configure bcc + C>make + + Visual C++ 6.0) + C>configure vc + C>make + + とすることでコンパイルすることができます. + その際 make にはそれぞれ GNU make 3.75 for DJGPP V2, GNUish make + 3.71, GNUish make 3.71 を使用しました. + その他のCコンパイラや make では Makefile.bcc, Makefile.vc を参 + 考に Makefile を作成しコンパイルしてください. + + 3. HUMAN68K の場合 + autoconf や configure が実行できる環境が整っていないとインストー + ルできません. 環境が整っている場合は最初に autoconf で HUMAN68K + 用の configure を作成し unix のインストール方に従ってください. + +○バグ + OREADME.MB を参照してください. + +○条件 + 1. オリジナルの GNU sed の著作権は Free Software Foundation, Inc. が + 有しています. パッチ部分の著作権は私 (WILLs) が有しています. ただ + し sed-1.18+mb1.03 から引き継いでいる部分に関しては t^2 が著作権 + を有しています. + + 2. GNU sed のソースコードは各所の ftp サイトから入手可能です. + 私は, ftp://ftp.iij.ad.jp/pub/GNU/sed/sed-3.02.tar.gz より入手し + ました + + 3. パッチファイルの再配布は自由です. これん関しては FSF の規定に従う + 必要はありません. しかし差分を適用した結果のソースコード, および + 実行形式での再配布の際は GNU GENERAL PUBLIC LICENSE (COPYING 参照) + に従ってください. + + sed+mb に何らかの改変を加えたものを再配布する際も, GNU GENERAL + PUBLIC LICENSE に従うようにしてください. また sed+mb に含まれるコー + ド (rx.[ch] など) を利用したプログラムを配布する際も GNU GENERAL + PUBLIC LICENSE の該当部分に従ってください. + + 4. このプログラムは無保証です. + + 5. この sed+mb に何らかの不具合いが発生した場合, 私に連絡をしてくだ + さい. + +○謝辞 + 原作者および FSF に感謝します. + + sed+mb の原作者 t^2 氏に感謝します. + + このドキュメント(README.MB) は, OREADME.MB を参考にさせていただきま + した. + + MSDOS 版には serow 氏作 xargs.[ch] を使用させていただきました. + WIN32 版には Bruce. 氏対応 xargs32.[ch] を使用させていただきました. + + MSDOS リアルモード版における Windows95 ロングファイルネームの対応に + は, Bruce. 氏作 mawk for MBCS のソースを参考にさせていただきました. + + 優れたソウトウェアを開発し, そのソースコードを公開してくださっている + 多くの方々に感謝します. + +○連絡先 + e-mail: HGC02147@nifty.ne.jp + + ういるす / WILLs / 岡部 勝幸 + + HGC02147@nifty.ne.jp + http://member.nifty.ne.jp/wills/ + +# Local variables: +# mode: indented-text +# indent-tabs-mode: nil +# tab-stop-list: (4 8 16 24 32 40 48 56 64 72 80) +# left-margin: 4 +# fill-column: 72 +# fill-prefix: " " +# version-control: never +# End: diff -u2rN sed-3.02/acconfig.h sed-3.02+mb1.09/acconfig.h --- sed-3.02/acconfig.h Fri Jul 3 10:35:56 1998 +++ sed-3.02+mb1.09/acconfig.h Sun Nov 19 17:44:20 2000 @@ -5,4 +5,7 @@ #undef VERSION +/* Multi-byte extension VERSION number */ +#undef MBVERSION + /* Use lib/regex-gnu.h header (in preference to system's ) */ #undef USE_REGEX_GNU_H @@ -13,2 +16,9 @@ /* have the regnexec() function */ #undef HAVE_REGNEXEC + +/* default multi-byte character set */ +#undef ASCII +#undef SJIS +#undef EUC +#undef UTF8 + diff -u2rN sed-3.02/aclocal.m4 sed-3.02+mb1.09/aclocal.m4 --- sed-3.02/aclocal.m4 Sun Aug 2 09:38:41 1998 +++ sed-3.02+mb1.09/aclocal.m4 Tue Nov 28 01:02:50 2000 @@ -1,6 +1,6 @@ -dnl aclocal.m4 generated automatically by aclocal 1.3 +dnl aclocal.m4 generated automatically by aclocal 1.4 -dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. -dnl This Makefile.in is free software; the Free Software Foundation +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -45,5 +45,5 @@ AC_DEFUN(AM_INIT_AUTOMAKE, -[AC_REQUIRE([AM_PROG_INSTALL]) +[AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) @@ -55,6 +55,6 @@ fi ifelse([$3],, -AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") -AC_DEFINE_UNQUOTED(VERSION, "$VERSION")) +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) @@ -67,13 +67,4 @@ AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) - - -# serial 1 - -AC_DEFUN(AM_PROG_INSTALL, -[AC_REQUIRE([AC_PROG_INSTALL]) -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' -AC_SUBST(INSTALL_SCRIPT)dnl -]) # diff -u2rN sed-3.02/config_h.in sed-3.02+mb1.09/config_h.in --- sed-3.02/config_h.in Fri Jul 3 19:06:31 1998 +++ sed-3.02+mb1.09/config_h.in Sun Nov 19 17:44:20 2000 @@ -58,13 +58,16 @@ #undef STDC_HEADERS -/* PACKAGE name */ -#undef PACKAGE - -/* Package VERSION number */ -#undef VERSION +/* Multi-byte extension VERSION number */ +#undef MBVERSION /* Use lib/regex-gnu.h header (in preference to system's ) */ #undef USE_REGEX_GNU_H +/* default multi-byte character set */ +#undef ASCII +#undef SJIS +#undef EUC +#undef UTF8 + /* Define if you have the bcopy function. */ #undef HAVE_BCOPY @@ -100,7 +103,19 @@ #undef HAVE_REGNEXEC +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + /* Define if you have the strerror function. */ #undef HAVE_STRERROR +/* Define if you have the stricmp function. */ +#undef HAVE_STRICMP + +/* Define if you have the strncasecmp function. */ +#undef HAVE_STRNCASECMP + +/* Define if you have the strnicmp function. */ +#undef HAVE_STRNICMP + /* Define if you have the header file. */ #undef HAVE_LIMITS_H @@ -126,2 +141,12 @@ /* Define if you have the cposix library (-lcposix). */ #undef HAVE_LIBCPOSIX + +/* Define if you have the hmem library (-lhmem). */ +#undef HAVE_LIBHMEM + +/* Name of package */ +#undef PACKAGE + +/* Version number of package */ +#undef VERSION + diff -u2rN sed-3.02/configure sed-3.02+mb1.09/configure --- sed-3.02/configure Sun Aug 2 09:38:46 1998 +++ sed-3.02+mb1.09/configure Tue Nov 28 01:02:51 2000 @@ -2,5 +2,5 @@ # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # @@ -13,4 +13,12 @@ # Any additions from configure.in: ac_help="$ac_help + --enable-ASCII set default multi-byte code to ASCII" +ac_help="$ac_help + --enable-EUC set default multi-byte code to EUC (default)" +ac_help="$ac_help + --enable-SJIS set defailt multi-byte code to SJIS" +ac_help="$ac_help + --enable-UTF8 set defailt multi-byte code to UTF8" +ac_help="$ac_help --with-regex=REGEX-LIB specify an alternative regex implementation" @@ -52,4 +60,5 @@ subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -335,5 +344,5 @@ -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" + echo "configure generated by autoconf version 2.13" exit 0 ;; @@ -505,7 +514,9 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. @@ -550,14 +561,15 @@ # IRIX /sbin/install # AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:557: checking for a BSD compatible install" >&5 +echo "configure:569: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. @@ -566,10 +578,11 @@ *) # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. : else @@ -601,11 +614,10 @@ test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - - test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:610: checking whether build environment is sane" >&5 +echo "configure:622: checking whether build environment is sane" >&5 # Just in case sleep 1 @@ -664,5 +676,5 @@ echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:667: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:679: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then @@ -710,5 +722,5 @@ missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:713: checking for working aclocal" >&5 +echo "configure:725: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -723,5 +735,5 @@ echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:726: checking for working autoconf" >&5 +echo "configure:738: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -736,5 +748,5 @@ echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:739: checking for working automake" >&5 +echo "configure:751: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -749,5 +761,5 @@ echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:752: checking for working autoheader" >&5 +echo "configure:764: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -762,5 +774,5 @@ echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:765: checking for working makeinfo" >&5 +echo "configure:777: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -775,8 +787,58 @@ +MBVERSION=1.09 + +cat >> confdefs.h <> confdefs.h <<\EOF +#define ASCII 1 +EOF + ;; +sjis) cat >> confdefs.h <<\EOF +#define SJIS 1 +EOF + ;; +utf8) cat >> confdefs.h <<\EOF +#define UTF8 1 +EOF + ;; +*) cat >> confdefs.h <<\EOF +#define EUC 1 +EOF + ;; +esac + # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:781: checking for $ac_word" >&5 +echo "configure:843: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -785,6 +847,7 @@ ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then @@ -807,5 +870,5 @@ set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:810: checking for $ac_word" >&5 +echo "configure:873: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -814,7 +877,8 @@ ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - for ac_dir in $PATH; do + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then @@ -851,9 +915,43 @@ fi + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:924: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:858: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:956: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c @@ -861,13 +959,15 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -cat > conftest.$ac_ext < conftest.$ac_ext << EOF + +#line 967 "configure" #include "confdefs.h" + main(){return(0);} EOF -if { (eval echo configure:872: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. @@ -883,4 +983,10 @@ fi rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 @@ -889,10 +995,10 @@ fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:892: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:998: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:897: checking whether we are using GNU C" >&5 +echo "configure:1003: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -903,5 +1009,5 @@ #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:906: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1012: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else @@ -914,9 +1020,13 @@ if test $ac_cv_prog_gcc = yes; then GCC=yes - ac_test_CFLAGS="${CFLAGS+set}" - ac_save_CFLAGS="$CFLAGS" - CFLAGS= - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:921: checking whether ${CC-cc} accepts -g" >&5 +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:1031: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -933,14 +1043,18 @@ echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then CFLAGS="-g -O2" else - CFLAGS="-O2" + CFLAGS="-g" fi else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi fi @@ -948,5 +1062,5 @@ set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:951: checking for $ac_word" >&5 +echo "configure:1065: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -955,6 +1069,7 @@ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then @@ -978,5 +1093,5 @@ # one of the CPPFLAGS, LDFLAGS, or LIBS variables. echo $ac_n "checking whether large file support needs explicit enabling""... $ac_c" 1>&6 -echo "configure:981: checking whether large file support needs explicit enabling" >&5 +echo "configure:1096: checking whether large file support needs explicit enabling" >&5 ac_getconfs='' ac_result=yes @@ -1009,5 +1124,5 @@ echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1012: checking how to run the C preprocessor" >&5 +echo "configure:1127: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then @@ -1024,5 +1139,5 @@ # not just through cpp. cat > conftest.$ac_ext < @@ -1030,6 +1145,6 @@ EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1033: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1148: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1041,5 +1156,22 @@ CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < @@ -1047,6 +1179,6 @@ EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1050: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1061,4 +1193,6 @@ fi rm -f conftest* +fi +rm -f conftest* ac_cv_prog_CPP="$CPP" fi @@ -1071,16 +1205,16 @@ ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 -echo "configure:1074: checking for minix/config.h" >&5 +echo "configure:1208: checking for minix/config.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1084: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1218: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1119,7 +1253,7 @@ echo $ac_n "checking for AIX""... $ac_c" 1>&6 -echo "configure:1122: checking for AIX" >&5 +echo "configure:1256: checking for AIX" >&5 cat > conftest.$ac_ext <&6 -echo "configure:1146: checking for strerror in -lcposix" >&5 +echo "configure:1280: checking for strerror in -lcposix" >&5 ac_lib_var=`echo cposix'_'strerror | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then @@ -1151,5 +1285,5 @@ LIBS="-lcposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1299: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" @@ -1189,12 +1323,67 @@ fi +case "$KSH_VERSION" in +*X6*) + binsuffix=.x + echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6 +echo "configure:1330: checking for hmemset in -lhmem" >&5 +ac_lib_var=`echo hmem'_'hmemset | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lhmem $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo hmem | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + + ;; +*) + binsuffix= + ;; +esac echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1194: checking for ANSI C header files" >&5 +echo "configure:1383: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -1204,6 +1393,6 @@ EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1396: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1221,5 +1410,5 @@ # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < @@ -1239,5 +1428,5 @@ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < @@ -1260,5 +1449,5 @@ else cat > conftest.$ac_ext < @@ -1271,5 +1460,5 @@ EOF -if { (eval echo configure:1274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : @@ -1298,16 +1487,16 @@ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1301: checking for $ac_hdr" >&5 +echo "configure:1490: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1311: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1500: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1335,10 +1524,10 @@ echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1338: checking for working const" >&5 +echo "configure:1527: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes @@ -1410,10 +1599,10 @@ echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1413: checking for size_t" >&5 +echo "configure:1602: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -1424,5 +1613,5 @@ EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* ac_cv_type_size_t=yes @@ -1444,5 +1633,5 @@ echo $ac_n "checking which regex library to use""... $ac_c" 1>&6 -echo "configure:1447: checking which regex library to use" >&5 +echo "configure:1636: checking which regex library to use" >&5 ac_regex_lib=lib/regex.o # Check whether --with-regex or --without-regex was given. @@ -1480,16 +1669,16 @@ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1483: checking for $ac_hdr" >&5 +echo "configure:1672: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1493: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1682: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1525,10 +1714,10 @@ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1528: checking for $ac_func" >&5 +echo "configure:1717: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" @@ -1587,10 +1776,10 @@ # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:1590: checking for working alloca.h" >&5 +echo "configure:1779: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -1599,5 +1788,5 @@ ; return 0; } EOF -if { (eval echo configure:1602: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes @@ -1620,10 +1809,10 @@ echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:1623: checking for alloca" >&5 +echo "configure:1812: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +# ifdef _MSC_VER +# include +# define alloca _alloca # else -# ifdef _AIX - #pragma alloca +# if HAVE_ALLOCA_H +# include # else -# ifndef alloca /* predefined by HP cc +Olibcalls */ +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); +# endif # endif # endif @@ -1648,5 +1842,5 @@ ; return 0; } EOF -if { (eval echo configure:1651: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1845: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes @@ -1673,5 +1867,5 @@ # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. - ALLOCA=alloca.o + ALLOCA=alloca.${ac_objext} cat >> confdefs.h <<\EOF #define C_ALLOCA 1 @@ -1680,10 +1874,10 @@ echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:1683: checking whether alloca needs Cray hooks" >&5 +echo "configure:1877: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 -echo "configure:1713: checking for $ac_func" >&5 +echo "configure:1907: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" @@ -1765,5 +1959,5 @@ echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:1768: checking stack direction for C alloca" >&5 +echo "configure:1962: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1773,5 +1967,5 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 @@ -1817,16 +2011,16 @@ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1820: checking for $ac_hdr" >&5 +echo "configure:2014: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1830: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:2024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1856,10 +2050,10 @@ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1859: checking for $ac_func" >&5 +echo "configure:2053: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" @@ -1909,5 +2103,5 @@ echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:1912: checking for working mmap" >&5 +echo "configure:2106: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1917,5 +2111,5 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes @@ -2080,10 +2274,10 @@ echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:2083: checking for vprintf" >&5 +echo "configure:2277: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" @@ -2132,10 +2326,10 @@ if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:2135: checking for _doprnt" >&5 +echo "configure:2329: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" @@ -2188,10 +2382,10 @@ do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2191: checking for $ac_func" >&5 +echo "configure:2385: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2413: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" @@ -2237,18 +2431,18 @@ else echo "$ac_t""no" 1>&6 -LIBOBJS="$LIBOBJS ${ac_func}.o" +LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}" fi done -for ac_func in isatty bcopy bzero isascii memcpy +for ac_func in isatty bcopy bzero isascii memcpy strcasecmp strncasecmp stricmp strnicmp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2248: checking for $ac_func" >&5 +echo "configure:2442: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" @@ -2317,4 +2511,5 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x," + trap '' 1 2 15 cat > confcache <<\EOF @@ -2340,5 +2535,5 @@ # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution @@ -2407,5 +2602,5 @@ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) @@ -2428,7 +2623,9 @@ $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g @@ -2450,6 +2647,6 @@ s%@mandir@%$mandir%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g s%@PACKAGE@%$PACKAGE%g s%@VERSION@%$VERSION%g @@ -2460,4 +2657,5 @@ s%@MAKEINFO@%$MAKEINFO%g s%@SET_MAKE@%$SET_MAKE%g +s%@MBVERSION@%$MBVERSION%g s%@CC@%$CC%g s%@RANLIB@%$RANLIB%g @@ -2465,4 +2663,5 @@ s%@ALLOCA@%$ALLOCA%g s%@LIBOBJS@%$LIBOBJS%g +s%@binsuffix@%$binsuffix%g CEOF diff -u2rN sed-3.02/configure.bat sed-3.02+mb1.09/configure.bat --- sed-3.02/configure.bat Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/configure.bat Sun Nov 19 17:44:20 2000 @@ -0,0 +1,20 @@ +@echo off +if "%1" == "djgpp" goto djgpp +if "%1" == "bcc31" goto bcc31 +if "%1" == "vc" goto vc +:usage +echo usage: configure TARGET +goto end +:djgpp +@rem copy Makefile.dj Makefile +command.com /e:4096 /c djgpp\config.bat +goto end +:bcc31 +copy Makefile.bcc Makefile +if not exist lib\regex-gn.h copy lib\regex-gnu.h lib\regex-gn.h +if not exist sed\regex-se.h copy sed\regex-sed.h sed\regex-se.h +if not exist sed\basicdef.h copy sed\basicdefs.h sed\basicdef.h +goto end +:vc +copy Makefile.vc Makefile +:end diff -u2rN sed-3.02/configure.in sed-3.02+mb1.09/configure.in --- sed-3.02/configure.in Sun Aug 2 09:38:33 1998 +++ sed-3.02+mb1.09/configure.in Tue Nov 28 00:54:13 2000 @@ -1,7 +1,35 @@ dnl Process this file with autoconf to produce a configure script. + +dnl Multi-byte extension added Jun, 1997 by WILLs (Katsuyuki Okabe) +dnl Last change: Nov 28, 2000 by WILLs + AC_INIT(sed/sed.c) AM_CONFIG_HEADER(config.h:config_h.in) AC_PREREQ(2.12)dnl (not tested with anything older) AM_INIT_AUTOMAKE(sed, 3.02) +MBVERSION=1.09 +AC_SUBST(MBVERSION) +AC_DEFINE_UNQUOTED(MBVERSION, "$MBVERSION") + +dnl check default multi-byte code +AC_ARG_ENABLE(ASCII, + [ --enable-ASCII set default multi-byte code to ASCII], + [test "$enableval" = "yes" && mbctype="ascii"]) +AC_ARG_ENABLE(EUC, + [ --enable-EUC set default multi-byte code to EUC (default)], + [test "$enableval" = "yes" && mbctype="euc"]) +AC_ARG_ENABLE(SJIS, + [ --enable-SJIS set defailt multi-byte code to SJIS], + [test "$enableval" = "yes" && mbctype="sjis"]) +AC_ARG_ENABLE(UTF8, + [ --enable-UTF8 set defailt multi-byte code to UTF8], + [test "$enableval" = "yes" && mbctype="utf8"]) +case "$mbctype" in +ascii) AC_DEFINE(ASCII) ;; +sjis) AC_DEFINE(SJIS) ;; +utf8) AC_DEFINE(UTF8) ;; +*) AC_DEFINE(EUC) ;; +esac + AC_PROG_CC AC_PROG_RANLIB @@ -47,4 +75,13 @@ AC_AIX AC_CHECK_LIB(cposix,strerror) +case "$KSH_VERSION" in +*X6*) + binsuffix=.x + AC_CHECK_LIB(hmem, hmemset) + ;; +*) + binsuffix= + ;; +esac AC_STDC_HEADERS @@ -100,7 +137,8 @@ AC_REPLACE_FUNCS(memchr memcmp memmove strerror) -AC_CHECK_FUNCS(isatty bcopy bzero isascii memcpy) +AC_CHECK_FUNCS(isatty bcopy bzero isascii memcpy strcasecmp strncasecmp stricmp strnicmp) AC_ARG_PROGRAM +AC_SUBST(binsuffix) AC_OUTPUT(Makefile djgpp/Makefile doc/Makefile dnl lib/Makefile sed/Makefile testsuite/Makefile diff -u2rN sed-3.02/djgpp/Makefile.in sed-3.02+mb1.09/djgpp/Makefile.in --- sed-3.02/djgpp/Makefile.in Sun Aug 2 10:17:05 1998 +++ sed-3.02+mb1.09/djgpp/Makefile.in Tue Nov 28 01:02:57 2000 @@ -1,5 +1,5 @@ -# Makefile.in generated automatically by automake 1.3 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,5 +15,5 @@ -SHELL = /bin/sh +SHELL = @SHELL@ srcdir = @srcdir@ @@ -36,5 +36,5 @@ oldincludedir = /usr/include -DISTDIR = +DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ @@ -50,5 +50,5 @@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -63,10 +63,12 @@ CC = @CC@ MAKEINFO = @MAKEINFO@ +MBVERSION = @MBVERSION@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ +binsuffix = @binsuffix@ + +EXTRA_DIST = README bootstrap.bat getconf config.bat config.btm config.sed config.site -EXTRA_DIST = README bootstrap.bat getconf \ - config.bat config.btm config.sed config.site mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h @@ -78,12 +80,11 @@ TAR = tar -GZIP = --best -all: Makefile - +GZIP_ENV = --best +all: all-redirect .SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps djgpp/Makefile +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu djgpp/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -98,60 +99,78 @@ distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu djgpp/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file; \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ done -info: -dvi: -check: all - $(MAKE) -installcheck: -install-exec: - @$(NORMAL_INSTALL) - -install-data: - @$(NORMAL_INSTALL) - -install: install-exec install-data all - @: - -uninstall: - +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: - -rm -f Makefile $(DISTCLEANFILES) + -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -mostlyclean: mostlyclean-generic +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-generic mostlyclean-am -clean: clean-generic mostlyclean +clean: clean-am -distclean: distclean-generic clean - -rm -f config.status +distclean-am: distclean-generic clean-am -maintainer-clean: maintainer-clean-generic distclean +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." -.PHONY: tags distdir info dvi installcheck install-exec install-data \ -install uninstall all installdirs mostlyclean-generic distclean-generic \ -clean-generic maintainer-clean-generic clean mostlyclean distclean \ -maintainer-clean +maintainer-clean: maintainer-clean-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean diff -u2rN sed-3.02/djgpp/bootstrap.bat sed-3.02+mb1.09/djgpp/bootstrap.bat --- sed-3.02/djgpp/bootstrap.bat Fri Jun 5 13:10:07 1998 +++ sed-3.02+mb1.09/djgpp/bootstrap.bat Sun Nov 19 17:44:20 2000 @@ -5,4 +5,5 @@ echo #define PACKAGE "sed" >> config.h echo #define VERSION "``bootstrap''" >> config.h +echo #define MBVERSION "1.07" >> config.h echo #define BOOTSTRAP 1 >> config.h @@ -14,5 +15,5 @@ if exist sed\sed del sed\sed cd lib -gcc -DHAVE_CONFIG_H -I.. -I. -c getopt.c getopt1.c memcmp.c memmove.c regex.c strerror.c +gcc -DHAVE_CONFIG_H -I.. -I. -c getopt.c getopt1.c mbc.c mbfuncs.c memcmp.c memmove.c regex.c strerror.c cd ..\sed gcc -DHAVE_CONFIG_H -I.. -I. -I../lib -c sed.c compile.c execute.c utils.c diff -u2rN sed-3.02/djgpp/config.bat sed-3.02+mb1.09/djgpp/config.bat --- sed-3.02/djgpp/config.bat Wed Jul 15 16:59:39 1998 +++ sed-3.02+mb1.09/djgpp/config.bat Sun Nov 19 17:44:20 2000 @@ -65,5 +65,5 @@ if not exist install-sh if exist install-sh.sh ren install-sh.sh install-sh echo Running the ./configure script... -sh ./configure --srcdir:%XSRC% %1 %2 %3 %4 %5 %6 %7 %8 %9 +sh ./configure --enable-SJIS --srcdir:%XSRC% %1 %2 %3 %4 %5 %6 %7 %8 %9 if errorlevel 1 goto CfgError if not exist install-sh.sh if exist install-sh ren install-sh install-sh.sh diff -u2rN sed-3.02/doc/Makefile.in sed-3.02+mb1.09/doc/Makefile.in --- sed-3.02/doc/Makefile.in Sun Aug 2 10:17:08 1998 +++ sed-3.02+mb1.09/doc/Makefile.in Tue Nov 28 01:02:59 2000 @@ -1,5 +1,5 @@ -# Makefile.in generated automatically by automake 1.3 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -12,5 +12,5 @@ -SHELL = /bin/sh +SHELL = @SHELL@ srcdir = @srcdir@ @@ -33,5 +33,5 @@ oldincludedir = /usr/include -DISTDIR = +DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ @@ -47,5 +47,5 @@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -60,7 +60,9 @@ CC = @CC@ MAKEINFO = @MAKEINFO@ +MBVERSION = @MBVERSION@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ +binsuffix = @binsuffix@ info_TEXINFOS = sed.texi @@ -71,5 +73,4 @@ CONFIG_CLEAN_FILES = TEXI2DVI = texi2dvi -TEXINFO_TEX = $(srcdir)/texinfo.tex INFO_DEPS = sed.info DVIS = sed.dvi @@ -86,29 +87,28 @@ TAR = tar -GZIP = --best -all: Makefile $(INFO_DEPS) $(MANS) - +GZIP_ENV = --best +all: all-redirect .SUFFIXES: .SUFFIXES: .dvi .info .ps .texi .texinfo .txi -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps doc/Makefile +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status -version.texi: stamp-vti - cp $(srcdir)/stamp-vti $(srcdir)/version.texi +$(srcdir)/version.texi: stamp-vti + @: -stamp-vti: sed.texi $(top_srcdir)/configure.in - @echo "@set UPDATED `cd $(srcdir) \ - && $(SHELL) ./mdate-sh sed.texi`" > vti.tmp +$(srcdir)/stamp-vti: sed.texi $(top_srcdir)/configure.in + @echo "@set UPDATED `$(SHELL) $(srcdir)/mdate-sh $(srcdir)/sed.texi`" > vti.tmp @echo "@set EDITION $(VERSION)" >> vti.tmp @echo "@set VERSION $(VERSION)" >> vti.tmp - @cmp -s vti.tmp $(srcdir)/stamp-vti \ - || (echo "Updating $(srcdir)/stamp-vti"; \ - cp vti.tmp $(srcdir)/stamp-vti) + @cmp -s vti.tmp $(srcdir)/version.texi \ + || (echo "Updating $(srcdir)/version.texi"; \ + cp vti.tmp $(srcdir)/version.texi) -@rm -f vti.tmp + @cp $(srcdir)/version.texi $@ mostlyclean-vti: @@ -120,5 +120,5 @@ maintainer-clean-vti: - -rm -f stamp-vti version.texi + -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi sed.info: sed.texi version.texi @@ -134,5 +134,5 @@ .texi.dvi: - TEXINPUTS=$(srcdir):$$TEXINPUTS \ + TEXINPUTS=.:$$TEXINPUTS \ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $< @@ -153,5 +153,5 @@ .texinfo.dvi: - TEXINPUTS=$(srcdir):$$TEXINPUTS \ + TEXINPUTS=.:$$TEXINPUTS \ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $< @@ -162,5 +162,5 @@ .txi.dvi: - TEXINPUTS=$(srcdir):$$TEXINPUTS \ + TEXINPUTS=.:$$TEXINPUTS \ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $< @@ -175,5 +175,6 @@ @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(infodir) - @for file in $(INFO_DEPS); do \ + @list='$(INFO_DEPS)'; \ + for file in $$list; do \ d=$(srcdir); \ for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \ @@ -186,5 +187,6 @@ @$(POST_INSTALL) @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \ - for file in $(INFO_DEPS); do \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\ install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\ @@ -197,15 +199,18 @@ ii=yes; \ else ii=; fi; \ - for file in $(INFO_DEPS); do \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ test -z "$ii" \ || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \ done @$(NORMAL_UNINSTALL) - for file in $(INFO_DEPS); do \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ (cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \ done dist-info: $(INFO_DEPS) - for base in $(INFO_DEPS); do \ + list='$(INFO_DEPS)'; \ + for base in $$list; do \ d=$(srcdir); \ for file in `cd $$d && eval echo $$base*`; do \ @@ -226,5 +231,5 @@ maintainer-clean-aminfo: - for i in $(INFO_DEPS); do \ + cd $(srcdir) && for i in $(INFO_DEPS); do \ rm -f $$i; \ if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \ @@ -267,8 +272,8 @@ install-man: $(MANS) @$(NORMAL_INSTALL) - $(MAKE) install-man1 + $(MAKE) $(AM_MAKEFLAGS) install-man1 uninstall-man: @$(NORMAL_UNINSTALL) - $(MAKE) uninstall-man1 + $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 tags: TAGS TAGS: @@ -280,29 +285,43 @@ distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu doc/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file; \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ done - $(MAKE) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info -info: $(INFO_DEPS) -dvi: $(DVIS) -check: all - $(MAKE) -installcheck: -install-exec: - @$(NORMAL_INSTALL) - -install-data: install-info-am install-man - @$(NORMAL_INSTALL) - -install: install-exec install-data all - @: - -uninstall: uninstall-info uninstall-man - + $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info +info-am: $(INFO_DEPS) +info: info-am +dvi-am: $(DVIS) +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: install-info-am install-man +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-info uninstall-man +uninstall: uninstall-am +all-am: Makefile $(INFO_DEPS) $(MANS) +all-redirect: all-am install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(infodir) $(DESTDIR)$(mandir)/man1 @@ -310,36 +329,40 @@ mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: - -rm -f Makefile $(DISTCLEANFILES) + -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -mostlyclean: mostlyclean-vti mostlyclean-aminfo mostlyclean-generic +mostlyclean-am: mostlyclean-vti mostlyclean-aminfo mostlyclean-generic -clean: clean-vti clean-aminfo clean-generic mostlyclean +mostlyclean: mostlyclean-am -distclean: distclean-vti distclean-aminfo distclean-generic clean - -rm -f config.status +clean-am: clean-vti clean-aminfo clean-generic mostlyclean-am -maintainer-clean: maintainer-clean-vti maintainer-clean-aminfo \ - maintainer-clean-generic distclean +clean: clean-am + +distclean-am: distclean-vti distclean-aminfo distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-vti maintainer-clean-aminfo \ + maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." +maintainer-clean: maintainer-clean-am + .PHONY: mostlyclean-vti distclean-vti clean-vti maintainer-clean-vti \ install-info-am uninstall-info mostlyclean-aminfo distclean-aminfo \ clean-aminfo maintainer-clean-aminfo install-man1 uninstall-man1 \ -install-man uninstall-man tags distdir info dvi installcheck \ -install-exec install-data install uninstall all installdirs \ -mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean +install-man uninstall-man tags distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean diff -u2rN sed-3.02/doc/sed.1 sed-3.02+mb1.09/doc/sed.1 --- sed-3.02/doc/sed.1 Mon Jun 1 06:16:15 1998 +++ sed-3.02+mb1.09/doc/sed.1 Sun Nov 19 17:44:19 2000 @@ -86,4 +86,11 @@ .I script-file to the set of commands to be run while processing the input. +.TP +.BI -Wctype= character-set +.TP +.BI --ctype= character-set +specify the character set. +.I character-set +is ASCII, EUC, SJIS, or UTF8. .PP If no diff -u2rN sed-3.02/doc/sed.info sed-3.02+mb1.09/doc/sed.info --- sed-3.02/doc/sed.info Sun Aug 2 09:39:19 1998 +++ sed-3.02+mb1.09/doc/sed.info Sun Nov 19 19:05:08 2000 @@ -1,4 +1,3 @@ -This is Info file sed.info, produced by Makeinfo version 1.68 from the -input file sed.texi. +This is sed.info, produced by makeinfo version 4.0 from sed.texi. START-INFO-DIR-ENTRY @@ -94,4 +93,9 @@ commands to be run while processing the input. +`-Wctype=CHARACTER-SET' +`--ctype=CHARACTER-SET' + specify the character set. CHARACTER-SET is ASCII, EUC, SJIS, or + UTF8. + If no `-e', `-f', `--expression', or `--file' options are given on the command-line, then the first non-option argument on the command @@ -178,5 +182,5 @@ from where the first address matches, and continues until the second address matches (inclusively). If the second address is a REGEXP, then -checking for the ending match will start with the line *following* the +checking for the ending match will start with the line _following_ the line which matched the first address. If the second address is a NUMBER less than (or equal to) the line matching the first address, @@ -185,5 +189,5 @@ Appending the `!' character to the end of an address specification will negate the sense of the match. That is, if the `!' character -follows an address range, then only lines which do *not* match the +follows an address range, then only lines which do _not_ match the address range will be selected. This also works for singleton addresses, and, perhaps perversely, for the null address. @@ -205,6 +209,6 @@ ====================== - SED maintains two data buffers: the active *pattern* space, and the -auxiliary *hold* space. In "normal" operation, SED reads in one line + SED maintains two data buffers: the active _pattern_ space, and the +auxiliary _hold_ space. In "normal" operation, SED reads in one line from the input stream and places it in the pattern space. This pattern space is where text manipulations occur. The hold space is initially @@ -265,5 +269,5 @@ `g' - Apply the replacement to *all* matches to the REGEXP, not + Apply the replacement to _all_ matches to the REGEXP, not just the first. @@ -339,5 +343,5 @@ stead), `\', or newlines can appear in the SOURCE-CHARS or DEST-CHARS lists, provide that each instance is escaped by a `\'. - The SOURCE-CHARS and DEST-CHARS lists *must* contain the same + The SOURCE-CHARS and DEST-CHARS lists _must_ contain the same number of characters (after de-escaping). @@ -505,4 +509,6 @@ the word "sed" somewhere in the "Subject:" field. + Report multi-byte extension version bugs to: . +  File: sed.info, Node: Concept Index, Next: Command and Option Index, Prev: Reporting Bugs, Up: Top @@ -545,6 +551,6 @@ * Flow of control in scripts: Programming Commands. * Global substitution: Common Commands. -* GNU extensions, I modifier <1>: Common Commands. -* GNU extensions, I modifier: Addresses. +* GNU extensions, I modifier <1>: Addresses. +* GNU extensions, I modifier: Common Commands. * GNU extensions, N~M addresses: Addresses. * GNU extensions, unlimited line length: Limitations. @@ -624,4 +630,5 @@ * # (comment) command: Common Commands. +* --ctype: Invoking SED. * --expression: Invoking SED. * --file: Invoking SED. @@ -636,4 +643,5 @@ * -n, forcing from within a script: Common Commands. * -V: Invoking SED. +* -Wctype: Invoking SED. * : (label) command: Programming Commands. * = (print line number) command: Other Commands. @@ -666,20 +674,20 @@  Tag Table: -Node: Top1042 -Node: Introduction1762 -Node: Invoking SED2308 -Node: sed Programs3751 -Node: Addresses4736 -Node: Regular Expressions7443 -Node: Data Spaces7802 -Node: Common Commands8325 -Node: Other Commands12456 -Node: Programming Commands16367 -Node: Examples17266 -Node: Limitations17560 -Node: Other Resources18218 -Node: Reporting Bugs19000 -Node: Concept Index19248 -Node: Command and Option Index24957 +Node: Top1016 +Node: Introduction1736 +Node: Invoking SED2282 +Node: sed Programs3856 +Node: Addresses4841 +Node: Regular Expressions7548 +Node: Data Spaces7907 +Node: Common Commands8430 +Node: Other Commands12561 +Node: Programming Commands16472 +Node: Examples17371 +Node: Limitations17665 +Node: Other Resources18323 +Node: Reporting Bugs19105 +Node: Concept Index19426 +Node: Command and Option Index25135  End Tag Table diff -u2rN sed-3.02/doc/sed.texi sed-3.02+mb1.09/doc/sed.texi --- sed-3.02/doc/sed.texi Mon Jun 29 08:01:51 1998 +++ sed-3.02+mb1.09/doc/sed.texi Sun Nov 19 17:44:19 2000 @@ -63,5 +63,5 @@ @titlepage @title sed, a stream editor -@subtitle version @value{VERSION}, @value{UPDATED} +@subtitle version @value{VERSION} + multi-byte extension 1.08, @value{UPDATED} @author by Ken Pizzini @@ -182,4 +182,11 @@ to the set of commands to be run while processing the input. +@itemx -Wctype=@var{character-set} +@itemx --ctype=@var{character-set} +@opindex -Wctype +@opindex --ctype +specify the character set. +@var{character-set} is ASCII, EUC, SJIS, or UTF8. + @end table @@ -741,4 +748,6 @@ Email bug reports to @email{bug-gnu-utils@@gnu.org}. Be sure to include the word ``sed'' somewhere in the ``Subject:'' field. + +Report multi-byte extension version bugs to: @email{hgc02147@@nifty.ne.jp}. @c XXX FIXME: the term "cycle" is never defined... diff -u2rN sed-3.02/doc/stamp-vti sed-3.02+mb1.09/doc/stamp-vti --- sed-3.02/doc/stamp-vti Sun Aug 2 09:39:15 1998 +++ sed-3.02+mb1.09/doc/stamp-vti Tue Nov 28 01:02:59 2000 @@ -1,3 +1,3 @@ -@set UPDATED 28 June 1998 +@set UPDATED 19 November 2000 @set EDITION 3.02 @set VERSION 3.02 diff -u2rN sed-3.02/doc/version.texi sed-3.02+mb1.09/doc/version.texi --- sed-3.02/doc/version.texi Sun Aug 2 09:39:15 1998 +++ sed-3.02+mb1.09/doc/version.texi Sun Nov 19 19:05:07 2000 @@ -1,3 +1,3 @@ -@set UPDATED 28 June 1998 +@set UPDATED 19 November 2000 @set EDITION 3.02 @set VERSION 3.02 diff -u2rN sed-3.02/lib/Makefile.am sed-3.02+mb1.09/lib/Makefile.am --- sed-3.02/lib/Makefile.am Fri Jul 3 10:10:14 1998 +++ sed-3.02+mb1.09/lib/Makefile.am Sun Nov 19 17:44:19 2000 @@ -1,8 +1,8 @@ ## Process this file with automake to produce Makefile.in noinst_LIBRARIES = libsed.a -noinst_HEADERS = regex-gnu.h getopt.h +noinst_HEADERS = regex-gnu.h getopt.h mbc.h mbfuncs.h xargs.h xargs32.h -libsed_a_SOURCES = getopt1.c getopt.c -EXTRA_DIST = memmove.c regex.c strerror.c +libsed_a_SOURCES = getopt1.c getopt.c mbc.c mbfuncs.c +EXTRA_DIST = memmove.c regex.c strerror.c xargs.c xargs32.c libsed_a_LIBADD = @LIBOBJS@ @ALLOCA@ diff -u2rN sed-3.02/lib/Makefile.bcc sed-3.02+mb1.09/lib/Makefile.bcc --- sed-3.02/lib/Makefile.bcc Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/Makefile.bcc Sun Nov 19 17:44:19 2000 @@ -0,0 +1,24 @@ +libsed_a_OBJECTS = getopt1.obj getopt.obj mbc.obj mbfuncs.obj regex.obj xargs.obj + +SHELL = command.com + +DEFS = -DMSDOS -DHAVE_CONFIG_H -I.. +CC = bcc -ml -f- +CFLAGS = -A- -O2-i -N -d -w- +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LDFLAGS = +ARFLAGS = + +.SUFFIXES: +.SUFFIXES: .c .obj .lib .exe + +.c.obj: + $(COMPILE) -c $< + +libsed.lib: $(libsed_a_OBJECTS) + -if exist $@ del $@ + tlib $@ /C +getopt1.obj+getopt.obj+mbc.obj+mbfuncs.obj+regex.obj+xargs.obj + +clean: + -if exist libsed.lib del libsed.lib + -if exist *.obj del *.obj diff -u2rN sed-3.02/lib/Makefile.in sed-3.02+mb1.09/lib/Makefile.in --- sed-3.02/lib/Makefile.in Sun Aug 2 10:17:12 1998 +++ sed-3.02+mb1.09/lib/Makefile.in Tue Nov 28 01:03:00 2000 @@ -1,5 +1,5 @@ -# Makefile.in generated automatically by automake 1.3 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -12,5 +12,5 @@ -SHELL = /bin/sh +SHELL = @SHELL@ srcdir = @srcdir@ @@ -33,5 +33,5 @@ oldincludedir = /usr/include -DISTDIR = +DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ @@ -47,5 +47,5 @@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -60,13 +60,15 @@ CC = @CC@ MAKEINFO = @MAKEINFO@ +MBVERSION = @MBVERSION@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ +binsuffix = @binsuffix@ noinst_LIBRARIES = libsed.a -noinst_HEADERS = regex-gnu.h getopt.h +noinst_HEADERS = regex-gnu.h getopt.h mbc.h mbfuncs.h xargs.h xargs32.h -libsed_a_SOURCES = getopt1.c getopt.c -EXTRA_DIST = memmove.c regex.c strerror.c +libsed_a_SOURCES = getopt1.c getopt.c mbc.c mbfuncs.c +EXTRA_DIST = memmove.c regex.c strerror.c xargs.c xargs32.c libsed_a_LIBADD = @LIBOBJS@ @ALLOCA@ @@ -82,9 +84,10 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -libsed_a_OBJECTS = getopt1.o getopt.o +libsed_a_OBJECTS = getopt1.o getopt.o mbc.o mbfuncs.o AR = ar CFLAGS = @CFLAGS@ -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ HEADERS = $(noinst_HEADERS) @@ -96,16 +99,18 @@ TAR = tar -GZIP = --best +GZIP_ENV = --best +DEP_FILES = .deps/alloca.P .deps/getopt.P .deps/getopt1.P .deps/mbc.P \ +.deps/mbfuncs.P .deps/memchr.P .deps/memcmp.P .deps/memmove.P \ +.deps/regex.P .deps/strerror.P SOURCES = $(libsed_a_SOURCES) OBJECTS = $(libsed_a_OBJECTS) -all: Makefile $(LIBRARIES) $(HEADERS) - +all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps lib/Makefile +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -121,7 +126,4 @@ maintainer-clean-noinstLIBRARIES: -.c.o: - $(COMPILE) -c $< - .s.o: $(COMPILE) -c $< @@ -148,6 +150,10 @@ ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) @@ -175,71 +181,120 @@ distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu lib/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file; \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ done -getopt.o: getopt.c ../config.h -getopt1.o: getopt1.c ../config.h getopt.h -regex.o: regex.c ../config.h regex-gnu.h - -info: -dvi: -check: all - $(MAKE) -installcheck: -install-exec: - @$(NORMAL_INSTALL) -install-data: - @$(NORMAL_INSTALL) +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) -install: install-exec install-data all - @: +-include $(DEP_FILES) -uninstall: +mostlyclean-depend: +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +all-redirect: all-am install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: - -rm -f Makefile $(DISTCLEANFILES) + -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \ - mostlyclean-tags mostlyclean-generic - -clean: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \ - mostlyclean - -distclean: distclean-noinstLIBRARIES distclean-compile distclean-tags \ - distclean-generic clean - -rm -f config.status +mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am -maintainer-clean: maintainer-clean-noinstLIBRARIES \ +distclean-am: distclean-noinstLIBRARIES distclean-compile \ + distclean-tags distclean-depend distclean-generic \ + clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ maintainer-clean-compile maintainer-clean-tags \ - maintainer-clean-generic distclean + maintainer-clean-depend maintainer-clean-generic \ + distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." +maintainer-clean: maintainer-clean-am + .PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags distdir info dvi installcheck \ -install-exec install-data install uninstall all installdirs \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean diff -u2rN sed-3.02/lib/Makefile.vc sed-3.02+mb1.09/lib/Makefile.vc --- sed-3.02/lib/Makefile.vc Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/Makefile.vc Sun Nov 19 17:44:19 2000 @@ -0,0 +1,24 @@ +libsed_a_OBJECTS = getopt1.obj getopt.obj mbc.obj mbfuncs.obj regex.obj xargs32.obj + +DEFS = -DWIN32 -DHAVE_CONFIG_H -I.. +CC = cl +CFLAGS = -W3 -O2 -GF -QI0f -QIfdiv +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LDFLAGS = /MACHINE:IX86 /SUBSYSTEM:CONSOLE +ARFLAGS = /MACHINE:IX86 /SUBSYSTEM:CONSOLE + +.SUFFIXES: +.SUFFIXES: .c .obj .lib .exe + +.c.obj: + $(COMPILE) -c $< + +libsed.lib: $(libsed_a_OBJECTS) + -if exist $@ del $@ + lib /OUT:$@ $(ARFLAGS) @<< +$(libsed_a_OBJECTS) +<< + +clean: + -if exist libsed.lib del libsed.lib + -if exist *.obj del *.obj diff -u2rN sed-3.02/lib/getopt.c sed-3.02+mb1.09/lib/getopt.c --- sed-3.02/lib/getopt.c Tue Apr 28 08:45:12 1998 +++ sed-3.02+mb1.09/lib/getopt.c Sun Nov 19 17:44:19 2000 @@ -73,4 +73,8 @@ #endif /* GNU C library. */ +#if defined MSDOS && !defined __GO32__ +#include +#endif + #ifdef VMS # include @@ -193,5 +197,5 @@ static char *posixly_correct; -#ifdef __GNU_LIBRARY__ +#if defined __GNU_LIBRARY__ || defined MSDOS /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. @@ -298,5 +302,5 @@ the new indices of the non-options in ARGV after they are moved. */ -#if defined __STDC__ && __STDC__ +#if (defined __STDC__ && __STDC__) || defined MSDOS static void exchange (char **); #endif @@ -384,5 +388,5 @@ /* Initialize the internal data when the first call is made. */ -#if defined __STDC__ && __STDC__ +#if (defined __STDC__ && __STDC__) || defined MSDOS static const char *_getopt_initialize (int, char *const *, const char *); #endif diff -u2rN sed-3.02/lib/getopt.h sed-3.02+mb1.09/lib/getopt.h --- sed-3.02/lib/getopt.h Sat Jun 21 13:31:18 1997 +++ sed-3.02+mb1.09/lib/getopt.h Sun Nov 19 17:44:19 2000 @@ -81,5 +81,5 @@ struct option { -#if defined (__STDC__) && __STDC__ +#if (defined (__STDC__) && __STDC__) || defined MSDOS const char *name; #else @@ -99,5 +99,5 @@ #define optional_argument 2 -#if defined (__STDC__) && __STDC__ +#if (defined (__STDC__) && __STDC__) || defined MSDOS #ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with diff -u2rN sed-3.02/lib/getopt1.c sed-3.02+mb1.09/lib/getopt1.c --- sed-3.02/lib/getopt1.c Tue Apr 14 08:54:17 1998 +++ sed-3.02+mb1.09/lib/getopt1.c Sun Nov 19 17:44:19 2000 @@ -28,8 +28,10 @@ #if !defined __STDC__ || !__STDC__ +#ifndef MSDOS /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const +#endif #endif #endif diff -u2rN sed-3.02/lib/mbc.c sed-3.02+mb1.09/lib/mbc.c --- sed-3.02/lib/mbc.c Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/mbc.c Mon Nov 27 23:28:28 2000 @@ -0,0 +1,198 @@ +/* Functions for multi-byte support. + Created for grep multi-byte extension Jul., 1993 by t^2 (Takahiro Tanimoto) + Last change: Feb 21, 1999 by wills (okabe katsuyuki) */ +#ifdef MSDOS +#ifndef __STDC__ +#define __STDC__ 1 +#endif +#endif +#include "mbc.h" + +static const unsigned char mbctab_ascii[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const unsigned char mbctab_euc[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +static const unsigned char mbctab_sjis[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + +static const unsigned char mbctab_utf8[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 +}; + +const unsigned char *mbctab = mbctab_ascii; +int current_mbctype = MBCTYPE_ASCII; + +void +#ifdef __STDC__ +mbcinit(int mbctype) +#else +mbcinit(mbctype) + int mbctype; +#endif +{ + switch (mbctype) { + case MBCTYPE_ASCII: + mbctab = mbctab_ascii; + current_mbctype = MBCTYPE_ASCII; + break; + case MBCTYPE_EUC: + mbctab = mbctab_euc; + current_mbctype = MBCTYPE_EUC; + break; + case MBCTYPE_SJIS: + mbctab = mbctab_sjis; + current_mbctype = MBCTYPE_SJIS; + break; + case MBCTYPE_UTF8: + mbctab = mbctab_utf8; + current_mbctype = MBCTYPE_UTF8; + break; + } +} + +mbchar_t +#ifdef __STDC__ +mbcfetch(const char *s, char **endptr) +#else +mbcfetch(s, endptr) + const char *s; + char **endptr; +#endif +{ + mbchar_t wc; + int n; + + if (current_mbctype == MBCTYPE_UTF8) { + wc = (unsigned char) *s++; + if ((n = mbclen(wc) - 1) > 0) { + wc &= 0x3f >> n; + while (n-- > 0) + wc = (wc << 6) | (*s++ & 0x3f); + } + } else { + wc = (unsigned char) *s++; + for (n = mbclen(wc) - 1; n > 0; n--) + wc = (wc << 8) | (unsigned char) *s++; + } + + if (endptr) + *endptr = (char *) s; + + return wc; +} + +char * +#ifdef __STDC__ +mbcstore(char *s, mbchar_t wc) +#else +mbcstore(s, wc) + char *s; + mbchar_t wc; +#endif +{ + mbchar_t mask; + int n; + char *ret; + + if (current_mbctype == MBCTYPE_UTF8) { + if (wc < 0x80) { + *s++ = (char) wc; + return s; + } + + mask = ~0x7ffL; + for (n = 2; n < 6; n++) { + if ((wc & mask) == 0) + break; + mask <<= 5; + } + + ret = s + n; + s[0] = (char) (~0xff >> n); + while (--n > 0) { + s[n] = 0x80 | (wc & 0x3f); + wc >>= 6; + } + s[0] |= wc; + } else { + mask = ~0xffL; + for (n = 1; n < 4; n++) { + if ((wc & mask) == 0) + break; + mask <<= 8; + } + + ret = s + n; + while (--n >= 0) { + s[n] = (char) wc; + wc >>= 8; + } + } + + return ret; +} diff -u2rN sed-3.02/lib/mbc.h sed-3.02+mb1.09/lib/mbc.h --- sed-3.02/lib/mbc.h Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/mbc.h Sun Nov 19 17:44:19 2000 @@ -0,0 +1,48 @@ +#ifndef MBC_H +#define MBC_H 1 +/* Definitions for multi-byte support. + Created for grep multi-byte extension Jul., 1993 by t^2 (Takahiro Tanimoto) + Last change: Feb. 10, 1999 by wills (okabe katsuyuki) */ + +#ifndef const +#ifndef __STDC__ +#ifdef __GNUC__ +#define const __const__ +#define volatile __volatile__ +#else +#ifndef MSDOS +#define const +#define volatile +#endif +#endif +#endif +#endif + +#ifndef _ +#if defined(__STDC__) || defined(MSDOS) +#define _(x) x +#else +#define _(x) () +#endif +#endif + +typedef unsigned long mbchar_t; + +#define MBCTYPE_ASCII 0 +#define MBCTYPE_EUC 1 +#define MBCTYPE_SJIS 2 +#define MBCTYPE_UTF8 3 + +extern const unsigned char *mbctab; +extern int current_mbctype; + +void mbcinit _((int)); +mbchar_t mbcfetch _((const char *, char **)); +char *mbcstore _((char *, mbchar_t)); + +#define ismbchar(c) mbctab[(unsigned char)(c)] + +#define MBCLEN_MAX 6 +#define mbclen(c) (mbctab[(unsigned char)(c)] + 1) + +#endif /* !MBC_H */ diff -u2rN sed-3.02/lib/mbfuncs.c sed-3.02+mb1.09/lib/mbfuncs.c --- sed-3.02/lib/mbfuncs.c Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/mbfuncs.c Sun Nov 19 17:44:19 2000 @@ -0,0 +1,133 @@ +/* Functions for multi-byte support. + Created for gawk multi-byte extension May, 1993 by t^2 (Takahiro Tanimoto) + Last change: May 21, 1997 by K.Okabe */ +#include +#include "mbfuncs.h" + +#define TOLOWER(c) (isupper((c)) ? tolower((c)) : (c)) + +int +#ifdef __STDC__ +mbstrncasecmp(const char *s1, const char *s2, size_t n) +#else +mbstrncasecmp(s1, s2, n) + const char *s1, *s2; + size_t n; +#endif +{ + int c1; + int c2; + + while (n--) { + if ((c1 = (unsigned char)*s1++) == 0) + return -(unsigned char)*s2; + c2 = (unsigned char)*s2++; + if (!ismbchar(c1)) { + if ((c1 = ((unsigned char)TOLOWER(c1) - (unsigned char)TOLOWER(c2))) != 0) + return c1; + } + else { + size_t len = mbclen(c1) - 1; + + if ((c1 -= (unsigned char)*s2++) != 0) + return c1; + + while (len--) { + if (!n--) + return 0; + if ((c1 = (unsigned char)*s1++) == 0) + return -(unsigned char)*s2; + if ((c1 -= (unsigned char)*s2++) != 0) + return c1; + } + } + } + return 0; +} + +int +#ifdef __STDC__ +mbmemcmp(const void *p1, size_t n1, const void *p2, size_t n2) +#else +mbmemcmp(p1, n1, p2, n2) + const void *p1, *p2; + size_t n1, n2; +#endif +{ + const unsigned char *s1 = p1, *s2 = p2; + unsigned char c1; + size_t n; + + for (;;) { + if (!n1--) + return n2 ? -1 : 0; + if (!n2--) + return 1; + if ((c1 = *s1++) != *s2++) { + s2--; + return ismbchar(c1) ? (ismbchar(*s2) ? (int)c1 - *s2 : 1): + (ismbchar(*s2) ? -1 : (int)c1 - *s2); + } + + if (!ismbchar(c1)) + continue; + for (n = mbclen(c1) - 1; n > 0; n--) { + if (!n1--) + return n2 ? -1 : 0; + if (!n2--) + return 1; + if (*s1++ != *s2++) + return (int)*--s1 - *--s2; + } + } +} + +size_t +#ifdef __STDC__ +mblength(const char *s, size_t len) +#else +mblength(s, len) + const char *s; + size_t len; +#endif +{ + const char *send; + + send = s + len; + len = 0; + while ((s += mbclen(*s)) <= send) + len++; + return len; +} + +size_t +#ifdef __STDC__ +mbbyte(const char *s, size_t len) +#else +mbbyte(s, len) + const char *s; + size_t len; +#endif +{ + const char *s0, *s1; + + if (current_mbctype == MBCTYPE_UTF8) { + if (len == 0) + return 0; + + s0 = s; + s1 = s + len; + s = s1 - 1; + while (s > s0 && ! ismbchar (*s) && ! ((unsigned char) *s < 0x80)) + s--; + return (s + mbclen(*s) == s1) ? len : s - s0 ; + } else { + s0 = s; + s1 = s + len; + for (s = s1; s-- > s0 && ismbchar (*s);) + ; + if (! ((s1 - s) & 1)) + len--; + return len; + } +} diff -u2rN sed-3.02/lib/mbfuncs.h sed-3.02+mb1.09/lib/mbfuncs.h --- sed-3.02/lib/mbfuncs.h Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/mbfuncs.h Sun Nov 19 17:44:19 2000 @@ -0,0 +1,21 @@ +#ifndef MBFUNCS_H +#define MBFUNCS_H 1 +/* Definitions for multi-byte support. + Created for sed multi-byte extension Feb., 1999 by wills (okabe katsuyuki) + Last change: Feb. 2, 1999 by wills */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#include "mbc.h" + +int mbstrncasecmp _((const char *, const char *, size_t)); +int mbmemcmp _((const void *, size_t, const void *, size_t)); +size_t mblength _((const char *, size_t)); +size_t mbbyte _((const char *, size_t)); + +#endif /* !MBFUNCS_H */ diff -u2rN sed-3.02/lib/regex-gnu.h sed-3.02+mb1.09/lib/regex-gnu.h --- sed-3.02/lib/regex-gnu.h Fri May 8 10:00:59 1998 +++ sed-3.02+mb1.09/lib/regex-gnu.h Sun Nov 19 17:44:19 2000 @@ -431,5 +431,5 @@ worth it. */ -#if __STDC__ +#if __STDC__ || defined MSDOS || defined WIN32 # define _RE_ARGS(args) args diff -u2rN sed-3.02/lib/regex.c sed-3.02+mb1.09/lib/regex.c --- sed-3.02/lib/regex.c Fri Jul 3 10:05:57 1998 +++ sed-3.02+mb1.09/lib/regex.c Mon Nov 27 23:00:58 2000 @@ -23,4 +23,7 @@ USA. */ +/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto) + Last change: Jan 22, 1999 by WILLs (Katsuyuki Okabe) */ + /* AIX requires this to be the first thing in the file. */ #if defined _AIX && !defined REGEX_MALLOC @@ -147,4 +150,7 @@ # define memcpy(d, s, n) (bcopy (s, d, n), (d)) # endif +# ifndef memmove +# define memmove(d, s, n) (bcopy (s, d, n), (d)) +# endif # endif # endif @@ -208,4 +214,5 @@ /* Get the interface, including the syntax bits. */ #include "regex-gnu.h" +#include "mbc.h" /* isalpha etc. are used for the character classes. */ @@ -263,5 +270,5 @@ (Per Bothner suggested the basic approach.) */ #undef SIGN_EXTEND_CHAR -#if __STDC__ +#if __STDC__ || defined MSDOS # define SIGN_EXTEND_CHAR(c) ((signed char) (c)) #else /* not __STDC__ */ @@ -297,5 +304,12 @@ # if HAVE_ALLOCA_H # include -# endif /* HAVE_ALLOCA_H */ +# else /* not HAVE_ALLOCA_H */ +# if defined _MSC_VER || defined __TURBOC__ +# include +# ifdef _MSC_VER +# define alloca _alloca +# endif +# endif /* !_MSC_VER && !__TURBOC__ */ +# endif /* not HAVE_ALLOCA_H */ # endif /* not __GNUC__ */ @@ -594,4 +608,28 @@ #endif /* DEBUG */ + +#define STORE_MBC(p, wc) do { \ + unsigned long _wc = (wc); \ + (p)[3] = (unsigned char) _wc; \ + (p)[2] = (unsigned char) (_wc >>= 8); \ + (p)[1] = (unsigned char) (_wc >>= 8); \ + (p)[0] = (unsigned char) (_wc >> 8); \ +} while (0) +#define STORE_MBC_AND_INCR(p, wc) do { \ + STORE_MBC((p), (wc)); \ + (p) += 4; \ +} while (0) + +#define EXTRACT_MBC(p) \ + ((((mbchar_t) (unsigned char) (p)[0]) << 24) \ + | (((mbchar_t) (unsigned char) (p)[1]) << 16) \ + | (((mbchar_t) (unsigned char) (p)[2]) << 8) \ + | ((mbchar_t) (unsigned char) (p)[3])) +#define EXTRACT_MBC_AND_INCR(p) ((p) += 4, EXTRACT_MBC(p - 4)) + +#define EXTRACT_UNSIGNED(p) \ + ((unsigned char) (p)[0] | (unsigned char) (p)[1] << 8) +#define EXTRACT_UNSIGNED_AND_INCR(p) \ + ((p) += 2, (unsigned char) (p)[-2] | (unsigned char) (p)[-1] << 8) /* If DEBUG is defined, Regex prints many voluminous messages about what @@ -688,4 +726,11 @@ do { + size_t n; + if (ismbchar (*p) && (n = mbclen(*p)) <= mcnt) { + printf ("/%.*s", n, (char *) p); + p += n; + mcnt -= (n - 1); + continue; + } putchar ('/'); putchar (*p++); @@ -749,7 +794,20 @@ putchar (last); - putchar (']'); - p += 1 + *p; + { + unsigned short i, size; + char buf0[8]; + char buf1[8]; + + size = EXTRACT_UNSIGNED_AND_INCR (p); + for (i = 0; i < size; i++) { + bzero (buf0, sizeof buf0); + bzero (buf1, sizeof buf1); + mbcstore (buf0, EXTRACT_MBC_AND_INCR (p)); + mbcstore (buf1, EXTRACT_MBC_AND_INCR (p)); + printf ("%s-%s", buf0, buf1); + } + } + putchar (']'); } break; @@ -1083,4 +1141,12 @@ change it ourselves. */ +#ifndef INT_IS_16BIT +#ifndef WIN32 +#if defined _MSC_VER || defined __TURBOC__ +#define INT_IS_16BIT +#endif +#endif +#endif + #ifdef INT_IS_16BIT @@ -1508,4 +1574,5 @@ static boolean at_endline_loc_p _RE_ARGS ((const char *p, const char *pend, reg_syntax_t syntax)); +#if 0 /* We don't use this. */ static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr, const char *pend, @@ -1513,4 +1580,5 @@ reg_syntax_t syntax, unsigned char *b)); +#endif /* Fetch the next character in the uncompiled pattern---translating it @@ -1522,5 +1590,6 @@ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ - if (translate) c = (unsigned char) translate[c]; \ + if (translate && !ismbchar (c)) \ + c = (unsigned char) translate[(unsigned char) (c)]; \ } while (0) #endif @@ -1536,4 +1605,12 @@ #define PATUNFETCH p-- +#define PATFETCH_MBC(wc) \ + do {if (p == pend || p + mbclen(*p) > pend) return REG_EEND; \ + { char *end; wc = mbcfetch (p, &end); p = end; } \ + if (translate && wc < (1 << BYTEWIDTH)) \ + wc = (mbchar_t) translate[(unsigned char) (wc)]; \ + } while (0) + + /* If `translate' is non-null, return translate[D], else just D. We @@ -1542,6 +1619,6 @@ when we use a character as a subscript we must make it unsigned. */ #ifndef TRANSLATE -# define TRANSLATE(d) \ - (translate ? (char) translate[(unsigned char) (d)] : (d)) +#define TRANSLATE(d) \ + (translate ? (unsigned char) translate[(unsigned char) (d)] : (d)) #endif @@ -1610,5 +1687,5 @@ reallocating to 0 bytes. Such thing is not going to work too well. You have been warned!! */ -#if defined _MSC_VER && !defined WIN32 +#if (defined _MSC_VER || defined __TURBOC__) && !defined WIN32 /* Microsoft C 16-bit versions limit malloc to approx 65512 bytes. The REALLOC define eliminates a flurry of conversion warnings, @@ -1746,4 +1823,249 @@ #endif +/* Handle charset(_not)?. + + Structure of charset(_not)? in compiled pattern. + + struct { + unsinged char id; charset(_not)? + unsigned char sbc_size; + unsigned char sbc_map[sbc_size]; same as original up to here. + unsigned short mbc_size; number of intervals. + struct { + uint32_t beg; beginning of interval. + uint32_t end; end of interval. + } intervals[mbc_size]; + }; */ +#define UTF8_CHARSET_SIZE 128 + +static reg_errcode_t +#if defined __STDC__ || defined MSDOS +set_list_bits (mbchar_t c1, mbchar_t c2, + reg_syntax_t syntax, unsigned char *b, const char *translate) +#else +set_list_bits (c1, c2, syntax, b, translate) + mbchar_t c1, c2; + reg_syntax_t syntax; + unsigned char *b; + const char *translate; +#endif +{ + unsigned char sbc_size = b[-1]; + unsigned short mbc_size = EXTRACT_UNSIGNED (&b[sbc_size]); + mbchar_t beg, end, upb; + boolean isutf8 = current_mbctype == MBCTYPE_UTF8; + size_t charset_size; + + if (c1 > c2) + return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; + charset_size = isutf8 ? UTF8_CHARSET_SIZE : (1 << BYTEWIDTH); + if (c1 < charset_size) { + upb = c2; + if (charset_size <= upb) + upb = charset_size - 1; /* The last single-byte char */ + if (sbc_size <= upb / BYTEWIDTH) { + /* Allocate maximum size so it never happens again. */ + /* NOTE: memcpy() would not work here. */ + memmove (&b[charset_size / BYTEWIDTH], &b[sbc_size], 2 + mbc_size*8); + bzero (&b[sbc_size], charset_size / BYTEWIDTH - sbc_size); + b[-1] = sbc_size = charset_size / BYTEWIDTH; + } + if (!translate) { + for (; c1 <= upb; c1++) + if (!ismbchar (c1)) + SET_LIST_BIT (c1); + } + else + for (; c1 <= upb; c1++) + if (!ismbchar (c1)) + SET_LIST_BIT (TRANSLATE (c1)); + if (c2 < charset_size) + return REG_NOERROR; + c1 = isutf8 ? 0x80 : 0x8000 ; /* The first wide char */ + } + b = &b[sbc_size + 2]; + + /* intervals[beg] + ●----------● ●----------● + c1 + ○----------------------● + + 上図のような区間のインデックス beg を決定する. */ + for (beg = 0, upb = mbc_size; beg < upb; ) { + mbchar_t mid = (beg + upb) >> 1; + + if (c1 - 1 > EXTRACT_MBC (&b[mid*8 + 4])) + beg = mid + 1; + else + upb = mid; + } + + /* intervals[end] + ●-------● ●----------● + c2 + ●---------------○ + + 上図のような区間のインデックス end を決定する. */ + for (end = beg, upb = mbc_size; end < upb; ) { + mbchar_t mid = (end + upb) >> 1; + + if (c2 >= EXTRACT_MBC (&b[mid*8]) - 1) + end = mid + 1; + else + upb = mid; + } + + if (beg != end) { + /* 既存の区間を少なくとも1つ統合する場合, + 区間の始点, 終点を修正する. */ + if (c1 > EXTRACT_MBC (&b[beg*8])) + c1 = EXTRACT_MBC (&b[beg*8]); + if (c2 < EXTRACT_MBC (&b[end*8 - 4])) + c2 = EXTRACT_MBC (&b[end*8 - 4]); + } + if (end < mbc_size && end != beg + 1) + /* 追加される区間の後ろに既存の区間を移動する. */ + /* NOTE: memcpy() would not work here. */ + memmove (&b[(beg + 1)*8], &b[end*8], (mbc_size - end)*8); + STORE_MBC (&b[beg*8 + 0], c1); + STORE_MBC (&b[beg*8 + 4], c2); + mbc_size += beg + 1 - end; + STORE_NUMBER (&b[-2], mbc_size); + return REG_NOERROR; +} + +static int +#if defined __STDC__ || defined MSDOS +is_in_list (mbchar_t c, const unsigned char *b) +#else +is_in_list (c, b) + mbchar_t c; + const unsigned char *b; +#endif +{ + unsigned short size; + int in = (re_opcode_t) b[-1] == charset_not; + boolean isutf8 = current_mbctype == MBCTYPE_UTF8; + + size = *b++; + if (c < (isutf8 ? UTF8_CHARSET_SIZE : (1 << BYTEWIDTH))) { + if (c / BYTEWIDTH < size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH) + in = !in; + } + else { + mbchar_t i, j; + + b += size + 2; + size = EXTRACT_UNSIGNED (&b[-2]); + + /* intervals[i] + ●-------● ●--------● + c + ○----------------● + + 上図のような区間のインデックス i を決定する. */ + for (i = 0, j = size; i < j; ) { + mbchar_t k = (i + j) >> 1; + + if (c > EXTRACT_MBC (&b[k*8 + 4])) + i = k + 1; + else + j = k; + } + if (i < size && EXTRACT_MBC (&b[i*8]) <= c + /* [...] から, 無効なマルチバイト文字を除外する. ここでは簡単の + ため2バイト目が '\n' または '\0' だけを無効とした. [^...] + の場合は, 逆に無効なマルチバイト文字をマッチさせる. */ + && (((unsigned char) c != '\n' && (unsigned char) c != '\0') || isutf8)) + in = !in; + } + return in; +} + +static boolean +#if defined __STDC__ || defined MSDOS +is_mblist_nooverlap (const unsigned char *b1, const unsigned char *b2) +#else +is_mblist_nooverlap (b1, b2) + const unsigned char *b1; + const unsigned char *b2; +#endif +{ + unsigned short size1; + mbchar_t c11; + mbchar_t c12; + unsigned short size2; + mbchar_t c21; + mbchar_t c22; + unsigned short i; + unsigned short j; + + b1 = &b1[2]; + size1 = EXTRACT_UNSIGNED (&b1[-2]); + b2 = &b2[2]; + size2 = EXTRACT_UNSIGNED (&b2[-2]); + for (i = 0; i < size1; i++) + { + c11 = EXTRACT_MBC (&b1[i * 8]); + c12 = EXTRACT_MBC (&b1[i * 8 + 4]); + for (j = 0; j < size2; j++) + { + c21 = EXTRACT_MBC (&b2[j * 8]); + c22 = EXTRACT_MBC (&b2[j * 8 + 4]); + if (! ((c22 < c11) || (c12 < c21))) + return false; + } + } + return true; +} + +static boolean +#if defined __STDC__ || defined MSDOS +is_invmblist_nooverlap (const unsigned char *b1, const unsigned char *b2) +#else +is_invmblist_nooverlap (b1, b2) + const unsigned char *b1; + const unsigned char *b2; +#endif +{ + unsigned short size2; + unsigned char *inv_b2; + unsigned short inv_size2; + boolean isutf8 = current_mbctype == MBCTYPE_UTF8; + unsigned short i; + mbchar_t c2; + mbchar_t c; + boolean ret; + + b2 = &b2[2]; + size2 = EXTRACT_UNSIGNED (&b2[-2]); + inv_b2 = REGEX_ALLOCATE (2 + 8 * (size2 + 2)); + inv_b2 = &inv_b2[2]; + + c = isutf8 ? 0x80 : 0x8000; /* The first wide char */ + inv_size2 = 0; + for (i = 0; i < size2; i++) { + c2 = EXTRACT_MBC (&b2[i * 8]) - 1; + if (c <= c2) { + STORE_MBC (&inv_b2[inv_size2 * 8], c); + STORE_MBC (&inv_b2[inv_size2 * 8 + 4], c2); + inv_size2++; + } + c = EXTRACT_MBC (&b2[i * 8 + 4]) + 1; + } + c2 = 0x7fffffffL; + STORE_MBC (&inv_b2[inv_size2 * 8], c); + STORE_MBC (&inv_b2[inv_size2 * 8 + 4], c2); + inv_size2++; + STORE_NUMBER (&inv_b2[-2], inv_size2); + inv_b2 = &inv_b2[-2]; + + ret = is_mblist_nooverlap(b1, inv_b2); + + REGEX_FREE (inv_b2); + + return ret; +} + #ifndef MATCH_MAY_ALLOCATE @@ -2112,4 +2434,6 @@ { boolean had_char_class = false; + mbchar_t c, c1; + long last_char = -1L; if (p == pend) FREE_STACK_RETURN (REG_EBRACK); @@ -2117,5 +2441,6 @@ /* Ensure that we have enough space to push a charset: the opcode, the length count, and the bitset; 34 bytes in all. */ - GET_BUFFER_SPACE (34); + /* + 2 + 8 for mbcharset(_not)? with just one interval. */ + GET_BUFFER_SPACE (34 + 2 + 8); laststart = b; @@ -2134,5 +2459,5 @@ /* Clear the whole map. */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); + bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH + 2); /* charset_not matches newline according to a syntax bit. */ @@ -2144,7 +2469,14 @@ for (;;) { + int size; + if (p == pend) FREE_STACK_RETURN (REG_EBRACK); - PATFETCH (c); + if ((size = EXTRACT_UNSIGNED (&b[(1 << BYTEWIDTH) / BYTEWIDTH]))) + /* Ensure the space is enough to hold another interval + of multi-byte chars in charset(_not)?. */ + GET_BUFFER_SPACE (32 + 2 + size*8 + 8); + + PATFETCH_RAW (c); /* \ might escape characters inside [...] and [^...]. */ @@ -2153,6 +2485,14 @@ if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); - PATFETCH (c1); - SET_LIST_BIT (c1); + PATFETCH_RAW (c1); + if (ismbchar (c1)) { + PATUNFETCH; + PATFETCH_MBC (c1); + (void) set_list_bits (c1, c1, syntax, b, translate); + last_char = c1; + continue; + } + SET_LIST_BIT (TRANSLATE (c1)); + last_char = c1; continue; } @@ -2169,4 +2509,9 @@ FREE_STACK_RETURN (REG_ERANGE); + if (ismbchar (c)) { + PATUNFETCH; + PATFETCH_MBC (c); + } + /* Look ahead to see if it's a range when the last thing was a character: if this is a hyphen not at the @@ -2174,10 +2519,23 @@ operator. */ if (c == '-' +#if 0 /* The original was: */ && !(p - 2 >= pattern && p[-2] == '[') && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') +#else /* I wonder why he did not write like this. + Have we got any problems? */ + && p != p1 + 1 +#endif && *p != ']') { - reg_errcode_t ret - = compile_range (&p, pend, translate, syntax, b); + reg_errcode_t ret; + + assert (last_char >= 0); + PATFETCH_RAW (c1); + if (ismbchar (c1)) { + PATUNFETCH; + PATFETCH_MBC (c1); + } + ret = set_list_bits (last_char, c1, syntax, b, translate); + last_char = c1; if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); } @@ -2188,7 +2546,13 @@ /* Move past the `-'. */ - PATFETCH (c1); + PATFETCH_RAW (c1); - ret = compile_range (&p, pend, translate, syntax, b); + PATFETCH_RAW (c1); + if (ismbchar (c1)) { + PATUNFETCH; + PATFETCH_MBC (c1); + } + ret = set_list_bits (c, c1, syntax, b, translate); + last_char = c1; if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); } @@ -2303,4 +2667,7 @@ had_char_class = true; #endif /* libc || wctype.h */ +#ifdef DEBUG + last_char = -1; +#endif } else @@ -2309,7 +2676,13 @@ while (c1--) PATUNFETCH; +#if 0 /* The original was: */ SET_LIST_BIT ('['); SET_LIST_BIT (':'); +#else /* I think this is the right way. */ + SET_LIST_BIT (TRANSLATE ('[')); + SET_LIST_BIT (TRANSLATE (':')); +#endif had_char_class = false; + last_char = ':'; } } @@ -2317,5 +2690,6 @@ { had_char_class = false; - SET_LIST_BIT (c); + (void) set_list_bits (c, c, syntax, b, translate); + last_char = c; } } @@ -2325,5 +2699,9 @@ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) b[-1]--; - b += b[-1]; + if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH) + memmove (&b[b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH], + 2 + EXTRACT_UNSIGNED (&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8); + b += b[-1] + 2 + EXTRACT_UNSIGNED (&b[b[-1]])*8; + break; } break; @@ -2812,5 +3190,6 @@ not to translate; but if we don't translate it it will never match anything. */ - c = TRANSLATE (c); + if (!ismbchar (c)) + c = TRANSLATE (c); goto normal_char; } @@ -2821,4 +3200,12 @@ /* Expects the character in `c'. */ normal_char: + + p1 = p; + if (ismbchar (c)) { + p += mbclen (c) - 1; + if (p > pend) + return REG_EEND; + } + /* If no exactn currently being built. */ if (!pending_exact @@ -2828,5 +3215,5 @@ /* We have only one byte following the exactn for the count. */ - || *pending_exact == (1 << BYTEWIDTH) - 1 + || *pending_exact >= (1 << BYTEWIDTH) - mbclen(c) /* If followed by a repetition operator. */ @@ -2850,4 +3237,8 @@ BUF_PUSH (c); (*pending_exact)++; + while (p1 < p) { + BUF_PUSH (*p1++); + (*pending_exact)++; + } break; } /* switch (c) */ @@ -3055,4 +3446,5 @@ +#if 0 /* We use set_list_bits() now. */ /* Read the ending character of a range (in a bracket expression) from the uncompiled pattern *P_PTR (which ends at PEND). We assume the @@ -3111,4 +3503,5 @@ return REG_NOERROR; } +#endif /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in @@ -3209,18 +3602,73 @@ case charset: + /* NOTE: Charset for single-byte chars never contain + multi-byte char. See set_list_bits(). */ for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) fastmap[j] = 1; + { + unsigned short size; + unsigned char c, end; + char buf[8], bufend[8]; + + p += p[-1] + 2; + size = EXTRACT_UNSIGNED (&p[-2]); + for (j = 0; j < size; j++) + { + /* set bits for 1st bytes of multi-byte chars. */ + mbcstore (buf, EXTRACT_MBC (&p[j*8])); + mbcstore (bufend, EXTRACT_MBC (&p[j*8 + 4])); + for (c = (unsigned char) buf[0], end = (unsigned char) bufend[0]; + c <= end; + c++) + /* NOTE: Charset for multi-byte chars might contain + single-byte chars. We must reject them. */ + if (ismbchar (c)) + fastmap[c] = 1; + } + } break; case charset_not: + /* S: set of all single-byte chars. + M: set of all first bytes that can start multi-byte chars. + s: any set of single-byte chars. + m: any set of first bytes that can start multi-byte chars. + + We assume S+M = U. + ___ _ _ + s+m = (S*s+M*m). */ /* Chars beyond end of map must be allowed. */ + /* NOTE: Charset_not for single-byte chars might contain + multi-byte chars. See set_list_bits(). */ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; + if (!ismbchar (j)) + fastmap[j] = 1; for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - fastmap[j] = 1; + if (!ismbchar (j)) + fastmap[j] = 1; + { + unsigned short size; + unsigned c, beg; + char buf[8]; + + p += p[-1] + 2; + size = EXTRACT_UNSIGNED (&p[-2]); + c = 0x00; + for (j = 0; j < size; j++) { + mbcstore (buf, EXTRACT_MBC (&p[j*8 + 0])); + for (beg = (unsigned char) buf[0]; c <= beg; c++) + if (ismbchar (c)) + fastmap[c] = 1; + mbcstore (buf, EXTRACT_MBC (&p[j*8 + 4])); + c = (unsigned char) buf[0]; + } + for (beg = 0xff; c <= beg; c++) + if (ismbchar (c)) + fastmap[c] = 1; + } break; @@ -3565,4 +4013,5 @@ register int lim = 0; int irange = range; + unsigned char c; if (startpos < size1 && startpos + range >= size1) @@ -3574,11 +4023,28 @@ inside the loop. */ if (translate) - while (range > lim - && !fastmap[(unsigned char) - translate[(unsigned char) *d++]]) + while (range > lim) { + c = *d++; + if (ismbchar (c)) { + size_t n; + if (fastmap[c]) + break; + d += (n = mbclen (c)) - 1; + range -= n; + continue; + } + if (fastmap[(unsigned char) translate[c]]) + break; range--; + } else - while (range > lim && !fastmap[(unsigned char) *d++]) + while (range > lim && (c = *d++, !fastmap[c])) { + if (ismbchar (c)) { + size_t n; + d += (n = mbclen (c)) - 1; + range -= n; + continue; + } range--; + } startpos += irange - range; @@ -3619,11 +4085,45 @@ else if (range > 0) { - range--; - startpos++; + const char *d = ((startpos >= size1 ? string2 - size1 : string1) + + startpos); + + if (ismbchar (*d)) { + size_t n; + range -= (n = mbclen (*d) - 1); + startpos += n; + if (range <= 0) + break; + } + range--, startpos++; } else { - range++; - startpos--; + range++, startpos--; + { + const char *s, *d, *p; + + if (startpos < size1) + s = string1, d = string1 + startpos; + else + s = string2, d = string2 + startpos - size1; + if (current_mbctype == MBCTYPE_UTF8) { + for (p = d; p > s && !ismbchar(*p) && !((unsigned char) *p < 0x80); p--) { + range++; + startpos--; + } + if (range > 0) + break; + } else { + for (p = d; p-- > s && ismbchar(*p); ) + /* --p >= s だと 80[12]?86 で動かない可能性がある. (huge + model 以外で, s のオフセットが 0 だった場合.) */ + ; + if (!((d - p) & 1)) { + if (!range) + break; + range++, startpos--; + } + } + } } } @@ -4029,5 +4529,5 @@ for (;;) { -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT2 ("\n%p: ", p); #else @@ -4225,7 +4725,22 @@ do { + unsigned char c; + PREFETCH (); - if ((unsigned char) translate[(unsigned char) *d++] - != (unsigned char) *p++) + c = *d++; + if (ismbchar (c)) { + size_t n; + if (c != (unsigned char) *p++) + goto fail; + for (n = mbclen (c) - 1; n > 0; n--) + if (!--mcnt /* パターンが正しくコンパイルさ + れている限り, このチェックは + 冗長だが念のため. */ + || d == dend + || (unsigned char) *d++ != (unsigned char) *p++) + goto fail; + continue; + } + if ((unsigned char) translate[c] != (unsigned char) *p++) goto fail; } @@ -4237,5 +4752,26 @@ { PREFETCH (); +#if 0 + /* 他の部分では, string1 と string2 にマルチバイト文字 + が跨るのを許していない. このことを速度を犠牲にして + もチェックする場合は, ここの `#if 0' を `#if 1' に + 変えること. */ + { + unsigned char c; + size_t n; + + c = (unsigned char) *d++; + if (c != (unsigned char) *p++) + goto fail; + if (ismbchar (c)) + for (n = mbclen (c) - 1; n > 0; n--) + if (!--mcnt + || d == dend + || (unsigned char) *d++ != (unsigned char) *p++) + goto fail; + } +#else if (*d++ != (char) *p++) goto fail; +#endif } while (--mcnt); @@ -4250,4 +4786,22 @@ PREFETCH (); + if (ismbchar (*d)) { + size_t i, n = mbclen (*d); + const char *p; + + if (d + n > dend) + goto fail; + for (p = d, i = n - 1; i > 0; i--) + if (*++p == '\n' || *p == '\0') + /* 無効なマルチバイト文字にはマッチさせない. ここでは, 簡 + 単のため2バイト目以降が '\n', '\0' のものだけを無効と + する. */ + goto fail; + + SET_REGS_MATCHED (); + DEBUG_PRINT2 (" Matched `%ld'.\n", (long) mbcfetch (d, NULL)); + d += n; + break; + } if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') @@ -4264,5 +4818,5 @@ case charset_not: { - register unsigned char c; + register mbchar_t c; boolean not = (re_opcode_t) *(p - 1) == charset_not; @@ -4270,18 +4824,21 @@ PREFETCH (); - c = TRANSLATE (*d); /* The character to match. */ + c = (unsigned char) *d; + if (ismbchar (c)) { + if (d + mbclen (c) > dend) + goto fail; + c = mbcfetch (d, NULL); + } + else + c = TRANSLATE (c); /* The character to match. */ - /* Cast to `unsigned' instead of `unsigned char' in case the - bit list is a full 32 bytes long. */ - if (c < (unsigned) (*p * BYTEWIDTH) - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; + not = is_in_list (c, p); - p += 1 + *p; + p += 1 + *p + 2 + EXTRACT_UNSIGNED (&p[1 + *p])*8; if (!not) goto fail; SET_REGS_MATCHED (); - d++; + d += mbclen (*d); break; } @@ -4639,5 +5196,5 @@ EXTRACT_NUMBER_AND_INCR (mcnt, p); -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT3 (" %d (to %p)", mcnt, p + mcnt); #else @@ -4736,5 +5293,5 @@ || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) { - register unsigned char c + register mbchar_t c = *p2 == (unsigned char) endline ? '\n' : p2[2]; @@ -4749,13 +5306,10 @@ || (re_opcode_t) p1[3] == charset_not) { - int not = (re_opcode_t) p1[3] == charset_not; + if (ismbchar (c)) + c = mbcfetch (&p2[2], NULL); - if (c < (unsigned char) (p1[4] * BYTEWIDTH) - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - /* `not' is equal to 1 if c would match, which means + /* `is_in_list()' is TRUE if c would match, which means that we can't change to pop_failure_jump. */ - if (!not) + if (!is_in_list (c, p1 + 4)) { p[-3] = (unsigned char) pop_failure_jump; @@ -4767,25 +5321,15 @@ { #ifdef DEBUG - register unsigned char c - = *p2 == (unsigned char) endline ? '\n' : p2[2]; + register mbchar_t c + = *p2 == (unsigned char) endline ? '\n' : p2[2]; #endif -#if 0 - if ((re_opcode_t) p1[3] == exactn - && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] - && (p2[2 + p1[5] / BYTEWIDTH] - & (1 << (p1[5] % BYTEWIDTH))))) -#else - if ((re_opcode_t) p1[3] == exactn - && ! ((int) p2[1] * BYTEWIDTH > (int) p1[4] - && (p2[2 + p1[4] / BYTEWIDTH] - & (1 << (p1[4] % BYTEWIDTH))))) -#endif - { + mbchar_t wc = mbcfetch (&p1[5], NULL); + if ((re_opcode_t) p1[3] == exactn && !is_in_list (wc, p2 + 1)) + { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", c, p1[5]); - } - + } else if ((re_opcode_t) p1[3] == charset_not) { @@ -4799,5 +5343,6 @@ break; - if (idx == p2[1]) + if (idx == p2[1] + && is_invmblist_nooverlap (&p2[2 + p2[1]], &p1[5 + p1[4]])) { p[-3] = (unsigned char) pop_failure_jump; @@ -4816,5 +5361,6 @@ break; - if (idx == p2[1] || idx == p1[4]) + if ((idx == p2[1] || idx == p1[4]) + && is_mblist_nooverlap (&p2[2 + p2[1]], &p1[5 + p1[4]])) { p[-3] = (unsigned char) pop_failure_jump; @@ -4859,5 +5405,5 @@ unconditional_jump: -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT2 ("\n%p: ", p); #else @@ -4871,5 +5417,5 @@ DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); p += mcnt; /* Do the jump. */ -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT2 ("(to %p).\n", p); #else @@ -4924,5 +5470,5 @@ p += 2; STORE_NUMBER_AND_INCR (p, mcnt); -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT3 (" Setting %p to %d.\n", p - 2, mcnt); #else @@ -4932,5 +5478,5 @@ else if (mcnt == 0) { -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT2 (" Setting two bytes from %p to no_op.\n", p+2); #else @@ -4952,5 +5498,5 @@ mcnt--; STORE_NUMBER (p + 2, mcnt); -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT3 (" Setting %p to %d.\n", p + 2, mcnt); #else @@ -4971,5 +5517,5 @@ p1 = p + mcnt; EXTRACT_NUMBER_AND_INCR (mcnt, p); -#ifdef _LIBC +#if defined _LIBC || defined MSDOS DEBUG_PRINT3 (" Setting %p to %d.\n", p1, mcnt); #else @@ -5433,7 +5979,20 @@ register const unsigned char *p1 = (const unsigned char *) s1; register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c; + while (len) { - if (translate[*p1++] != translate[*p2++]) return 1; + c = *p1++; + if (ismbchar(c)) { + size_t n; + if (c != *p2++) + return 1; + for (n = mbclen (c) - 1; n > 0; n--) + if (!--len || *p1++ != *p2++) + return 1; + } + else + if (translate[c] != translate[*p2++]) + return 1; len--; } @@ -5599,4 +6158,7 @@ = (cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; +#ifdef DEBUG + debug = 1; +#endif /* regex_compile will allocate the space for the compiled pattern. */ diff -u2rN sed-3.02/lib/xargs.c sed-3.02+mb1.09/lib/xargs.c --- sed-3.02/lib/xargs.c Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/xargs.c Sun Nov 19 17:44:19 2000 @@ -0,0 +1,949 @@ +/* $Id: xargs.c 2.3 1993/09/04 17:09:31 serow Exp serow $ + * + * wild card expand routine for BORLAND C, MS C, LSI C.. + * This code is in the public domain. + * + * $Log: xargs.c $ + * Revision 2.3 1993/09/04 17:09:31 serow + * _heapmin (MS-C) + * + * Revision 2.2 1993/05/22 04:33:02 serow + * 自前でargv[0]をつくる + * + * Revision 2.1 1993/01/20 10:43:04 serow + * v2 + * + */ +/* Last modified 1997.4.1 by K.Okabe */ + +#include +#include +#include +#include +#include +#include "xargs.h" + +#ifdef TEST +#define static +#endif + +static unsigned long xargs_rule = XARGS_CSH_LIKE_RULE; + +#define OnlySubDir (0x100) +#define AllFindAttr (0x17) +#define INVERTCHAR '^' +#define LBRACE '[' +#define RBRACE ']' +#define LCURLY '{' +#define RCURLY '}' +#define Isend(c) ((c) == '\0' || ((xargs_rule & XARGS_DOTBREAK) && (c) == '.')) +#define Iswild(c) ((c) == '*' || (c) == '?' || (c) == LBRACE || (c) == LCURLY) +#define Isalpha(c) (Isupper(c) || Islower(c)) +#define Isupper(c) ('A' <= (c) && (c) <= 'Z') +#define Islower(c) ('a' <= (c) && (c) <= 'z') +#define Isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r') +/* ascii only */ +#define Tolower(c) ((c) | 0x20) +/* Shift-JIS only */ +#if 1 /* patch 1997.1.29 by K.Okabe */ +#define isk1(c) dbcs_table[(unsigned char) (c)] +#else +#define isk1(c) ((0x81 <= (unsigned char)(c) && (unsigned char)(c) <= 0x9F)\ + || (0xE0 <= (unsigned char)(c) && (unsigned char)(c) <= 0xFC)) +#endif + +#define REALLOC_UNIT 128 + +#ifdef __TURBOC__ +#if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__) /* patch 1997.1.27 by K.Okabe */ +#define LARGE_DATA 1 +#endif +#else /* may be MS-C */ +#if defined(M_I86LM) || defined(M_I86CM) || defined(M_I86HM) +#define LARGE_DATA 1 +#endif +#endif + +#if defined(LSI_C) +/* union REGS dose not have '.cflag' but '.flags' */ +#define CFLAG(reg) ((reg).x.flags & 1) +#else +#define CFLAG(reg) ((reg).x.cflag) +#endif + +#if defined(_MSC_VER) || defined(__TURBOC__) +/* MS-C */ +#define NEAR _near +#else +#define NEAR +#endif + +#undef FP_OFF +#undef FP_SEG +#undef MK_FP +#define FP_OFF(fp) ((unsigned int)((unsigned long)((void far *)(fp)) & 0xFFFFL)) +#define FP_SEG(fp) ((unsigned int)((unsigned long)((void far *)(fp)) >> 16)) +#define MK_FP(sg, of) ((void far *)(((unsigned long)(sg) << 16)|(unsigned)(of))) + +typedef struct { + char d_buf[21]; + char d_attribute; + unsigned short d_time; + unsigned short d_date; + long d_size; + char d_name[13]; +} SFNDTA_BUF; + +typedef struct { + unsigned long d_attribute; + unsigned long d_ctime[2]; + unsigned long d_atime[2]; + unsigned long d_mtime[2]; + unsigned long d_size[2]; + unsigned long d_reserve[2]; + char d_longname[260]; + char d_name[14]; +} LFNDTA_BUF; + +typedef union { + SFNDTA_BUF sfn; + LFNDTA_BUF lfn; +} DTA_BUF; + +static DTA_BUF dta_buf; +#define dtabuf (dta_buf.sfn) +#define lfnbuf (dta_buf.lfn) + +static union REGS reg, nreg; +#ifdef LARGE_DATA +static struct SREGS sreg; +#endif + +static char ERNOMEM[] = "not enought memory.\r\n"; + +/* patch 1997.1.29 by K.Okabe */ +#define DBCS_TABLE_SIZE 256 +static unsigned char *dbcs_table = 0; +/* end of patch */ + +/* patch 1997.4.1 by K.Okabe */ +static int fhandle; +static int lfn_supported = -1; +static char * NEAR find_file_sfn(char *, int); +static char * NEAR find_file_lfn(char *, int); +static char *(NEAR *find_file)(char *, int) = find_file_sfn; +#ifdef LARGE_DATA +#define INTDOS(in,out,seg) intdosx((in),(out),(seg)) +#else +#define INTDOS(in,out,seg) intdos((in),(out)) +#endif +/* end of patch */ + +/***************************************************************/ + +static void NEAR +error(char * s) +{ + write(2, "xargs: ", 7); + write(2, s, strlen(s)); + exit(1); +} + +static char * NEAR +find_file_lfn(char *dir, int Attr) +{ + if (dir != (char *) 0) { /* get first entry */ + reg.x.ax = 0x714e; + reg.x.cx = (unsigned char) Attr; + reg.x.si = 1; +#ifdef LARGE_DATA + reg.x.di = FP_OFF(&lfnbuf); + sreg.es = FP_SEG(&lfnbuf); + reg.x.dx = FP_OFF(dir); + sreg.ds = FP_SEG(dir); +#else + reg.x.di = (unsigned) &lfnbuf; + reg.x.dx = (unsigned) dir; +#endif + INTDOS(®, &nreg, &sreg); + + if (CFLAG(nreg)) + return (char *) 0; + fhandle = nreg.x.ax; + } else { /* get next entry */ + retry: + reg.x.ax = 0x714f; + reg.x.bx = fhandle; + reg.x.si = 1; +#ifdef LARGE_DATA + reg.x.di = FP_OFF(&lfnbuf); + sreg.es = FP_SEG(&lfnbuf); +#else + reg.x.di = (unsigned) &lfnbuf; +#endif + INTDOS(®, &nreg, &sreg); + + if (CFLAG(nreg)) { + reg.x.ax = 0x71a1; + intdos(®, &nreg); + return (char *) 0; + } + } + + if ((lfnbuf.d_longname[0] == '.' && lfnbuf.d_longname[1] == '\0') + || (lfnbuf.d_longname[0] == '.' && lfnbuf.d_longname[1] == '.' && lfnbuf.d_longname[2] == '\0')) + goto retry; + + if ((Attr & OnlySubDir) && (lfnbuf.d_attribute & 0x10) == 0) + goto retry; + + if (lfnbuf.d_longname[0] == '.' && (xargs_rule & XARGS_HIDDENDOT) && (Attr & 2) == 0) + goto retry; + + return lfnbuf.d_longname; +} + +static void NEAR +set_dta(void) +{ + reg.h.ah = 0x1A; +#ifdef LARGE_DATA + reg.x.dx = FP_OFF(&dtabuf); + sreg.ds = FP_SEG(&dtabuf); +#else + reg.x.dx = (int) &dtabuf; +#endif + INTDOS(®, &nreg, &sreg); +} + +static char * NEAR +find_file_sfn(char *dir, int Attr) +{ + if (dir != (char *) 0) { /* get first entry */ + set_dta(); + reg.h.ah = 0x4E; + reg.h.cl = (char) Attr; +#ifdef LARGE_DATA + reg.x.dx = FP_OFF(dir); + sreg.ds = FP_SEG(dir); +#else + reg.x.dx = (unsigned) dir; +#endif + } else { /* get next entry */ + retry:; + set_dta(); + reg.h.ah = 0x4F; +#ifdef LARGE_DATA + reg.x.dx = FP_OFF(&dtabuf); + sreg.ds = FP_SEG(&dtabuf); +#else + reg.x.dx = (unsigned) &dtabuf; +#endif + } + INTDOS(®, &nreg, &sreg); + + if (CFLAG(nreg)) + return (char *) 0; + + if (dtabuf.d_name[0] == 5) + dtabuf.d_name[0] = (char) 0xE5; + + if (Attr & OnlySubDir) { + if ((dtabuf.d_attribute & 0x10) == 0) + goto retry; + if (dtabuf.d_name[0] == '.') + goto retry; + } + if (dtabuf.d_name[0] == '.' && (xargs_rule & XARGS_HIDDENDOT) && (Attr & 2) == 0) + goto retry; + + return dtabuf.d_name; +} + +static char * NEAR +jstrtolwr(char *p) +{ + char *op = p; + + while (*p) { + if (isk1(*p) && p[1]) + p++; + else if (Isupper(*p)) + *p = (char) Tolower(*p); + p++; + } + return op; +} + +static char * NEAR +jrindex(char *p, int c) +{ + char *oldp; + + c &= 0xFF; + for (oldp = 0; *p; p++) { + if (isk1(*p) && p[1]) { + p++; + } else if (((*p) & 0xFF) == c) { + oldp = p; + } + } + return oldp; +} + +static int +ustrcmp(void const *s1, void const *s2) +{ + unsigned char *p1 = *(unsigned char **)s1; + unsigned char *p2 = *(unsigned char **)s2; + + while ((*p1 != '\0') && (*p1 == *p2)) { + p1++; + p2++; + } + return *p1 - *p2; +} + +static char * NEAR +xmalloc(size_t n) +{ + char *bp; + + if ((bp = calloc(1, n)) == (char *) 0) + error(ERNOMEM); + return bp; +} + +static char * NEAR +xrealloc(void *blk, size_t n) +{ + char *bp; + + if ((bp = realloc(blk, n)) == (char *) 0) + error(ERNOMEM); +#ifdef _MSC_VER + _heapmin(); +#endif + return bp; +} +static void NEAR +xfree(void *p) +{ + if (p) + free(p); +#ifdef _MSC_VER + _heapmin(); +#endif +} + +/* patch 1997.1.29 by K.Okabe */ +static void NEAR +dbcs_alloc(void) +{ + struct SREGS segs; + union REGS regs; + unsigned char far *ptr; + + if (dbcs_table != 0) + return; + + dbcs_table = (unsigned char *) xmalloc(DBCS_TABLE_SIZE); + segs.ds = regs.x.si = 0; + regs.x.ax = 0x6300; + intdosx(®s, ®s, &segs); + ptr = (unsigned char far *) MK_FP(segs.ds + (regs.x.si >> 4), regs.x.si & 15); + if (ptr == (unsigned char far *) 0L) + return; + + for (;;) { + int lo, hi, c; + + lo = *ptr++; + hi = *ptr++; + if (lo == 0 && hi == 0) + break; + + for (c = lo; c <= hi; c++) + dbcs_table[c] = 1; + } +} +/* end of patch */ + +/* patch 1997.4.1 by K.Okabe */ +static int NEAR +get_drive(void) +{ + reg.h.ah = 0x19; + intdos(®, &nreg); + return (unsigned char) nreg.h.al; +} + +static void NEAR +check_lfn(char *path) +{ + char buf[32]; + char *root; + char *env; + + find_file = find_file_sfn; + + if (lfn_supported == -1) + lfn_supported = ((env = getenv("XARGS")) != 0 && strstr(env, "LFN") != 0) + || ((env = getenv("LFN")) != 0 && Tolower(env[0]) != 'n'); + + if (lfn_supported == 0) + return; + + if ((xargs_rule & XARGS_USELFN) == 0) + return; + + root = xmalloc(strlen(path) + 4); + if (path[0] == '\\' && path[1] == '\\') { + strcpy(root, path); + } else { + root[0] = Isalpha(path[0]) && path[1] == ':' ? path[0] : get_drive() + 'A' ; + root[1] = ':'; + root[2] = '\\'; + root[3] = '\0'; + } + + reg.x.ax = 0x71a0; +#ifdef LARGE_DATA + reg.x.di = FP_OFF(buf); + sreg.es = FP_SEG(buf); + reg.x.dx = FP_OFF(root); + sreg.ds = FP_SEG(root); +#else + reg.x.di = (unsigned) buf; + reg.x.dx = (unsigned) root; +#endif + + INTDOS(®, &nreg, &sreg); + + xfree(root); + + if (CFLAG(nreg)) + return; + + find_file = find_file_lfn; +} +/* end of patch */ + +static int NEAR +has_glob_char(char *pat) +{ + int c; + + while ((c = *pat++) != '\0') { + if (Iswild(c)) + return 1; + if (isk1(c) && *pat) + pat++; + } + return 0; +} + +#define Scan(c, p) {\ + c = (unsigned char)(*p++);\ + if (isk1(c) && *p) \ + c = (c << 8) + (unsigned char)(*p++);\ + else if (Isupper(c))\ + c = Tolower(c);\ + } +#define ScanRaw(c, p) {\ + c = (unsigned char)(*p++);\ + if (isk1(c) && *p)\ + c = (c << 8) + (unsigned char)(*p++);\ + } + +static int NEAR +glob_match(char *text, char *pattern) +{ + int include, exclude; + unsigned int ks, ke, kp, kt; + char *start, *stop; + + while (*pattern) { + switch (*pattern) { + case LCURLY: + if (Isend(*text)) + return 0; + stop = start = text; + pattern++; + do { + text = start; + include = 1; + do { + if (Isend(*pattern)) + return 0; /*ERMISSCURLY*/ + Scan(kt, text); + Scan(kp, pattern); + if (kt != kp) + include = 0; + } while (*pattern != ',' && *pattern != RCURLY); + + if (include && text - start > stop - start) + stop = text; + if (*pattern == ',') + pattern++; + } while (*pattern != RCURLY); + if (stop == start) + return 0; + pattern++; + text = stop; + break; + + case '?': + if (Isend(*text)) + return 0; + ScanRaw(kt, text); + pattern++; + break; + + case '*': + while ((include = glob_match(text, pattern + 1)) == 0 && !Isend(*text)) { + ScanRaw(kt, text); + } + return include; + + case LBRACE: + if (Isend(*text)) + return 0; + include = exclude = 0; + pattern++; + if (*pattern == INVERTCHAR) { + exclude = 1; + pattern++; + } + Scan(kt, text); + do { + if (Isend(*pattern)) + return 0; /*ERMISSBRACKET*/ + Scan(ks, pattern); + ke = ks; + if (*pattern == '-' && *(pattern + 1) != RBRACE) { + pattern++; + if (Isend(*pattern)) + return 0; /*ERMISSBRACKET*/ + Scan(ke, pattern); + } + if (ks <= kt && kt <= ke) { + include = 1; + /* no break to checking missing brace */ + /*break;*/ + } + } while (*pattern != RBRACE); + + if (include == exclude) + return 0; + pattern++; + break; + + case '.': + if (xargs_rule & XARGS_DOTBREAK) { + if (!Isend(*text)) + return 0; + if (*text == '.') + text++; + pattern++; + break; + } + default: + Scan(kt, text); + Scan(kp, pattern); + if (kt != kp) + return 0; + } + } + return *text == '\0' ? 1 : 0; +} + +static char * NEAR +jrpathdlm(char *s) +{ + char *ap, *ap1, *ap2; + + ap1 = jrindex(s, '\\'); + ap2 = jrindex(s, '/'); + if ((ap = (ap1 < ap2) ? ap2 : ap1) == (char *) 0) + ap = jrindex(s, ':'); + return ap; +} + +char ** +glob_filename(char *pattern) +{ + char *ap, *ap1, *ap2; + char **res; + char *pat; + char **paths; + char *dirp; + char *wld; + char *pp; + int ra, ri, i, plen; + int np; + int attr = ((int) (xargs_rule & 0xFF)); + + /* patch 1997.1.29 by K.Okabe */ + dbcs_alloc(); + /* end of patch */ + ap = jrpathdlm(pattern); + if (ap && ap[0] != ':' && ap[1] == '\0') { + attr = AllFindAttr | OnlySubDir; + pp = (char *) xmalloc(strlen(pattern) + 1); + strcpy(pp, pattern); + pp[(int) (ap - pattern)] = '\0'; + ap = jrpathdlm(pp); + if (ap) + ap = pattern + (int) (ap - pp); + xfree(pp); + } + if (ap) { + pat = xmalloc(strlen(ap + 1) + 1); + strcpy(pat, ap + 1); + ap2 = dirp = (char *) xmalloc((int) (ap - pattern) + 2); + for (ap1 = pattern; ap1 <= ap; ap1++) + *ap2++ = *ap1; + *ap2 = '\0'; + if (ap[0] != ':' && has_glob_char(dirp)) { + paths = glob_filename(dirp); + xfree(dirp); + } else { + paths = (char **) xmalloc(sizeof(paths[0]) * 2); + paths[0] = dirp; + paths[1] = (char *) 0; + } + } else { + pat = xmalloc(strlen(pattern) + 1); + strcpy(pat, pattern); + paths = (char **) xmalloc(sizeof(paths[0]) * 2); + paths[0] = (char *) xmalloc(2); + paths[1] = (char *) 0; + strcpy(paths[0], ""); + } + ap = jrpathdlm(pat); + if (ap && ap[0] != ':' && ap[1] == '\0') { + ap[0] = '\0'; + } + res = (char **) xmalloc(sizeof(char *) * (ra = 128)); + ri = 0; + res[ri] = 0; + for (i = 0; paths[i]; i++) { + check_lfn(paths[i]); + plen = strlen(paths[i]); + wld = xmalloc(plen + 5); + strcpy(wld, paths[i]); + ap = jrpathdlm(wld); + if (plen == 0 || (ap && ap[1] == '\0')) { + np = 0; + } else { + strcat(wld, "/"); + np = 1; + } + strcat(wld, "*.*"); + if ((ap = find_file(wld, attr)) != (char *) 0) { + do { + if (glob_match(ap, pat)) { + if (xargs_rule & XARGS_CVLOWER) + jstrtolwr(ap); + res[ri] = xmalloc(plen + strlen(ap) + 2); + strcat(strcat(strcpy(res[ri], paths[i]), np ? "/" : ""), ap); + res[++ri] = (char *) 0; + if (ri >= ra - 2) { + res = (char **) xrealloc(res, sizeof(char *) * (ra += 128)); + } + } + } while ((ap = find_file((char *) 0, attr)) != (char *) 0); + } + xfree(wld); + } + if (ri) { + if (xargs_rule & XARGS_DOSORT) + qsort(&res[0], ri, sizeof(res[0]), ustrcmp); + } else { + strcpy(res[ri] = xmalloc(strlen(pattern) + 1), pattern); + res[++ri] = (char *) 0; + } + xfree(pat); + for (i = 0; paths[i]; i++) + xfree(paths[i]); + xfree(paths); + return res; +} + +/******/ +struct inputredir { + int type; +#define IP_FILE 1 +#define IP_MEM 2 + struct inputredir *next; + union { + FILE *fp; + char *cp; + } i; +}; +static struct inputredir *iroot = 0; + +static void NEAR +add_input(void *p, int type) +{ + struct inputredir *ip; + + ip = (struct inputredir *) xmalloc(sizeof(struct inputredir)); + ip->type = type; + ip->i.cp = p; + if (iroot) { + ip->next = iroot; + iroot = ip; + } else { + iroot = ip; + iroot->next = 0; + } +} + +static int pushbackc = -1; + +static int NEAR +nextc(void) +{ + int c; + struct inputredir *lip; + + if (pushbackc != -1) { + c = pushbackc; + pushbackc = -1; + return c; + } + if (iroot == 0) + return EOF; + switch (iroot->type) { + case IP_FILE: + if ((c = fgetc(iroot->i.fp)) == EOF) { + fclose(iroot->i.fp); + lip = iroot; + iroot = iroot->next; + xfree(lip); + c = nextc(); + } + break; + case IP_MEM: + if ((c = *(iroot->i.cp++)) == '\0') { + lip = iroot; + iroot = iroot->next; + xfree(lip); + c = nextc(); + } + break; + default: + c = EOF; + break; + } + return c; +} +static void NEAR +pushback(int c) +{ + pushbackc = c; +} + +/******/ + +static void NEAR +setav(char *NCptr, int *_ARGC, char ***_ARGV) +{ + int c, i, jf, at; + int quote, withwild; + char *ap; + char *buf; + size_t absiz; + size_t bfsiz; +#define argbuf (*_ARGV) +#define argcnt (*_ARGC) + char **res; + FILE *fp; + + buf = (char *) xmalloc((bfsiz = REALLOC_UNIT * 2) * sizeof(char)); + argbuf = (char **) xmalloc((absiz = REALLOC_UNIT) * sizeof(char *)); + argcnt = 0; + + add_input(NCptr, IP_MEM); + + while ((c = nextc()) != EOF) { + withwild = quote = 0; + while (Isspace(c)) + c = nextc(); + if (c == EOF) + break; + at = (c == '@') ? 1 : 0; + ap = buf; + jf = 0; + do { + if (ap == &buf[bfsiz - 1]) { + buf = (char *) xrealloc(buf, (bfsiz + REALLOC_UNIT) * sizeof(buf[0])); + ap = &buf[bfsiz - 1]; + bfsiz += REALLOC_UNIT; + } + if (jf || isk1(c)) { + *ap++ = (char) c; + jf = !jf; + continue; + } + if (!quote && Iswild(c)) + withwild = 1; + if (c == quote) { /* end of quoted string */ + quote = 0; + } else if (!quote && (c == '\'' || c == '"')) { + quote = c; + } else { + if (c == '\\') { + c = nextc(); + if (c != '"' && c != '\'') { + pushback(c); + c = '\\'; + } + } + *ap++ = (char) c; + } + } while ((c = nextc()) != EOF && (quote || !Isspace(c))); + *ap = 0; + if ((xargs_rule & XARGS_ATRESP) && at) { + if ((fp = fopen(buf + 1, "r")) != 0) { + add_input(fp, IP_FILE); + continue; + } else { + /* ignore */ + } + } + if (withwild) { + res = glob_filename(buf); + } else { + res = (char **) xmalloc(sizeof(char *) * 2); + strcpy(res[0] = (char *) xmalloc(strlen(buf) + 1), buf); + res[1] = (char *) 0; + } + for (i = 0; res[i]; i++) { + argbuf[argcnt++] = res[i]; + if ((size_t) argcnt >= absiz) { + argbuf = (char **) xrealloc(argbuf, (absiz += REALLOC_UNIT) * sizeof(argbuf[0])); + } + } + xfree(res); + } + argbuf[argcnt] = (char *) 0; + argbuf = (char **) xrealloc(argbuf, (argcnt + 1) * sizeof(argbuf[0])); + xfree(buf); +} + +unsigned long +xargs_set_rule(unsigned long rule) +{ + unsigned long lastrule; + + lastrule = xargs_rule; + xargs_rule = rule; + return lastrule; +} + +unsigned long +xargs_modify_rule(unsigned long mask, unsigned long rule) +{ + unsigned long lastrule; + + lastrule = xargs_rule; + xargs_rule = (xargs_rule & ~mask) | rule; + return lastrule; +} + +void +xargs(int *argc, char ***argv) +{ + char far *pp; + char *s; + int i, j; + int jf = 0; + int li = 0; + int sa = 0; + +#if defined(GAWK) && defined(OS2) && (_MSC_VER != 510) /* patch 1997.2.20 by K.Okabe */ + if (_osmode == OS2_MODE) + return; +#endif + + /* patch 1997.1.29 by K.Okabe */ + dbcs_alloc(); + /* end of patch */ + if (!(xargs_rule & XARGS_USECMDL) + || (s = getenv("CMDLINE")) == 0 + || getenv("NOCMDLINE") != 0) { + sa = 1; + if (_osmajor >= 3) { + pp = MK_FP(*(unsigned int far *)MK_FP(_psp, 0x2C), 0); /* environ */ + while (pp[0] != 0 || pp[1] != 0) + pp++; + pp += 4; + } else { + pp = "xargs"; + } + s = xmalloc(1024); + for (i = 0; (s[i] = *pp++) != '\0'; i++) { + if (jf) { + jf = 0; + continue; + } + if (isk1(s[i]) && !jf) { + jf = 1; + continue; + } + if ((xargs_rule & XARGS_0CVLOWER) && Isupper(s[i])) + s[i] = (char) Tolower(s[i]); + if (s[i] == '.') + li = i; + if (s[i] == '/' || s[i] == '\\') + li = 0; + if ((xargs_rule & XARGS_0CVSLASH) && s[i] == '\\') + s[i] = '/'; + } + if ((xargs_rule & XARGS_0REMOVEXT) && li && li != i - 1) { + i = li; + s[i] = 0; + } + pp = MK_FP(_psp, 128); + j = *pp++; + while ((*pp == ' ' || *pp == '\t') && j) { + pp++; + j--; + } + if (j) + s[i++] = ' '; + while (j--) { + s[i++] = *pp++; + } + s[i] = 0; + } + setav(s, argc, argv); + if (sa) + xfree(s); +} + + +#ifdef TEST +#include + +static char QUOTE[]= "\033[33m\"\033[m"; + +void +main(int argc, char **argv) +{ + int a = 0; + + /*xargs_modify_rule(XARGS_DOTBREAK, XARGS_DOTBREAK);*/ + xargs(&argc, &argv); + + printf("[argv]-------------------------- %d argument(s)\n", argc); + while (argc--) { + printf("[%4d]%s%s%s\n", a++, QUOTE, *argv++, QUOTE); + } + printf("-------------------------------- Thats all\n"); +} + +#endif diff -u2rN sed-3.02/lib/xargs.h sed-3.02+mb1.09/lib/xargs.h --- sed-3.02/lib/xargs.h Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/xargs.h Sun Nov 19 17:44:19 2000 @@ -0,0 +1,66 @@ +/* $Id: xargs.h 2.1 1993/01/20 10:43:04 serow Exp serow $ + * + * header for xargs.c + * This code is in the public domain. + * + * $Log: xargs.h $ + * Revision 2.1 1993/01/20 10:43:04 serow + * v2 + * + */ + +#ifndef _INC_XARGS +#ifdef __cplusplus +extern "C" { +#endif + +/* The following bits are used in the xargs_rule variable + to select globbing rule */ + +#define XARGS_F_RO (1L ) /* attribute for find file. */ +#define XARGS_F_HID (1L << 1L) /* */ +#define XARGS_F_SYS (1L << 2L) /* */ +#define XARGS_F_VOL (1L << 3L) /* */ +#define XARGS_F_DIR (1L << 4L) /* */ + +#define XARGS_DOTBREAK (1L << 8L) /* ?, * doesnot math with '.' */ +#define XARGS_HIDDENDOT (1L << 9L) /* treat '.' & '..' as hidden file */ +#define XARGS_DOSORT (1L << 12L) /* wild card args will be sorted by name */ +#define XARGS_CVLOWER (1L << 13L) /* convert filenames to lower case */ +#define XARGS_ATRESP (1L << 14L) /* @responsefile */ +#define XARGS_USECMDL (1L << 16L) /* get arg from "CMDLINE" environ if there */ +#define XARGS_USELFN (1L << 17L) /* enable long file name */ +#define XARGS_0CVLOWER (1L << 20L) /* convert argv[0] to lower case */ +#define XARGS_0CVSLASH (1L << 21L) /* convert '\\' to '/' in argv[0] */ +#define XARGS_0REMOVEXT (1L << 22L) /* remove extention from argv[0] */ + +/* typical rules */ + +#define XARGS_CSH_LIKE_RULE (\ + XARGS_F_RO|XARGS_F_DIR|XARGS_F_SYS \ + |XARGS_HIDDENDOT \ + |XARGS_DOSORT \ + |XARGS_CVLOWER \ + |XARGS_ATRESP \ + |XARGS_0CVLOWER \ + |XARGS_0CVSLASH \ + |XARGS_0REMOVEXT \ + ) + +#define XARGS_MESSY_RULE (\ + XARGS_F_RO|XARGS_F_SYS \ + |XARGS_DOTBREAK \ + |XARGS_HIDDENDOT \ + ) + +/* prototypes */ + +char ** glob_filename(char *pattern); +unsigned long xargs_set_rule(unsigned long rule); +unsigned long xargs_modify_rule(unsigned long mask, unsigned long rule); +void xargs(int *argc, char ***argv); +#ifdef __cplusplus +} +#endif +#define _INC_XARGS 1 +#endif /* _INC_XARGS */ diff -u2rN sed-3.02/lib/xargs32.c sed-3.02+mb1.09/lib/xargs32.c --- sed-3.02/lib/xargs32.c Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/xargs32.c Sun Nov 19 17:44:19 2000 @@ -0,0 +1,719 @@ +/* Id: xargs.c 2.3 1993/09/04 17:09:31 serow Exp serow + * + * wild card expand routine for BORLAND C, MS C, LSI C.. + * This code is in the public domain. + * + * $Log: xargs32.c $ + * Revision 1.2 1997/07/18 17:13:11 koichik + * 32bit対応の抜けに対処 + * + * Revision 1.1 1997/04/27 15:01:25 koichik + * Initial revision + * + * Revision 2.3 1993/09/04 17:09:31 serow + * _heapmin (MS-C) + * + * Revision 2.2 1993/05/22 04:33:02 serow + * 自前でargv[0]をつくる + * + * Revision 2.1 1993/01/20 10:43:04 serow + * v2 + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "xargs32.h" + +#ifdef TEST +#define static +#endif + +static unsigned long xargs_rule = XARGS_CSH_LIKE_RULE; + +#define OnlySubDir (1<<31) +#define AllFindAttr (0xB7) +#define INVERTCHAR '^' +#define LBRACE '[' +#define RBRACE ']' +#define LCURLY '{' +#define RCURLY '}' +#define Isend(c) ((c) == '\0' || ((xargs_rule & XARGS_DOTBREAK) && (c) == '.')) +#define Iswild(c) ((c) == '*' || (c) == '?' || (c) == LBRACE || (c) == LCURLY) +#define Isupper(c) ('A' <= (c) && (c) <= 'Z') +#define Isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r') +/* ascii only */ +#define Tolower(c) ((c) | 0x20) +/* Shift-JIS only */ +#define isk1(c) ((0x81 <= (unsigned char)(c) && (unsigned char)(c) <= 0x9F)\ + || (0xE0 <= (unsigned char)(c) && (unsigned char)(c) <= 0xFC)) + +#define REALLOC_UNIT 512 + +static char ERNOMEM[] = "not enought memory.\r\n"; + +/***************************************************************/ + +static void +error(char * s) +{ + write(2, "xargs: ", 7); + write(2, s, strlen(s)); + exit(1); +} + +static char * +find_file(char *dir, HANDLE *hFind, DWORD Attr, WIN32_FIND_DATA *dta) +{ + char *ret = NULL; + + assert(hFind != NULL); + + if (*hFind == INVALID_HANDLE_VALUE) { /* get first entry */ + dta->dwFileAttributes = (DWORD)(Attr & 0xffff); + if ((*hFind = FindFirstFile(dir, dta)) != INVALID_HANDLE_VALUE) + ret = dta->cFileName; + } else { /* get next entry */ +retry: + ret = NULL; + if (FindNextFile(*hFind, dta)) + ret = dta->cFileName; + } + + if (ret == NULL) + return NULL; + + if (!strcmp(ret, "..") || !strcmp(ret, ".")) + goto retry; + + if ((Attr & OnlySubDir) && (dta->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + goto retry; + + if (dta->cFileName[0] == '.' && (xargs_rule & XARGS_HIDDENDOT) + && (dta->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0) + goto retry; + + return ret; +} + +static char * +jstrtolwr(char *p) +{ + char *op = p; + + while (*p) { + if (isk1(*p) && p[1]) + p++; + else if (Isupper(*p)) + *p = (char) Tolower(*p); + p++; + } + return op; +} + +static char * +jrindex(char *p, int c) +{ + char *oldp; + + c &= 0xFF; + for (oldp = 0; *p; p++) { + if (isk1(*p) && p[1]) { + p++; + } else if (((*p) & 0xFF) == c) { + oldp = p; + } + } + return oldp; +} + +static int +ustrcmp(void const *s1, void const *s2) +{ + unsigned char *p1 = *(unsigned char **)s1; + unsigned char *p2 = *(unsigned char **)s2; + + while ((*p1 != '\0') && (*p1 == *p2)) { + p1++; + p2++; + } + return *p1 - *p2; +} + +static char * +xmalloc(size_t n) +{ + char *bp; + + if ((bp = calloc(1, n)) == (char *) 0) + error(ERNOMEM); + return bp; +} + +static char * +xrealloc(void *blk, size_t n) +{ + char *bp; + + if ((bp = realloc(blk, n)) == (char *) 0) + error(ERNOMEM); + + return bp; +} +static void +xfree(void *p) +{ + if (p) + free(p); + +} + +static int +has_glob_char(char *pat) +{ + int c; + + while ((c = *pat++) != '\0') { + if (Iswild(c)) + return 1; + if (isk1(c) && *pat) + pat++; + } + return 0; +} + +#define Scan(c, p) {\ + c = (unsigned char)(*p++);\ + if (isk1(c) && *p) \ + c = (c << 8) + (unsigned char)(*p++);\ + else if (Isupper(c))\ + c = Tolower(c);\ + } +#define ScanRaw(c, p) {\ + c = (unsigned char)(*p++);\ + if (isk1(c) && *p)\ + c = (c << 8) + (unsigned char)(*p++);\ + } + +static int +glob_match(char *text, char *pattern) +{ + int include, exclude; + unsigned int ks, ke, kp, kt; + char *start, *stop; + + while (*pattern) { + switch (*pattern) { + case LCURLY: + if (Isend(*text)) + return 0; + stop = start = text; + pattern++; + do { + text = start; + include = 1; + do { + if (Isend(*pattern)) + return 0; /*ERMISSCURLY*/ + Scan(kt, text); + Scan(kp, pattern); + if (kt != kp) + include = 0; + } while (*pattern != ',' && *pattern != RCURLY); + + if (include && text - start > stop - start) + stop = text; + if (*pattern == ',') + pattern++; + } while (*pattern != RCURLY); + if (stop == start) + return 0; + pattern++; + text = stop; + break; + + case '?': + if (Isend(*text)) + return 0; + ScanRaw(kt, text); + pattern++; + break; + + case '*': + while ((include = glob_match(text, pattern + 1)) == 0 && !Isend(*text)) { + ScanRaw(kt, text); + } + return include; + + case LBRACE: + if (Isend(*text)) + return 0; + include = exclude = 0; + pattern++; + if (*pattern == INVERTCHAR) { + exclude = 1; + pattern++; + } + Scan(kt, text); + do { + if (Isend(*pattern)) + return 0; /*ERMISSBRACKET*/ + Scan(ks, pattern); + ke = ks; + if (*pattern == '-' && *(pattern + 1) != RBRACE) { + pattern++; + if (Isend(*pattern)) + return 0; /*ERMISSBRACKET*/ + Scan(ke, pattern); + } + if (ks <= kt && kt <= ke) { + include = 1; + /* no break to checking missing brace */ + /*break;*/ + } + } while (*pattern != RBRACE); + + if (include == exclude) + return 0; + pattern++; + break; + + case '.': + if (xargs_rule & XARGS_DOTBREAK) { + if (!Isend(*text)) + return 0; + if (*text == '.') + text++; + pattern++; + break; + } + default: + Scan(kt, text); + Scan(kp, pattern); + if (kt != kp) + return 0; + } + } + return *text == '\0' ? 1 : 0; +} + +static char * +jrpathdlm(char *s) +{ + char *ap, *ap1, *ap2; + + ap1 = jrindex(s, '\\'); + ap2 = jrindex(s, '/'); + if ((ap = (ap1 < ap2) ? ap2 : ap1) == (char *) 0) + ap = jrindex(s, ':'); + return ap; +} + +char ** +glob_filename(char *pattern) +{ + char *ap, *ap1, *ap2; + char **res; + char *pat; + char **paths; + char *dirp; + char *wld; + char *pp; + int ra, ri, i, plen; + int np; + DWORD Attr = ((DWORD) (xargs_rule & 0xFFFF)); + + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA dta; + + ap = jrpathdlm(pattern); + if (ap && ap[0] != ':' && ap[1] == '\0') { + Attr = AllFindAttr | OnlySubDir; + pp = (char *) xmalloc(strlen(pattern) + 1); + strcpy(pp, pattern); + pp[(int) (ap - pattern)] = '\0'; + ap = jrpathdlm(pp); + if (ap) + ap = pattern + (int) (ap - pp); + xfree(pp); + } + if (ap) { + pat = xmalloc(strlen(ap + 1) + 1); + strcpy(pat, ap + 1); + ap2 = dirp = (char *) xmalloc((int) (ap - pattern) + 2); + for (ap1 = pattern; ap1 <= ap; ap1++) + *ap2++ = *ap1; + *ap2 = '\0'; + if (ap[0] != ':' && has_glob_char(dirp)) { + paths = glob_filename(dirp); + xfree(dirp); + } else { + paths = (char **) xmalloc(sizeof(paths[0]) * 2); + paths[0] = dirp; + paths[1] = (char *) 0; + } + } else { + pat = xmalloc(strlen(pattern) + 1); + strcpy(pat, pattern); + paths = (char **) xmalloc(sizeof(paths[0]) * 2); + paths[0] = (char *) xmalloc(2); + paths[1] = (char *) 0; + strcpy(paths[0], ""); + } + ap = jrpathdlm(pat); + if (ap && ap[0] != ':' && ap[1] == '\0') { + ap[0] = '\0'; + } + res = (char **) xmalloc(sizeof(char *) * (ra = 260)); + ri = 0; + res[ri] = 0; + for (i = 0; paths[i]; i++) { + plen = strlen(paths[i]); + wld = xmalloc(plen + 5); + strcpy(wld, paths[i]); + ap = jrpathdlm(wld); + + if (plen == 0 || (ap && ap[1] == '\0')) { + np = 0; + } else { + strcat(wld, "/"); + np = 1; + } + + strcat(wld, "*.*"); + + if ((ap = find_file(wld, &hFind, Attr, &dta)) != NULL) { + do { + if (glob_match(ap, pat)) { + if (xargs_rule & XARGS_CVLOWER) + jstrtolwr(ap); + res[ri] = xmalloc(plen + strlen(ap) + 2); + strcat(strcat(strcpy(res[ri], paths[i]), np ? "/" : ""), ap); + res[++ri] = (char *) 0; + if (ri >= ra - 2) { + res = (char **) xrealloc(res, sizeof(char *) * (ra += 260)); + } + } + } while (find_file(wld, &hFind, Attr, &dta)); + + FindClose(hFind); + hFind=INVALID_HANDLE_VALUE; + } + + xfree(wld); + } + if (ri) { + if (xargs_rule & XARGS_DOSORT) + qsort(&res[0], ri, sizeof(res[0]), ustrcmp); + } else { + strcpy(res[ri] = xmalloc(strlen(pattern) + 1), pattern); + res[++ri] = (char *) 0; + } + xfree(pat); + for (i = 0; paths[i]; i++) + xfree(paths[i]); + xfree(paths); + return res; +} + +/******/ +struct inputredir { + int type; +#define IP_FILE 1 +#define IP_MEM 2 + struct inputredir *next; + union { + FILE *fp; + char *cp; + } i; +}; +static struct inputredir *iroot = 0; + +static void +add_input(void *p, int type) +{ + struct inputredir *ip; + + ip = (struct inputredir *) xmalloc(sizeof(struct inputredir)); + ip->type = type; + ip->i.cp = p; + if (iroot) { + ip->next = iroot; + iroot = ip; + } else { + iroot = ip; + iroot->next = 0; + } +} + +static int pushbackc = -1; + +static int +nextc(void) +{ + int c; + struct inputredir *lip; + + if (pushbackc != -1) { + c = pushbackc; + pushbackc = -1; + return c; + } + if (iroot == 0) + return EOF; + switch (iroot->type) { + case IP_FILE: + if ((c = fgetc(iroot->i.fp)) == EOF) { + fclose(iroot->i.fp); + lip = iroot; + iroot = iroot->next; + xfree(lip); + c = nextc(); + } + break; + case IP_MEM: + if ((c = *(iroot->i.cp++)) == '\0') { + lip = iroot; + iroot = iroot->next; + xfree(lip); + c = nextc(); + } + break; + default: + c = EOF; + break; + } + return c; +} +static void +pushback(int c) +{ + pushbackc = c; +} + +/******/ + +static void +setav(char *NCptr, int *_ARGC, char ***_ARGV) +{ + int c, i, jf, at; + int quote, withwild; + char *ap; + char *buf; + size_t absiz; + size_t bfsiz; +#define argbuf (*_ARGV) +#define argcnt (*_ARGC) + char **res; + FILE *fp; + + buf = (char *) xmalloc((bfsiz = REALLOC_UNIT * 2) * sizeof(char)); + argbuf = (char **) xmalloc((absiz = REALLOC_UNIT) * sizeof(char *)); + argcnt = 0; + + add_input(NCptr, IP_MEM); + + while ((c = nextc()) != EOF) { + withwild = quote = 0; + while (Isspace(c)) + c = nextc(); + if (c == EOF) + break; + at = (c == '@') ? 1 : 0; + ap = buf; + jf = 0; + do { + if (ap == &buf[bfsiz - 1]) { + buf = (char *) xrealloc(buf, (bfsiz + REALLOC_UNIT) * sizeof(buf[0])); + ap = &buf[bfsiz - 1]; + bfsiz += REALLOC_UNIT; + } + if (jf || isk1(c)) { + *ap++ = (char) c; + jf = !jf; + continue; + } + if (quote != '\'' && Iswild(c)) + withwild = 1; + if (c == quote) { /* end of quoted string */ + quote = 0; + } else if (!quote && (c == '\'' || c == '"')) { + quote = c; + } else { + if (c == '\\') { + c = nextc(); + if (c != '"' && c != '\'') { + pushback(c); + c = '\\'; + } + } + *ap++ = (char) c; + } + } while ((c = nextc()) != EOF && (quote || !Isspace(c))); + *ap = 0; + if ((xargs_rule & XARGS_ATRESP) && at) { + if ((fp = fopen(buf + 1, "r")) != 0) { + add_input(fp, IP_FILE); + continue; + } else { + /* ignore */ + } + } + if (withwild) { + res = glob_filename(buf); + } else { + res = (char **) xmalloc(sizeof(char *) * 2); + strcpy(res[0] = (char *) xmalloc(strlen(buf) + 1), buf); + res[1] = (char *) 0; + } + for (i = 0; res[i]; i++) { + argbuf[argcnt++] = res[i]; + if ((size_t) argcnt >= absiz) { + argbuf = (char **) xrealloc(argbuf, (absiz += REALLOC_UNIT) * sizeof(argbuf[0])); + } + } + xfree(res); + } + argbuf[argcnt] = (char *) 0; + argbuf = (char **) xrealloc(argbuf, (argcnt + 1) * sizeof(argbuf[0])); + xfree(buf); +} + +unsigned long +xargs_set_rule(unsigned long rule) +{ + unsigned long lastrule; + + lastrule = xargs_rule; + xargs_rule = rule; + return lastrule; +} + +unsigned long +xargs_modify_rule(unsigned long mask, unsigned long rule) +{ + unsigned long lastrule; + + lastrule = xargs_rule; + xargs_rule = (xargs_rule & ~mask) | rule; + return lastrule; +} + +unsigned char cmdlinebuf[1024]; + +void +xargs(int *argc, char ***argv) +{ + char far *pp; + char *s; + int i, j; + int jf = 0; + int li = 0; + int sa = 0; + + if (!(xargs_rule & XARGS_USECMDL) + || (s = getenv("CMDLINE")) == 0 + || getenv("NOCMDLINE") != 0) { + sa = 1; + pp = "xargs"; + s = xmalloc(1024); + +#if 0 + { + cmdlinebuf[0] = '\0'; + //wcstombs(cmdlinebuf, GetCommandLine(), (sizeof (cmdlinebuf) - 1)); + //pp = cmdlinebuf; + strcpy(cmdlinebuf, GetCommandLine()); + pp = cmdlinebuf; + } + + for (i = 0; (s[i] = *pp++) != '\0'; i++) { + //if (isspace(s[i])) { + // s[i] = '\0'; + // break; + //} + + if (jf) { + jf = 0; + continue; + } + if (isk1(s[i]) && !jf) { + jf = 1; + continue; + } + if ((xargs_rule & XARGS_0CVLOWER) && Isupper(s[i])) + s[i] = (char) Tolower(s[i]); + if (s[i] == '.') + li = i; + if (s[i] == '/' || s[i] == '\\') + li = 0; + if ((xargs_rule & XARGS_0CVSLASH) && s[i] == '\\') + s[i] = '/'; + } + if ((xargs_rule & XARGS_0REMOVEXT) && li && li != i - 1) { + i = li; + s[i] = 0; + } + { + //cmdlinebuf[0] = '\0'; + //wcstombs(cmdlinebuf, GetCommandLine(), (sizeof (cmdlinebuf) - 1)); + //pp = cmdlinebuf; + //strcpy(cmdlinebuf, GetCommandLine()); + // pp = cmdlinebuf; + //while (*pp && !isspace(*pp)) + // *pp++; + //j = *pp; + pp = cmdlinebuf+i; + j = strlen(cmdlinebuf+i); + + } + while ((*pp == ' ' || *pp == '\t') && j) { + pp++; + j--; + } + if (j) + s[i++] = ' '; + while (j--) { + s[i++] = *pp++; + } + s[i] = 0; +#else + s[0] = '\0'; + strcpy(s, GetCommandLine()); +#endif + } + setav(s, argc, argv); + if (sa) + xfree(s); +} + + +#ifdef TEST +#include + +static char QUOTE[]= "\033[33m\"\033[m"; + +int +main(int argc, char **argv) +{ + int a = 0; + + /*xargs_modify_rule(XARGS_DOTBREAK, XARGS_DOTBREAK);*/ + xargs(&argc, &argv); + + printf("[argv]-------------------------- %d argument(s)\n", argc); + while (argc--) { + printf("[%4d]%s%s%s\n", a++, QUOTE, *argv++, QUOTE); + } + printf("-------------------------------- Thats all\n"); + + return 0; +} + +#endif diff -u2rN sed-3.02/lib/xargs32.h sed-3.02+mb1.09/lib/xargs32.h --- sed-3.02/lib/xargs32.h Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/lib/xargs32.h Sun Nov 19 17:44:19 2000 @@ -0,0 +1,68 @@ +/* Id: xargs.h 2.1 1993/01/20 10:43:04 serow Exp serow + * + * header for xargs.c + * This code is in the public domain. + * + * $Log: xargs32.h $ + * Revision 1.1 1997/04/27 15:04:01 koichik + * Initial revision + * + * Revision 2.1 1993/01/20 10:43:04 serow + * v2 + * + */ + +#ifndef _INC_XARGS +#ifdef __cplusplus +extern "C" { +#endif + +/* The following bits are used in the xargs_rule variable + to select globbing rule */ + +#define XARGS_F_RO (1L ) /* attribute for find file. */ +#define XARGS_F_HID (1L << 1L) /* */ +#define XARGS_F_SYS (1L << 2L) /* */ +#define XARGS_F_VOL (1L << 3L) /* */ +#define XARGS_F_DIR (1L << 4L) /* */ + +#define XARGS_DOTBREAK (1L << 22L) /* ?, * doesnot math with '.' */ +#define XARGS_HIDDENDOT (1L << 23L) /* treat '.' & '..' as hidden file */ +#define XARGS_DOSORT (1L << 24L) /* wild card args will be sorted by name */ +#define XARGS_CVLOWER (1L << 25L) /* convert filenames to lower case */ +#define XARGS_ATRESP (1L << 26L) /* @responsefile */ +#define XARGS_USECMDL (1L << 27L) /* get arg from "CMDLINE" environ if there */ +#define XARGS_0CVLOWER (1L << 28L) /* convert argv[0] to lower case */ +#define XARGS_0CVSLASH (1L << 29L) /* convert '\\' to '/' in argv[0] */ +#define XARGS_0REMOVEXT (1L << 30L) /* remove extention from argv[0] */ + +/* typical rules */ + +#define XARGS_CSH_LIKE_RULE (\ + XARGS_F_RO|XARGS_F_DIR|XARGS_F_SYS \ + |XARGS_HIDDENDOT \ + |XARGS_DOSORT \ + |XARGS_CVLOWER \ + |XARGS_ATRESP \ + |XARGS_0CVLOWER \ + |XARGS_0CVSLASH \ + |XARGS_0REMOVEXT \ + ) + +#define XARGS_MESSY_RULE (\ + XARGS_F_RO|XARGS_F_SYS \ + |XARGS_DOTBREAK \ + |XARGS_HIDDENDOT \ + ) + +/* prototypes */ + +char ** glob_filename(char *pattern); +unsigned long xargs_set_rule(unsigned long rule); +unsigned long xargs_modify_rule(unsigned long mask, unsigned long rule); +void xargs(int *argc, char ***argv); +#ifdef __cplusplus +} +#endif +#define _INC_XARGS 1 +#endif /* _INC_XARGS */ diff -u2rN sed-3.02/sed/Makefile.bcc sed-3.02+mb1.09/sed/Makefile.bcc --- sed-3.02/sed/Makefile.bcc Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/sed/Makefile.bcc Sun Nov 19 17:44:19 2000 @@ -0,0 +1,24 @@ +bin_PROGRAMS = sed.exe +sed_OBJECTS = sed.obj compile.obj execute.obj utils.obj +sed_LDADD = ../lib/libsed.lib + +SHELL = command.com + +DEFS = -DMSDOS -DHAVE_CONFIG_H -I.. -I../lib +CC = bcc -ml -f- +CFLAGS = -A- -O2-i -N -d -w- +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) + +.SUFFIXES: +.SUFFIXES: .c .obj .lib .exe + +.c.obj: + $(COMPILE) -c $< + +sed.exe: $(sed_OBJECTS) + -if exist $@ del $@ + $(CC) -e$@ $(LDFLAGS) $(sed_OBJECTS) $(sed_LDADD) + +clean: + -if exist sed.exe del sed.exe + -if exist *.obj del *.obj diff -u2rN sed-3.02/sed/Makefile.in sed-3.02+mb1.09/sed/Makefile.in --- sed-3.02/sed/Makefile.in Sun Aug 2 10:17:15 1998 +++ sed-3.02+mb1.09/sed/Makefile.in Tue Nov 28 01:03:05 2000 @@ -1,5 +1,5 @@ -# Makefile.in generated automatically by automake 1.3 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -12,5 +12,5 @@ -SHELL = /bin/sh +SHELL = @SHELL@ srcdir = @srcdir@ @@ -33,5 +33,5 @@ oldincludedir = /usr/include -DISTDIR = +DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ @@ -47,5 +47,5 @@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -60,7 +60,9 @@ CC = @CC@ MAKEINFO = @MAKEINFO@ +MBVERSION = @MBVERSION@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ +binsuffix = @binsuffix@ bin_PROGRAMS = sed @@ -87,6 +89,7 @@ sed_LDFLAGS = CFLAGS = @CFLAGS@ -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ HEADERS = $(noinst_HEADERS) @@ -97,16 +100,16 @@ TAR = tar -GZIP = --best +GZIP_ENV = --best +DEP_FILES = .deps/compile.P .deps/execute.P .deps/sed.P .deps/utils.P SOURCES = $(sed_SOURCES) OBJECTS = $(sed_OBJECTS) -all: Makefile $(PROGRAMS) $(HEADERS) - +all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps sed/Makefile +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu sed/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -127,6 +130,6 @@ @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ - echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ - $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done @@ -135,10 +138,7 @@ @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done -.c.o: - $(COMPILE) -c $< - .s.o: $(COMPILE) -c $< @@ -164,6 +164,10 @@ ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) @@ -191,76 +195,120 @@ distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu sed/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file; \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ done -compile.o: compile.c ../config.h regex-sed.h ../lib/regex-gnu.h \ - basicdefs.h utils.h sed.h -execute.o: execute.c ../config.h regex-sed.h ../lib/regex-gnu.h \ - basicdefs.h utils.h sed.h -sed.o: sed.c ../config.h regex-sed.h ../lib/regex-gnu.h ../lib/getopt.h \ - basicdefs.h utils.h sed.h -utils.o: utils.c ../config.h basicdefs.h utils.h - -info: -dvi: -check: all - $(MAKE) -installcheck: -install-exec: install-binPROGRAMS - @$(NORMAL_INSTALL) -install-data: - @$(NORMAL_INSTALL) +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) -install: install-exec install-data all - @: +-include $(DEP_FILES) -uninstall: uninstall-binPROGRAMS +mostlyclean-depend: +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-binPROGRAMS +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-binPROGRAMS +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(HEADERS) +all-redirect: all-am install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: - $(mkinstalldirs) $(DATADIR)$(bindir) + $(mkinstalldirs) $(DESTDIR)$(bindir) mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: - -rm -f Makefile $(DISTCLEANFILES) + -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ - mostlyclean-tags mostlyclean-generic - -clean: clean-binPROGRAMS clean-compile clean-tags clean-generic \ - mostlyclean - -distclean: distclean-binPROGRAMS distclean-compile distclean-tags \ - distclean-generic clean - -rm -f config.status - -maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ - maintainer-clean-tags maintainer-clean-generic \ - distclean +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ + distclean-depend distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." +maintainer-clean: maintainer-clean-am + .PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags distdir info dvi installcheck \ -install-exec install-data install uninstall all installdirs \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean diff -u2rN sed-3.02/sed/Makefile.vc sed-3.02+mb1.09/sed/Makefile.vc --- sed-3.02/sed/Makefile.vc Thu Jan 1 09:00:00 1970 +++ sed-3.02+mb1.09/sed/Makefile.vc Sun Nov 19 17:44:19 2000 @@ -0,0 +1,24 @@ +bin_PROGRAMS = sed.exe +sed_OBJECTS = sed.obj compile.obj execute.obj utils.obj +sed_LDADD = ..\lib\libsed.lib + +DEFS = -DWIN32 -DHAVE_CONFIG_H -I.. -I..\lib +CC = cl +CFLAGS = -W3 -O2 -GF -QI0f -QIfdiv +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) + +.SUFFIXES: +.SUFFIXES: .c .obj .lib .exe + +.c.obj: + $(COMPILE) -c $< + +sed.exe: $(sed_OBJECTS) + -if exist $@ del $@ + $(CC) -Fe$@ $(LDFLAGS) @<< +$(sed_OBJECTS) $(sed_LDADD) +<< + +clean: + -if exist sed.exe del sed.exe + -if exist *.obj del *.obj diff -u2rN sed-3.02/sed/basicdefs.h sed-3.02+mb1.09/sed/basicdefs.h --- sed-3.02/sed/basicdefs.h Sat Jul 4 23:25:44 1998 +++ sed-3.02+mb1.09/sed/basicdefs.h Sun Nov 19 17:44:19 2000 @@ -18,9 +18,12 @@ /* some basic #defines to support pre-ANSI compilers */ +/* Multi-byte extension added Feb, 1999 by wills (okabe katsuyuki) + Last change: Feb 11, 1999 by wills */ + #ifndef BASICDEFS_H #define BASICDEFS_H /* Can the compiler grok function prototypes? */ -#if defined __STDC__ && __STDC__ +#if (defined __STDC__ && __STDC__) || defined MSDOS # define P_(s) s #else @@ -87,4 +90,6 @@ Solaris defines some of these symbols so we must undefine them first. */ +#define NOTMBCHAR(c) (0 <= (c) && (c) <= 255) + #undef ISASCII #if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII) @@ -95,20 +100,24 @@ #ifdef isblank -# define ISBLANK(c) (ISASCII (c) && isblank (c)) +# define ISBLANK(c) (NOTMBCHAR (c) && ISASCII (c) && isblank (c)) #else # define ISBLANK(c) ((c) == ' ' || (c) == '\t') #endif +#define ISSJISKANA(c) \ + (current_mbctype == MBCTYPE_SJIS && 0240 <= (c) && (c) <= 0337) + #undef ISPRINT -#define ISPRINT(c) (ISASCII (c) && isprint (c)) -#define ISDIGIT(c) (ISASCII (c) && isdigit (c)) -#define ISALNUM(c) (ISASCII (c) && isalnum (c)) -#define ISALPHA(c) (ISASCII (c) && isalpha (c)) -#define ISCNTRL(c) (ISASCII (c) && iscntrl (c)) -#define ISLOWER(c) (ISASCII (c) && islower (c)) -#define ISPUNCT(c) (ISASCII (c) && ispunct (c)) -#define ISSPACE(c) (ISASCII (c) && isspace (c)) -#define ISUPPER(c) (ISASCII (c) && isupper (c)) -#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c)) +#define ISPRINT(c) \ + ((NOTMBCHAR (c) && ISASCII (c) && isprint (c)) || ISSJISKANA(c)) +#define ISDIGIT(c) (NOTMBCHAR (c) && ISASCII (c) && isdigit (c)) +#define ISALNUM(c) (NOTMBCHAR (c) && ISASCII (c) && isalnum (c)) +#define ISALPHA(c) (NOTMBCHAR (c) && ISASCII (c) && isalpha (c)) +#define ISCNTRL(c) (NOTMBCHAR (c) && ISASCII (c) && iscntrl (c)) +#define ISLOWER(c) (NOTMBCHAR (c) && ISASCII (c) && islower (c)) +#define ISPUNCT(c) (NOTMBCHAR (c) && ISASCII (c) && ispunct (c)) +#define ISSPACE(c) (NOTMBCHAR (c) && ISASCII (c) && isspace (c)) +#define ISUPPER(c) (NOTMBCHAR (c) && ISASCII (c) && isupper (c)) +#define ISXDIGIT(c) (NOTMBCHAR (c) && ISASCII (c) && isxdigit (c)) diff -u2rN sed-3.02/sed/compile.c sed-3.02+mb1.09/sed/compile.c --- sed-3.02/sed/compile.c Mon Jul 27 07:43:05 1998 +++ sed-3.02+mb1.09/sed/compile.c Sun Nov 19 17:44:19 2000 @@ -19,4 +19,7 @@ /* compile.c: translate sed source into internal form */ +/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto) + Last change: Feb 13, 1999 by WILLs (Katsuyuki Okabe) */ + #include "config.h" #include @@ -46,4 +49,5 @@ #include "basicdefs.h" #include "utils.h" +#include "mbfuncs.h" #include "sed.h" @@ -54,5 +58,7 @@ +#if 0 #define YMAP_LENGTH 256 /*XXX shouldn't this be (UCHAR_MAX+1)?*/ +#endif #define VECTOR_ALLOC_INCREMENT 40 @@ -87,22 +93,24 @@ +static int compare_mbcs P_((const void *, const void *)); static struct vector *compile_program P_((struct vector *)); static struct vector *new_vector P_((struct error_info *errinfo, struct vector *old_vector)); -static void read_text P_((struct text_buf *buf, int leadin_ch)); +static void read_text P_((struct text_buf *buf, mbchar_t leadin_ch)); static struct sed_cmd *next_cmd_entry P_((struct vector **vectorp)); -static int add_then_next P_((struct buffer *b, int ch)); -static int snarf_char_class P_((struct buffer *b)); -static struct buffer *match_slash P_((int slash, flagT regex, flagT keep_back)); +static mbchar_t add_then_next P_((struct buffer *b, mbchar_t ch)); +static mbchar_t snarf_char_class P_((struct buffer *b)); +static struct buffer *match_slash P_((mbchar_t slash, flagT regex, flagT keep_back)); static regex_t *compile_regex P_((struct buffer *b, flagT icase, flagT nosub)); -static flagT compile_address P_((struct addr *addr, int ch)); +static flagT compile_address P_((struct addr *addr, mbchar_t ch)); static void compile_filename P_((flagT readit, const char **name, FILE **fp)); static struct sed_label *setup_jump P_((struct sed_label *list, struct sed_cmd *cmd, struct vector *vec)); static flagT mark_subst_opts P_((struct subst *cmd)); -static int inchar P_((void)); -static int in_nonblank P_((void)); -static countT in_integer P_((int ch)); -static void savchar P_((int ch)); +static mbchar_t inchar P_((void)); +static mbchar_t inchar_raw P_((void)); +static mbchar_t in_nonblank P_((void)); +static countT in_integer P_((mbchar_t ch)); +static void savchar P_((mbchar_t ch)); static void bad_prog P_((const char *why)); @@ -137,4 +145,5 @@ static const char UNTERM_S_CMD[] = "Unterminated `s' command"; static const char UNTERM_Y_CMD[] = "Unterminated `y' command"; +static const char BAD_MBC[] = "Multi-byte character incomplete"; @@ -305,7 +314,7 @@ read_text(buf, leadin_ch) struct text_buf *buf; - int leadin_ch; + mbchar_t leadin_ch; { - int ch; + mbchar_t ch; /* Should we start afresh (as opposed to continue a partial text)? */ @@ -346,4 +355,18 @@ +static int +compare_mbcs (p1, p2) + const VOID *p1, *p2; +{ + mbchar_t c1 = *(mbchar_t *) p1; + mbchar_t c2 = *(mbchar_t *) p2; + + if (c1 == c2) + return p1 == p2 ? 0 + /* qsort() が安定になるように, 大小関係を強制する. */ + : p1 < p2 ? -1 : 1 ; + return c1 < c2 ? -1 : 1 ; +} + /* Read a program (or a subprogram within '{' '}' pairs) in and store the compiled form in *'vector'. Return a pointer to the new vector. */ @@ -355,8 +378,10 @@ struct buffer *b; struct buffer *b2; - unsigned char *ustring; + mbchar_t *mbstring; + char *string; size_t len; - int slash; - int ch; + mbchar_t slash; + mbchar_t ch; + size_t mbindx; if (!vector) @@ -506,15 +531,18 @@ case 'y': - ustring = MALLOC(YMAP_LENGTH, unsigned char); - for (len = 0; len < YMAP_LENGTH; len++) - ustring[len] = len; - cur_cmd->x.translate = ustring; - slash = inchar(); - if ( !(b = match_slash(slash, 0, 0)) ) + if (!(b = match_slash(slash, 0, 0))) bad_prog(UNTERM_Y_CMD); - ustring = CAST(unsigned char *)get_buffer(b); - for (len = size_buffer(b); len; --len) + len = size_buffer(b); + mbstring = MALLOC(YMAP_LENGTH + 2 * len, mbchar_t); + for (len = 0; len < YMAP_LENGTH; len++) + mbstring[len] = len; + + mbindx = YMAP_LENGTH; + string = CAST(char *)get_buffer(b); + for (len = mblength(string, size_buffer(b)); len; --len) { + mbchar_t c; + ch = inchar(); if (ch == slash) @@ -526,6 +554,18 @@ if (ch == EOF) bad_prog(BAD_EOF); - cur_cmd->x.translate[*ustring++] = ch; + + c = mbcfetch(string, &string); + if (c < YMAP_LENGTH) + mbstring[c] = ch; + else + { + mbstring[mbindx++] = c; + mbstring[mbindx++] = ch; + } } + cur_cmd->x.translate = REALLOC(mbstring, mbindx, mbchar_t); + cur_cmd->x.mbcsize = (mbindx - YMAP_LENGTH) / 2; + if (cur_cmd->x.mbcsize) + qsort(cur_cmd->x.translate + YMAP_LENGTH, cur_cmd->x.mbcsize, 2 * sizeof(mbchar_t), compare_mbcs); free_buffer(b); @@ -582,8 +622,8 @@ #define CLOSE_BRACKET ']' -static int +static mbchar_t add_then_next(b, ch) struct buffer *b; - int ch; + mbchar_t ch; { add1_buffer(b, ch); @@ -591,9 +631,9 @@ } -static int +static mbchar_t snarf_char_class(b) struct buffer *b; { - int ch; + mbchar_t ch; ch = inchar(); @@ -606,6 +646,6 @@ if (ch == OPEN_BRACKET) { - int prev; - int delim = ch = add_then_next(b, ch); + mbchar_t prev; + mbchar_t delim = ch = add_then_next(b, ch); if (delim != '.' && delim != ':' && delim != '=') @@ -640,10 +680,10 @@ static struct buffer * match_slash(slash, regex, keep_backwhack) - int slash; + mbchar_t slash; flagT regex; flagT keep_backwhack; { struct buffer *b; - int ch; + mbchar_t ch; b = init_buffer(); @@ -748,5 +788,5 @@ compile_address(addr, ch) struct addr *addr; - int ch; + mbchar_t ch; { if (ISDIGIT(ch)) @@ -827,5 +867,5 @@ { struct buffer *b; - int ch; + mbchar_t ch; char *file_name; struct fp_list *p; @@ -875,5 +915,5 @@ struct sed_label *ret; struct buffer *b; - int ch; + mbchar_t ch; b = init_buffer(); @@ -902,5 +942,5 @@ { flagT caseless = 0; - int ch; + mbchar_t ch; cmd->global = 0; @@ -953,13 +993,29 @@ anything to read. Keep cur_input.line up to date, so error messages can be meaningful. */ -static int +static mbchar_t saved_char = EOF; + +static mbchar_t inchar() { - int ch = EOF; + mbchar_t ch = EOF; + + if (saved_char != EOF) + { + ch = saved_char; + saved_char = EOF; + return ch; + } if (prog.cur) { if (prog.cur < prog.end) - ch = *prog.cur++; + { + const unsigned char *end; + + ch = mbcfetch(prog.cur, CAST(char **)&end); + if (end > prog.end) + bad_prog(BAD_MBC); + prog.cur = end; + } } else if (prog.file) @@ -967,4 +1023,22 @@ if (!feof(prog.file)) ch = getc(prog.file); + if (ch != EOF && ismbchar(ch)) + { + char buf[MBCLEN_MAX]; + size_t len; + size_t i; + + len = mbclen(ch); + i = 0; + buf[i++] = ch; + while (i < len) + { + ch = getc(prog.file); + if (ch == EOF || ch == '\n') + bad_prog(BAD_MBC); + buf[i++] = ch; + } + ch = mbcfetch(buf, NULL); + } } if (ch == '\n') @@ -974,8 +1048,8 @@ /* Read the next non-blank character from the program. */ -static int +static mbchar_t in_nonblank() { - int ch; + mbchar_t ch; do ch = inchar(); @@ -987,5 +1061,5 @@ static countT in_integer(ch) - int ch; + mbchar_t ch; { countT num = 0; @@ -1003,8 +1077,13 @@ static void savchar(ch) - int ch; + mbchar_t ch; { if (ch == EOF) return; + if (!NOTMBCHAR(ch)) + { + saved_char = ch; + return; + } if (ch == '\n' && cur_input.line > 0) --cur_input.line; diff -u2rN sed-3.02/sed/execute.c sed-3.02+mb1.09/sed/execute.c --- sed-3.02/sed/execute.c Mon Jul 6 13:01:01 1998 +++ sed-3.02+mb1.09/sed/execute.c Sun Nov 19 17:44:19 2000 @@ -35,4 +35,10 @@ # include # endif +# if defined _MSC_VER || defined __TURBOC__ +# include +# ifdef _MSC_VER +# define isatty _isatty +# endif +# endif #endif @@ -80,4 +86,8 @@ #endif +#ifdef _MSC_VER +# define fileno _fileno +#endif + /* If set, don't write out the line unless explicitly told to */ extern flagT no_default_output; @@ -142,4 +152,5 @@ static void do_list P_((void)); static void do_subst P_((struct subst *subst)); +static void do_mbtranslate P_((struct sed_cmd *cmd)); static flagT execute_program P_((struct vector *, struct input *input)); static void output_line @@ -566,15 +577,22 @@ char *o; size_t olen; + mbchar_t wc; for (; len--; ++p) { o = obuf; - if (ISPRINT(*p)) { + wc = CAST(mbchar_t)*p; + if (ISPRINT(wc)) { *o++ = *p; if (*p == '\\') *o++ = '\\'; + } else if (ismbchar(*p) && len >= (olen = mbclen(*p)) - 1) { + memcpy(o, p, olen); + o += olen; + p += olen - 1; + len -= olen - 1; } else { *o++ = '\\'; switch (*p) { -#if defined __STDC__ && __STDC__ +#if (defined __STDC__ && __STDC__) || defined MSDOS case '\a': *o++ = 'a'; break; #else @@ -594,4 +612,12 @@ } } +#if 1 + olen = mblength(obuf, o - obuf); + if (width+olen >= LCMD_OUT_LINE_LEN) { + ck_fwrite("\\\n", 1, 2, stdout); + width = 0; + } + ck_fwrite(obuf, 1, o - obuf, stdout); +#else olen = o - obuf; if (width+olen >= LCMD_OUT_LINE_LEN) { @@ -600,4 +626,5 @@ } ck_fwrite(obuf, 1, olen, stdout); +#endif width += olen; } @@ -672,5 +699,9 @@ */ if (matched == 0 && offset < line.length) - matched = 1; + { + matched = mbclen(line.text[offset]); + if (offset + matched > line.length) + matched = line.length - offset; + } str_append(&s_accum, line.text + offset, matched); start = offset + matched; @@ -696,5 +727,11 @@ rep_next++) { - if (*rep_next == '\\') + if (ismbchar(*rep_next)) + { + rep_next += mbclen(*rep_next) - 1; + if (rep_next >= rep_end) + break; + } + else if (*rep_next == '\\') { /* Preceding the backslash may be some literal @@ -717,5 +754,6 @@ } else - str_append(&s_accum, rep_next, 1); + str_append(&s_accum, rep_next, mbclen(*rep_next)); + rep_next += mbclen(*rep_next) - 1; rep_cur = rep_next + 1; } @@ -751,7 +789,12 @@ if (regs[0].rm_so == regs[0].rm_eo) { - str_append(&s_accum, line.text + offset, 1); - ++start; - --remain; + size_t len; + + len = mbclen(line.text[offset]); + if (len > remain) + len = remain; + str_append(&s_accum, line.text + offset, len); + start += len; + remain -= len; } } @@ -774,4 +817,60 @@ } +static void +do_mbtranslate(cur_cmd) + struct sed_cmd *cur_cmd; +{ + /* s_accum will accumulate the result of the s command. */ + /* static so as to keep malloc() calls down */ + static struct line s_accum; + + struct line tmp; + unsigned char *cur; + unsigned char *end; + char mbcbuf[MBCLEN_MAX]; + mbchar_t ch; + size_t i; + size_t j; + + if (s_accum.alloc == 0) + line_init(&s_accum, INITIAL_BUFFER_SIZE); + s_accum.length = 0; + + cur = CAST(unsigned char *)line.text; + end = cur + line.length; + while (cur < end) + { + ch = mbcfetch(CAST(char *)cur, CAST(char **)&cur); + if (ch < YMAP_LENGTH) + ch = cur_cmd->x.translate[ch]; + else + { + /* 同じキーについては最後のものが有効になるように, 慎重 + に検索する. */ + /* まず, ch < cur_cmd.x.translate[YMAP_LENGTH + i * 2] を満たす + i の最小値を求める. */ + for (i = 0, j = cur_cmd->x.mbcsize; i < j;) { + int k = (i + j) / 2; + if (ch >= cur_cmd->x.translate[YMAP_LENGTH + k * 2]) + i = k + 1; + else + j = k; + } + + if (0 < i && ch == cur_cmd->x.translate[YMAP_LENGTH + (i - 1) * 2]) + /* 直前のキーが一致すれば, 変換する. */ + ch = cur_cmd->x.translate[YMAP_LENGTH + (i - 1) * 2 + 1]; + } + + mbcstore(mbcbuf, ch); + str_append(&s_accum, mbcbuf, mbclen(mbcbuf[0])); + } + + memcpy(VCAST(VOID *)&tmp, VCAST(VOID *)&line, sizeof line); + memcpy(VCAST(VOID *)&line, VCAST(VOID *)&s_accum, sizeof line); + line.chomped = tmp.chomped; + memcpy(VCAST(VOID *)&s_accum, VCAST(VOID *)&tmp, sizeof line); +} + /* Execute the program 'vec' on the current input line. Return non-zero if caller should quit, 0 otherwise. */ @@ -966,9 +1065,11 @@ case 'y': - { + if (current_mbctype == MBCTYPE_ASCII) { unsigned char *p, *e; p = CAST(unsigned char *)line.text; for (e=p+line.length; px.translate[*p]; + } else { + do_mbtranslate(cur_cmd); } break; diff -u2rN sed-3.02/sed/sed.c sed-3.02+mb1.09/sed/sed.c --- sed-3.02/sed/sed.c Fri Jul 3 10:06:26 1998 +++ sed-3.02+mb1.09/sed/sed.c Mon Nov 27 23:27:47 2000 @@ -1,4 +1,5 @@ #define COPYRIGHT_NOTICE "Copyright (C) 1998 Free Software Foundation, Inc." #define BUG_ADDRESS "bug-gnu-utils@gnu.org" +#define MB_BUG_ADDRESS "hgc02147@nifty.ne.jp" /* GNU SED, a batch stream editor. @@ -20,4 +21,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto) + Last change: Feb 14, 1999 by WILLs (Katsuyuki Okabe)" */ #include "config.h" @@ -58,4 +61,15 @@ #include "sed.h" +#undef USE_XARGS +#if defined MSDOS && !defined __GO32__ +# include "xargs.h" +# define USE_XARGS 1 +#else +# if defined _WIN32 && !defined __CYGWIN32__ && !defined __CYGWIN__ +# include "xargs32.h" +# define USE_XARGS 1 +# endif +#endif + #ifndef HAVE_STDLIB_H extern char *getenv P_((const char *)); @@ -67,4 +81,80 @@ #endif /*STUB_FROM_RX_LIBRARY_USAGE*/ +#ifdef _MSC_VER +#define stricmp _stricmp +#define strnicmp _strnicmp +#endif + +#define TOLOWER(c) (isupper((c)) ? tolower((c)) : (c)) + +#ifndef HAVE_STRCASECMP +# ifdef HAVE_STRICMP +# define strcasecmp(s1,s2) stricmp((s1),(s2)) +# else /* !HAVE_STRICMP */ +static int strcasecmp P_((const char *, const char *)); +static int +strcasecmp(s1, s2) + const char *s1; + const char *s2; +{ + int c1, c2; + + for (;;) + { + c1 = (unsigned char) *s1++; + c1 = TOLOWER (c1); + c2 = (unsigned char) *s2++; + c2 = TOLOWER (c2); + if (c1 != c2) + return c1 - c2; + if (c1 == '\0') + return 0; + } +} +# endif /* !HAVE_STRICMP */ +#endif /* !HAVE_STRCASECMP */ + +#ifndef HAVE_STRNCASECMP +# ifdef HAVE_STRNICMP +# define strncasecmp(s1,s2,n) strnicmp((s1),(s2),(n)) +# else /* !HAVE_STRNICMP */ +static int strncasecmp P_((const char *s1, const char *s2, int n)); +static int +strncasecmp (s1, s2, n) + const char *s1; + const char *s2; + int n; +{ + int c1, c2; + + while (n-- > 0) + { + c1 = (unsigned char) *s1++; + c1 = TOLOWER (c1); + c2 = (unsigned char) *s2++; + c2 = TOLOWER (c2); + if (c1 != c2) + return c1 - c2; + if (c1 == '\0') + return 0; + } + return 0; +} +# endif /* !HAVE_STRNICMP */ +#endif /* !HAVE_STRNCASECMP */ + +#ifdef EUC +# define DEFAULT_MBCTYPE MBCTYPE_EUC +#endif +#ifdef SJIS +# define DEFAULT_MBCTYPE MBCTYPE_SJIS +#endif +#ifdef UTF8 +# define DEFAULT_MBCTYPE MBCTYPE_UTF8 +#endif +#if defined ASCII || !defined DEFAULT_MBCTYPE +# define DEFAULT_MBCTYPE MBCTYPE_ASCII +#endif + static void usage P_((int)); @@ -79,4 +169,8 @@ flagT POSIXLY_CORRECT; +#ifdef __TURBOC__ +int _stklen = 0x4000; +#endif + static void usage(status) @@ -96,4 +190,7 @@ --help display this help and exit\n\ -V, --version output version information and exit\n\ + -W ctype=character-set, --ctype=character-set\n\ + specify the character set\n\ + character-set is ASCII, EUC, SJIS, or UTF8\n\ \n\ If no -e, --expression, -f, or --file option is given, then the first\n\ @@ -105,7 +202,35 @@ Be sure to include the word ``%s'' somewhere in the ``Subject:'' field.\n", BUG_ADDRESS, PACKAGE); + fprintf(out, "\nReport multi-byte extension version bugs to: %s .\n", + MB_BUG_ADDRESS); exit(status); } +char * +sed_name(filespec) + const char *filespec; +{ +#if defined MSDOS || defined _WIN32 || defined __human68k__ + char *p, *q; + + p = (char *) filespec; /* Sloppy... */ + + /* OS/2 allows / for directory separator too */ + if ((q = strrchr(p, '\\')) != NULL) + p = q + 1; + if ((q = strrchr(p, '/')) != NULL) + p = q + 1; + if ((q = strchr(p, '.')) != NULL) + *q = '\0'; + return strlwr(p); +#else + char *p; + + /* "path/name" -> "name" */ + p = strrchr(filespec, '/'); + return (p == NULL ? (char *) filespec : p + 1); +#endif +} + int main(argc, argv) @@ -121,4 +246,5 @@ {"version", 0, NULL, 'V'}, {"help", 0, NULL, 'h'}, + {"ctype", 1, NULL, 'T'}, {NULL, 0, NULL, 0} }; @@ -130,4 +256,31 @@ more of the input files couldn't be opened. */ +#ifdef USE_XARGS +# ifndef XARGS_USELFN +# define XARGS_USELFN 0 +# endif /* !XARGS_USELFN */ + xargs_modify_rule (XARGS_DOTBREAK|XARGS_USELFN, XARGS_DOTBREAK|XARGS_USELFN); + xargs (&argc, &argv); + { + const char *p; + for (p = argv[0]; *p != '\0'; p++) + if (*p == ':' || *p == '/') + argv[0] = (char *) p + 1; + } +#endif /* USE_XARGS */ + + myname = sed_name(argv[0]); + if (myname[0] == 'j' || myname[0] == 'J') { + mbcinit(DEFAULT_MBCTYPE); + } else if (!strncasecmp(myname, "euc", 3)) { + mbcinit(MBCTYPE_EUC); + } else if (!strncasecmp(myname, "sjis", 4)) { + mbcinit(MBCTYPE_SJIS); + } else if (!strncasecmp(myname, "utf8", 4)) { + mbcinit(MBCTYPE_UTF8); + } else if (getenv("SEDMB_ENABLE")) { + mbcinit(DEFAULT_MBCTYPE); + } + POSIXLY_CORRECT = (getenv("POSIXLY_CORRECT") != NULL); #ifdef STUB_FROM_RX_LIBRARY_USAGE @@ -140,5 +293,5 @@ myname = *argv; - while ((opt = getopt_long(argc, argv, "hnrVe:f:", longopts, NULL)) != EOF) + while ((opt = getopt_long(argc, argv, "hnrVe:f:W:", longopts, NULL)) != EOF) { switch (opt) @@ -159,5 +312,6 @@ break; case 'V': - fprintf(stdout, "GNU %s version %s\n\n", PACKAGE, VERSION); + fprintf(stdout, "GNU %s version %s + multi-byte extension %s\n\n", + PACKAGE, VERSION, MBVERSION); fprintf(stdout, "%s\n\ This is free software; see the source for copying conditions. There is NO\n\ @@ -168,4 +322,32 @@ case 'h': usage(0); + case 'W': + if (strncasecmp(optarg, "ctype=", 6) != 0) + usage(4); + optarg += 6; + /* Fall Through */ + case 'T': + if (strcasecmp(optarg, "ASCII") == 0) + { + mbcinit(MBCTYPE_ASCII); + break; + } + else if (strcasecmp(optarg, "EUC") == 0) + { + mbcinit(MBCTYPE_EUC); + break; + } + else if (strcasecmp(optarg, "SJIS") == 0) + { + mbcinit(MBCTYPE_SJIS); + break; + } + else if (strcasecmp(optarg, "UTF8") == 0) + { + mbcinit(MBCTYPE_UTF8); + break; + } + fprintf(stderr, "%s: unknown ctype\n", optarg); + /* Fall Through */ default: usage(4); diff -u2rN sed-3.02/sed/sed.h sed-3.02+mb1.09/sed/sed.h --- sed-3.02/sed/sed.h Sat Jun 13 05:20:26 1998 +++ sed-3.02+mb1.09/sed/sed.h Sun Nov 19 17:44:19 2000 @@ -17,5 +17,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto) + Last change: Feb 13, 1999 by WILLs (Katsuyuki Okabe) */ + #include +#include "mbc.h" /* type countT is used to keep track of line numbers, etc. */ @@ -137,5 +141,11 @@ /* This for the y command */ - unsigned char *translate; + struct { + mbchar_t *translate; + size_t mbcsize; + } cmd_y; +#define translate cmd_y.translate +#define mbcsize cmd_y.mbcsize +#define YMAP_LENGTH 256 /*XXX shouldn't this be (UCHAR_MAX+1)?*/ /* For {} */ @@ -146,5 +156,4 @@ } x; }; - diff -u2rN sed-3.02/sed/utils.c sed-3.02+mb1.09/sed/utils.c --- sed-3.02/sed/utils.c Mon Jul 6 13:00:55 1998 +++ sed-3.02+mb1.09/sed/utils.c Sun Nov 19 17:44:19 2000 @@ -21,4 +21,7 @@ /* Tweaked by ken */ +/* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto) + Last change: Feb 10, 1999 by WILLs (okabe katsuyuki) */ + #include "config.h" @@ -58,6 +61,125 @@ +#if defined(MSDOS) && !defined(__GO32__) +#include +#include +#include + +#ifndef FP_OFF +#ifdef _FP_OFF +#define FP_OFF(p) _FP_OFF(p) +#define FP_SEG(p) _FP_SEG(p) +#else +#define FP_OFF(p) ((unsigned short)((unsigned long)((void far *)(p)))) +#define FP_SEG(p) ((unsigned short)((unsigned long)((void far *)(p)) >> 16)) +#endif +#endif + +static int get_drive P_ ((void)); +static int check_lfn P_ ((const char *)); +FILE *os_fopen P_ ((const char *, const char *)); + +static int +get_drive() +{ + union REGS ireg, oreg; + + ireg.h.ah = 0x19; + intdos(&ireg, &oreg); + return (unsigned char) oreg.h.al; +} + +static int +check_lfn(path) +const char *path; +{ + static int lfn_supported = -1; + static char drv_cache['Z' - 'A' + 1]; + union REGS ireg, oreg; + struct SREGS sreg; + char buf[32]; + char *root; + char *env; + int lfn_ok; + int drv; + + if (lfn_supported == -1) { + lfn_supported = ((env = getenv("XARGS")) != 0 && strstr(env, "LFN") != 0) + || ((env = getenv("LFN")) != 0 && tolower(env[0]) != 'n'); + memset(drv_cache, (char) -1, sizeof (drv_cache)); + } + + if (lfn_supported == 0) + return 0; + + root = (char *) alloca(strlen(path) + 4); + if (path[0] == '\\' && path[1] == '\\') { + drv = -1; + strcpy(root, path); + } else { + drv = isalpha(path[0]) && path[1] == ':' + ? toupper(path[0]) - 'A' : get_drive() ; + + if (drv_cache[drv] >= 0) + return drv_cache[drv]; + + root[0] = drv + 'A'; + root[1] = ':'; + root[2] = '\\'; + root[3] = '\0'; + } + + ireg.x.ax = 0x71a0; + ireg.x.di = FP_OFF(buf); + sreg.es = FP_SEG(buf); + ireg.x.dx = FP_OFF(root); + sreg.ds = FP_SEG(root); + + intdosx(&ireg, &oreg, &sreg); + + lfn_ok = oreg.x.cflag ? 0 : 1 ; + + if (drv >= 0) + drv_cache[drv] = lfn_ok; + + return lfn_ok; +} + +FILE * +os_fopen(name, mode) +const char *name; +const char *mode; +{ + union REGS ireg, oreg; + struct SREGS sreg; + char *sname; + FILE *fp; + + if (check_lfn(name) == 0) { + fp = fopen(name, mode); + } else { + sname = (char *) alloca(strlen(name) + 1); + + ireg.x.ax = 0x7160; + ireg.h.cl = 1; + ireg.h.ch = 0x80; + ireg.x.si = FP_OFF(name); + sreg.ds = FP_SEG(name); + ireg.x.di = FP_OFF(sname); + sreg.es = FP_SEG(sname); + + intdosx(&ireg, &oreg, &sreg); + + fp = fopen((oreg.x.cflag ? name : sname), mode); + } + + return fp; +} + +#define fopen(name,mode) os_fopen((name),(mode)) +#endif /* defined(MSDOS) && !defined(__GO32__) */ + /* Print an error message and exit */ -#if !defined __STDC__ || !__STDC__ +#if (!defined __STDC__ || !__STDC__) && !defined MSDOS # include # define VSTART(l,a) va_start(l) @@ -369,5 +491,5 @@ add1_buffer(b, c) struct buffer *b; - int c; + mbchar_t c; { /* This special case should be kept cheap; @@ -379,7 +501,8 @@ if (c != EOF) { - if (b->allocated - b->length < 1) - resize_buffer(b, b->length+1); - b->b[b->length++] = c; + if (b->allocated - b->length < MBCLEN_MAX) + resize_buffer(b, b->length + MBCLEN_MAX); + mbcstore(&b->b[b->length], c); + b->length += mbclen(b->b[b->length]); } } diff -u2rN sed-3.02/sed/utils.h sed-3.02+mb1.09/sed/utils.h --- sed-3.02/sed/utils.h Mon Jul 6 12:56:26 1998 +++ sed-3.02+mb1.09/sed/utils.h Sun Nov 19 17:44:19 2000 @@ -1,3 +1,7 @@ +/* Multi-byte extension added Feb, 1999 by WILLs (okabe katsuyuki) + Last change: Feb 10, 1999 by WILLs */ + #include +#include "mbc.h" void panic P_((const char *str, ...)); @@ -20,6 +24,11 @@ size_t size_buffer P_((struct buffer *b)); void add_buffer P_((struct buffer *b, const char *p, size_t n)); -void add1_buffer P_((struct buffer *b, int ch)); +void add1_buffer P_((struct buffer *b, mbchar_t ch)); void free_buffer P_((struct buffer *b)); + +#if defined MSDOS && !defined __GO32__ +FILE *os_fopen P_((const char *name, const char *mode)); +#define fopen(name,mode) os_fopen((name),(mode)) +#endif extern const char *myname; diff -u2rN sed-3.02/testsuite/Makefile.am sed-3.02+mb1.09/testsuite/Makefile.am --- sed-3.02/testsuite/Makefile.am Sat Jul 25 15:59:49 1998 +++ sed-3.02+mb1.09/testsuite/Makefile.am Sun Nov 19 17:44:19 2000 @@ -1,3 +1,3 @@ -SED=$(top_builddir)/sed/sed +SED=$(top_builddir)/sed/sed --ctype=ASCII #TIME=time CMP=cmp @@ -158,4 +158,4 @@ # so I need to special-case this: version.good: $(srcdir)/version.gin Makefile - $(SED) 's^@'VERSION'@^@VERSION@^' $(srcdir)/version.gin > tmp-$@ + $(SED) -e 's^@'VERSION'@^@VERSION@^' -e 's^@'MBVERSION'@^@MBVERSION@^' $(srcdir)/version.gin > tmp-$@ mv tmp-$@ $@ diff -u2rN sed-3.02/testsuite/Makefile.in sed-3.02+mb1.09/testsuite/Makefile.in --- sed-3.02/testsuite/Makefile.in Sun Aug 2 10:17:18 1998 +++ sed-3.02+mb1.09/testsuite/Makefile.in Tue Nov 28 01:03:07 2000 @@ -1,5 +1,5 @@ -# Makefile.in generated automatically by automake 1.3 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -12,5 +12,5 @@ -SHELL = /bin/sh +SHELL = @SHELL@ srcdir = @srcdir@ @@ -33,5 +33,5 @@ oldincludedir = /usr/include -DISTDIR = +DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ @@ -47,5 +47,5 @@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -60,49 +60,23 @@ CC = @CC@ MAKEINFO = @MAKEINFO@ +MBVERSION = @MBVERSION@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ +binsuffix = @binsuffix@ -SED=$(top_builddir)/sed/sed +SED = $(top_builddir)/sed/sed --ctype=ASCII #TIME=time -CMP=cmp -RM=rm -f +CMP = cmp +RM = rm -f CLEANFILES = tmp* core *.core DISTCLEANFILES = version.good -EXTRA_DIST = \ - Makefile.in \ - enable.good enable.inp enable.sed \ - sep.good sep.inp sep.sed \ - inclib.good inclib.inp inclib.sed \ - 8bit.good 8bit.inp 8bit.sed \ - newjis.good newjis.inp newjis.sed \ - manis.inp manis.sed \ - xabcx.good xabcx.inp xabcx.sed \ - dollar.good dollar.inp dollar.sed \ - noeol.good noeol.inp noeol.sed \ - numsub.good numsub.inp numsub.sed \ - allsub.good allsub.sed \ - subwrite.inp subwrite.sed subwrt1.good subwrt2.good \ - head.good head.inp head.sed \ - madding.good madding.inp madding.sed \ - mac-mf.good mac-mf.inp mac-mf.sed \ - empty.good empty.inp empty.sed \ - 8to7.good 8to7.sed \ - cv-vars.good cv-vars.inp cv-vars.sed \ - middle.good middle.sed \ - khadafy.inp khadafy.sed \ - spencer.inp spencer.sh \ - linecnt.good linecnt.inp linecnt.sed \ - distrib.good distrib.inp distrib.sed distrib.sh \ - writeout.inp writeout.sed wrtout1.good wrtout2.good \ - readin.good readin.in2 readin.inp readin.sed \ - dc.good dc.inp \ - help.good version.gin - -CORE_BASICS = \ - enable sep inclib 8bit newjis xabcx dollar noeol \ - numsub head madding mac-mf empty +EXTRA_DIST = Makefile.in enable.good enable.inp enable.sed sep.good sep.inp sep.sed inclib.good inclib.inp inclib.sed 8bit.good 8bit.inp 8bit.sed newjis.good newjis.inp newjis.sed manis.inp manis.sed xabcx.good xabcx.inp xabcx.sed dollar.good dollar.inp dollar.sed noeol.good noeol.inp noeol.sed numsub.good numsub.inp numsub.sed allsub.good allsub.sed subwrite.inp subwrite.sed subwrt1.good subwrt2.good head.good head.inp head.sed madding.good madding.inp madding.sed mac-mf.good mac-mf.inp mac-mf.sed empty.good empty.inp empty.sed 8to7.good 8to7.sed cv-vars.good cv-vars.inp cv-vars.sed middle.good middle.sed khadafy.inp khadafy.sed spencer.inp spencer.sh linecnt.good linecnt.inp linecnt.sed distrib.good distrib.inp distrib.sed distrib.sh writeout.inp writeout.sed wrtout1.good wrtout2.good readin.good readin.in2 readin.inp readin.sed dc.good dc.inp help.good version.gin + + +CORE_BASICS = enable sep inclib 8bit newjis xabcx dollar noeol numsub head madding mac-mf empty + mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h @@ -114,12 +88,11 @@ TAR = tar -GZIP = --best -all: Makefile - +GZIP_ENV = --best +all: all-redirect .SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps testsuite/Makefile +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -134,33 +107,46 @@ distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu testsuite/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file; \ + if test -d $$d/$$file; then \ + cp -pr $$/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ done -info: -dvi: -check: all - $(MAKE) -installcheck: -install-exec: - @$(NORMAL_INSTALL) - -install-data: - @$(NORMAL_INSTALL) - -install: install-exec install-data all - @: - -uninstall: - +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile +all-redirect: all-am install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: @@ -168,26 +154,33 @@ distclean-generic: - -rm -f Makefile $(DISTCLEANFILES) + -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -mostlyclean: mostlyclean-generic +mostlyclean-am: mostlyclean-generic + +mostlyclean: mostlyclean-am -clean: clean-generic mostlyclean +clean-am: clean-generic mostlyclean-am -distclean: distclean-generic clean - -rm -f config.status +clean: clean-am -maintainer-clean: maintainer-clean-generic distclean +distclean-am: distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." -.PHONY: tags distdir info dvi installcheck install-exec install-data \ -install uninstall all installdirs mostlyclean-generic distclean-generic \ -clean-generic maintainer-clean-generic clean mostlyclean distclean \ -maintainer-clean +maintainer-clean: maintainer-clean-am + +.PHONY: tags distdir info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean @@ -305,5 +298,5 @@ # so I need to special-case this: version.good: $(srcdir)/version.gin Makefile - $(SED) 's^@'VERSION'@^@VERSION@^' $(srcdir)/version.gin > tmp-$@ + $(SED) -e 's^@'VERSION'@^@VERSION@^' -e 's^@'MBVERSION'@^@MBVERSION@^' $(srcdir)/version.gin > tmp-$@ mv tmp-$@ $@ diff -u2rN sed-3.02/testsuite/help.good sed-3.02+mb1.09/testsuite/help.good --- sed-3.02/testsuite/help.good Tue Jun 2 11:26:56 1998 +++ sed-3.02+mb1.09/testsuite/help.good Sun Nov 19 17:44:19 2000 @@ -9,4 +9,7 @@ --help display this help and exit -V, --version output version information and exit + -W ctype=character-set, --ctype=character-set + specify the character set + character-set is ASCII, EUC, SJIS, or UTF8 If no -e, --expression, -f, or --file option is given, then the first @@ -17,2 +20,4 @@ E-mail bug reports to: bug-gnu-utils@gnu.org . Be sure to include the word ``sed'' somewhere in the ``Subject:'' field. + +Report multi-byte extension version bugs to: hgc02147@nifty.ne.jp . diff -u2rN sed-3.02/testsuite/version.gin sed-3.02+mb1.09/testsuite/version.gin --- sed-3.02/testsuite/version.gin Tue Jul 7 14:42:54 1998 +++ sed-3.02+mb1.09/testsuite/version.gin Sun Nov 19 17:44:20 2000 @@ -1,3 +1,3 @@ -GNU sed version @VERSION@ +GNU sed version @VERSION@ + multi-byte extension @MBVERSION@ Copyright (C) 1998 Free Software Foundation, Inc.