aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FAQ160
-rw-r--r--LAYOUT128
-rw-r--r--LICENSE25
-rw-r--r--README93
-rw-r--r--build/ExtUtils/Embed.pm473
-rw-r--r--build/Makefile.in630
-rw-r--r--build/README369
-rw-r--r--build/README.LynxOS320
-rw-r--r--build/acconfig.h82
-rw-r--r--build/aclocal.m417
-rwxr-xr-xbuild/config.guess571
-rw-r--r--build/config.h.in179
-rwxr-xr-xbuild/config.sub872
-rwxr-xr-xbuild/configure4446
-rw-r--r--build/configure.in725
-rw-r--r--build/distrib84
-rwxr-xr-xbuild/install-sh238
-rw-r--r--build/pathnames.h.in45
-rw-r--r--build/port.h.in185
-rw-r--r--build/recover.in49
-rw-r--r--build/spell.ok58
-rw-r--r--catalog/Makefile26
-rw-r--r--catalog/README125
-rw-r--r--catalog/dump.c36
-rw-r--r--catalog/dutch317
-rw-r--r--catalog/dutch.base15
-rw-r--r--catalog/dutch.check37
-rw-r--r--catalog/english317
-rw-r--r--catalog/english.base309
-rw-r--r--catalog/english.check36
-rw-r--r--catalog/french317
-rw-r--r--catalog/french.base461
-rw-r--r--catalog/french.check34
-rw-r--r--catalog/german317
-rw-r--r--catalog/german.base311
-rw-r--r--catalog/german.check36
-rw-r--r--catalog/german.owner3
-rw-r--r--catalog/polish.base306
-rw-r--r--catalog/polish.owner1
-rw-r--r--catalog/ru_RU.KOI8-R267
-rw-r--r--catalog/ru_RU.KOI8-R.base530
-rw-r--r--catalog/ru_RU.KOI8-R.check169
-rw-r--r--catalog/ru_RU.KOI8-R.owner4
-rw-r--r--catalog/ru_SU.KOI8-R267
-rw-r--r--catalog/ru_SU.KOI8-R.base219
-rw-r--r--catalog/ru_SU.KOI8-R.check169
-rw-r--r--catalog/ru_SU.KOI8-R.owner1
-rw-r--r--catalog/spanish317
-rw-r--r--catalog/spanish.base313
-rw-r--r--catalog/spanish.check35
-rw-r--r--catalog/swedish317
-rw-r--r--catalog/swedish.base41
-rw-r--r--catalog/swedish.check34
-rw-r--r--catalog/uk_UA.KOI8-U.base306
-rw-r--r--catalog/uk_UA.KOI8-U.owner1
-rw-r--r--catalog/zh_CN.GB2312.base311
-rw-r--r--catalog/zh_CN.GB2312.owner1
-rw-r--r--cl/README.signal2
-rw-r--r--cl/cl.h51
-rw-r--r--cl/cl_bsd.c346
-rw-r--r--cl/cl_funcs.c408
-rw-r--r--cl/cl_main.c96
-rw-r--r--cl/cl_read.c83
-rw-r--r--cl/cl_screen.c69
-rw-r--r--cl/cl_term.c140
-rw-r--r--cl/extern.h (renamed from include/cl_extern.h)33
-rw-r--r--clib/env.c160
-rw-r--r--clib/gethostname.c22
-rw-r--r--clib/getopt.c130
-rw-r--r--clib/memmove.c147
-rw-r--r--clib/memset.c137
-rw-r--r--clib/mkstemp.c133
-rw-r--r--clib/mmap.c50
-rw-r--r--clib/snprintf.c45
-rw-r--r--clib/strerror.c74
-rw-r--r--clib/strsep.c85
-rw-r--r--clib/strtol.c134
-rw-r--r--clib/strtoul.c113
-rw-r--r--clib/vsnprintf.c31
-rw-r--r--common/api.c525
-rw-r--r--common/args.h2
-rw-r--r--common/common.h15
-rw-r--r--common/conv.c446
-rw-r--r--common/conv.h57
-rw-r--r--common/cut.c143
-rw-r--r--common/cut.h18
-rw-r--r--common/delete.c39
-rw-r--r--common/encoding.c230
-rw-r--r--common/exf.c431
-rw-r--r--common/exf.h20
-rw-r--r--common/extern.h (renamed from include/com_extern.h)141
-rw-r--r--common/gs.h62
-rw-r--r--common/key.c257
-rw-r--r--common/key.h66
-rw-r--r--common/line.c278
-rw-r--r--common/log.c174
-rw-r--r--common/main.c98
-rw-r--r--common/mark.c74
-rw-r--r--common/mark.h5
-rw-r--r--common/mem.h130
-rw-r--r--common/msg.c295
-rw-r--r--common/msg.h4
-rw-r--r--common/multibyte.h115
-rw-r--r--common/options.c595
-rw-r--r--common/options.h5
-rw-r--r--common/options_def.h83
-rw-r--r--common/options_f.c212
-rw-r--r--common/put.c54
-rw-r--r--common/recover.c590
-rw-r--r--common/screen.c57
-rw-r--r--common/screen.h30
-rw-r--r--common/search.c72
-rw-r--r--common/seq.c151
-rw-r--r--common/seq.h6
-rw-r--r--common/util.c303
-rw-r--r--common/util.h39
-rw-r--r--docs/USD.doc/vi.man/vi.186
-rw-r--r--docs/USD.doc/vi.ref/vi.ref2
-rw-r--r--docs/help2
-rw-r--r--ex/ex.c279
-rw-r--r--ex/ex.h35
-rw-r--r--ex/ex_abbrev.c14
-rw-r--r--ex/ex_append.c38
-rw-r--r--ex/ex_args.c63
-rw-r--r--ex/ex_argv.c464
-rw-r--r--ex/ex_at.c28
-rw-r--r--ex/ex_bang.c15
-rw-r--r--ex/ex_cd.c46
-rw-r--r--ex/ex_cmd.c176
-rw-r--r--ex/ex_cscope.c404
-rw-r--r--ex/ex_def.h76
-rw-r--r--ex/ex_delete.c7
-rw-r--r--ex/ex_display.c68
-rw-r--r--ex/ex_edit.c32
-rw-r--r--ex/ex_equal.c7
-rw-r--r--ex/ex_file.c16
-rw-r--r--ex/ex_filter.c31
-rw-r--r--ex/ex_global.c68
-rw-r--r--ex/ex_init.c115
-rw-r--r--ex/ex_join.c33
-rw-r--r--ex/ex_map.c13
-rw-r--r--ex/ex_mark.c7
-rw-r--r--ex/ex_mkexrc.c10
-rw-r--r--ex/ex_move.c46
-rw-r--r--ex/ex_open.c7
-rw-r--r--ex/ex_perl.c69
-rw-r--r--ex/ex_preserve.c19
-rw-r--r--ex/ex_print.c94
-rw-r--r--ex/ex_put.c7
-rw-r--r--ex/ex_quit.c7
-rw-r--r--ex/ex_read.c53
-rw-r--r--ex/ex_screen.c23
-rw-r--r--ex/ex_script.c313
-rw-r--r--ex/ex_set.c7
-rw-r--r--ex/ex_shell.c203
-rw-r--r--ex/ex_shift.c29
-rw-r--r--ex/ex_source.c24
-rw-r--r--ex/ex_stop.c7
-rw-r--r--ex/ex_subst.c262
-rw-r--r--ex/ex_tag.c582
-rw-r--r--ex/ex_tcl.c80
-rw-r--r--ex/ex_txt.c63
-rw-r--r--ex/ex_undo.c7
-rw-r--r--ex/ex_usage.c34
-rw-r--r--ex/ex_util.c72
-rw-r--r--ex/ex_version.c10
-rw-r--r--ex/ex_visual.c16
-rw-r--r--ex/ex_write.c113
-rw-r--r--ex/ex_yank.c7
-rw-r--r--ex/ex_z.c9
-rw-r--r--ex/extern.h (renamed from include/ex_extern.h)35
-rw-r--r--ex/script.h4
-rw-r--r--ex/tag.h24
-rw-r--r--ex/version.h3
-rw-r--r--include/bitstring.h143
-rw-r--r--include/ex_def.h78
-rw-r--r--include/ip_extern.h23
-rw-r--r--include/options_def.h79
-rw-r--r--include/perl_extern.h8
-rw-r--r--include/sys/queue.h259
-rw-r--r--include/tcl_extern.h1
-rw-r--r--include/tk_extern.h29
-rw-r--r--ip/IP_INSTRUCTIONS41
-rw-r--r--ip/ip.h92
-rw-r--r--ip/ip_funcs.c443
-rw-r--r--ip/ip_main.c165
-rw-r--r--ip/ip_read.c307
-rw-r--r--ip/ip_screen.c87
-rw-r--r--ip/ip_term.c108
-rw-r--r--ip_cl/Makefile20
-rw-r--r--ip_cl/ip_cl.c742
-rw-r--r--perl_api/VI.pod218
-rw-r--r--perl_api/nviperl.pod43
-rw-r--r--perl_api/perl.xs1115
-rw-r--r--perl_api/perlsfio.c85
-rw-r--r--perl_api/typemap42
-rw-r--r--perl_scripts/forall.pl10
-rw-r--r--perl_scripts/make.pl27
-rw-r--r--perl_scripts/tk.pl20
-rw-r--r--perl_scripts/wc.pl11
-rw-r--r--regex/COPYRIGHT (renamed from clib/strpbrk.c)56
-rw-r--r--regex/WHATSNEW94
-rw-r--r--regex/cclass.h (renamed from clib/bsearch.c)111
-rw-r--r--regex/cname.h143
-rw-r--r--regex/engine.c1102
-rw-r--r--regex/re_format.7271
-rw-r--r--regex/regcomp.c1737
-rw-r--r--regex/regerror.c176
-rw-r--r--regex/regex.3540
-rw-r--r--regex/regex.h109
-rw-r--r--regex/regex2.h174
-rw-r--r--regex/regexec.c180
-rw-r--r--regex/regfree.c (renamed from clib/strdup.c)64
-rw-r--r--regex/utils.h (renamed from clib/memchr.c)52
-rw-r--r--tcl_api/tcl.c852
-rw-r--r--tcl_scripts/errors.tcl44
-rw-r--r--tcl_scripts/gnats.tcl95
-rw-r--r--tcl_scripts/mailprocs.tcl115
-rw-r--r--tcl_scripts/wc.tcl16
-rw-r--r--tk/init.tcl1096
-rw-r--r--tk/tk_funcs.c346
-rw-r--r--tk/tk_main.c423
-rw-r--r--tk/tk_read.c207
-rw-r--r--tk/tk_screen.c86
-rw-r--r--tk/tk_term.c169
-rw-r--r--tk/tk_util.c250
-rw-r--r--tk/tki.h64
-rw-r--r--vi/extern.h (renamed from include/vi_extern.h)13
-rw-r--r--vi/getc.c36
-rw-r--r--vi/v_at.c24
-rw-r--r--vi/v_ch.c43
-rw-r--r--vi/v_cmd.c2
-rw-r--r--vi/v_delete.c6
-rw-r--r--vi/v_ex.c190
-rw-r--r--vi/v_increment.c47
-rw-r--r--vi/v_init.c23
-rw-r--r--vi/v_itxt.c69
-rw-r--r--vi/v_left.c22
-rw-r--r--vi/v_mark.c70
-rw-r--r--vi/v_match.c91
-rw-r--r--vi/v_paragraph.c20
-rw-r--r--vi/v_put.c14
-rw-r--r--vi/v_redraw.c6
-rw-r--r--vi/v_replace.c19
-rw-r--r--vi/v_right.c10
-rw-r--r--vi/v_screen.c14
-rw-r--r--vi/v_scroll.c69
-rw-r--r--vi/v_search.c121
-rw-r--r--vi/v_section.c22
-rw-r--r--vi/v_sentence.c12
-rw-r--r--vi/v_status.c7
-rw-r--r--vi/v_txt.c527
-rw-r--r--vi/v_ulcase.c38
-rw-r--r--vi/v_undo.c10
-rw-r--r--vi/v_util.c31
-rw-r--r--vi/v_word.c69
-rw-r--r--vi/v_xchar.c10
-rw-r--r--vi/v_yank.c6
-rw-r--r--vi/v_z.c12
-rw-r--r--vi/v_zexit.c6
-rw-r--r--vi/vi.c174
-rw-r--r--vi/vi.h31
-rw-r--r--vi/vs_line.c76
-rw-r--r--vi/vs_msg.c113
-rw-r--r--vi/vs_refresh.c80
-rw-r--r--vi/vs_relative.c43
-rw-r--r--vi/vs_smap.c116
-rw-r--r--vi/vs_split.c570
268 files changed, 13999 insertions, 30361 deletions
diff --git a/FAQ b/FAQ
deleted file mode 100644
index 357650a589bd..000000000000
--- a/FAQ
+++ /dev/null
@@ -1,160 +0,0 @@
-@(#)FAQ 8.13 (Berkeley) 10/14/96
-
-Q: How can I get vi to display my character set?
-A: Vi uses the C library routine isprint(3) to determine if a character
- is printable, or should be displayed as an octal or hexadecimal value
- on the screen. Generally, if vi is displaying printable characters
- in octal/hexadecimal forms, your environment is not configured correctly.
- Try looking at the man pages that allow you to configure your locale.
- For example, to configure an ISO 8859-1 locale under Solaris using csh,
- you would do:
-
- setenv LANG C
- setenv LC_CTYPE iso_8859_1
-
- Other LC_CTYPE systems/values that I'm told work:
-
- System Value
- ====== =====
- FreeBSD lt_LN.ISO_8859-1
- HP-UX 9.X american.iso88591
- HP-UX 10.X en_US.iso88591
- SunOS 4.X iso_8859_1
- SunOS 5.X iso_8859_1
-
- If there's no other solution, you can use the print and noprint edit
- options of vi to specify that a specific character is printable or not
- printable.
-
-Q: My map won't work!
-A: One thing that you should immediately check if a vi map doesn't work
- is if depends on the final cursor position after a P or p command.
- Historic vi's were inconsistent as to the final position of the cursor,
- and, to make matter worse, the final cursor position also depended on
- whether the put text came from a named or unnamed buffer! Vi follows
- the POSIX 1003.2 standard on this one, and makes this consistent, always
- placing the cursor on the first character.
-
-Q: I'm using ksh or csh as my vi edit option shell value, and file
- expansions don't work right!
-A: The problem may be in your ksh or csh startup files, e.g., .cshrc. Vi
- executes the shell to do name expansion, and the shell generally reads
- its startup files. If the startup files are not correctly configured
- for non-interactive use, e.g., they always echo a prompt to the screen,
- vi will be unable to parse the output and things will not work
- correctly.
-
-Q: How does the iclower edit option differ from the ignorecase (i.e. ic)
- edit option?
-A: The difference is that the ignorecase edit option always ignores the
- case of letters in the Regular Expression (RE), and the iclower edit
- option only ignores the case if there are no upper-case letters in the
- RE. If any upper-case letters appear in the Regular Expression, then
- it will be treated case-sensitively, as if the ignorecase edit option
- was not set.
-
-Q: When I edit binary files, vi appends a <newline> to the last line!
-A: This is historic practice for vi, and further, it's required by the
- POSIX 1003.2 standard. My intent is to provide a command line and/or
- edit option to turn this behavior off when I switch to version 2.0 of
- the Berkeley DB package.
-
-Q: My cursor keys don't work when I'm in text input mode!
-A: A common problem over slow links is that the set of characters sent by
- the cursor keys don't arrive close enough together for vi to understand
- that they are a single keystroke, and not separate keystrokes. Try
- increasing the value of the escapetime edit option, which will cause
- vi to wait longer before deciding that the <escape> character that
- starts cursor key sequences doesn't have any characters following it.
-
-Q: When I edit some files, vi seems to hang forever, and I have to kill it.
-A: Vi uses flock(2) and fcntl(2) to do file locking. When it attempts to
- acquired a lock for a file on an NFS mounted filesystem, it can hang
- for a very long (perhaps infinite) period of time. Turning off the
- "lock" edit option will keep vi from attempting to acquire any locks
- on the files you edit.
-
-Q: When I compile vi I get lots of warnings about pointer assignments
- being incompatible!
-A: Vi is partially written to support wide characters. When this code
- interfaces with the code that doesn't yet support wide characters,
- the pointer types clash. This will hopefully be fixed in the near
- future, but I've been saying that for awhile, now.
-
-Q: I get jumpy scrolling behavior in the screen!
-A: This is almost certainly a problem with the system's terminfo or
- termcap information for your terminal. If the terminfo/termcap entry
- doesn't have the settable scrolling region capabilities, or the more
- powerful scrolling commands, these behaviors can result. Historic
- implementations of vi, and some of the vi clones, don't suffer from
- this problem because they wrote their own screen support instead of
- using the curses library.
-
- The solution is to find a good terminfo or termcap entry for your
- terminal, which will fix the problem for all of the applications on
- your system, not just vi. Eric Raymond maintains the freely
- redistributable termcap/terminfo entries. They can be downloaded
- from http://www.ccil.org/~esr/ncurses.html, or you can contact him
- at esr@snark.thyrsus.com.
-
-Q: The entire screen repaints on every keystroke!
-A: Your system's curses implementation is broken. You should use the
- curses implementation provided with vi or a curses replacement such
- as ncurses. Eric Raymond is one of the maintainers of the freely
- redistributable ncurses package. You can download ncurses from
- http://www.ccil.org/~esr/ncurses.html, or you can contact him at
- esr@snark.thyrsus.com.
-
-Q: When I use vi on a Sun console (terminal type sun-34) the screen
- is occasionally trashed, usually when exiting vi!
-A: The Sun console can't handle the 'al' capability of the termcap
- entry (the il1 capability of terminfo entries). If you delete that
- entry from your terminfo/termcap information everything should work
- correctly.
-
-Q: I don't have a version of ctags (or I have ctags, but it doesn't tag
- nearly enough things)!
-A: There's a version of ctags available on the 4.4BSD-Lite distributions,
- as well as the FreeBSD, NetBSD, Linux and GNU distributions. Or, you
- might want to try Exuberant Ctags:
-
- Title: Exuberant Ctags
- Version: 1.3
- Entered-date: 16JUN96
- Description:
- A better ctags which generates tags for all possible tag types:
- macro definitions, enumerated values (values inside enum{...}),
- function and method definitions, enum/struct/union tags, external
- function prototypes (optional), typedefs, and variable
- declarations. It is far less easily fooled by code containing #if
- preprocessor conditional constructs, using a conditional path
- selection algorithm to resolve complicated choices, and a
- fall-back algorithm when this one fails. Can also be used to print
- out a list of selected objects found in source files.
- Keywords: ctags, tags, exuberant
- Author: darren@sirsi.com (Darren Hiebert)
- darren@hiwaay.net (Darren Hiebert)
- Maintained-by: darren@sirsi.com (Darren Hiebert)
- darren@hiwaay.net (Darren Hiebert)
- Primary-site: sunsite.unc.edu /pub/Linux/devel/lang/c
- 27kB ctags-1.3.tar.gz
- Alternate-site: ftp.halcyon.com /local/gvr
- 27kB ctags-1.3.tar.gz
- Original-site:
- Platforms: UNIX, MSDOS, WindowsNT, Windows95, OS/2, Amiga
- Copying-policy: Public domain
-
-Q: When I update a file I already have open, and use :e to reread it, I
- get nul's for the rest of the file!
-A: Your system's implementation of mmap(2) has a bug; you will have to
- exit vi and re-execute it.
-
-Q: Where can I get cscope?
-A: Cscope is available on UNIXWare System V Release 4.0 variants such as
- Sun Solaris 2.x (/opt/SUNWspro/bin) and UNIXWare System V Release 4.1.
-
- You can buy version 13.3 source with an unrestricted license for $400
- from AT&T Software Solutions by calling +1-800-462-8146. Binary
- redistribution of cscope is an additional $1500, one-time flat fee.
-
- For more information, see http://www.unipress.com/att/new/cscope.html.
diff --git a/LAYOUT b/LAYOUT
deleted file mode 100644
index e3a55ebb5778..000000000000
--- a/LAYOUT
+++ /dev/null
@@ -1,128 +0,0 @@
-# @(#)LAYOUT 8.12 (Berkeley) 10/10/96
-
-LAYOUT
- This file: the layout of the nvi sources.
-
-LICENSE
- Nvi's copyright notice and conditions for redistribution.
-
-README
- Welcome message and basic information.
-
-build/
- The build/configuration directory for nvi. See build/README for
- more information.
-
-catalog/
- Support for message catalogs for nvi. See catalog/README for more
- information.
-
-cl/
- Source files for nvi's curses screen support.
-
-clib/
- Replacement source files for C library functions.
-
-common/
- Source files for pieces of code that are shared by ex and vi,
- e.g., searching and logging code or code translating line numbers
- into requests to the dbopen(3) database code. It also has the
- interface code for modifying "records" in the underlying database.
-
-curses/
- A stripped-down replacement curses library. Do not try and use
- this library outside of nvi, many standard curses functions have
- been removed because nvi doesn't use them. See build/README for
- more information.
-
-db/
- A stripped-down replacement DB library. Do not try and use this
- library outside of nvi, many standard DB functions have been
- removed because nvi doesn't use them. See db/README for more
- information.
-
-docs/
- Ex/vi documentation, both current and historic.
-
- USD.doc/
- [USD stands for "User's Supplementary Documents".]
-
- edit/ Roff source for "Edit: A tutorial". This document
- was USD:14 in the 4.3BSD manuals, but was not
- distributed with 4.4BSD.
-
- exref/ Roff source for "Ex Reference Manual -- Version
- 3.7". This document was USD:16 in the 4.3BSD
- manuals, and USD tabbed 12 in the 4.4BSD manuals.
-
- vi.man/ Roff source for a UNIX manual page for nex/nvi.
- An updated version of the 4.4BSD manual page.
-
- vi.ref/ Roff source for the nex/nvi reference document.
- An updated version of the 4.4BSD document, USD
- tabbed 13.
-
- vitut/ Roff source for "An Introduction to Display
- Editing with Vi". This document was USD:15 in
- the 4.3BSD manuals, but was not distributed with
- 4.4BSD. It includes the historic "Vi Quick
- Reference" card.
-
-
- PostScript preformatted versions of the nex/nvi reference
- manual and manual page are in the files named with a ".ps"
- suffix, in their respective source directories. Flat text
- preformatted versions of the nex/nvi reference manual and
- manual page are in the files named with a ".txt" suffix,
- in their respective source directories.
-
- changelog -- Log of changes from version to version.
- features -- Todo list, suggested features list.
- internals/
- autowrite -- Vi autowrite option discussion.
- context -- Previous context marks discussion.
- gdb.script -- GDB debugging scripts.
- input -- Vi maps, executable buffers, and input discussion.
- openmode -- Open mode behaviors.
- quoting -- Vi quoting discussion.
- structures -- Out-of-date nvi internal structure description.
- tutorial/ -- Historic vi tutorial(s), of unknown quality.
-
-ex/
- The ex source code. Because vi has the colon command, lots of
- this code is used by vi. Generally, if functionality is shared
- by both ex and vi, it's in the ex directory. If it's vi only,
- it's in the vi directory. Files are generally named by the
- command(s) they support, but occasionally with a name that
- describes their functionality.
-
- version.h -- Version information.
-
-include/
- Replacement include files:
-
- bitstring.h -- The 4.4BSD bitstring operations.
- sys/queue.h -- The 4.4BSD queue operations.
-
-perl_api/
- Source code supporting the Perl scripting language for nvi.
-
-perl_scripts/
- Scripts for Perl included with nvi.
-
-regex/
- Henry Spencer's POSIX 1003.2 regular expression (RE) library.
-
-tcl_api/
- Source code supporting the Tcl scripting language for nvi.
-
-tcl_scripts/
- Scripts for Tcl included with nvi.
-
-tk/
- Source files for nvi's Tk screen support.
-
- init.tcl -- Vi startup tcl script.
-
-vi/
- The vi source code.
diff --git a/LICENSE b/LICENSE
index 78e8f4a40e19..c79151197da6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,14 +1,19 @@
-The vi program is freely redistributable. You are welcome to copy, modify
-and share it with others under the conditions listed in this file. If any
-company (not any individual!) finds vi sufficiently useful that you would
-have purchased it, or if any company wishes to redistribute it, contributions
-to the authors would be appreciated.
-
/*-
+ * $Id: LICENSE,v 8.18 2011/07/10 11:58:35 zy Exp $
+ */
+
+The following are the copyrights and redistribution conditions that apply
+to this copy of the Vi software.
+
+/*
* Copyright (c) 1991, 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
- * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996
+ * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
* Keith Bostic. All rights reserved.
+ * Copyright (c) 1999, 2000
+ * Sven Verdoolaege. All rights reserved.
+ * Copyright (c) 2011
+ * Zhihao Yuan. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -18,11 +23,7 @@ to the authors would be appreciated.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/README b/README
index 33db36a5c862..bb05379e7a7c 100644
--- a/README
+++ b/README
@@ -1,31 +1,32 @@
-# @(#)README 8.147 (Berkeley) 10/19/96
+# $Id: README,v 9.0 2012/10/07 09:13:54 zy Exp $
-This is the README for nex/nvi, a freely redistributable implementation
-of the ex/vi text editors originally distributed as part of the Fourth
-Berkeley Software Distribution (4BSD), by the University of California,
-Berkeley.
+This is version 2.1.1 (2012-10-07) of nex/nvi, a reimplementation of the ex/vi
+text editors originally distributed as part of the Fourth Berkeley
+Software Distribution (4BSD), by the University of California, Berkeley.
-The source code for nex/nvi can be retrieved by using anonymous ftp to
-ftp.cs.berkeley.edu. The file ucb/4bsd/nvi.tar.gz is the gzip'd archive,
-of version 1.71 of nex/nvi. This version is believed to be stable and
-problem free. The file ucb/4bsd/nvi-###.ALPHA.tar.gz is a gzip'd archive
-of the current alpha-test release of nex/nvi. This version reflects the
-current development tree, and will be more likely to have problems.
+The directory layout is as follows:
-See the file:
- build/README for information on building nvi.
- LAYOUT for a description of where everything is.
- LICENSE for the copyright and redistribution terms.
+ LICENSE ....... Copyright, use and redistribution information.
+ README ........ This file.
+ build ......... Build directory.
+ catalog ....... Message catalogs; see catalog/README.
+ cl ............ Vi interface to the curses(3) library.
+ common ........ Code shared by ex and vi.
+ docs .......... Ex/vi documentation, both current and historic.
+ ex ............ Ex source code.
+ regex ......... Modified regex library with wide character support.
+ vi ............ Vi source code.
-If you have any questions about nex/nvi, problems with it, or concerns
-about the conditions for redistribution, please contact me:
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+o Nvi was written by Keith Bostic, and the last version is 1.79. After that,
- Keith Bostic +1-508-287-4781
- 394 E. Riding Dr. bostic@bostic.com
- Carlisle, MA 01741
- USA
+ Sven Verdoolaege added the iconv support and the DB3 locking.
-Keith Bostic
+ Jun-ichiro itojun Hagino developed the file encoding detection
+ techniques in his nvi-m17n.
+
+The following acknowledgments were written by Keith Bostic:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
o This software is several years old and is the product of many folks' work.
@@ -63,51 +64,3 @@ o From the original vi acknowledgements, by William Joy and Mark Horton:
o And...
The financial support of UUNET Communications Services is gratefully
acknowledged.
-
-=-=-=-=-=-=-=-=-=-=-=
-o Status:
-
-This software is in beta test, and it's pretty stable. Almost all of the
-historic functionality in ex/vi is there, the only major missing pieces
-are open mode and the lisp edit option.
-
-Nvi is largely 8-bit clean. This isn't difficult to fix, and was left in
-during initial development to keep things simple. Wide character support
-will be integrated at the same time that it is made fully 8-bit clean.
-
-There aren't a lot of new features in nex/nvi, but there are a few things
-you might like. The "Additional Features" section of the reference work
-(docs/USD.doc/vi.ref/vi.ref.txt, docs/USD.doc/vi.ref/vi.ref.ps) has more
-information.
-
-=-=-=-=-=-=-=-=-=-=-=
-o Debugging:
-
-Code fixes are greatly appreciated, of course, but if you can't provide
-them, please email me as much information as you can as to how I might
-reproduce the bug, and I'll try to fix it locally. Stack traces of core
-dumps are only rarely helpful -- an example file with a set of keystrokes
-that causes the problem is almost invariably necessary. I know it's
-annoying, but simply playing with the bug until you can reproduce it at
-will, with minimal keystrokes, is immensely helpful to me.
-
-Please include the following in the bug report;
-
- o The version of nvi you're running (use :version to get it).
- o The row/column dimensions of the screen (80 x 32).
- o Unless you're confident that they're not part of the problem,
- your startup files (.exrc, .nexrc) and the environment variable
- (EXINIT, NEXINIT) values. (Cutting and pasting the output
- of ":set all" is usually sufficient.)
-
-If you want to do your own debugging, recompile the program with DEBUG
-defined. (Configuring with --enable-debug will do this for you.) This
-turns on the additional command-line option -D, that takes either s or w
-as an argument. The option -Ds causes nvi to ignore the EXINIT and
-.exrc files on startup, and -Dw causes nvi to print out the process id
-and wait for you to enter a <carriage-return> to continue.
-
-If you're running a memory checker (e.g. Purify) on nvi, you will first
-want to recompile everything with "-DPURIFY" set in the CFLAGS. This
-initializes allocated pages in the DB code, and free's allocated memory
-at the end of the nvi execution.
diff --git a/build/ExtUtils/Embed.pm b/build/ExtUtils/Embed.pm
deleted file mode 100644
index 04525c18c908..000000000000
--- a/build/ExtUtils/Embed.pm
+++ /dev/null
@@ -1,473 +0,0 @@
-# $Id: Embed.pm,v 1.17 1996/07/02 13:48:17 dougm Exp $
-require 5.002;
-
-package ExtUtils::Embed;
-require Exporter;
-require FileHandle;
-use Config;
-use Getopt::Std;
-
-#Only when we need them
-#require ExtUtils::MakeMaker;
-#require ExtUtils::Liblist;
-
-use vars qw(@ISA @EXPORT $VERSION
- @Extensions $Verbose $lib_ext
- $opt_o $opt_s
- );
-use strict;
-
-$VERSION = sprintf("%d.%02d", q$Revision: 1.17 $ =~ /(\d+)\.(\d+)/);
-#for the namespace change
-$Devel::embed::VERSION = "99.99";
-
-sub Version { $VERSION; }
-
-@ISA = qw(Exporter);
-@EXPORT = qw(&xsinit &ldopts
- &ccopts &ccflags &ccdlflags &perl_inc
- &xsi_header &xsi_protos &xsi_body);
-
-#let's have Miniperl borrow from us instead
-#require ExtUtils::Miniperl;
-#*canon = \&ExtUtils::Miniperl::canon;
-
-$Verbose = 0;
-$lib_ext = $Config{lib_ext} || '.a';
-
-sub xsinit {
- my($file, $std, $mods) = @_;
- my($fh,@mods,%seen);
- $file ||= "perlxsi.c";
-
- if (@_) {
- @mods = @$mods if $mods;
- }
- else {
- getopts('o:s:');
- $file = $opt_o if defined $opt_o;
- $std = $opt_s if defined $opt_s;
- @mods = @ARGV;
- }
- $std = 1 unless scalar @mods;
-
- if ($file eq "STDOUT") {
- $fh = \*STDOUT;
- }
- else {
- $fh = new FileHandle "> $file";
- }
-
- push(@mods, static_ext()) if defined $std;
- @mods = grep(!$seen{$_}++, @mods);
-
- print $fh &xsi_header();
- print $fh "EXTERN_C void xs_init _((void));\n\n";
- print $fh &xsi_protos(@mods);
-
- print $fh "\nEXTERN_C void\nxs_init()\n{\n";
- print $fh &xsi_body(@mods);
- print $fh "}\n";
-
-}
-
-sub xsi_header {
- return <<EOF;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <EXTERN.h>
-#include <perl.h>
-
-#ifdef __cplusplus
-}
-# ifndef EXTERN_C
-# define EXTERN_C extern "C"
-# endif
-#else
-# ifndef EXTERN_C
-# define EXTERN_C extern
-# endif
-#endif
-
-EOF
-}
-
-sub xsi_protos {
- my(@exts) = @_;
- my(@retval,%seen);
-
- foreach $_ (@exts){
- my($pname) = canon('/', $_);
- my($mname, $cname);
- ($mname = $pname) =~ s!/!::!g;
- ($cname = $pname) =~ s!/!__!g;
- my($ccode) = "EXTERN_C void boot_${cname} _((CV* cv));\n";
- next if $seen{$ccode}++;
- push(@retval, $ccode);
- }
- return join '', @retval;
-}
-
-sub xsi_body {
- my(@exts) = @_;
- my($pname,@retval,%seen);
- my($dl) = canon('/','DynaLoader');
- push(@retval, "\tdXSUB_SYS;\n") if $] > 5.002;
- push(@retval, "\tchar *file = __FILE__;\n\n");
-
- foreach $_ (@exts){
- my($pname) = canon('/', $_);
- my($mname, $cname, $ccode);
- ($mname = $pname) =~ s!/!::!g;
- ($cname = $pname) =~ s!/!__!g;
- if ($pname eq $dl){
- # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
- # boot_DynaLoader is called directly in DynaLoader.pm
- $ccode = "\t/* DynaLoader is a special case */\n\tnewXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n";
- push(@retval, $ccode) unless $seen{$ccode}++;
- } else {
- $ccode = "\tnewXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
- push(@retval, $ccode) unless $seen{$ccode}++;
- }
- }
- return join '', @retval;
-}
-
-sub static_ext {
- unless (scalar @Extensions) {
- @Extensions = sort split /\s+/, $Config{static_ext};
- unshift @Extensions, qw(DynaLoader);
- }
- @Extensions;
-}
-
-sub ldopts {
- require ExtUtils::MakeMaker;
- require ExtUtils::Liblist;
- my($std,$mods,$link_args,$path) = @_;
- my(@mods,@link_args,@argv);
- my($dllib,$config_libs,@potential_libs,@path);
- local($") = ' ' unless $" eq ' ';
- my $MM = bless {} => 'MY';
- if (scalar @_) {
- @link_args = @$link_args if $link_args;
- @mods = @$mods if $mods;
- }
- else {
- @argv = @ARGV;
- #hmm
- while($_ = shift @argv) {
- /^-std$/ && do { $std = 1; next; };
- /^--$/ && do { @link_args = @argv; last; };
- /^-I(.*)/ && do { $path = $1 || shift @argv; next; };
- push(@mods, $_);
- }
- }
- $std = 1 unless scalar @link_args;
- @path = $path ? split(/:/, $path) : @INC;
-
- push(@potential_libs, @link_args) if scalar @link_args;
- push(@potential_libs, $Config{libs}) if defined $std;
-
- push(@mods, static_ext()) if $std;
-
- my($mod,@ns,$root,$sub,$extra,$archive,@archives);
- print STDERR "Searching (@path) for archives\n" if $Verbose;
- foreach $mod (@mods) {
- @ns = split('::', $mod);
- $sub = $ns[-1];
- $root = $MM->catdir(@ns);
-
- print STDERR "searching for '$sub${lib_ext}'\n" if $Verbose;
- foreach (@path) {
- next unless -e ($archive = $MM->catdir($_,"auto",$root,"$sub$lib_ext"));
- push @archives, $archive;
- if(-e ($extra = $MM->catdir($_,"auto",$root,"extralibs.ld"))) {
- local(*FH);
- if(open(FH, $extra)) {
- my($libs) = <FH>; chomp $libs;
- push @potential_libs, split /\s+/, $libs;
- }
- else {
- warn "Couldn't open '$extra'";
- }
- }
- last;
- }
- }
- #print STDERR "\@potential_libs = @potential_libs\n";
-
- my($extralibs, $bsloadlibs, $ldloadlibs, $ld_run_path) =
- $MM->ext(join ' ',
- $MM->catdir("-L$Config{archlib}", "CORE"), " -lperl",
- @potential_libs);
-
- my $ld_or_bs = $bsloadlibs || $ldloadlibs;
- print STDERR "bs: $bsloadlibs ** ld: $ldloadlibs" if $Verbose;
- my $linkage = "$Config{ldflags} @archives $ld_or_bs";
- print STDERR "ldopts: '$linkage'\n" if $Verbose;
-
- return $linkage if scalar @_;
- print "$linkage\n";
-}
-
-sub ccflags {
- print " $Config{ccflags} ";
-}
-
-sub ccdlflags {
- print " $Config{ccdlflags} ";
-}
-
-sub perl_inc {
- print " -I$Config{archlib}/CORE ";
-}
-
-sub ccopts {
- ccflags;
- ccdlflags;
- perl_inc;
-}
-
-sub canon {
- my($as, @ext) = @_;
- foreach(@ext) {
- # might be X::Y or lib/auto/X/Y/Y.a
- next if s!::!/!g;
- s:^(lib|ext)/(auto/)?::;
- s:/\w+\.\w+$::;
- }
- grep(s:/:$as:, @ext) if ($as ne '/');
- @ext;
-}
-
-__END__
-
-=head1 NAME
-
-ExtUtils::Embed - Utilities for embedding Perl in C/C++ applications
-
-=head1 SYNOPSIS
-
-
- perl -MExtUtils::Embed -e xsinit
- perl -MExtUtils::Embed -e ldopts
-
-=head1 DESCRIPTION
-
-ExtUtils::Embed provides utility functions for embedding a Perl interpreter
-and extensions in your C/C++ applications.
-Typically, an application B<Makefile> will invoke ExtUtils::Embed
-functions while building your application.
-
-=head1 @EXPORT
-
-ExtUtils::Embed exports the following functions:
-
-L<xsinit()>, L<ldopts()>, L<ccopts()>, L<perl_inc()>, L<ccflags()>,
-L<ccdlflags()>, L<xsi_header()>, L<xsi_protos()>, L<xsi_body()>
-
-=head1 FUNCTIONS
-
-=item xsinit()
-
-Generate C/C++ code for the XS intializer function.
-
-When invoked as C<`perl -MExtUtils::Embed -e xsinit --`>
-the following options are recognized:
-
-B<-o> <output filename> (Defaults to B<perlxsi.c>)
-
-B<-o STDOUT> will print to STDOUT.
-
-B<-std> (Write code for extensions that are linked with the current Perl.)
-
-Any additional arguments are expected to be names of modules
-to generate code for.
-
-When invoked with parameters the following are accepted and optional:
-
-C<xsinit($filename,$std,[@modules])>
-
-Where,
-
-B<$filename> is equivalent to the B<-o> option.
-
-B<$std> is boolean, equivalent to the B<-std> option.
-
-B<[@modules]> is an array ref, same as additional arguments mentioned above.
-
-=item Examples
-
-
- perl -MExtUtils::Embed -e xsinit -- -o xsinit.c Socket
-
-
-This will generate code with an B<xs_init> function that glues the perl B<Socket::bootstrap> function
-to the C B<boot_Socket> function and writes it to a file named "xsinit.c".
-
-Note that B<DynaLoader> is a special case where it must call B<boot_DynaLoader> directly.
-
- perl -MExtUtils::Embed -e xsinit
-
-
-This will generate code for linking with B<DynaLoader> and
-each static extension found in B<$Config{static_ext}>.
-The code is written to the default file name B<perlxsi.c>.
-
-
- perl -MExtUtils::Embed -e xsinit -- -o xsinit.c -std DBI DBD::Oracle
-
-
-Here, code is written for all the currently linked extensions along with code
-for B<DBI> and B<DBD::Oracle>.
-
-If you have a working B<DynaLoader> then there is rarely any need to statically link in any
-other extensions.
-
-=item ldopts()
-
-Output arguments for linking the Perl library and extensions to your
-application.
-
-When invoked as C<`perl -MExtUtils::Embed -e ldopts --`>
-the following options are recognized:
-
-B<-std>
-
-Output arguments for linking the Perl library and any extensions linked
-with the current Perl.
-
-B<-I> <path1:path2>
-
-Search path for ModuleName.a archives.
-Default path is B<@INC>.
-Library archives are expected to be found as
-B</some/path/auto/ModuleName/ModuleName.a>
-For example, when looking for B<Socket.a> relative to a search path,
-we should find B<auto/Socket/Socket.a>
-
-When looking for B<DBD::Oracle> relative to a search path,
-we should find B<auto/DBD/Oracle/Oracle.a>
-
-Keep in mind, you can always supply B</my/own/path/ModuleName.a>
-as an additional linker argument.
-
-B<--> <list of linker args>
-
-Additional linker arguments to be considered.
-
-Any additional arguments found before the B<--> token
-are expected to be names of modules to generate code for.
-
-When invoked with parameters the following are accepted and optional:
-
-C<ldopts($std,[@modules],[@link_args],$path)>
-
-Where,
-
-B<$std> is boolean, equivalent to the B<-std> option.
-
-B<[@modules]> is equivalent to additional arguments found before the B<--> token.
-
-B<[@link_args]> is equivalent to arguments found after the B<--> token.
-
-B<$path> is equivalent to the B<-I> option.
-
-In addition, when ldopts is called with parameters, it will return the argument string
-rather than print it to STDOUT.
-
-=item Examples
-
-
- perl -MExtUtils::Embed -e ldopts
-
-
-This will print arguments for linking with B<libperl.a>, B<DynaLoader> and
-extensions found in B<$Config{static_ext}>. This includes libraries
-found in B<$Config{libs}> and the first ModuleName.a library
-for each extension that is found by searching B<@INC> or the path
-specifed by the B<-I> option.
-In addition, when ModuleName.a is found, additional linker arguments
-are picked up from the B<extralibs.ld> file in the same directory.
-
-
- perl -MExtUtils::Embed -e ldopts -- -std Socket
-
-
-This will do the same as the above example, along with printing additional arguments for linking with the B<Socket> extension.
-
-
- perl -MExtUtils::Embed -e ldopts -- DynaLoader
-
-
-This will print arguments for linking with just the B<DynaLoader> extension
-and B<libperl.a>.
-
-
- perl -MExtUtils::Embed -e ldopts -- -std Msql -- -L/usr/msql/lib -lmsql
-
-
-Any arguments after the second '--' token are additional linker
-arguments that will be examined for potential conflict. If there is no
-conflict, the additional arguments will be part of the output.
-
-
-=item perl_inc()
-
-For including perl header files this function simply prints:
-
- -I $Config{archlib}/CORE
-
-So, rather than having to say:
-
- perl -MConfig -e 'print "-I $Config{archlib}/CORE"'
-
-Just say:
-
- perl -MExtUtils::Embed -e perl_inc
-
-=item ccflags(), ccdlflags()
-
-These functions simply print $Config{ccflags} and $Config{ccdlflags}
-
-=item ccopts()
-
-This function combines perl_inc(), ccflags() and ccdlflags() into one.
-
-=item xsi_header()
-
-This function simply returns a string defining the same B<EXTERN_C> macro as
-B<perlmain.c> along with #including B<perl.h> and B<EXTERN.h>.
-
-=item xsi_protos(@modules)
-
-This function returns a string of B<boot_$ModuleName> prototypes for each @modules.
-
-=item xsi_body(@modules)
-
-This function returns a string of calls to B<newXS()> that glue the module B<bootstrap>
-function to B<boot_ModuleName> for each @modules.
-
-B<xsinit()> uses the xsi_* functions to generate most of it's code.
-
-=head1 EXAMPLES
-
-For examples on how to use B<ExtUtils::Embed> for building C/C++ applications
-with embedded perl, see the eg/ directory and the I<perlembed> man page.
-
-=head1 SEE ALSO
-
-the I<perlembed> man page
-
-=head1 AUTHOR
-
-Doug MacEachern <dougm@osf.org>
-
-Based on ideas from Tim Bunce <Tim.Bunce@ig.co.uk> and
-B<minimod.pl> by Andreas Koenig <k@anna.in-berlin.de> and Tim Bunce.
-
-=cut
-
diff --git a/build/Makefile.in b/build/Makefile.in
deleted file mode 100644
index 54025e7d3b9d..000000000000
--- a/build/Makefile.in
+++ /dev/null
@@ -1,630 +0,0 @@
-# @(#)Makefile.in 8.75 (Berkeley) 10/23/96
-
-srcdir= @srcdir@/..
-CC= @CC@
-OPTFLAG=@OPTFLAG@
-CFLAGS= -c $(OPTFLAG) @CFLAGS@ -I. -I$(srcdir)/include @CPPFLAGS@
-LDFLAGS=@LDFLAGS@
-PERL= @vi_cv_path_perl@
-PERLLIB=@vi_cv_perllib@
-SHRPENV=@shrpenv@
-
-# Objects
-COBJS= addbytes.o addch.o box.o clear.o clrtobot.o clrtoeol.o \
- cr_put.o ctrace.o cur_hash.o curses.o delch.o deleteln.o delwin.o \
- erase.o fullname.o getch.o getstr.o id_subwins.o idlok.o initscr.o \
- insch.o insertln.o longname.o move.o mvwin.o newwin.o overlay.o \
- overwrite.o putchar.o refresh.o scroll.o setterm.o standout.o \
- toucholap.o touchwin.o tscroll.o tstp.o tty.o unctrl.o waddnstr.o
-CLOBJS= cl_bsd.o cl_funcs.o cl_main.o cl_read.o cl_screen.o cl_term.o
-DBOBJS= db.o mpool.o \
- bt_close.o bt_conv.o bt_debug.o bt_delete.o bt_get.o bt_open.o \
- bt_overflow.o bt_page.o bt_put.o bt_search.o bt_seq.o \
- bt_split.o bt_utils.o \
- rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o \
- rec_search.o rec_seq.o rec_utils.o
-REOBJS= regcomp.o regerror.o regexec.o regfree.o
-TKOBJS= tk_funcs.o tk_main.o tk_read.o tk_screen.o tk_term.o tk_util.o
-VIOBJS= cut.o delete.o ex.o ex_abbrev.o ex_append.o ex_args.o ex_argv.o \
- ex_at.o ex_bang.o ex_cd.o ex_cmd.o ex_cscope.o ex_delete.o \
- ex_display.o ex_edit.o ex_equal.o ex_file.o ex_filter.o \
- ex_global.o ex_init.o ex_join.o ex_map.o ex_mark.o ex_mkexrc.o \
- ex_move.o ex_open.o ex_perl.o ex_preserve.o ex_print.o ex_put.o \
- ex_quit.o ex_read.o ex_screen.o ex_script.o ex_set.o ex_shell.o \
- ex_shift.o ex_source.o ex_stop.o ex_subst.o ex_tag.o ex_tcl.o \
- ex_txt.o ex_undo.o ex_usage.o ex_util.o ex_version.o ex_visual.o \
- ex_write.o ex_yank.o ex_z.o exf.o getc.o key.o line.o log.o main.o \
- mark.o msg.o options.o options_f.o put.o recover.o screen.o \
- search.o seq.o util.o v_at.o v_ch.o v_cmd.o v_delete.o v_ex.o \
- v_increment.o v_init.o v_itxt.o v_left.o v_mark.o v_match.o \
- v_paragraph.o v_put.o v_redraw.o v_replace.o v_right.o v_screen.o \
- v_scroll.o v_search.o v_section.o v_sentence.o v_status.o v_txt.o \
- v_ulcase.o v_undo.o v_util.o v_word.o v_xchar.o v_yank.o v_z.o \
- v_zexit.o vi.o vs_line.o vs_msg.o vs_refresh.o vs_relative.o \
- vs_smap.o vs_split.o
-
-all: nvi @tknvi@
-
-NVIALL= $(CLOBJS) $(VIOBJS) @cobjs@ @LIBOBJS@
-nvi nex: $(NVIALL)
- $(SHRPENV) $(CC) $(LDFLAGS) -o $@ $(NVIALL) @LIBS@
- -rm -f nex
- ln $@ nex
-
-TKALL= $(TKOBJS) $(VIOBJS) @LIBOBJS@
-tknvi: $(TKALL)
- $(SHRPENV) $(CC) $(LDFLAGS) -o $@ $(TKALL) @TKLIBS@
-
-chmod= @vi_cv_path_chmod@
-cp= @vi_cv_path_cp@
-ln= @vi_cv_path_ln@
-mkdir= @vi_cv_path_mkdir@
-rm= @vi_cv_path_rm@
-strip= @vi_cv_path_strip@
-
-prefix= @prefix@
-bindir= @bindir@
-datadir=@datadir@
-mandir= @mandir@
-exec_prefix=@exec_prefix@
-
-dmode= 755
-emode= 555
-fmode= 444
-
-transform=@program_transform_name@
-
-install: all install_common
- @echo "Installing vi, ex, view: $(bindir) ..."
- [ -d $(bindir) ] || \
- ($(mkdir) $(bindir) && $(chmod) $(dmode) $(bindir))
- cd $(bindir) && $(rm) -f `echo vi | sed '$(transform)'`
- $(cp) nvi $(bindir)/`echo vi | sed '$(transform)'`
- cd $(bindir) && [ -f $(strip) ] && \
- $(strip) `echo vi | sed '$(transform)'`
- cd $(bindir) && $(chmod) $(emode) `echo vi | sed '$(transform)'`
- cd $(bindir) && $(rm) -f `echo ex | sed '$(transform)'`
- cd $(bindir) && $(rm) -f `echo view | sed '$(transform)'`
- cd $(bindir) && $(ln) \
- `echo vi | sed '$(transform)'` `echo ex | sed '$(transform)'`
- cd $(bindir) && $(ln) \
- `echo vi | sed '$(transform)'` `echo view | sed '$(transform)'`
- [ -d $(mandir) ] || \
- ($(mkdir) $(mandir) && $(chmod) $(dmode) $(mandir))
- [ -d $(mandir)/cat1 ] || \
- ($(mkdir) $(mandir)/cat1 && $(chmod) $(dmode) $(mandir)/cat1)
- @echo "Installing man pages: $(mandir) ..."
- cd $(mandir)/cat1 && $(rm) -f `echo vi.0 | sed '$(transform)'`
- $(cp) $(srcdir)/docs/USD.doc/vi.man/vi.0 \
- $(mandir)/cat1/`echo vi.0 | sed '$(transform)'`
- cd $(mandir)/cat1 && $(chmod) $(fmode) `echo vi.0 | sed '$(transform)'`
- cd $(mandir)/cat1 && $(rm) -f `echo ex.0 | sed '$(transform)'`
- cd $(mandir)/cat1 && $(rm) -f `echo view.0 | sed '$(transform)'`
- cd $(mandir)/cat1 && $(ln) \
- `echo vi.0 | sed '$(transform)'` `echo ex.0 | sed '$(transform)'`
- cd $(mandir)/cat1 && $(ln) \
- `echo vi.0 | sed '$(transform)'` `echo view.0 | sed '$(transform)'`
- [ -d $(mandir)/man1 ] || \
- ($(mkdir) $(mandir)/man1 && $(chmod) $(dmode) $(mandir)/man1)
- cd $(mandir)/man1 && $(rm) -f `echo vi.1 | sed '$(transform)'`
- $(cp) $(srcdir)/docs/USD.doc/vi.man/vi.1 \
- $(mandir)/man1/`echo vi.1 | sed '$(transform)'`
- cd $(mandir)/man1 && $(chmod) $(fmode) `echo vi.1 | sed '$(transform)'`
- cd $(mandir)/man1 && $(rm) -f `echo ex.1 | sed '$(transform)'`
- cd $(mandir)/man1 && $(rm) -f `echo view.1 | sed '$(transform)'`
- cd $(mandir)/man1 && $(ln) \
- `echo vi.1 | sed '$(transform)'` `echo ex.1 | sed '$(transform)'`
- cd $(mandir)/man1 && $(ln) \
- `echo vi.1 | sed '$(transform)'` `echo view.1 | sed '$(transform)'`
-
-cat= dutch english french german ru_SU.KOI8-R spanish swedish
-install_common:
- [ -f $(chmod) ]
- [ -f $(cp) ]
- [ -f $(ln) ]
- [ -f $(mkdir) ]
- [ -f $(rm) ]
- [ -d $(prefix) ] || \
- ($(mkdir) $(prefix) && $(chmod) $(dmode) $(prefix))
- [ -d $(exec_prefix) ] || \
- ($(mkdir) $(exec_prefix) && $(chmod) $(dmode) $(exec_prefix))
- [ -d $(datadir) ] || \
- ($(mkdir) $(datadir) && $(chmod) $(dmode) $(datadir))
- $(rm) -rf $(datadir)/vi
- $(mkdir) $(datadir)/vi && $(chmod) $(dmode) $(datadir)/vi
- @echo "Installing message catalogs: $(datadir)/vi/catalog ..."
- $(mkdir) $(datadir)/vi/catalog && \
- $(chmod) $(dmode) $(datadir)/vi/catalog
- (cd $(srcdir)/catalog && $(cp) $(cat) $(datadir)/vi/catalog && \
- cd $(datadir)/vi/catalog && $(chmod) $(fmode) *)
- @echo "Installing Perl scripts: $(datadir)/vi/perl ..."
- $(mkdir) $(datadir)/vi/perl && $(chmod) $(dmode) $(datadir)/vi/perl
- [ -f VI.pm ] && $(cp) VI.pm $(datadir)/vi/perl && \
- cd $(datadir)/vi/perl && $(chmod) $(fmode) VI.pm)
- (cd $(srcdir)/perl_scripts && $(cp) *.pl $(datadir)/vi/perl && \
- cd $(datadir)/vi/perl && $(chmod) $(fmode) *.pl)
- @echo "Installing Tcl scripts: $(datadir)/vi/tcl ..."
- $(mkdir) $(datadir)/vi/tcl && $(chmod) $(dmode) $(datadir)/vi/tcl
- (cd $(srcdir)/tcl_scripts && $(cp) *.tcl $(datadir)/vi/tcl && \
- cd $(datadir)/vi/tcl && $(chmod) $(fmode) *.tcl)
- @echo "Installing recover script: $(datadir)/vi/recover ..."
- ($(cp) recover $(datadir)/vi/recover && \
- $(chmod) $(emode) $(datadir)/vi/recover)
-
-uninstall:
- $(rm) -rf $(datadir)/vi
- cd $(bindir) && $(rm) -f `echo ex | sed '$(transform)'`
- cd $(bindir) && $(rm) -f `echo vi | sed '$(transform)'`
- cd $(bindir) && $(rm) -f `echo view | sed '$(transform)'`
- cd $(mandir)/cat1 && $(rm) -f `echo ex.0 | sed '$(transform)'`
- cd $(mandir)/cat1 && $(rm) -f `echo vi.0 | sed '$(transform)'`
- cd $(mandir)/cat1 && $(rm) -f `echo view.0 | sed '$(transform)'`
- cd $(mandir)/man1 && $(rm) -f `echo ex.1 | sed '$(transform)'`
- cd $(mandir)/man1 && $(rm) -f `echo vi.1 | sed '$(transform)'`
- cd $(mandir)/man1 && $(rm) -f `echo view.1 | sed '$(transform)'`
-
-docs:
- cd $(srcdir)/docs/USD.doc/vi.ref && $(MAKE)
- cd $(srcdir)/docs/USD.doc/vi.man && $(MAKE)
- cd $(srcdir)/docs/USD.doc/edit && $(MAKE)
- cd $(srcdir)/docs/USD.doc/exref && $(MAKE)
- cd $(srcdir)/docs/USD.doc/vitut && $(MAKE)
-
-clean:
- -rm -f *.core *.o memcpy.c perl.c
- -rm -f nex nvi tknvi core
- -rm -f $(COBJS) $(CLOBJS) $(DBOBJS) $(REOBJS)
- -rm -f $(TKOBJS) $(VIOBJS)
-
-cleandocs:
- cd $(srcdir)/docs/USD.doc/vi.ref && $(MAKE) clean
- cd $(srcdir)/docs/USD.doc/vi.man && $(MAKE) clean
- cd $(srcdir)/docs/USD.doc/edit && $(MAKE) clean
- cd $(srcdir)/docs/USD.doc/exref && $(MAKE) clean
- cd $(srcdir)/docs/USD.doc/vitut && $(MAKE) clean
-
-distclean maintainer-clean realclean: clean cleandocs
- -rm -f Makefile config.cache config.h config.log config.status
- -rm -f pathnames.h port.h
-
-# Vi curses sources.
-cl_bsd.o: $(srcdir)/cl/cl_bsd.c
- $(CC) $(CFLAGS) $?
-cl_funcs.o: $(srcdir)/cl/cl_funcs.c
- $(CC) $(CFLAGS) $?
-cl_main.o: $(srcdir)/cl/cl_main.c
- $(CC) $(CFLAGS) $?
-cl_read.o: $(srcdir)/cl/cl_read.c
- $(CC) $(CFLAGS) $?
-cl_screen.o: $(srcdir)/cl/cl_screen.c
- $(CC) $(CFLAGS) $?
-cl_term.o: $(srcdir)/cl/cl_term.c
- $(CC) $(CFLAGS) $?
-
-# Vi Tk sources.
-tk_funcs.o: $(srcdir)/tk/tk_funcs.c
- $(CC) $(CFLAGS) @XINCS@ $?
-tk_main.o: $(srcdir)/tk/tk_main.c
- $(CC) $(CFLAGS) @XINCS@ $?
-tk_read.o: $(srcdir)/tk/tk_read.c
- $(CC) $(CFLAGS) @XINCS@ $?
-tk_screen.o: $(srcdir)/tk/tk_screen.c
- $(CC) $(CFLAGS) @XINCS@ $?
-tk_term.o: $(srcdir)/tk/tk_term.c
- $(CC) $(CFLAGS) @XINCS@ $?
-tk_util.o: $(srcdir)/tk/tk_util.c
- $(CC) $(CFLAGS) @XINCS@ $?
-
-# Vi Tcl/Perl interpreter sources.
-api.o: $(srcdir)/common/api.c
- $(CC) $(CFLAGS) $?
-perl.c: $(srcdir)/perl_api/perl.xs $(srcdir)/perl_api/typemap
- echo "#define _PATH_PERLSCRIPTS \"$(datadir)/vi/perl\"" > $@
- $(PERL) $(PERLLIB)/ExtUtils/xsubpp -typemap \
- $(PERLLIB)/ExtUtils/typemap $(srcdir)/perl_api/perl.xs >> $@
- ($(PERL) -ne 'print "sub $$1 {\$$curscr->$$1(\@_)}\n" \
- if /newXS\("VI::([^":]*)"/;' $@ ; echo "1;") > VI.pm
-perl.o: perl.c
- $(CC) $(CFLAGS) $?
-perlsfio.o: $(srcdir)/perl_api/perlsfio.c
- $(CC) $(CFLAGS) $?
-tcl.o: $(srcdir)/tcl_api/tcl.c
- $(CC) $(CFLAGS) $?
-
-# Vi sources.
-cut.o: $(srcdir)/common/cut.c
- $(CC) $(CFLAGS) $?
-delete.o: $(srcdir)/common/delete.c
- $(CC) $(CFLAGS) $?
-exf.o: $(srcdir)/common/exf.c
- $(CC) $(CFLAGS) $?
-key.o: $(srcdir)/common/key.c
- $(CC) $(CFLAGS) $?
-line.o: $(srcdir)/common/line.c
- $(CC) $(CFLAGS) $?
-log.o: $(srcdir)/common/log.c
- $(CC) $(CFLAGS) $?
-main.o: $(srcdir)/common/main.c
- $(CC) $(CFLAGS) $?
-mark.o: $(srcdir)/common/mark.c
- $(CC) $(CFLAGS) $?
-msg.o: $(srcdir)/common/msg.c
- $(CC) $(CFLAGS) $?
-options.o: $(srcdir)/common/options.c
- $(CC) $(CFLAGS) $?
-options_f.o: $(srcdir)/common/options_f.c
- $(CC) $(CFLAGS) $?
-put.o: $(srcdir)/common/put.c
- $(CC) $(CFLAGS) $?
-screen.o: $(srcdir)/common/screen.c
- $(CC) $(CFLAGS) $?
-search.o: $(srcdir)/common/search.c
- $(CC) $(CFLAGS) $?
-seq.o: $(srcdir)/common/seq.c
- $(CC) $(CFLAGS) $?
-recover.o: $(srcdir)/common/recover.c
- $(CC) $(CFLAGS) $?
-util.o: $(srcdir)/common/util.c
- $(CC) $(CFLAGS) $?
-ex.o: $(srcdir)/ex/ex.c
- $(CC) $(CFLAGS) $?
-ex_abbrev.o: $(srcdir)/ex/ex_abbrev.c
- $(CC) $(CFLAGS) $?
-ex_append.o: $(srcdir)/ex/ex_append.c
- $(CC) $(CFLAGS) $?
-ex_args.o: $(srcdir)/ex/ex_args.c
- $(CC) $(CFLAGS) $?
-ex_argv.o: $(srcdir)/ex/ex_argv.c
- $(CC) $(CFLAGS) $?
-ex_at.o: $(srcdir)/ex/ex_at.c
- $(CC) $(CFLAGS) $?
-ex_bang.o: $(srcdir)/ex/ex_bang.c
- $(CC) $(CFLAGS) $?
-ex_cd.o: $(srcdir)/ex/ex_cd.c
- $(CC) $(CFLAGS) $?
-ex_cmd.o: $(srcdir)/ex/ex_cmd.c
- $(CC) $(CFLAGS) $?
-ex_cscope.o: $(srcdir)/ex/ex_cscope.c
- $(CC) $(CFLAGS) $?
-ex_delete.o: $(srcdir)/ex/ex_delete.c
- $(CC) $(CFLAGS) $?
-ex_digraph.o: $(srcdir)/ex/ex_digraph.c
- $(CC) $(CFLAGS) $?
-ex_display.o: $(srcdir)/ex/ex_display.c
- $(CC) $(CFLAGS) $?
-ex_edit.o: $(srcdir)/ex/ex_edit.c
- $(CC) $(CFLAGS) $?
-ex_equal.o: $(srcdir)/ex/ex_equal.c
- $(CC) $(CFLAGS) $?
-ex_file.o: $(srcdir)/ex/ex_file.c
- $(CC) $(CFLAGS) $?
-ex_filter.o: $(srcdir)/ex/ex_filter.c
- $(CC) $(CFLAGS) $?
-ex_global.o: $(srcdir)/ex/ex_global.c
- $(CC) $(CFLAGS) $?
-ex_init.o: $(srcdir)/ex/ex_init.c
- $(CC) $(CFLAGS) $?
-ex_join.o: $(srcdir)/ex/ex_join.c
- $(CC) $(CFLAGS) $?
-ex_map.o: $(srcdir)/ex/ex_map.c
- $(CC) $(CFLAGS) $?
-ex_mark.o: $(srcdir)/ex/ex_mark.c
- $(CC) $(CFLAGS) $?
-ex_mkexrc.o: $(srcdir)/ex/ex_mkexrc.c
- $(CC) $(CFLAGS) $?
-ex_move.o: $(srcdir)/ex/ex_move.c
- $(CC) $(CFLAGS) $?
-ex_open.o: $(srcdir)/ex/ex_open.c
- $(CC) $(CFLAGS) $?
-ex_perl.o: $(srcdir)/ex/ex_perl.c
- $(CC) $(CFLAGS) $?
-ex_preserve.o: $(srcdir)/ex/ex_preserve.c
- $(CC) $(CFLAGS) $?
-ex_print.o: $(srcdir)/ex/ex_print.c
- $(CC) $(CFLAGS) $?
-ex_put.o: $(srcdir)/ex/ex_put.c
- $(CC) $(CFLAGS) $?
-ex_quit.o: $(srcdir)/ex/ex_quit.c
- $(CC) $(CFLAGS) $?
-ex_read.o: $(srcdir)/ex/ex_read.c
- $(CC) $(CFLAGS) $?
-ex_screen.o: $(srcdir)/ex/ex_screen.c
- $(CC) $(CFLAGS) $?
-ex_script.o: $(srcdir)/ex/ex_script.c
- $(CC) $(CFLAGS) $?
-ex_set.o: $(srcdir)/ex/ex_set.c
- $(CC) $(CFLAGS) $?
-ex_shell.o: $(srcdir)/ex/ex_shell.c
- $(CC) $(CFLAGS) $?
-ex_shift.o: $(srcdir)/ex/ex_shift.c
- $(CC) $(CFLAGS) $?
-ex_source.o: $(srcdir)/ex/ex_source.c
- $(CC) $(CFLAGS) $?
-ex_stop.o: $(srcdir)/ex/ex_stop.c
- $(CC) $(CFLAGS) $?
-ex_subst.o: $(srcdir)/ex/ex_subst.c
- $(CC) $(CFLAGS) $?
-ex_tag.o: $(srcdir)/ex/ex_tag.c
- $(CC) $(CFLAGS) $?
-ex_tcl.o: $(srcdir)/ex/ex_tcl.c
- $(CC) $(CFLAGS) $?
-ex_txt.o: $(srcdir)/ex/ex_txt.c
- $(CC) $(CFLAGS) $?
-ex_undo.o: $(srcdir)/ex/ex_undo.c
- $(CC) $(CFLAGS) $?
-ex_usage.o: $(srcdir)/ex/ex_usage.c
- $(CC) $(CFLAGS) $?
-ex_util.o: $(srcdir)/ex/ex_util.c
- $(CC) $(CFLAGS) $?
-ex_version.o: $(srcdir)/ex/ex_version.c
- $(CC) $(CFLAGS) $?
-ex_visual.o: $(srcdir)/ex/ex_visual.c
- $(CC) $(CFLAGS) $?
-ex_write.o: $(srcdir)/ex/ex_write.c
- $(CC) $(CFLAGS) $?
-ex_yank.o: $(srcdir)/ex/ex_yank.c
- $(CC) $(CFLAGS) $?
-ex_z.o: $(srcdir)/ex/ex_z.c
- $(CC) $(CFLAGS) $?
-getc.o: $(srcdir)/vi/getc.c
- $(CC) $(CFLAGS) $?
-v_at.o: $(srcdir)/vi/v_at.c
- $(CC) $(CFLAGS) $?
-v_ch.o: $(srcdir)/vi/v_ch.c
- $(CC) $(CFLAGS) $?
-v_cmd.o: $(srcdir)/vi/v_cmd.c
- $(CC) $(CFLAGS) $?
-v_delete.o: $(srcdir)/vi/v_delete.c
- $(CC) $(CFLAGS) $?
-v_ex.o: $(srcdir)/vi/v_ex.c
- $(CC) $(CFLAGS) $?
-v_increment.o: $(srcdir)/vi/v_increment.c
- $(CC) $(CFLAGS) $?
-v_init.o: $(srcdir)/vi/v_init.c
- $(CC) $(CFLAGS) $?
-v_itxt.o: $(srcdir)/vi/v_itxt.c
- $(CC) $(CFLAGS) $?
-v_left.o: $(srcdir)/vi/v_left.c
- $(CC) $(CFLAGS) $?
-v_mark.o: $(srcdir)/vi/v_mark.c
- $(CC) $(CFLAGS) $?
-v_match.o: $(srcdir)/vi/v_match.c
- $(CC) $(CFLAGS) $?
-v_paragraph.o: $(srcdir)/vi/v_paragraph.c
- $(CC) $(CFLAGS) $?
-v_put.o: $(srcdir)/vi/v_put.c
- $(CC) $(CFLAGS) $?
-v_redraw.o: $(srcdir)/vi/v_redraw.c
- $(CC) $(CFLAGS) $?
-v_replace.o: $(srcdir)/vi/v_replace.c
- $(CC) $(CFLAGS) $?
-v_right.o: $(srcdir)/vi/v_right.c
- $(CC) $(CFLAGS) $?
-v_screen.o: $(srcdir)/vi/v_screen.c
- $(CC) $(CFLAGS) $?
-v_scroll.o: $(srcdir)/vi/v_scroll.c
- $(CC) $(CFLAGS) $?
-v_search.o: $(srcdir)/vi/v_search.c
- $(CC) $(CFLAGS) $?
-v_section.o: $(srcdir)/vi/v_section.c
- $(CC) $(CFLAGS) $?
-v_sentence.o: $(srcdir)/vi/v_sentence.c
- $(CC) $(CFLAGS) $?
-v_status.o: $(srcdir)/vi/v_status.c
- $(CC) $(CFLAGS) $?
-v_txt.o: $(srcdir)/vi/v_txt.c
- $(CC) -c @no_op_OPTFLAG@ @CFLAGS@ -I. -I$(srcdir)/include @CPPFLAGS@ $?
-v_ulcase.o: $(srcdir)/vi/v_ulcase.c
- $(CC) $(CFLAGS) $?
-v_undo.o: $(srcdir)/vi/v_undo.c
- $(CC) $(CFLAGS) $?
-v_util.o: $(srcdir)/vi/v_util.c
- $(CC) $(CFLAGS) $?
-v_word.o: $(srcdir)/vi/v_word.c
- $(CC) $(CFLAGS) $?
-v_xchar.o: $(srcdir)/vi/v_xchar.c
- $(CC) $(CFLAGS) $?
-v_yank.o: $(srcdir)/vi/v_yank.c
- $(CC) $(CFLAGS) $?
-v_z.o: $(srcdir)/vi/v_z.c
- $(CC) $(CFLAGS) $?
-v_zexit.o: $(srcdir)/vi/v_zexit.c
- $(CC) $(CFLAGS) $?
-vi.o: $(srcdir)/vi/vi.c
- $(CC) $(CFLAGS) $?
-vs_line.o: $(srcdir)/vi/vs_line.c
- $(CC) $(CFLAGS) $?
-vs_msg.o: $(srcdir)/vi/vs_msg.c
- $(CC) $(CFLAGS) $?
-vs_refresh.o: $(srcdir)/vi/vs_refresh.c
- $(CC) $(CFLAGS) $?
-vs_relative.o: $(srcdir)/vi/vs_relative.c
- $(CC) $(CFLAGS) $?
-vs_smap.o: $(srcdir)/vi/vs_smap.c
- $(CC) $(CFLAGS) $?
-vs_split.o: $(srcdir)/vi/vs_split.c
- $(CC) $(CFLAGS) $?
-
-addbytes.o: $(srcdir)/curses/addbytes.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-addch.o: $(srcdir)/curses/addch.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-box.o: $(srcdir)/curses/box.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-clear.o: $(srcdir)/curses/clear.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-clrtobot.o: $(srcdir)/curses/clrtobot.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-clrtoeol.o: $(srcdir)/curses/clrtoeol.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-cr_put.o: $(srcdir)/curses/cr_put.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-ctrace.o: $(srcdir)/curses/ctrace.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-cur_hash.o: $(srcdir)/curses/cur_hash.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-curses.o: $(srcdir)/curses/curses.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-delch.o: $(srcdir)/curses/delch.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-deleteln.o: $(srcdir)/curses/deleteln.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-delwin.o: $(srcdir)/curses/delwin.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-erase.o: $(srcdir)/curses/erase.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-fullname.o: $(srcdir)/curses/fullname.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-getch.o: $(srcdir)/curses/getch.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-getstr.o: $(srcdir)/curses/getstr.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-id_subwins.o: $(srcdir)/curses/id_subwins.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-idlok.o: $(srcdir)/curses/idlok.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-initscr.o: $(srcdir)/curses/initscr.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-insch.o: $(srcdir)/curses/insch.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-insertln.o: $(srcdir)/curses/insertln.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-longname.o: $(srcdir)/curses/longname.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-move.o: $(srcdir)/curses/move.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-mvwin.o: $(srcdir)/curses/mvwin.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-newwin.o: $(srcdir)/curses/newwin.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-overlay.o: $(srcdir)/curses/overlay.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-overwrite.o: $(srcdir)/curses/overwrite.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-putchar.o: $(srcdir)/curses/putchar.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-refresh.o: $(srcdir)/curses/refresh.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-scroll.o: $(srcdir)/curses/scroll.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-setterm.o: $(srcdir)/curses/setterm.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-standout.o: $(srcdir)/curses/standout.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-toucholap.o: $(srcdir)/curses/toucholap.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-touchwin.o: $(srcdir)/curses/touchwin.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-tscroll.o: $(srcdir)/curses/tscroll.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-tstp.o: $(srcdir)/curses/tstp.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-tty.o: $(srcdir)/curses/tty.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-unctrl.o: $(srcdir)/curses/unctrl.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-waddnstr.o: $(srcdir)/curses/waddnstr.c
- $(CC) -D_CURSES_PRIVATE $(CFLAGS) $?
-
-# DB sources.
-db.o: $(srcdir)/db/db/db.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) $?
-mpool.o: $(srcdir)/db/mpool/mpool.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/mpool $?
-bt_close.o: $(srcdir)/db/btree/bt_close.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_conv.o: $(srcdir)/db/btree/bt_conv.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_debug.o: $(srcdir)/db/btree/bt_debug.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_delete.o: $(srcdir)/db/btree/bt_delete.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_get.o: $(srcdir)/db/btree/bt_get.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_open.o: $(srcdir)/db/btree/bt_open.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_overflow.o: $(srcdir)/db/btree/bt_overflow.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_page.o: $(srcdir)/db/btree/bt_page.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_put.o: $(srcdir)/db/btree/bt_put.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_search.o: $(srcdir)/db/btree/bt_search.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_seq.o: $(srcdir)/db/btree/bt_seq.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_split.o: $(srcdir)/db/btree/bt_split.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-bt_utils.o: $(srcdir)/db/btree/bt_utils.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/btree $?
-rec_close.o: $(srcdir)/db/recno/rec_close.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-rec_delete.o: $(srcdir)/db/recno/rec_delete.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-rec_get.o: $(srcdir)/db/recno/rec_get.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-rec_open.o: $(srcdir)/db/recno/rec_open.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-rec_put.o: $(srcdir)/db/recno/rec_put.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-rec_search.o: $(srcdir)/db/recno/rec_search.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-rec_seq.o: $(srcdir)/db/recno/rec_seq.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-rec_utils.o: $(srcdir)/db/recno/rec_utils.c
- $(CC) -D__DBINTERFACE_PRIVATE $(CFLAGS) -I$(srcdir)/db/recno $?
-
-# Regular Expressions sources.
-regcomp.o: $(srcdir)/regex/regcomp.c
- $(CC) -D__REGEX_PRIVATE $(CFLAGS) $?
-regerror.o: $(srcdir)/regex/regerror.c
- $(CC) -D__REGEX_PRIVATE $(CFLAGS) $?
-regexec.o: $(srcdir)/regex/regexec.c
- $(CC) -D__REGEX_PRIVATE $(CFLAGS) $?
-regfree.o: $(srcdir)/regex/regfree.c
- $(CC) -D__REGEX_PRIVATE $(CFLAGS) $?
-
-# Random replacement and workaround sources.
-addnstr.o: $(srcdir)/clib/addnstr.c
- $(CC) $(CFLAGS) $?
-bsearch.o: $(srcdir)/clib/bsearch.c
- $(CC) $(CFLAGS) $?
-env.o: $(srcdir)/clib/env.c
- $(CC) $(CFLAGS) $?
-fchmod.o: $(srcdir)/clib/fchmod.c
- $(CC) $(CFLAGS) $(INC) $?
-gethostname.o: $(srcdir)/clib/gethostname.c
- $(CC) $(CFLAGS) $(INC) $?
-getopt.o: $(srcdir)/clib/getopt.c
- $(CC) $(CFLAGS) $(INC) $?
-memchr.o: $(srcdir)/clib/memchr.c
- $(CC) $(CFLAGS) $?
-memcpy.o: $(srcdir)/clib/memmove.c
- $(cp) $? memcpy.c
- $(CC) $(CFLAGS) -DMEMCOPY memcpy.c
-memmove.o: $(srcdir)/clib/memmove.c
- $(CC) $(CFLAGS) -DMEMMOVE $?
-memset.o: $(srcdir)/clib/memset.c
- $(CC) $(CFLAGS) $?
-mkstemp.o: $(srcdir)/clib/mkstemp.c
- $(CC) $(CFLAGS) $?
-mmap.o: $(srcdir)/clib/mmap.c
- $(CC) $(CFLAGS) $?
-realloc.o: $(srcdir)/clib/realloc.c
- $(CC) $(CFLAGS) $?
-snprintf.o: $(srcdir)/clib/snprintf.c
- $(CC) $(CFLAGS) $?
-strdup.o: $(srcdir)/clib/strdup.c
- $(CC) $(CFLAGS) $?
-strerror.o: $(srcdir)/clib/strerror.c
- $(CC) $(CFLAGS) $?
-strpbrk.o: $(srcdir)/clib/strpbrk.c
- $(CC) $(CFLAGS) $?
-strsep.o: $(srcdir)/clib/strsep.c
- $(CC) $(CFLAGS) $?
-strtol.o: $(srcdir)/clib/strtol.c
- $(CC) $(CFLAGS) $?
-strtoul.o: $(srcdir)/clib/strtoul.c
- $(CC) $(CFLAGS) $?
-vsnprintf.o: $(srcdir)/clib/vsnprintf.c
- $(CC) $(CFLAGS) $?
diff --git a/build/README b/build/README
deleted file mode 100644
index efbce2b9dfbb..000000000000
--- a/build/README
+++ /dev/null
@@ -1,369 +0,0 @@
-# @(#)README 8.26 (Berkeley) 10/19/96
-
-Nvi uses the GNU autoconf program for configuration and compilation. You
-should enter:
-
- configure
- make
-
-and nvi will configure the system and build one or two binaries: nvi and
-tknvi. You can use any path to the configure script, e.g., to build for
-an x86 architecture, I suggest that you do:
-
- mkdir build.x86
- cd build.x86
- ../build/configure
- make
-
-There are options that you can specify to the configure command. See
-the next section for a description of these options.
-
-If you want to rebuild or reconfigure nvi, for example, because you change
-your mind as to the curses library that you want to use, create a new
-directory and reconfigure it using "configure" and whatever options you
-choose, don't try to selectively edit the files.
-
-By default, nvi is installed as "vi", with hard links to "ex" and "view".
-To install them using different names, use the configure program options.
-For example, to install them as "nvi", "nex" and "nview", use:
-
- configure --program-prefix=n
-
-See the section below on installation for details.
-
-Note, if you're building nvi on a LynxOS system, you should read the
-README.LynxOS file in this directory for additional build instructions
-that are specific to that operating system.
-
-If you have trouble with this procedure, send email to the addresses
-listed in ../README. In that email, please provide a complete script
-of the output for all of the above commands that you entered.
-
-=-=-=-=-=-=-=
-NVI'S OPTIONS TO THE CONFIGURE PROGRAM
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-There are many options that you can enter to the configuration program.
-To see a complete list of the options, enter "configure --help". Only
-a few of them are nvi specific. These options are as follows:
-
- --disable-curses DON'T use the nvi-provided curses routines.
- --disable-db DON'T use the nvi-provided DB routines.
- --disable-re DON'T use the nvi-provided RE routines.
- --enable-debug Build a debugging version.
- --enable-perlinterp Include a Perl interpreter in vi.
- --enable-tclinterp Include a Tk/Tcl interpreter in vi.
- --enable-tknvi Build a Tk/Tcl front-end for vi.
-
-disable-curses:
- By default, nvi loads its own implementation of the curses
- routines (which are a stripped-down version of the 4.4BSD curses
- library). If you have your own curses library implementation and
- you want to use it instead, enter:
-
- --disable-curses
-
- as an argument to configure, and the curses routines will be taken
- from whatever libraries you load. Note: System V based curses
- implementations are usually broken. See the last section of this
- README for further information about nvi and the curses library.
-
-disable-db:
- By default, nvi loads its own versions of the Berkeley DB routines
- (which are a stripped-down version of DB 1.85). If you have your
- own version of the Berkeley DB routines and you want to use them
- instead, enter:
-
- --disable-db
-
- as an argument to configure, and the DB routines will be taken
- from whatever libraries you load. Make sure that the DB routines
- you use are at least version 1.85 or later.
-
-disable-re:
- By default, nvi loads its own versions of the POSIX 1003.2 Regular
- Expression routines (which are Henry Spencer's implementation).
- If your C library contains an implementation of the POSIX 1003.2
- RE routines (note, this is NOT the same as the historic UNIX RE
- routines), and you want to use them instead, enter:
-
- --disable-re
-
- as an argument to configure, and the RE routines will be taken
- from whatever libraries you load. Please ensure that your RE
- routines implement Henry Spencer's extensions for doing vi-style
- "word" searches.
-
-enable-debug:
- If you want to build nvi with no optimization (i.e. without -O
- as a compiler flag), with -g as a compiler flag, and with DEBUG
- defined during compilation, enter:
-
- --enable-debug
-
- as an argument to configure.
-
-enable-perlinterp:
- If you have the Perl 5 libraries and you want to compile in the
- Perl interpreter, enter:
-
- --enable-perlinterp
-
- as an argument to configure. (Note: this is NOT possible with
- Perl 4, or even with Perl 5 versions earlier than 5.002.)
-
-enable-tclinterp:
- If you have the Tk/Tcl libraries and you want to compile in the
- Tcl/Tk interpreter, enter:
-
- --enable-tclinterp
-
- as an argument to configure. If your Tk/Tcl include files and
- libraries aren't in the standard library and include locations,
- see the next section of this README file for more information.
-
-enable-tknvi:
- If you have the Tk/Tcl libraries and you want to build the Tcl/Tk
- nvi front-end, enter:
-
- --enable-tknvi
-
- as an argument to configure. If your Tk/Tcl include files and
- libraries aren't in the standard library and include locations,
- see the next section of this README file for more information.
-
-=-=-=-=-=-=-=
-ADDING OR CHANGING COMPILERS, OR COMPILE OR LOAD LINE FLAGS
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-If you want to use a specific compiler, specify the CC environment
-variable before running configure. For example:
-
- env CC=gcc configure
-
-Using anything other than the native compiler will almost certainly
-mean that you'll want to check the compile and load line flags, too.
-
-If you want to specify additional load line flags, specify the ADDLDFLAGS
-environment variable before running configure. For example:
-
- env ADDLDFLAGS="-Q" configure
-
-would specify the -Q flag in the load line when the nvi programs are
-loaded.
-
-If you don't want configure to use the default load line flags for the
-system, specify the LDFLAGS environment variable before running configure.
-For example:
-
- env LDFLAGS="-32" configure
-
-will cause configure to set the load line flags to "-32", and not set
-them based on the current system.
-
-If you want to specify additional compile line flags, specify the
-ADDCPPFLAGS environment variable before running configure. For example:
-
- env ADDCPPFLAGS="-I../foo" configure
-
-would cause the compiler to be passed the -I../foo flag when compiling
-test programs during configuration as well as when building nvi object
-files.
-
-If you don't want configure to use the default compile line flags for the
-system, specify the CPPFLAGS environment variable before running configure.
-For example:
-
- env CPPFLAGS="-I.." configure
-
-will cause configure to use "-I.." as the compile line flags instead of
-the default values.
-
-=-=-=-=-=-=-=
-ADDING LIBRARIES AND INCLUDE FILES
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-If the Tk/Tcl or any other include files or libraries are in non-standard
-places on your system, you will need to specify the directory path where
-they can be found.
-
-If you want to specify additional library paths, set the ADDLIBS environment
-variable before running configure. For example:
-
- env ADDLIBS="-L/a/b -L/e/f -ldb" configure
-
-would specify two additional directories to search for libraries, /a/b
-and /e/f, and one additional library to load, "db".
-
-If you want to specify additional include paths, specify the ADDCPPFLAGS
-environment variable before running configure. For example:
-
- env ADDCPPFLAGS="-I/usr/local/include" LIBS="-ldb" configure
-
-would search /usr/local/include for include files, as well as load the db
-library as described above.
-
-As a final example, let's say that you've downloaded ncurses from the net
-and you've built it in a directory named ncurses which is at the same
-level in the filesystem hierarchy as nvi. You would enter something like:
-
- env ADDCPPFLAGS="-I../../ncurses/include" \
- ADDLIBS="-L../../ncurses/libraries" configure
-
-to cause nvi to look for the curses include files and the curses library
-in the ncurses environment.
-
-Notes:
- Make sure that you prepend -L to any library directory names, and
- that you prepend -I to any include file directory names! Also,
- make sure that you quote the paths as shown above, i.e. with
- single or double quotes around the values you're specifying for
- ADDCPPFLAGS and ADDLIBS.
-
- =-=-=-=-=-=
- You should NOT need to add any libraries or include files to load
- the Perl5 interpreter. The configure script will obtain that
- information directly from the Perl5 program. This means that the
- configure script must be able to find perl in its path. It looks
- for "perl5" first, and then "perl". If you're building a Perl
- interpreter and neither is found, it's a fatal error.
-
- =-=-=-=-=-=
- You do not need to specify additional libraries to load Tk/Tcl,
- Perl or curses, as the nvi configuration script adds the
- appropriate libraries to the load line whenever you specify
- --enable-tknvi or other Perl or Tk/Tcl related option, or build
- the Tk/Tcl or curses version of nvi. The library names that are
- automatically loaded are as follows:
-
- for Perl: -lperl
- for Tk/Tcl: -ltk -ltcl -lm
- for curses: -lcurses
-
- In addition, the configure script loads:
-
- ... the X libraries when loading the Tk/Tcl libraries,
- if they exist.
-
- ... the -ltermcap or -ltermlib libraries when loading
- any curses library, if they exist.
-
- =-=-=-=-=-=
- The env command is available on most systems, and simply sets one
- or more environment variables before running a command. If the
- env command is not available to you, you can set the environment
- variables in your shell before running configure. For example,
- in sh or ksh, you could do:
-
- ADDLIBS="-L/a/b -L/e/f -ldb" configure
-
- and in csh or tcsh, you could do:
-
- setenv ADDLIBS "-L/a/b -L/e/f -ldb"
- configure
-
- See your shell manual page for further information.
-
-=-=-=-=-=-=-=
-INSTALLING NVI
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-Nvi installs the following files into the following locations, with
-the following default values:
-
-Variables: Default value:
-prefix /usr/local
-exec_prefix $(prefix)
-bindir $(prefix)/bin
-datadir $(prefix)/share
-mandir $(prefix)/man
-
-File(s): Default location
-----------------------------------------
-vi $(bindir)/vi
-vi.1 $(mandir)/man1/vi.1
-vi.0 $(mandir)/cat1/vi.0
-Perl scripts $(datadir)/vi/perl/
-Tcl scripts $(datadir)/vi/tcl/
-Message Catalogs $(datadir)/vi/catalog/
-
-Notes:
- There are two hard links to the vi program, named ex and view.
- Similarly, there are two hard links to the unformatted vi manual
- page, named ex.1 and view.1, and two hard links to the formatted
- manual page, named ex.0 and view.0. These links are created when
- the program and man pages are installed.
-
- If you want to install vi, ex, view and the man pages as nvi, nex,
- nview, use the configure option --program-prefix=n. Other, more
- complex transformations are possible -- use configure --help to
- see more options.
-
- To move the entire installation tree somewhere besides /usr/local,
- change the value of both "exec_prefix" and "prefix". To move the
- binaries to a different place, change the value of "bindir".
- Similarly, to put the datafiles (the message catalogs, Perl and
- Tcl scripts) or the man pages in a different place, change the
- value of "datadir" or "mandir". These values can be changed as
- part of configuration:
-
- configure --exec_prefix=/usr/contrib --prefix=/usr/share
-
- or when doing the install itself:
-
- make exec_prefix=/usr/contrib prefix=/usr/contrib install
-
- The datafile directory (e.g., /usr/local/share/vi by default) is
- completely removed and then recreated as part of the installation
- process.
-
-=-=-=-=-=-=-=
-NVI AND THE CURSES LIBRARY
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-The major portability problem for nvi is selecting a curses library.
-Unfortunately, it is common to find broken versions of curses -- the
-original System V curses was broken, resulting in all vendors whose
-implementations are derived from System V having broken implementations
-in turn.
-
-For this reason, BY DEFAULT, nvi uses the stripped-down curses library
-that's included in its distribution. Of course, it would be preferable
-to use the vendor's curses library, or one of the newer implementations
-of curses, e.g., ncurses.
-
-To use the vendor's curses library, specify the:
-
- --disable-curses
-
-argument to the configure command. If you use the vendor's or other
-curses library, and you see any of the following symptoms:
-
- + Core dumps in curses routines.
- + Missing routines when compiling.
- + Repainting the wrong characters on the screen.
- + Displaying inverse video in the wrong places.
- + Failure to reset your terminal to the correct modes on exit.
-
-you have a broken curses implementation, and you should reconfigure nvi
-to use another curses library or the curses library provided with nvi.
-
-There are two alternative sources for curses libraries:
-
-#1: Compile the 4BSD curses library from any of the recent BSD
- releases: FreeBSD, NetBSD or 4.4BSD-Lite release 2. These
- libraries should be able to support nvi.
-
-#2: Retrieve and build the ncurses library. This library is not
- recommended unreservedly, at least for now, for two reasons.
- First, it can't be built on any system where the compiler
- doesn't support function prototypes. Second, it currently has
- a few bugs in its support for nvi. It mostly works, but it's
- still not quite right.
-
-One final note. If you see the following symptoms:
-
- + Line-by-line screen repainting instead of scrolling.
-
-it usually means that your termcap or terminfo information is insufficient
-for the terminal.
diff --git a/build/README.LynxOS b/build/README.LynxOS
deleted file mode 100644
index 2cc68dafc861..000000000000
--- a/build/README.LynxOS
+++ /dev/null
@@ -1,320 +0,0 @@
-README.LynxOS
-=============
-
-Written by Ronald F. Guilmette <rfg@monkeys.com>
-
-Last modified Wed Aug 14 23:10:07 PDT 1996
-------------------------------------------
-
-0. Introduction
----------------
-
-This file describes how to build and install the Berkeley nvi editor for
-the LynxOS 2.4.0 operating system.
-
-LynxOS 2.4.0 is available for a variety of different hardware platforms, in
-particular, x86, m680x0, Sparc, and PowerPC. I have successfully built nvi
-on all four of these flavors of LynxOS by following the procedures given in
-this file.
-
-Note that these procedures may not work on versions of LynxOS prior to 2.4.0.
-(As I understand it, a good deal of work went into making the 2.4.0 release
-more POSIX-compliant, and I have no idea what build glitches, if any, you
-might encounter if you try to build nvi on a pre-2.4.0 version of LynxOS.)
-
-There are basically four steps to configuring, building, and installing nvi
-on LynxOS, namely:
-
- 1. Get setup to use the proper C compiler.
- 2. Replace your installed `tr' program.
- 3. Fix your system include files.
- 4. Do a normal configure, build, and install of nvi.
-
-These steps are described in separate sections below.
-
-1. Get Setup to Use the Proper C Compiler
-------------------------------------------
-
-The first step when building nvi on LynxOS is to set your $PATH environment
-variable properly so that the gcc 2.x compiler appears first on your path,
-prior to the older (and less robust) gcc 1.xx compiler (typically installed
-as /bin/gcc) and/or the old Lynx proprietary C compiler (typically installed
-as /bin/cc), both of which may also be present on your system.
-
-Note that for most operating systems, the configure script for nvi tries
-to use whatever compiler you have installed (and in your $PATH) as "cc",
-however in the special case of LynxOS, the configure script will auto-
-matically try to find a "gcc" program on your $PATH in preference to a
-compiler called "cc". If the nvi configure script only find a compiler
-called "cc", that's OK. It will still try to see if that is really just
-the GNU C compiler installed under the name "cc".
-
-Regardless of the name however (be it "gcc" or "cc") the first C compiler
-in your $PATH should be some _recent_ (i.e. 2.0 or later) version of the
-GNU C compiler... and the nvi configure script now checks that this is the
-case, and fails if it isn't.
-
-Oddly enough, LynxOS 2.4.0 (and some prior versions) shipped with as many
-as three different C compilers installed, so it is important to set your
-$PATH environment variable carfully in order to get the proper C compiler
-to appear first in your $PATH. You want to avoid having either the /bin/gcc
-compiler or the /bin/cc compiler be the first C compiler in your $PATH.
-
-To make sure that the GNU C version 2.x compiler which was shipped with your
-LynxOS system appears first on your path, you will need to either set your
-$PATH variable (for sh/bash/ksh users) or your $path variable (for csh/tcsh
-users). You can, of course, just do this at the shell command prompt, but
-it is probably better to actually edit this change into your .profile file
-(for sh/bash/ksh users) or into your .cshrc file (for csh/tcsh users).
-
-The pathname of the directory that contains the GNU C version 2.x compiler
-is (unfortunately) dependent upon the exact type of LynxOS system you have.
-
-For LynxOS 2.4.0 on x86 systems, gcc 2.x is located in:
-
- /cygnus/94q4-lynxos-x86/bin
-
-For LynxOS 2.4.0 on m680x0 systems, gcc 2.x is located in:
-
- /cygnus/94q4-lynxos-68k/bin
-
-For LynxOS 2.4.0 on Sparc systems, gcc 2.x is located in:
-
- /cygnus/94q4-lynxos-usparc/bin
-
-For LynxOS 2.4.0 on PowerPC systems, gcc 2.x is located in:
-
- /cygnus/95q2-lynxos-ppc/bin
-
-(Note also that these locations may change in LynxOS 2.5.x and beyond.)
-
-Anyway, it is imperative that you setup your $PATH environment variable
-(*before* you do the configure step for nvi) so that the GNU C version 2.x
-compiler appears in your $PATH before either the /bin/cc or /bin/gcc
-compilers (if present). If you fail to do this, the configure step for
-nvi will fail, because the compiler script actually checks (now) that the
-compiler you are using (if your are on a LynxOS system) is gcc 2.0 or
-later.
-
-To make absolutely sure that you will be configuring and building nvi with
-the proper C compiler (i.e. the GNU C version 2.x compiler on your system)
-you should add the directory name listed above for your specific system type
-to your $PATH setting in your $HOME/.profile file. (For csh/tcsh users, you
-will instead want to add the relevant directory name to the setting of your
-$path variable in your ~/.cshrc file.) Once you have added the proper direc-
-tory name (from the list given above) to your $HOME/.profile file (or to your
-~/.cshrc file, if you are using csh or tcsh) you should log out completely
-and then log back into the system just to make sure your new $PATH/$path
-setting takes effect properly.
-
-When you finish making this adjustment to your $PATH (or $path), the most
-up-to-date version of gcc on your system should be available to you as the
-first `gcc' program on your $PATH. You should verify that this is indeed the
-case simply by typing `gcc -v' and then checking the version number reported
-by the compiler. It should say either "2.6-94q4" or (on PowerPC systems) it
-should say "2.6-95q2". If you don't get these results, try again to set your
-$PATH (or $path) until you do. You won't be able to build nvi until you are
-properly setup to use gcc version 2.0 or later.
-
-Performing the steps shown above will insure that your subsequent configura-
-tion and build steps for nvi will make use of the most up-to-date version of
-gcc that was shipped with your Lynx operating system. (Note that the versions
-of gcc which are currently shipping with LynxOS 2.4.0 are also somewhat out-
-of-date themselves, but they are still quite a bit newer and more bug-free
-and ANSI conformant that those other two C compilers, /bin/cc and /bin/gcc,
-which also ship with LynxOS 2.4.0.)
-
-(Note: At present, LynxOS version 2.4.0 is the latest officially released
-version of LynxOS, and all of the above information is accurate and correct
-for LynxOS 2.4.0 as of the time of this writing. However it is rumored that
-future releases of LynxOS may provide a still newer version of gcc, and that
-it may be located in the /usr/bin directory. Thus, if you are building nvi
-for some LynxOS version later than 2.4.0, you may wish to check and see if
-your system has a program called /usr/bin/gcc, and use that version of gcc,
-if available, rather than the one suggested above.)
-
-2. Replace Your Installed `tr' Program
----------------------------------------
-
-The `tr' program which comes bundled with LynxOS 2.4.0 (as /bin/tr) has a
-somewhat obscure bug which just happens to be tickled by almost all GNU
-`autoconf' generated `configure' scripts (including the one that nowadays
-comes bundled with nvi). Using the stock /bin/tr program on LynxOS when
-executing such `configure' scripts _will_ cause these scripts to malfunction
-in various ways. It is therefore imperative that you replace your LynxOS
-/bin/tr program with a properly working version of the `tr' command _before_
-you even try to configure nvi. (You can tell if your `tr' program has the
-bug by executng the command "echo ab- | tr ab- ABC". If this yields the
-string "Ab-" then you have the bug. If it yields "ABC" then you don't.)
-
-You can obtain sources for a working version of the `tr' command as part of
-the GNU `textutils' package (the latest version of which, at the time of this
-writing, is 1.19). The GNU textutils package is available for downloading
-from prep.ai.mit.edu in the pub/gnu directory. Look for the file named
-textutils-1.19.tar.gz, or an even more recent version of textutils, if one
-is available. Fetch it, gunzip it, untar it, and follow the directions in
-the INSTALL file included in the tar file to build and install the entire
-textutils set of utility programs (which includes a working `tr' program).
-Then just make sure that the GNU version of `tr' appears on your $PATH
-_before_ the LynxOS version of `tr' (i.e. /bin/tr). Be sure to do this
-step _before_ you start to configure nvi.
-
-When building the textutils set of programs, I suggest that you use the most
-up-to-date C compiler available on your system (as described above). Also,
-note that it will be important for you to AVOID using the -O (optimize)
-compiler option when building the GNU textutils package, even if you are
-using the most up-to-date version of gcc which shipped with your system.
-If you try to use -O when building the textutils package on an x86 with
-the Cygnus 94q4 C compiler, you will end up with a `tr' program which will
-malfunction even worse than the one you are trying to replace! If you use
--O when building the textutils package on LynxOS on the PowerPC (using the
-Cygnus 95q2 C compiler) you will just get yourself a compiler crash. So
-just don't use -O when building textutils. You can avoid using -O by in-
-voking make in the textutils directory as follows:
-
- make CFLAGS="-g"
-
-(Note: At present, LynxOS version 2.4.0 is the latest officially released
-version of LynxOS, and all of the above information is accurate and correct
-for LynxOS 2.4.0 as of the time of this writing. However it is rumored that
-the bug in the /bin/tr program will be fixed in future releases of LynxOS,
-so if you have a version of LynxOS later than 2.4.0, you may wish to check
-and see if your /bin/tr program even has the problematic bug before bothering
-with all of this.)
-
-
-3. Fix Your System Include Files
----------------------------------
-
-If you are building nvi on a PowerPC system, it is also important that you
-apply the patches given at the end of this file to your /usr/include files.
-(Note that you will have to be root in order to do this.) Two of the patches
-included below fix a pair of serious bugs in the /usr/include/stdarg.h file
-on the PowerPC, and you really _do_ want to have these bugs fixed anyway,
-because without these fixes, anything that you compile which uses <stdarg.h>
-will very likely malfunction at run-time.
-
-Regardless of which LynxOS platform you are using (i.e. x86, PowerPC, Sparc,
-or m680x0) you may want to apply all of the system include files patches that
-are included below anyway. Doing so will clean up a few minor problems with
-the relevant system include files (i.e. <stdarg.h>, <ioctl.h>, and <wait.h>)
-and this step will also prevent a few warnings which you would otherwise get
-during the build of nvi.
-
-You can apply all of the patches given at the end of this file simply by
-doing the following:
-
- su root
- cd /usr/include
- /bin/patch < this-file
-
-Where `this-file' is the actual full pathname of the file you are now reading,
-wherever it may reside on your own system.
-
-(Note: At present, LynxOS version 2.4.0 is the latest officially released
-version of LynxOS, and all of the above information is accurate and correct
-for LynxOS 2.4.0 as of the time of this writing. However it is rumored that
-future releases of LynxOS may incorporate some or all of the important system
-include file fixes provided below. Thus, if you are building nvi for some
-LynxOS version later than 2.4.0, you should probably go ahead and try to
-apply the patches given below to your system include files, and then just
-don't worry about it if these patches seem to have already been applied.)
-
-
-4. A Brief Note about Sendmail
--------------------------------
-
-I should mention also that LynxOS does not normally ship with the `sendmail'
-mail transfer program installed, either under /usr/lib/ or anywhere else for
-that matter. This isn't really a big problem, but nvi normally wants and
-expects to have a sendmail program available so that it can send users notifi-
-cations (by mail) whenever a partially edited file is preserved by the editor
-in response to a sudden system crash, a sudden system shutdown, or an unexpect-
-ed serial-line hangup. You can configure and build nvi without any sendmail
-program installed on your system, but you will get warnings about its absence
-when you are doing the initial configure step prior to actually building nvi.
-If you want to have a fully-functional nvi which does send out notification
-messages (by mail) whenever partially edited files are preserved during a
-serial line hangup or system crash, then you should get the BSD sendmail
-sources (via ftp from ftp.cs.berkeley.edu), build and install sendmail, and
-then reconfigure, rebuild, and reinstall nvi.
-
-Please contact me at the E-mail address below if you experience any problems in
-building or using nvi on LynxOS. I make no guarrantees, but I may be willing
-to try to help.
-
-Ron Guilmette
-Roseville, California
-<rfg@monkeys.com>
-August 14, 1996
-
-
-cut here for LynxOS 2.4.0 system include files patches
------------------------------------------------------------------------------
-*** wait.h Fri Apr 26 10:02:45 1996
---- wait.h Sun May 19 05:36:50 1996
-***************
-*** 94,104 ****
- /* Function prototypes */
- #ifndef __LYNXOS
-- #ifdef _POSIX_SOURCE
- extern pid_t wait _AP((int *));
- extern pid_t waitpid _AP((pid_t, int *, int));
-! #else
-! extern int wait _AP((union wait *));
-! extern int waitpid _AP((int, union wait *, int));
-! extern int wait3 _AP((union wait *, int, struct rusage *));
- #endif
- #endif /* !__LYNXOS */
---- 94,101 ----
- /* Function prototypes */
- #ifndef __LYNXOS
- extern pid_t wait _AP((int *));
- extern pid_t waitpid _AP((pid_t, int *, int));
-! #ifndef _POSIX_SOURCE
-! extern int wait3 _AP((int *, int, struct rusage *));
- #endif
- #endif /* !__LYNXOS */
-*** ioctl.h Fri Apr 26 16:50:51 1996
---- ioctl.h Sat May 18 17:55:16 1996
-***************
-*** 572,576 ****
-
- #ifndef __LYNXOS
-! extern int ioctl _AP((int, int, char *));
- #endif
-
---- 572,576 ----
-
- #ifndef __LYNXOS
-! extern int ioctl _AP((int, int, ...));
- #endif
-
-*** stdarg.h Fri Apr 26 16:51:02 1996
---- stdarg.h Sat May 18 19:34:13 1996
-***************
-*** 88,92 ****
- (((sizeof(TYPE) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-
-! #define va_start(AP, LASTARG) (AP = ((char *) __builtin_next_arg ()))
-
- void va_end(va_list); /* Defined in libgcc.a */
---- 88,92 ----
- (((sizeof(TYPE) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-
-! #define va_start(AP, LASTARG) (AP = ((char *) __builtin_next_arg (LASTARG)))
-
- void va_end(va_list); /* Defined in libgcc.a */
-***************
-*** 162,166 ****
- (((sizeof(TYPE) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-
-! #define va_start(AP, LASTARG) (AP = ((char *) __builtin_next_arg ()))
-
- void va_end(va_list); /* Defined in libgcc.a */
---- 162,166 ----
- (((sizeof(TYPE) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-
-! #define va_start(AP, LASTARG) (AP = ((char *) __builtin_next_arg (LASTARG)))
-
- void va_end(va_list); /* Defined in libgcc.a */
diff --git a/build/acconfig.h b/build/acconfig.h
deleted file mode 100644
index 567f9ee60070..000000000000
--- a/build/acconfig.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @(#)acconfig.h 8.18 (Berkeley) 7/2/96 */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef ssize_t
-
-/* Define if you want a debugging version. */
-#undef DEBUG
-
-/* Define if you have a System V-style (broken) gettimeofday. */
-#undef HAVE_BROKEN_GETTIMEOFDAY
-
-/* Define if you have a Ultrix-style (broken) vdisable. */
-#undef HAVE_BROKEN_VDISABLE
-
-/* Define if you have a BSD version of curses. */
-#undef HAVE_BSD_CURSES
-
-/* Define if you have the curses(3) addnstr function. */
-#undef HAVE_CURSES_ADDNSTR
-
-/* Define if you have the curses(3) beep function. */
-#undef HAVE_CURSES_BEEP
-
-/* Define if you have the curses(3) flash function. */
-#undef HAVE_CURSES_FLASH
-
-/* Define if you have the curses(3) idlok function. */
-#undef HAVE_CURSES_IDLOK
-
-/* Define if you have the curses(3) keypad function. */
-#undef HAVE_CURSES_KEYPAD
-
-/* Define if you have the curses(3) newterm function. */
-#undef HAVE_CURSES_NEWTERM
-
-/* Define if you have the curses(3) setupterm function. */
-#undef HAVE_CURSES_SETUPTERM
-
-/* Define if you have the curses(3) tigetstr/tigetnum functions. */
-#undef HAVE_CURSES_TIGETSTR
-
-/* Define if you have the DB __hash_open call in the C library. */
-#undef HAVE_DB_HASH_OPEN
-
-/* Define if you have the chsize(2) system call. */
-#undef HAVE_FTRUNCATE_CHSIZE
-
-/* Define if you have the ftruncate(2) system call. */
-#undef HAVE_FTRUNCATE_FTRUNCATE
-
-/* Define if you have fcntl(2) style locking. */
-#undef HAVE_LOCK_FCNTL
-
-/* Define if you have flock(2) style locking. */
-#undef HAVE_LOCK_FLOCK
-
-/* Define if you want to compile in the Perl interpreter. */
-#undef HAVE_PERL_INTERP
-
-/* Define if your Perl is at least 5.003_01. */
-#undef HAVE_PERL_5_003_01
-
-/* Define if you have the Berkeley style revoke(2) system call. */
-#undef HAVE_REVOKE
-
-/* Define if you have the Berkeley style strsep(3) function. */
-#undef HAVE_STRSEP
-
-/* Define if you have <sys/mman.h> */
-#undef HAVE_SYS_MMAN_H
-
-/* Define if you have <sys/select.h> */
-#undef HAVE_SYS_SELECT_H
-
-/* Define if you have the System V style pty calls. */
-#undef HAVE_SYS5_PTY
-
-/* Define if you want to compile in the Tcl interpreter. */
-#undef HAVE_TCL_INTERP
-
-/* Define if your sprintf returns a pointer, not a length. */
-#undef SPRINTF_RET_CHARPNT
diff --git a/build/aclocal.m4 b/build/aclocal.m4
deleted file mode 100644
index de7e57ed3aac..000000000000
--- a/build/aclocal.m4
+++ /dev/null
@@ -1,17 +0,0 @@
-AC_DEFUN(AM_SANITY_CHECK_CC,
-[dnl Derived from macros from Bruno Haible and from Cygnus.
-AC_MSG_CHECKING([whether the compiler ($CC $CFLAGS $LDFLAGS) actually works])
-AC_LANG_SAVE
- AC_LANG_C
- AC_TRY_RUN([main() { exit(0); }],
- am_cv_prog_cc_works=yes, am_cv_prog_cc_works=no,
- dnl When crosscompiling, just try linking.
- AC_TRY_LINK([], [], am_cv_prog_cc_works=yes,
- am_cv_prog_cc_works=no))
-AC_LANG_RESTORE
-case "$am_cv_prog_cc_works" in
- *no) AC_MSG_ERROR([Installation or configuration problem: C compiler cannot create executables.]) ;;
- *yes) ;;
-esac
-AC_MSG_RESULT(yes)
-])dnl
diff --git a/build/config.guess b/build/config.guess
deleted file mode 100755
index 4c314d97aacb..000000000000
--- a/build/config.guess
+++ /dev/null
@@ -1,571 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-#
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit system type (host/target name).
-#
-# Only a few systems have been added to this list; please add others
-# (but try to keep the structure clean).
-#
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 8/24/94.)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
- PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- alpha:OSF1:V*:*)
- # After 1.2, OSF1 uses "V1.3" for uname -r.
- echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'`
- exit 0 ;;
- alpha:OSF1:*:*)
- # 1.2 uses "1.2" for uname -r.
- echo alpha-dec-osf${UNAME_RELEASE}
- exit 0 ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit 0 ;;
- amiga:NetBSD:*:*)
- echo m68k-cbm-netbsd${UNAME_RELEASE}
- exit 0 ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit 0;;
- Pyramid*:OSx*:*:*)
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit 0 ;;
- sun4*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- i86pc:SunOS:5.*:*)
- echo i386-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- sun4*:SunOS:6*:*)
- # According to config.sub, this is the proper way to canonicalize
- # SunOS6. Hard to guess exactly what SunOS6 will be like, but
- # it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit 0 ;;
- sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
- Series*|S4*)
- UNAME_RELEASE=`uname -v`
- ;;
- esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit 0 ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit 0 ;;
- atari*:NetBSD:*:*)
- echo m68k-atari-netbsd${UNAME_RELEASE}
- exit 0 ;;
- sun3*:NetBSD:*:*)
- echo m68k-sun-netbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:NetBSD:*:*)
- echo m68k-apple-netbsd${UNAME_RELEASE}
- exit 0 ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit 0 ;;
- mips:*:4*:UMIPS)
- echo mips-mips-riscos4sysv
- exit 0 ;;
- mips:*:5*:RISCos)
- echo mips-mips-riscos${UNAME_RELEASE}
- exit 0 ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit 0 ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit 0 ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit 0 ;;
- AViiON:dgux:*:*)
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
- -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
- echo m88k-dg-dgux${UNAME_RELEASE}
- else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- exit 0 ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit 0 ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit 0 ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit 0 ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit 0 ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit 0 ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i?86:AIX:*:*)
- echo i386-ibm-aix
- exit 0 ;;
- *:AIX:2:3)
- if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- sed 's/^ //' << EOF >dummy.c
- #include <sys/systemcfg.h>
-
- main()
- {
- if (!__power_pc())
- exit(1);
- puts("powerpc-ibm-aix3.2.5");
- exit(0);
- }
-EOF
- ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
- echo rs6000-ibm-aix3.2.5
- elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
- else
- echo rs6000-ibm-aix3.2
- fi
- exit 0 ;;
- *:AIX:*:4)
- if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
- IBM_ARCH=rs6000
- else
- IBM_ARCH=powerpc
- fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=4.${UNAME_RELEASE}
- fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit 0 ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit 0 ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit 0 ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit 0 ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit 0 ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit 0 ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit 0 ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit 0 ;;
- 9000/[3478]??:HP-UX:*:*)
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/7?? | 9000/8?[79] ) HP_ARCH=hppa1.1 ;;
- 9000/8?? ) HP_ARCH=hppa1.0 ;;
- esac
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit 0 ;;
- 3050*:HI-UX:*:*)
- sed 's/^ //' << EOF >dummy.c
- #include <unistd.h>
- int
- main ()
- {
- long cpu = sysconf (_SC_CPU_VERSION);
- /* The order matters, because CPU_IS_HP_MC68K erroneously returns
- true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
- results, however. */
- if (CPU_IS_PA_RISC (cpu))
- {
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
- default: puts ("hppa-hitachi-hiuxwe2"); break;
- }
- }
- else if (CPU_IS_HP_MC68K (cpu))
- puts ("m68k-hitachi-hiuxwe2");
- else puts ("unknown-hitachi-hiuxwe2");
- exit (0);
- }
-EOF
- ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
- echo unknown-hitachi-hiuxwe2
- exit 0 ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit 0 ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit 0 ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit 0 ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit 0 ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit 0 ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit 0 ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit 0 ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit 0 ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit 0 ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit 0 ;;
- CRAY*X-MP:*:*:*)
- echo xmp-cray-unicos
- exit 0 ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE}
- exit 0 ;;
- CRAY*C90:*:*:*)
- echo c90-cray-unicos${UNAME_RELEASE}
- exit 0 ;;
- CRAY-2:*:*:*)
- echo cray2-cray-unicos
- exit 0 ;;
- hp3[0-9][05]:NetBSD:*:*)
- echo m68k-hp-netbsd${UNAME_RELEASE}
- exit 0 ;;
- i?86:BSD/386:*:* | *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit 0 ;;
- *:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit 0 ;;
- *:NetBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- exit 0 ;;
- *:GNU:*:*)
- echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit 0 ;;
- *:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us.
- ld_help_string=`ld --help 2>&1`
- if echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: elf_i?86"; then
- echo "${UNAME_MACHINE}-unknown-linux" ; exit 0
- elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i?86linux"; then
- echo "${UNAME_MACHINE}-unknown-linuxaout" ; exit 0
- elif echo $ld_help_string | grep >/dev/null 2>&1 "supported emulations: i?86coff"; then
- echo "${UNAME_MACHINE}-unknown-linuxcoff" ; exit 0
- elif test "${UNAME_MACHINE}" = "alpha" ; then
- echo alpha-unknown-linux ; exit 0
- else
- # Either a pre-BFD a.out linker (linuxoldld) or one that does not give us
- # useful --help. Gcc wants to distinguish between linuxoldld and linuxaout.
- test ! -d /usr/lib/ldscripts/. \
- && echo "${UNAME_MACHINE}-unknown-linuxoldld" && exit 0
- # Determine whether the default compiler is a.out or elf
- cat >dummy.c <<EOF
-main(argc, argv)
-int argc;
-char *argv[];
-{
-#ifdef __ELF__
- printf ("%s-unknown-linux\n", argv[1]);
-#else
- printf ("%s-unknown-linuxaout\n", argv[1]);
-#endif
- return 0;
-}
-EOF
- ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
- fi ;;
-# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
-# are messed up and put the nodename in both sysname and nodename.
- i?86:DYNIX/ptx:4*:*)
- echo i386-sequent-sysv4
- exit 0 ;;
- i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
- if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
- else
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
- fi
- exit 0 ;;
- i?86:*:3.2:*)
- if test -f /usr/options/cb.name; then
- UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-unknown-isc$UNAME_REL
- elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
- (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL
- else
- echo ${UNAME_MACHINE}-unknown-sysv32
- fi
- exit 0 ;;
- Intel:Mach:3*:*)
- echo i386-unknown-mach3
- exit 0 ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit 0 ;;
- i860:*:4.*:*) # i860-SVR4
- if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
- else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
- fi
- exit 0 ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit 0 ;;
- M680?0:*:R3V[567]*:*)
- test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0)
- uname -p 2>/dev/null | grep 86 >/dev/null \
- && echo i486-ncr-sysv4.3 && exit 0 ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- uname -p 2>/dev/null | grep 86 >/dev/null \
- && echo i486-ncr-sysv4 && exit 0 ;;
- m68*:LynxOS:2.*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- mc68*:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit 0 ;;
- i?86:LynxOS:2.*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- TSUNAMI:LynxOS:2.*:* | uSPARC2:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- PowerPC:LynxOS:2.*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit 0 ;;
- *FTX*)
- echo i860-stratus-sysv4
- exit 0 ;;
- *:SINIX-*:*:*)
- if uname -p 2>/dev/null >/dev/null ; then
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
- else
- echo ns32k-sni-sysv
- fi
- exit 0 ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit 0 ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-cat >dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3");
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-unknown-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-#if !defined (ultrix)
- printf ("vax-dec-bsd\n"); exit (0);
-#else
- printf ("vax-dec-ultrix\n"); exit (0);
-#endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
-rm -f dummy.c dummy
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit 0 ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit 0 ;;
- c34*)
- echo c34-convex-bsd
- exit 0 ;;
- c38*)
- echo c38-convex-bsd
- exit 0 ;;
- c4*)
- echo c4-convex-bsd
- exit 0 ;;
- esac
-fi
-
-#echo '(Unable to guess system type)' 1>&2
-
-exit 1
diff --git a/build/config.h.in b/build/config.h.in
deleted file mode 100644
index c87fcdd7f214..000000000000
--- a/build/config.h.in
+++ /dev/null
@@ -1,179 +0,0 @@
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define to empty if the keyword does not work. */
-#undef const
-
-/* Define if you have a working `mmap' system call. */
-#undef HAVE_MMAP
-
-/* Define if your struct stat has st_blksize. */
-#undef HAVE_ST_BLKSIZE
-
-/* Define if you have <vfork.h>. */
-#undef HAVE_VFORK_H
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef mode_t
-
-/* Define to `long' if <sys/types.h> doesn't define. */
-#undef off_t
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef pid_t
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-#undef size_t
-
-/* Define if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define if your <sys/time.h> declares struct tm. */
-#undef TM_IN_SYS_TIME
-
-/* Define vfork as fork if vfork does not work. */
-#undef vfork
-
-/* Define if your processor stores words with the most significant
- byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-#undef ssize_t
-
-/* Define if you want a debugging version. */
-#undef DEBUG
-
-/* Define if you have a System V-style (broken) gettimeofday. */
-#undef HAVE_BROKEN_GETTIMEOFDAY
-
-/* Define if you have a Ultrix-style (broken) vdisable. */
-#undef HAVE_BROKEN_VDISABLE
-
-/* Define if you have a BSD version of curses. */
-#undef HAVE_BSD_CURSES
-
-/* Define if you have the curses(3) addnstr function. */
-#undef HAVE_CURSES_ADDNSTR
-
-/* Define if you have the curses(3) beep function. */
-#undef HAVE_CURSES_BEEP
-
-/* Define if you have the curses(3) flash function. */
-#undef HAVE_CURSES_FLASH
-
-/* Define if you have the curses(3) idlok function. */
-#undef HAVE_CURSES_IDLOK
-
-/* Define if you have the curses(3) keypad function. */
-#undef HAVE_CURSES_KEYPAD
-
-/* Define if you have the curses(3) newterm function. */
-#undef HAVE_CURSES_NEWTERM
-
-/* Define if you have the curses(3) setupterm function. */
-#undef HAVE_CURSES_SETUPTERM
-
-/* Define if you have the curses(3) tigetstr/tigetnum functions. */
-#undef HAVE_CURSES_TIGETSTR
-
-/* Define if you have the chsize(2) system call. */
-#undef HAVE_FTRUNCATE_CHSIZE
-
-/* Define if you have the ftruncate(2) system call. */
-#undef HAVE_FTRUNCATE_FTRUNCATE
-
-/* Define if you have fcntl(2) style locking. */
-#undef HAVE_LOCK_FCNTL
-
-/* Define if you have flock(2) style locking. */
-#undef HAVE_LOCK_FLOCK
-
-/* Define if you want to compile in the Perl interpreter. */
-#undef HAVE_PERL_INTERP
-
-/* Define if your Perl is at least 5.003_01. */
-#undef HAVE_PERL_5_003_01
-
-/* Define if you have the Berkeley style revoke(2) system call. */
-#undef HAVE_REVOKE
-
-/* Define if you have <sys/mman.h> */
-#undef HAVE_SYS_MMAN_H
-
-/* Define if you have <sys/select.h> */
-#undef HAVE_SYS_SELECT_H
-
-/* Define if you have the System V style pty calls. */
-#undef HAVE_SYS5_PTY
-
-/* Define if you want to compile in the Tcl interpreter. */
-#undef HAVE_TCL_INTERP
-
-/* Define if your sprintf returns a pointer, not a length. */
-#undef SPRINTF_RET_CHARPNT
-
-/* Define if you have the bsearch function. */
-#undef HAVE_BSEARCH
-
-/* Define if you have the gethostname function. */
-#undef HAVE_GETHOSTNAME
-
-/* Define if you have the getopt function. */
-#undef HAVE_GETOPT
-
-/* Define if you have the getpagesize function. */
-#undef HAVE_GETPAGESIZE
-
-/* Define if you have the memchr function. */
-#undef HAVE_MEMCHR
-
-/* Define if you have the memcpy function. */
-#undef HAVE_MEMCPY
-
-/* Define if you have the memmove function. */
-#undef HAVE_MEMMOVE
-
-/* Define if you have the memset function. */
-#undef HAVE_MEMSET
-
-/* Define if you have the mkstemp function. */
-#undef HAVE_MKSTEMP
-
-/* Define if you have the mmap function. */
-#undef HAVE_MMAP
-
-/* Define if you have the select function. */
-#undef HAVE_SELECT
-
-/* Define if you have the setenv function. */
-#undef HAVE_SETENV
-
-/* Define if you have the snprintf function. */
-#undef HAVE_SNPRINTF
-
-/* Define if you have the strdup function. */
-#undef HAVE_STRDUP
-
-/* Define if you have the strerror function. */
-#undef HAVE_STRERROR
-
-/* Define if you have the strpbrk function. */
-#undef HAVE_STRPBRK
-
-/* Define if you have the strsep function. */
-#undef HAVE_STRSEP
-
-/* Define if you have the strtol function. */
-#undef HAVE_STRTOL
-
-/* Define if you have the strtoul function. */
-#undef HAVE_STRTOUL
-
-/* Define if you have the unsetenv function. */
-#undef HAVE_UNSETENV
-
-/* Define if you have the valloc function. */
-#undef HAVE_VALLOC
-
-/* Define if you have the vsnprintf function. */
-#undef HAVE_VSNPRINTF
diff --git a/build/config.sub b/build/config.sub
deleted file mode 100755
index 43f086781962..000000000000
--- a/build/config.sub
+++ /dev/null
@@ -1,872 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script, version 1.1.
-# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-if [ x$1 = x ]
-then
- echo Configuration name missing. 1>&2
- echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
- echo "or $0 ALIAS" 1>&2
- echo where ALIAS is a recognized configuration type. 1>&2
- exit 1
-fi
-
-# First pass through any local machine types.
-case $1 in
- *local*)
- echo $1
- exit 0
- ;;
- *)
- ;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS (if any).
-basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-if [ $basic_machine != $1 ]
-then os=`echo $1 | sed 's/.*-/-/'`
-else os=; fi
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp )
- os=
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- tahoe | i[345]86 | i860 | m68k | m68000 | m88k | ns32k | arm \
- | arme[lb] | pyramid \
- | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \
- | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \
- | powerpc | powerpcle | sparc64 | 1750a | dsp16xx | mips64 | mipsel \
- | pdp11 | mips64el | mips64orion | mips64orionel \
- | sparc)
- basic_machine=$basic_machine-unknown
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[345]86-* | i860-* | m68k-* | m68000-* | m88k-* \
- | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
- | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
- | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
- | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
- | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-cbm
- ;;
- amigados)
- basic_machine=m68k-cbm
- os=-amigados
- ;;
- amigaunix | amix)
- basic_machine=m68k-cbm
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- cray2)
- basic_machine=cray2-cray
- os=-unicos
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- os=-mvs
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[345]86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
- os=-sysv32
- ;;
- i[345]86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
- os=-sysv4
- ;;
- i[345]86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
- os=-sysv
- ;;
- i[345]86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
- os=-solaris2
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- mac | macintosh)
- basic_machine=m68k-apple
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pentium | p5 | p6)
- # We don't have specific support for the Intel Pentium (p6) followon yet, so just call it a Pentium
- basic_machine=i586-intel
- ;;
- pentium-* | p5-* | p6-*)
- # We don't have specific support for the Intel Pentium (p6) followon yet, so just call it a Pentium
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- k5)
- # We don't have specific support for AMD's K5 yet, so just call it a Pentium
- basic_machine=i586-amd
- ;;
- nexen)
- # We don't have specific support for Nexgen yet, so just call it a Pentium
- basic_machine=i586-nexgen
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=rs6000-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- xmp)
- basic_machine=xmp-cray
- os=-unicos
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- mips)
- basic_machine=mips-mips
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sparc)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -unixware* | svr4*)
- os=-sysv4
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[345]* \
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigados* | -msdos* | -newsos* | -unicos* | -aos* \
- | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \
- | -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \
- | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* )
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -aux*)
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -xenix)
- os=-xenix
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-semi)
- os=-aout
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-ibm)
- os=-aix
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigados
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -hpux*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -vxworks*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
diff --git a/build/configure b/build/configure
deleted file mode 100755
index e2055d113ca8..000000000000
--- a/build/configure
+++ /dev/null
@@ -1,4446 +0,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.7
-# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
- --enable-debug Build a debugging version."
-ac_help="$ac_help
- --with-x use the X Window System"
-ac_help="$ac_help
- --enable-perlinterp Include a Perl interpreter in vi."
-ac_help="$ac_help
- --enable-tknvi Build a Tk/Tcl front-end for vi."
-ac_help="$ac_help
- --enable-tclinterp Include a Tk/Tcl interpreter in vi."
-ac_help="$ac_help
- --disable-curses DON'T use the nvi-provided curses routines."
-ac_help="$ac_help
- --disable-db DON'T use the nvi-provided DB routines."
-ac_help="$ac_help
- --disable-re DON'T use the nvi-provided RE routines."
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.7"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=../common/main.c
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='echo $CPP $CPPFLAGS 1>&5;
-$CPP $CPPFLAGS'
-ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5;
-${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
-ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
-${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
-
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-ac_aux_dir=
-for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
-fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
-
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# 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
-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}:"
- for ac_dir in $PATH; do
- # Account for people who put trailing slashes in PATH elements.
- case "$ac_dir/" in
- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd 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
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
- done
- ;;
- esac
- done
- IFS="$ac_save_ifs"
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL="$ac_cv_path_install"
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL="$ac_install_sh"
- fi
-fi
-echo "$ac_t""$INSTALL" 1>&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-# Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-
-host_alias=$host
-case "$host_alias" in
-NONE)
- case $nonopt in
- NONE)
- if host_alias=`$ac_config_guess`; then :
- else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
- fi ;;
- *) host_alias=$nonopt ;;
- esac ;;
-esac
-
-host=`$ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
-
-if test "$program_transform_name" = s,x,x,; then
- program_transform_name=
-else
- # Double any \ or $. echo might interpret backslashes.
- cat <<\EOF_SED > conftestsed
-s,\\,\\\\,g; s,\$,$$,g
-EOF_SED
- program_transform_name="`echo $program_transform_name|sed -f conftestsed`"
- rm -f conftestsed
-fi
-test "$program_prefix" != NONE &&
- program_transform_name="s,^,${program_prefix},; $program_transform_name"
-# Use a double $ so make ignores it.
-test "$program_suffix" != NONE &&
- program_transform_name="s,\$\$,${program_suffix},; $program_transform_name"
-
-# sed with no file args requires a program.
-test "$program_transform_name" = "" && program_transform_name="s,x,x,"
-
-
-echo $ac_n "checking if --enable-debug option specified""... $ac_c" 1>&6
-# Check whether --enable-debug or --disable-debug was given.
-if test "${enable_debug+set}" = set; then
- enableval="$enable_debug"
- vi_cv_debug="yes"
-else
- vi_cv_debug="no"
-fi
-
-if test "$vi_cv_debug" = yes; then
- cat >> confdefs.h <<\EOF
-#define DEBUG 1
-EOF
-
- OPTFLAG=${OPTFLAG-"-g"}
- no_op_OPTFLAG=${no_op_OPTFLAG-"-g"}
-fi
-echo "$ac_t""$vi_cv_debug" 1>&6
-
-
-
-case "$host_os" in
-aix3.2.5) OPTFLAG=${OPTFLAG-"-O"};;
-aix4.1*) CFLAGS=${CFLAGS-"-qstrict"}
- OPTFLAG=${OPTFLAG-"-O3"};;
-aux*) CPPFLAGS=${CPPFLAGS-"-ZP -D_BSD_SOURCE -D_SYSV_SOURCE -D_AUX_SOURCE"}
- LDFLAGS=${LDFLAGS-"-ZP"}
- OPTFLAG=${OPTFLAG-"-O"};;
-bsd4.4) OPTFLAG=${OPTFLAG-"-O2"};;
-bsdi*) CC=${CC-"shlicc"}
- OPTFLAG=${OPTFLAG-"-O2"};;
-irix6*) OPTFLAG=${OPTFLAG-"-O2"};;
-irix*) OPTFLAG=${OPTFLAG-"-O2"};;
-lynxos*) # 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
-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="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="cc"
-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
-
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if ${CC-cc} -E conftest.c 2>&5 | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
- if test "${CFLAGS+set}" != set; then
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_gcc_g=yes
-else
- ac_cv_prog_gcc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6
- if test $ac_cv_prog_gcc_g = yes; then
- CFLAGS="-g -O"
- else
- CFLAGS="-O"
- fi
- fi
-else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
-fi
-
- echo $ac_n "checking for GNU C (gcc) version 2.x""... $ac_c" 1>&6
- ac_cv_gcc_vers=`${CC-cc} -v 2>&1 | \
- grep "gcc version " | sed 's/.*version //'`
- ac_cv_gcc_major=`echo "$ac_cv_gcc_vers" | sed 's/\..*//'`
- if test "$ac_cv_gcc_major" = "2" ; then
- echo "$ac_t""yes" 1>&6
- else
- echo "$ac_t""no" 1>&6
- echo "Fatal error: Nvi requires gcc 2.x to build on LynxOS."
- echo "See build/README.LynxOS for more information."
- exit 1
- fi;;
-nextstep3) CPPFLAGS=${CPPFLAGS-"-w -pipe -posix"}
- LDFLAGS=${LDFLAGS-"-posix"}
- OPTFLAG=${OPTFLAG-"-O9"};;
-osf*) CFLAGS=${CFLAGS-"-Olimit 1000"};;
-solaris*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
-sunos*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
-esac
-
-
-CC=${CC-cc}
-
-
-OPTFLAG=${OPTFLAG-"-O"}
-
-
-no_op_OPTFLAG=${no_op_OPTFLAG-"$OPTFLAG"}
-
-case "$host_os" in
-bsdi2.1) LIBS=${LIBS-"-lipc"};;
-dgux*) LIBS=${LIBS-"-ldgc"};;
-irix6*) LIBS=${LIBS-"-lbsd"};;
-irix*) LIBS=${LIBS-"-lc_s -lbsd"};;
-isc*) LIBS=${LIBS-"-lcposix -linet"};;
-netbsd1*) LIBS=${LIBS-"-lcrypt"};;
-ptx*) LIBS=${LIBS-"-lseq -linet -lsocket"};;
-sco3.2*) LIBS=${LIBS-"-lsocket"};;
-sinix*) LIBS=${LIBS-"-lelf -lc"};;
-solaris*) LIBS=${LIBS-"-lsocket -lnsl -ldl"}
- RLIBS=yes;;
-wgs*) LIBS=${LIBS-"-lnsl"};;
-esac
-
-case "$host_os" in
-aux*) LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
-esac
-
-case "$host_os" in
-ultrix*) cat >> confdefs.h <<\EOF
-#define HAVE_BROKEN_VDISABLE 1
-EOF
-;;
-esac
-
-CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
-
-LDFLAGS="$ADDLDFLAGS $LDFLAGS"
-
-LIBS="$ADDLIBS $LIBS"
-
-# If we cannot run a trivial program, we must be cross compiling.
-echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_c_cross=yes
-else
-cat > conftest.$ac_ext <<EOF
-#line 839 "configure"
-#include "confdefs.h"
-main(){return(0);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_cross=no
-else
- ac_cv_c_cross=yes
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_c_cross" 1>&6
-cross_compiling=$ac_cv_c_cross
-
-echo $ac_n "checking whether the compiler ($CC $CFLAGS $LDFLAGS) actually works""... $ac_c" 1>&6
-
- ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='echo $CPP $CPPFLAGS 1>&5;
-$CPP $CPPFLAGS'
-ac_compile='echo ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5;
-${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5 2>&5'
-ac_link='echo ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5;
-${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5 2>&5'
-
- if test "$cross_compiling" = yes; then
- cat > conftest.$ac_ext <<EOF
-#line 869 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- am_cv_prog_cc_works=yes
-else
- rm -rf conftest*
- am_cv_prog_cc_works=no
-fi
-rm -f conftest*
-
-else
-cat > conftest.$ac_ext <<EOF
-#line 888 "configure"
-#include "confdefs.h"
-main() { exit(0); }
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- am_cv_prog_cc_works=yes
-else
- am_cv_prog_cc_works=no
-fi
-fi
-rm -fr conftest*
-
-case "$am_cv_prog_cc_works" in
- *no) { echo "configure: error: Installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } ;;
- *yes) ;;
-esac
-echo "$ac_t""yes" 1>&6
-
-
-PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib:"
-
-# Extract the first word of "sh", so it can be a program name with args.
-set dummy sh; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_shell'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_shell" in
- /*)
- ac_cv_path_vi_cv_path_shell="$vi_cv_path_shell" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_shell="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_shell" && ac_cv_path_vi_cv_path_shell="no"
- ;;
-esac
-fi
-vi_cv_path_shell="$ac_cv_path_vi_cv_path_shell"
-if test -n "$vi_cv_path_shell"; then
- echo "$ac_t""$vi_cv_path_shell" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test "$vi_cv_path_shell" = no; then
- echo "Fatal error: the shell utility not found."
- exit 1
-fi
-
-# Extract the first word of "sendmail", so it can be a program name with args.
-set dummy sendmail; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_sendmail'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_sendmail" in
- /*)
- ac_cv_path_vi_cv_path_sendmail="$vi_cv_path_sendmail" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_sendmail="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_sendmail" && ac_cv_path_vi_cv_path_sendmail="no"
- ;;
-esac
-fi
-vi_cv_path_sendmail="$ac_cv_path_vi_cv_path_sendmail"
-if test -n "$vi_cv_path_sendmail"; then
- echo "$ac_t""$vi_cv_path_sendmail" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test "$vi_cv_path_sendmail" = no; then
- echo "WARNING: The sendmail utility was not found!"
- echo "WARNING: Users will not be told of saved files."
-fi
-
-
-for ac_prog in perl5 perl
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_perl'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_perl" in
- /*)
- ac_cv_path_vi_cv_path_perl="$vi_cv_path_perl" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_perl="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- ;;
-esac
-fi
-vi_cv_path_perl="$ac_cv_path_vi_cv_path_perl"
-if test -n "$vi_cv_path_perl"; then
- echo "$ac_t""$vi_cv_path_perl" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-test -n "$vi_cv_path_perl" && break
-done
-test -n "$vi_cv_path_perl" || vi_cv_path_perl="no"
-
-
-
-echo $ac_n "checking for preserve directory""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_path_preserve'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- dirlist="/var/preserve /var/tmp /usr/tmp"
- vi_cv_path_preserve=no
- for i in $dirlist; do
- if test -d $i/vi.recover; then
- vi_cv_path_preserve=$i/vi.recover
- break;
- fi
- done
- if test "$vi_cv_path_preserve" = no; then
- for i in $dirlist; do
- if test -d $i -a -w $i; then
- vi_cv_path_preserve=$i/vi.recover
- break;
- fi
- done
-
- fi
-fi
-
-if test "$vi_cv_path_preserve" = no; then
- echo "Fatal error: no writeable preserve directory found."
- exit 1
-fi
-echo "$ac_t""$vi_cv_path_preserve" 1>&6
-
-# Extract the first word of "chmod", so it can be a program name with args.
-set dummy chmod; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_chmod'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_chmod" in
- /*)
- ac_cv_path_vi_cv_path_chmod="$vi_cv_path_chmod" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_chmod="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_chmod" && ac_cv_path_vi_cv_path_chmod="missing_chmod"
- ;;
-esac
-fi
-vi_cv_path_chmod="$ac_cv_path_vi_cv_path_chmod"
-if test -n "$vi_cv_path_chmod"; then
- echo "$ac_t""$vi_cv_path_chmod" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Extract the first word of "cp", so it can be a program name with args.
-set dummy cp; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_cp'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_cp" in
- /*)
- ac_cv_path_vi_cv_path_cp="$vi_cv_path_cp" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_cp="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_cp" && ac_cv_path_vi_cv_path_cp="missing_cp"
- ;;
-esac
-fi
-vi_cv_path_cp="$ac_cv_path_vi_cv_path_cp"
-if test -n "$vi_cv_path_cp"; then
- echo "$ac_t""$vi_cv_path_cp" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Extract the first word of "ln", so it can be a program name with args.
-set dummy ln; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_ln'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_ln" in
- /*)
- ac_cv_path_vi_cv_path_ln="$vi_cv_path_ln" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_ln="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_ln" && ac_cv_path_vi_cv_path_ln="missing_ln"
- ;;
-esac
-fi
-vi_cv_path_ln="$ac_cv_path_vi_cv_path_ln"
-if test -n "$vi_cv_path_ln"; then
- echo "$ac_t""$vi_cv_path_ln" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Extract the first word of "mkdir", so it can be a program name with args.
-set dummy mkdir; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_mkdir'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_mkdir" in
- /*)
- ac_cv_path_vi_cv_path_mkdir="$vi_cv_path_mkdir" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_mkdir="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_mkdir" && ac_cv_path_vi_cv_path_mkdir="missing_mkdir"
- ;;
-esac
-fi
-vi_cv_path_mkdir="$ac_cv_path_vi_cv_path_mkdir"
-if test -n "$vi_cv_path_mkdir"; then
- echo "$ac_t""$vi_cv_path_mkdir" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Extract the first word of "rm", so it can be a program name with args.
-set dummy rm; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_rm'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_rm" in
- /*)
- ac_cv_path_vi_cv_path_rm="$vi_cv_path_rm" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_rm="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_rm" && ac_cv_path_vi_cv_path_rm="missing_rm"
- ;;
-esac
-fi
-vi_cv_path_rm="$ac_cv_path_vi_cv_path_rm"
-if test -n "$vi_cv_path_rm"; then
- echo "$ac_t""$vi_cv_path_rm" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_strip'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- case "$vi_cv_path_strip" in
- /*)
- ac_cv_path_vi_cv_path_strip="$vi_cv_path_strip" # Let the user override the test with a path.
- ;;
- *)
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_path_vi_cv_path_strip="$ac_dir/$ac_word"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_path_vi_cv_path_strip" && ac_cv_path_vi_cv_path_strip="missing_strip"
- ;;
-esac
-fi
-vi_cv_path_strip="$ac_cv_path_vi_cv_path_strip"
-if test -n "$vi_cv_path_strip"; then
- echo "$ac_t""$vi_cv_path_strip" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 1252 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 1266 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-# If we find X, set shell vars x_includes and x_libraries to the
-# paths, otherwise set no_x=yes.
-# Uses ac_ vars as temps to allow command line to override cache and checks.
-# --without-x overrides everything else, but does not touch the cache.
-echo $ac_n "checking for X""... $ac_c" 1>&6
-
-# Check whether --with-x or --without-x was given.
-if test "${with_x+set}" = set; then
- withval="$with_x"
- :
-fi
-
-if test "x$with_x" = xno; then
- no_x=yes
-else
- if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
- no_x=
- else
-if eval "test \"`echo '$''{'ac_cv_path_x'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # One or both of the vars are not set, and there is no cached value.
-no_x=yes
-rm -fr conftestdir
-if mkdir conftestdir; then
- cd conftestdir
- # Make sure to not put "make" in the Imakefile rules, since we grep it out.
- cat > Imakefile <<'EOF'
-acfindx:
- @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
-EOF
- if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
- no_x=
- # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
- eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
- # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
- for ac_extension in a so sl; do
- if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
- test -f $ac_im_libdir/libX11.$ac_extension; then
- ac_im_usrlibdir=$ac_im_libdir; break
- fi
- done
- # Screen out bogus values from the imake configuration.
- case "$ac_im_incroot" in
- /usr/include) ;;
- *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;;
- esac
- case "$ac_im_usrlibdir" in
- /usr/lib | /lib) ;;
- *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;;
- esac
- fi
- cd ..
- rm -fr conftestdir
-fi
-
-if test "$no_x" = yes; then
-test -z "$x_direct_test_library" && x_direct_test_library=Xt
-test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
-test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
-cat > conftest.$ac_ext <<EOF
-#line 1352 "configure"
-#include "confdefs.h"
-#include <$x_direct_test_include>
-EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- no_x= ac_x_includes=
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- for ac_dir in \
- /usr/X11R6/include \
- /usr/X11R5/include \
- /usr/X11R4/include \
- \
- /usr/include/X11R6 \
- /usr/include/X11R5 \
- /usr/include/X11R4 \
- \
- /usr/local/X11R6/include \
- /usr/local/X11R5/include \
- /usr/local/X11R4/include \
- \
- /usr/local/include/X11R6 \
- /usr/local/include/X11R5 \
- /usr/local/include/X11R4 \
- \
- /usr/X11/include \
- /usr/include/X11 \
- /usr/local/X11/include \
- /usr/local/include/X11 \
- \
- /usr/X386/include \
- /usr/x386/include \
- /usr/XFree86/include/X11 \
- \
- /usr/include \
- /usr/local/include \
- /usr/unsupported/include \
- /usr/athena/include \
- /usr/local/x11r5/include \
- /usr/lpp/Xamples/include \
- \
- /usr/openwin/include \
- /usr/openwin/share/include \
- ; \
- do
- if test -r "$ac_dir/$x_direct_test_include"; then
- no_x= ac_x_includes=$ac_dir
- break
- fi
- done
-fi
-rm -f conftest*
-
-# Check for the libraries.
-# See if we find them without any special options.
-# Don't add to $LIBS permanently.
-ac_save_LIBS="$LIBS"
-LIBS="-l$x_direct_test_library $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 1415 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-${x_direct_test_function}()
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- LIBS="$ac_save_LIBS" no_x= ac_x_libraries=
-else
- rm -rf conftest*
- LIBS="$ac_save_LIBS"
-# First see if replacing the include by lib works.
-for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
- /usr/X11R6/lib \
- /usr/X11R5/lib \
- /usr/X11R4/lib \
- \
- /usr/lib/X11R6 \
- /usr/lib/X11R5 \
- /usr/lib/X11R4 \
- \
- /usr/local/X11R6/lib \
- /usr/local/X11R5/lib \
- /usr/local/X11R4/lib \
- \
- /usr/local/lib/X11R6 \
- /usr/local/lib/X11R5 \
- /usr/local/lib/X11R4 \
- \
- /usr/X11/lib \
- /usr/lib/X11 \
- /usr/local/X11/lib \
- /usr/local/lib/X11 \
- \
- /usr/X386/lib \
- /usr/x386/lib \
- /usr/XFree86/lib/X11 \
- \
- /usr/lib \
- /usr/local/lib \
- /usr/unsupported/lib \
- /usr/athena/lib \
- /usr/local/x11r5/lib \
- /usr/lpp/Xamples/lib \
- \
- /usr/openwin/lib \
- /usr/openwin/share/lib \
- ; \
-do
- for ac_extension in a so sl; do
- if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
- no_x= ac_x_libraries=$ac_dir
- break 2
- fi
- done
-done
-fi
-rm -f conftest*
-
-fi
-if test "$no_x" = yes; then
- ac_cv_path_x="no_x=yes"
-else
- ac_cv_path_x="no_x= ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
-fi
-fi
- fi
- eval "$ac_cv_path_x"
-fi # $with_x != no
-
-if test "$no_x" = yes; then
- echo "$ac_t""no" 1>&6
-else
- test "x$x_includes" = xNONE && x_includes=$ac_x_includes
- test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
- ac_cv_path_x="no_x= ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
- echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6
-fi
-
-
-if test "$no_x" != yes; then
- if test "X$x_libraries" != "X"; then
- if test "X$RLIBS" = "Xyes"; then
- XLIBS="-R$x_libraries -L$x_libraries $XLIBS"
- else
- XLIBS="-L$x_libraries $XLIBS"
- fi
- fi
- XLIBS="$XLIBS -lX11"
- if test "X$x_includes" != "X"; then
- XINCS="-I$x_includes"
- fi
-fi
-
-
-
-echo $ac_n "checking if --enable-perlinterp option specified""... $ac_c" 1>&6
-# Check whether --enable-perlinterp or --disable-perlinterp was given.
-if test "${enable_perlinterp+set}" = set; then
- enableval="$enable_perlinterp"
- vi_cv_perlinterp="yes"
-else
- vi_cv_perlinterp="no"
-fi
-
-echo "$ac_t""$vi_cv_perlinterp" 1>&6
-if test "$vi_cv_perlinterp" = "yes"; then
- if test "$vi_cv_path_perl" = no; then
- echo "Fatal error: no perl5 utility found."
- exit 1
- fi
- $vi_cv_path_perl -e 'require 5.002' || {
- echo "Fatal error: perl5 must be version 5.002 or later."
- exit 1
- }
- $vi_cv_path_perl -e 'close(STDERR);require 5.003_01' &&
- cat >> confdefs.h <<\EOF
-#define HAVE_PERL_5_003_01 1
-EOF
-
-
- eval `$vi_cv_path_perl -V:shrpenv`
- if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
- shrpenv=""
- fi
- vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
- perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
- -e 'ccflags;perl_inc'`
- if test "X$perlcppflags" != "X"; then
- CPPFLAGS="$perlcppflags $CPPFLAGS"
- fi
- perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
- -e 'ldopts'`
- if test "X$perllibs" != "X"; then
- LIBS="$perllibs $LIBS"
- fi
- perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
- -e 'ccdlflags'`
- if test "X$perlldflags" != "X"; then
- LDFLAGS="$perlldflags $LDFLAGS"
- fi
- LIBOBJS="perl.o perlsfio.o $LIBOBJS"
- cat >> confdefs.h <<\EOF
-#define HAVE_PERL_INTERP 1
-EOF
-
-fi
-
-
-
-echo $ac_n "checking if --enable-tknvi option specified""... $ac_c" 1>&6
-# Check whether --enable-tknvi or --disable-tknvi was given.
-if test "${enable_tknvi+set}" = set; then
- enableval="$enable_tknvi"
- vi_cv_tknvi="yes"
-else
- vi_cv_tknvi="no"
-fi
-
-echo "$ac_t""$vi_cv_tknvi" 1>&6
-if test "$vi_cv_tknvi" = "yes"; then
- tknvi=tknvi
- TKLIBS="-ltk -ltcl -lm $XLIBS $LIBS"
-fi
-
-echo $ac_n "checking if --enable-tclinterp option specified""... $ac_c" 1>&6
-# Check whether --enable-tclinterp or --disable-tclinterp was given.
-if test "${enable_tclinterp+set}" = set; then
- enableval="$enable_tclinterp"
- vi_cv_tclinterp="yes"
-else
- vi_cv_tclinterp="no"
-fi
-
-echo "$ac_t""$vi_cv_tclinterp" 1>&6
-if test "$vi_cv_tclinterp" = "yes"; then
- LIBOBJS="tcl.o $LIBOBJS"
- LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
- cat >> confdefs.h <<\EOF
-#define HAVE_TCL_INTERP 1
-EOF
-
-fi
-
-if test "$vi_cv_tknvi" = "yes" || test "$vi_cv_tclinterp" = "yes"; then
- echo $ac_n "checking for -ltcl""... $ac_c" 1>&6
-ac_lib_var=`echo tcl | tr '.-/+' '___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="-ltcl -ltk -lm $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 1611 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-main()
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- 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
- vi_cv_tkfatal="no"
-else
- echo "$ac_t""no" 1>&6
-vi_cv_tkfatal="yes"
-fi
-
- if test "$vi_cv_tkfatal" = "yes"; then
- echo "Fatal error: no Tk/Tcl library; see the section"
- echo "ADDING LIBRARIES AND INCLUDE FILES in the README file."
- exit 1
- fi
-fi
-
-if test "$vi_cv_tclinterp" = yes || test "$vi_cv_perlinterp" = yes; then
- LIBOBJS="api.o $LIBOBJS"
-fi
-
-echo $ac_n "checking for -ltermlib""... $ac_c" 1>&6
-ac_lib_var=`echo termlib | tr '.-/+' '___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="-ltermlib $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 1657 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-tgetent()
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- 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
- vi_cv_termlib=-ltermlib
-else
- echo "$ac_t""no" 1>&6
-vi_cv_termlib=no
-fi
-
-if test "$vi_cv_termlib" = no; then
- echo $ac_n "checking for -ltermcap""... $ac_c" 1>&6
-ac_lib_var=`echo termcap | tr '.-/+' '___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="-ltermcap $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 1693 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-tgetent()
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- 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
- vi_cv_termlib=-ltermcap
-else
- echo "$ac_t""no" 1>&6
-vi_cv_termlib=no
-fi
-
-fi
-if test "$vi_cv_termlib" != no; then
- LIBS="$vi_cv_termlib $LIBS"
-fi
-
-echo $ac_n "checking if --disable-curses option specified""... $ac_c" 1>&6
-# Check whether --enable-curses or --disable-curses was given.
-if test "${enable_curses+set}" = set; then
- enableval="$enable_curses"
- vi_cv_curses="other curses"
-else
- vi_cv_curses="bundled curses"
-fi
-
-echo "$ac_t""$vi_cv_curses" 1>&6
-case "$vi_cv_curses" in
-"bundled curses")
- CPPFLAGS="-I\$(srcdir)/curses $CPPFLAGS"
- cobjs="\$(COBJS)";;
-"other curses")
- LIBS="-lcurses $LIBS";;
-esac
-
-echo $ac_n "checking for sys/mman.h""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_include_sys_mman'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1748 "configure"
-#include "confdefs.h"
-#include <sys/mman.h>
-EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- vi_cv_include_sys_mman=yes
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- vi_cv_include_sys_mman=no
-fi
-rm -f conftest*
-fi
-
-if test "$vi_cv_include_sys_mman" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_MMAN_H 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_include_sys_mman" 1>&6
-
-echo $ac_n "checking for sys/select.h""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_include_sys_select'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1778 "configure"
-#include "confdefs.h"
-#include <sys/select.h>
-EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- vi_cv_include_sys_select=yes
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- vi_cv_include_sys_select=no
-fi
-rm -f conftest*
-fi
-
-if test "$vi_cv_include_sys_select" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_SELECT_H 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_include_sys_select" 1>&6
-
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1808 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- ac_cv_header_stdc=yes
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 1830 "configure"
-#include "confdefs.h"
-#include <string.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "memchr" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 1848 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "free" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-if test "$cross_compiling" = yes; then
- :
-else
-cat > conftest.$ac_ext <<EOF
-#line 1869 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int main () { int i; for (i = 0; i < 256; i++)
-if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
-exit (0); }
-
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- :
-else
- ac_cv_header_stdc=no
-fi
-fi
-rm -fr conftest*
-fi
-fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
-if test $ac_cv_header_stdc = yes; then
- cat >> confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1904 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "ssize_t" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_ssize_t=yes
-else
- rm -rf conftest*
- ac_cv_type_ssize_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_ssize_t" 1>&6
-if test $ac_cv_type_ssize_t = no; then
- cat >> confdefs.h <<\EOF
-#define ssize_t int
-EOF
-
-fi
-
-echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_cv_c_bigendian=unknown
-# See if sys/param.h defines the BYTE_ORDER macro.
-cat > conftest.$ac_ext <<EOF
-#line 1937 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-int main() { return 0; }
-int t() {
-
-#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
- bogus endian macros
-#endif
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- # It does; now see whether it defined to BIG_ENDIAN or not.
-cat > conftest.$ac_ext <<EOF
-#line 1953 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/param.h>
-int main() { return 0; }
-int t() {
-
-#if BYTE_ORDER != BIG_ENDIAN
- not big endian
-#endif
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- ac_cv_c_bigendian=yes
-else
- rm -rf conftest*
- ac_cv_c_bigendian=no
-fi
-rm -f conftest*
-
-fi
-rm -f conftest*
-
-if test $ac_cv_c_bigendian = unknown; then
-if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 1982 "configure"
-#include "confdefs.h"
-main () {
- /* Are we little or big endian? From Harbison&Steele. */
- union
- {
- long l;
- char c[sizeof (long)];
- } u;
- u.l = 1;
- exit (u.c[sizeof (long) - 1] == 1);
-}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_c_bigendian=no
-else
- ac_cv_c_bigendian=yes
-fi
-fi
-rm -fr conftest*
-fi
-fi
-
-echo "$ac_t""$ac_cv_c_bigendian" 1>&6
-if test $ac_cv_c_bigendian = yes; then
- cat >> confdefs.h <<\EOF
-#define WORDS_BIGENDIAN 1
-EOF
-
-fi
-
-echo $ac_n "checking for working const""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2019 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-
-/* Ultrix mips cc rejects this. */
-typedef int charset[2]; const charset x;
-/* SunOS 4.1.1 cc rejects this. */
-char const *const *ccp;
-char **p;
-/* NEC SVR4.0.2 mips cc rejects this. */
-struct point {int x, y;};
-static struct point const zero = {0,0};
-/* AIX XL C 1.02.0.0 rejects this.
- It does not let you subtract one const X* pointer from another in an arm
- of an if-expression whose if-part is not a constant expression */
-const char *g = "string";
-ccp = &g + (g ? g-g : 0);
-/* HPUX 7.0 cc rejects these. */
-++ccp;
-p = (char**) ccp;
-ccp = (char const *const *) p;
-{ /* SCO 3.2v4 cc rejects this. */
- char *t;
- char const *s = 0 ? (char *) 0 : (char const *) 0;
-
- *t++ = 0;
-}
-{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
- int x[] = {25, 17};
- const int *foo = &x[0];
- ++foo;
-}
-{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
- typedef const int *iptr;
- iptr p = 0;
- ++p;
-}
-{ /* AIX XL C 1.02.0.0 rejects this saying
- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
- struct s { int j; const int *ap[3]; };
- struct s *b; b->j = 5;
-}
-{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
- const int foo = 10;
-}
-
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- ac_cv_c_const=yes
-else
- rm -rf conftest*
- ac_cv_c_const=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_c_const" 1>&6
-if test $ac_cv_c_const = no; then
- cat >> confdefs.h <<\EOF
-#define const
-EOF
-
-fi
-
-echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2093 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-int main() { return 0; }
-int t() {
-struct stat s; s.st_blksize;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- ac_cv_struct_st_blksize=yes
-else
- rm -rf conftest*
- ac_cv_struct_st_blksize=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_struct_st_blksize" 1>&6
-if test $ac_cv_struct_st_blksize = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_ST_BLKSIZE 1
-EOF
-
-fi
-
-echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2126 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "mode_t" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_mode_t=yes
-else
- rm -rf conftest*
- ac_cv_type_mode_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_mode_t" 1>&6
-if test $ac_cv_type_mode_t = no; then
- cat >> confdefs.h <<\EOF
-#define mode_t int
-EOF
-
-fi
-
-echo $ac_n "checking for off_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2157 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "off_t" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_off_t=yes
-else
- rm -rf conftest*
- ac_cv_type_off_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_off_t" 1>&6
-if test $ac_cv_type_off_t = no; then
- cat >> confdefs.h <<\EOF
-#define off_t long
-EOF
-
-fi
-
-echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2188 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pid_t" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_pid_t=yes
-else
- rm -rf conftest*
- ac_cv_type_pid_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_pid_t" 1>&6
-if test $ac_cv_type_pid_t = no; then
- cat >> confdefs.h <<\EOF
-#define pid_t int
-EOF
-
-fi
-
-echo $ac_n "checking for size_t""... $ac_c" 1>&6
-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 <<EOF
-#line 2219 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "size_t" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_size_t=yes
-else
- rm -rf conftest*
- ac_cv_type_size_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_size_t" 1>&6
-if test $ac_cv_type_size_t = no; then
- cat >> confdefs.h <<\EOF
-#define size_t unsigned
-EOF
-
-fi
-
-echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2250 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <time.h>
-int main() { return 0; }
-int t() {
-struct tm *tp; tp->tm_sec;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- ac_cv_struct_tm=time.h
-else
- rm -rf conftest*
- ac_cv_struct_tm=sys/time.h
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_struct_tm" 1>&6
-if test $ac_cv_struct_tm = sys/time.h; then
- cat >> confdefs.h <<\EOF
-#define TM_IN_SYS_TIME 1
-EOF
-
-fi
-
-
- for ac_func in bsearch gethostname getopt memchr memcpy memmove memset
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2286 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_func in bsearch gethostname getopt memchr memcpy memmove memset
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2337 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-LIBOBJS="$LIBOBJS ${ac_func}.o"
-fi
-
-done
-
- for ac_func in mkstemp mmap snprintf strdup strerror strpbrk strtol
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2386 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_func in mkstemp mmap snprintf strdup strerror strpbrk strtol
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2437 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-LIBOBJS="$LIBOBJS ${ac_func}.o"
-fi
-
-done
-
- for ac_func in strtoul vsnprintf
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2486 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_func in strtoul vsnprintf
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2537 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-LIBOBJS="$LIBOBJS ${ac_func}.o"
-fi
-
-done
-
-
-for ac_func in select
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2587 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_func in setenv
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2638 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
- need_env=no
-else
- echo "$ac_t""no" 1>&6
-need_env=yes
-fi
-done
-
-for ac_func in strsep
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2690 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
- need_strsep=no
-else
- echo "$ac_t""no" 1>&6
-need_strsep=yes
-fi
-done
-
-for ac_func in unsetenv
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2742 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-need_env=yes
-fi
-done
-
-
-for ac_func in valloc getpagesize
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-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 <<EOF
-#line 2795 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char $ac_func();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_mmap'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_func_mmap=no
-else
-cat > conftest.$ac_ext <<EOF
-#line 2847 "configure"
-#include "confdefs.h"
-
-/* Thanks to Mike Haertel and Jim Avera for this test. */
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#ifndef HAVE_GETPAGESIZE
-# include <sys/param.h>
-# ifdef EXEC_PAGESIZE
-# define getpagesize() EXEC_PAGESIZE
-# else
-# ifdef NBPG
-# define getpagesize() NBPG * CLSIZE
-# ifndef CLSIZE
-# define CLSIZE 1
-# endif
-# else
-# ifdef NBPC
-# define getpagesize() NBPC
-# else
-# define getpagesize() PAGESIZE /* SVR4 */
-# endif
-# endif
-# endif
-#endif
-
-#ifndef HAVE_VALLOC
-# define valloc malloc
-#endif
-
-#ifdef __cplusplus
-extern "C" { void *valloc(unsigned), *malloc(unsigned); }
-#else
-char *valloc(), *malloc();
-#endif
-
-int
-main()
-{
- char *buf1, *buf2, *buf3;
- int i = getpagesize(), j;
- int i2 = i * 2;
- int fd;
-
- buf1 = (char *)valloc(i2);
- buf2 = (char *)valloc(i);
- buf3 = (char *)malloc(i2);
- for (j = 0; j < i2; ++j)
- *(buf1 + j) = rand();
- fd = open("conftestmmap", O_CREAT | O_RDWR, 0666);
- write(fd, buf1, i2);
- mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0);
- for (j = 0; j < i; ++j)
- if (*(buf1 + j) != *(buf2 + j))
- exit(1);
- lseek(fd, (long)i, 0);
- read(fd, buf2, i); /* read into mapped memory -- file should not change */
- /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */
- lseek(fd, (long)0, 0);
- read(fd, buf3, i2);
- for (j = 0; j < i2; ++j)
- if (*(buf1 + j) != *(buf3 + j))
- exit(1);
- exit(0);
-}
-
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_func_mmap=yes
-else
- ac_cv_func_mmap=no
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_func_mmap" 1>&6
-if test $ac_cv_func_mmap = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_MMAP 1
-EOF
-
-fi
-
-ac_safe=`echo "vfork.h" | tr './\055' '___'`
-echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-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
-#line 2940 "configure"
-#include "confdefs.h"
-#include <vfork.h>
-EOF
-eval "$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_VFORK_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- echo $ac_n "checking for vfork""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2976 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char vfork(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-char vfork();
-
-int main() { return 0; }
-int t() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_vfork) || defined (__stub___vfork)
-choke me
-#else
-vfork();
-#endif
-
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- eval "ac_cv_func_vfork=yes"
-else
- rm -rf conftest*
- eval "ac_cv_func_vfork=no"
-fi
-rm -f conftest*
-
-fi
-if eval "test \"`echo '$ac_cv_func_'vfork`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-fi
-
-else
-cat > conftest.$ac_ext <<EOF
-#line 3017 "configure"
-#include "confdefs.h"
-/* Thanks to Paul Eggert for this test. */
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_VFORK_H
-#include <vfork.h>
-#endif
-/* On some sparc systems, changes by the child to local and incoming
- argument registers are propagated back to the parent.
- The compiler is told about this with #include <vfork.h>,
- but some compilers (e.g. gcc -O) don't grok <vfork.h>.
- Test for this by using a static variable whose address
- is put into a register that is clobbered by the vfork. */
-static
-#ifdef __cplusplus
-sparc_address_test (int arg)
-#else
-sparc_address_test (arg) int arg;
-#endif
-{
- static pid_t child;
- if (!child) {
- child = vfork ();
- if (child < 0)
- perror ("vfork");
- if (!child) {
- arg = getpid();
- write(-1, "", 0);
- _exit (arg);
- }
- }
-}
-main() {
- pid_t parent = getpid ();
- pid_t child;
-
- sparc_address_test ();
-
- child = vfork ();
-
- if (child == 0) {
- /* Here is another test for sparc vfork register problems.
- This test uses lots of local variables, at least
- as many local variables as main has allocated so far
- including compiler temporaries. 4 locals are enough for
- gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe.
- A buggy compiler should reuse the register of parent
- for one of the local variables, since it will think that
- parent can't possibly be used any more in this routine.
- Assigning to the local variable will thus munge parent
- in the parent process. */
- pid_t
- p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
- p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
- /* Convince the compiler that p..p7 are live; otherwise, it might
- use the same hardware register for all 8 local variables. */
- if (p != p1 || p != p2 || p != p3 || p != p4
- || p != p5 || p != p6 || p != p7)
- _exit(1);
-
- /* On some systems (e.g. IRIX 3.3),
- vfork doesn't separate parent from child file descriptors.
- If the child closes a descriptor before it execs or exits,
- this munges the parent's descriptor as well.
- Test for this by closing stdout in the child. */
- _exit(close(fileno(stdout)) != 0);
- } else {
- int status;
- struct stat st;
-
- while (wait(&status) != child)
- ;
- exit(
- /* Was there some problem with vforking? */
- child < 0
-
- /* Did the child fail? (This shouldn't happen.) */
- || status
-
- /* Did the vfork/compiler bug occur? */
- || parent != getpid()
-
- /* Did the file descriptor bug occur? */
- || fstat(fileno(stdout), &st) != 0
- );
- }
-}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- ac_cv_func_vfork=yes
-else
- ac_cv_func_vfork=no
-fi
-fi
-rm -fr conftest*
-fi
-
-echo "$ac_t""$ac_cv_func_vfork" 1>&6
-if test $ac_cv_func_vfork = no; then
- cat >> confdefs.h <<\EOF
-#define vfork fork
-EOF
-
-fi
-
-
-if test "$need_env" = yes; then
- LIBOBJS="env.o $LIBOBJS"
-fi
-
-if test "$need_strsep" = yes; then
- LIBOBJS="strsep.o $LIBOBJS"
-fi
-
-echo $ac_n "checking for fcntl/flock""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_lock'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- vi_cv_lock=none
- case "$host_os" in
- dgux*);;
- irix*);;
- *)
- cat > conftest.$ac_ext <<EOF
-#line 3147 "configure"
-#include "confdefs.h"
-#include <fcntl.h>
-int main() { return 0; }
-int t() {
-flock(0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_lock=flock
-fi
-rm -f conftest*
-;;
- esac
- if test "$vi_cv_lock" = none; then
- cat > conftest.$ac_ext <<EOF
-#line 3164 "configure"
-#include "confdefs.h"
-#include <fcntl.h>
-int main() { return 0; }
-int t() {
-fcntl(0, F_SETLK, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_lock=fcntl
-fi
-rm -f conftest*
-
- fi
-fi
-
-
-if test "$vi_cv_lock" = flock; then
- cat >> confdefs.h <<\EOF
-#define HAVE_LOCK_FLOCK 1
-EOF
-
-fi
-if test "$vi_cv_lock" = fcntl; then
- cat >> confdefs.h <<\EOF
-#define HAVE_LOCK_FCNTL 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_lock" 1>&6
-
-echo $ac_n "checking for ftruncate/chsize""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_ftruncate'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3201 "configure"
-#include "confdefs.h"
-#include <unistd.h>
-int main() { return 0; }
-int t() {
-ftruncate(0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_ftruncate=ftruncate
-else
- rm -rf conftest*
- cat > conftest.$ac_ext <<EOF
-#line 3215 "configure"
-#include "confdefs.h"
-#include <unistd.h>
-int main() { return 0; }
-int t() {
-chsize(0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_ftruncate=chsize
-else
- rm -rf conftest*
- vi_cv_ftruncate=no
-fi
-rm -f conftest*
-
-fi
-rm -f conftest*
-
-fi
-
-if test "$vi_cv_ftruncate" = ftruncate; then
- cat >> confdefs.h <<\EOF
-#define HAVE_FTRUNCATE_FTRUNCATE 1
-EOF
-
-fi
-if test "$vi_cv_ftruncate" = chsize; then
- cat >> confdefs.h <<\EOF
-#define HAVE_FTRUNCATE_CHSIZE 1
-EOF
-
-fi
-if test "$vi_cv_ftruncate" = no; then
- echo
- echo "Fatal error: no file truncation system call."
- exit 1
-fi
-echo "$ac_t""$vi_cv_ftruncate" 1>&6
-
-echo $ac_n "checking for tigetstr/tigetnum""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_have_curses_tigetstr'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3261 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-tigetstr(0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_tigetstr=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_tigetstr=no
-fi
-rm -f conftest*
-
-fi
-
-if test "$vi_cv_have_curses_tigetstr" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_TIGETSTR 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_have_curses_tigetstr" 1>&6
-
-if test "$vi_cv_curses" = "bundled curses"; then
- cat >> confdefs.h <<\EOF
-#define HAVE_BSD_CURSES 1
-EOF
-
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_ADDNSTR 1
-EOF
-
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_IDLOK 1
-EOF
-
-else
- echo $ac_n "checking for addnstr""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'vi_cv_have_curses_addnstr'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3307 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-addnstr(0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_addnstr=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_addnstr=no
-fi
-rm -f conftest*
-
-fi
-
- if test "$vi_cv_have_curses_addnstr" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_ADDNSTR 1
-EOF
-
- fi
- echo "$ac_t""$vi_cv_have_curses_addnstr" 1>&6
-
- echo $ac_n "checking for beep""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'vi_cv_have_curses_beep'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3339 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-beep();
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_beep=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_beep=no
-fi
-rm -f conftest*
-
-fi
-
- if test "$vi_cv_have_curses_beep" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_BEEP 1
-EOF
-
- fi
- echo "$ac_t""$vi_cv_have_curses_beep" 1>&6
-
- echo $ac_n "checking for flash""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'vi_cv_have_curses_flash'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3371 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-flash();
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_flash=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_flash=no
-fi
-rm -f conftest*
-
-fi
-
- if test "$vi_cv_have_curses_flash" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_FLASH 1
-EOF
-
- fi
- echo "$ac_t""$vi_cv_have_curses_flash" 1>&6
-
- echo $ac_n "checking for idlok""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'vi_cv_have_curses_idlok'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3403 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-idlok(0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_idlok=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_idlok=no
-fi
-rm -f conftest*
-
-fi
-
- if test "$vi_cv_have_curses_idlok" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_IDLOK 1
-EOF
-
- fi
- echo "$ac_t""$vi_cv_have_curses_idlok" 1>&6
-
- echo $ac_n "checking for keypad""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'vi_cv_have_curses_keypad'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3435 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-keypad(0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_keypad=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_keypad=no
-fi
-rm -f conftest*
-
-fi
-
- if test "$vi_cv_have_curses_keypad" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_KEYPAD 1
-EOF
-
- fi
- echo "$ac_t""$vi_cv_have_curses_keypad" 1>&6
-
- echo $ac_n "checking for newterm""... $ac_c" 1>&6
- if eval "test \"`echo '$''{'vi_cv_have_curses_newterm'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3467 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-newterm(0, 0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_newterm=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_newterm=no
-fi
-rm -f conftest*
-
-fi
-
- if test "$vi_cv_have_curses_newterm" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_NEWTERM 1
-EOF
-
- fi
- echo "$ac_t""$vi_cv_have_curses_newterm" 1>&6
-
- if test "$vi_cv_have_curses_newterm" = no; then
- cat >> confdefs.h <<\EOF
-#define HAVE_BSD_CURSES 1
-EOF
-
- fi
-fi
-
-echo $ac_n "checking for setupterm""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_have_curses_setupterm'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3507 "configure"
-#include "confdefs.h"
-#include <curses.h>
-int main() { return 0; }
-int t() {
-setupterm(0, 0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_have_curses_setupterm=yes
-else
- rm -rf conftest*
- vi_cv_have_curses_setupterm=no
-fi
-rm -f conftest*
-
-fi
-
-if test "$vi_cv_have_curses_setupterm" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_CURSES_SETUPTERM 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_have_curses_setupterm" 1>&6
-
-echo $ac_n "checking for broken gettimeofday system call""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_gettimeofday'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3539 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/time.h>
-int main() { return 0; }
-int t() {
-gettimeofday(0, 0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_gettimeofday=okay
-else
- rm -rf conftest*
- vi_cv_gettimeofday=broken
-fi
-rm -f conftest*
-
-fi
-
-if test "$vi_cv_gettimeofday" = broken; then
- cat >> confdefs.h <<\EOF
-#define HAVE_BROKEN_GETTIMEOFDAY 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_gettimeofday" 1>&6
-
-echo $ac_n "checking for System V pty calls""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_sys5_pty'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3572 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-grantpt(0);
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_sys5_pty=yes
-else
- rm -rf conftest*
- vi_cv_sys5_pty=no
-fi
-rm -f conftest*
-
-fi
-
-if test "$vi_cv_sys5_pty" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS5_PTY 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_sys5_pty" 1>&6
-
-echo $ac_n "checking for revoke system call""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_revoke'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3604 "configure"
-#include "confdefs.h"
-
-int main() { return 0; }
-int t() {
-revoke("a");
-; return 0; }
-EOF
-if eval $ac_link; then
- rm -rf conftest*
- vi_cv_revoke=yes
-else
- rm -rf conftest*
- vi_cv_revoke=no
-fi
-rm -f conftest*
-
-fi
-
-if test "$vi_cv_revoke" = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_REVOKE 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_revoke" 1>&6
-
-echo $ac_n "checking for int type sprintf return value""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_sprintf_count'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3639 "configure"
-#include "confdefs.h"
-main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_sprintf_count=yes
-else
- vi_cv_sprintf_count=no
-fi
-fi
-rm -fr conftest*
-fi
-
-if test "$vi_cv_sprintf_count" = no; then
- cat >> confdefs.h <<\EOF
-#define SPRINTF_RET_CHARPNT 1
-EOF
-
-fi
-echo "$ac_t""$vi_cv_sprintf_count" 1>&6
-
-echo $ac_n "checking if --disable-db option specified""... $ac_c" 1>&6
-# Check whether --enable-db or --disable-db was given.
-if test "${enable_db+set}" = set; then
- enableval="$enable_db"
- vi_cv_db_lib="other DB"
-else
- vi_cv_db_lib="bundled DB"
-fi
-
-echo "$ac_t""$vi_cv_db_lib" 1>&6
-case "$vi_cv_db_lib" in
-"bundled DB")
- CPPFLAGS="-I\$(srcdir)/db/include $CPPFLAGS"
- LIBOBJS="\$(DBOBJS) $LIBOBJS";;
-"other DB")
- ;;
-esac
-
-echo $ac_n "checking if --disable-re option specified""... $ac_c" 1>&6
-# Check whether --enable-re or --disable-re was given.
-if test "${enable_re+set}" = set; then
- enableval="$enable_re"
- vi_cv_re_lib="other RE"
-else
- vi_cv_re_lib="bundled RE"
-fi
-
-echo "$ac_t""$vi_cv_re_lib" 1>&6
-case "$vi_cv_re_lib" in
-"bundled RE")
- CPPFLAGS="-I\$(srcdir)/regex $CPPFLAGS"
- LIBOBJS="\$(REOBJS) $LIBOBJS";;
-"other RE")
- ;;
-esac
-
-
-echo $ac_n "checking for u_char""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_uchar'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3703 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-u_char foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_uchar=yes
-else
- rm -rf conftest*
- vi_cv_uchar=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_uchar" 1>&6
-if test "$vi_cv_uchar" = no; then
- u_char_decl="typedef unsigned char u_char;"
-fi
-
-
-echo $ac_n "checking for u_short""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_ushort'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3733 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-u_short foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_ushort=yes
-else
- rm -rf conftest*
- vi_cv_ushort=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_ushort" 1>&6
-if test "$vi_cv_ushort" = no; then
- u_short_decl="typedef unsigned short u_short;"
-fi
-
-
-echo $ac_n "checking for u_int""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_uint'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3763 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-u_int foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_uint=yes
-else
- rm -rf conftest*
- vi_cv_uint=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_uint" 1>&6
-if test "$vi_cv_uint" = no; then
- u_int_decl="typedef unsigned int u_int;"
-fi
-
-
-echo $ac_n "checking for u_long""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_ulong'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3793 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-u_long foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_ulong=yes
-else
- rm -rf conftest*
- vi_cv_ulong=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_ulong" 1>&6
-if test "$vi_cv_ulong" = no; then
- u_long_decl="typedef unsigned long u_long;"
-fi
-
-
-echo $ac_n "checking for u_int8_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_uint8'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3823 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-u_int8_t foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_uint8=yes
-else
- rm -rf conftest*
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3840 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(unsigned char) != 1);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_uint8="unsigned char"
-else
- vi_cv_uint8=no
-fi
-fi
-rm -fr conftest*
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_uint8" 1>&6
-if test "$vi_cv_uint8" = no; then
- echo
- echo "Fatal error: no unsigned, 8-bit integral type."
- exit 1
-fi
-if test "$vi_cv_uint8" != yes; then
- u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
-fi
-
-
-echo $ac_n "checking for u_int16_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_uint16'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3873 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-u_int16_t foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_uint16=yes
-else
- rm -rf conftest*
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3890 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(unsigned short) != 2);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_uint16="unsigned short"
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3902 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(unsigned int) != 2);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_uint16="unsigned int"
-else
- vi_cv_uint16=no
-fi
-fi
-rm -fr conftest*
-fi
-fi
-rm -fr conftest*
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_uint16" 1>&6
-if test "$vi_cv_uint16" = no; then
- echo
- echo "Fatal error: no unsigned, 16-bit integral type."
- exit 1
-fi
-if test "$vi_cv_uint16" != yes; then
- u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
-fi
-
-
-echo $ac_n "checking for int16_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_int16'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3938 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-int16_t foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_int16=yes
-else
- rm -rf conftest*
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3955 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(short) != 2);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_int16="short"
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 3967 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(int) != 2);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_int16="int"
-else
- vi_cv_int16=no
-fi
-fi
-rm -fr conftest*
-fi
-fi
-rm -fr conftest*
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_int16" 1>&6
-if test "$vi_cv_int16" = no; then
- echo
- echo "Fatal error: no signed, 16-bit integral type."
- exit 1
-fi
-if test "$vi_cv_int16" != yes; then
- int16_decl="typedef $vi_cv_int16 int16_t;"
-fi
-
-
-echo $ac_n "checking for u_int32_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_uint32'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4003 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-u_int32_t foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_uint32=yes
-else
- rm -rf conftest*
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 4020 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(unsigned int) != 4);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_uint32="unsigned int"
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 4032 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(unsigned long) != 4);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_uint32="unsigned long"
-else
- vi_cv_uint32=no
-fi
-fi
-rm -fr conftest*
-fi
-fi
-rm -fr conftest*
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_uint32" 1>&6
-if test "$vi_cv_uint32" = no; then
- echo
- echo "Fatal error: no unsigned, 32-bit integral type."
- exit 1
-fi
-if test "$vi_cv_uint32" != yes; then
- u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
-fi
-
-
-echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-if eval "test \"`echo '$''{'vi_cv_int32'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4068 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int main() { return 0; }
-int t() {
-int32_t foo;
-; return 0; }
-EOF
-if eval $ac_compile; then
- rm -rf conftest*
- vi_cv_int32=yes
-else
- rm -rf conftest*
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 4085 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(int) != 4);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_int32="int"
-else
- if test "$cross_compiling" = yes; then
- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-cat > conftest.$ac_ext <<EOF
-#line 4097 "configure"
-#include "confdefs.h"
-main(){exit(sizeof(long) != 4);}
-EOF
-eval $ac_link
-if test -s conftest && (./conftest; exit) 2>/dev/null; then
- vi_cv_int32="long"
-else
- vi_cv_int32=no
-fi
-fi
-rm -fr conftest*
-fi
-fi
-rm -fr conftest*
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$vi_cv_int32" 1>&6
-if test "$vi_cv_int32" = no; then
- echo
- echo "Fatal error: no signed, 32-bit integral type."
- exit 1
-fi
-if test "$vi_cv_int32" != yes; then
- int32_decl="typedef $vi_cv_int32 int32_t;"
-fi
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \
- >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-DEFS=-DHAVE_CONFIG_H
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- 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.7"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-
-trap 'rm -fr `echo "Makefile port.h:port.h.in
- pathnames.h:pathnames.h.in recover:recover.in config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@host@%$host%g
-s%@host_alias@%$host_alias%g
-s%@host_cpu@%$host_cpu%g
-s%@host_vendor@%$host_vendor%g
-s%@host_os@%$host_os%g
-s%@CC@%$CC%g
-s%@OPTFLAG@%$OPTFLAG%g
-s%@no_op_OPTFLAG@%$no_op_OPTFLAG%g
-s%@vi_cv_path_shell@%$vi_cv_path_shell%g
-s%@vi_cv_path_sendmail@%$vi_cv_path_sendmail%g
-s%@vi_cv_path_perl@%$vi_cv_path_perl%g
-s%@vi_cv_path_preserve@%$vi_cv_path_preserve%g
-s%@vi_cv_path_chmod@%$vi_cv_path_chmod%g
-s%@vi_cv_path_cp@%$vi_cv_path_cp%g
-s%@vi_cv_path_ln@%$vi_cv_path_ln%g
-s%@vi_cv_path_mkdir@%$vi_cv_path_mkdir%g
-s%@vi_cv_path_rm@%$vi_cv_path_rm%g
-s%@vi_cv_path_strip@%$vi_cv_path_strip%g
-s%@CPP@%$CPP%g
-s%@XINCS@%$XINCS%g
-s%@shrpenv@%$shrpenv%g
-s%@vi_cv_perllib@%$vi_cv_perllib%g
-s%@tknvi@%$tknvi%g
-s%@TKLIBS@%$TKLIBS%g
-s%@cobjs@%$cobjs%g
-s%@LIBOBJS@%$LIBOBJS%g
-s%@u_char_decl@%$u_char_decl%g
-s%@u_short_decl@%$u_short_decl%g
-s%@u_int_decl@%$u_int_decl%g
-s%@u_long_decl@%$u_long_decl%g
-s%@u_int8_decl@%$u_int8_decl%g
-s%@u_int16_decl@%$u_int16_decl%g
-s%@int16_decl@%$int16_decl%g
-s%@u_int32_decl@%$u_int32_decl%g
-s%@int32_decl@%$int32_decl%g
-
-CEOF
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile port.h:port.h.in
- pathnames.h:pathnames.h.in recover:recover.in"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust relative srcdir, etc. for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file
-fi; done
-rm -f conftest.subs
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-CONFIG_HEADERS=${CONFIG_HEADERS-"config.h"}
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo creating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- cp $ac_given_srcdir/$ac_file_in conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-# Maximum number of lines to put in a single here document.
-ac_max_here_lines=12
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
diff --git a/build/configure.in b/build/configure.in
deleted file mode 100644
index cb8e4637d957..000000000000
--- a/build/configure.in
+++ /dev/null
@@ -1,725 +0,0 @@
-dnl @(#)configure.in 8.134 (Berkeley) 10/15/96
-
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(../common/main.c)
-AC_CONFIG_HEADER(config.h)
-
-dnl Configure setup.
-AC_PROG_INSTALL()
-AC_CANONICAL_HOST
-AC_ARG_PROGRAM()
-
-dnl If the user wants a debugging environment, set OPTFLAG now. (Some
-dnl compilers won't mix optimizing and debug flags.)
-AC_MSG_CHECKING(if --enable-debug option specified)
-AC_ARG_ENABLE(debug,
- [ --enable-debug Build a debugging version.],
- [vi_cv_debug="yes"], [vi_cv_debug="no"])
-if test "$vi_cv_debug" = yes; then
- AC_DEFINE(DEBUG)
- OPTFLAG=${OPTFLAG-"-g"}
- no_op_OPTFLAG=${no_op_OPTFLAG-"-g"}
-fi
-AC_MSG_RESULT($vi_cv_debug)
-
-dnl This is where we handle stuff that autoconf can't handle.
-dnl XXX
-dnl Don't override anything if it's already set from the environment.
-
-dnl Compiler, preprocessor and load flags.
-dnl AUX: -ZP disables _BSD_SOURCE et al, but enables POSIX at link time.
-dnl LynxOS: We check for gcc 2.x or better, the gcc 1 that was shipped with
-dnl LynxOS historically wasn't good enough.
-AC_SUBST(CPPFLAGS)
-case "$host_os" in
-aix3.2.5) OPTFLAG=${OPTFLAG-"-O"};;
-aix4.1*) CFLAGS=${CFLAGS-"-qstrict"}
- OPTFLAG=${OPTFLAG-"-O3"};;
-aux*) CPPFLAGS=${CPPFLAGS-"-ZP -D_BSD_SOURCE -D_SYSV_SOURCE -D_AUX_SOURCE"}
- LDFLAGS=${LDFLAGS-"-ZP"}
- OPTFLAG=${OPTFLAG-"-O"};;
-bsd4.4) OPTFLAG=${OPTFLAG-"-O2"};;
-bsdi*) CC=${CC-"shlicc"}
- OPTFLAG=${OPTFLAG-"-O2"};;
-irix6*) OPTFLAG=${OPTFLAG-"-O2"};;
-irix*) OPTFLAG=${OPTFLAG-"-O2"};;
-lynxos*) AC_PROG_CC()
- AC_MSG_CHECKING([for GNU C (gcc) version 2.x])
- ac_cv_gcc_vers=`${CC-cc} -v 2>&1 | \
- grep "gcc version " | sed 's/.*version //'`
- ac_cv_gcc_major=`echo "$ac_cv_gcc_vers" | sed 's/\..*//'`
- if test "$ac_cv_gcc_major" = "2" ; then
- AC_MSG_RESULT(yes)
- else
- AC_MSG_RESULT(no)
- echo "Fatal error: Nvi requires gcc 2.x to build on LynxOS."
- echo "See build/README.LynxOS for more information."
- exit 1
- fi;;
-nextstep3) CPPFLAGS=${CPPFLAGS-"-w -pipe -posix"}
- LDFLAGS=${LDFLAGS-"-posix"}
- OPTFLAG=${OPTFLAG-"-O9"};;
-osf*) CFLAGS=${CFLAGS-"-Olimit 1000"};;
-solaris*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
-sunos*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
-esac
-
-dnl The default compiler is cc.
-AC_SUBST(CC)
-CC=${CC-cc}
-
-dnl The default OPTFLAG is -O
-AC_SUBST(OPTFLAG)
-OPTFLAG=${OPTFLAG-"-O"}
-
-dnl The SunOS/Solaris compiler can't optimize vi/v_txt.c; the symptom is
-dnl that the command 35i==<esc> turns into an infinite loop.
-AC_SUBST(no_op_OPTFLAG)
-no_op_OPTFLAG=${no_op_OPTFLAG-"$OPTFLAG"}
-
-dnl Libraries.
-case "$host_os" in
-bsdi2.1) LIBS=${LIBS-"-lipc"};;
-dgux*) LIBS=${LIBS-"-ldgc"};;
-irix6*) LIBS=${LIBS-"-lbsd"};;
-irix*) LIBS=${LIBS-"-lc_s -lbsd"};;
-isc*) LIBS=${LIBS-"-lcposix -linet"};;
-netbsd1*) LIBS=${LIBS-"-lcrypt"};;
-ptx*) LIBS=${LIBS-"-lseq -linet -lsocket"};;
-sco3.2*) LIBS=${LIBS-"-lsocket"};;
-sinix*) LIBS=${LIBS-"-lelf -lc"};;
-solaris*) LIBS=${LIBS-"-lsocket -lnsl -ldl"}
- RLIBS=yes;;
-wgs*) LIBS=${LIBS-"-lnsl"};;
-esac
-
-dnl A/UX has a broken getopt(3), strpbrk(3).
-case "$host_os" in
-aux*) LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
-esac
-
-dnl Ultrix has a broken POSIX.1 VDISABLE value.
-case "$host_os" in
-ultrix*) AC_DEFINE(HAVE_BROKEN_VDISABLE);;
-esac
-
-dnl The user may have additional CPP information.
-CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
-
-dnl The user may have additional load line information.
-LDFLAGS="$ADDLDFLAGS $LDFLAGS"
-
-dnl The user may have additional library information.
-LIBS="$ADDLIBS $LIBS"
-
-dnl Check to see if it's going to work.
-AM_SANITY_CHECK_CC
-
-dnl Checks for programs.
-PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib:"
-
-dnl Check for the shell path.
-AC_PATH_PROG(vi_cv_path_shell, sh, no)
-if test "$vi_cv_path_shell" = no; then
- echo "Fatal error: the shell utility not found."
- exit 1
-fi
-
-dnl Check for the sendmail path.
-AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
-if test "$vi_cv_path_sendmail" = no; then
- echo "WARNING: The sendmail utility was not found!"
- echo "WARNING: Users will not be told of saved files."
-fi
-
-dnl Check for the perl5/perl path.
-AC_SUBST(vi_cv_path_perl)
-AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
-
-dnl Check for the "preserve" path.
-dnl Historically, nvi has used /var/tmp/vi.recover. The Linux filesystem
-dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
-dnl beneath it so that we don't have name collisions with other editors.
-dnl Other systems have /var/preserve as well, so we test first for an already
-dnl existing name, and then use the first one that's writeable.
-AC_SUBST(vi_cv_path_preserve)
-AC_MSG_CHECKING(for preserve directory)
-AC_CACHE_VAL(vi_cv_path_preserve, [dnl
- dirlist="/var/preserve /var/tmp /usr/tmp"
- vi_cv_path_preserve=no
- for i in $dirlist; do
- if test -d $i/vi.recover; then
- vi_cv_path_preserve=$i/vi.recover
- break;
- fi
- done
- if test "$vi_cv_path_preserve" = no; then
- for i in $dirlist; do
- if test -d $i -a -w $i; then
- vi_cv_path_preserve=$i/vi.recover
- break;
- fi
- done
-
- fi])
-if test "$vi_cv_path_preserve" = no; then
- echo "Fatal error: no writeable preserve directory found."
- exit 1
-fi
-AC_MSG_RESULT($vi_cv_path_preserve)
-
-dnl Check for programs used for installation
-AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
-AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
-AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
-AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
-AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
-AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
-
-dnl Checks for libraries.
-dnl Find the X libraries and includes.
-AC_PATH_X
-AC_SUBST(XINCS)
-if test "$no_x" != yes; then
- if test "X$x_libraries" != "X"; then
- if test "X$RLIBS" = "Xyes"; then
- XLIBS="-R$x_libraries -L$x_libraries $XLIBS"
- else
- XLIBS="-L$x_libraries $XLIBS"
- fi
- fi
- XLIBS="$XLIBS -lX11"
- if test "X$x_includes" != "X"; then
- XINCS="-I$x_includes"
- fi
-fi
-
-dnl If the user wants a Perl interpreter in nvi, load it.
-AC_SUBST(shrpenv)
-AC_SUBST(vi_cv_perllib)
-AC_MSG_CHECKING(if --enable-perlinterp option specified)
-AC_ARG_ENABLE(perlinterp,
- [ --enable-perlinterp Include a Perl interpreter in vi.],
- [vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
-AC_MSG_RESULT($vi_cv_perlinterp)
-if test "$vi_cv_perlinterp" = "yes"; then
- if test "$vi_cv_path_perl" = no; then
- echo "Fatal error: no perl5 utility found."
- exit 1
- fi
- $vi_cv_path_perl -e 'require 5.002' || {
- echo "Fatal error: perl5 must be version 5.002 or later."
- exit 1
- }
- $vi_cv_path_perl -e 'close(STDERR);require 5.003_01' &&
- AC_DEFINE(HAVE_PERL_5_003_01)
-
- eval `$vi_cv_path_perl -V:shrpenv`
- if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
- shrpenv=""
- fi
- vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
- perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
- -e 'ccflags;perl_inc'`
- if test "X$perlcppflags" != "X"; then
- CPPFLAGS="$perlcppflags $CPPFLAGS"
- fi
- perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
- -e 'ldopts'`
- if test "X$perllibs" != "X"; then
- LIBS="$perllibs $LIBS"
- fi
- perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
- -e 'ccdlflags'`
- if test "X$perlldflags" != "X"; then
- LDFLAGS="$perlldflags $LDFLAGS"
- fi
- LIBOBJS="perl.o perlsfio.o $LIBOBJS"
- AC_DEFINE(HAVE_PERL_INTERP)
-fi
-
-dnl If the user wants a Tk/Tcl front-end for nvi, build it.
-AC_SUBST(tknvi)
-AC_SUBST(TKLIBS)
-AC_MSG_CHECKING(if --enable-tknvi option specified)
-AC_ARG_ENABLE(tknvi,
- [ --enable-tknvi Build a Tk/Tcl front-end for vi.],
- [vi_cv_tknvi="yes"], [vi_cv_tknvi="no"])
-AC_MSG_RESULT($vi_cv_tknvi)
-if test "$vi_cv_tknvi" = "yes"; then
- tknvi=tknvi
- TKLIBS="-ltk -ltcl -lm $XLIBS $LIBS"
-fi
-
-dnl If the user wants a Tk/Tcl interpreter in nvi, load it.
-AC_MSG_CHECKING(if --enable-tclinterp option specified)
-AC_ARG_ENABLE(tclinterp,
- [ --enable-tclinterp Include a Tk/Tcl interpreter in vi.],
- [vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
-AC_MSG_RESULT($vi_cv_tclinterp)
-if test "$vi_cv_tclinterp" = "yes"; then
- LIBOBJS="tcl.o $LIBOBJS"
- LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
- AC_DEFINE(HAVE_TCL_INTERP)
-fi
-
-dnl Make sure that we can find a Tk/Tcl library.
-if test "$vi_cv_tknvi" = "yes" || test "$vi_cv_tclinterp" = "yes"; then
- AC_CHECK_LIB(tcl, main,
- [vi_cv_tkfatal="no"], [vi_cv_tkfatal="yes"], -ltk -lm)
- if test "$vi_cv_tkfatal" = "yes"; then
- echo "Fatal error: no Tk/Tcl library; see the section"
- echo "ADDING LIBRARIES AND INCLUDE FILES in the README file."
- exit 1
- fi
-fi
-
-dnl Both Tcl/Tk and Perl interpreters need the vi api code.
-if test "$vi_cv_tclinterp" = yes || test "$vi_cv_perlinterp" = yes; then
- LIBOBJS="api.o $LIBOBJS"
-fi
-
-dnl Check for the termcap/termlib library. Compile in nvi's curses routines
-dnl unless the user specifies otherwise. These two checks must occur in the
-dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
-AC_CHECK_LIB(termlib, tgetent,
- [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
-if test "$vi_cv_termlib" = no; then
- AC_CHECK_LIB(termcap, tgetent,
- [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
-fi
-if test "$vi_cv_termlib" != no; then
- LIBS="$vi_cv_termlib $LIBS"
-fi
-AC_SUBST(cobjs)
-AC_MSG_CHECKING(if --disable-curses option specified)
-AC_ARG_ENABLE(curses,
- [ --disable-curses DON'T use the nvi-provided curses routines.],
- [vi_cv_curses="other curses"], [vi_cv_curses="bundled curses"])
-AC_MSG_RESULT($vi_cv_curses)
-case "$vi_cv_curses" in
-"bundled curses")
- CPPFLAGS="-I\$(srcdir)/curses $CPPFLAGS"
- cobjs="\$(COBJS)";;
-"other curses")
- LIBS="-lcurses $LIBS";;
-esac
-
-dnl Checks for header files.
-AC_MSG_CHECKING(for sys/mman.h)
-AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
-AC_TRY_CPP([#include <sys/mman.h>],
- [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
-if test "$vi_cv_include_sys_mman" = yes; then
- AC_DEFINE(HAVE_SYS_MMAN_H)
-fi
-AC_MSG_RESULT($vi_cv_include_sys_mman)
-
-AC_MSG_CHECKING(for sys/select.h)
-AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
-AC_TRY_CPP([#include <sys/select.h>],
- [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
-if test "$vi_cv_include_sys_select" = yes; then
- AC_DEFINE(HAVE_SYS_SELECT_H)
-fi
-AC_MSG_RESULT($vi_cv_include_sys_select)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_CHECK_TYPE(ssize_t, int)
-AC_C_BIGENDIAN
-AC_C_CONST
-AC_STRUCT_ST_BLKSIZE
-AC_TYPE_MODE_T
-AC_TYPE_OFF_T
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_STRUCT_TM
-
-dnl Checks for library functions.
- AC_CHECK_FUNCS(bsearch gethostname getopt memchr memcpy memmove memset)
-AC_REPLACE_FUNCS(bsearch gethostname getopt memchr memcpy memmove memset)
- AC_CHECK_FUNCS(mkstemp mmap snprintf strdup strerror strpbrk strtol)
-AC_REPLACE_FUNCS(mkstemp mmap snprintf strdup strerror strpbrk strtol)
- AC_CHECK_FUNCS(strtoul vsnprintf)
-AC_REPLACE_FUNCS(strtoul vsnprintf)
-
-AC_CHECK_FUNCS(select)
-AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
-AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
-AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
-
-AC_FUNC_MMAP
-AC_FUNC_VFORK
-
-dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
-if test "$need_env" = yes; then
- LIBOBJS="env.o $LIBOBJS"
-fi
-
-dnl If we need strsep, add it and define it so we get a prototype.
-if test "$need_strsep" = yes; then
- LIBOBJS="strsep.o $LIBOBJS"
-fi
-
-dnl Check for fcntl/flock
-dnl Use flock preferentially, since it has cleaner semantics and won't
-dnl hang up the editor.
-dnl XXX
-dnl Ultrix has a broken fcntl, but a working flock.
-dnl IRIX and DGUX have a broken flock, but working fcntl.
-AC_MSG_CHECKING(for fcntl/flock)
-AC_CACHE_VAL(vi_cv_lock, [dnl
- vi_cv_lock=none
- case "$host_os" in
- dgux*);;
- irix*);;
- *)
- AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
- [vi_cv_lock=flock]);;
- esac
- if test "$vi_cv_lock" = none; then
- AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
- [vi_cv_lock=fcntl])
- fi])
-
-if test "$vi_cv_lock" = flock; then
- AC_DEFINE(HAVE_LOCK_FLOCK)
-fi
-if test "$vi_cv_lock" = fcntl; then
- AC_DEFINE(HAVE_LOCK_FCNTL)
-fi
-AC_MSG_RESULT($vi_cv_lock)
-
-dnl Check for ftruncate/chsize
-AC_MSG_CHECKING(for ftruncate/chsize)
-AC_CACHE_VAL(vi_cv_ftruncate, [dnl
-AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
- [vi_cv_ftruncate=ftruncate],
-AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
- [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
-if test "$vi_cv_ftruncate" = ftruncate; then
- AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
-fi
-if test "$vi_cv_ftruncate" = chsize; then
- AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
-fi
-if test "$vi_cv_ftruncate" = no; then
- echo
- echo "Fatal error: no file truncation system call."
- exit 1
-fi
-AC_MSG_RESULT($vi_cv_ftruncate)
-
-dnl Check for the tigetstr/tigetnum functions.
-AC_MSG_CHECKING(for tigetstr/tigetnum)
-AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
-AC_TRY_LINK([#include <curses.h>], [tigetstr(0);],
- [vi_cv_have_curses_tigetstr=yes],
- [vi_cv_have_curses_tigetstr=no])])
-if test "$vi_cv_have_curses_tigetstr" = yes; then
- AC_DEFINE(HAVE_CURSES_TIGETSTR)
-fi
-AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
-
-dnl Check for potentially missing curses functions in system or user-specified
-dnl libraries. We also have to guess at whether the specified library is a
-dnl BSD or System V style curses. Use the newterm function, all System V
-dnl curses implementations have it, none, as far as I know, of the BSD ones do.
-if test "$vi_cv_curses" = "bundled curses"; then
- AC_DEFINE(HAVE_BSD_CURSES)
- AC_DEFINE(HAVE_CURSES_ADDNSTR)
- AC_DEFINE(HAVE_CURSES_IDLOK)
-else
- dnl Check for the addnstr function.
- AC_MSG_CHECKING(for addnstr)
- AC_CACHE_VAL(vi_cv_have_curses_addnstr, [dnl
- AC_TRY_LINK([#include <curses.h>], [addnstr(0, 0);],
- [vi_cv_have_curses_addnstr=yes],
- [vi_cv_have_curses_addnstr=no])])
- if test "$vi_cv_have_curses_addnstr" = yes; then
- AC_DEFINE(HAVE_CURSES_ADDNSTR)
- fi
- AC_MSG_RESULT($vi_cv_have_curses_addnstr)
-
- dnl Check for the beep function.
- AC_MSG_CHECKING(for beep)
- AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
- AC_TRY_LINK([#include <curses.h>], [beep();],
- [vi_cv_have_curses_beep=yes],
- [vi_cv_have_curses_beep=no])])
- if test "$vi_cv_have_curses_beep" = yes; then
- AC_DEFINE(HAVE_CURSES_BEEP)
- fi
- AC_MSG_RESULT($vi_cv_have_curses_beep)
-
- dnl Check for the flash function.
- AC_MSG_CHECKING(for flash)
- AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
- AC_TRY_LINK([#include <curses.h>], [flash();],
- [vi_cv_have_curses_flash=yes],
- [vi_cv_have_curses_flash=no])])
- if test "$vi_cv_have_curses_flash" = yes; then
- AC_DEFINE(HAVE_CURSES_FLASH)
- fi
- AC_MSG_RESULT($vi_cv_have_curses_flash)
-
- dnl Check for the idlok function.
- AC_MSG_CHECKING(for idlok)
- AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
- AC_TRY_LINK([#include <curses.h>], [idlok(0, 0);],
- [vi_cv_have_curses_idlok=yes],
- [vi_cv_have_curses_idlok=no])])
- if test "$vi_cv_have_curses_idlok" = yes; then
- AC_DEFINE(HAVE_CURSES_IDLOK)
- fi
- AC_MSG_RESULT($vi_cv_have_curses_idlok)
-
- dnl Check for the keypad function.
- AC_MSG_CHECKING(for keypad)
- AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
- AC_TRY_LINK([#include <curses.h>], [keypad(0, 0);],
- [vi_cv_have_curses_keypad=yes],
- [vi_cv_have_curses_keypad=no])])
- if test "$vi_cv_have_curses_keypad" = yes; then
- AC_DEFINE(HAVE_CURSES_KEYPAD)
- fi
- AC_MSG_RESULT($vi_cv_have_curses_keypad)
-
- dnl Check for the newterm function.
- AC_MSG_CHECKING(for newterm)
- AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
- AC_TRY_LINK([#include <curses.h>], [newterm(0, 0, 0);],
- [vi_cv_have_curses_newterm=yes],
- [vi_cv_have_curses_newterm=no])])
- if test "$vi_cv_have_curses_newterm" = yes; then
- AC_DEFINE(HAVE_CURSES_NEWTERM)
- fi
- AC_MSG_RESULT($vi_cv_have_curses_newterm)
-
- if test "$vi_cv_have_curses_newterm" = no; then
- AC_DEFINE(HAVE_BSD_CURSES)
- fi
-fi
-
-dnl Check for the setupterm function. We make this check regardless of
-dnl using the system library, because it may be part of the underlying
-dnl termcap/termlib support, and we want to use the local one.
-AC_MSG_CHECKING(for setupterm)
-AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
-AC_TRY_LINK([#include <curses.h>], [setupterm(0, 0, 0);],
- [vi_cv_have_curses_setupterm=yes],
- [vi_cv_have_curses_setupterm=no])])
-if test "$vi_cv_have_curses_setupterm" = yes; then
- AC_DEFINE(HAVE_CURSES_SETUPTERM)
-fi
-AC_MSG_RESULT($vi_cv_have_curses_setupterm)
-
-dnl Some moron decided to drop off an argument from the gettimeofday call,
-dnl without changing the name.
-AC_MSG_CHECKING(for broken gettimeofday system call)
-AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
-AC_TRY_LINK([#include <sys/types.h>
-#include <sys/time.h>], [gettimeofday(0, 0);],
- [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
-if test "$vi_cv_gettimeofday" = broken; then
- AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
-fi
-AC_MSG_RESULT($vi_cv_gettimeofday)
-
-dnl Check for which version of openpty to use, System V or Berkeley.
-AC_MSG_CHECKING(for System V pty calls)
-AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
-AC_TRY_LINK(, [grantpt(0);],
- [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
-if test "$vi_cv_sys5_pty" = yes; then
- AC_DEFINE(HAVE_SYS5_PTY)
-fi
-AC_MSG_RESULT($vi_cv_sys5_pty)
-
-dnl Check for the revoke system call.
-AC_MSG_CHECKING(for revoke system call)
-AC_CACHE_VAL(vi_cv_revoke, [dnl
-AC_TRY_LINK(, [revoke("a");],
- [vi_cv_revoke=yes], [vi_cv_revoke=no])])
-if test "$vi_cv_revoke" = yes; then
- AC_DEFINE(HAVE_REVOKE)
-fi
-AC_MSG_RESULT($vi_cv_revoke)
-
-dnl Some versions of sprintf return a pointer to the first argument instead
-dnl of a character count. We assume that the return value of snprintf and
-dnl vsprintf etc. will be the same as sprintf, and check the easy one.
-AC_MSG_CHECKING(for int type sprintf return value)
-AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
-AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
- [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
-if test "$vi_cv_sprintf_count" = no; then
- AC_DEFINE(SPRINTF_RET_CHARPNT)
-fi
-AC_MSG_RESULT($vi_cv_sprintf_count)
-
-dnl We compile in nvi's DB routines unless the user specifies otherwise.
-AC_MSG_CHECKING(if --disable-db option specified)
-AC_ARG_ENABLE(db,
- [ --disable-db DON'T use the nvi-provided DB routines.],
- [vi_cv_db_lib="other DB"], [vi_cv_db_lib="bundled DB"])
-AC_MSG_RESULT($vi_cv_db_lib)
-case "$vi_cv_db_lib" in
-"bundled DB")
- CPPFLAGS="-I\$(srcdir)/db/include $CPPFLAGS"
- LIBOBJS="\$(DBOBJS) $LIBOBJS";;
-"other DB")
- ;;
-esac
-
-dnl We compile in nvi's RE routines unless the user specifies otherwise.
-AC_MSG_CHECKING(if --disable-re option specified)
-AC_ARG_ENABLE(re,
- [ --disable-re DON'T use the nvi-provided RE routines.],
- [vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
-AC_MSG_RESULT($vi_cv_re_lib)
-case "$vi_cv_re_lib" in
-"bundled RE")
- CPPFLAGS="-I\$(srcdir)/regex $CPPFLAGS"
- LIBOBJS="\$(REOBJS) $LIBOBJS";;
-"other RE")
- ;;
-esac
-
-dnl Check for the standard shorthand types.
-AC_SUBST(u_char_decl)
-AC_MSG_CHECKING(for u_char)
-AC_CACHE_VAL(vi_cv_uchar, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
- [vi_cv_uchar=yes], [vi_cv_uchar=no])])
-AC_MSG_RESULT($vi_cv_uchar)
-if test "$vi_cv_uchar" = no; then
- u_char_decl="typedef unsigned char u_char;"
-fi
-
-AC_SUBST(u_short_decl)
-AC_MSG_CHECKING(for u_short)
-AC_CACHE_VAL(vi_cv_ushort, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
- [vi_cv_ushort=yes], [vi_cv_ushort=no])])
-AC_MSG_RESULT($vi_cv_ushort)
-if test "$vi_cv_ushort" = no; then
- u_short_decl="typedef unsigned short u_short;"
-fi
-
-AC_SUBST(u_int_decl)
-AC_MSG_CHECKING(for u_int)
-AC_CACHE_VAL(vi_cv_uint, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
- [vi_cv_uint=yes], [vi_cv_uint=no])])
-AC_MSG_RESULT($vi_cv_uint)
-if test "$vi_cv_uint" = no; then
- u_int_decl="typedef unsigned int u_int;"
-fi
-
-AC_SUBST(u_long_decl)
-AC_MSG_CHECKING(for u_long)
-AC_CACHE_VAL(vi_cv_ulong, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
- [vi_cv_ulong=yes], [vi_cv_ulong=no])])
-AC_MSG_RESULT($vi_cv_ulong)
-if test "$vi_cv_ulong" = no; then
- u_long_decl="typedef unsigned long u_long;"
-fi
-
-dnl DB/Vi use specific integer sizes.
-AC_SUBST(u_int8_decl)
-AC_MSG_CHECKING(for u_int8_t)
-AC_CACHE_VAL(vi_cv_uint8, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
- [vi_cv_uint8=yes],
-AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
- [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
-AC_MSG_RESULT($vi_cv_uint8)
-if test "$vi_cv_uint8" = no; then
- echo
- echo "Fatal error: no unsigned, 8-bit integral type."
- exit 1
-fi
-if test "$vi_cv_uint8" != yes; then
- u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
-fi
-
-AC_SUBST(u_int16_decl)
-AC_MSG_CHECKING(for u_int16_t)
-AC_CACHE_VAL(vi_cv_uint16, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
- [vi_cv_uint16=yes],
-AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
- [vi_cv_uint16="unsigned short"],
-AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
- [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
-AC_MSG_RESULT($vi_cv_uint16)
-if test "$vi_cv_uint16" = no; then
- echo
- echo "Fatal error: no unsigned, 16-bit integral type."
- exit 1
-fi
-if test "$vi_cv_uint16" != yes; then
- u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
-fi
-
-AC_SUBST(int16_decl)
-AC_MSG_CHECKING(for int16_t)
-AC_CACHE_VAL(vi_cv_int16, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
- [vi_cv_int16=yes],
-AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
- [vi_cv_int16="short"],
-AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
- [vi_cv_int16="int"], [vi_cv_int16=no])))])
-AC_MSG_RESULT($vi_cv_int16)
-if test "$vi_cv_int16" = no; then
- echo
- echo "Fatal error: no signed, 16-bit integral type."
- exit 1
-fi
-if test "$vi_cv_int16" != yes; then
- int16_decl="typedef $vi_cv_int16 int16_t;"
-fi
-
-AC_SUBST(u_int32_decl)
-AC_MSG_CHECKING(for u_int32_t)
-AC_CACHE_VAL(vi_cv_uint32, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
- [vi_cv_uint32=yes],
-AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
- [vi_cv_uint32="unsigned int"],
-AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
- [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
-AC_MSG_RESULT($vi_cv_uint32)
-if test "$vi_cv_uint32" = no; then
- echo
- echo "Fatal error: no unsigned, 32-bit integral type."
- exit 1
-fi
-if test "$vi_cv_uint32" != yes; then
- u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
-fi
-
-AC_SUBST(int32_decl)
-AC_MSG_CHECKING(for int32_t)
-AC_CACHE_VAL(vi_cv_int32, [dnl
-AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
- [vi_cv_int32=yes],
-AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
- [vi_cv_int32="int"],
-AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
- [vi_cv_int32="long"], [vi_cv_int32=no])))])
-AC_MSG_RESULT($vi_cv_int32)
-if test "$vi_cv_int32" = no; then
- echo
- echo "Fatal error: no signed, 32-bit integral type."
- exit 1
-fi
-if test "$vi_cv_int32" != yes; then
- int32_decl="typedef $vi_cv_int32 int32_t;"
-fi
-
-AC_OUTPUT(Makefile port.h:port.h.in
- pathnames.h:pathnames.h.in recover:recover.in)
diff --git a/build/distrib b/build/distrib
deleted file mode 100644
index 45dbe52f4049..000000000000
--- a/build/distrib
+++ /dev/null
@@ -1,84 +0,0 @@
-#! /bin/sh
-# @(#)distrib 8.11 (Berkeley) 10/23/96
-
-# Clean
-#make -f Makefile.in clean
-#rm -f configure config.h.in
-
-# Build autoconf structure.
-echo "Running autoheader"
-autoheader 2>&1 | sed '/warning: AC_TRY_RUN called without default/d'
-chmod 444 config.h.in
-echo "Running autoconf"
-autoconf 2>&1 | sed '/warning: AC_TRY_RUN called without default/d'
-chmod 555 configure config.guess config.sub install-sh
-
-# Build include files.
-f=../include/cl_extern.h
-echo "Building $f"
-rm -f $f
-sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../cl/*.c > $f
-chmod 444 $f
-
-f=../include/com_extern.h
-echo "Building $f"
-rm -f $f
-sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../clib/*.c ../common/*.c > $f
-chmod 444 $f
-
-f=../include/ex_def.h
-echo "Building $f"
-rm -f $f
-awk -f ../ex/ex.awk ../ex/ex_cmd.c > $f
-chmod 444 $f
-
-f=../include/ex_extern.h
-echo "Building $f"
-rm -f $f
-sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../ex/*.c > $f
-chmod 444 $f
-
-if [ -d ../ip ]; then
- f=../include/ip_extern.h
- echo "Building $f"
- rm -f $f
- sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../ip/*.c > $f
- chmod 444 $f
-fi
-
-f=../include/options_def.h
-echo "Building $f"
-rm -f $f
-awk -f ../common/options.awk ../common/options.c > $f
-chmod 444 $f
-
-f=../include/perl_extern.h
-echo "Building $f"
-rm -f $f
-sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../perl_api/*.xs ../perl_api/*.c > $f
-chmod 444 $f
-
-f=../include/tcl_extern.h
-echo "Building $f"
-rm -f $f
-sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../tcl_api/*.c > $f
-chmod 444 $f
-
-f=../include/tk_extern.h
-echo "Building $f"
-rm -f $f
-sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../tk/*.c > $f
-chmod 444 $f
-
-f=../include/vi_extern.h
-echo "Building $f"
-rm -f $f
-sed -n "s/^ \* PUBLIC: \(.*\)/\1/p" ../vi/*.c > $f
-chmod 444 $f
-
-# Build tags files.
-echo "Building tags files"
-rm -f tags
-ctags -w -d ../cl/*.[ch] ../common/*.[ch] ../ex/*.[ch] ../perl_api/*.[ch] \
- ../tcl_api/*.[ch] ../tk/*.[ch] ../vi/*.[ch]
-chmod 444 tags
diff --git a/build/install-sh b/build/install-sh
deleted file mode 100755
index ab74c882e923..000000000000
--- a/build/install-sh
+++ /dev/null
@@ -1,238 +0,0 @@
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-tranformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/build/pathnames.h.in b/build/pathnames.h.in
deleted file mode 100644
index 09cf97460ae8..000000000000
--- a/build/pathnames.h.in
+++ /dev/null
@@ -1,45 +0,0 @@
-/* @(#)pathnames.h.in 8.4 (Berkeley) 6/26/96 */
-
-#ifndef _PATH_BSHELL
-#define _PATH_BSHELL "@vi_cv_path_shell@"
-#endif
-
-#ifndef _PATH_EXRC
-#define _PATH_EXRC ".exrc"
-#endif
-
-#ifndef _PATH_MSGCAT
-#define _PATH_MSGCAT "./"
-#endif
-
-#ifndef _PATH_NEXRC
-#define _PATH_NEXRC ".nexrc"
-#endif
-
-#ifndef _PATH_PRESERVE
-#define _PATH_PRESERVE "@vi_cv_path_preserve@"
-#endif
-
-#ifndef _PATH_SYSV_PTY
-#define _PATH_SYSV_PTY "/dev/ptmx"
-#endif
-
-#ifndef _PATH_SENDMAIL
-#define _PATH_SENDMAIL "@vi_cv_path_sendmail@"
-#endif
-
-#ifndef _PATH_SYSEXRC
-#define _PATH_SYSEXRC "/etc/vi.exrc"
-#endif
-
-#ifndef _PATH_TAGS
-#define _PATH_TAGS "tags"
-#endif
-
-#ifndef _PATH_TMP
-#define _PATH_TMP "/tmp"
-#endif
-
-#ifndef _PATH_TTY
-#define _PATH_TTY "/dev/tty"
-#endif
diff --git a/build/port.h.in b/build/port.h.in
deleted file mode 100644
index 6696848ecc7d..000000000000
--- a/build/port.h.in
+++ /dev/null
@@ -1,185 +0,0 @@
-/* @(#)port.h.in 8.13 (Berkeley) 6/12/96 */
-
-/*
- * Declare the basic types, if they aren't already declared. Named and
- * some system's db.h files protect them with __BIT_TYPES_DEFINED__.
- */
-#ifndef __BIT_TYPES_DEFINED__
-#define __BIT_TYPES_DEFINED__
-@u_int8_decl@
-@int16_decl@
-@u_int16_decl@
-@int32_decl@
-@u_int32_decl@
-#endif
-
-@u_char_decl@
-@u_short_decl@
-@u_int_decl@
-@u_long_decl@
-
-/*
- * XXX
- * Handle function prototypes. This steps on name space that vi doesn't
- * control, but all of the other solutions are worse.
- */
-#undef __P
-#if defined(__STDC__) || defined(__cplusplus)
-#define __P(protos) protos /* ANSI C prototypes */
-#else
-#define __P(protos) () /* K&R C preprocessor */
-#endif
-
-/*
- * XXX
- * Some versions of System V changed the number of arguments to gettimeofday
- * without changing the name.
- */
-#ifdef HAVE_BROKEN_GETTIMEOFDAY
-#define gettimeofday(tv, tz) gettimeofday(tv)
-#endif
-
-/*
- * XXX
- * If we don't have mmap, we fake it with read and write, but we'll
- * still need the header information.
- */
-#ifndef HAVE_SYS_MMAN_H
-#define MAP_SHARED 1 /* share changes */
-#define MAP_PRIVATE 2 /* changes are private */
-#define PROT_READ 0x1 /* pages can be read */
-#define PROT_WRITE 0x2 /* pages can be written */
-#define PROT_EXEC 0x4 /* pages can be executed */
-#endif
-
-/*
- * XXX
- * POSIX 1003.1 names for file descriptors.
- */
-#ifndef STDERR_FILENO
-#define STDIN_FILENO 0 /* ANSI C #defines */
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-#endif
-
-/*
- * XXX
- * POSIX 1003.1 names for seek settings.
- */
-#ifndef SEEK_END
-#define SEEK_SET 0 /* POSIX 1003.1 seek values */
-#define SEEK_CUR 1
-#define SEEK_END 2
-#endif
-
-/*
- * Hack _POSIX_VDISABLE to \377 since Ultrix doesn't honor _POSIX_VDISABLE
- * (treats it as ^@). The symptom is that the ^@ keystroke immediately
- * drops core.
- */
-#ifdef HAVE_BROKEN_VDISABLE
-#undef _POSIX_VDISABLE
-#define _POSIX_VDISABLE ((unsigned char)'\377')
-#endif
-
-/*
- * XXX
- * POSIX 1003.1 tty disabling character.
- */
-#ifndef _POSIX_VDISABLE
-#define _POSIX_VDISABLE 0 /* Some systems used 0. */
-#endif
-
-/*
- * XXX
- * 4.4BSD extension to only set the software termios bits.
- */
-#ifndef TCSASOFT /* 4.4BSD extension. */
-#define TCSASOFT 0
-#endif
-
-/*
- * XXX
- * POSIX 1003.1 maximum path length.
- */
-#ifndef MAXPATHLEN
-#ifdef PATH_MAX
-#define MAXPATHLEN PATH_MAX
-#else
-#define MAXPATHLEN 1024
-#endif
-#endif
-
-/*
- * XXX
- * MIN, MAX, historically in <sys/param.h>
- */
-#ifndef MAX
-#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a))
-#endif
-#ifndef MIN
-#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
-#endif
-
-/*
- * XXX
- * "DB" isn't always portable, and we want the private information.
- */
-#define DB L__DB
-#undef pgno_t /* IRIX has its own version. */
-#define pgno_t L__db_pgno_t
-
-/*
- * XXX
- * 4.4BSD extension to provide lock values in the open(2) call.
- */
-#ifndef O_EXLOCK
-#define O_EXLOCK 0
-#endif
-
-#ifndef O_SHLOCK
-#define O_SHLOCK 0
-#endif
-
-/*
- * XXX
- * POSIX 1003.1 bad file format errno.
- */
-#ifndef EFTYPE
-#define EFTYPE EINVAL
-#endif
-
-/*
- * XXX
- * POSIX 1003.2 RE length limit.
- */
-#ifndef _POSIX2_RE_DUP_MAX
-#define _POSIX2_RE_DUP_MAX 255
-#endif
-
-/*
- * XXX
- * 4.4BSD extension to determine if a program dropped core from the exit
- * status.
- */
-#ifndef WCOREDUMP
-#define WCOREDUMP(a) 0
-#endif
-
-/*
- * XXX
- * Endian-ness of the machine.
- */
-#if !defined(LITTLE_ENDIAN)
-#define LITTLE_ENDIAN 1234
-#endif
-#if !defined(BIG_ENDIAN)
-#define BIG_ENDIAN 4321
-#endif
-#if !defined(BYTE_ORDER)
-#if WORDS_BIGENDIAN == 1
-#define BYTE_ORDER BIG_ENDIAN
-#else
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-#endif
diff --git a/build/recover.in b/build/recover.in
deleted file mode 100644
index cfaf75f2c287..000000000000
--- a/build/recover.in
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/sh -
-#
-# @(#)recover.in 8.8 (Berkeley) 10/10/96
-#
-# Script to recover nvi edit sessions.
-
-RECDIR="@vi_cv_path_preserve@"
-SENDMAIL="@vi_cv_path_sendmail@"
-
-echo 'Recovering nvi editor sessions.'
-
-# Check editor backup files.
-vibackup=`echo $RECDIR/vi.*`
-if [ "$vibackup" != "$RECDIR/vi.*" ]; then
- for i in $vibackup; do
- # Only test files that are readable.
- if test ! -r $i; then
- continue
- fi
-
- # Unmodified nvi editor backup files either have the
- # execute bit set or are zero length. Delete them.
- if test -x $i -o ! -s $i; then
- rm $i
- fi
- done
-fi
-
-# It is possible to get incomplete recovery files, if the editor crashes
-# at the right time.
-virecovery=`echo $RECDIR/recover.*`
-if [ "$virecovery" != "$RECDIR/recover.*" ]; then
- for i in $virecovery; do
- # Only test files that are readable.
- if test ! -r $i; then
- continue
- fi
-
- # Delete any recovery files that are zero length, corrupted,
- # or that have no corresponding backup file. Else send mail
- # to the user.
- recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
- if test -n "$recfile" -a -s "$recfile"; then
- $SENDMAIL -t < $i
- else
- rm $i
- fi
- done
-fi
diff --git a/build/spell.ok b/build/spell.ok
deleted file mode 100644
index fc103f43602d..000000000000
--- a/build/spell.ok
+++ /dev/null
@@ -1,58 +0,0 @@
-ADDCPPFLAGS
-ADDLDFLAGS
-ADDLIBS
-CPPFLAGS
-FreeBSD
-LDFLAGS
-LIBS
-Lite
-NVI
-NVI'S
-NetBSD
-Nvi
-POSIX
-Perl
-README
-Tcl
-Tk
-asnvi
-asvi
-autoconf
-bindir
-cd
-contrib
-csh
-datadir
-datafiles
-db
-distclean
-env
-filesystem
-foo
-gcc
-ksh
-lcurses
-ldb
-lm
-lperl
-ltcl
-ltermcap
-ltermlib
-ltk
-mandir
-mkdir
-ncurses
-nex
-nvi
-nview
-perl
-perlinterp
-setenv
-sh
-tcl
-tclinterp
-tcsh
-terminfo
-tknvi
-usr
-vi
diff --git a/catalog/Makefile b/catalog/Makefile
index 1044051ff389..11e71cce6d7b 100644
--- a/catalog/Makefile
+++ b/catalog/Makefile
@@ -1,7 +1,8 @@
-# @(#)Makefile 8.29 (Berkeley) 10/19/96
+# $Id: Makefile,v 9.0 2012/10/19 15:13:11 zy Exp $
-CAT= dutch english french german ru_SU.KOI8-R spanish swedish
-FILES= ../cl/*.c ../common/*.c ../ex/*.c ../tk/*.c ../vi/*.c
+CAT= dutch english french german polish ru_RU.KOI8-R spanish swedish \
+ uk_UA.KOI8-U zh_CN.GB2312
+FILES= ../cl/*.c ../common/*.c ../ex/*.c ../vi/*.c
all: dump ${CAT}
@@ -18,13 +19,10 @@ ${CAT}: english.base
print "DUPLICATE MESSAGE NUMBER " $$1; \
exit 1; \
} \
- for (; nline < $$1; ++nline) \
- print ""; \
print $0; \
}' | \
- sed -e '1s/^/VI_MESSAGE_CATALOG/' \
- -e '/"/s/^[^"]*"//' \
- -e '1!s/"$$/X/' > $@; \
+ sed -e '1s/^/$$set 1~$$quote "~/; 1y/~/\n/' | \
+ gencat $@ /dev/stdin; \
chmod 444 $@; \
if grep DUPLICATE $@ > /dev/null; then \
grep DUPLICATE $@; \
@@ -34,7 +32,8 @@ ${CAT}: english.base
fi
CHK= dutch.check english.check french.check german.check \
- ru_SU.KOI8-R.check spanish.check swedish.check
+ polish.check ru_RU.KOI8-R.check spanish.check swedish.check \
+ uk_UA.KOI8-U.check zh_CN.GB2312.check
check: ${CHK}
${CHK}: ${CAT}
@echo "... $@"; \
@@ -63,19 +62,14 @@ ${CHK}: ${CAT}
echo "Duplicate messages, both id and message (this is okay):"; \
sed '/^$$/d' < $$f.base | sort | uniq -c | \
awk '$$1 != 1 { print $$0 }' | sort -n; \
- echo =========================; \
- echo "Duplicate messages, just message (this is okay):"; \
- sed '/^$$/d' < $$f | sort | uniq -c | \
- awk '$$1 != 1 { print $$0 }' | sort -n; \
echo =========================) > $@
english.base: dump ${FILES} #Makefile
./dump ${FILES} |\
sed -e '/|/!d' \
-e 's/|/ "/' \
- -e 's/^"//' \
- -e 's/\\"/"/g' |\
- sort -n > $@
+ -e 's/^"//' |\
+ sort -nu > $@
dump: dump.c
${CC} -O -o dump dump.c
diff --git a/catalog/README b/catalog/README
index 15a706358869..42a728afbe2e 100644
--- a/catalog/README
+++ b/catalog/README
@@ -1,15 +1,9 @@
-# @(#)README 8.4 (Berkeley) 11/22/94
+# $Id: README,v 9.0 2012/10/19 17:06:15 zy Exp $
Generally, all non-system error and informational messages in nvi are
catalog messages, i.e. they can be tailored to a specific langauge.
-Command strings, usage strings, system errors and other "known text"
-are not. It would certainly be possible to internationalize all the
-text strings in nvi, but it's unclear that it's the right thing to do.
-
-First, there's no portable way to do message catalogs. The System V
-scheme is a reasonable choice, but none of the 4BSD derived systems
-support it. So, catalogs are completely implemented within nvi, and
-don't require any library support.
+Command strings, usage strings, system errors and other 'known text'
+are not.
Message catalogs in nvi are fairly simple. Every catalog message
consists of two parts -- an initial number followed by a pipe (`|')
@@ -33,19 +27,7 @@ For example:
msgq(sp, M_ERR, "002|Error: %d %x", arg1, arg2);
-is a format string that displays two arguments. It is possible, however,
-to reorder the arguments or to not display all of them. The convention
-nvi uses is the System V printf(3) convention, i.e. "%[0-9]*$" is the name
-of a specific, numbered argument. For example:
-
- msgq(sp, M_ERR, "002|Error: %2$d %1$x", arg1, arg2);
-
-displays the arguments in reverse order.
-
-If the system supports this convention in its library printf routines
-(as specified by the test #define NL_ARGMAX), nvi uses those routines.
-Otherwise, there is some serious magic going on in common/msg.c to make
-this all work.
+is a format string that displays two arguments.
Arguments to the msgq function are required to contain ONLY printable
characters. No further translation is done by the msgq routine before
@@ -54,14 +36,16 @@ displaying the message on the screen. For example, in the msgq call:
msgq(sp, M_ERR, "003|File: %s", file_name);
"file_name" must contain only printable characters. The routine
-msg_print() returns a printable version of a string in allocated
-memory. For example:
+msg_print() returns a printable version of a string; the third argument
+indicates whether the string needs to be freed. For example:
char *p;
+ int nf;
- p = msg_print(sp, file_name);
- msgq(sp, M_ERR, M("003", "File: %s"), p);
- FREE_SPACE(sp, p, 0);
+ p = msg_print(sp, file_name, &nf);
+ msgq(sp, M_ERR, "003|File: %s", p);
+ if (nf)
+ FREE_SPACE(sp, p, 0);
makes sure that "file_name" is printable before calling the msgq
routine.
@@ -71,63 +55,40 @@ routine.
The message catalogs themselves are maintained in two files. The first
is the "base file" which contains two fields, a record number and the
message itself. All base files are named using the convention
-"vi_<language>.base", e.g. the English one is "vi_english.base". For
+"<language>.base", e.g. the English one is "english.base". For
example:
- 002 "Unable to create temporary file"
- 003 "Warning: %s is not a regular file"
- 004 "%s already locked, session is read-only"
- 005 "%s: remove"
- 006 "%s: close"
- 007 "%s: remove"
- 008 "%s: remove"
- 009 "Read-only file, not written; use ! to override"
- 010 "Read-only file, not written"
-
-are the first few lines of the current vi_english.base file. Note that
-message #1 is missing -- the first message of each catalog is a special
-one, so that nvi can recognize message catalog files. It's added by the
-Makefile script that creates the second version of the message catalog.
-
-The second file is the file used by nvi to access messages, and is a list
-of the messages, one per line:
-
- VI_MESSAGE_CATALOG
- Unable to create temporary fileX
- Warning: %s is not a regular fileX
- %s already locked, session is read-onlyX
- %s: removeX
- %s: closeX
- %s: removeX
- %s: removeX
- Read-only file, not written; use ! to overrideX
- Read-only file, not writtenX
-
-Note that all messages have had a trailing 'X' character appended. This
-is to provide nvi a place to store a trailing nul for the message so that
-C library routines that expect one won't be disappointed.
-
-These files are named for their language, e.g. "vi_english". The second
-files are automatically created from the first files.
+ 002 "Line length overflow"
+ 003 "unable to delete line %lu"
+ 004 "unable to append to line %lu"
+ 005 "unable to insert at line %lu"
+ 006 "unable to store line %lu"
+ 007 "unable to get last line"
-To create a new catalog for nvi:
+are the first few lines of the current english.base file.
-Copy the file vi_english.base to a file that you can modify , e.g. "cp
-vi_english.base vi_german.base". For each of the messages in the file,
-replace the message with the string that you want to use. To find out
-what the arguments to a message are, I'm afraid you'll have to search
-the source code for the message number. You can find them fairly quickly
-by doing:
+Before this file being converted to the second file, the POSIX formatted
+message catalog file, by gencat(1), two lines:
- cd ..; egrep '123\|' */*.[chys]
+ $set 1
+ $quote "
+
+will be inserted before the base text to setup the set_id and the quote
+character. So the double-quote needs to be escaped by a backslash to be
+included in a message; same as the backslash itself.
+
+These files are named for their language, e.g. "english". However, a
+locale(1) name is also recommended.
+
+To create a new catalog for nvi:
-I'm sorry that there's not an easier way, but I couldn't think of
-anything that wasn't a lot of work.
+Copy the file english.base to a file that you can modify , e.g. "cp
+english.base german.base". For each of the messages in the file,
+replace the message with the string that you want to use. If you have
+doubts about the meaning of a message, just email me.
-If, for some reason, you don't have the file vi_english.base, or you
-have new sources for which you want to create a new base catalog, you
-can create it by running the command "make english" in the catalog
-directory.
+A latest english.base can be created from source by running the command
+"make english" in the catalog/ directory.
Once you've translated all of the strings, then add your catalog to the
"CAT=" line of the Makefile, and run the command "make catalog". This
@@ -156,11 +117,11 @@ a single place.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
To select a catalog when running nvi, set the "msgcat" option. If the
value of this option ends with a '/', it is treated as the name of a
-directory that contains a message catalog "vi_XXXX", where XXXX is the
-value of the LANG environmental variable, if it's set, or the value of
-the LC_MESSAGES environmental variable if it's not. If neither of those
-environmental variables are set, or if the option doesn't end in a '/',
-the option is treated as the full path name of the message catalog to use.
+directory that contains a message catalog "$LC_MESSAGES", which is set
+through the LC_MESSAGES environment variable but returned by setlocale(3).
+Check the output of locale(1) to validate such a value. If the option
+doesn't end in a '/', the option is treated as the full path name of the
+message catalog to use.
If any messages are missing from the catalog, the backup text (English)
is used instead.
diff --git a/catalog/dump.c b/catalog/dump.c
index 0b3cd26520d5..4cd39df863b2 100644
--- a/catalog/dump.c
+++ b/catalog/dump.c
@@ -2,43 +2,17 @@
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * %sccs.include.redist.c%
*/
#ifndef lint
static char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
+"%Z% Copyright (c) 1992, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)dump.c 8.1 (Berkeley) 8/31/94";
+static char sccsid[] = "$Id: dump.c,v 8.2 2011/07/14 00:05:25 zy Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -105,10 +79,10 @@ main(argc, argv)
for (; *argv != NULL; ++argv) {
if ((fp = fopen(*argv, "r")) == NULL) {
perror(*argv);
- exit (1);
+ return (1);
}
parse(fp);
(void)fclose(fp);
}
- exit (0);
+ return (0);
}
diff --git a/catalog/dutch b/catalog/dutch
deleted file mode 100644
index de9fb603bf8e..000000000000
--- a/catalog/dutch
+++ /dev/null
@@ -1,317 +0,0 @@
-VI_MESSAGE_CATALOG
-regel te langX
-kan regel %lu niet verwijderenX
-kan niet toevoegen aan regel %luX
-kan niet invoegen vooraan regel %luX
-kan regel %lu niet opslaanX
-kan laatste regel niet lezenX
-Fout: kan regel %lu niet vindenX
-log bestandX
-Er vindt geen logging plaats, kan wijzigingen niet ongedaan makenX
-geen wijzigingen om ongedaan te makenX
-Er vindt geen logging plaats, kan wijzigingen niet ongedaan makenX
-Er vindt geen logging plaats, herhaling niet mogelijkX
-geen wijzigingen om te herhalenX
-%s/%d: schrijven naar log misluktX
-Vi's standaard invoer en uitvoer moeten aan een terminal gekoppeld zijnX
-Merk %s: niet gezetX
-Merk %s: de regel is verwijderdX
-Merk %s: de cursor positie bestaat niet meerX
-Fout: X
-nieuw bestandX
-naam veranderdX
-gewijzigdX
-ongewijzigdX
-NIET BEVEILIGDX
-niet schrijfbaarX
-regel %lu uit %lu [%ld%%]X
-leeg bestandX
-regel %luX
-Het bestand %s is geen message catalogX
-Niet in staat om de standaard %s optie in te stellenX
-Gebruik: %sX
-set: optie %s onbekend: 'set all' laat alle opties zienX
-set: [no]%s optie kan geen waarde hebbenX
-set: %s optie moet een waarde hebbenX
-set: %s optie: %sX
-set: %s optie: %s: getal is te grootX
-set: %s optie: %s is een ongeldige waardeX
-set: %s optie moet een waarde hebbenX
-Te weinig kolommen op het scherm, minder dan %dX
-Aantal kolommen te groot, meer dan %dX
-Te weinig regels op het scherm, minder dan %dX
-Aantal regels te groot, meer dan %dX
-De lisp optie is niet ondersteundX
-messages niet uitgeschakeld: %sX
-messages niet geactiveerd: %sX
-
-De paragraph optie moet karakter paren bevattenX
-De section optie moet karakter paren bevattenX
-
-
-
-De standaard buffer is leegX
-Buffer %s is leegX
-Bestanden met newlines in de naam kunnen niet hersteld wordenX
-Wijzigingen kunnen niet ongedaan gemaakt worden als deze sessie misluktX
-Bestand wordt gecopieerd voor herstel...X
-Herstel mechanisme werkt niet: %sX
-Wijzigingen kunnen niet ongedaan gemaakt worden als deze sessie misluktX
-Kon bestand niet veilig stellen: %sX
-Bestand wordt gecopieerd voor herstel...X
-Informatie met betrekking tot gebruiker nummer %u niet gevondenX
-Kan herstel bestand niet beveiligenX
-herstel buffer overgelopenX
-herstel bestandX
-%s: verminkt herstel bestandX
-%s: verminkt herstel bestandX
-U heeft geen bestand genaamd %s te herstellenX
-U kan eerdere versies van dit bestand herstellenX
-U kan nog meer bestanden herstellenX
-kan geen email versturen: %sX
-Bestand leeg; niets om te doorzoekenX
-Einde van het bestand bereikt zonder dat het patroon gevonden isX
-Geen vorig zoek patroonX
-Patroon niet gevondenX
-Begin van het bestand bereikt zonder dat het patroon gevonden isX
-Zoek-operatie omgeslagenX
-Bezig met zoeken...X
-Geen niet-printbaar karakter gevondenX
-Onbekend commandoX
-
-Commando niet beschikbaar in ex modeX
-Aantal mag niet nul zijnX
-%s: ongeldige regel aanduidingX
-Interne fout in syntax tabel (%s: %s)X
-Gebruik: %sX
-%s: tijdelijke buffer niet vrijgegevenX
-Vlag offset voor regel 1X
-Vlag offset voorbij bestands eindeX
-bestand/scherm veranderd tijdens uitvoeren van @ in een blokX
-bestand/scherm veranderd tijdens uitvoeren van globaal/v commandoX
-Ex commando mislukt: rest van commando(s) genegeerdX
-Ex commando mislukt: gemappede toetsen genegeerdX
-Het tweede adres is kleiner dan het eersteX
-Geen merk naam opgegevenX
-\\ niet gevolgd door / of ?X
-Referentie aan een regel nummer kleiner dan 0X
-Het %s commando is onbekendX
-Adres waarde te grootX
-Adres waarde te kleinX
-Ongeldige adres combinatieX
-Ongeldig adres: slechts %lu regels in het bestand aanwezigX
-Ongeldig adres: het bestand is leegX
-Het %s commando staat het adres 0 niet toeX
-Geen afkortingen om weer te gevenX
-Afkortingen moeten eindigen met een "woord" letterX
-Afkortingen mogen geen tabulaties of spaties bevattenX
-Afkortingen mogen geen woord/niet-woord karakters mengen, behalve aan het eindeX
-"%s" is geen afkortingX
-Vi commando mislukt: gemappede toetsen genegeerdX
-Dit is het laatste bestandX
-Dit is het eerste bestandX
-Dit is het eerste bestandX
-lijst met bestanden is leegX
-Geen voorgaand commando om "!" te vervangenX
-Geen bestandsnaam voor %%X
-Geen bestandsnaam voor #X
-Fout: execl: %sX
-I/O fout: %sX
-Bestand gewijzigd sinds laatste schrijfactie; schrijf het weg of gebruik ! om het te forcerenX
-Kan uw home directory niet vindenX
-Nieuwe huidige directory: %sX
-Geen cut buffers aanwezigX
-Het %s commando kan niet gebruikt worden in een globaal of v commandoX
-%s/%s: niet gelezen: noch U noch root is de eigenaarX
-%s/%s: niet gelezen: U bent niet de eigenaarX
-%s/%s: niet gelezen: kan gewijzigd worden door andere gebruikersX
-%s: niet gelezen: noch U noch root is de eigenaar"X
-%s: niet gelezen: U bent niet de eigenaarX
-%s: niet gelezen: kan gewijzigd worden door andere gebruikersX
-Geen volgende regel om samen te voegenX
-Geen input map entriesX
-Geen command map entriesX
-Het %s karakter kan niet ge-remapped wordenX
-"%s" is niet gemappedX
-Merk naam moet een enkel karakter zijnX
-%s bestaat al, niet weggeschreven; gebruik ! om het te forcerenX
-Nieuw .exrc bestand: %s. X
-doel regel ligt in het blokX
-Het open commando vereist dat de open optie actief isX
-Het open commando is nog niet ondersteundX
-Kan dit bestand niet veilig stellenX
-Bestand veilig gesteldX
-%s resulteert in te veel bestandsnamenX
-Alleen echte bestanden en named pipes kunnen gelezen wordenX
-%s: lees beveiliging niet beschikbaarX
-Bezig met lezen...X
-%s: %lu regels, %lu karaktersX
-Geen achtergrond schermen aanwezigX
-Het script commando is alleen beschikbaar in vi modeX
-Geen comando om uit te voerenX
-shiftwidth optie op 0 gezetX
-Count te grootX
-Count te kleinX
-Reguliere expressie opgegeven; r vlag heeft geen betekenisX
-De #, l en p vlaggen kunnen niet gecombineerd worden met de c vlag in vi modeX
-Geen match gevondenX
-Geen voorafgaande tag aanwezigX
-Minder dan %s elementen op de tags stapel; gebruik :display t[ags]X
-Geen bestand genaamd %s op de tags stapel; gebruik :display t[ags]X
-Kies Enter om door te gaan: X
-%s: tag niet gevondenX
-%s: verminkte tag in %sX
-%s: Het regel nummer van deze tag is voorbij het einde van het bestandX
-De tags stapel is leegX
-%s: zoek patroon niet gevondenX
-%d andere bestanden te wijzigenX
-Buffer %s is leegX
-Bevestig wijziging? [n]X
-OnderbrokenX
-Geen voorafgaande buffer om uit te voerenX
-Geen vorige reguliere expressieX
-Het %s commando vereist dat er een bestand geladen isX
-Gebruik: %sX
-Het visual commando vereist dat de open optie actief isX
-
-Leeg bestandX
-Geen voorafgaand F, f, T of t zoek commandoX
-%s niet gevondenX
-Geen voorafgaand bestand te bewerkenX
-Cursor niet op een getalX
-Getal wordt te grootX
-Getal wordt te kleinX
-Geen overeenkomstig karakter op deze regelX
-Overeenkomstig karakter niet gevondenX
-Geen karakters te vervangenX
-Geen ander scherm aanwezigX
-Karakters achter het zoek patroon, de regel offset, en/of het z commandoX
-Geen voorafgaand zoek patroonX
-Zoekopdracht na omslag teruggekeerd op originele positieX
-Afkorting overschrijdt expansie limiet: karakters genegeerdX
-Ongeldig karakter; quote to enterX
-Reeds aan het begin van de invoerX
-Niet meer karakters te verwijderenX
-Verplaatsing voorbij het einde van het bestandX
-Verplaatsing voorbij het einde van de regelX
-Cursor niet verplaatstX
-Reeds aan het begin van het bestandX
-Verplaatsing voorbij het begin van het bestandX
-Reeds in de eerste kolomX
-Buffers moeten voor het commando opgegeven wordenX
-Reeds bij het einde van het bestandX
-Reeds bij het einde van de regelX
-%s is geen vi commandoX
-Gebruik: %sX
-Geen karakters te verwijderenX
-Het Q commando vereist de ex terminal interfaceX
-Geen commando om te herhalenX
-Het bestand is leegX
-%s mag niet gebruikt worden als een verplaatsings commandoX
-Al in commando modeX
-Cursor niet in een woordX
-
-Windows optie waarde is te groot, maximum is %uX
-ToevoegenX
-VeranderenX
-CommandoX
-InvoegenX
-VervangenX
-Verplaatsing voorbij het eind van het schermX
-Verplaatsing voorbij het begin van het schermX
-Scherm moet meer dan %d regels hebben om het te kunnen splitsenX
-Er zijn geen achtergrond schermenX
-Er is geen achtergrond scherm waarin U bestand %s aan het bewerken bentX
-U kan uw enige scherm niet in de achtergrond zettenX
-Het scherm kan slechts verkleind worden tot %d regelsX
-Het scherm kan niet kleinerX
-Het scherm kan niet groterX
-
-Dit scherm kan niet gesuspend wordenX
-Onderbroken: gemappede toetsen genegeerdX
-vi: tijdelijke buffer niet vrijgegevenX
-Deze terminal heeft geen %s toetsX
-Er kan slechts een buffer opgegeven wordenX
-Getal groter dan %luX
-OnderbrokenX
-Aanmaken van tijdelijk bestand is misluktX
-Waarschuwing: %s is geen regulier bestandX
-%s is al geopend, bestand is in deze sessie niet schrijfbaarX
-%s: verwijdering misluktX
-%s: sluiting misluktX
-%s: verwijdering misluktX
-%s: verwijdering misluktX
-Bestand niet schrijfbaar, niet weggeschreven; gebruik ! om het te forcerenX
-Bestand niet schrijfbaar, niet weggeschrevenX
-%s bestaat al, niet weggeschreven; gebruik ! om het te forcerenX
-%s bestaat al, niet weggeschrevenX
-Gebruik ! om een incompleet bestand weg te schrijvenX
-Bestand incompleet, niet weggeschrevenX
-%s: bestand op disk nieuwer dan deze versie; gebruik ! om het te forcerenX
-%s: bestand op disk nieuwer dan deze versieX
-%s: schrijf beveiliging niet beschikbaarX
-Bezig met schrijven...X
-%s: WAARSCHUWING: BESTAND INCOMPLEETX
-Reeds op de eerste tag van deze groepX
-%s: nieuw bestand: %lu regels, %lu karaktersX
-%s: %lu regels, %lu karaktersX
-%s resulteert in te veel bestandsnamenX
-%s: geen normaal bestandX
-%s: U bent niet de eigenaarX
-%s: kan gewijzigd worden door andere gebruikersX
-Bestand gewijzigd sinds laatste schrijfactie; schrijf het weg of gebruik ! om het te forcerenX
-Bestand gewijzigd sinds laatste schrijfactie; schrijf het weg of gebruik :edit! om het te forcerenX
-Bestand gewijzigd sinds laatste schrijfactie; schrijf het weg of gebruik ! om het te forcerenX
-Tijdelijk bestand; exit negeert wijzigingenX
-Bestand niet schrijfbaar, wijzigingen niet automatisch weggeschrevenX
-log opnieuw gestartX
-Bevestig? [ynq]X
-Druk op een toets om door te gaan: X
-Druk op een toets om door te gaan [: voor meer ex commandos]: X
-Druk op een toets om door te gaan [q om te stoppen]: X
-Deze vorm van %s vereist de ex terminal interfaceX
-Entering ex input mode.X
-Commando mislukt, nog geen bestand geladen.X
- doorgaan?X
-Onverwacht character eventX
-Onverwacht end-of-file eventX
-Geen match gevonden voor dit patroonX
-Onverwacht interrupt eventX
-Onverwacht quit eventX
-Onverwacht repaint eventX
-Reeds op de laatste tag van deze groepX
-Het %s command vereist de ex terminal interfaceX
-Deze vorm van %s is niet ondersteund als de secure edit optie actief isX
-Onverwacht string eventX
-Onverwacht timeout eventX
-Onverwacht write eventX
-
-Shell expansies zijn niet ondersteund als de secure edit optie actief isX
-Het %s commando is niet ondersteund als de secure edit optie actief isX
-set: %s mag niet uitgezet wordenX
-Scherm te klein.X
-toegevoegdX
-gewijzigdX
-verwijderdX
-samengevoegdX
-verplaatstX
-verschovenX
-gebufferdX
-regelX
-regelsX
-Vi was niet geladen met een Tcl interpreterX
-Bestand gewijzigd sinds het de laatste keer weg is geschreven.X
-Shell expansie misluktX
-Geen %s edit optie opgegevenX
-Vi was niet geladen met een Perl interpreterX
-Geen ex commando om uit te voerenX
-Kies <CR> om commando uit te voeren, :q om te stoppenX
-Gebruik "cscope help" voor uitlegX
-Nog geen cscope connectie aanwezigX
-%s: onbekend zoek type: gebruik een van %sX
-%d: onbekende cscope sessieX
-set: de %s optie mag nooit aangezet wordenX
-set: de %s optie mag nooit op 0 gezet wordenX
-%s: toegevoegd: %lu regels, %lu karaktersX
-Onverwacht resize eventX
-%d bestanden te wijzigenX
diff --git a/catalog/dutch.base b/catalog/dutch.base
index 2d8667e6d460..eca193c28c04 100644
--- a/catalog/dutch.base
+++ b/catalog/dutch.base
@@ -43,8 +43,7 @@
044 "De lisp optie is niet ondersteund"
045 "messages niet uitgeschakeld: %s"
046 "messages niet geactiveerd: %s"
-048 "De paragraph optie moet karakter paren bevatten"
-049 "De section optie moet karakter paren bevatten"
+047 "De %s optie moet karakter paren bevatten"
053 "De standaard buffer is leeg"
054 "Buffer %s is leeg"
055 "Bestanden met newlines in de naam kunnen niet hersteld worden"
@@ -97,16 +96,16 @@
103 "Ongeldig adres: het bestand is leeg"
104 "Het %s commando staat het adres 0 niet toe"
105 "Geen afkortingen om weer te geven"
-106 "Afkortingen moeten eindigen met een "woord" letter"
+106 "Afkortingen moeten eindigen met een \"woord\" letter"
107 "Afkortingen mogen geen tabulaties of spaties bevatten"
108 "Afkortingen mogen geen woord/niet-woord karakters mengen, behalve aan het einde"
-109 ""%s" is geen afkorting"
+109 "\"%s\" is geen afkorting"
110 "Vi commando mislukt: gemappede toetsen genegeerd"
111 "Dit is het laatste bestand"
112 "Dit is het eerste bestand"
113 "Dit is het eerste bestand"
114 "lijst met bestanden is leeg"
-115 "Geen voorgaand commando om "!" te vervangen"
+115 "Geen voorgaand commando om \"!\" te vervangen"
116 "Geen bestandsnaam voor %%"
117 "Geen bestandsnaam voor #"
118 "Fout: execl: %s"
@@ -119,14 +118,14 @@
125 "%s/%s: niet gelezen: noch U noch root is de eigenaar"
126 "%s/%s: niet gelezen: U bent niet de eigenaar"
127 "%s/%s: niet gelezen: kan gewijzigd worden door andere gebruikers"
-128 "%s: niet gelezen: noch U noch root is de eigenaar""
+128 "%s: niet gelezen: noch U noch root is de eigenaar"
129 "%s: niet gelezen: U bent niet de eigenaar"
130 "%s: niet gelezen: kan gewijzigd worden door andere gebruikers"
131 "Geen volgende regel om samen te voegen"
132 "Geen input map entries"
133 "Geen command map entries"
134 "Het %s karakter kan niet ge-remapped worden"
-135 ""%s" is niet gemapped"
+135 "\"%s\" is niet gemapped"
136 "Merk naam moet een enkel karakter zijn"
137 "%s bestaat al, niet weggeschreven; gebruik ! om het te forceren"
138 "Nieuw .exrc bestand: %s. "
@@ -296,7 +295,7 @@
306 "Vi was niet geladen met een Perl interpreter"
307 "Geen ex commando om uit te voeren"
308 "Kies <CR> om commando uit te voeren, :q om te stoppen"
-309 "Gebruik "cscope help" voor uitleg"
+309 "Gebruik \"cscope help\" voor uitleg"
310 "Nog geen cscope connectie aanwezig"
311 "%s: onbekend zoek type: gebruik een van %s"
312 "%d: onbekende cscope sessie"
diff --git a/catalog/dutch.check b/catalog/dutch.check
deleted file mode 100644
index d651aec75cc2..000000000000
--- a/catalog/dutch.check
+++ /dev/null
@@ -1,37 +0,0 @@
-Unused message id's (this is okay):
-001
-047
-050
-051
-052
-081
-176
-213
-229
-288
-=========================
-MISSING ERROR MESSAGES (Please add!):
-=========================
-Extra error messages (just delete them):
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s bestaat al, niet weggeschreven; gebruik ! om het te forcerenX
- 2 %s resulteert in te veel bestandsnamenX
- 2 %s: %lu regels, %lu karaktersX
- 2 %s: verminkt herstel bestandX
- 2 Bestand wordt gecopieerd voor herstel...X
- 2 Buffer %s is leegX
- 2 Dit is het eerste bestandX
- 2 Er vindt geen logging plaats, kan wijzigingen niet ongedaan makenX
- 2 OnderbrokenX
- 2 Wijzigingen kunnen niet ongedaan gemaakt worden als deze sessie misluktX
- 2 gewijzigdX
- 2 set: %s optie moet een waarde hebbenX
- 3 %s: verwijdering misluktX
- 3 Bestand gewijzigd sinds laatste schrijfactie; schrijf het weg of gebruik ! om het te forcerenX
- 4 Gebruik: %sX
-=========================
diff --git a/catalog/english b/catalog/english
deleted file mode 100644
index f34451d9b6d5..000000000000
--- a/catalog/english
+++ /dev/null
@@ -1,317 +0,0 @@
-VI_MESSAGE_CATALOG
-Line length overflowX
-unable to delete line %luX
-unable to append to line %luX
-unable to insert at line %luX
-unable to store line %luX
-unable to get last lineX
-Error: unable to retrieve line %luX
-Log fileX
-Logging not being performed, undo not possibleX
-No changes to undoX
-Logging not being performed, undo not possibleX
-Logging not being performed, roll-forward not possibleX
-No changes to re-doX
-%s/%d: log put errorX
-Vi's standard input and output must be a terminalX
-Mark %s: not setX
-Mark %s: the line was deletedX
-Mark %s: cursor position no longer existsX
-Error: X
-new fileX
-name changedX
-modifiedX
-unmodifiedX
-UNLOCKEDX
-readonlyX
-line %lu of %lu [%ld%%]X
-empty fileX
-line %luX
-The file %s is not a message catalogX
-Unable to set default %s optionX
-Usage: %sX
-set: no %s option: 'set all' gives all option valuesX
-set: [no]%s option doesn't take a valueX
-set: %s option isn't a booleanX
-set: %s option: %sX
-set: %s option: %s: value overflowX
-set: %s option: %s is an illegal numberX
-set: %s option isn't a booleanX
-Screen columns too small, less than %dX
-Screen columns too large, greater than %dX
-Screen lines too small, less than %dX
-Screen lines too large, greater than %dX
-The lisp option is not implementedX
-messages not turned off: %sX
-messages not turned on: %sX
-
-The paragraph option must be in two character groupsX
-The section option must be in two character groupsX
-
-
-
-The default buffer is emptyX
-Buffer %s is emptyX
-Files with newlines in the name are unrecoverableX
-Modifications not recoverable if the session failsX
-Copying file for recovery...X
-Preservation failed: %sX
-Modifications not recoverable if the session failsX
-File backup failed: %sX
-Copying file for recovery...X
-Information on user id %u not foundX
-Unable to lock recovery fileX
-Recovery file buffer overrunX
-Recovery fileX
-%s: malformed recovery fileX
-%s: malformed recovery fileX
-No files named %s, readable by you, to recoverX
-There are older versions of this file for you to recoverX
-There are other files for you to recoverX
-not sending email: %sX
-File empty; nothing to searchX
-Reached end-of-file without finding the patternX
-No previous search patternX
-Pattern not foundX
-Reached top-of-file without finding the patternX
-Search wrappedX
-Searching...X
-No non-printable character foundX
-Unknown command nameX
-
-%s: command not available in ex modeX
-Count may not be zeroX
-%s: bad line specificationX
-Internal syntax table error (%s: %s)X
-Usage: %sX
-%s: temporary buffer not releasedX
-Flag offset to before line 1X
-Flag offset past end-of-fileX
-@ with range running when the file/screen changedX
-Global/v command running when the file/screen changedX
-Ex command failed: pending commands discardedX
-Ex command failed: mapped keys discardedX
-The second address is smaller than the firstX
-No mark name suppliedX
-\\ not followed by / or ?X
-Reference to a line number less than 0X
-The %s command is unknownX
-Address value overflowX
-Address value underflowX
-Illegal address combinationX
-Illegal address: only %lu lines in the fileX
-Illegal address: the file is emptyX
-The %s command doesn't permit an address of 0X
-No abbreviations to displayX
-Abbreviations must end with a "word" characterX
-Abbreviations may not contain tabs or spacesX
-Abbreviations may not mix word/non-word characters, except at the endX
-"%s" is not an abbreviationX
-Vi command failed: mapped keys discardedX
-No more files to editX
-No previous files to editX
-No previous files to rewindX
-No file list to displayX
-No previous command to replace "!"X
-No filename to substitute for %%X
-No filename to substitute for #X
-Error: execl: %sX
-I/O error: %sX
-File modified since last complete write; write or use ! to overrideX
-Unable to find home directory locationX
-New current directory: %sX
-No cut buffers to displayX
-The %s command can't be used as part of a global or v commandX
-%s/%s: not sourced: not owned by you or rootX
-%s/%s: not sourced: not owned by youX
-%s/%s: not sourced: writeable by a user other than the ownerX
-%s: not sourced: not owned by you or rootX
-%s: not sourced: not owned by youX
-%s: not sourced: writeable by a user other than the ownerX
-No following lines to joinX
-No input map entriesX
-No command map entriesX
-The %s character may not be remappedX
-"%s" isn't currently mappedX
-Mark names must be a single characterX
-%s exists, not written; use ! to overrideX
-New exrc file: %sX
-Destination line is inside move rangeX
-The open command requires that the open option be setX
-The open command is not yet implementedX
-Preservation of this file not possibleX
-File preservedX
-%s: expanded into too many file namesX
-Only regular files and named pipes may be readX
-%s: read lock was unavailableX
-Reading...X
-%s: %lu lines, %lu charactersX
-No background screens to displayX
-The script command is only available in vi modeX
-No command to executeX
-shiftwidth option set to 0X
-Count overflowX
-Count underflowX
-Regular expression specified; r flag meaninglessX
-The #, l and p flags may not be combined with the c flag in vi modeX
-No match foundX
-No previous tag enteredX
-Less than %s entries on the tags stack; use :display t[ags]X
-No file %s on the tags stack to return to; use :display t[ags]X
-Press Enter to continue: X
-%s: tag not foundX
-%s: corrupted tag in %sX
-%s: the tag's line number is past the end of the fileX
-The tags stack is emptyX
-%s: search pattern not foundX
-%d more files to editX
-Buffer %s is emptyX
-Confirm change? [n]X
-InterruptedX
-No previous buffer to executeX
-No previous regular expressionX
-The %s command requires that a file have already been read inX
-Usage: %sX
-The visual command requires that the open option be setX
-
-Empty fileX
-No previous F, f, T or t searchX
-%s not foundX
-No previous file to editX
-Cursor not in a numberX
-Resulting number too largeX
-Resulting number too smallX
-No match character on this lineX
-Matching character not foundX
-No characters to replaceX
-No other screen to switch toX
-Characters after search string, line offset and/or z commandX
-No previous search patternX
-Search wrapped to original positionX
-Abbreviation exceeded expansion limit: characters discardedX
-Illegal character; quote to enterX
-Already at the beginning of the insertX
-No more characters to eraseX
-Movement past the end-of-fileX
-Movement past the end-of-lineX
-No cursor movement madeX
-Already at the beginning of the fileX
-Movement past the beginning of the fileX
-Already in the first columnX
-Buffers should be specified before the commandX
-Already at end-of-fileX
-Already at end-of-lineX
-%s isn't a vi commandX
-Usage: %sX
-No characters to deleteX
-The Q command requires the ex terminal interfaceX
-No command to repeatX
-The file is emptyX
-%s may not be used as a motion commandX
-Already in command modeX
-Cursor not in a wordX
-
-Windows option value is too large, max is %uX
-AppendX
-ChangeX
-CommandX
-InsertX
-ReplaceX
-Movement past the end-of-screenX
-Movement past the beginning-of-screenX
-Screen must be larger than %d lines to splitX
-There are no background screensX
-There's no background screen editing a file named %sX
-You may not background your only displayed screenX
-The screen can only shrink to %d rowsX
-The screen cannot shrinkX
-The screen cannot growX
-
-This screen may not be suspendedX
-Interrupted: mapped keys discardedX
-vi: temporary buffer not releasedX
-This terminal has no %s keyX
-Only one buffer may be specifiedX
-Number larger than %luX
-InterruptedX
-Unable to create temporary fileX
-Warning: %s is not a regular fileX
-%s already locked, session is read-onlyX
-%s: removeX
-%s: closeX
-%s: removeX
-%s: removeX
-Read-only file, not written; use ! to overrideX
-Read-only file, not writtenX
-%s exists, not written; use ! to overrideX
-%s exists, not writtenX
-Partial file, not written; use ! to overrideX
-Partial file, not writtenX
-%s: file modified more recently than this copy; use ! to overrideX
-%s: file modified more recently than this copyX
-%s: write lock was unavailableX
-Writing...X
-%s: WARNING: FILE TRUNCATEDX
-Already at the first tag of this groupX
-%s: new file: %lu lines, %lu charactersX
-%s: %lu lines, %lu charactersX
-%s expanded into too many file namesX
-%s: not a regular fileX
-%s: not owned by youX
-%s: accessible by a user other than the ownerX
-File modified since last complete write; write or use ! to overrideX
-File modified since last complete write; write or use :edit! to overrideX
-File modified since last complete write; write or use ! to overrideX
-File is a temporary; exit will discard modificationsX
-File readonly, modifications not auto-writtenX
-Log restartedX
-confirm? [ynq]X
-Press any key to continue: X
-Press any key to continue [: to enter more ex commands]: X
-Press any key to continue [q to quit]: X
-That form of %s requires the ex terminal interfaceX
-Entering ex input mode.X
-Command failed, no file read in yet.X
- cont?X
-Unexpected character eventX
-Unexpected end-of-file eventX
-No matches for queryX
-Unexpected interrupt eventX
-Unexpected quit eventX
-Unexpected repaint eventX
-Already at the last tag of this groupX
-The %s command requires the ex terminal interfaceX
-That form of %s is not supported when the secure edit option is setX
-Unexpected string eventX
-Unexpected timeout eventX
-Unexpected write eventX
-
-Shell expansions not supported when the secure edit option is setX
-The %s command is not supported when the secure edit option is setX
-set: the %s option may not be turned offX
-Display too small.X
-addedX
-changedX
-deletedX
-joinedX
-movedX
-shiftedX
-yankedX
-lineX
-linesX
-Vi was not loaded with a Tcl interpreterX
-File modified since last write.X
-Shell expansion failedX
-No %s edit option specifiedX
-Vi was not loaded with a Perl interpreterX
-No ex command to executeX
-Enter <CR> to execute a command, :q to exitX
-Use "cscope help" for helpX
-No cscope connections runningX
-%s: unknown search type: use one of %sX
-%d: no such cscope sessionX
-set: the %s option may never be turned onX
-set: the %s option may never be set to 0X
-%s: appended: %lu lines, %lu charactersX
-Unexpected resize eventX
-%d files to editX
diff --git a/catalog/english.base b/catalog/english.base
deleted file mode 100644
index 6d8d7bf60bbf..000000000000
--- a/catalog/english.base
+++ /dev/null
@@ -1,309 +0,0 @@
-002 "Line length overflow"
-003 "unable to delete line %lu"
-004 "unable to append to line %lu"
-005 "unable to insert at line %lu"
-006 "unable to store line %lu"
-007 "unable to get last line"
-008 "Error: unable to retrieve line %lu"
-009 "Log file"
-010 "Logging not being performed, undo not possible"
-011 "No changes to undo"
-012 "Logging not being performed, undo not possible"
-013 "Logging not being performed, roll-forward not possible"
-014 "No changes to re-do"
-015 "%s/%d: log put error"
-016 "Vi's standard input and output must be a terminal"
-017 "Mark %s: not set"
-018 "Mark %s: the line was deleted"
-019 "Mark %s: cursor position no longer exists"
-020 "Error: "
-021 "new file"
-022 "name changed"
-023 "modified"
-024 "unmodified"
-025 "UNLOCKED"
-026 "readonly"
-027 "line %lu of %lu [%ld%%]"
-028 "empty file"
-029 "line %lu"
-030 "The file %s is not a message catalog"
-031 "Unable to set default %s option"
-032 "Usage: %s"
-033 "set: no %s option: 'set all' gives all option values"
-034 "set: [no]%s option doesn't take a value"
-035 "set: %s option isn't a boolean"
-036 "set: %s option: %s"
-037 "set: %s option: %s: value overflow"
-038 "set: %s option: %s is an illegal number"
-039 "set: %s option isn't a boolean"
-040 "Screen columns too small, less than %d"
-041 "Screen columns too large, greater than %d"
-042 "Screen lines too small, less than %d"
-043 "Screen lines too large, greater than %d"
-044 "The lisp option is not implemented"
-045 "messages not turned off: %s"
-046 "messages not turned on: %s"
-048 "The paragraph option must be in two character groups"
-049 "The section option must be in two character groups"
-053 "The default buffer is empty"
-054 "Buffer %s is empty"
-055 "Files with newlines in the name are unrecoverable"
-056 "Modifications not recoverable if the session fails"
-057 "Copying file for recovery..."
-058 "Preservation failed: %s"
-059 "Modifications not recoverable if the session fails"
-060 "File backup failed: %s"
-061 "Copying file for recovery..."
-062 "Information on user id %u not found"
-063 "Unable to lock recovery file"
-064 "Recovery file buffer overrun"
-065 "Recovery file"
-066 "%s: malformed recovery file"
-067 "%s: malformed recovery file"
-068 "No files named %s, readable by you, to recover"
-069 "There are older versions of this file for you to recover"
-070 "There are other files for you to recover"
-071 "not sending email: %s"
-072 "File empty; nothing to search"
-073 "Reached end-of-file without finding the pattern"
-074 "No previous search pattern"
-075 "Pattern not found"
-076 "Reached top-of-file without finding the pattern"
-077 "Search wrapped"
-078 "Searching..."
-079 "No non-printable character found"
-080 "Unknown command name"
-082 "%s: command not available in ex mode"
-083 "Count may not be zero"
-084 "%s: bad line specification"
-085 "Internal syntax table error (%s: %s)"
-086 "Usage: %s"
-087 "%s: temporary buffer not released"
-088 "Flag offset to before line 1"
-089 "Flag offset past end-of-file"
-090 "@ with range running when the file/screen changed"
-091 "Global/v command running when the file/screen changed"
-092 "Ex command failed: pending commands discarded"
-093 "Ex command failed: mapped keys discarded"
-094 "The second address is smaller than the first"
-095 "No mark name supplied"
-096 "\\ not followed by / or ?"
-097 "Reference to a line number less than 0"
-098 "The %s command is unknown"
-099 "Address value overflow"
-100 "Address value underflow"
-101 "Illegal address combination"
-102 "Illegal address: only %lu lines in the file"
-103 "Illegal address: the file is empty"
-104 "The %s command doesn't permit an address of 0"
-105 "No abbreviations to display"
-106 "Abbreviations must end with a "word" character"
-107 "Abbreviations may not contain tabs or spaces"
-108 "Abbreviations may not mix word/non-word characters, except at the end"
-109 ""%s" is not an abbreviation"
-110 "Vi command failed: mapped keys discarded"
-111 "No more files to edit"
-112 "No previous files to edit"
-113 "No previous files to rewind"
-114 "No file list to display"
-115 "No previous command to replace "!""
-116 "No filename to substitute for %%"
-117 "No filename to substitute for #"
-118 "Error: execl: %s"
-119 "I/O error: %s"
-120 "File modified since last complete write; write or use ! to override"
-121 "Unable to find home directory location"
-122 "New current directory: %s"
-123 "No cut buffers to display"
-124 "The %s command can't be used as part of a global or v command"
-125 "%s/%s: not sourced: not owned by you or root"
-126 "%s/%s: not sourced: not owned by you"
-127 "%s/%s: not sourced: writeable by a user other than the owner"
-128 "%s: not sourced: not owned by you or root"
-129 "%s: not sourced: not owned by you"
-130 "%s: not sourced: writeable by a user other than the owner"
-131 "No following lines to join"
-132 "No input map entries"
-133 "No command map entries"
-134 "The %s character may not be remapped"
-135 ""%s" isn't currently mapped"
-136 "Mark names must be a single character"
-137 "%s exists, not written; use ! to override"
-138 "New exrc file: %s"
-139 "Destination line is inside move range"
-140 "The open command requires that the open option be set"
-141 "The open command is not yet implemented"
-142 "Preservation of this file not possible"
-143 "File preserved"
-144 "%s: expanded into too many file names"
-145 "Only regular files and named pipes may be read"
-146 "%s: read lock was unavailable"
-147 "Reading..."
-148 "%s: %lu lines, %lu characters"
-149 "No background screens to display"
-150 "The script command is only available in vi mode"
-151 "No command to execute"
-152 "shiftwidth option set to 0"
-153 "Count overflow"
-154 "Count underflow"
-155 "Regular expression specified; r flag meaningless"
-156 "The #, l and p flags may not be combined with the c flag in vi mode"
-157 "No match found"
-158 "No previous tag entered"
-159 "Less than %s entries on the tags stack; use :display t[ags]"
-160 "No file %s on the tags stack to return to; use :display t[ags]"
-161 "Press Enter to continue: "
-162 "%s: tag not found"
-163 "%s: corrupted tag in %s"
-164 "%s: the tag's line number is past the end of the file"
-165 "The tags stack is empty"
-166 "%s: search pattern not found"
-167 "%d more files to edit"
-168 "Buffer %s is empty"
-169 "Confirm change? [n]"
-170 "Interrupted"
-171 "No previous buffer to execute"
-172 "No previous regular expression"
-173 "The %s command requires that a file have already been read in"
-174 "Usage: %s"
-175 "The visual command requires that the open option be set"
-177 "Empty file"
-178 "No previous F, f, T or t search"
-179 "%s not found"
-180 "No previous file to edit"
-181 "Cursor not in a number"
-182 "Resulting number too large"
-183 "Resulting number too small"
-184 "No match character on this line"
-185 "Matching character not found"
-186 "No characters to replace"
-187 "No other screen to switch to"
-188 "Characters after search string, line offset and/or z command"
-189 "No previous search pattern"
-190 "Search wrapped to original position"
-191 "Abbreviation exceeded expansion limit: characters discarded"
-192 "Illegal character; quote to enter"
-193 "Already at the beginning of the insert"
-194 "No more characters to erase"
-195 "Movement past the end-of-file"
-196 "Movement past the end-of-line"
-197 "No cursor movement made"
-198 "Already at the beginning of the file"
-199 "Movement past the beginning of the file"
-200 "Already in the first column"
-201 "Buffers should be specified before the command"
-202 "Already at end-of-file"
-203 "Already at end-of-line"
-204 "%s isn't a vi command"
-205 "Usage: %s"
-206 "No characters to delete"
-207 "The Q command requires the ex terminal interface"
-208 "No command to repeat"
-209 "The file is empty"
-209 "The file is empty"
-210 "%s may not be used as a motion command"
-211 "Already in command mode"
-212 "Cursor not in a word"
-214 "Windows option value is too large, max is %u"
-215 "Append"
-216 "Change"
-217 "Command"
-218 "Insert"
-219 "Replace"
-220 "Movement past the end-of-screen"
-221 "Movement past the beginning-of-screen"
-222 "Screen must be larger than %d lines to split"
-223 "There are no background screens"
-224 "There's no background screen editing a file named %s"
-225 "You may not background your only displayed screen"
-226 "The screen can only shrink to %d rows"
-227 "The screen cannot shrink"
-228 "The screen cannot grow"
-230 "This screen may not be suspended"
-231 "Interrupted: mapped keys discarded"
-232 "vi: temporary buffer not released"
-233 "This terminal has no %s key"
-234 "Only one buffer may be specified"
-235 "Number larger than %lu"
-236 "Interrupted"
-237 "Unable to create temporary file"
-238 "Warning: %s is not a regular file"
-239 "%s already locked, session is read-only"
-240 "%s: remove"
-241 "%s: close"
-242 "%s: remove"
-243 "%s: remove"
-244 "Read-only file, not written; use ! to override"
-245 "Read-only file, not written"
-246 "%s exists, not written; use ! to override"
-247 "%s exists, not written"
-248 "Partial file, not written; use ! to override"
-249 "Partial file, not written"
-250 "%s: file modified more recently than this copy; use ! to override"
-251 "%s: file modified more recently than this copy"
-252 "%s: write lock was unavailable"
-253 "Writing..."
-254 "%s: WARNING: FILE TRUNCATED"
-255 "Already at the first tag of this group"
-256 "%s: new file: %lu lines, %lu characters"
-257 "%s: %lu lines, %lu characters"
-258 "%s expanded into too many file names"
-259 "%s: not a regular file"
-260 "%s: not owned by you"
-261 "%s: accessible by a user other than the owner"
-262 "File modified since last complete write; write or use ! to override"
-263 "File modified since last complete write; write or use :edit! to override"
-264 "File modified since last complete write; write or use ! to override"
-265 "File is a temporary; exit will discard modifications"
-266 "File readonly, modifications not auto-written"
-267 "Log restarted"
-268 "confirm? [ynq]"
-269 "Press any key to continue: "
-270 "Press any key to continue [: to enter more ex commands]: "
-271 "Press any key to continue [q to quit]: "
-272 "That form of %s requires the ex terminal interface"
-273 "Entering ex input mode."
-274 "Command failed, no file read in yet."
-275 " cont?"
-276 "Unexpected character event"
-277 "Unexpected end-of-file event"
-278 "No matches for query"
-279 "Unexpected interrupt event"
-280 "Unexpected quit event"
-281 "Unexpected repaint event"
-282 "Already at the last tag of this group"
-283 "The %s command requires the ex terminal interface"
-284 "That form of %s is not supported when the secure edit option is set"
-285 "Unexpected string event"
-286 "Unexpected timeout event"
-287 "Unexpected write event"
-289 "Shell expansions not supported when the secure edit option is set"
-290 "The %s command is not supported when the secure edit option is set"
-291 "set: the %s option may not be turned off"
-292 "Display too small."
-293 "added"
-294 "changed"
-295 "deleted"
-296 "joined"
-297 "moved"
-298 "shifted"
-299 "yanked"
-300 "line"
-301 "lines"
-302 "Vi was not loaded with a Tcl interpreter"
-303 "File modified since last write."
-304 "Shell expansion failed"
-304 "Shell expansion failed"
-305 "No %s edit option specified"
-306 "Vi was not loaded with a Perl interpreter"
-307 "No ex command to execute"
-308 "Enter <CR> to execute a command, :q to exit"
-309 "Use "cscope help" for help"
-310 "No cscope connections running"
-311 "%s: unknown search type: use one of %s"
-312 "%d: no such cscope session"
-313 "set: the %s option may never be turned on"
-314 "set: the %s option may never be set to 0"
-315 "%s: appended: %lu lines, %lu characters"
-316 "Unexpected resize event"
-317 "%d files to edit"
diff --git a/catalog/english.check b/catalog/english.check
deleted file mode 100644
index 51093785c87c..000000000000
--- a/catalog/english.check
+++ /dev/null
@@ -1,36 +0,0 @@
-Unused message id's (this is okay):
-001
-047
-050
-051
-052
-081
-176
-229
-288
-=========================
-MISSING ERROR MESSAGES (Please add!):
-=========================
-Extra error messages (just delete them):
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
- 2 209 "The file is empty"
- 2 304 "Shell expansion failed"
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s exists, not written; use ! to overrideX
- 2 %s: %lu lines, %lu charactersX
- 2 %s: malformed recovery fileX
- 2 Buffer %s is emptyX
- 2 Copying file for recovery...X
- 2 InterruptedX
- 2 Logging not being performed, undo not possibleX
- 2 Modifications not recoverable if the session failsX
- 2 No previous search patternX
- 2 set: %s option isn't a booleanX
- 3 %s: removeX
- 3 File modified since last complete write; write or use ! to overrideX
- 4 Usage: %sX
-=========================
diff --git a/catalog/french b/catalog/french
deleted file mode 100644
index a75c486ef9ba..000000000000
--- a/catalog/french
+++ /dev/null
@@ -1,317 +0,0 @@
-VI_MESSAGE_CATALOG
-D‚passement de longueur de ligneX
-impossible de supprimer la ligne %luX
-impossible d'ajouter … la ligne %luX
-impossible d'ins‚rer devant la ligne %luX
-impossible de stocker la ligne %luX
-impossible d'obtenir la derniŠre ligneX
-Erreur : impossible de r‚cup‚rer la ligne %luX
-Fichier journalX
-Aucune connexion n'‚tant effectu‚e, impossible d'annulerX
-Aucune action … annulerX
-Aucune connexion n'‚tant effectu‚e, impossible d'annulerX
-Aucune connexion n'‚tant effectu‚e, reprise actualis‚e impossibleX
-Aucune action … refaireX
-%s/%d : Erreur d'‚criture de journalX
-L'entr‚e et la sortie Vi standards doivent ˆtre un terminalX
-Marque %s : non d‚finieX
-Marque %s : la ligne a ‚t‚ supprim‚eX
-Marque %s : la position du curseur n'existe plusX
-Erreur : X
-nouveau fichierX
-le nom a chang‚X
-modifi‚X
-non modifi‚X
-DEVERROUILLEX
-lecture seuleX
-ligne %lu de %lu [%ld%%]X
-fichier videX
-ligne %luX
-Ce fichier %s n'est pas un catalogue de messagesX
-Impossible de configurer option %s par d‚fautX
-Utilisation : %sX
-D‚finition : pas d'option %s : 'tout d‚finir' donne toutes les valeurs optionnellesX
-D‚finition : option [no]%s ne prend pas de valeurX
-D‚finition : l'option %s n'est pas bool‚enneX
-D‚finition : option %s : %sX
-D‚finition : option %s : %s : D‚passement de valeurX
-D‚finition : option %s : %s n'est pas un nombre valideX
-D‚finition : l'option %s n'est pas bool‚enneX
-Les colonnes de l'‚cran sont trop petites, inf‚rieures … %dX
-Les colonnes de l'‚cran sont trop grandes, sup‚rieures … %dX
-Les lignes de l'‚cran sont trop courtes, inf‚rieures … %dX
-Les lignes de l'‚cran sont trop longues, sup‚rieures … %dX
-L'option lisp n'est pas impl‚ment‚eX
-Les messages ne sont pas d‚sactiv‚s : %sX
-Les messages ne sont pas activ‚s : %sX
-
-L'option de paragraphe doit ˆtre en groupe de deux caractŠresX
-L'option de section doit ˆtre en groupe de deux caractŠresX
-
-
-
-Le tampon par d‚faut est videX
-Le tampon %s est videX
-Les fichiers dont le nom contient des caractŠres de saut de ligne sont irr‚cup‚rablesX
-Impossible de r‚cup‚rer les modifications si la session ‚choueX
-Copie en cours du fichier pour r‚cup‚ration...X
-La pr‚servation a ‚chou‚ : %sX
-Impossible de r‚cup‚rer les modifications si la session ‚choueX
-La sauvegarde du fichier a ‚chou‚ : %sX
-Copie en cours du fichier pour r‚cup‚ration...X
-Les renseignements sur l'identit‚ %u de l'utilisateur sont introuvablesX
-Impossible de verrouiller le fichier de r‚cup‚rationX
-D‚bordement de tampon du fichier de r‚cup‚rationX
-Fichier de r‚cup‚rationX
-%s : Fichier de r‚cup‚ration malform‚X
-%s : Fichier de r‚cup‚ration malform‚X
-Aucun fichier nomm‚ %s … r‚cup‚rer, que vous puissiez lireX
-Il existe des versions r‚cup‚rables ant‚rieures … ce fichierX
-Vous avez d'autres fichiers … r‚cup‚rerX
-pas d'envoi d'email : %sX
-Fichier vide, rien … rechercherX
-Fin de fichier atteinte sans trouver le motifX
-Pas de motif de recherche pr‚c‚dentX
-Motif introuvableX
-D‚but du fichier atteint sans trouver le motifX
-La recherche est revenue … son point de d‚partX
-Recherche en cours...X
-CaractŠre non-imprimable introuvableX
-Nom de commande inconnuX
-
-%s : Commande non disponible en ex modeX
-Le compte ne peut ˆtre z‚roX
-%s : mauvaise sp‚cification de ligneX
-Erreur de tableau de syntaxe interne (%s: %s)X
-Utilisation : %sX
-%s : tampon temporaire non lib‚r‚X
-D‚calage de drapeau hors de la ligne 1X
-D‚calage de drapeau hors de la fin du fichierX
-@ avec plage, en cours d'ex‚cution quand le fichier/l'‚cran a chang‚X
-Commande Global/v en cours d'ex‚cution quand le fichier/l'‚cran a chang‚X
-La commande ex a ‚chou‚ : commandes en attente abandonn‚esX
-La commande ex a ‚chou‚ : les touches affect‚es sont abandonn‚esX
-La deuxiŠme adresse est plus petite que la premiŠreX
-Aucun nom de marque fourniX
-\\ pas suivi par / ou ?X
-R‚f‚rence … un num‚ro de ligne inf‚rieure … 0X
-La commande %s est inconnueX
-D‚passement de la valeur adresseX
-D‚passement n‚gatif de la valeur adresseX
-Combinaison d'adresse non valideX
-Adresse non valide : il n'y a que des lignes %lu dans le fichierX
-Adresse non valide : le fichier est videX
-La commande %s ne permet pas une adresse de 0X
-Pas d'abr‚viations … afficherX
-Les abr‚viations doivent finir par un caractŠre"motX
-Les abr‚viations ne peuvent pas contenir de tabulations ni d'espacesX
-Les abr‚viations ne peuvent pas contenir un m‚lange de caractŠres mot/non-mot, sauf … la finX
-"%s" n'est pas une abr‚viationX
-La commande Vi a ‚chou‚ : Les touches affect‚es ont ‚t‚ abandonn‚esX
-Plus de fichiers … ‚diterX
-Pas de fichiers pr‚c‚dents … ‚diterX
-Pas de fichiers pr‚c‚dents … rembobinerX
-Pas de liste de fichiers … afficherX
-Pas de commande pr‚c‚dente … remplacer"!"X
-Pas de nom de fichier … substituer … %%X
-Pas de nom de fichier … substituer … #X
-Erreur : execl : %sX
-Erreur E/S : %sX
-Fichier modifi‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser ! pour outrepasserX
-Impossible de trouver l'emplacement du r‚pertoire d'origineX
-Nouveau r‚pertoire en cours : %sX
-Pas de tampon de coupure … afficherX
-La commande %s ne peut pas ˆtre utilis‚e … l'int‚rieur d'une commande globale ou commande vX
-%s/%s : ‚chec de source : ni vous ni le super-utilisateur n'ˆtes les propri‚taires X
-%s/%s : ‚chec de source : vous n'ˆtes pas le propri‚taireX
-%s/%s : ‚chec de source : peut ˆtre ‚crit par un utilisateur autre que le propri‚taireX
-%s : ‚chec de source : ni vous ni le super-utilisateur n'ˆtes les propri‚tairesX
-%s : ‚chec de source : vous n'ˆtes pas le propri‚taireX
-%s : ‚chec de source : peut ˆtre ‚crit par un utilisateur autre que le propri‚taireX
-Pas de lignes suivantes … joindreX
-Pas d'entr‚es de mappage d'entr‚eX
-Pas d'entr‚es de mappage de commandesX
-Le caractŠre %s ne peut pas ˆtre remapp‚X
-"%s" n'est pas actuellement mapp‚X
-Les noms de marque ne doivent avoir qu'un caractŠreX
-%s existe, non enregistr‚; utiliser ! pour outrepasserX
-Nouveau fichier exrc : %sX
-La ligne de destination est … l'int‚rieur de la plage … d‚placerX
-La commande ouverte n‚cessite que l'option ouverte soit d‚finieX
-La commande ouverte n'est pas encore impl‚ment‚eX
-La pr‚servation de ce fichier est impossibleX
-Fichier pr‚serv‚X
-%s: ‚tendu dans trop de noms de fichiersX
-Vous ne pouvez lire que les fichiers standards et les canaux de transmission nomm‚sX
-%s: Interdiction de lecture non disponibleX
-Lecture en cours...X
-%s: %lu lignes, %lu caractŠresX
-Pas d'‚crans d'arriŠre-plan … afficherX
-La commande script n'est disponible qu'en mode viX
-Pas de commande … ex‚cuterX
-Option de largeur de d‚calage d‚finie sur 0X
-Compter d‚passementX
-Compter d‚passement n‚gatifX
-Expression standard sp‚cifi‚e; drapeau r superfluX
-Vous ne pouvez pas en mode vi, combiner les drapeaux #, l et p avec le drapeau cX
-Aucune correspondance trouv‚eX
-Aucune marque pr‚c‚dente entr‚eX
-Moins de %s entr‚es dans la pile de marques ; utilisez t[ags]X
-Pas de fichier %s vers lequel retourner dans la pile de marques ; utiliser : affichage t[ags]X
-Appuyez sur Entr‚e pour continuer :X
-%s : marque introuvableX
-%s : marque corrompue en %sX
-%s : le num‚ro de ligne de la marque d‚passe la fin du fichierX
-La pile de marques est videX
-%s : motif de recherche introuvableX
-%d fichiers suppl‚mentaires … ‚diterX
-Le tampon %s est vide
-Confirmer les changements ? [n]X
-InterrompuX
-Pas de tampon pr‚c‚dent … ex‚cuterX
-Pas d'expression standard pr‚c‚denteX
-La commande %s n‚cessite qu'un fichier ait d‚j… ‚t‚ lu en m‚moireX
-Utilisation : %sX
-La commande visuelle n‚cessite que l'option ouverte soit d‚finieX
-
-Fichier videX
-Pas de recherche pr‚c‚dente F, f, T ou tX
-%s introuvableX
-Pas de fichier pr‚c‚dent … ‚diterX
-Le curseur n'est pas dans un nombreX
-Le nombre obtenu est trop grandX
-Le nombre obtenu est trop petitX
-Pas de correspondance de caractŠre sur cette ligneX
-CaractŠre correspondant introuvableX
-Pas de caractŠres … remplacerX
-Pas d'autre ‚cran vers lequel basculerX
-CaractŠres aprŠs la chaŒne de recherche, d‚calage de ligne et/ou commande zX
-Pas de motif de recherche pr‚c‚dentX
-La recherche est revenue … son point de d‚partX
-L'abr‚viation a d‚pass‚ la limite de l'expansion : caractŠres abandonn‚sX
-CaractŠre non valide ; guillemet pour saisirX
-D‚j… au d‚but de l'insertionX
-Plus de caractŠres … effacerX
-D‚placement hors de fin de fichierX
-D‚placement hors de fin de ligneX
-Aucun mouvement de curseur n'a ‚t‚ effectu‚X
-D‚j… au d‚but du fichierX
-D‚placement hors du d‚but du fichierX
-D‚j… dans la premiŠre colonneX
-Les tampons doivent ˆtre sp‚cifi‚s avant la commandeX
-D‚j… … la fin du fichierX
-D‚j… … la fin de la ligneX
-%s n'est pas une commande viX
-Utilisation : %sX
-Pas de caractŠres … supprimerX
-La commande Q n‚cessite une interface terminal exX
-Pas de commande … r‚p‚terX
-Le fichier est videX
-Vous ne pouvez pas utiliser %s comme commande de d‚placementX
-D‚j… en mode commandeX
-Le curseur n'est pas dans un motX
-
-Valeur optionnelle de fenˆtre trop grande, maximum est %uX
-AjouterX
-ChangerX
-CommandeX
-Ins‚rerX
-RemplacerX
-D‚placement hors de la fin d'‚cranX
-D‚placement hors du d‚but d'‚cranX
-L'‚cran doit ˆtre sup‚rieur … %d lignes pour se fractionnerX
-Il n'y a pas d'‚cran d'arriŠre-planX
-Il n'y a pas d'‚cran d'arriŠre-plan qui ‚dite un fichier nomm‚ %sX
-Vous ne pouvez pas mettre … l'arriŠre-plan votre seul ‚cran affich‚X
-L'‚cran ne peut ˆtre r‚duit qu'… %d rangsX
-L'‚cran n'est pas auto-r‚ductibleX
-L'‚cran n'est pas auto-extensibleX
-
-Vous ne pouvez pas mettre cet ‚cran en attenteX
-Interrompu : les touches affect‚es ont ‚t‚ abandonn‚esX
-vi : le tampon temporaire n' a pas ‚t‚ lib‚r‚X
-Ce terminal n'a pas de touche %sX
-Vous ne pouvez sp‚cifier qu'un seul tamponX
-Nombre sup‚rieur … %luX
-InterrompuX
-Impossible de cr‚er un fichier temporaireX
-Avertissement : %s n'est pas un fichier standardX
-%s d‚j… verrouill‚, session en lecture seuleX
-%s: supprimerX
-%s: fermerX
-%s: supprimerX
-%s: supprimerX
-Fichier en lecture seule, pas ‚crit, utiliser ! pour outrepasserX
-Fichier en lecture seule, pas ‚critX
-%s existe, pas ‚crit; utiliser ! pour outrepasserX
-%s existe, pas ‚critX
-Fichier partiel, pas ‚crit; utiliser ! pour outrepasserX
-Fichier partiel, pas ‚critX
-%s: fichier modifi‚ plus r‚cemment que cet exemplaire; utiliser ! pour outrepasserX
-%s: fichier modifi‚ plus r‚cemment que cet exemplaireX
-%s: interdiction d'‚criture non disponibleX
-Ecriture en cours...X
-%s: AVERTISSEMENT : FICHIER TRONQUEX
-PremiŠre marque de ce groupe d‚j… atteinteX
-%s: nouveau fichier : %lu lignes, %lu caractŠresX
-%s: %lu lignes, %lu caractŠresX
-%s ‚tendue … trop de noms de fichiersX
-%s: pas un fichier standardX
-%s: ne vous appartient pasX
-%s: accessible par un utilisateur autre que son propri‚taireX
-Fichier modif‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser ! pour outrepasser X
-Fichier modif‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser :edit! pour outrepasserX
-Fichier modif‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser ! pour outrepasserX
-Fichier temporaire ; quitter annulera les modificationsX
-Fichier en lecture seule ; les modifications ne sont pas ‚crites automatiquementX
-Journal red‚marr‚X
-confirmer ? [ynq]X
-Appuyez sur n'importe quelle touche pour continuer : X
-Appuyez sur n'importe quelle touche pour continuer [: pour entrer plus de commandes ex] : X
-Appuyez sur n'importe quelle touche pour continuer [q pour Quitter]: X
-Cette forme de %s n‚cessite l'interface de terminal exX
-Entr‚e de mode entr‚e ex.X
-La commande a ‚chou‚, aucun fichier n'a encore ‚t‚ lu.X
-cont?X
-Ev‚nement impr‚vu de caractŠreX
-Ev‚nement impr‚vu de fin-de-fichierX
-Pas de correspondances pour cette requˆteX
-Ev‚nement impr‚vu d'interruptionX
-Ev‚nement quitter impr‚vuX
-Ev‚nement impr‚vu de rafraŒchissementX
-La derniŠre marque de ce groupe a d‚j… ‚t‚ atteinteX
-La commande %s n‚cessite l'interface de terminal exX
-Cette forme de %s n'est pas reconnue quand l'option d'‚dition prot‚g‚e est activ‚eX
-Ev‚nement impr‚vu de chaŒneX
-Ev‚nement impr‚vu de d‚lai impartiX
-Ev‚nement d'‚criture impr‚vuX
-
-Les expansions du shell ne sont pas reconnues quand l'option d'‚dition prot‚g‚e est activ‚eX
-La commande %s n'est pas reconnue quand l'option d'‚dition prot‚g‚e est activ‚eX
-D‚finition : l'option %s ne peut pas ˆtre d‚sactiv‚eX
-Affichage trop petit.X
-ajout‚X
-chang‚X
-supprim‚X
-jointX
-d‚plac‚X
-d‚cal‚X
-coup‚X
-ligneX
-lignesX
-Vi n'a pas ‚t‚ charg‚ avec un interpr‚tateur TclX
-Ficher modifi‚ depuis le dernier enregistrement.X
-L'expansion du shell a ‚chou‚X
-Pas d'option d'‚dition %s sp‚cifi‚eX
-Vi n'a pas ‚t‚ charg‚ avec un interpr‚tateur PerlX
-Pas de commande ex … ex‚cuterX
-Entrez <CR> pour ex‚cuter une commande, :q pour quitterX
-Utiliser "cscope help" pour obtenir de l'aideX
-Aucune connexion cscope n'est lanc‚eX
-%s : type de recherche inconnu : utiliser un des %sX
-%d : Il n'existe pas de telle session cscopeX
-D‚finition : l'option %s ne peut jamais ˆtre activ‚eX
-D‚finition : l'option %s ne peut jamais ˆtre d‚finie sur 0X
-%s: joints : %lu lignes, %lu caractŠresX
-‚v‚nement impr‚vu de redimensionnementX
-%d fichiers … ‚diterX
diff --git a/catalog/french.base b/catalog/french.base
index db2d45f9b220..234b8c6ba2c7 100644
--- a/catalog/french.base
+++ b/catalog/french.base
@@ -1,309 +1,306 @@
-002 "D‚passement de longueur de ligne"
+002 "Dépassement de longueur de ligne"
003 "impossible de supprimer la ligne %lu"
-004 "impossible d'ajouter … la ligne %lu"
-005 "impossible d'ins‚rer devant la ligne %lu"
+004 "impossible d'ajouter à la ligne %lu"
+005 "impossible d'insérer devant la ligne %lu"
006 "impossible de stocker la ligne %lu"
-007 "impossible d'obtenir la derniŠre ligne"
-008 "Erreur : impossible de r‚cup‚rer la ligne %lu"
+007 "impossible d'obtenir la dernière ligne"
+008 "Erreur : impossible de récupérer la ligne %lu"
009 "Fichier journal"
-010 "Aucune connexion n'‚tant effectu‚e, impossible d'annuler"
-011 "Aucune action … annuler"
-012 "Aucune connexion n'‚tant effectu‚e, impossible d'annuler"
-013 "Aucune connexion n'‚tant effectu‚e, reprise actualis‚e impossible"
-014 "Aucune action … refaire"
-015 "%s/%d : Erreur d'‚criture de journal"
-016 "L'entr‚e et la sortie Vi standards doivent ˆtre un terminal"
-017 "Marque %s : non d‚finie"
-018 "Marque %s : la ligne a ‚t‚ supprim‚e"
+010 "Aucune journalisation n'étant effectuée, impossible d'annuler"
+011 "Aucune action à annuler"
+012 "Aucune journalisation n'étant effectuée, impossible d'annuler"
+013 "Aucune journalisation n'étant effectuée, reprise actualisée impossible"
+014 "Aucune action à refaire"
+015 "%s/%d : Erreur d'écriture de journal"
+016 "L'entrée et la sortie Vi standards doivent être un terminal"
+017 "Marque %s : non définie"
+018 "Marque %s : la ligne a été supprimée"
019 "Marque %s : la position du curseur n'existe plus"
020 "Erreur : "
021 "nouveau fichier"
-022 "le nom a chang‚"
-023 "modifi‚"
-024 "non modifi‚"
-025 "DEVERROUILLE"
+022 "le nom a changé"
+023 "modifié"
+024 "non modifié"
+025 "DÉVERROUILLÉ"
026 "lecture seule"
027 "ligne %lu de %lu [%ld%%]"
028 "fichier vide"
029 "ligne %lu"
030 "Ce fichier %s n'est pas un catalogue de messages"
-031 "Impossible de configurer option %s par d‚faut"
+031 "Impossible de configurer option %s par défaut"
032 "Utilisation : %s"
-033 "D‚finition : pas d'option %s : 'tout d‚finir' donne toutes les valeurs optionnelles"
-034 "D‚finition : option [no]%s ne prend pas de valeur"
-035 "D‚finition : l'option %s n'est pas bool‚enne"
-036 "D‚finition : option %s : %s"
-037 "D‚finition : option %s : %s : D‚passement de valeur"
-038 "D‚finition : option %s : %s n'est pas un nombre valide"
-039 "D‚finition : l'option %s n'est pas bool‚enne"
-040 "Les colonnes de l'‚cran sont trop petites, inf‚rieures … %d"
-041 "Les colonnes de l'‚cran sont trop grandes, sup‚rieures … %d"
-042 "Les lignes de l'‚cran sont trop courtes, inf‚rieures … %d"
-043 "Les lignes de l'‚cran sont trop longues, sup‚rieures … %d"
-044 "L'option lisp n'est pas impl‚ment‚e"
-045 "Les messages ne sont pas d‚sactiv‚s : %s"
-046 "Les messages ne sont pas activ‚s : %s"
-048 "L'option de paragraphe doit ˆtre en groupe de deux caractŠres"
-049 "L'option de section doit ˆtre en groupe de deux caractŠres"
-053 "Le tampon par d‚faut est vide"
+033 "Définition : pas d'option %s : 'set all' donne toutes les valeurs optionnelles"
+034 "Définition : option [no]%s ne prend pas de valeur"
+035 "Définition : l'option %s n'est pas booléenne"
+036 "Définition : option %s : %s"
+037 "Définition : option %s : %s : Dépassement de valeur"
+038 "Définition : option %s : %s n'est pas un nombre valide"
+039 "Définition : l'option %s n'est pas booléenne"
+040 "Les colonnes de l'écran sont trop petites, inférieures à %d"
+041 "Les colonnes de l'écran sont trop grandes, supérieures à %d"
+042 "Les lignes de l'écran sont trop courtes, inférieures à %d"
+043 "Les lignes de l'écran sont trop longues, supérieures à %d"
+044 "L'option lisp n'est pas implémentée"
+045 "Les messages ne sont pas désactivés : %s"
+046 "Les messages ne sont pas activés : %s"
+047 "L'option de %s doit être en groupe de deux caractères"
+053 "Le tampon par défaut est vide"
054 "Le tampon %s est vide"
-055 "Les fichiers dont le nom contient des caractŠres de saut de ligne sont irr‚cup‚rables"
-056 "Impossible de r‚cup‚rer les modifications si la session ‚choue"
-057 "Copie en cours du fichier pour r‚cup‚ration..."
-058 "La pr‚servation a ‚chou‚ : %s"
-059 "Impossible de r‚cup‚rer les modifications si la session ‚choue"
-060 "La sauvegarde du fichier a ‚chou‚ : %s"
-061 "Copie en cours du fichier pour r‚cup‚ration..."
-062 "Les renseignements sur l'identit‚ %u de l'utilisateur sont introuvables"
-063 "Impossible de verrouiller le fichier de r‚cup‚ration"
-064 "D‚bordement de tampon du fichier de r‚cup‚ration"
-065 "Fichier de r‚cup‚ration"
-066 "%s : Fichier de r‚cup‚ration malform‚"
-067 "%s : Fichier de r‚cup‚ration malform‚"
-068 "Aucun fichier nomm‚ %s … r‚cup‚rer, que vous puissiez lire"
-069 "Il existe des versions r‚cup‚rables ant‚rieures … ce fichier"
-070 "Vous avez d'autres fichiers … r‚cup‚rer"
+055 "Les fichiers dont le nom contient des caractères de saut de ligne sont irrécupérables"
+056 "Impossible de récupérer les modifications si la session échoue"
+057 "Copie en cours du fichier pour récupération..."
+058 "La préservation a échoué : %s"
+059 "Impossible de récupérer les modifications si la session échoue"
+060 "La sauvegarde du fichier a échoué : %s"
+061 "Copie en cours du fichier pour récupération..."
+062 "Les renseignements sur l'identité %u de l'utilisateur sont introuvables"
+063 "Impossible de verrouiller le fichier de récupération"
+064 "Débordement de tampon du fichier de récupération"
+065 "Fichier de récupération"
+066 "%s : Fichier de récupération malformé"
+067 "%s : Fichier de récupération malformé"
+068 "Aucun fichier nommé %s à récupérer, que vous puissiez lire"
+069 "Il existe des versions récupérables antérieures à ce fichier"
+070 "Vous avez d'autres fichiers à récupérer"
071 "pas d'envoi d'email : %s"
-072 "Fichier vide, rien … rechercher"
+072 "Fichier vide, rien à rechercher"
073 "Fin de fichier atteinte sans trouver le motif"
-074 "Pas de motif de recherche pr‚c‚dent"
+074 "Pas de motif de recherche précédent"
075 "Motif introuvable"
-076 "D‚but du fichier atteint sans trouver le motif"
-077 "La recherche est revenue … son point de d‚part"
+076 "Début du fichier atteint sans trouver le motif"
+077 "La recherche est revenue à son point de départ"
078 "Recherche en cours..."
-079 "CaractŠre non-imprimable introuvable"
+079 "Caractère non-imprimable introuvable"
080 "Nom de commande inconnu"
082 "%s : Commande non disponible en ex mode"
-083 "Le compte ne peut ˆtre z‚ro"
-084 "%s : mauvaise sp‚cification de ligne"
+083 "Le compteur ne peut être zéro"
+084 "%s : mauvaise spécification de ligne"
085 "Erreur de tableau de syntaxe interne (%s: %s)"
086 "Utilisation : %s"
-087 "%s : tampon temporaire non lib‚r‚"
-088 "D‚calage de drapeau hors de la ligne 1"
-089 "D‚calage de drapeau hors de la fin du fichier"
-090 "@ avec plage, en cours d'ex‚cution quand le fichier/l'‚cran a chang‚"
-091 "Commande Global/v en cours d'ex‚cution quand le fichier/l'‚cran a chang‚"
-092 "La commande ex a ‚chou‚ : commandes en attente abandonn‚es"
-093 "La commande ex a ‚chou‚ : les touches affect‚es sont abandonn‚es"
-094 "La deuxiŠme adresse est plus petite que la premiŠre"
+087 "%s : tampon temporaire non libéré"
+088 "Décalage de drapeau hors de la ligne 1"
+089 "Décalage de drapeau hors de la fin du fichier"
+090 "@ avec plage, en cours d'exécution quand le fichier/l'écran a changé"
+091 "Commande Global/v en cours d'exécution quand le fichier/l'écran a changé"
+092 "La commande ex a échoué : commandes en attente abandonnées"
+093 "La commande ex a échoué : les touches affectées sont abandonnées"
+094 "La deuxième adresse est plus petite que la première"
095 "Aucun nom de marque fourni"
-096 "\\ pas suivi par / ou ?"
-097 "R‚f‚rence … un num‚ro de ligne inf‚rieure … 0"
+096 "\\ non suivi par / ou ?"
+097 "Référence à un numéro de ligne inférieure à 0"
098 "La commande %s est inconnue"
-099 "D‚passement de la valeur adresse"
-100 "D‚passement n‚gatif de la valeur adresse"
+099 "Dépassement de la valeur adresse"
+100 "Dépassement négatif de la valeur adresse"
101 "Combinaison d'adresse non valide"
-102 "Adresse non valide : il n'y a que des lignes %lu dans le fichier"
+102 "Adresse non valide : il n'y a que %lu lignes dans ce fichier"
103 "Adresse non valide : le fichier est vide"
104 "La commande %s ne permet pas une adresse de 0"
-105 "Pas d'abr‚viations … afficher"
-106 "Les abr‚viations doivent finir par un caractŠre"mot"
-107 "Les abr‚viations ne peuvent pas contenir de tabulations ni d'espaces"
-108 "Les abr‚viations ne peuvent pas contenir un m‚lange de caractŠres mot/non-mot, sauf … la fin"
-109 ""%s" n'est pas une abr‚viation"
-110 "La commande Vi a ‚chou‚ : Les touches affect‚es ont ‚t‚ abandonn‚es"
-111 "Plus de fichiers … ‚diter"
-112 "Pas de fichiers pr‚c‚dents … ‚diter"
-113 "Pas de fichiers pr‚c‚dents … rembobiner"
-114 "Pas de liste de fichiers … afficher"
-115 "Pas de commande pr‚c‚dente … remplacer"!""
-116 "Pas de nom de fichier … substituer … %%"
-117 "Pas de nom de fichier … substituer … #"
+105 "Pas d'abréviations à afficher"
+106 "Les abréviations doivent finir par un caractère \"mot\""
+107 "Les abréviations ne peuvent pas contenir de tabulations ni d'espaces"
+108 "Les abréviations ne peuvent pas contenir un mélange de caractères mot/non-mot, sauf à la fin"
+109 "\"%s\" n'est pas une abréviation"
+110 "La commande Vi a échoué : Les touches affectées ont été abandonnées"
+111 "Plus de fichiers à éditer"
+112 "Pas de fichiers précédents à éditer"
+113 "Pas de fichiers précédents à rembobiner"
+114 "Pas de liste de fichiers à afficher"
+115 "Pas de commande précédente à remplacer \"!\""
+116 "Pas de nom de fichier à substituer à %%"
+117 "Pas de nom de fichier à substituer à #"
118 "Erreur : execl : %s"
119 "Erreur E/S : %s"
-120 "Fichier modifi‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser ! pour outrepasser"
-121 "Impossible de trouver l'emplacement du r‚pertoire d'origine"
-122 "Nouveau r‚pertoire en cours : %s"
-123 "Pas de tampon de coupure … afficher"
-124 "La commande %s ne peut pas ˆtre utilis‚e … l'int‚rieur d'une commande globale ou commande v"
-125 "%s/%s : ‚chec de source : ni vous ni le super-utilisateur n'ˆtes les propri‚taires "
-126 "%s/%s : ‚chec de source : vous n'ˆtes pas le propri‚taire"
-127 "%s/%s : ‚chec de source : peut ˆtre ‚crit par un utilisateur autre que le propri‚taire"
-128 "%s : ‚chec de source : ni vous ni le super-utilisateur n'ˆtes les propri‚taires"
-129 "%s : ‚chec de source : vous n'ˆtes pas le propri‚taire"
-130 "%s : ‚chec de source : peut ˆtre ‚crit par un utilisateur autre que le propri‚taire"
-131 "Pas de lignes suivantes … joindre"
-132 "Pas d'entr‚es de mappage d'entr‚e"
-133 "Pas d'entr‚es de mappage de commandes"
-134 "Le caractŠre %s ne peut pas ˆtre remapp‚"
-135 ""%s" n'est pas actuellement mapp‚"
-136 "Les noms de marque ne doivent avoir qu'un caractŠre"
-137 "%s existe, non enregistr‚; utiliser ! pour outrepasser"
+120 "Fichier modifié depuis la dernière écriture complète ; écrire ou utiliser ! pour outrepasser"
+121 "Impossible de trouver l'emplacement du répertoire d'origine"
+122 "Nouveau répertoire en cours : %s"
+123 "Pas de tampon de coupure à afficher"
+124 "La commande %s ne peut pas être utilisée à l'intérieur d'une commande globale ou commande v"
+125 "%s/%s : échec de source : ni vous ni le super-utilisateur n'êtes les propriétaires "
+126 "%s/%s : échec de source : vous n'êtes pas le propriétaire"
+127 "%s/%s : échec de source : peut être écrit par un utilisateur autre que le propriétaire"
+128 "%s : échec de source : ni vous ni le super-utilisateur n'êtes les propriétaires"
+129 "%s : échec de source : vous n'êtes pas le propriétaire"
+130 "%s : échec de source : peut être écrit par un utilisateur autre que le propriétaire"
+131 "Pas de lignes suivantes à joindre"
+132 "Pas d'entrées de mappage d'entrée"
+133 "Pas d'entrées de mappage de commandes"
+134 "Le caractère %s ne peut pas être remappé"
+135 "\"%s\" n'est pas actuellement mappé"
+136 "Les noms de marque ne doivent avoir qu'un caractère"
+137 "%s existe, non enregistré; utiliser ! pour outrepasser"
138 "Nouveau fichier exrc : %s"
-139 "La ligne de destination est … l'int‚rieur de la plage … d‚placer"
-140 "La commande ouverte n‚cessite que l'option ouverte soit d‚finie"
-141 "La commande ouverte n'est pas encore impl‚ment‚e"
-142 "La pr‚servation de ce fichier est impossible"
-143 "Fichier pr‚serv‚"
-144 "%s: ‚tendu dans trop de noms de fichiers"
-145 "Vous ne pouvez lire que les fichiers standards et les canaux de transmission nomm‚s"
+139 "La ligne de destination est à l'intérieur de la plage à déplacer"
+140 "La commande ouverte nécessite que l'option ouverte soit définie"
+141 "La commande ouverte n'est pas encore implémentée"
+142 "La préservation de ce fichier est impossible"
+143 "Fichier préservé"
+144 "%s: étendu dans trop de noms de fichiers"
+145 "Vous ne pouvez lire que les fichiers standards et les canaux de transmission nommés"
146 "%s: Interdiction de lecture non disponible"
147 "Lecture en cours..."
-148 "%s: %lu lignes, %lu caractŠres"
-149 "Pas d'‚crans d'arriŠre-plan … afficher"
+148 "%s: %lu lignes, %lu caractères"
+149 "Pas d'écrans d'arrière-plan à afficher"
150 "La commande script n'est disponible qu'en mode vi"
-151 "Pas de commande … ex‚cuter"
-152 "Option de largeur de d‚calage d‚finie sur 0"
-153 "Compter d‚passement"
-154 "Compter d‚passement n‚gatif"
-155 "Expression standard sp‚cifi‚e; drapeau r superflu"
+151 "Pas de commande à exécuter"
+152 "Option de largeur de décalage définie sur 0"
+153 "Compter dépassement"
+154 "Compter dépassement négatif"
+155 "Expression standard spécifiée; drapeau r superflu"
156 "Vous ne pouvez pas en mode vi, combiner les drapeaux #, l et p avec le drapeau c"
-157 "Aucune correspondance trouv‚e"
-158 "Aucune marque pr‚c‚dente entr‚e"
-159 "Moins de %s entr‚es dans la pile de marques ; utilisez t[ags]"
+157 "Aucune correspondance trouvée"
+158 "Aucune marque précédente entrée"
+159 "Moins de %s entrées dans la pile de marques ; utilisez t[ags]"
160 "Pas de fichier %s vers lequel retourner dans la pile de marques ; utiliser : affichage t[ags]"
-161 "Appuyez sur Entr‚e pour continuer :"
+161 "Appuyez sur Entrée pour continuer :"
162 "%s : marque introuvable"
163 "%s : marque corrompue en %s"
-164 "%s : le num‚ro de ligne de la marque d‚passe la fin du fichier"
+164 "%s : le numéro de ligne de la marque dépasse la fin du fichier"
165 "La pile de marques est vide"
166 "%s : motif de recherche introuvable"
-167 "%d fichiers suppl‚mentaires … ‚diter"
+167 "%d fichiers supplémentaires à éditer"
168 "Le tampon %s est vide
169 "Confirmer les changements ? [n]"
170 "Interrompu"
-171 "Pas de tampon pr‚c‚dent … ex‚cuter"
-172 "Pas d'expression standard pr‚c‚dente"
-173 "La commande %s n‚cessite qu'un fichier ait d‚j… ‚t‚ lu en m‚moire"
+171 "Pas de tampon précédent à exécuter"
+172 "Pas d'expression standard précédente"
+173 "La commande %s nécessite qu'un fichier ait déjà été lu en mémoire"
174 "Utilisation : %s"
-175 "La commande visuelle n‚cessite que l'option ouverte soit d‚finie"
+175 "La commande visual nécessite que l'option open soit définie"
177 "Fichier vide"
-178 "Pas de recherche pr‚c‚dente F, f, T ou t"
+178 "Pas de recherche précédente F, f, T ou t"
179 "%s introuvable"
-180 "Pas de fichier pr‚c‚dent … ‚diter"
+180 "Pas de fichier précédent à éditer"
181 "Le curseur n'est pas dans un nombre"
182 "Le nombre obtenu est trop grand"
183 "Le nombre obtenu est trop petit"
-184 "Pas de correspondance de caractŠre sur cette ligne"
-185 "CaractŠre correspondant introuvable"
-186 "Pas de caractŠres … remplacer"
-187 "Pas d'autre ‚cran vers lequel basculer"
-188 "CaractŠres aprŠs la chaŒne de recherche, d‚calage de ligne et/ou commande z"
-189 "Pas de motif de recherche pr‚c‚dent"
-190 "La recherche est revenue … son point de d‚part"
-191 "L'abr‚viation a d‚pass‚ la limite de l'expansion : caractŠres abandonn‚s"
-192 "CaractŠre non valide ; guillemet pour saisir"
-193 "D‚j… au d‚but de l'insertion"
-194 "Plus de caractŠres … effacer"
-195 "D‚placement hors de fin de fichier"
-196 "D‚placement hors de fin de ligne"
-197 "Aucun mouvement de curseur n'a ‚t‚ effectu‚"
-198 "D‚j… au d‚but du fichier"
-199 "D‚placement hors du d‚but du fichier"
-200 "D‚j… dans la premiŠre colonne"
-201 "Les tampons doivent ˆtre sp‚cifi‚s avant la commande"
-202 "D‚j… … la fin du fichier"
-203 "D‚j… … la fin de la ligne"
+184 "Pas de correspondance de caractère sur cette ligne"
+185 "Caractère correspondant introuvable"
+186 "Pas de caractères à remplacer"
+187 "Pas d'autre écran vers lequel basculer"
+188 "Caractères après la chaîne de recherche, décalage de ligne et/ou commande z"
+189 "Pas de motif de recherche précédent"
+190 "La recherche est revenue à son point de départ"
+191 "L'abréviation a dépassé la limite de l'expansion : caractères abandonnés"
+192 "Caractère non valide ; guillemet pour saisir"
+193 "Déjà au début de l'insertion"
+194 "Plus de caractères à effacer"
+195 "Déplacement hors de fin de fichier"
+196 "Déplacement hors de fin de ligne"
+197 "Aucun mouvement de curseur n'a été effectué"
+198 "Déjà au début du fichier"
+199 "Déplacement hors du début du fichier"
+200 "Déjà dans la première colonne"
+201 "Les tampons doivent être spécifiés avant la commande"
+202 "Déjà à la fin du fichier"
+203 "Déjà à la fin de la ligne"
204 "%s n'est pas une commande vi"
205 "Utilisation : %s"
-206 "Pas de caractŠres … supprimer"
-207 "La commande Q n‚cessite une interface terminal ex"
-208 "Pas de commande … r‚p‚ter"
+206 "Pas de caractères à supprimer"
+207 "La commande Q nécessite une interface terminal ex"
+208 "Pas de commande à répéter"
209 "Le fichier est vide"
-209 "Le fichier est vide"
-210 "Vous ne pouvez pas utiliser %s comme commande de d‚placement"
-211 "D‚j… en mode commande"
+210 "Vous ne pouvez pas utiliser %s comme commande de déplacement"
+211 "Déjà en mode commande"
212 "Le curseur n'est pas dans un mot"
-214 "Valeur optionnelle de fenˆtre trop grande, maximum est %u"
+214 "Valeur optionnelle de fenêtre trop grande, maximum est %u"
215 "Ajouter"
216 "Changer"
217 "Commande"
-218 "Ins‚rer"
+218 "Insérer"
219 "Remplacer"
-220 "D‚placement hors de la fin d'‚cran"
-221 "D‚placement hors du d‚but d'‚cran"
-222 "L'‚cran doit ˆtre sup‚rieur … %d lignes pour se fractionner"
-223 "Il n'y a pas d'‚cran d'arriŠre-plan"
-224 "Il n'y a pas d'‚cran d'arriŠre-plan qui ‚dite un fichier nomm‚ %s"
-225 "Vous ne pouvez pas mettre … l'arriŠre-plan votre seul ‚cran affich‚"
-226 "L'‚cran ne peut ˆtre r‚duit qu'… %d rangs"
-227 "L'‚cran n'est pas auto-r‚ductible"
-228 "L'‚cran n'est pas auto-extensible"
-230 "Vous ne pouvez pas mettre cet ‚cran en attente"
-231 "Interrompu : les touches affect‚es ont ‚t‚ abandonn‚es"
-232 "vi : le tampon temporaire n' a pas ‚t‚ lib‚r‚"
+220 "Déplacement hors de la fin d'écran"
+221 "Déplacement hors du début d'écran"
+222 "L'écran doit être supérieur à %d lignes pour se fractionner"
+223 "Il n'y a pas d'écran d'arrière-plan"
+224 "Il n'y a pas d'écran d'arrière-plan qui édite un fichier nommé %s"
+225 "Vous ne pouvez pas mettre à l'arrière-plan votre seul écran affiché"
+226 "L'écran ne peut être réduit qu'à %d rangs"
+227 "L'écran n'est pas auto-réductible"
+228 "L'écran n'est pas auto-extensible"
+230 "Vous ne pouvez pas mettre cet écran en attente"
+231 "Interrompu : les touches affectées ont été abandonnées"
+232 "vi : le tampon temporaire n' a pas été libéré"
233 "Ce terminal n'a pas de touche %s"
-234 "Vous ne pouvez sp‚cifier qu'un seul tampon"
-235 "Nombre sup‚rieur … %lu"
+234 "Vous ne pouvez spécifier qu'un seul tampon"
+235 "Nombre supérieur à %lu"
236 "Interrompu"
-237 "Impossible de cr‚er un fichier temporaire"
+237 "Impossible de créer un fichier temporaire"
238 "Avertissement : %s n'est pas un fichier standard"
-239 "%s d‚j… verrouill‚, session en lecture seule"
+239 "%s déjà verrouillé, session en lecture seule"
240 "%s: supprimer"
241 "%s: fermer"
242 "%s: supprimer"
243 "%s: supprimer"
-244 "Fichier en lecture seule, pas ‚crit, utiliser ! pour outrepasser"
-245 "Fichier en lecture seule, pas ‚crit"
-246 "%s existe, pas ‚crit; utiliser ! pour outrepasser"
-247 "%s existe, pas ‚crit"
-248 "Fichier partiel, pas ‚crit; utiliser ! pour outrepasser"
-249 "Fichier partiel, pas ‚crit"
-250 "%s: fichier modifi‚ plus r‚cemment que cet exemplaire; utiliser ! pour outrepasser"
-251 "%s: fichier modifi‚ plus r‚cemment que cet exemplaire"
-252 "%s: interdiction d'‚criture non disponible"
+244 "Fichier en lecture seule, non écrit, utiliser ! pour outrepasser"
+245 "Fichier en lecture seule, non écrit"
+246 "%s existe, non écrit; utiliser ! pour outrepasser"
+247 "%s existe, non écrit"
+248 "Fichier partiel, non écrit; utiliser ! pour outrepasser"
+249 "Fichier partiel, non écrit"
+250 "%s: fichier modifié plus récemment que cet exemplaire; utiliser ! pour outrepasser"
+251 "%s: fichier modifié plus récemment que cet exemplaire"
+252 "%s: interdiction d'écriture non disponible"
253 "Ecriture en cours..."
-254 "%s: AVERTISSEMENT : FICHIER TRONQUE"
-255 "PremiŠre marque de ce groupe d‚j… atteinte"
-256 "%s: nouveau fichier : %lu lignes, %lu caractŠres"
-257 "%s: %lu lignes, %lu caractŠres"
-258 "%s ‚tendue … trop de noms de fichiers"
+254 "%s: AVERTISSEMENT : FICHIER TRONQUÉ"
+255 "Première marque de ce groupe déjà atteinte"
+256 "%s: nouveau fichier : %lu lignes, %lu caractères"
+257 "%s: %lu lignes, %lu caractères"
+258 "%s étendue à trop de noms de fichiers"
259 "%s: pas un fichier standard"
260 "%s: ne vous appartient pas"
-261 "%s: accessible par un utilisateur autre que son propri‚taire"
-262 "Fichier modif‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser ! pour outrepasser "
-263 "Fichier modif‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser :edit! pour outrepasser"
-264 "Fichier modif‚ depuis la derniŠre ‚criture complŠte ; ‚crire ou utiliser ! pour outrepasser"
+261 "%s: accessible par un utilisateur autre que son propriétaire"
+262 "Fichier modifé depuis la dernière écriture complète ; écrire ou utiliser ! pour outrepasser "
+263 "Fichier modifé depuis la dernière écriture complète ; écrire ou utiliser :edit! pour outrepasser"
+264 "Fichier modifé depuis la dernière écriture complète ; écrire ou utiliser ! pour outrepasser"
265 "Fichier temporaire ; quitter annulera les modifications"
-266 "Fichier en lecture seule ; les modifications ne sont pas ‚crites automatiquement"
-267 "Journal red‚marr‚"
+266 "Fichier en lecture seule ; les modifications ne sont pas écrites automatiquement"
+267 "Journal redémarré"
268 "confirmer ? [ynq]"
269 "Appuyez sur n'importe quelle touche pour continuer : "
270 "Appuyez sur n'importe quelle touche pour continuer [: pour entrer plus de commandes ex] : "
271 "Appuyez sur n'importe quelle touche pour continuer [q pour Quitter]: "
-272 "Cette forme de %s n‚cessite l'interface de terminal ex"
-273 "Entr‚e de mode entr‚e ex."
-274 "La commande a ‚chou‚, aucun fichier n'a encore ‚t‚ lu."
+272 "Cette forme de %s nécessite l'interface de terminal ex"
+273 "Entrée de mode entrée ex."
+274 "La commande a échoué, aucun fichier n'a encore été lu."
275 "cont?"
-276 "Ev‚nement impr‚vu de caractŠre"
-277 "Ev‚nement impr‚vu de fin-de-fichier"
-278 "Pas de correspondances pour cette requˆte"
-279 "Ev‚nement impr‚vu d'interruption"
-280 "Ev‚nement quitter impr‚vu"
-281 "Ev‚nement impr‚vu de rafraŒchissement"
-282 "La derniŠre marque de ce groupe a d‚j… ‚t‚ atteinte"
-283 "La commande %s n‚cessite l'interface de terminal ex"
-284 "Cette forme de %s n'est pas reconnue quand l'option d'‚dition prot‚g‚e est activ‚e"
-285 "Ev‚nement impr‚vu de chaŒne"
-286 "Ev‚nement impr‚vu de d‚lai imparti"
-287 "Ev‚nement d'‚criture impr‚vu"
-289 "Les expansions du shell ne sont pas reconnues quand l'option d'‚dition prot‚g‚e est activ‚e"
-290 "La commande %s n'est pas reconnue quand l'option d'‚dition prot‚g‚e est activ‚e"
-291 "D‚finition : l'option %s ne peut pas ˆtre d‚sactiv‚e"
+276 "Evénement imprévu de caractère"
+277 "Evénement imprévu de fin-de-fichier"
+278 "Pas de correspondances pour cette requête"
+279 "Evénement imprévu d'interruption"
+280 "Evénement quitter imprévu"
+281 "Evénement imprévu de rafraîchissement"
+282 "La dernière marque de ce groupe a déjà été atteinte"
+283 "La commande %s nécessite l'interface de terminal ex"
+284 "Cette forme de %s n'est pas reconnue quand l'option d'édition protégée est activée"
+285 "Evénement imprévu de chaîne"
+286 "Evénement imprévu de délai imparti"
+287 "Evénement d'écriture imprévu"
+289 "Les expansions du shell ne sont pas reconnues quand l'option d'édition protégée est activée"
+290 "La commande %s n'est pas reconnue quand l'option d'édition protégée est activée"
+291 "Définition : l'option %s ne peut pas être désactivée"
292 "Affichage trop petit."
-293 "ajout‚"
-294 "chang‚"
-295 "supprim‚"
+293 "ajouté"
+294 "changé"
+295 "supprimé"
296 "joint"
-297 "d‚plac‚"
-298 "d‚cal‚"
-299 "coup‚"
+297 "déplacé"
+298 "décalé"
+299 "coupé"
300 "ligne"
301 "lignes"
-302 "Vi n'a pas ‚t‚ charg‚ avec un interpr‚tateur Tcl"
-303 "Ficher modifi‚ depuis le dernier enregistrement."
-304 "L'expansion du shell a ‚chou‚"
-304 "L'expansion du shell a ‚chou‚"
-305 "Pas d'option d'‚dition %s sp‚cifi‚e"
-306 "Vi n'a pas ‚t‚ charg‚ avec un interpr‚tateur Perl"
-307 "Pas de commande ex … ex‚cuter"
-308 "Entrez <CR> pour ex‚cuter une commande, :q pour quitter"
-309 "Utiliser "cscope help" pour obtenir de l'aide"
-310 "Aucune connexion cscope n'est lanc‚e"
+302 "Vi n'a pas été chargé avec un interprétateur Tcl"
+303 "Ficher modifié depuis le dernier enregistrement."
+304 "L'expansion du shell a échoué"
+305 "Pas d'option d'édition %s spécifiée"
+306 "Vi n'a pas été chargé avec un interprétateur Perl"
+307 "Pas de commande ex à exécuter"
+308 "Entrez <CR> pour exécuter une commande, :q pour quitter"
+309 "Utiliser \"cscope help\" pour obtenir de l'aide"
+310 "Aucune connexion cscope n'est lancée"
311 "%s : type de recherche inconnu : utiliser un des %s"
312 "%d : Il n'existe pas de telle session cscope"
-313 "D‚finition : l'option %s ne peut jamais ˆtre activ‚e"
-314 "D‚finition : l'option %s ne peut jamais ˆtre d‚finie sur 0"
-315 "%s: joints : %lu lignes, %lu caractŠres"
-316 "‚v‚nement impr‚vu de redimensionnement"
-317 "%d fichiers … ‚diter"
+313 "Définition : l'option %s ne peut jamais être activée"
+314 "Définition : l'option %s ne peut jamais être définie sur 0"
+315 "%s: joints : %lu lignes, %lu caractères"
+316 "événement imprévu de redimensionnement"
+317 "%d fichiers à éditer"
diff --git a/catalog/french.check b/catalog/french.check
deleted file mode 100644
index 1e53d93cb446..000000000000
--- a/catalog/french.check
+++ /dev/null
@@ -1,34 +0,0 @@
-Unused message id's (this is okay):
-001
-047
-050
-051
-052
-081
-176
-229
-288
-=========================
-MISSING ERROR MESSAGES (Please add!):
-=========================
-Extra error messages (just delete them):
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
- 2 209 "Le fichier est vide"
- 2 304 "L'expansion du shell a ‚chou‚"
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s : Fichier de r‚cup‚ration malform‚X
- 2 %s: %lu lignes, %lu caractŠresX
- 2 Aucune connexion n'‚tant effectu‚e, impossible d'annulerX
- 2 Copie en cours du fichier pour r‚cup‚ration...X
- 2 D‚finition : l'option %s n'est pas bool‚enneX
- 2 Impossible de r‚cup‚rer les modifications si la session ‚choueX
- 2 InterrompuX
- 2 La recherche est revenue … son point de d‚partX
- 2 Pas de motif de recherche pr‚c‚dentX
- 3 %s: supprimerX
- 4 Utilisation : %sX
-=========================
diff --git a/catalog/german b/catalog/german
deleted file mode 100644
index 0810ba6cf9b4..000000000000
--- a/catalog/german
+++ /dev/null
@@ -1,317 +0,0 @@
-VI_MESSAGE_CATALOG
-Zeilenlaengen UeberlaufX
-kann Zeile %lu nicht loeschenX
-kann an Zeile %lu nicht anfuegenX
-kann in Zeile %lu nicht einfuegenX
-kann Zeile %lu nicht speichernX
-kann letzte Zeile nicht lesenX
-Fehler: kann Zeile %lu nicht wiederherstellenX
-ProtokolldateiX
-Keine Protokollierung aktiv, rueckgaengig machen nicht moeglichX
-Keine Aenderungen rueckgaengig zu machenX
-Keine Protokollierung aktiv, rueckgaengig machen nicht moeglichX
-Keine Protokollierung aktiv, Wiederholung von Aenderungen nicht moeglichX
-Keine Aenderungen zu wiederholenX
-%s/%d: ProtokollschreibfehlerX
-Vi's Standardein- und ausgabe muss ein Terminal seinX
-Marke %s: nicht gesetztX
-Marke %s: die Zeile wurde geloeschtX
-Marke %s: Cursorposition existiert nicht mehrX
-Fehler: X
-neue DateiX
-Name geaendertX
-geaendertX
-nicht geaendertX
-NICHT GELOCKEDX
-nur zum LesenX
-Zeile %lu von %lu [%ld%%]X
-leere DateiX
-Zeile %luX
-Die Datei %s ist kein MeldungskatalogX
-Setzen der Voreinstellung fuer %s Option nicht moeglichX
-Benutzung: %sX
-set: keine %s Option: 'set all' zeigt alle Optionen mit Werten anX
-set: der [no]%s Option kann kein Wert zugewiesen werdenX
-set: %s ist keine boolsche OptionX
-set: %s Option: %sX
-set: %s Option: %s: Wert UeberlaufX
-set: %s Option: %s ist eine ungueltige ZahlX
-set: %s ist keine boolsche OptionX
-Anzeige hat zu wenig Spalten, weniger als %dX
-Anzeige hat zu viele Spalten, mehr als %dX
-Anzeige hat zu wenig Zeilen, weniger als %dX
-Anzeige hat zu viele Zeilen, mehr als %dX
-Die lisp Option ist nicht implementiertX
-Messages nicht abgeschalten: %sX
-Messages nicht eingeschalten: %sX
-
-Die paragraph Option muss Gruppen zu zwei Zeichen enthaltenX
-Die section Option muss Gruppen zu zwei Zeichen enthaltenX
-
-
-
-Der Standardpuffer ist leerX
-Puffer %s ist leerX
-Dateien mit newlines im Namen sind nicht wiederherstellbarX
-Aenderungen nicht wiederherstellbar falls die Editorsitzung schief gehtX
-kopiere Datei fuer Wiederherstellung ...X
-Rettungsmechanismus funktioniert nicht: %sX
-Aenderungen nicht wiederherstellbar falls die Editorsitzung schief gehtX
-Sicherung der Datei gescheitert: %sX
-kopiere Datei fuer Wiederherstellung ...X
-Informationen ueber den Benutzer mit id %u nicht gefundenX
-Wiederherstellungsdatei kann nicht gesperrt werdenX
-Puffer der Wiederherstellungsdatei uebergelaufenX
-WiederherstellungsdateiX
-%s: Wiederherstellungsdatei hat falsches FormatX
-%s: Wiederherstellungsdatei hat falsches FormatX
-Keine von Ihnen lesbaren Dateien mit Namen %s zum WiederherstellenX
-Es gibt aeltere Versionen dieser Datei von Ihnen zum WiederherstellenX
-Sie haben noch andere Dateien zum WiederherstellenX
-schicke keine email: %sX
-Datei leer; nichts zu suchenX
-Dateiende erreicht, ohne das Suchmuster zu findenX
-Kein altes SuchmusterX
-Suchmuster nicht gefundenX
-Dateianfang erreicht, ohne das Suchmuster zu findenX
-Suche umgeschlagenX
-suche ...X
-Keine nichtdruckbaren Zeichen gefundenX
-Unbekannter KommandonameX
-
-%s: Kommando im ex Modus nicht verfuegbarX
-Count darf nicht Null seinX
-%s: falsche ZeilenangabeX
-Interner Syntaxtabellenfehler (%s: %s)X
-Benutzung: %sX
-%s: temporaerer Puffer nicht freigegebenX
-Flagoffset vor Zeile 1X
-Flagoffset hinter dem DateiendeX
-@ mit Bereich lief als Datei/Anzeige geaendert wurdeX
-globales oder v-Kommando lief als Datei/Anzeige geaendert wurdeX
-Ex Kommando misslungen: restliche Kommandoeingabe ignoriertX
-Ex Kommando misslungen: umdefinierte Tasten ungueltigX
-Die zweite Adresse ist kleiner als die ersteX
-Kein Markenname angegebenX
-\\ ohne folgenden / oder ?X
-Referenz auf eine negative ZeilennummerX
-Das Kommando %s ist unbekanntX
-Adresswert zu grossX
-Adresswert zu kleinX
-Ungueltige AdresskombinationX
-Ungueltige Adresse: nur %lu Zeilen in der DateiX
-Ungueltige Adresse: die Datei ist leerX
-Das Kommando %s erlaubt keine Adresse 0X
-Keine Abkuerzungen zum AnzeigenX
-Abkuerzungen muessen mit einem "Wort"-Zeichen endenX
-Abkuerzungen duerfen keine Tabulator- oder Leerzeichen enthaltenX
-In Abkuerzungen duerfen ausser am Ende Wort- und Nicht-Wort-Zeichen nicht gemischt werdenX
-"%s" ist keine AbkuerzungX
-Vi Kommando misslungen: umdefinierte Tasten ungueltigX
-Keine weiteren Dateien zu edierenX
-Keine vorhergehenden Dateien zu edierenX
-Keine vorhergehenden Dateien fuer rewindX
-Keine Dateiliste zum AnzeigenX
-Kein vorhergehendes Kommando um "!" zu ersetzenX
-Kein Dateiname fuer %%X
-Kein Dateiname fuer #X
-Fehler: execl: %sX
-I/O Fehler: %sX
-Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende ! zum ignorierenX
-Kann Homedirectory nicht bestimmenX
-Neues aktuelles Directory: %sX
-Keine Puffer anzuzeigenX
-Das Kommando %s kann nicht als Teil eines global oder v Kommandos verwendet werdenX
-%s/%s: nicht gelesen: gehoehrt weder Ihnen noch rootX
-%s/%s: nicht gelesen: gehoehrt nicht IhnenX
-%s/%s: nicht gelesen: anderer Benutzer als Eigentuemer hat SchreibrechtX
-%s: nicht gelesen: gehoehrt weder Ihnen noch rootX
-%s: nicht gelesen: gehoehrt nicht IhnenX
-%s: nicht gelesen: anderer Benutzer als Eigentuemer hat SchreibrechtX
-Keine folgenden Zeilen zum VerbindenX
-Kein Eingabe-Map EintragX
-Kein Kommando-Map EintragX
-Das %s Zeichen kann nicht umgemappt werdenX
-"%s" ist momentan nicht gemapptX
-Markennamen muessen einzelne Buchstaben seinX
-%s existiert, nicht geschrieben; verwende ! zum UeberschreibenX
-Neue .exrc Datei: %s. X
-Zielzeile ist innerhalb des VerschiebebereichsX
-Das open Kommando verlangt, dass die open Option gesetzt istX
-Das open Kommando ist nocht nicht implementiertX
-Rettung dieser Datei nicht moeglichX
-Datei gerettetX
-%s wurde in zu viele Dateinamen expandiertX
-Nur regulaere Dateien und named pipes koennen gelesen werdenX
-%s: Lesesperrung war nicht moeglichX
-lese ...X
-%s: %lu Zeilen, %lu ZeichenX
-Keine Hintegrundanzeigen vorhandenX
-Das script Kommando ist nur im vi Modus verfuegbarX
-Kein Kommando auszufuehrenX
-shiftwidth Option auf 0 gesetztX
-Count ueberlaufX
-Count unterlaufX
-Regulaerer Ausdruck angegeben; r Flag bedeutungslosX
-Die #, l und p Flags koennen im vi Modus nicht mit dem c Flag kombiniert werdenX
-Keine Uebereinstimmung gefundenX
-Kein vorhergehender 'tag' angegebenX
-Weniger als %s Eintraege auf dem 'tag'-Stack; verwende :display t[ags]X
-Keine Datei namens %s auf dem 'tag'-Stack; verwende :display t[ags]X
-Druecke Enter um fortzufahren: X
-%s: 'tag' nicht gefundenX
-%s: kaputter 'tag' in %sX
-%s: die Zeilennummer des 'tag' ist hinter dem DateiendeX
-Der 'tag' Stack ist leerX
-%s: Suchmuster nicht gefundenX
-%d weitere Dateien zu edierenX
-Puffer %s ist leerX
-Bestaetige Aenderung [n]X
-Unterbrochen.X
-Kein vorhergehender Puffer zum AusfuehrenX
-Kein vorhergehender regulaerer AusdruckX
-Das Kommando %s verlangt, dass bereits eine Datei eingelesen wurdeX
-Benutzung: %sX
-Das visual Kommando verlangt dass die open Option gesetzt istX
-
-Leere DateiX
-Keine vorhergehende F, f, T oder t SucheX
-%s nicht gefundenX
-Keine vorhergehende Datei zu edierenX
-Cursor nicht auf einer ZahlX
-Sich ergebende Zahl ist zu grossX
-Sich ergebende Zahl ist zu kleinX
-Kein korrespondierendes Zeichen in dieser ZeileX
-Korrespondierendes Zeichen nicht gefundenX
-Keine Zeichen zu ersetzenX
-Keine andere Anzeige zum HinschaltenX
-Zeichen nach Suchmuster, Zeilenoffset und/oder z KommandoX
-Kein altes SuchmusterX
-Suche zur urspruenglichen Position umgeschlagenX
-Abkuerzung ueberschreitet Expansionsgrenze: Zeichen weggelassenX
-Nicht erlaubtes Zeichen; maskiere zum EingebenX
-Bereits am Anfang der EingabeX
-Keine weiteren Zeichen zu loeschenX
-Bewegung hinter das DateiendeX
-Bewegung hinter das ZeilenendeX
-Keine Cursorbewegung gemachtX
-Bereits am DateianfangX
-Bewegung vor den DateianfangX
-Bereits in der ersten SpalteX
-Puffer sollen vor dem Kommando angegeben werdenX
-Bereits am DateiendeX
-Bereits am ZeilenendeX
-%s ist kein vi KommandoX
-Benutzung: %sX
-Keine Zeichen zu loeschenX
-Das Q Kommando benoetigt das ex Terminal InterfaceX
-Kein Kommando zu wiederholenX
-Die Datei ist leerX
-%s kann nicht als Bewegungskommando verwendet werdenX
-Bereits im Kommando-ModusX
- Cursor nicht auf einem WortX
-
-Wert der Window Option ist zu gross, max ist %uX
-AnfuegenX
-AendernX
-KommandoX
-EinfuegenX
-ErsetzenX
-Bewegung hinter das AnzeigenendeX
-Bewegung vor den AnzeigenanfangX
-Anzeige muss zum Zerlegen groesser als %d seinX
-Keine Hintergrundanzeigen vorhandenX
-Es gibt keine Hintergrundanzeige die eine Datei namens %s ediertX
-Die einzige dargestellte Anzeige kann nicht in den Hintergrund gebracht werdenX
-Die Anzeige kann nur auf %d Zeilen verkleinert werdenX
-Die Anzeige kann nicht verkleinert werdenX
-Die Anzeige kann nicht vergroessert werdenX
-
-Diese Anzeige kann nicht gestopped werdenX
-Unterbrochen: umdefinierte Tasten ungueltigX
-vi: temporaerer Puffer nicht freigegebenX
-Dieses Terminal hat keine %s TasteX
-es kann nur ein Puffer angegeben werdenX
-Zahl groesser als %luX
-UnterbrochenX
-Nicht moeglich temporaere Datei anzulegenX
-Warnung: %s ist keine regulaere DateiX
-%s ist bereits gesperrt, nur-lese EditorsitzungX
-%s: loeschenX
-%s: schliessenX
-%s: loeschenX
-%s: loeschenX
-Nur-lese Datei, nicht geschrieben; verwende ! zum UeberschreibenX
-Nur-lese Datei, nicht geschriebenX
-%s existiert, nicht geschrieben; verwende ! zum UeberschreibenX
-%s existiert, nicht geschriebenX
-Teil der Datei, nicht geschrieben; verwende ! zum UeberschreibenX
-Teil der Datei, nicht geschriebenX
-%s: Datei wurde spaeter als diese Kopie veraendert; verwende ! zum UeberschreibenX
-%s: Datei wurde spaeter als diese Kopie veraendertX
-%s: Schreibsperrung war nicht moeglichX
-schreibe ...X
-%s: WARNUNG: DATEI ABGESCHNITTENX
-Bereits am ersten 'tag' dieser GruppeX
-%s: neue Datei: %lu Zeilen, %lu ZeichenX
-%s: %lu Zeilen, %lu ZeichenX
-%s wurde in zu viele Dateinamen expandiertX
-%s: keine regulaere DateiX
-%s: gehoehrt nicht IhnenX
-%s: anderer Benutzer als Eigentuemer hat ZugriffX
-Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende ! zum ignorierenX
-Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende :edit! zum ignorierenX
-Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende ! zum ignorierenX
-Datei ist temporaer; beim Verlassen gehen die Aenderungen verlorenX
-Nur-lese Datei, Aenderungen werden nicht automatisch geschriebenX
-Portokollierung neu begonnenX
-bestaetigen [ynq]X
-Druecke beliebige Taste um fortzufahrenX
-Druecke beliebige Taste um fortzufahren [: um weitere Kommandos einzugeben]: X
-Druecke beliebige Taste um fortzufahren [q zum Verlassen]: X
-Diese Form von %s benoetigt das ex Terminal-InterfaceX
-Gehe in ex Eingabe-Modus.\nX
-Kommando schief gelaufen, noch keine Datei eingelesenX
- weiter?X
-unerwartetes Zeichen - EreignisX
-unerwartetes Dateiende - EreignisX
-Keine Position zum Anspringen gefundenX
-unerwartetes Unterbrechungs - EreignisX
-unerwartetes Verlassen - EreignisX
-unerwartetes Wiederherstellungs - EreignisX
-Bereits am letzten 'tag' dieser GruppeX
-Das %s Kommando benoetigt das ex Terminal-InterfaceX
-Diese Form von %s wird nicht unterstuetzt wenn die 'secure edit' - Option gesetzt istX
-unerwartetes Zeichenketten - EreignisX
-unerwartetes timeout - EreignisX
-unerwartetes Schreibe - EreignisX
-
-Shell Expandierungen nicht unterstuetzt wenn die 'secure edit' - Option gesetzt istX
-Das %s Kommando wird nicht unterstuetzt wenn die 'secure edit' - Option gesetzt istX
-set: %s kann nicht ausgeschaltet werdenX
-Anzeige zu klein.X
-angefuegtX
-geaendertX
-geloeschtX
-verbundenX
-verschobenX
-geschobenX
-in Puffer geschriebenX
-ZeileX
-ZeilenX
-Vi wurde nicht mit dem Tcl Interpreter gelinktX
-Datei wurde seit dem letzten Schreiben veraendert.X
-Shell Expansion nicht geklapptX
-Es ist keine %s Edieroption angegebenX
-Vi wurde nicht mit einem Perl Interpreter geladenX
-Kein ex Kommando auszufuehrenX
-Druecke <CR> um ein Kommando auszufuehren, :q zum verlassenX
-Verwende "cscope help" fuer HilestellungX
-Keine cscope Verbindung aktivX
-%s: unbekannter Suchtyp: verwende einen aus %sX
-%d: keine solche cscope VerbindungX
-set: die %s Option kann nicht eingeschaltet werdenX
-set: die %s Option kann nicht auf 0 gesetzt werdenX
-%s: angefuegt: %lu Zeilen, %lu ZeichenX
-unerwartetes Groessenveraenderungs - EreignisX
-%d Dateien zu edierenX
diff --git a/catalog/german.base b/catalog/german.base
index 135b72da7994..f636df2b9c18 100644
--- a/catalog/german.base
+++ b/catalog/german.base
@@ -1,67 +1,66 @@
-002 "Zeilenlaengen Ueberlauf"
-003 "kann Zeile %lu nicht loeschen"
-004 "kann an Zeile %lu nicht anfuegen"
-005 "kann in Zeile %lu nicht einfuegen"
+002 "Zeilenlängen-Überlauf"
+003 "kann Zeile %lu nicht löschen"
+004 "kann an Zeile %lu nicht anfügen"
+005 "kann in Zeile %lu nicht einfügen"
006 "kann Zeile %lu nicht speichern"
007 "kann letzte Zeile nicht lesen"
008 "Fehler: kann Zeile %lu nicht wiederherstellen"
009 "Protokolldatei"
-010 "Keine Protokollierung aktiv, rueckgaengig machen nicht moeglich"
-011 "Keine Aenderungen rueckgaengig zu machen"
-012 "Keine Protokollierung aktiv, rueckgaengig machen nicht moeglich"
-013 "Keine Protokollierung aktiv, Wiederholung von Aenderungen nicht moeglich"
-014 "Keine Aenderungen zu wiederholen"
+010 "Keine Protokollierung aktiv, Rückgängigmachen nicht möglich"
+011 "Keine Änderungen rückgängig zu machen"
+012 "Keine Protokollierung aktiv, Rückgängigmachen nicht möglich"
+013 "Keine Protokollierung aktiv, Wiederholung von Änderungen nicht möglich"
+014 "Keine Änderungen zu wiederholen"
015 "%s/%d: Protokollschreibfehler"
-016 "Vi's Standardein- und ausgabe muss ein Terminal sein"
+016 "Vi's Standardein- und -ausgabe muß ein Terminal sein"
017 "Marke %s: nicht gesetzt"
-018 "Marke %s: die Zeile wurde geloescht"
+018 "Marke %s: die Zeile wurde gelöscht"
019 "Marke %s: Cursorposition existiert nicht mehr"
020 "Fehler: "
021 "neue Datei"
-022 "Name geaendert"
-023 "geaendert"
-024 "nicht geaendert"
-025 "NICHT GELOCKED"
+022 "Name geändert"
+023 "geändert"
+024 "nicht geändert"
+025 "NICHT GELOCKT"
026 "nur zum Lesen"
027 "Zeile %lu von %lu [%ld%%]"
028 "leere Datei"
029 "Zeile %lu"
030 "Die Datei %s ist kein Meldungskatalog"
-031 "Setzen der Voreinstellung fuer %s Option nicht moeglich"
+031 "Setzen der Voreinstellung für %s Option nicht möglich"
032 "Benutzung: %s"
033 "set: keine %s Option: 'set all' zeigt alle Optionen mit Werten an"
034 "set: der [no]%s Option kann kein Wert zugewiesen werden"
-035 "set: %s ist keine boolsche Option"
+035 "set: %s ist keine Boolsche Option"
036 "set: %s Option: %s"
-037 "set: %s Option: %s: Wert Ueberlauf"
-038 "set: %s Option: %s ist eine ungueltige Zahl"
-039 "set: %s ist keine boolsche Option"
-040 "Anzeige hat zu wenig Spalten, weniger als %d"
-041 "Anzeige hat zu viele Spalten, mehr als %d"
-042 "Anzeige hat zu wenig Zeilen, weniger als %d"
-043 "Anzeige hat zu viele Zeilen, mehr als %d"
-044 "Die lisp Option ist nicht implementiert"
-045 "Messages nicht abgeschalten: %s"
-046 "Messages nicht eingeschalten: %s"
-048 "Die paragraph Option muss Gruppen zu zwei Zeichen enthalten"
-049 "Die section Option muss Gruppen zu zwei Zeichen enthalten"
+037 "set: %s Option: %s: Werte-Überlauf"
+038 "set: %s Option: %s ist eine ungültige Zahl"
+039 "set: %s ist keine Boolsche Option"
+040 "Bildschirm hat zu wenig Spalten, weniger als %d"
+041 "Bildschirm hat zu viele Spalten, mehr als %d"
+042 "Bildschirm hat zu wenig Zeilen, weniger als %d"
+043 "Bildschirm hat zu viele Zeilen, mehr als %d"
+044 "Die lisp-Option ist nicht implementiert"
+045 "Meldungen nicht abgeschaltet: %s"
+046 "Meldungen nicht eingeschaltet: %s"
+047 "Die %s-Option muß Gruppen zu zwei Zeichen enthalten"
053 "Der Standardpuffer ist leer"
054 "Puffer %s ist leer"
055 "Dateien mit newlines im Namen sind nicht wiederherstellbar"
-056 "Aenderungen nicht wiederherstellbar falls die Editorsitzung schief geht"
-057 "kopiere Datei fuer Wiederherstellung ..."
+056 "Änderungen nicht wiederherstellbar, falls die Editorsitzung schiefgeht"
+057 "kopiere Datei für Wiederherstellung ..."
058 "Rettungsmechanismus funktioniert nicht: %s"
-059 "Aenderungen nicht wiederherstellbar falls die Editorsitzung schief geht"
+059 "Änderungen nicht wiederherstellbar, falls die Editorsitzung schiefgeht"
060 "Sicherung der Datei gescheitert: %s"
-061 "kopiere Datei fuer Wiederherstellung ..."
-062 "Informationen ueber den Benutzer mit id %u nicht gefunden"
-063 "Wiederherstellungsdatei kann nicht gesperrt werden"
-064 "Puffer der Wiederherstellungsdatei uebergelaufen"
+061 "kopiere Datei für Wiederherstellung ..."
+062 "Informationen über den Benutzer mit id %u nicht gefunden"
+063 "Wiederherstellungsdatei kann nicht gelockt werden"
+064 "Puffer der Wiederherstellungsdatei übergelaufen"
065 "Wiederherstellungsdatei"
066 "%s: Wiederherstellungsdatei hat falsches Format"
067 "%s: Wiederherstellungsdatei hat falsches Format"
068 "Keine von Ihnen lesbaren Dateien mit Namen %s zum Wiederherstellen"
-069 "Es gibt aeltere Versionen dieser Datei von Ihnen zum Wiederherstellen"
+069 "Es gibt ältere Versionen dieser Datei von Ihnen zum Wiederherstellen"
070 "Sie haben noch andere Dateien zum Wiederherstellen"
071 "schicke keine email: %s"
072 "Datei leer; nichts zu suchen"
@@ -69,110 +68,110 @@
074 "Kein altes Suchmuster"
075 "Suchmuster nicht gefunden"
076 "Dateianfang erreicht, ohne das Suchmuster zu finden"
-077 "Suche umgeschlagen"
+077 "Suche beginnt von vorn"
078 "suche ..."
079 "Keine nichtdruckbaren Zeichen gefunden"
080 "Unbekannter Kommandoname"
-082 "%s: Kommando im ex Modus nicht verfuegbar"
-083 "Count darf nicht Null sein"
+082 "%s: Kommando im ex-Modus nicht verfügbar"
+083 "Anzahl darf nicht Null sein"
084 "%s: falsche Zeilenangabe"
085 "Interner Syntaxtabellenfehler (%s: %s)"
086 "Benutzung: %s"
-087 "%s: temporaerer Puffer nicht freigegeben"
+087 "%s: temporärer Puffer nicht freigegeben"
088 "Flagoffset vor Zeile 1"
089 "Flagoffset hinter dem Dateiende"
-090 "@ mit Bereich lief als Datei/Anzeige geaendert wurde"
-091 "globales oder v-Kommando lief als Datei/Anzeige geaendert wurde"
-092 "Ex Kommando misslungen: restliche Kommandoeingabe ignoriert"
-093 "Ex Kommando misslungen: umdefinierte Tasten ungueltig"
+090 "@ mit Bereich lief, als Datei/Anzeige geändert wurde"
+091 "globales oder v-Kommando lief, als Datei/Anzeige geändert wurde"
+092 "Ex-Kommando mißlungen: restliche Kommandoeingabe ignoriert"
+093 "Ex-Kommando mißlungen: umdefinierte Tasten ungültig"
094 "Die zweite Adresse ist kleiner als die erste"
095 "Kein Markenname angegeben"
096 "\\ ohne folgenden / oder ?"
097 "Referenz auf eine negative Zeilennummer"
098 "Das Kommando %s ist unbekannt"
-099 "Adresswert zu gross"
-100 "Adresswert zu klein"
-101 "Ungueltige Adresskombination"
-102 "Ungueltige Adresse: nur %lu Zeilen in der Datei"
-103 "Ungueltige Adresse: die Datei ist leer"
+099 "Adreßwert zu groß"
+100 "Adreßwert zu klein"
+101 "Ungültige Adreßkombination"
+102 "Ungültige Adresse: nur %lu Zeilen in der Datei"
+103 "Ungültige Adresse: die Datei ist leer"
104 "Das Kommando %s erlaubt keine Adresse 0"
-105 "Keine Abkuerzungen zum Anzeigen"
-106 "Abkuerzungen muessen mit einem "Wort"-Zeichen enden"
-107 "Abkuerzungen duerfen keine Tabulator- oder Leerzeichen enthalten"
-108 "In Abkuerzungen duerfen ausser am Ende Wort- und Nicht-Wort-Zeichen nicht gemischt werden"
-109 ""%s" ist keine Abkuerzung"
-110 "Vi Kommando misslungen: umdefinierte Tasten ungueltig"
-111 "Keine weiteren Dateien zu edieren"
-112 "Keine vorhergehenden Dateien zu edieren"
-113 "Keine vorhergehenden Dateien fuer rewind"
+105 "Keine Abkürzungen zum Anzeigen"
+106 "Abkürzungen müssen mit einem \"Wort\"-Zeichen enden"
+107 "Abkürzungen dürfen keine Tabulator- oder Leerzeichen enthalten"
+108 "In Abkürzungen dürfen außer am Ende Wort- und Nicht-Wort-Zeichen nicht gemischt werden"
+109 "\"%s\" ist keine Abkürzung"
+110 "Vi Kommando mißlungen: umdefinierte Tasten ungültig"
+111 "Keine weiteren Dateien zu editieren"
+112 "Keine vorhergehenden Dateien zu editieren"
+113 "Keine vorhergehenden Dateien für rewind"
114 "Keine Dateiliste zum Anzeigen"
-115 "Kein vorhergehendes Kommando um "!" zu ersetzen"
-116 "Kein Dateiname fuer %%"
-117 "Kein Dateiname fuer #"
+115 "Kein vorhergehendes Kommando, um \"!\" zu ersetzen"
+116 "Kein Dateiname für %%"
+117 "Kein Dateiname für #"
118 "Fehler: execl: %s"
-119 "I/O Fehler: %s"
-120 "Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende ! zum ignorieren"
+119 "E/A-Fehler: %s"
+120 "Datei wurde seit dem letzten vollständigen Schreiben geändert; schreibe oder verwende ! zum ignorieren"
121 "Kann Homedirectory nicht bestimmen"
122 "Neues aktuelles Directory: %s"
123 "Keine Puffer anzuzeigen"
124 "Das Kommando %s kann nicht als Teil eines global oder v Kommandos verwendet werden"
-125 "%s/%s: nicht gelesen: gehoehrt weder Ihnen noch root"
-126 "%s/%s: nicht gelesen: gehoehrt nicht Ihnen"
-127 "%s/%s: nicht gelesen: anderer Benutzer als Eigentuemer hat Schreibrecht"
-128 "%s: nicht gelesen: gehoehrt weder Ihnen noch root"
-129 "%s: nicht gelesen: gehoehrt nicht Ihnen"
-130 "%s: nicht gelesen: anderer Benutzer als Eigentuemer hat Schreibrecht"
+125 "%s/%s: nicht gelesen: gehört weder Ihnen noch root"
+126 "%s/%s: nicht gelesen: gehört nicht Ihnen"
+127 "%s/%s: nicht gelesen: anderer Benutzer als Eigentümer hat Schreibrecht"
+128 "%s: nicht gelesen: gehört weder Ihnen noch root"
+129 "%s: nicht gelesen: gehört nicht Ihnen"
+130 "%s: nicht gelesen: anderer Benutzer als Eigentümer hat Schreibrecht"
131 "Keine folgenden Zeilen zum Verbinden"
-132 "Kein Eingabe-Map Eintrag"
-133 "Kein Kommando-Map Eintrag"
+132 "Kein input-Map Eintrag"
+133 "Kein command-Map Eintrag"
134 "Das %s Zeichen kann nicht umgemappt werden"
-135 ""%s" ist momentan nicht gemappt"
-136 "Markennamen muessen einzelne Buchstaben sein"
-137 "%s existiert, nicht geschrieben; verwende ! zum Ueberschreiben"
+135 "\"%s\" ist momentan nicht gemappt"
+136 "Markennamen müssen einzelne Buchstaben sein"
+137 "%s existiert, nicht geschrieben; verwende ! zum Überschreiben"
138 "Neue .exrc Datei: %s. "
139 "Zielzeile ist innerhalb des Verschiebebereichs"
-140 "Das open Kommando verlangt, dass die open Option gesetzt ist"
+140 "Das open Kommando verlangt, daß die open Option gesetzt ist"
141 "Das open Kommando ist nocht nicht implementiert"
-142 "Rettung dieser Datei nicht moeglich"
+142 "Rettung dieser Datei nicht möglich"
143 "Datei gerettet"
144 "%s wurde in zu viele Dateinamen expandiert"
-145 "Nur regulaere Dateien und named pipes koennen gelesen werden"
-146 "%s: Lesesperrung war nicht moeglich"
+145 "Nur reguläre Dateien und named pipes können gelesen werden"
+146 "%s: Locken zum Lesen war nicht möglich"
147 "lese ..."
148 "%s: %lu Zeilen, %lu Zeichen"
-149 "Keine Hintegrundanzeigen vorhanden"
-150 "Das script Kommando ist nur im vi Modus verfuegbar"
-151 "Kein Kommando auszufuehren"
+149 "Keine Hintergrundanzeigen vorhanden"
+150 "Das script Kommando ist nur im vi Modus verfügbar"
+151 "Kein Kommando auszuführen"
152 "shiftwidth Option auf 0 gesetzt"
-153 "Count ueberlauf"
-154 "Count unterlauf"
-155 "Regulaerer Ausdruck angegeben; r Flag bedeutungslos"
-156 "Die #, l und p Flags koennen im vi Modus nicht mit dem c Flag kombiniert werden"
-157 "Keine Uebereinstimmung gefunden"
+153 "Anzahl-Überlauf"
+154 "Anzahl-Unterlauf"
+155 "Regulärer Ausdruck angegeben; r Flag bedeutungslos"
+156 "Die #, l und p Flags können im vi Modus nicht mit dem c Flag kombiniert werden"
+157 "Keine Übereinstimmung gefunden"
158 "Kein vorhergehender 'tag' angegeben"
-159 "Weniger als %s Eintraege auf dem 'tag'-Stack; verwende :display t[ags]"
+159 "Weniger als %s Einträge auf dem 'tag'-Stack; verwende :display t[ags]"
160 "Keine Datei namens %s auf dem 'tag'-Stack; verwende :display t[ags]"
-161 "Druecke Enter um fortzufahren: "
+161 "Drücke Enter um fortzufahren: "
162 "%s: 'tag' nicht gefunden"
163 "%s: kaputter 'tag' in %s"
164 "%s: die Zeilennummer des 'tag' ist hinter dem Dateiende"
165 "Der 'tag' Stack ist leer"
166 "%s: Suchmuster nicht gefunden"
-167 "%d weitere Dateien zu edieren"
+167 "%d weitere Dateien zu editieren"
168 "Puffer %s ist leer"
-169 "Bestaetige Aenderung [n]"
+169 "Bestätige Änderung [n]"
170 "Unterbrochen."
-171 "Kein vorhergehender Puffer zum Ausfuehren"
-172 "Kein vorhergehender regulaerer Ausdruck"
-173 "Das Kommando %s verlangt, dass bereits eine Datei eingelesen wurde"
+171 "Kein vorhergehender Puffer zum Ausführen"
+172 "Kein vorhergehender regulärer Ausdruck"
+173 "Das Kommando %s verlangt, daß bereits eine Datei eingelesen wurde"
174 "Benutzung: %s"
-175 "Das visual Kommando verlangt dass die open Option gesetzt ist"
+175 "Das visual Kommando verlangt daß die open Option gesetzt ist"
177 "Leere Datei"
178 "Keine vorhergehende F, f, T oder t Suche"
179 "%s nicht gefunden"
-180 "Keine vorhergehende Datei zu edieren"
+180 "Keine vorhergehende Datei zu editieren"
181 "Cursor nicht auf einer Zahl"
-182 "Sich ergebende Zahl ist zu gross"
+182 "Sich ergebende Zahl ist zu groß"
183 "Sich ergebende Zahl ist zu klein"
184 "Kein korrespondierendes Zeichen in dieser Zeile"
185 "Korrespondierendes Zeichen nicht gefunden"
@@ -180,11 +179,11 @@
187 "Keine andere Anzeige zum Hinschalten"
188 "Zeichen nach Suchmuster, Zeilenoffset und/oder z Kommando"
189 "Kein altes Suchmuster"
-190 "Suche zur urspruenglichen Position umgeschlagen"
-191 "Abkuerzung ueberschreitet Expansionsgrenze: Zeichen weggelassen"
+190 "Suche zur ursprünglichen Position zurückgekehrt"
+191 "Abkürzung überschreitet Expansionsgrenze: Zeichen weggelassen"
192 "Nicht erlaubtes Zeichen; maskiere zum Eingeben"
193 "Bereits am Anfang der Eingabe"
-194 "Keine weiteren Zeichen zu loeschen"
+194 "Keine weiteren Zeichen zu löschen"
195 "Bewegung hinter das Dateiende"
196 "Bewegung hinter das Zeilenende"
197 "Keine Cursorbewegung gemacht"
@@ -196,73 +195,73 @@
203 "Bereits am Zeilenende"
204 "%s ist kein vi Kommando"
205 "Benutzung: %s"
-206 "Keine Zeichen zu loeschen"
-207 "Das Q Kommando benoetigt das ex Terminal Interface"
+206 "Keine Zeichen zu löschen"
+207 "Das Q Kommando benötigt das ex Terminal Interface"
208 "Kein Kommando zu wiederholen"
209 "Die Datei ist leer"
210 "%s kann nicht als Bewegungskommando verwendet werden"
211 "Bereits im Kommando-Modus"
212 " Cursor nicht auf einem Wort"
-214 "Wert der Window Option ist zu gross, max ist %u"
-215 "Anfuegen"
-216 "Aendern"
+214 "Wert der Window Option ist zu groß, max ist %u"
+215 "Anhängen"
+216 "Ändern"
217 "Kommando"
-218 "Einfuegen"
+218 "Einfügen"
219 "Ersetzen"
220 "Bewegung hinter das Anzeigenende"
221 "Bewegung vor den Anzeigenanfang"
-222 "Anzeige muss zum Zerlegen groesser als %d sein"
+222 "Anzeige muß für Bildschirmteilung größer als %d sein"
223 "Keine Hintergrundanzeigen vorhanden"
-224 "Es gibt keine Hintergrundanzeige die eine Datei namens %s ediert"
+224 "Es gibt keine Hintergrundanzeige, die eine Datei namens %s editiert"
225 "Die einzige dargestellte Anzeige kann nicht in den Hintergrund gebracht werden"
226 "Die Anzeige kann nur auf %d Zeilen verkleinert werden"
227 "Die Anzeige kann nicht verkleinert werden"
-228 "Die Anzeige kann nicht vergroessert werden"
-230 "Diese Anzeige kann nicht gestopped werden"
-231 "Unterbrochen: umdefinierte Tasten ungueltig"
-232 "vi: temporaerer Puffer nicht freigegeben"
+228 "Die Anzeige kann nicht vergrößert werden"
+230 "Diese Anzeige kann nicht gestopt werden"
+231 "Unterbrochen: umdefinierte Tasten ungültig"
+232 "vi: temporärer Puffer nicht freigegeben"
233 "Dieses Terminal hat keine %s Taste"
234 "es kann nur ein Puffer angegeben werden"
-235 "Zahl groesser als %lu"
+235 "Zahl größer als %lu"
236 "Unterbrochen"
-237 "Nicht moeglich temporaere Datei anzulegen"
-238 "Warnung: %s ist keine regulaere Datei"
-239 "%s ist bereits gesperrt, nur-lese Editorsitzung"
-240 "%s: loeschen"
-241 "%s: schliessen"
-242 "%s: loeschen"
-243 "%s: loeschen"
-244 "Nur-lese Datei, nicht geschrieben; verwende ! zum Ueberschreiben"
-245 "Nur-lese Datei, nicht geschrieben"
-246 "%s existiert, nicht geschrieben; verwende ! zum Ueberschreiben"
+237 "Nicht möglich, temporäre Datei anzulegen"
+238 "Warnung: %s ist keine reguläre Datei"
+239 "%s ist bereits gelockt, Editorsitzung schreibgeschützt"
+240 "%s: löschen"
+241 "%s: schließen"
+242 "%s: löschen"
+243 "%s: löschen"
+244 "Datei nicht schreibbar, nicht geschrieben; verwende ! zum Überschreiben"
+245 "Datei nicht schreibbar, nicht geschrieben"
+246 "%s existiert, nicht geschrieben; verwende ! zum Überschreiben"
247 "%s existiert, nicht geschrieben"
-248 "Teil der Datei, nicht geschrieben; verwende ! zum Ueberschreiben"
+248 "Teil der Datei, nicht geschrieben; verwende ! zum Überschreiben"
249 "Teil der Datei, nicht geschrieben"
-250 "%s: Datei wurde spaeter als diese Kopie veraendert; verwende ! zum Ueberschreiben"
-251 "%s: Datei wurde spaeter als diese Kopie veraendert"
-252 "%s: Schreibsperrung war nicht moeglich"
+250 "%s: Datei wurde später als diese Kopie verändert; verwende ! zum Überschreiben"
+251 "%s: Datei wurde später als diese Kopie verändert"
+252 "%s: Locken zum Schreiben war nicht möglich"
253 "schreibe ..."
254 "%s: WARNUNG: DATEI ABGESCHNITTEN"
255 "Bereits am ersten 'tag' dieser Gruppe"
256 "%s: neue Datei: %lu Zeilen, %lu Zeichen"
257 "%s: %lu Zeilen, %lu Zeichen"
258 "%s wurde in zu viele Dateinamen expandiert"
-259 "%s: keine regulaere Datei"
-260 "%s: gehoehrt nicht Ihnen"
-261 "%s: anderer Benutzer als Eigentuemer hat Zugriff"
-262 "Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende ! zum ignorieren"
-263 "Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende :edit! zum ignorieren"
-264 "Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende ! zum ignorieren"
-265 "Datei ist temporaer; beim Verlassen gehen die Aenderungen verloren"
-266 "Nur-lese Datei, Aenderungen werden nicht automatisch geschrieben"
+259 "%s: keine reguläre Datei"
+260 "%s: gehört nicht Ihnen"
+261 "%s: anderer Benutzer als Eigentümer hat Zugriff"
+262 "Datei wurde seit dem letzten vollständigen Schreiben geändert; schreibe oder verwende ! zum ignorieren"
+263 "Datei wurde seit dem letzten vollständigen Schreiben geändert; schreibe oder verwende :edit! zum ignorieren"
+264 "Datei wurde seit dem letzten vollständigen Schreiben geändert; schreibe oder verwende ! zum ignorieren"
+265 "Datei ist temporär; beim Verlassen gehen die Änderungen verloren"
+266 "Datei ist schreibgeschützt, Änderungen werden nicht automatisch geschrieben"
267 "Portokollierung neu begonnen"
-268 "bestaetigen [ynq]"
-269 "Druecke beliebige Taste um fortzufahren"
-270 "Druecke beliebige Taste um fortzufahren [: um weitere Kommandos einzugeben]: "
-271 "Druecke beliebige Taste um fortzufahren [q zum Verlassen]: "
-272 "Diese Form von %s benoetigt das ex Terminal-Interface"
+268 "bestätigen [ynq]"
+269 "Drücke beliebige Taste um fortzufahren"
+270 "Drücke beliebige Taste um fortzufahren [: um weitere Kommandos einzugeben]: "
+271 "Drücke beliebige Taste um fortzufahren [q zum Verlassen]: "
+272 "Diese Form von %s benötigt das ex Terminal-Interface"
273 "Gehe in ex Eingabe-Modus.\n"
-274 "Kommando schief gelaufen, noch keine Datei eingelesen"
+274 "Kommando schiefgelaufen, noch keine Datei eingelesen"
275 " weiter?"
276 "unerwartetes Zeichen - Ereignis"
277 "unerwartetes Dateiende - Ereignis"
@@ -271,18 +270,18 @@
280 "unerwartetes Verlassen - Ereignis"
281 "unerwartetes Wiederherstellungs - Ereignis"
282 "Bereits am letzten 'tag' dieser Gruppe"
-283 "Das %s Kommando benoetigt das ex Terminal-Interface"
-284 "Diese Form von %s wird nicht unterstuetzt wenn die 'secure edit' - Option gesetzt ist"
+283 "Das %s Kommando benötigt das ex Terminal-Interface"
+284 "Diese Form von %s wird nicht unterstützt wenn die 'secure edit' - Option gesetzt ist"
285 "unerwartetes Zeichenketten - Ereignis"
286 "unerwartetes timeout - Ereignis"
287 "unerwartetes Schreibe - Ereignis"
-289 "Shell Expandierungen nicht unterstuetzt wenn die 'secure edit' - Option gesetzt ist"
-290 "Das %s Kommando wird nicht unterstuetzt wenn die 'secure edit' - Option gesetzt ist"
+289 "Shell Expandierungen nicht unterstützt wenn die 'secure edit' - Option gesetzt ist"
+290 "Das %s Kommando wird nicht unterstützt wenn die 'secure edit' - Option gesetzt ist"
291 "set: %s kann nicht ausgeschaltet werden"
292 "Anzeige zu klein."
-293 "angefuegt"
-294 "geaendert"
-295 "geloescht"
+293 "angefügt"
+294 "geändert"
+295 "gelöscht"
296 "verbunden"
297 "verschoben"
298 "geschoben"
@@ -290,18 +289,18 @@
300 "Zeile"
301 "Zeilen"
302 "Vi wurde nicht mit dem Tcl Interpreter gelinkt"
-303 "Datei wurde seit dem letzten Schreiben veraendert."
-304 "Shell Expansion nicht geklappt"
-305 "Es ist keine %s Edieroption angegeben"
+303 "Datei wurde seit dem letzten Schreiben verändert."
+304 "Shell Expansion hat nicht geklappt"
+305 "Es ist keine %s Editieroption angegeben"
306 "Vi wurde nicht mit einem Perl Interpreter geladen"
-307 "Kein ex Kommando auszufuehren"
-308 "Druecke <CR> um ein Kommando auszufuehren, :q zum verlassen"
-309 "Verwende "cscope help" fuer Hilestellung"
+307 "Kein ex Kommando auszuführen"
+308 "Drücke <CR> um ein Kommando auszuführen, :q zum verlassen"
+309 "Verwende \"cscope help\" für Hilestellung"
310 "Keine cscope Verbindung aktiv"
311 "%s: unbekannter Suchtyp: verwende einen aus %s"
312 "%d: keine solche cscope Verbindung"
313 "set: die %s Option kann nicht eingeschaltet werden"
314 "set: die %s Option kann nicht auf 0 gesetzt werden"
-315 "%s: angefuegt: %lu Zeilen, %lu Zeichen"
-316 "unerwartetes Groessenveraenderungs - Ereignis"
+315 "%s: angefügt: %lu Zeilen, %lu Zeichen"
+316 "unerwartetes Größenveränderungs - Ereignis"
317 "%d Dateien zu edieren"
diff --git a/catalog/german.check b/catalog/german.check
deleted file mode 100644
index 4fd60c14e63b..000000000000
--- a/catalog/german.check
+++ /dev/null
@@ -1,36 +0,0 @@
-Unused message id's (this is okay):
-001
-047
-050
-051
-052
-081
-176
-213
-229
-288
-=========================
-MISSING ERROR MESSAGES (Please add!):
-=========================
-Extra error messages (just delete them):
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s existiert, nicht geschrieben; verwende ! zum UeberschreibenX
- 2 %s wurde in zu viele Dateinamen expandiertX
- 2 %s: %lu Zeilen, %lu ZeichenX
- 2 %s: Wiederherstellungsdatei hat falsches FormatX
- 2 Aenderungen nicht wiederherstellbar falls die Editorsitzung schief gehtX
- 2 Kein altes SuchmusterX
- 2 Keine Protokollierung aktiv, rueckgaengig machen nicht moeglichX
- 2 Puffer %s ist leerX
- 2 geaendertX
- 2 kopiere Datei fuer Wiederherstellung ...X
- 2 set: %s ist keine boolsche OptionX
- 3 %s: loeschenX
- 3 Datei wurde seit dem letzten vollstaendigen Schreiben geaendert; schreibe oder verwende ! zum ignorierenX
- 4 Benutzung: %sX
-=========================
diff --git a/catalog/german.owner b/catalog/german.owner
index e72e8ae268fc..efed56a0a76f 100644
--- a/catalog/german.owner
+++ b/catalog/german.owner
@@ -1 +1,2 @@
-Bernhard Daeubler <daeb@physik.uni-ulm.de>
+Bernhard Daeubler <daeb@physik.uni-ulm.de>
+Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
diff --git a/catalog/polish.base b/catalog/polish.base
new file mode 100644
index 000000000000..74b2756934a0
--- /dev/null
+++ b/catalog/polish.base
@@ -0,0 +1,306 @@
+002 "Zbyt d³uga linia"
+003 "nie mo¿na usun±æ linii %lu"
+004 "nie mo¿na dodaæ do linii %lu"
+005 "nie mo¿na wstawiæ w linii %lu"
+006 "nie mo¿na zachowaæ linii %lu"
+007 "nie mo¿na pobraæ ostatniej linii"
+008 "B³±d: nie mo¿na pobraæ linii %lu"
+009 "Plik logu"
+010 "Brak logowania, anulowanie (undo) niemo¿liwe"
+011 "Brak zmian do anulowania"
+012 "Brak logowania, anulowanie (undo) niemo¿liwe"
+013 "Brak logowania, nie mo¿na przegl±daæ do przodu"
+014 "Brak zmian do powtórzenia"
+015 "%s/%d: b³±d zapisu do logu"
+016 "Standardowe wej¶cie i wyj¶cie vi musi byæ terminalem"
+017 "Znacznik %s: nie ustawiony"
+018 "Znacznik %s: linia zosta³a usuniêta"
+019 "Znacznik %s: pozycja kursora ju¿ nie istnieje"
+020 "B³±d: "
+021 "nowy plik"
+022 "nazwa zosta³a zmieniona"
+023 "zmieniony"
+024 "nie zmieniony"
+025 "ODBLOKOWANY"
+026 "tylko do odczytu"
+027 "linia %lu z %lu [%ld%%]"
+028 "pusty plik"
+029 "linia %lu"
+030 "Plik %s nie jest katalogiem komunikatów"
+031 "Nie mo¿na ustawiæ domy¶lnej opcji %s"
+032 "Sposób u¿ycia: %s"
+033 "set: brak opcji %s: 'set all' wy¶wietla warto¶ci opcji"
+034 "set: opcja no]%s nie pobiera warto¶ci"
+035 "set: opcja %s nie jest zmienn± boolowsk±"
+036 "set: opcja %s: %s"
+037 "set: opcja %s: %s: przepe³nienie"
+038 "set: opcja %s: %s nie jest poprawn± liczb±"
+039 "set: opcja %s nie jest zmienn± boolowsk±"
+040 "Zbyt ma³a liczba kolumn ekranu, mniejsza ni¿ %d"
+041 "Zbyt du¿a liczba kolumn, wiêksza ni¿ %d"
+042 "Zbyt ma³a liczba wierszy ekranu, mniejsza ni¿ %d"
+043 "Zbyt du¿a liczba wierszy ekranu, wiêksza ni¿ %d"
+044 "Opcja lisp nie jest zaimplementowana"
+045 "komunikaty nie wy³±czone: %s"
+046 "komunikaty nie w³±czone: %s"
+047 "Opcja %s musi sk³adaæ siê z dwóch grup symboli"
+053 "Domy¶lny bufor jest pusty"
+054 "Bufor %s jest pusty"
+055 "Pliki z symbolem nowego wiersza w nazwie nie mog± byæ odtworzone"
+056 "Zmiany nie do odtworzenia, je¶li sesja zostanie przerwana"
+057 "Tworzenie kopii zapasowej..."
+058 "B³±d podczas zachowywania: %s"
+059 "Zmiany nie do odtworzenia, je¶li sesja zostanie przerwana"
+060 "B³±d podczas tworzenia kopii zapasowej: %s"
+061 "Tworzenie kopii zapasowej..."
+062 "Nie znaleziono informacji o u¿ytkowniku numer %u"
+063 "Nie mo¿na zablokowaæ kopii zapasowej"
+064 "Przepe³nienie bufora kopii zapasowej"
+065 "Kopia zapasowa"
+066 "%s: b³êdna kopia zapasowa"
+067 "%s: b³êdna kopia zapasowa"
+068 "Brak plików o nazwie %s, które móg³by¶ odczytaæ, do odzyskania"
+069 "Istniej± starsze wersje tego pliku, które mo¿na odzyskaæ"
+070 "Istniej± inne pliki, które mo¿na odzyskaæ"
+071 "nie wysy³am poczty: %s"
+072 "Pusty plik; nie ma czego szukaæ"
+073 "Dotarto do koñca pliku bez znalezienia szukanego wzorca"
+074 "Brak poprzedniego wzorca poszukiwañ"
+075 "Nie znaleziono wzorca"
+076 "Dotarto do pocz±tku pliku bez znalezienia szukanego wzorca"
+077 "Poszukiwanie od pocz±tku"
+078 "Szukam..."
+079 "Nie znaleziono niedrukowalnych znaków"
+080 "Nieznana nazwa polecenia"
+082 "%s: polecenie niedostêpne w trybie edytora ex"
+083 "Liczba nie mo¿e byæ zerem"
+084 "%s: b³êdny numer linii"
+085 "Wewnêtrzny b³±d tablicy sk³adni (%s: %s)"
+086 "Sposób u¿ycia: %s"
+087 "%s: tymczasowy bufor nie zosta³ zwolniony"
+088 "Przesuniêcie przed liniê 1"
+089 "Przesuniêcie poza koniec pliku"
+090 "@ with range running when the file/screen changed"
+091 "Wykonywano polecenie globalne/wizualne podczas zmiany pliku/ekranu"
+092 "B³±d polecenie ex: pozosta³e polecenia anulowane"
+093 "B³±d polecenia ex: mapowanie klawiszy anulowane"
+094 "Drugi adres jest mniejszy od pierwszego"
+095 "Nie podano nazwy znacznika"
+096 "\\ bez / lub ?"
+097 "Odniesienie do linii o numerze mniejszym od 0"
+098 "Nieznane polecenie %s"
+099 "Przepe³nienie warto¶ci adresu"
+100 "Niedomiar warto¶ci adresu"
+101 "Niedozwolona kombinacja adresu"
+102 "Niedozwolony adres: jest tylko %lu linii w pliku"
+103 "Niedozwolony adres: plik jest pusty"
+104 "Polecenie %s nie zezwala na u¿ycie adresu 0"
+105 "Brak skrótów do wy¶wietlenia"
+106 "Skróty musz± siê koñczyæ symbolem \"s³owo\""
+107 "Skróty nie mog± zawieraæ spacji lub tabulacji"
+108 "Skróty nie mog± przeplataæ symboli s³owo/nie-s³owo, z wyj±tkiem na koñcu linii"
+109 "\"%s\" nie jest skrótem"
+110 "B³±d polecenia vi: mapowanie klawiszy odrzucone"
+111 "Nie ma wiêcej plików do edycji"
+112 "Nie ma poprzednich plików do edycji"
+113 "Nie ma poprzednich plików do przewiniêcia wstecz"
+114 "Nie ma listy plików do wy¶wietlenia"
+115 "Nie ma poprzedniego polecenia do zast±pienia \"!\""
+116 "Nie ma nazwy pliku do zast±pienia %%"
+117 "Nie ma nazwy pliku do zast±pienia #"
+118 "B³±d: execl: %s"
+119 "B³±d I/O: %s"
+120 "Plik zmodyfikowany od ostatniego zapisu; zapisz lub u¿yj ! ¿eby wymusiæ"
+121 "Nie mozna znale¼æ katalogu domowego (home)"
+122 "Nowy katalog bie¿±cy: %s"
+123 "Nie ma buforów edycji do wy¶wietlenia"
+124 "Polecenie %s nie mo¿e byæ u¿yte jako czê¶æ polecenia globalnego lub wizualnego"
+125 "%s/%s: nie wczytany: nie nale¿y do ciebie ani do roota"
+126 "%s/%s: nie wczytany: nie nale¿y do ciebie"
+127 "%s/%s: nie wczytany: inny u¿ytkownik ni¿ w³a¶ciciel ma prawo do zapisu"
+128 "%s: nie wczytany: nie nale¿y do ciebie ani do roota"
+129 "%s: nie wczytany: nie nale¿y do ciebie"
+130 "%s: nie wczytany: inny uzytkownik ni¿ w³a¶ciciel ma prawo do zapisu"
+131 "Brak kolejnych linii do po³±czenia"
+132 "Brak pozycji map wej¶ciowych"
+133 "Brak pozycji map poleceñ"
+134 "Znak %s nie mo¿e byæ przemapowany"
+135 "\"%s\" obecnie nie jest mapowany"
+136 "Nazwa znacznika musi byæ pojedyñcz± liter±"
+137 "%s istnieje, nie zapisany; u¿yj ! ¿eby wymusiæ"
+138 "Nowy plik exrc: %s"
+139 "Linia docelowa jest wewn±trz przenoszonego obszaru"
+140 "Polecenie open wymaga ustawienia opcji open"
+141 "Polecenie open jest niezaimplementowane"
+142 "Niemo¿liwe jest zachowanie tego pliku"
+143 "Plik zachowany"
+144 "%s: rozwija siê na zbyt wiele nazw plików"
+145 "Tylko zwyk³e pliki i nazwane ³±cza (named pipes) mo¿na czytaæ"
+146 "%s: nie mo¿na za³o¿yæ blokady do odczytu"
+147 "Czytanie..."
+148 "%s: %lu linii, %lu znaków"
+149 "Brak ekranów w tle do wy¶wietlenia"
+150 "Polecenie script dostêpne jest tylko w trybie vi"
+151 "Brak polecenia do wykonania"
+152 "Opcja shiftwidth ustawiona na 0"
+153 "Przepe³nienie licznika"
+154 "Niedomiar licznika"
+155 "Podano wyra¿enie regularne; flaga r nie ma znaczenia"
+156 "Flagi #, l oraz p nie mog± byæ ³±czone z flag± c w trybie vi"
+157 "Nie znaleziono wzorca"
+158 "Brak poprzedniego znacznika"
+159 "Mniej ni¿ %s na stosie znaczników; u¿yj :display t[ags]"
+160 "Brak pliku %s na stosie znaczników do powrotu; u¿yj :display t[ags]"
+161 "Naci¶nij Enter: "
+162 "%s: znacznik nie znaleziony"
+163 "%s: b³êdny znacznik w %s"
+164 "%s: numer linii znacznika wykracza poza koniec pliku"
+165 "Stos znaczników jest pusty"
+166 "%s: nie znaleziono szukanego wzorca"
+167 "%d plików jeszcze do edycji"
+168 "Bufor %s jest pusty"
+169 "Potwierdzasz zmianê? [n]"
+170 "Przerwany"
+171 "Brak poprzedniego bufora do wykonania"
+172 "Brak poprzedniego wyra¿enia regularnego"
+173 "Polecenie %s wymaga uprzedniego wczytania pliku"
+174 "Sposób u¿ycia: %s"
+175 "Polecenie wizualne wymaga ustawienia opcji open"
+177 "Pusty plik"
+178 "Brak poprzedniego szukania F, f, T lub t"
+179 "%s nie znaleziono"
+180 "Brak poprzedniego pliku do edycji"
+181 "Kursor nie na liczbie"
+182 "Liczba wynikowa zbyt du¿a"
+183 "Liczba wynikowa zbyt ma³a"
+184 "Brak pasuj±cych znaków w tej linii"
+185 "Nie znaleziono pasuj±cych znaków"
+186 "Brak znaków do zamiany"
+187 "Brak innego ekranu do prze³±czenia"
+188 "Znaki poza napisem do szukania, przesuniêciem linii i/lub poleceniem z"
+189 "Brak poprzedniego wzorca szukania"
+190 "Szukanie wróci³o do pierwotnej pozycji"
+191 "Skrót przekroczy³ limit rozwiniêcia: czê¶æ znaków odrzucono"
+192 "Niedozwolony znak; zacytuj, ¿eby wprowadziæ"
+193 "Ju¿ na pocz±tku wstawiania"
+194 "Brak kolejnych znaków do usuniêcia"
+195 "Przesuniêcie poza koniec pliku"
+196 "Przesuniêcie poza koniec linii"
+197 "Nie wykonano przesuniêcia kursora"
+198 "Ju¿ na pocz±tku pliku"
+199 "Przesuniêcie przed pocz±tek pliku"
+200 "Ju¿ w pierwszej kolumnie"
+201 "Nale¿y podaæ bufory przed poleceniem"
+202 "Ju¿ na koñcu pliku"
+203 "Ju¿ na koñcu linii"
+204 "%s nie jest poleceniem vi"
+205 "Sposób u¿ycia: %s"
+206 "Brak znaków do usuniêcia"
+207 "Polecenie Q wymaga interfejsu terminala ex"
+208 "Brak polecenia do powtórzenia"
+209 "Plik jest pusty"
+210 "%s nie mo¿e byæ u¿yte jako polecenie przesuniêcia"
+211 "Ju¿ w trybie poleceñ"
+212 "Kursor nie na s³owie"
+214 "Warto¶ci opcji okna zbyt du¿e, max to %u"
+215 "Do³±cz"
+216 "Zmieñ"
+217 "Polecenie"
+218 "Wstaw"
+219 "Zamieñ"
+220 "Przesuniêcie poza koniec ekranu"
+221 "Przesuniêcie przed pocz±tek ekranu"
+222 "Ekran musi mieæ wiêcej ni¿ %d linii, ¿eby go podzieliæ"
+223 "Brak ekranów w tle"
+224 "Nie ma ekranu w tle z edycj± pliku o nazwie %s"
+225 "Nie mo¿na schowaæ w tle jedynego ekranu edycyjnego"
+226 "Mo¿na zmniejszyæ ekran tylko do %d wierszy"
+227 "Ekran nie mo¿e byæ zmniejszony"
+228 "Ekran nie mo¿e byæ zwiêkszony"
+230 "Ekran nie mo¿e byæ zawieszony"
+231 "Przerwano: odrzucono mapowane klawisze"
+232 "vi: nie zwolniono bufora tymczasowego"
+233 "Ten terminal nie posiada klawisza %s"
+234 "Mo¿na podaæ tylko jeden bufor"
+235 "Liczba wiêksza ni¿ %lu"
+236 "Przerwano"
+237 "Nie mo¿na utworzyæ pliku tymczasowego"
+238 "Uwaga: %s nie jest zwyk³ym plikiem"
+239 "%s ju¿ zablokowany, sesja tylko do odczytu"
+240 "%s: usuñ"
+241 "%s: zamknij"
+242 "%s: usuñ"
+243 "%s: usuñ"
+244 "Plik tylko do odczytu, nie zapisany; u¿yj ! ¿eby wymusiæ"
+245 "Plik tylko do odczytu, nie zapisany"
+246 "%s istnieje, nie zapisany; u¿yj ! ¿eby wymusiæ"
+247 "%s istnieje, nie zapisany"
+248 "Plik czê¶ciowy, nie zapisany; u¿yj ! ¿eby wymusiæ"
+249 "Plik czê¶ciowy, nie zapisany"
+250 "%s: plik zmodyfikowany pó¼niej, ni¿ ta kopia; u¿yj ! ¿eby wymusiæ"
+251 "%s: plik zmodyfikowany pó¼niej, ni¿ ta kopia"
+252 "%s: nie mo¿na zablokowaæ do pisania"
+253 "Zapisywanie..."
+254 "%s: OSTRZE¯ENIE: PLIK ZOSTA£ OBCIÊTY"
+255 "Ju¿ przy pierwszym znaczniku z tej grupy"
+256 "%s: nowy plik: %lu linii, %lu znaków"
+257 "%s: %lu linii, %lu znaków"
+258 "%s rozwija siê na zbyt wiele nazw plików"
+259 "%s: nie jest zwyk³ym plikiem"
+260 "%s: nie jeste¶ w³a¶cicielem"
+261 "%s: dostêpny dla u¿ytkownika innego ni¿ w³a¶ciciel"
+262 "Plik zmodyfikowany od ostatniego zapisu; zapisz lub u¿yj ! ¿eby wymusiæ"
+263 "Plik zmodyfikowany od ostatniego zapisu; zapisz lub u¿yj :edit! ¿eby wymusiæ"
+264 "Plik zmodyfikowany od ostatniego zapisu; zapisz lub u¿yj ! ¿eby wymusiæ"
+265 "To jest plik tymczasowy; wyj¶cie anuluje zmiany"
+266 "Plik tylko do odczytu, nie ma autozapisu zmian"
+267 "Ponownie rozpoczêto logowanie"
+268 "potwierdzasz? [ynq]"
+269 "Naci¶nij dowolny klawisz: "
+270 "Naci¶nij dowolny klawisz [: ¿eby podaæ nastêpne polecenia ex]: "
+271 "Naci¶nij dowolny klawisz [q ¿eby zakoñczyæ]: "
+272 "Ta forma %s wymaga interfejsu terminala ex"
+273 "Wchodzê w tryb wprowadzania ex."
+274 "B³±d polecenia, jeszcze nie wczytano pliku."
+275 " dalej?"
+276 "Nieoczekiwany symbol"
+277 "Nieoczekiwany koniec pliku"
+278 "Brak wzorców pasuj±cych do zapytania"
+279 "Nieoczekiwane przerwanie"
+280 "Nieoczekiwane polecenie koniec"
+281 "Nieoczekiwane polecenie od¶wie¿enia"
+282 "Ju¿ przy ostatnim znaczniku z tej grupy"
+283 "Polecenie %s wymaga interfejsu terminala ex"
+284 "Ta forma %s jest niedostêpna, kiedy ustawiona jest opcja bezpiecznej edycji"
+285 "Nieoczekiwany ci±g znaków"
+286 "Nieoczekiwany timeout"
+287 "Nieoczekiwane polecenie zapisu"
+289 "Rozwiniêcia shella niedostêpne w trybie bezpiecznej edycji"
+290 "Polecenie %s jest niedostêpne w trybie bezpiecznej edycji"
+291 "set: opcji %s nie mo¿na wy³±czyæ"
+292 "Ekran zbyt ma³y."
+293 "dodano"
+294 "zmieniono"
+295 "usuniêto"
+296 "po³±czono"
+297 "przeniesiono"
+298 "przesuniêto"
+299 "wczytano"
+300 "linia"
+301 "linii"
+302 "Vi nie zosta³ uruchomiony z interpreterem Tcl"
+303 "Plik zmodyfikowany od ostatniego zapisu"
+304 "B³±d rozwiniêcia shella"
+305 "Brak opcji %s edycji"
+306 "Vi nie zosta³ uruchomiony z interpreterem Perl"
+307 "Brak polecenia ex do wykonania"
+308 "Naci¶nij <CR> ¿eby wykonac polecenie, :q ¿eby wyj¶æ"
+309 "U¿yj \"cscope help\" w celu uzyskania pomocy"
+310 "Brak aktywnych po³±czeñ cscope"
+311 "%s: nieznany typ poszukiwañ: u¿yj jednego z %s"
+312 "%d: brak takiej sesji cscope"
+313 "set: nie mo¿na nigdy w³±czyæ opcji %s"
+314 "set: opcja %s nie mo¿e nigdy mieæ warto¶ci 0"
+315 "%s: dodano: %lu linii, %lu znaków"
+316 "Nieoczekiwane polecenie zmiany rozmiaru"
+317 "%d plików do edycji"
diff --git a/catalog/polish.owner b/catalog/polish.owner
new file mode 100644
index 000000000000..1fcf5c545810
--- /dev/null
+++ b/catalog/polish.owner
@@ -0,0 +1 @@
+Andrzej Bia³ecki <abial@warman.org.pl>
diff --git a/catalog/ru_RU.KOI8-R b/catalog/ru_RU.KOI8-R
deleted file mode 100644
index 7eb35b9cf262..000000000000
--- a/catalog/ru_RU.KOI8-R
+++ /dev/null
@@ -1,267 +0,0 @@
-VI_MESSAGE_CATALOG
-pEREPOLNENIE ZNA^ENIQ DLINY STROKIX
-%s/%d: NEWOZMOVNO UDALITX STROKU %uX
-%s/%d: NEWOZMOVNO DOBAWITX K STROKE %uX
-%s/%d: NEWOZMOVNO WSTAWITX W STROKU %uX
-%s/%d: NEWOZMOVNO SOHRANITX STROKU %uX
-%s/%d: NEWOZMOVNO DOSTATX POSLEDN@@ STROKUX
-
-fAJL ZAPISEJX
-zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDUX
-nET IZMENENIJ DLQ OTMENYX
-zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDUX
-zAPISI NE WELISX, NEWOZMOVNO PROSMOTRETX WPEREDX
-nET IZMENENIJ DLQ PEREDELKIX
-%s/%d: O[IBKA PRI ZAPISI PROTOKOLAX
-sTANDARTNYJ WWOD/WYWOD DLQ VI DOLVEN BYTX TERMINALX
-oTMETKA %s: NE USTANOWLENAX
-oTMETKA %s: STROKA BYLA UDALENAX
-oTMETKA %s: POZICII KURSORA BOLX[E NE SU]ESTWUETX
-o[IBKA:X
-
-
-
-
-
-
-
-
-
-fAJL %s NE QWLQETSQ KATALOGOM SOOB]ENIJX
-nEWOZMOVNO USTANOWITX OPCI@ %s PO UMOL^ANI@X
-iSPOLXZOWANIE: %sX
-oPCII %s NET: 'set all' POKAZYWAET WSE WOZMOVNYE OPCIIX
-set: [no]%s NE PRINIMAET TAKOGO ZNA^ENIQX
-set: %s OPCIQ NE QWLQETSQ DWOI^NOJX
-
-
-set: NEPRAWILXNOE ZNA^ENIE %sX
-set: %s OPCIQ NE QWLQETSQ DWOI^NOJX
-kOLI^ESTWO KOLONOK \KRANA SLI[KOM MALO, MENX[E ^EM %dX
-kOLI^ESTWO KOLONOK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %dX
-kOLI^ESTWO STROK \KRANA SLI[KOM MALO, MENX[E ^EM %dX
-kOLI^ESTWO STROK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %dX
-oPCIQ lisp OTSUTSTWUETX
-sOOB]ENIQ NE WYKL@^ENY: %sX
-sOOB]ENIQ NE WKL@^ENY: %sX
-oPCIQ modeline(s) NE MOVET BYTX PEREUSTANOWLENAX
-oPCIQ paragraph DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMIX
-oPCIQ section DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMIX
-oPCIQ shiftwidth NE MOVET BYTX USTANOWLENA NA 0X
-oPCIQ sourceany NE MOVET BYTX USTANOWLENAX
-tABULQCIQ NE MOVET BYTX USTANOWLENA NA 0X
-sTARTOWYJ BUFER PUSTX
-bUFER %s PUSTX
-fAJLY S SIMWOLAMI PEREWODA STROKI W IMENI NE MOGUT BYTX WOSSTANOWLENYX
-iZMENENIQ NE SOHRANENY PRI KRAHE SESSIIX
-
-sOHRANENIE NE UDALOSX: %sX
-iZMENENIQ NE SOHRANQ@TSQ PRI OBRYWE SESSIIX
-sOHRANENIE KOPII FAJLA NE UDALOSX: %sX
-
-iNFORMACII NA POLXZOWATELQ %u NE NAJDENOX
-nEWOZMOVNO ZA]ITITX SPASENNYJ FAJLX
-bUFER WOSSTANOWLENNOGO FAJLA PEREPOLNENX
-wOSSTANOWLENNYJ FAJLX
-%s: NE DO KONCA WOSSTANOWLENNYJ FAJLX
-%s: NE DO KONCA WOSSTANOWLENNYJ FAJLX
-fAJLOW S IMENEM %s, KOTORYE wY MOVETE ^ITATX, NE SU]ESTWUETX
-eSTX STARYE WERSII FAJLA, KOTORYE MOVNO WOSSTANOWITXX
-sU]ESTWU@T DRUGIE FAJLY, KOTORYE MOVNO WOSSTANOWITXX
-E-mail NE POSLAN: %sX
-fAJL PUST - ISKATX NE^EGOX
-dOSTIGNUT KONEC FAJLA BEZ NAHOVDENIQ OBRAZCA POISKAX
-nE ZADAN OBRAZEC POISKAX
-oBRAZEC POISKA NE NAJDENX
-dOSTUPNO NA^ALO FAJLA BEZ NAHOVDENIQ OBRAZCA POISKAX
-pOISK ZACIKLENX
-
-nEPE^ATNYH SIMWOLOW NE NAJDENOX
-nEIZWESTNAQ KOMANDAX
-
-kOMANDA NE DOSTUPNA W REVIME exX
-s^ET^IK NE MOVET BYTX NULEMX
-%s: NEPRAWILXNOE UKAZANIE STROKIX
-wNUTRENNQQ O[IBKA W SINTAKSISE (%s: %s)X
-iSPOLXZOWANIE: %sX
-%s: WREMENNYJ BUFER NE ISPOLXZOWANX
-mETKA POSTAWLENA PERED STROKOJ 1X
-mETKA POSTAWLENA POSLE KONCA FAJLAX
-
-
-kOMANDA ex NE UDALASX: PARAMETRY KOMANDY ZABYTYX
-
-wTOROJ ADRES MENX[E ^EM PERWYJX
-nE UKAZANO NAZWANIE OTMETKIX
-\\ NE ZAWER[AETSQ / ILI ?X
-sSYLKA K STROKE S NOMEROM MENX[E 0X
-kOMANDA %s NEIZWESTNAX
-pEREPOLNENIE ZNA^ENIQ ADRESAX
-nEDOBOR ZNA^ENIQ ADRESAX
-nEDOPUSTIMAQ KOMBINACIQ W ADRESEX
-nEPRAWILXNYJ ADRES: WSEGO %lu STROK W FAJLEX
-nEPRAWILXNYJ ADRES: FAJL PUSTX
-kOMMANDA %s NE MOVET ISPOLXZOWATX ADRES 0X
-aBBREWIATURY OTSUTSTWU@TX
-aBBREWIATURY DOLVNY ZAKAN^IWATXSQ SIMWOLOM "word"X
-aBBREWIATURY NE MOGUT SODERVATX SIMWOLOY TABLQCII ILI PROBELYX
-aBBREWIATURY NE MOGUT SO^ETATXSQ S SIMWOLAMI SLOW/NE-SLOW, ZA ISKL@^ENIEM KONCA STROKIX
-"%s" NE QWLQETSQ ABBREWIATUROJX
-
-fAJLOW DLQ REDAKTIROWANIQ BOLX[E NETX
-oTSUTSTWIE PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQX
-oTSUTSTWIE PREDYDU]EGO FAJLA DLQ PROSMOTRA NAZADX
-nET FAJLOWX
-oTSUTSTWIE PREDYDU]EJ KOMANDY DLQ ZAMENY "!"X
-oTSUTSTWIE ZAMENY DLQ %%X
-oTSUTSTWIE ZAMENY DLQ #X
-o[IBKA: execl: %sX
-o[IBKA WWODA/WYWODA: %sX
-fAJL IZMENEN S MOMENTA POSLEDNEJ POLNOJ ZAPISI: ISPOLXZUJTE ! DLQ OBHODAX
-nEWOZMOVNO NAJTI DOMA[NIJ KATALOGX
-nOWYJ KATALOG: %sX
-nET WYREZANYH BUFEROWX
-kOMANDA %s NE MOVET BYTX ISPOLXZOWANA WNUTRI OB]EJ KOMANDYX
-%s/%s: NE OTKRYT: NE PRINADLEVIT wAM ILI root-UX
-%s/%s: NE OTKRYT: NE PRINADLEVIT wAMX
-%s/%s: NE OTKRYT: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEMX
-%s/%s: NE S^ITAN: NE PRINADLEVIT wAM ILI root-UX
-%s/%s: NE S^ITAN: NE PRINADLEVIT wAMX
-%s/%s: NE S^ITAN: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEMX
-pOSLEDU@]IE STROKI OTSUTSTWU@TX
-oTSUTSTWIE PARAMETROW WWODAX
-oTSUTSTWIE PARAMETROW KOMANDYX
-sIMWOL %s NE MOVET BYTX PEREZAPOMNENX
-"%s" NA DANNYJ MOMENT NE OTME^ENX
-iMQ METKI DOLVNO BYTX ODNIM SIMWOLOMX
-%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODAX
-nOWYJ FAJL .exrc: %sX
-sTROKA PERENOSA NAHODITSQ WNUTRI PARAMETROW PERENOSAX
-kOMANDA open PODRAZUMEWAET USTANOWKU OPCII openX
-kOMANDA open NE REALIZOWANAX
-zA]ITA FAJLA NEWOZMOVNAX
-fAJL ZA]I]ENX
-%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOWX
-
-%s: ZA]ITA NA ^TENIE BYLA NEDOSTUPNAX
-
-%s: %lu STROK, %lu SIMWOLOWX
-nET TENEWYH OKONX
-kOMANDA script ISPOLXZUETSQ TOLXKO W REVIME viX
-nET KOMANDY DLQ ISPOLNENIQX
-oPCIQ shiftwidth USTANOWLENA NA 0X
-pEREPOLNENIE S^ET^IKAX
-cIKL WYPOLNEN NE DO KONCAX
-uKAZANO REGULQRNOE WYRAVENIE: FLAG r NE NUVENX
-fLAGI #, l I p NE MOGUT BYTX OB_EDINENY S FLAGOM c W REVIME viX
-sOWPADENIJ NETX
-mETKA OTSUTSTWUETX
-w STEKE METOK ZAPISEJ MENX[E, ^EM %s, ISPOLXZUJTE :display t[ags]X
-fAJLA S IMENEM %s W STEKE METOK NET; ISPOLXZUJTE :display t[ags]X
-
-%s: METKA NE NAJDENAX
-%s: PLOHAQ METKA W %sX
-
-sTEK METOK PUSTX
-%s: ISKOMAQ PEREMENNAQ NE NAJDENAX
-
-bUFER %s PUSTX
-
-pRERWANOX
-oTSUTSTWIE BUFERA DLQ ISPOLXZOWANIQX
-nET PREDIDU]EGO REGULQRNOGO WYRAVENIQX
-kOMANDA %s PODRAZUMEWAET NALI^IE PRO^TENNOGO FAJLAX
-iSPOLXZOWANIE: %sX
-kOMANDA visual PODRAZUMEWAET OBQZATELXNU@ USTANOWKU OPCII openX
-%s RAS[IRILSQ DO SLI[KOM BOLX[OGO KOLI^ESTWA FAJLOWX
-pUSTOJ FAJLX
-nET PREDYDU]EGO POISKA F, f, T, ILI tX
-%s NE NAJDENOX
-nET PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQX
-kURSOR STOIT NE NA CIFREX
-pOLU^ENNOE ^ISLO SLI[KOM WELIKOX
-pOLU^ENNOE ^ISLO SLI[KOM MALOX
-pODHODQ]EGO SIMWOLA NET NA \TOJ STROKEX
-pODHODQ]IJ SIMWOL NE NAJDENX
-nET SIMWOLOW DLQ UDALENIQX
-dRUGOGO \KRANA NE SU]ESTWUETX
-sIMWOLY POSLE STROKI DLQ POISKA I/ILI PEREBOR STROKIX
-pRO[LYJ OBRAZEC POISKA OTSUTSTWUETX
-pOISK ZAWER[ILSQ NA NA^ALXNOJ POZICIIX
-
-sIMWOL NEPRAWILEN; ZAKL@^EN W KAWY^KI DLQ WWODAX
-uVE NA NA^ALE WSTAWKIX
-nET SIMWOLOW DLQ UDALENIQX
-pEREDWIVENIE ZA KONEC FAJLAX
-pEREDWIVENIE ZA KONEC STROKIX
-dWIVENIE STROKI NE SDELANOX
-uVE NA NA^ALE FAJLAX
-dWIVENIE KURSORA ZA NA^ALO FAJLAX
-uVE W PERWOJ KOLONKEX
-bUFERY DOLVNY BYTX UKAZANY DO WYPOLNENIQ KOMANDYX
-uVE NA KONCE FAJLAX
-uVE NA KONSE STROKIX
-%s NE QWLQETSQ KOMANDOJ VIX
-iSPOLXZOWANIE: %sX
-nET SIMWOLOW DLQ UDALENIQX
-
-nET KOMANDY DLQ POWTORAX
-
-kOMANDA %s NE MOVET BYTX ISPOLXZOWANA KAK KOMANDA PRODWIVENIQX
-~ISLO BOLX[E ^EM %luX
-
-
-zNA^ENIE KOLI^ESTWA OKON SLI[KOM WELIKO, MAKSIMALXNOE ZNA^ENIE = %uX
-
-
-
-
-
-dWIVENIE KURSORA ZA KONEC \KRANAX
-dWIVENIE KURSORA ZA NA^ALO \KRANAX
-
-tENEWYH OKON NETX
-nE SU]ESTWUET TENEWOGO OKNA S REDAKTIROWANIEM FAJLA %sX
-wY NE MOVETE SDELATX EDINSTWENNOE OKNO TENEWYMX
-|KRAN MOVET BYTX SVATX
-|KRAN NE MOVET BYTX SVATX
-|KRAN NE MOVET BYTX RAS[IRENX
-
-
-
-
-dANNYJ TIP TERMINALA NE IMEET KLAWI[I %sX
-
-
-
-nEWOZMOVNO SOZDATX WREMENNYJ FAJLX
-wNIMANIE: %s SPECIALXNYJ FAJLX
-%s UVE ZABLOKIROWAN, DOSTUPEN TOLXKO NA ^TENIEX
-%s: UDALENX
-%s: ZAKRYTX
-%s: UDALENX
-%s: UDALENX
-fAJL TOLXKO DLQ ^TENIQ, NE ZAPISAN: iSPOLXZUJTE ! DLQ OBHODAX
-fAJL TOLXKO DLQ ^TENIQ, NE ZAPISANX
-%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODAX
-%s SU]ESTWUET, NE ZAPISANX
-iSPOLXZUJTE ! DLQ ^ASTI^NOJ ZAPISI FAJLAX
-~ASTX FAJLA, FAJL NE ZAPISANX
-%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQ: ISPOLXZUJTE ! DLQ OBHODAX
-%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQX
-%s: ZA]ITA NA ZAPISX BYLA NEDOSTUPNAX
-
-%s: wnimanie: fajl use~enX
-
-%s: NOWYJ FAJL: %lu STROK, %lu SIMWOLOWX
-%s: %lu STROK, %lu SIMWOLOWX
-%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOWX
-%s SPECIALXNYJ FAJLX
-%s: NE PRINADLEVIT wAMX
-%s: DOSTUPEN NE TOLXKO wAMX
-fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODAX
-fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE :edit DLQ OBHODAX
-fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODAX
-fAJL WREMENNYJ: WYHOD SOTRET L@BYE IZMENENIQX
-
-zAPISI NA^ATY ZANOWOX
diff --git a/catalog/ru_RU.KOI8-R.base b/catalog/ru_RU.KOI8-R.base
index 59efd3f53a5f..6d1c1b5d08bc 100644
--- a/catalog/ru_RU.KOI8-R.base
+++ b/catalog/ru_RU.KOI8-R.base
@@ -1,219 +1,311 @@
-002 "pEREPOLNENIE ZNA^ENIQ DLINY STROKI"
-003 "%s/%d: NEWOZMOVNO UDALITX STROKU %u"
-004 "%s/%d: NEWOZMOVNO DOBAWITX K STROKE %u"
-005 "%s/%d: NEWOZMOVNO WSTAWITX W STROKU %u"
-006 "%s/%d: NEWOZMOVNO SOHRANITX STROKU %u"
-007 "%s/%d: NEWOZMOVNO DOSTATX POSLEDN@@ STROKU"
-009 "fAJL ZAPISEJ"
-010 "zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDU"
-011 "nET IZMENENIJ DLQ OTMENY"
-012 "zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDU"
-013 "zAPISI NE WELISX, NEWOZMOVNO PROSMOTRETX WPERED"
-014 "nET IZMENENIJ DLQ PEREDELKI"
-015 "%s/%d: O[IBKA PRI ZAPISI PROTOKOLA"
-016 "sTANDARTNYJ WWOD/WYWOD DLQ VI DOLVEN BYTX TERMINAL"
-017 "oTMETKA %s: NE USTANOWLENA"
-018 "oTMETKA %s: STROKA BYLA UDALENA"
-019 "oTMETKA %s: POZICII KURSORA BOLX[E NE SU]ESTWUET"
-020 "o[IBKA:"
-030 "fAJL %s NE QWLQETSQ KATALOGOM SOOB]ENIJ"
-031 "nEWOZMOVNO USTANOWITX OPCI@ %s PO UMOL^ANI@"
-032 "iSPOLXZOWANIE: %s"
-033 "oPCII %s NET: 'set all' POKAZYWAET WSE WOZMOVNYE OPCII"
-034 "set: [no]%s NE PRINIMAET TAKOGO ZNA^ENIQ"
-035 "set: %s OPCIQ NE QWLQETSQ DWOI^NOJ"
-038 "set: NEPRAWILXNOE ZNA^ENIE %s"
-039 "set: %s OPCIQ NE QWLQETSQ DWOI^NOJ"
-040 "kOLI^ESTWO KOLONOK \KRANA SLI[KOM MALO, MENX[E ^EM %d"
-041 "kOLI^ESTWO KOLONOK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %d"
-042 "kOLI^ESTWO STROK \KRANA SLI[KOM MALO, MENX[E ^EM %d"
-043 "kOLI^ESTWO STROK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %d"
-044 "oPCIQ lisp OTSUTSTWUET"
-045 "sOOB]ENIQ NE WYKL@^ENY: %s"
-046 "sOOB]ENIQ NE WKL@^ENY: %s"
-047 "oPCIQ modeline(s) NE MOVET BYTX PEREUSTANOWLENA"
-048 "oPCIQ paragraph DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMI"
-049 "oPCIQ section DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMI"
-050 "oPCIQ shiftwidth NE MOVET BYTX USTANOWLENA NA 0"
-051 "oPCIQ sourceany NE MOVET BYTX USTANOWLENA"
-052 "tABULQCIQ NE MOVET BYTX USTANOWLENA NA 0"
-053 "sTARTOWYJ BUFER PUST"
-054 "bUFER %s PUST"
-055 "fAJLY S SIMWOLAMI PEREWODA STROKI W IMENI NE MOGUT BYTX WOSSTANOWLENY"
-056 "iZMENENIQ NE SOHRANENY PRI KRAHE SESSII"
-058 "sOHRANENIE NE UDALOSX: %s"
-059 "iZMENENIQ NE SOHRANQ@TSQ PRI OBRYWE SESSII"
-060 "sOHRANENIE KOPII FAJLA NE UDALOSX: %s"
-062 "iNFORMACII NA POLXZOWATELQ %u NE NAJDENO"
-063 "nEWOZMOVNO ZA]ITITX SPASENNYJ FAJL"
-064 "bUFER WOSSTANOWLENNOGO FAJLA PEREPOLNEN"
-065 "wOSSTANOWLENNYJ FAJL"
-066 "%s: NE DO KONCA WOSSTANOWLENNYJ FAJL"
-067 "%s: NE DO KONCA WOSSTANOWLENNYJ FAJL"
-068 "fAJLOW S IMENEM %s, KOTORYE wY MOVETE ^ITATX, NE SU]ESTWUET"
-069 "eSTX STARYE WERSII FAJLA, KOTORYE MOVNO WOSSTANOWITX"
-070 "sU]ESTWU@T DRUGIE FAJLY, KOTORYE MOVNO WOSSTANOWITX"
-071 "E-mail NE POSLAN: %s"
-072 "fAJL PUST - ISKATX NE^EGO"
-073 "dOSTIGNUT KONEC FAJLA BEZ NAHOVDENIQ OBRAZCA POISKA"
-074 "nE ZADAN OBRAZEC POISKA"
-075 "oBRAZEC POISKA NE NAJDEN"
-076 "dOSTUPNO NA^ALO FAJLA BEZ NAHOVDENIQ OBRAZCA POISKA"
-077 "pOISK ZACIKLEN"
-079 "nEPE^ATNYH SIMWOLOW NE NAJDENO"
-080 "nEIZWESTNAQ KOMANDA"
-082 "kOMANDA NE DOSTUPNA W REVIME ex"
-083 "s^ET^IK NE MOVET BYTX NULEM"
-084 "%s: NEPRAWILXNOE UKAZANIE STROKI"
-085 "wNUTRENNQQ O[IBKA W SINTAKSISE (%s: %s)"
-086 "iSPOLXZOWANIE: %s"
-087 "%s: WREMENNYJ BUFER NE ISPOLXZOWAN"
-088 "mETKA POSTAWLENA PERED STROKOJ 1"
-089 "mETKA POSTAWLENA POSLE KONCA FAJLA"
-092 "kOMANDA ex NE UDALASX: PARAMETRY KOMANDY ZABYTY"
-094 "wTOROJ ADRES MENX[E ^EM PERWYJ"
-095 "nE UKAZANO NAZWANIE OTMETKI"
-096 "\\ NE ZAWER[AETSQ / ILI ?"
-097 "sSYLKA K STROKE S NOMEROM MENX[E 0"
-098 "kOMANDA %s NEIZWESTNA"
-099 "pEREPOLNENIE ZNA^ENIQ ADRESA"
-100 "nEDOBOR ZNA^ENIQ ADRESA"
-101 "nEDOPUSTIMAQ KOMBINACIQ W ADRESE"
-102 "nEPRAWILXNYJ ADRES: WSEGO %lu STROK W FAJLE"
-103 "nEPRAWILXNYJ ADRES: FAJL PUST"
-104 "kOMMANDA %s NE MOVET ISPOLXZOWATX ADRES 0"
-105 "aBBREWIATURY OTSUTSTWU@T"
-106 "aBBREWIATURY DOLVNY ZAKAN^IWATXSQ SIMWOLOM "word""
-107 "aBBREWIATURY NE MOGUT SODERVATX SIMWOLOY TABLQCII ILI PROBELY"
-108 "aBBREWIATURY NE MOGUT SO^ETATXSQ S SIMWOLAMI SLOW/NE-SLOW, ZA ISKL@^ENIEM KONCA STROKI"
-109 ""%s" NE QWLQETSQ ABBREWIATUROJ"
-111 "fAJLOW DLQ REDAKTIROWANIQ BOLX[E NET"
-112 "oTSUTSTWIE PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQ"
-113 "oTSUTSTWIE PREDYDU]EGO FAJLA DLQ PROSMOTRA NAZAD"
-114 "nET FAJLOW"
-115 "oTSUTSTWIE PREDYDU]EJ KOMANDY DLQ ZAMENY "!""
-116 "oTSUTSTWIE ZAMENY DLQ %%"
-117 "oTSUTSTWIE ZAMENY DLQ #"
-118 "o[IBKA: execl: %s"
-119 "o[IBKA WWODA/WYWODA: %s"
-120 "fAJL IZMENEN S MOMENTA POSLEDNEJ POLNOJ ZAPISI: ISPOLXZUJTE ! DLQ OBHODA"
-121 "nEWOZMOVNO NAJTI DOMA[NIJ KATALOG"
-122 "nOWYJ KATALOG: %s"
-123 "nET WYREZANYH BUFEROW"
-124 "kOMANDA %s NE MOVET BYTX ISPOLXZOWANA WNUTRI OB]EJ KOMANDY"
-125 "%s/%s: NE OTKRYT: NE PRINADLEVIT wAM ILI root-U"
-126 "%s/%s: NE OTKRYT: NE PRINADLEVIT wAM"
-127 "%s/%s: NE OTKRYT: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEM"
-128 "%s/%s: NE S^ITAN: NE PRINADLEVIT wAM ILI root-U"
-129 "%s/%s: NE S^ITAN: NE PRINADLEVIT wAM"
-130 "%s/%s: NE S^ITAN: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEM"
-131 "pOSLEDU@]IE STROKI OTSUTSTWU@T"
-132 "oTSUTSTWIE PARAMETROW WWODA"
-133 "oTSUTSTWIE PARAMETROW KOMANDY"
-134 "sIMWOL %s NE MOVET BYTX PEREZAPOMNEN"
-135 ""%s" NA DANNYJ MOMENT NE OTME^EN"
-136 "iMQ METKI DOLVNO BYTX ODNIM SIMWOLOM"
-137 "%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODA"
-138 "nOWYJ FAJL .exrc: %s"
-139 "sTROKA PERENOSA NAHODITSQ WNUTRI PARAMETROW PERENOSA"
-140 "kOMANDA open PODRAZUMEWAET USTANOWKU OPCII open"
-141 "kOMANDA open NE REALIZOWANA"
-142 "zA]ITA FAJLA NEWOZMOVNA"
-143 "fAJL ZA]I]EN"
-144 "%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOW"
-146 "%s: ZA]ITA NA ^TENIE BYLA NEDOSTUPNA"
-148 "%s: %lu STROK, %lu SIMWOLOW"
-149 "nET TENEWYH OKON"
-150 "kOMANDA script ISPOLXZUETSQ TOLXKO W REVIME vi"
-151 "nET KOMANDY DLQ ISPOLNENIQ"
-152 "oPCIQ shiftwidth USTANOWLENA NA 0"
-153 "pEREPOLNENIE S^ET^IKA"
-154 "cIKL WYPOLNEN NE DO KONCA"
-155 "uKAZANO REGULQRNOE WYRAVENIE: FLAG r NE NUVEN"
-156 "fLAGI #, l I p NE MOGUT BYTX OB_EDINENY S FLAGOM c W REVIME vi"
-157 "sOWPADENIJ NET"
-158 "mETKA OTSUTSTWUET"
-159 "w STEKE METOK ZAPISEJ MENX[E, ^EM %s, ISPOLXZUJTE :display t[ags]"
-160 "fAJLA S IMENEM %s W STEKE METOK NET; ISPOLXZUJTE :display t[ags]"
-162 "%s: METKA NE NAJDENA"
-163 "%s: PLOHAQ METKA W %s"
-165 "sTEK METOK PUST"
-166 "%s: ISKOMAQ PEREMENNAQ NE NAJDENA"
-168 "bUFER %s PUST"
-170 "pRERWANO"
-171 "oTSUTSTWIE BUFERA DLQ ISPOLXZOWANIQ"
-172 "nET PREDIDU]EGO REGULQRNOGO WYRAVENIQ"
-173 "kOMANDA %s PODRAZUMEWAET NALI^IE PRO^TENNOGO FAJLA"
-174 "iSPOLXZOWANIE: %s"
-175 "kOMANDA visual PODRAZUMEWAET OBQZATELXNU@ USTANOWKU OPCII open"
-176 "%s RAS[IRILSQ DO SLI[KOM BOLX[OGO KOLI^ESTWA FAJLOW"
-177 "pUSTOJ FAJL"
-178 "nET PREDYDU]EGO POISKA F, f, T, ILI t"
-179 "%s NE NAJDENO"
-180 "nET PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQ"
-181 "kURSOR STOIT NE NA CIFRE"
-182 "pOLU^ENNOE ^ISLO SLI[KOM WELIKO"
-183 "pOLU^ENNOE ^ISLO SLI[KOM MALO"
-184 "pODHODQ]EGO SIMWOLA NET NA \TOJ STROKE"
-185 "pODHODQ]IJ SIMWOL NE NAJDEN"
-186 "nET SIMWOLOW DLQ UDALENIQ"
-187 "dRUGOGO \KRANA NE SU]ESTWUET"
-188 "sIMWOLY POSLE STROKI DLQ POISKA I/ILI PEREBOR STROKI"
-189 "pRO[LYJ OBRAZEC POISKA OTSUTSTWUET"
-190 "pOISK ZAWER[ILSQ NA NA^ALXNOJ POZICII"
-192 "sIMWOL NEPRAWILEN; ZAKL@^EN W KAWY^KI DLQ WWODA"
-193 "uVE NA NA^ALE WSTAWKI"
-194 "nET SIMWOLOW DLQ UDALENIQ"
-195 "pEREDWIVENIE ZA KONEC FAJLA"
-196 "pEREDWIVENIE ZA KONEC STROKI"
-197 "dWIVENIE STROKI NE SDELANO"
-198 "uVE NA NA^ALE FAJLA"
-199 "dWIVENIE KURSORA ZA NA^ALO FAJLA"
-200 "uVE W PERWOJ KOLONKE"
-201 "bUFERY DOLVNY BYTX UKAZANY DO WYPOLNENIQ KOMANDY"
-202 "uVE NA KONCE FAJLA"
-203 "uVE NA KONSE STROKI"
-204 "%s NE QWLQETSQ KOMANDOJ VI"
-205 "iSPOLXZOWANIE: %s"
-206 "nET SIMWOLOW DLQ UDALENIQ"
-208 "nET KOMANDY DLQ POWTORA"
-210 "kOMANDA %s NE MOVET BYTX ISPOLXZOWANA KAK KOMANDA PRODWIVENIQ"
-211 "~ISLO BOLX[E ^EM %lu"
-214 "zNA^ENIE KOLI^ESTWA OKON SLI[KOM WELIKO, MAKSIMALXNOE ZNA^ENIE = %u"
-220 "dWIVENIE KURSORA ZA KONEC \KRANA"
-221 "dWIVENIE KURSORA ZA NA^ALO \KRANA"
-223 "tENEWYH OKON NET"
-224 "nE SU]ESTWUET TENEWOGO OKNA S REDAKTIROWANIEM FAJLA %s"
-225 "wY NE MOVETE SDELATX EDINSTWENNOE OKNO TENEWYM"
-226 "|KRAN MOVET BYTX SVAT"
-227 "|KRAN NE MOVET BYTX SVAT"
-228 "|KRAN NE MOVET BYTX RAS[IREN"
-233 "dANNYJ TIP TERMINALA NE IMEET KLAWI[I %s"
-237 "nEWOZMOVNO SOZDATX WREMENNYJ FAJL"
-238 "wNIMANIE: %s SPECIALXNYJ FAJL"
-239 "%s UVE ZABLOKIROWAN, DOSTUPEN TOLXKO NA ^TENIE"
-240 "%s: UDALEN"
-241 "%s: ZAKRYT"
-242 "%s: UDALEN"
-243 "%s: UDALEN"
-244 "fAJL TOLXKO DLQ ^TENIQ, NE ZAPISAN: iSPOLXZUJTE ! DLQ OBHODA"
-245 "fAJL TOLXKO DLQ ^TENIQ, NE ZAPISAN"
-246 "%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODA"
-247 "%s SU]ESTWUET, NE ZAPISAN"
-248 "iSPOLXZUJTE ! DLQ ^ASTI^NOJ ZAPISI FAJLA"
-249 "~ASTX FAJLA, FAJL NE ZAPISAN"
-250 "%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQ: ISPOLXZUJTE ! DLQ OBHODA"
-251 "%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQ"
-252 "%s: ZA]ITA NA ZAPISX BYLA NEDOSTUPNA"
-254 "%s: wnimanie: fajl use~en"
-256 "%s: NOWYJ FAJL: %lu STROK, %lu SIMWOLOW"
-257 "%s: %lu STROK, %lu SIMWOLOW"
-258 "%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOW"
-259 "%s SPECIALXNYJ FAJL"
-260 "%s: NE PRINADLEVIT wAM"
-261 "%s: DOSTUPEN NE TOLXKO wAM"
-262 "fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODA"
-263 "fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE :edit DLQ OBHODA"
-264 "fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODA"
-265 "fAJL WREMENNYJ: WYHOD SOTRET L@BYE IZMENENIQ"
-267 "zAPISI NA^ATY ZANOWO"
+002 "ðÅÒÅÐÏÌÎÅÎÉÅ ÚÎÁÞÅÎÉÑ ÄÌÉÎÙ ÓÔÒÏËÉ"
+003 "ÎÅ×ÏÚÍÏÖÎÏ ÕÄÁÌÉÔØ ÓÔÒÏËÕ %lu"
+004 "ÎÅ×ÏÚÍÏÖÎÏ ÄÏÂÁ×ÉÔØ Ë ÓÔÒÏËÅ %lu"
+005 "ÎÅ×ÏÚÍÏÖÎÏ ×ÓÔÁ×ÉÔØ × ÓÔÒÏËÕ %lu"
+006 "ÎÅ×ÏÚÍÏÖÎÏ ÓÏÈÒÁÎÉÔØ ÓÔÒÏËÕ %lu"
+007 "ÎÅ×ÏÚÍÏÖÎÏ ÄÏÓÔÁÔØ ÐÏÓÌÅÄÎÀÀ ÓÔÒÏËÕ"
+008 "ïÛÉÂËÁ: ÎÅ ÕÄÁÌÏÓØ ÐÏÌÕÞÉÔØ ÓÔÒÏËÕ %lu"
+009 "æÁÊÌ ÚÁÐÉÓÅÊ"
+010 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÐÏÓÌÅÄÎÀÀ ËÏÍÁÎÄÕ"
+011 "îÅÔ ÉÚÍÅÎÅÎÉÊ ÄÌÑ ÏÔÍÅÎÙ"
+012 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÐÏÓÌÅÄÎÀÀ ËÏÍÁÎÄÕ"
+013 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÐÒÏÓÍÏÔÒÅÔØ ×ÐÅÒÅÄ"
+014 "îÅÔ ÉÚÍÅÎÅÎÉÊ ÄÌÑ ÐÅÒÅÄÅÌËÉ"
+015 "%s/%d: ÏÛÉÂËÁ ÐÒÉ ÚÁÐÉÓÉ ÐÒÏÔÏËÏÌÁ"
+016 "óÔÁÎÄÁÒÔÎÙÊ ××ÏÄ/×Ù×ÏÄ ÄÌÑ VI ÄÏÌÖÅÎ ÂÙÔØ ÔÅÒÍÉÎÁÌ"
+017 "ïÔÍÅÔËÁ %s: ÎÅ ÕÓÔÁÎÏ×ÌÅÎÁ"
+018 "ïÔÍÅÔËÁ %s: ÓÔÒÏËÁ ÂÙÌÁ ÕÄÁÌÅÎÁ"
+019 "ïÔÍÅÔËÁ %s: ÐÏÚÉÃÉÉ ËÕÒÓÏÒÁ ÂÏÌØÛÅ ÎÅ ÓÕÝÅÓÔ×ÕÅÔ"
+020 "ïÛÉÂËÁ: "
+021 "ÎÏ×ÙÊ ÆÁÊÌ"
+022 "ÉÍÑ ÉÚÍÅÎÅÎÏ"
+023 "ÍÏÄÉÆÉÃÉÒÏ×ÁÎÏ"
+024 "ÎÅ ÍÏÄÉÆÉÃÉÒÏ×ÁÎÏ"
+025 "òáúâìïëéòï÷áîï"
+026 "ÔÏÌØËÏ ÞÔÅÎÉÅ"
+027 "ÓÔÒÏËÁ %lu ÉÚ %lu [%ld%%]"
+028 "ÐÕÓÔÏÊ ÆÁÊÌ"
+029 "ÓÔÒÏËÁ %lu"
+030 "æÁÊÌ %s ÎÅ Ñ×ÌÑÅÔÓÑ ËÁÔÁÌÏÇÏÍ ÓÏÏÂÝÅÎÉÊ"
+031 "îÅ×ÏÚÍÏÖÎÏ ÕÓÔÁÎÏ×ÉÔØ ÏÐÃÉÀ %s ÐÏ ÕÍÏÌÞÁÎÉÀ"
+032 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
+033 "ïÐÃÉÉ %s ÎÅÔ: 'set all' ÐÏËÁÚÙ×ÁÅÔ ×ÓÅ ×ÏÚÍÏÖÎÙÅ ÏÐÃÉÉ"
+034 "set: [no]%s ÎÅ ÐÒÉÎÉÍÁÅÔ ÔÁËÏÇÏ ÚÎÁÞÅÎÉÑ"
+035 "set: %s ÏÐÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÌÏÇÉÞÅÓËÏÊ"
+036 "set: %s ÏÐÃÉÑ: %s"
+037 "set: %s ÏÐÃÉÑ: %s: ÚÎÁÞÅÎÉÅ ÐÅÒÅÐÏÌÎÅÎÉÑ"
+038 "set: ÎÅÐÒÁ×ÉÌØÎÏÅ ÚÎÁÞÅÎÉÅ %s"
+039 "set: %s ÏÐÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÌÏÇÉÞÅÓËÏÊ"
+040 "ëÏÌÉÞÅÓÔ×Ï ËÏÌÏÎÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ÍÁÌÏ, ÍÅÎØÛÅ ÞÅÍ %d"
+041 "ëÏÌÉÞÅÓÔ×Ï ËÏÌÏÎÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÂÏÌØÛÅ ÞÅÍ %d"
+042 "ëÏÌÉÞÅÓÔ×Ï ÓÔÒÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ÍÁÌÏ, ÍÅÎØÛÅ ÞÅÍ %d"
+043 "ëÏÌÉÞÅÓÔ×Ï ÓÔÒÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÂÏÌØÛÅ ÞÅÍ %d"
+044 "ïÐÃÉÑ lisp ÏÔÓÕÔÓÔ×ÕÅÔ"
+045 "óÏÏÂÝÅÎÉÑ ÎÅ ×ÙËÌÀÞÅÎÙ: %s"
+046 "óÏÏÂÝÅÎÉÑ ÎÅ ×ËÌÀÞÅÎÙ: %s"
+047 "ïÐÃÉÑ %s ÄÏÌÖÎÁ ÓÏÓÔÏÑÔØ ÉÚ ÇÒÕÐÐ Ó Ä×ÕÍÑ ÓÉÍ×ÏÌÁÍÉ"
+053 "óÔÁÒÔÏ×ÙÊ ÂÕÆÅÒ ÐÕÓÔ"
+054 "âÕÆÅÒ %s ÐÕÓÔ"
+055 "æÁÊÌÙ Ó ÓÉÍ×ÏÌÁÍÉ ÐÅÒÅ×ÏÄÁ ÓÔÒÏËÉ × ÉÍÅÎÉ ÎÅ ÍÏÇÕÔ ÂÙÔØ ×ÏÓÓÔÁÎÏ×ÌÅÎÙ"
+056 "éÚÍÅÎÅÎÉÑ ÎÅ ÓÏÈÒÁÎÅÎÙ ÐÒÉ ËÒÁÈÅ ÓÅÓÓÉÉ"
+057 "ëÏÐÉÒÏ×ÁÎÉÅ ÆÁÊÌÁ ÄÌÑ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÑ..."
+058 "óÏÈÒÁÎÅÎÉÅ ÎÅ ÕÄÁÌÏÓØ: %s"
+059 "éÚÍÅÎÅÎÉÑ ÎÅ ÓÏÈÒÁÎÑÀÔÓÑ ÐÒÉ ÏÂÒÙ×Å ÓÅÓÓÉÉ"
+060 "óÏÈÒÁÎÅÎÉÅ ËÏÐÉÉ ÆÁÊÌÁ ÎÅ ÕÄÁÌÏÓØ: %s"
+061 "ëÏÐÉÒÏ×ÁÎÉÅ ÆÁÊÌÁ ÄÌÑ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÑ..."
+062 "éÎÆÏÒÍÁÃÉÉ ÎÁ ÐÏÌØÚÏ×ÁÔÅÌÑ %u ÎÅ ÎÁÊÄÅÎÏ"
+063 "îÅ×ÏÚÍÏÖÎÏ ÚÁÝÉÔÉÔØ ÓÐÁÓÅÎÎÙÊ ÆÁÊÌ"
+064 "âÕÆÅÒ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÏÇÏ ÆÁÊÌÁ ÐÅÒÅÐÏÌÎÅÎ"
+065 "÷ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌ"
+066 "%s: ÎÅ ÄÏ ËÏÎÃÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌ"
+067 "%s: ÎÅ ÄÏ ËÏÎÃÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌ"
+068 "æÁÊÌÏ× Ó ÉÍÅÎÅÍ %s, ËÏÔÏÒÙÅ ÷Ù ÍÏÖÅÔÅ ÞÉÔÁÔØ, ÎÅ ÓÕÝÅÓÔ×ÕÅÔ"
+069 "åÓÔØ ÓÔÁÒÙÅ ×ÅÒÓÉÉ ÆÁÊÌÁ, ËÏÔÏÒÙÅ ÍÏÖÎÏ ×ÏÓÓÔÁÎÏ×ÉÔØ"
+070 "óÕÝÅÓÔ×ÕÀÔ ÄÒÕÇÉÅ ÆÁÊÌÙ, ËÏÔÏÒÙÅ ÍÏÖÎÏ ×ÏÓÓÔÁÎÏ×ÉÔØ"
+071 "Å-mail ÎÅ ÐÏÓÌÁÎ: %s"
+072 "æÁÊÌ ÐÕÓÔ - ÉÓËÁÔØ ÎÅÞÅÇÏ"
+073 "äÏÓÔÉÇÎÕÔ ËÏÎÅà ÆÁÊÌÁ ÂÅÚ ÎÁÈÏÖÄÅÎÉÑ ÏÂÒÁÚÃÁ ÐÏÉÓËÁ"
+074 "îÅ ÚÁÄÁÎ ÏÂÒÁÚÅà ÐÏÉÓËÁ"
+075 "ïÂÒÁÚÅà ÐÏÉÓËÁ ÎÅ ÎÁÊÄÅÎ"
+076 "äÏÓÔÕÐÎÏ ÎÁÞÁÌÏ ÆÁÊÌÁ ÂÅÚ ÎÁÈÏÖÄÅÎÉÑ ÏÂÒÁÚÃÁ ÐÏÉÓËÁ"
+077 "ðÏÉÓË ÚÁÃÉËÌÅÎ"
+078 "ðÏÉÓË..."
+079 "îÅÐÅÞÁÔÎÙÈ ÓÉÍ×ÏÌÏ× ÎÅ ÎÁÊÄÅÎÏ"
+080 "îÅÉÚ×ÅÓÔÎÁÑ ËÏÍÁÎÄÁ"
+082 "%s: ËÏÍÁÎÄÁ ÎÅ ÄÏÓÔÕÐÎÁ × ÒÅÖÉÍÅ ex"
+083 "óÞÅÔÞÉË ÎÅ ÍÏÖÅÔ ÂÙÔØ ÎÕÌÅÍ"
+084 "%s: ÎÅÐÒÁ×ÉÌØÎÏÅ ÕËÁÚÁÎÉÅ ÓÔÒÏËÉ"
+085 "÷ÎÕÔÒÅÎÎÑÑ ÏÛÉÂËÁ × ÓÉÎÔÁËÓÉÓÅ (%s: %s)"
+086 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
+087 "%s: ×ÒÅÍÅÎÎÙÊ ÂÕÆÅÒ ÎÅ ÉÓÐÏÌØÚÏ×ÁÎ"
+088 "íÅÔËÁ ÐÏÓÔÁ×ÌÅÎÁ ÐÅÒÅÄ ÓÔÒÏËÏÊ 1"
+089 "íÅÔËÁ ÐÏÓÔÁ×ÌÅÎÁ ÐÏÓÌÅ ËÏÎÃÁ ÆÁÊÌÁ"
+090 "@ Ó ÄÉÁÐÁÚÏÎÏÍ ×ÙÐÏÌÎÑÅÔÓÑ ËÏÇÄÁ ÆÁÊÌ/ÜËÒÁÎ ÉÚÍÅÎÅÎÙ"
+091 "çÌÏÂÁÌØÎÁÑ/v ËÏÍÁÎÄÁ ×ÙÐÏÌÎÑÅÔÓÑ ËÏÇÄÁ ÆÁÊÌ/ÜËÒÁÎ ÉÚÍÅÎÅÎÙ"
+092 "ëÏÍÁÎÄÁ ex ÎÅ ÕÄÁÌÁÓØ: ÐÏÓÌÅÄÕÀÝÉÅ ËÏÍÁÎÄÙ ÚÁÂÙÔÙ"
+093 "ëÏÍÁÎÄÁ ex ÎÅ ÕÄÁÌÁÓØ: ÎÁÚÎÁÞÅÎÎÙÅ ËÌÁ×ÉÛÉ ÚÁÂÙÔÙ"
+094 "÷ÔÏÒÏÊ ÁÄÒÅÓ ÍÅÎØÛÅ ÞÅÍ ÐÅÒ×ÙÊ"
+095 "îÅ ÕËÁÚÁÎÏ ÎÁÚ×ÁÎÉÅ ÏÔÍÅÔËÉ"
+096 "\\ ÎÅ ÚÁ×ÅÒÛÁÅÔÓÑ / ÉÌÉ ?"
+097 "óÓÙÌËÁ Ë ÓÔÒÏËÅ Ó ÎÏÍÅÒÏÍ ÍÅÎØÛÅ 0"
+098 "ëÏÍÁÎÄÁ %s ÎÅÉÚ×ÅÓÔÎÁ"
+099 "ðÅÒÅÐÏÌÎÅÎÉÅ ÚÎÁÞÅÎÉÑ ÁÄÒÅÓÁ"
+100 "îÅÄÏÂÏÒ ÚÎÁÞÅÎÉÑ ÁÄÒÅÓÁ"
+101 "îÅÄÏÐÕÓÔÉÍÁÑ ËÏÍÂÉÎÁÃÉÑ × ÁÄÒÅÓÅ"
+102 "îÅÐÒÁ×ÉÌØÎÙÊ ÁÄÒÅÓ: ×ÓÅÇÏ %lu ÓÔÒÏË × ÆÁÊÌÅ"
+103 "îÅÐÒÁ×ÉÌØÎÙÊ ÁÄÒÅÓ: ÆÁÊÌ ÐÕÓÔ"
+104 "ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØ ÁÄÒÅÓ 0"
+105 "áÂÂÒÅ×ÉÁÔÕÒÙ ÏÔÓÕÔÓÔ×ÕÀÔ"
+106 "áÂÂÒÅ×ÉÁÔÕÒÙ ÄÏÌÖÎÙ ÚÁËÁÎÞÉ×ÁÔØÓÑ ÓÉÍ×ÏÌÏÍ \"ÓÌÏ×\""
+107 "áÂÂÒÅ×ÉÁÔÕÒÙ ÎÅ ÍÏÇÕÔ ÓÏÄÅÒÖÁÔØ ÓÉÍ×ÏÌÙ ÔÁÂÕÌÑÃÉÉ ÉÌÉ ÐÒÏÂÅÌÙ"
+108 "áÂÂÒÅ×ÉÁÔÕÒÙ ÎÅ ÍÏÇÕÔ ÓÏÞÅÔÁÔØÓÑ Ó ÓÉÍ×ÏÌÁÍÉ ÓÌÏ×/ÎÅ-ÓÌÏ×, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ËÏÎÃÁ ÓÔÒÏËÉ"
+109 "\"%s\" ÎÅ Ñ×ÌÑÅÔÓÑ ÁÂÂÒÅ×ÉÁÔÕÒÏÊ"
+110 "Vi ËÏÍÁÎÄÁ ÎÅ ÕÄÁÌÁÓØ: ÎÁÚÎÁÞÅÎÎÙÅ ËÌÁ×ÉÛÉ ÚÁÂÙÔÙ"
+111 "æÁÊÌÏ× ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ ÂÏÌØÛÅ ÎÅÔ"
+112 "ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+113 "ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÐÒÏÓÍÏÔÒÁ ÎÁÚÁÄ"
+114 "îÅÔ ÆÁÊÌÏ×"
+115 "ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÊ ËÏÍÁÎÄÙ ÄÌÑ ÚÁÍÅÎÙ \"!\""
+116 "ïÔÓÕÔÓÔ×ÉÅ ÚÁÍÅÎÙ ÄÌÑ %%"
+117 "ïÔÓÕÔÓÔ×ÉÅ ÚÁÍÅÎÙ ÄÌÑ #"
+118 "ïÛÉÂËÁ: execl: %s"
+119 "ïÛÉÂËÁ ××ÏÄÁ/×Ù×ÏÄÁ: %s"
+120 "æÁÊÌ ÉÚÍÅÎÅÎ Ó ÍÏÍÅÎÔÁ ÐÏÓÌÅÄÎÅÊ ÐÏÌÎÏÊ ÚÁÐÉÓÉ: ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
+121 "îÅ×ÏÚÍÏÖÎÏ ÎÁÊÔÉ ÄÏÍÁÛÎÉÊ ËÁÔÁÌÏÇ"
+122 "îÏ×ÙÊ ËÁÔÁÌÏÇ: %s"
+123 "îÅÔ ×ÙÒÅÚÁÎÎÙÈ ÂÕÆÅÒÏ×"
+124 "ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÁ ×ÎÕÔÒÉ ÇÌÏÂÁÌØÎÏÊ ÉÌÉ v ËÏÍÁÎÄÙ"
+125 "%s/%s: ÎÅ ÏÔËÒÙÔ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ ÉÌÉ root-Õ"
+126 "%s/%s: ÎÅ ÏÔËÒÙÔ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ"
+127 "%s/%s: ÎÅ ÏÔËÒÙÔ: ×ÏÚÍÏÖÎÏÓÔØ ÚÁÐÉÓÉ Õ ÐÏÌØÚÏ×ÁÔÅÌÑ, ÎÅ Ñ×ÌÑÀÝÅÇÏÓÑ ×ÌÁÄÅÌØÃÅÍ"
+128 "%s: ÎÅ ÓÞÉÔÁÎ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ ÉÌÉ root-Õ"
+129 "%s: ÎÅ ÓÞÉÔÁÎ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ"
+130 "%s: ÎÅ ÓÞÉÔÁÎ: ×ÏÚÍÏÖÎÏÓÔØ ÚÁÐÉÓÉ Õ ÐÏÌØÚÏ×ÁÔÅÌÑ, ÎÅ Ñ×ÌÑÀÝÅÇÏÓÑ ×ÌÁÄÅÌØÃÅÍ"
+131 "ðÏÓÌÅÄÕÀÝÉÅ ÓÔÒÏËÉ ÏÔÓÕÔÓÔ×ÕÀÔ"
+132 "ïÔÓÕÔÓÔ×ÉÅ ÐÁÒÁÍÅÔÒÏ× ××ÏÄÁ"
+133 "ïÔÓÕÔÓÔ×ÉÅ ÐÁÒÁÍÅÔÒÏ× ËÏÍÁÎÄÙ"
+134 "óÉÍ×ÏÌ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÐÅÒÅÎÁÚÎÁÞÅÎ"
+135 "\"%s\" ÎÁ ÄÁÎÎÙÊ ÍÏÍÅÎÔ ÎÅ ÎÁÚÎÁÞÅÎ"
+136 "éÍÑ ÍÅÔËÉ ÄÏÌÖÎÏ ÂÙÔØ ÏÄÎÉÍ ÓÉÍ×ÏÌÏÍ"
+137 "%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ; ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
+138 "îÏ×ÙÊ ÆÁÊÌ exrc: %s"
+139 "óÔÒÏËÁ ÐÅÒÅÎÏÓÁ ÎÁÈÏÄÉÔÓÑ ×ÎÕÔÒÉ ÐÁÒÁÍÅÔÒÏ× ÐÅÒÅÎÏÓÁ"
+140 "ëÏÍÁÎÄÁ open ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÕÓÔÁÎÏ×ËÕ ÏÐÃÉÉ open"
+141 "ëÏÍÁÎÄÁ open ÎÅ ÒÅÁÌÉÚÏ×ÁÎÁ"
+142 "úÁÝÉÔÁ ÆÁÊÌÁ ÎÅ×ÏÚÍÏÖÎÁ"
+143 "æÁÊÌ ÚÁÝÉÝÅÎ"
+144 "%s ÒÁÓÛÉÒÉÌÓÑ × ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÍÅÎ ÆÁÊÌÏ×"
+145 "ôÏÌØËÏ ÏÂÙÞÎÙÅ ÆÁÊÌÙ ÉÌÉ ÉÍÅÎÏ×ÁÎÎÙÅ ËÁÎÁÌÙ ÍÏÇÕÔ ÂÙÔØ ÐÒÏÞÉÔÁÎÙ"
+146 "%s: ÚÁÝÉÔÁ ÎÁ ÞÔÅÎÉÅ ÂÙÌÁ ÎÅÄÏÓÔÕÐÎÁ"
+147 "þÔÅÎÉÅ..."
+148 "%s: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×"
+149 "îÅÔ ÔÅÎÅ×ÙÈ ÏËÏÎ"
+150 "ëÏÍÁÎÄÁ script ÉÓÐÏÌØÚÕÅÔÓÑ ÔÏÌØËÏ × ÒÅÖÉÍÅ vi"
+151 "îÅÔ ËÏÍÁÎÄÙ ÄÌÑ ÉÓÐÏÌÎÅÎÉÑ"
+152 "ïÐÃÉÑ shiftwidth ÕÓÔÁÎÏ×ÌÅÎÁ ÎÁ 0"
+153 "ðÅÒÅÐÏÌÎÅÎÉÅ ÓÞÅÔÞÉËÁ"
+154 "ãÉËÌ ×ÙÐÏÌÎÅÎ ÎÅ ÄÏ ËÏÎÃÁ"
+155 "õËÁÚÁÎÏ ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ: ÆÌÁÇ r ÎÅ ÎÕÖÅÎ"
+156 "æÌÁÇÉ #, l É p ÎÅ ÍÏÇÕÔ ÂÙÔØ ÏÂßÅÄÉÎÅÎÙ Ó ÆÌÁÇÏÍ c × ÒÅÖÉÍÅ vi"
+157 "óÏ×ÐÁÄÅÎÉÊ ÎÅÔ"
+158 "íÅÔËÁ ÏÔÓÕÔÓÔ×ÕÅÔ"
+159 "÷ ÓÔÅËÅ ÍÅÔÏË ÚÁÐÉÓÅÊ ÍÅÎØÛÅ, ÞÅÍ %s, ÉÓÐÏÌØÚÕÊÔÅ :display t[ags]"
+160 "æÁÊÌÁ Ó ÉÍÅÎÅÍ %s × ÓÔÅËÅ ÍÅÔÏË ÎÅÔ; ÉÓÐÏÌØÚÕÊÔÅ :display t[ags]"
+161 "îÁÖÍÉÔÅ Enter ÞÔÏÂÙ ÐÒÏÄÏÌÖÉÔØ: "
+162 "%s: ÍÅÔËÁ ÎÅ ÎÁÊÄÅÎÁ"
+163 "%s: ÐÌÏÈÁÑ ÍÅÔËÁ × %s"
+164 "%s: ÎÏÍÅÒ ÓÔÒÏËÉ ÍÅÔËÉ ×ÙÛÅÌ ÚÁ ËÏÎÅÃ ÆÁÊÌÁ"
+165 "óÔÅË ÍÅÔÏË ÐÕÓÔ"
+166 "%s: ÏÂÒÁÚÅÃ ÐÏÉÓËÁ ÎÅ ÎÁÊÄÅÎ"
+167 "ÅÝÅ %d ÆÁÊÌÏ× ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+168 "âÕÆÅÒ %s ÐÕÓÔ"
+169 "ðÏÄÔ×ÅÒÄÉÔØ ÉÚÍÅÎÅÎÉÑ? [n]"
+170 "ðÒÅÒ×ÁÎÏ"
+171 "ïÔÓÕÔÓÔ×ÉÅ ÂÕÆÅÒÁ ÄÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ"
+172 "îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ"
+173 "ëÏÍÁÎÄÁ %s ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÎÁÌÉÞÉÅ ÐÒÏÞÔÅÎÎÏÇÏ ÆÁÊÌÁ"
+174 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
+175 "ëÏÍÁÎÄÁ visual ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÏÂÑÚÁÔÅÌØÎÕÀ ÕÓÔÁÎÏ×ËÕ ÏÐÃÉÉ open"
+177 "ðÕÓÔÏÊ ÆÁÊÌ"
+178 "îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÐÏÉÓËÁ F, f, T, ÉÌÉ t"
+179 "%s ÎÅ ÎÁÊÄÅÎÏ"
+180 "îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+181 "ëÕÒÓÏÒ ÓÔÏÉÔ ÎÅ ÎÁ ÃÉÆÒÅ"
+182 "ðÏÌÕÞÅÎÎÏÅ ÞÉÓÌÏ ÓÌÉÛËÏÍ ×ÅÌÉËÏ"
+183 "ðÏÌÕÞÅÎÎÏÅ ÞÉÓÌÏ ÓÌÉÛËÏÍ ÍÁÌÏ"
+184 "ðÏÄÈÏÄÑÝÅÇÏ ÓÉÍ×ÏÌÁ ÎÅÔ ÎÁ ÜÔÏÊ ÓÔÒÏËÅ"
+185 "ðÏÄÈÏÄÑÝÉÊ ÓÉÍ×ÏÌ ÎÅ ÎÁÊÄÅÎ"
+186 "îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑ"
+187 "äÒÕÇÏÇÏ ÜËÒÁÎÁ ÎÅ ÓÕÝÅÓÔ×ÕÅÔ"
+188 "óÉÍ×ÏÌÙ ÐÏÓÌÅ ÓÔÒÏËÉ ÄÌÑ ÐÏÉÓËÁ, ÓÍÅÝÅÎÉÑ ÓÔÒÏËÉ É/ÉÌÉ ËÏÍÁÎÄÙ z"
+189 "ðÒÏÛÌÙÊ ÏÂÒÁÚÅÃ ÐÏÉÓËÁ ÏÔÓÕÔÓÔ×ÕÅÔ"
+190 "ðÏÉÓË ÚÁ×ÅÒÛÉÌÓÑ ÎÁ ÎÁÞÁÌØÎÏÊ ÐÏÚÉÃÉÉ"
+191 "áÂÂÒÅ×ÉÁÔÕÒÁ ÐÒÅ×ÙÓÉÌÁ ÌÉÍÉÔ ÒÁÓÛÉÒÅÎÉÑ: ÓÉÍ×ÏÌÙ ÚÁÂÙÔÙ"
+192 "óÉÍ×ÏÌ ÎÅÐÒÁ×ÉÌÅÎ; Ë×ÏÔÉÒÕÊÔÅ ÄÌÑ ××ÏÄÁ"
+193 "õÖÅ ÎÁ ÎÁÞÁÌÅ ×ÓÔÁ×ËÉ"
+194 "îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑ"
+195 "ðÅÒÅÄ×ÉÖÅÎÉÅ ÚÁ ËÏÎÅà ÆÁÊÌÁ"
+196 "ðÅÒÅÄ×ÉÖÅÎÉÅ ÚÁ ËÏÎÅà ÓÔÒÏËÉ"
+197 "ä×ÉÖÅÎÉÅ ÓÔÒÏËÉ ÎÅ ÓÄÅÌÁÎÏ"
+198 "õÖÅ ÎÁ ÎÁÞÁÌÅ ÆÁÊÌÁ"
+199 "ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ÎÁÞÁÌÏ ÆÁÊÌÁ"
+200 "õÖÅ × ÐÅÒ×ÏÊ ËÏÌÏÎËÅ"
+201 "âÕÆÅÒÙ ÄÏÌÖÎÙ ÂÙÔØ ÕËÁÚÁÎÙ ÄÏ ×ÙÐÏÌÎÅÎÉÑ ËÏÍÁÎÄÙ"
+202 "õÖÅ ÎÁ ËÏÎÃÅ ÆÁÊÌÁ"
+203 "õÖÅ ÎÁ ËÏÎÃÅ ÓÔÒÏËÉ"
+204 "%s ÎÅ Ñ×ÌÑÅÔÓÑ ËÏÍÁÎÄÏÊ VI"
+205 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
+206 "îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑ"
+207 "ëÏÍÁÎÄÁ Q ÔÒÅÂÕÅÔ ex ÉÎÔÅÒÆÅÊÓ ÔÅÒÍÉÎÁÌÁ"
+208 "îÅÔ ËÏÍÁÎÄÙ ÄÌÑ ÐÏ×ÔÏÒÁ"
+209 "æÁÊÌ ÐÕÓÔ"
+210 "ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÁ ËÁË ËÏÍÁÎÄÁ ÐÅÒÅÍÅÝÅÎÉÑ"
+211 "õÖÅ × ËÏÍÁÎÄÎÏÍ ÒÅÖÉÍÅ"
+212 "ëÕÒÓÏÒ ÎÁÈÏÄÉÔÓÑ ÎÅ ÎÁ ÓÌÏ×Å"
+214 "úÎÁÞÅÎÉÅ ÏÐÃÉÉ windows ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÍÁËÓÉÍÁÌØÎÏÅ ÚÎÁÞÅÎÉÅ = %u"
+215 "äÏÂÁ×ÉÔØ"
+216 "éÚÍÅÎÉÔØ"
+217 "ëÏÍÁÎÄÁ"
+218 "÷ÓÔÁ×ÉÔØ"
+219 "úÁÍÅÎÉÔØ"
+220 "ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ËÏÎÅà ÜËÒÁÎÁ"
+221 "ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ÎÁÞÁÌÏ ÜËÒÁÎÁ"
+222 "äÌÑ ÒÁÚÄÅÌÅÎÉÑ ÜËÒÁÎ ÄÏÌÖÅÎ ÂÙÔØ ÂÏÌØÛÅ ÞÅÍ ÓÔÒÏËÉ %d"
+223 "ôÅÎÅ×ÙÈ ÏËÏÎ ÎÅÔ"
+224 "îÅ ÓÕÝÅÓÔ×ÕÅÔ ÔÅÎÅ×ÏÇÏ ÏËÎÁ Ó ÒÅÄÁËÔÉÒÏ×ÁÎÉÅÍ ÆÁÊÌÁ %s"
+225 "÷Ù ÎÅ ÍÏÖÅÔÅ ÓÄÅÌÁÔØ ÅÄÉÎÓÔ×ÅÎÎÏÅ ÏËÎÏ ÔÅÎÅ×ÙÍ"
+226 "üËÒÁÎ ÍÏÖÅÔ ÂÙÔØ ÓÖÁÔ"
+227 "üËÒÁÎ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÓÖÁÔ ÔÏÌØËÏ ÄÏ %d ÓÔÒÏË"
+228 "üËÒÁÎ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÒÁÓÛÉÒÅÎ"
+230 "üÔÏÔ ÜËÒÁÎ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÐÒÉÏÓÔÁÎÏ×ÌÅÎ"
+231 "ðÒÅÒ×ÁÎÏ: ÎÁÚÎÁÞÅÎÎÙÅ ËÌÁ×ÉÛÉ ÚÁÂÙÔÙ"
+232 "vi: ×ÒÅÍÅÎÎÙÊ ÂÕÆÅÒ ÎÅ ÏÓ×ÏÂÏÖÄÅÎ"
+233 "äÁÎÎÙÊ ÔÉÐ ÔÅÒÍÉÎÁÌÁ ÎÅ ÉÍÅÅÔ ËÌÁ×ÉÛÉ %s"
+234 "íÏÖÅÔ ÂÙÔØ ÕËÁÚÁÎ ÔÏÌØËÏ ÏÄÉÎ ÂÕÆÅÒ"
+235 "þÉÓÌÏ ÂÏÌØÛÅ ÞÅÍ %lu"
+236 "ðÒÅÒ×ÁÎÏ"
+237 "îÅ×ÏÚÍÏÖÎÏ ÓÏÚÄÁÔØ ×ÒÅÍÅÎÎÙÊ ÆÁÊÌ"
+238 "÷ÎÉÍÁÎÉÅ: %s ÓÐÅÃÉÁÌØÎÙÊ ÆÁÊÌ"
+239 "%s ÕÖÅ ÚÁÂÌÏËÉÒÏ×ÁÎ, ÄÏÓÔÕÐÅÎ ÔÏÌØËÏ ÎÁ ÞÔÅÎÉÅ"
+240 "%s: ÕÄÁÌÅÎ"
+241 "%s: ÚÁËÒÙÔ"
+242 "%s: ÕÄÁÌÅÎ"
+243 "%s: ÕÄÁÌÅÎ"
+244 "æÁÊÌ ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ, ÎÅ ÚÁÐÉÓÁÎ: éÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
+245 "æÁÊÌ ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ, ÎÅ ÚÁÐÉÓÁÎ"
+246 "%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ; ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
+247 "%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ"
+248 "éÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÞÁÓÔÉÞÎÏÊ ÚÁÐÉÓÉ ÆÁÊÌÁ"
+249 "þÁÓÔØ ÆÁÊÌÁ, ÆÁÊÌ ÎÅ ÚÁÐÉÓÁÎ"
+250 "%s: æÁÊÌ ÉÚÍÅÎÑÌÓÑ ÐÏÚÄÎÅÅ, ÞÅÍ ÄÁÎÎÁÑ ËÏÐÉÑ: ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
+251 "%s: æÁÊÌ ÉÚÍÅÎÑÌÓÑ ÐÏÚÄÎÅÅ, ÞÅÍ ÄÁÎÎÁÑ ËÏÐÉÑ"
+252 "%s: ÚÁÝÉÔÁ ÎÁ ÚÁÐÉÓØ ÂÙÌÁ ÎÅÄÏÓÔÕÐÎÁ"
+253 "úÁÐÉÓØ..."
+254 "%s: ÷îéíáîéå: æáêì õóåþåî"
+255 "õÖÅ ÐÒÉÓÕÔÓÔ×ÕÅÔ × ÐÅÒ×ÏÊ ÍÅÔËÅ ÄÁÎÎÏÊ ÇÒÕÐÐÙ"
+256 "%s: ÎÏ×ÙÊ ÆÁÊÌ: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×"
+257 "%s: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×"
+258 "%s ÒÁÓÛÉÒÉÌÓÑ × ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÍÅÎ ÆÁÊÌÏ×"
+259 "%s: ÓÐÅÃÉÁÌØÎÙÊ ÆÁÊÌ"
+260 "%s: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ"
+261 "%s: ÄÏÓÔÕÐÅÎ ÎÅ ÔÏÌØËÏ ÷ÁÍ"
+262 "æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
+263 "æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ :edit ÄÌÑ ÏÂÈÏÄÁ"
+264 "æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
+265 "æÁÊÌ ×ÒÅÍÅÎÎÙÊ: ×ÙÈÏÄ ÓÏÔÒÅÔ ÌÀÂÙÅ ÉÚÍÅÎÅÎÉÑ"
+266 "æÁÊÌ ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ, Á×ÔÏÚÁÐÉÓØ ÎÅ ÓÒÁÂÏÔÁÌÁ"
+267 "úÁÐÉÓÉ ÎÁÞÁÔÙ ÚÁÎÏ×Ï"
+268 "ÐÏÄÔ×ÅÒÄÉÔØ? [ynq]"
+269 "îÁÖÍÉÔÅ ÌÀÂÕÀ ËÌÁ×ÉÛÕ ÞÔÏÂÙ ÐÒÏÄÏÌÖÉÔØ: "
+270 "îÁÖÍÉÔÅ ÌÀÂÕÀ ËÌÁ×ÉÛÕ ÞÔÏÂÙ ÐÒÏÄÏÌÖÉÔØ [: ÞÔÏÂÙ ××ÅÓÔÉ ÅÝÅ ex ËÏÍÁÎÄÙ]: "
+271 "îÁÖÍÉÔÅ ÌÀÂÕÀ ËÌÁ×ÉÛÕ ÞÔÏÂÙ ÐÒÏÄÏÌÖÉÔØ [q ÞÔÏÂÙ ×ÙÊÔÉ]: "
+272 "üÔÁ ÆÏÒÍÁ %s ÔÒÅÂÕÅÔ ex ÉÎÔÅÒÆÅÊÓ ÔÅÒÍÉÎÁÌÁ"
+273 "÷ÈÏÄ × ÒÅÖÉÍ ××ÏÄÁ ex."
+274 "ëÏÍÁÎÄÁ ÎÅ ÕÄÁÌÁÓØ, ÆÁÊÌ ÅÝÅ ÎÅ ÐÒÏÞÔÅÎ."
+275 " ÐÒÏÄ?"
+276 "îÅÏÖÉÄÁÎÎÏÅ ÓÉÍ×ÏÌØÎÏÅ ÓÏÂÙÔÉÅ"
+277 "îÅÏÖÉÄÁÎÎÏÅ ÓÏÂÙÔÉÅ 'ËÏÎÅà ÆÁÊÌÁ'"
+278 "ðÏ ÚÁÐÒÏÓÕ ÓÏ×ÐÁÄÅÎÉÊ ÎÅÔ"
+279 "îÅÏÖÉÄÁÎÎÏÅ ÓÏÂÙÔÉÅ ÐÒÅÒÙ×ÁÎÉÑ"
+280 "îÅÏÖÉÄÁÎÎÏÅ ÓÏÂÙÔÉÅ ×ÙÈÏÄÁ"
+281 "îÅÏÖÉÄÁÎÎÏÅ ÓÏÂÙÔÉÅ ÐÅÒÅÒÉÓÏ×ËÉ"
+282 "õÖÅ ÐÒÉÓÕÔÓÔ×ÕÅÔ × ÐÏÓÌÅÄÎÅÊ ÍÅÔËÅ ÄÁÎÎÏÊ ÇÒÕÐÐÙ"
+283 "ëÏÍÁÎÄÁ %s ÔÒÅÂÕÅÔ ex ÉÎÔÅÒÆÅÊÓ ÔÅÒÍÉÎÁÌÁ"
+284 "üÔÁ ÆÏÒÍÁ %s ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ ÐÏËÁ ÕÓÔÁÎÏ×ÌÅÎÁ ÏÐÃÉÑ ÂÅÚÏÐÁÓÎÏÇÏ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+285 "îÅÏÖÉÄÁÎÎÏÅ ÓÔÒÏËÏ×ÏÅ ÓÏÂÙÔÉÅ"
+286 "îÅÏÖÉÄÁÎÎÏÅ ÓÏÂÙÔÉÅ ÔÁÊÍÁÕÔÁ"
+287 "îÅÏÖÉÄÁÎÎÏÅ ÓÏÂÙÔÉÅ ÚÁÐÉÓÉ"
+288 "äÌÑ ÒÁÚÄÅÌÅÎÉÑ ÜËÒÁÎ ÄÏÌÖÅÎ ÂÙÔØ ÂÏÌØÛÅ ÞÅÍ ÓÔÏÌÂÃÙ %d"
+289 "Shell ÒÁÓÛÉÒÅÎÉÑ ÎÅ ÐÏÄÄÅÒÖÉ×ÁÀÔÓÑ ÐÏËÁ ÕÓÔÁÎÏ×ÌÅÎÁ ÏÐÃÉÑ ÂÅÚÏÐÁÓÎÏÇÏ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+290 "ëÏÍÁÎÄÁ %s ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ ÐÏËÁ ÕÓÔÁÎÏ×ÌÅÎÁ ÏÐÃÉÑ ÂÅÚÏÐÁÓÎÏÇÏ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+291 "set: ÏÐÃÉÑ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ×ÙËÌÀÞÅÎÁ"
+292 "üËÒÁÎ ÓÌÉÛËÏÍ ÍÁÌ"
+293 "ÄÏÂÁ×ÌÅÎÏ"
+294 "ÉÚÍÅÎÅÎÏ"
+295 "ÕÄÁÌÅÎÏ"
+296 "ÐÒÉÓÏÅÄÉÎÅÎÏ"
+297 "ÐÅÒÅÍÅÝÅÎÏ"
+298 "ÓÍÅÝÅÎÏ"
+299 "ÓËÏÐÉÒÏ×ÁÎÏ"
+300 "ÓÔÒÏËÁ"
+301 "ÓÔÒÏËÉ"
+303 "æÁÊÌ ÉÚÍÅÎÅÎ Ó ÍÏÍÅÎÔÁ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ."
+304 "Shell ÒÁÓÛÉÒÅÎÉÅ ÎÅ ÕÄÁÌÏÓØ"
+305 "îÅÔ ÕËÁÚÁÎÎÏÊ %s ÏÐÃÉÉ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+307 "îÅÔ ex ËÏÍÁÎÄÙ ÄÌÑ ×ÙÐÏÌÎÅÎÉÑ"
+308 "÷×ÅÄÉÔÅ <CR> ÄÌÑ ×ÙÐÏÌÎÅÎÉÑ ËÏÍÁÎÄÙ, :q ÞÔÏÂÙ ×ÙÊÔÉ"
+309 "éÓÐÏÌØÚÕÊÔÅ \"cscope help\" ÄÌÑ ÐÏÍÏÝÉ"
+310 "îÅÔ ÚÁÐÕÝÅÎÎÏÇÏ cscope ÓÏÅÄÉÎÅÎÉÑ"
+311 "%s: ÎÅÉÚ×ÅÓÔÎÙÊ ÔÉÐ ÐÏÉÓËÁ: ÉÓÐÏÌØÚÕÊÔÅ ÏÄÉÎ ÉÚ %s"
+312 "%d: ÎÅÔ ÔÁËÏÇÏ cscope ÓÅÁÎÓÁ"
+313 "set: %s ÏÐÃÉÑ ÎÉËÏÇÄÁ ÎÅ ÍÏÖÅÔ ÂÙÔØ ×ËÌÀÞÅÎÁ"
+314 "set: %s ÏÐÃÉÑ ÎÉËÏÇÄÁ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÕÓÔÁÎÏ×ÌÅÎÁ × 0"
+315 "%s: ÄÏÂÁ×ÌÅÎÏ: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×"
+316 "îÅÏÖÉÄÁÎÎÏÅ ÓÏÂÙÔÉÅ ÉÚÍÅÎÅÎÉÑ ÒÁÚÍÅÒÁ"
+317 "%d ÆÁÊÌÏ× ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
+319 "%d ÜËÒÁÎÏ× × ÆÏÎÏ×ÏÍ ÒÅÖÉÍÅ; ÉÓÐÏÌØÚÕÊÔÅ :display ÞÔÏÂÙ ÐÅÒÅÞÉÓÌÉÔØ ÉÈ"
+320 "îÅÉÚ×ÅÓÔÎÁÑ ÐÏÚÉÃÉÑ ËÕÒÓÏÒÁ"
+321 "ðÒÅÏÂÒÁÚÏ×ÁÎÉÅ ËÏÄÉÒÏ×ËÉ ÆÁÊÌÏ× ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ"
+322 "ðÒÅÏÂÒÁÚÏ×ÁÎÉÅ ËÏÄÉÒÏ×ËÉ ××ÏÄÁ ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ"
+323 "îÅ×ÅÒÎÙÊ ××ÏÄ. õÓÅÞÅÎÏ."
+324 "ïÛÉÂËÁ ÐÒÅÏÂÒÁÚÏ×ÁÎÉÑ × ÓÔÒÏËÅ %d"
diff --git a/catalog/ru_RU.KOI8-R.check b/catalog/ru_RU.KOI8-R.check
deleted file mode 100644
index ca77b891051a..000000000000
--- a/catalog/ru_RU.KOI8-R.check
+++ /dev/null
@@ -1,169 +0,0 @@
-Unused message id's (this is okay):
-001
-008
-021
-022
-023
-024
-025
-026
-027
-028
-029
-036
-037
-057
-061
-078
-081
-090
-091
-093
-110
-145
-147
-161
-164
-167
-169
-191
-207
-209
-212
-213
-215
-216
-217
-218
-219
-222
-229
-230
-231
-232
-234
-235
-236
-253
-255
-266
-=========================
-MISSING ERROR MESSAGES (Please add!):
-008
-021
-022
-023
-024
-025
-026
-027
-028
-029
-036
-037
-057
-061
-078
-090
-091
-093
-110
-145
-147
-161
-164
-167
-169
-191
-207
-209
-212
-215
-216
-217
-218
-219
-222
-230
-231
-232
-234
-235
-236
-253
-255
-266
-268
-269
-270
-271
-272
-273
-274
-275
-276
-277
-278
-279
-280
-281
-282
-283
-284
-285
-286
-287
-289
-290
-291
-292
-293
-294
-295
-296
-297
-298
-299
-300
-301
-302
-303
-304
-305
-306
-307
-308
-309
-310
-311
-312
-313
-314
-315
-316
-317
-=========================
-Extra error messages (just delete them):
-047
-050
-051
-052
-176
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOWX
- 2 %s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODAX
- 2 %s: %lu STROK, %lu SIMWOLOWX
- 2 %s: NE DO KONCA WOSSTANOWLENNYJ FAJLX
- 2 bUFER %s PUSTX
- 2 fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODAX
- 2 set: %s OPCIQ NE QWLQETSQ DWOI^NOJX
- 2 zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDUX
- 3 %s: UDALENX
- 3 nET SIMWOLOW DLQ UDALENIQX
- 4 iSPOLXZOWANIE: %sX
-=========================
diff --git a/catalog/ru_RU.KOI8-R.owner b/catalog/ru_RU.KOI8-R.owner
index bf4fa180298c..20ab08c2d5e2 100644
--- a/catalog/ru_RU.KOI8-R.owner
+++ b/catalog/ru_RU.KOI8-R.owner
@@ -1 +1,3 @@
-Dima Ruban <dima@demos.su>
+Andrey A. Chernov <ache@nagual.ru>
+Dima Ruban <dima@rdy.com>
+Pavel Timofeev <timp87@gmail.com>
diff --git a/catalog/ru_SU.KOI8-R b/catalog/ru_SU.KOI8-R
deleted file mode 100644
index 7eb35b9cf262..000000000000
--- a/catalog/ru_SU.KOI8-R
+++ /dev/null
@@ -1,267 +0,0 @@
-VI_MESSAGE_CATALOG
-pEREPOLNENIE ZNA^ENIQ DLINY STROKIX
-%s/%d: NEWOZMOVNO UDALITX STROKU %uX
-%s/%d: NEWOZMOVNO DOBAWITX K STROKE %uX
-%s/%d: NEWOZMOVNO WSTAWITX W STROKU %uX
-%s/%d: NEWOZMOVNO SOHRANITX STROKU %uX
-%s/%d: NEWOZMOVNO DOSTATX POSLEDN@@ STROKUX
-
-fAJL ZAPISEJX
-zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDUX
-nET IZMENENIJ DLQ OTMENYX
-zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDUX
-zAPISI NE WELISX, NEWOZMOVNO PROSMOTRETX WPEREDX
-nET IZMENENIJ DLQ PEREDELKIX
-%s/%d: O[IBKA PRI ZAPISI PROTOKOLAX
-sTANDARTNYJ WWOD/WYWOD DLQ VI DOLVEN BYTX TERMINALX
-oTMETKA %s: NE USTANOWLENAX
-oTMETKA %s: STROKA BYLA UDALENAX
-oTMETKA %s: POZICII KURSORA BOLX[E NE SU]ESTWUETX
-o[IBKA:X
-
-
-
-
-
-
-
-
-
-fAJL %s NE QWLQETSQ KATALOGOM SOOB]ENIJX
-nEWOZMOVNO USTANOWITX OPCI@ %s PO UMOL^ANI@X
-iSPOLXZOWANIE: %sX
-oPCII %s NET: 'set all' POKAZYWAET WSE WOZMOVNYE OPCIIX
-set: [no]%s NE PRINIMAET TAKOGO ZNA^ENIQX
-set: %s OPCIQ NE QWLQETSQ DWOI^NOJX
-
-
-set: NEPRAWILXNOE ZNA^ENIE %sX
-set: %s OPCIQ NE QWLQETSQ DWOI^NOJX
-kOLI^ESTWO KOLONOK \KRANA SLI[KOM MALO, MENX[E ^EM %dX
-kOLI^ESTWO KOLONOK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %dX
-kOLI^ESTWO STROK \KRANA SLI[KOM MALO, MENX[E ^EM %dX
-kOLI^ESTWO STROK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %dX
-oPCIQ lisp OTSUTSTWUETX
-sOOB]ENIQ NE WYKL@^ENY: %sX
-sOOB]ENIQ NE WKL@^ENY: %sX
-oPCIQ modeline(s) NE MOVET BYTX PEREUSTANOWLENAX
-oPCIQ paragraph DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMIX
-oPCIQ section DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMIX
-oPCIQ shiftwidth NE MOVET BYTX USTANOWLENA NA 0X
-oPCIQ sourceany NE MOVET BYTX USTANOWLENAX
-tABULQCIQ NE MOVET BYTX USTANOWLENA NA 0X
-sTARTOWYJ BUFER PUSTX
-bUFER %s PUSTX
-fAJLY S SIMWOLAMI PEREWODA STROKI W IMENI NE MOGUT BYTX WOSSTANOWLENYX
-iZMENENIQ NE SOHRANENY PRI KRAHE SESSIIX
-
-sOHRANENIE NE UDALOSX: %sX
-iZMENENIQ NE SOHRANQ@TSQ PRI OBRYWE SESSIIX
-sOHRANENIE KOPII FAJLA NE UDALOSX: %sX
-
-iNFORMACII NA POLXZOWATELQ %u NE NAJDENOX
-nEWOZMOVNO ZA]ITITX SPASENNYJ FAJLX
-bUFER WOSSTANOWLENNOGO FAJLA PEREPOLNENX
-wOSSTANOWLENNYJ FAJLX
-%s: NE DO KONCA WOSSTANOWLENNYJ FAJLX
-%s: NE DO KONCA WOSSTANOWLENNYJ FAJLX
-fAJLOW S IMENEM %s, KOTORYE wY MOVETE ^ITATX, NE SU]ESTWUETX
-eSTX STARYE WERSII FAJLA, KOTORYE MOVNO WOSSTANOWITXX
-sU]ESTWU@T DRUGIE FAJLY, KOTORYE MOVNO WOSSTANOWITXX
-E-mail NE POSLAN: %sX
-fAJL PUST - ISKATX NE^EGOX
-dOSTIGNUT KONEC FAJLA BEZ NAHOVDENIQ OBRAZCA POISKAX
-nE ZADAN OBRAZEC POISKAX
-oBRAZEC POISKA NE NAJDENX
-dOSTUPNO NA^ALO FAJLA BEZ NAHOVDENIQ OBRAZCA POISKAX
-pOISK ZACIKLENX
-
-nEPE^ATNYH SIMWOLOW NE NAJDENOX
-nEIZWESTNAQ KOMANDAX
-
-kOMANDA NE DOSTUPNA W REVIME exX
-s^ET^IK NE MOVET BYTX NULEMX
-%s: NEPRAWILXNOE UKAZANIE STROKIX
-wNUTRENNQQ O[IBKA W SINTAKSISE (%s: %s)X
-iSPOLXZOWANIE: %sX
-%s: WREMENNYJ BUFER NE ISPOLXZOWANX
-mETKA POSTAWLENA PERED STROKOJ 1X
-mETKA POSTAWLENA POSLE KONCA FAJLAX
-
-
-kOMANDA ex NE UDALASX: PARAMETRY KOMANDY ZABYTYX
-
-wTOROJ ADRES MENX[E ^EM PERWYJX
-nE UKAZANO NAZWANIE OTMETKIX
-\\ NE ZAWER[AETSQ / ILI ?X
-sSYLKA K STROKE S NOMEROM MENX[E 0X
-kOMANDA %s NEIZWESTNAX
-pEREPOLNENIE ZNA^ENIQ ADRESAX
-nEDOBOR ZNA^ENIQ ADRESAX
-nEDOPUSTIMAQ KOMBINACIQ W ADRESEX
-nEPRAWILXNYJ ADRES: WSEGO %lu STROK W FAJLEX
-nEPRAWILXNYJ ADRES: FAJL PUSTX
-kOMMANDA %s NE MOVET ISPOLXZOWATX ADRES 0X
-aBBREWIATURY OTSUTSTWU@TX
-aBBREWIATURY DOLVNY ZAKAN^IWATXSQ SIMWOLOM "word"X
-aBBREWIATURY NE MOGUT SODERVATX SIMWOLOY TABLQCII ILI PROBELYX
-aBBREWIATURY NE MOGUT SO^ETATXSQ S SIMWOLAMI SLOW/NE-SLOW, ZA ISKL@^ENIEM KONCA STROKIX
-"%s" NE QWLQETSQ ABBREWIATUROJX
-
-fAJLOW DLQ REDAKTIROWANIQ BOLX[E NETX
-oTSUTSTWIE PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQX
-oTSUTSTWIE PREDYDU]EGO FAJLA DLQ PROSMOTRA NAZADX
-nET FAJLOWX
-oTSUTSTWIE PREDYDU]EJ KOMANDY DLQ ZAMENY "!"X
-oTSUTSTWIE ZAMENY DLQ %%X
-oTSUTSTWIE ZAMENY DLQ #X
-o[IBKA: execl: %sX
-o[IBKA WWODA/WYWODA: %sX
-fAJL IZMENEN S MOMENTA POSLEDNEJ POLNOJ ZAPISI: ISPOLXZUJTE ! DLQ OBHODAX
-nEWOZMOVNO NAJTI DOMA[NIJ KATALOGX
-nOWYJ KATALOG: %sX
-nET WYREZANYH BUFEROWX
-kOMANDA %s NE MOVET BYTX ISPOLXZOWANA WNUTRI OB]EJ KOMANDYX
-%s/%s: NE OTKRYT: NE PRINADLEVIT wAM ILI root-UX
-%s/%s: NE OTKRYT: NE PRINADLEVIT wAMX
-%s/%s: NE OTKRYT: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEMX
-%s/%s: NE S^ITAN: NE PRINADLEVIT wAM ILI root-UX
-%s/%s: NE S^ITAN: NE PRINADLEVIT wAMX
-%s/%s: NE S^ITAN: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEMX
-pOSLEDU@]IE STROKI OTSUTSTWU@TX
-oTSUTSTWIE PARAMETROW WWODAX
-oTSUTSTWIE PARAMETROW KOMANDYX
-sIMWOL %s NE MOVET BYTX PEREZAPOMNENX
-"%s" NA DANNYJ MOMENT NE OTME^ENX
-iMQ METKI DOLVNO BYTX ODNIM SIMWOLOMX
-%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODAX
-nOWYJ FAJL .exrc: %sX
-sTROKA PERENOSA NAHODITSQ WNUTRI PARAMETROW PERENOSAX
-kOMANDA open PODRAZUMEWAET USTANOWKU OPCII openX
-kOMANDA open NE REALIZOWANAX
-zA]ITA FAJLA NEWOZMOVNAX
-fAJL ZA]I]ENX
-%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOWX
-
-%s: ZA]ITA NA ^TENIE BYLA NEDOSTUPNAX
-
-%s: %lu STROK, %lu SIMWOLOWX
-nET TENEWYH OKONX
-kOMANDA script ISPOLXZUETSQ TOLXKO W REVIME viX
-nET KOMANDY DLQ ISPOLNENIQX
-oPCIQ shiftwidth USTANOWLENA NA 0X
-pEREPOLNENIE S^ET^IKAX
-cIKL WYPOLNEN NE DO KONCAX
-uKAZANO REGULQRNOE WYRAVENIE: FLAG r NE NUVENX
-fLAGI #, l I p NE MOGUT BYTX OB_EDINENY S FLAGOM c W REVIME viX
-sOWPADENIJ NETX
-mETKA OTSUTSTWUETX
-w STEKE METOK ZAPISEJ MENX[E, ^EM %s, ISPOLXZUJTE :display t[ags]X
-fAJLA S IMENEM %s W STEKE METOK NET; ISPOLXZUJTE :display t[ags]X
-
-%s: METKA NE NAJDENAX
-%s: PLOHAQ METKA W %sX
-
-sTEK METOK PUSTX
-%s: ISKOMAQ PEREMENNAQ NE NAJDENAX
-
-bUFER %s PUSTX
-
-pRERWANOX
-oTSUTSTWIE BUFERA DLQ ISPOLXZOWANIQX
-nET PREDIDU]EGO REGULQRNOGO WYRAVENIQX
-kOMANDA %s PODRAZUMEWAET NALI^IE PRO^TENNOGO FAJLAX
-iSPOLXZOWANIE: %sX
-kOMANDA visual PODRAZUMEWAET OBQZATELXNU@ USTANOWKU OPCII openX
-%s RAS[IRILSQ DO SLI[KOM BOLX[OGO KOLI^ESTWA FAJLOWX
-pUSTOJ FAJLX
-nET PREDYDU]EGO POISKA F, f, T, ILI tX
-%s NE NAJDENOX
-nET PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQX
-kURSOR STOIT NE NA CIFREX
-pOLU^ENNOE ^ISLO SLI[KOM WELIKOX
-pOLU^ENNOE ^ISLO SLI[KOM MALOX
-pODHODQ]EGO SIMWOLA NET NA \TOJ STROKEX
-pODHODQ]IJ SIMWOL NE NAJDENX
-nET SIMWOLOW DLQ UDALENIQX
-dRUGOGO \KRANA NE SU]ESTWUETX
-sIMWOLY POSLE STROKI DLQ POISKA I/ILI PEREBOR STROKIX
-pRO[LYJ OBRAZEC POISKA OTSUTSTWUETX
-pOISK ZAWER[ILSQ NA NA^ALXNOJ POZICIIX
-
-sIMWOL NEPRAWILEN; ZAKL@^EN W KAWY^KI DLQ WWODAX
-uVE NA NA^ALE WSTAWKIX
-nET SIMWOLOW DLQ UDALENIQX
-pEREDWIVENIE ZA KONEC FAJLAX
-pEREDWIVENIE ZA KONEC STROKIX
-dWIVENIE STROKI NE SDELANOX
-uVE NA NA^ALE FAJLAX
-dWIVENIE KURSORA ZA NA^ALO FAJLAX
-uVE W PERWOJ KOLONKEX
-bUFERY DOLVNY BYTX UKAZANY DO WYPOLNENIQ KOMANDYX
-uVE NA KONCE FAJLAX
-uVE NA KONSE STROKIX
-%s NE QWLQETSQ KOMANDOJ VIX
-iSPOLXZOWANIE: %sX
-nET SIMWOLOW DLQ UDALENIQX
-
-nET KOMANDY DLQ POWTORAX
-
-kOMANDA %s NE MOVET BYTX ISPOLXZOWANA KAK KOMANDA PRODWIVENIQX
-~ISLO BOLX[E ^EM %luX
-
-
-zNA^ENIE KOLI^ESTWA OKON SLI[KOM WELIKO, MAKSIMALXNOE ZNA^ENIE = %uX
-
-
-
-
-
-dWIVENIE KURSORA ZA KONEC \KRANAX
-dWIVENIE KURSORA ZA NA^ALO \KRANAX
-
-tENEWYH OKON NETX
-nE SU]ESTWUET TENEWOGO OKNA S REDAKTIROWANIEM FAJLA %sX
-wY NE MOVETE SDELATX EDINSTWENNOE OKNO TENEWYMX
-|KRAN MOVET BYTX SVATX
-|KRAN NE MOVET BYTX SVATX
-|KRAN NE MOVET BYTX RAS[IRENX
-
-
-
-
-dANNYJ TIP TERMINALA NE IMEET KLAWI[I %sX
-
-
-
-nEWOZMOVNO SOZDATX WREMENNYJ FAJLX
-wNIMANIE: %s SPECIALXNYJ FAJLX
-%s UVE ZABLOKIROWAN, DOSTUPEN TOLXKO NA ^TENIEX
-%s: UDALENX
-%s: ZAKRYTX
-%s: UDALENX
-%s: UDALENX
-fAJL TOLXKO DLQ ^TENIQ, NE ZAPISAN: iSPOLXZUJTE ! DLQ OBHODAX
-fAJL TOLXKO DLQ ^TENIQ, NE ZAPISANX
-%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODAX
-%s SU]ESTWUET, NE ZAPISANX
-iSPOLXZUJTE ! DLQ ^ASTI^NOJ ZAPISI FAJLAX
-~ASTX FAJLA, FAJL NE ZAPISANX
-%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQ: ISPOLXZUJTE ! DLQ OBHODAX
-%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQX
-%s: ZA]ITA NA ZAPISX BYLA NEDOSTUPNAX
-
-%s: wnimanie: fajl use~enX
-
-%s: NOWYJ FAJL: %lu STROK, %lu SIMWOLOWX
-%s: %lu STROK, %lu SIMWOLOWX
-%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOWX
-%s SPECIALXNYJ FAJLX
-%s: NE PRINADLEVIT wAMX
-%s: DOSTUPEN NE TOLXKO wAMX
-fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODAX
-fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE :edit DLQ OBHODAX
-fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODAX
-fAJL WREMENNYJ: WYHOD SOTRET L@BYE IZMENENIQX
-
-zAPISI NA^ATY ZANOWOX
diff --git a/catalog/ru_SU.KOI8-R.base b/catalog/ru_SU.KOI8-R.base
deleted file mode 100644
index 59efd3f53a5f..000000000000
--- a/catalog/ru_SU.KOI8-R.base
+++ /dev/null
@@ -1,219 +0,0 @@
-002 "pEREPOLNENIE ZNA^ENIQ DLINY STROKI"
-003 "%s/%d: NEWOZMOVNO UDALITX STROKU %u"
-004 "%s/%d: NEWOZMOVNO DOBAWITX K STROKE %u"
-005 "%s/%d: NEWOZMOVNO WSTAWITX W STROKU %u"
-006 "%s/%d: NEWOZMOVNO SOHRANITX STROKU %u"
-007 "%s/%d: NEWOZMOVNO DOSTATX POSLEDN@@ STROKU"
-009 "fAJL ZAPISEJ"
-010 "zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDU"
-011 "nET IZMENENIJ DLQ OTMENY"
-012 "zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDU"
-013 "zAPISI NE WELISX, NEWOZMOVNO PROSMOTRETX WPERED"
-014 "nET IZMENENIJ DLQ PEREDELKI"
-015 "%s/%d: O[IBKA PRI ZAPISI PROTOKOLA"
-016 "sTANDARTNYJ WWOD/WYWOD DLQ VI DOLVEN BYTX TERMINAL"
-017 "oTMETKA %s: NE USTANOWLENA"
-018 "oTMETKA %s: STROKA BYLA UDALENA"
-019 "oTMETKA %s: POZICII KURSORA BOLX[E NE SU]ESTWUET"
-020 "o[IBKA:"
-030 "fAJL %s NE QWLQETSQ KATALOGOM SOOB]ENIJ"
-031 "nEWOZMOVNO USTANOWITX OPCI@ %s PO UMOL^ANI@"
-032 "iSPOLXZOWANIE: %s"
-033 "oPCII %s NET: 'set all' POKAZYWAET WSE WOZMOVNYE OPCII"
-034 "set: [no]%s NE PRINIMAET TAKOGO ZNA^ENIQ"
-035 "set: %s OPCIQ NE QWLQETSQ DWOI^NOJ"
-038 "set: NEPRAWILXNOE ZNA^ENIE %s"
-039 "set: %s OPCIQ NE QWLQETSQ DWOI^NOJ"
-040 "kOLI^ESTWO KOLONOK \KRANA SLI[KOM MALO, MENX[E ^EM %d"
-041 "kOLI^ESTWO KOLONOK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %d"
-042 "kOLI^ESTWO STROK \KRANA SLI[KOM MALO, MENX[E ^EM %d"
-043 "kOLI^ESTWO STROK \KRANA SLI[KOM WELIKO, BOLX[E ^EM %d"
-044 "oPCIQ lisp OTSUTSTWUET"
-045 "sOOB]ENIQ NE WYKL@^ENY: %s"
-046 "sOOB]ENIQ NE WKL@^ENY: %s"
-047 "oPCIQ modeline(s) NE MOVET BYTX PEREUSTANOWLENA"
-048 "oPCIQ paragraph DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMI"
-049 "oPCIQ section DOLVNA SOSTOQTX IZ GRUPP S DWUMQ SIMWOLAMI"
-050 "oPCIQ shiftwidth NE MOVET BYTX USTANOWLENA NA 0"
-051 "oPCIQ sourceany NE MOVET BYTX USTANOWLENA"
-052 "tABULQCIQ NE MOVET BYTX USTANOWLENA NA 0"
-053 "sTARTOWYJ BUFER PUST"
-054 "bUFER %s PUST"
-055 "fAJLY S SIMWOLAMI PEREWODA STROKI W IMENI NE MOGUT BYTX WOSSTANOWLENY"
-056 "iZMENENIQ NE SOHRANENY PRI KRAHE SESSII"
-058 "sOHRANENIE NE UDALOSX: %s"
-059 "iZMENENIQ NE SOHRANQ@TSQ PRI OBRYWE SESSII"
-060 "sOHRANENIE KOPII FAJLA NE UDALOSX: %s"
-062 "iNFORMACII NA POLXZOWATELQ %u NE NAJDENO"
-063 "nEWOZMOVNO ZA]ITITX SPASENNYJ FAJL"
-064 "bUFER WOSSTANOWLENNOGO FAJLA PEREPOLNEN"
-065 "wOSSTANOWLENNYJ FAJL"
-066 "%s: NE DO KONCA WOSSTANOWLENNYJ FAJL"
-067 "%s: NE DO KONCA WOSSTANOWLENNYJ FAJL"
-068 "fAJLOW S IMENEM %s, KOTORYE wY MOVETE ^ITATX, NE SU]ESTWUET"
-069 "eSTX STARYE WERSII FAJLA, KOTORYE MOVNO WOSSTANOWITX"
-070 "sU]ESTWU@T DRUGIE FAJLY, KOTORYE MOVNO WOSSTANOWITX"
-071 "E-mail NE POSLAN: %s"
-072 "fAJL PUST - ISKATX NE^EGO"
-073 "dOSTIGNUT KONEC FAJLA BEZ NAHOVDENIQ OBRAZCA POISKA"
-074 "nE ZADAN OBRAZEC POISKA"
-075 "oBRAZEC POISKA NE NAJDEN"
-076 "dOSTUPNO NA^ALO FAJLA BEZ NAHOVDENIQ OBRAZCA POISKA"
-077 "pOISK ZACIKLEN"
-079 "nEPE^ATNYH SIMWOLOW NE NAJDENO"
-080 "nEIZWESTNAQ KOMANDA"
-082 "kOMANDA NE DOSTUPNA W REVIME ex"
-083 "s^ET^IK NE MOVET BYTX NULEM"
-084 "%s: NEPRAWILXNOE UKAZANIE STROKI"
-085 "wNUTRENNQQ O[IBKA W SINTAKSISE (%s: %s)"
-086 "iSPOLXZOWANIE: %s"
-087 "%s: WREMENNYJ BUFER NE ISPOLXZOWAN"
-088 "mETKA POSTAWLENA PERED STROKOJ 1"
-089 "mETKA POSTAWLENA POSLE KONCA FAJLA"
-092 "kOMANDA ex NE UDALASX: PARAMETRY KOMANDY ZABYTY"
-094 "wTOROJ ADRES MENX[E ^EM PERWYJ"
-095 "nE UKAZANO NAZWANIE OTMETKI"
-096 "\\ NE ZAWER[AETSQ / ILI ?"
-097 "sSYLKA K STROKE S NOMEROM MENX[E 0"
-098 "kOMANDA %s NEIZWESTNA"
-099 "pEREPOLNENIE ZNA^ENIQ ADRESA"
-100 "nEDOBOR ZNA^ENIQ ADRESA"
-101 "nEDOPUSTIMAQ KOMBINACIQ W ADRESE"
-102 "nEPRAWILXNYJ ADRES: WSEGO %lu STROK W FAJLE"
-103 "nEPRAWILXNYJ ADRES: FAJL PUST"
-104 "kOMMANDA %s NE MOVET ISPOLXZOWATX ADRES 0"
-105 "aBBREWIATURY OTSUTSTWU@T"
-106 "aBBREWIATURY DOLVNY ZAKAN^IWATXSQ SIMWOLOM "word""
-107 "aBBREWIATURY NE MOGUT SODERVATX SIMWOLOY TABLQCII ILI PROBELY"
-108 "aBBREWIATURY NE MOGUT SO^ETATXSQ S SIMWOLAMI SLOW/NE-SLOW, ZA ISKL@^ENIEM KONCA STROKI"
-109 ""%s" NE QWLQETSQ ABBREWIATUROJ"
-111 "fAJLOW DLQ REDAKTIROWANIQ BOLX[E NET"
-112 "oTSUTSTWIE PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQ"
-113 "oTSUTSTWIE PREDYDU]EGO FAJLA DLQ PROSMOTRA NAZAD"
-114 "nET FAJLOW"
-115 "oTSUTSTWIE PREDYDU]EJ KOMANDY DLQ ZAMENY "!""
-116 "oTSUTSTWIE ZAMENY DLQ %%"
-117 "oTSUTSTWIE ZAMENY DLQ #"
-118 "o[IBKA: execl: %s"
-119 "o[IBKA WWODA/WYWODA: %s"
-120 "fAJL IZMENEN S MOMENTA POSLEDNEJ POLNOJ ZAPISI: ISPOLXZUJTE ! DLQ OBHODA"
-121 "nEWOZMOVNO NAJTI DOMA[NIJ KATALOG"
-122 "nOWYJ KATALOG: %s"
-123 "nET WYREZANYH BUFEROW"
-124 "kOMANDA %s NE MOVET BYTX ISPOLXZOWANA WNUTRI OB]EJ KOMANDY"
-125 "%s/%s: NE OTKRYT: NE PRINADLEVIT wAM ILI root-U"
-126 "%s/%s: NE OTKRYT: NE PRINADLEVIT wAM"
-127 "%s/%s: NE OTKRYT: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEM"
-128 "%s/%s: NE S^ITAN: NE PRINADLEVIT wAM ILI root-U"
-129 "%s/%s: NE S^ITAN: NE PRINADLEVIT wAM"
-130 "%s/%s: NE S^ITAN: WOZMOVNOSTX ZAPISI U POLXZOWATELQ, NE QWLQ@]EGOSQ WLADELXCEM"
-131 "pOSLEDU@]IE STROKI OTSUTSTWU@T"
-132 "oTSUTSTWIE PARAMETROW WWODA"
-133 "oTSUTSTWIE PARAMETROW KOMANDY"
-134 "sIMWOL %s NE MOVET BYTX PEREZAPOMNEN"
-135 ""%s" NA DANNYJ MOMENT NE OTME^EN"
-136 "iMQ METKI DOLVNO BYTX ODNIM SIMWOLOM"
-137 "%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODA"
-138 "nOWYJ FAJL .exrc: %s"
-139 "sTROKA PERENOSA NAHODITSQ WNUTRI PARAMETROW PERENOSA"
-140 "kOMANDA open PODRAZUMEWAET USTANOWKU OPCII open"
-141 "kOMANDA open NE REALIZOWANA"
-142 "zA]ITA FAJLA NEWOZMOVNA"
-143 "fAJL ZA]I]EN"
-144 "%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOW"
-146 "%s: ZA]ITA NA ^TENIE BYLA NEDOSTUPNA"
-148 "%s: %lu STROK, %lu SIMWOLOW"
-149 "nET TENEWYH OKON"
-150 "kOMANDA script ISPOLXZUETSQ TOLXKO W REVIME vi"
-151 "nET KOMANDY DLQ ISPOLNENIQ"
-152 "oPCIQ shiftwidth USTANOWLENA NA 0"
-153 "pEREPOLNENIE S^ET^IKA"
-154 "cIKL WYPOLNEN NE DO KONCA"
-155 "uKAZANO REGULQRNOE WYRAVENIE: FLAG r NE NUVEN"
-156 "fLAGI #, l I p NE MOGUT BYTX OB_EDINENY S FLAGOM c W REVIME vi"
-157 "sOWPADENIJ NET"
-158 "mETKA OTSUTSTWUET"
-159 "w STEKE METOK ZAPISEJ MENX[E, ^EM %s, ISPOLXZUJTE :display t[ags]"
-160 "fAJLA S IMENEM %s W STEKE METOK NET; ISPOLXZUJTE :display t[ags]"
-162 "%s: METKA NE NAJDENA"
-163 "%s: PLOHAQ METKA W %s"
-165 "sTEK METOK PUST"
-166 "%s: ISKOMAQ PEREMENNAQ NE NAJDENA"
-168 "bUFER %s PUST"
-170 "pRERWANO"
-171 "oTSUTSTWIE BUFERA DLQ ISPOLXZOWANIQ"
-172 "nET PREDIDU]EGO REGULQRNOGO WYRAVENIQ"
-173 "kOMANDA %s PODRAZUMEWAET NALI^IE PRO^TENNOGO FAJLA"
-174 "iSPOLXZOWANIE: %s"
-175 "kOMANDA visual PODRAZUMEWAET OBQZATELXNU@ USTANOWKU OPCII open"
-176 "%s RAS[IRILSQ DO SLI[KOM BOLX[OGO KOLI^ESTWA FAJLOW"
-177 "pUSTOJ FAJL"
-178 "nET PREDYDU]EGO POISKA F, f, T, ILI t"
-179 "%s NE NAJDENO"
-180 "nET PREDYDU]EGO FAJLA DLQ REDAKTIROWANIQ"
-181 "kURSOR STOIT NE NA CIFRE"
-182 "pOLU^ENNOE ^ISLO SLI[KOM WELIKO"
-183 "pOLU^ENNOE ^ISLO SLI[KOM MALO"
-184 "pODHODQ]EGO SIMWOLA NET NA \TOJ STROKE"
-185 "pODHODQ]IJ SIMWOL NE NAJDEN"
-186 "nET SIMWOLOW DLQ UDALENIQ"
-187 "dRUGOGO \KRANA NE SU]ESTWUET"
-188 "sIMWOLY POSLE STROKI DLQ POISKA I/ILI PEREBOR STROKI"
-189 "pRO[LYJ OBRAZEC POISKA OTSUTSTWUET"
-190 "pOISK ZAWER[ILSQ NA NA^ALXNOJ POZICII"
-192 "sIMWOL NEPRAWILEN; ZAKL@^EN W KAWY^KI DLQ WWODA"
-193 "uVE NA NA^ALE WSTAWKI"
-194 "nET SIMWOLOW DLQ UDALENIQ"
-195 "pEREDWIVENIE ZA KONEC FAJLA"
-196 "pEREDWIVENIE ZA KONEC STROKI"
-197 "dWIVENIE STROKI NE SDELANO"
-198 "uVE NA NA^ALE FAJLA"
-199 "dWIVENIE KURSORA ZA NA^ALO FAJLA"
-200 "uVE W PERWOJ KOLONKE"
-201 "bUFERY DOLVNY BYTX UKAZANY DO WYPOLNENIQ KOMANDY"
-202 "uVE NA KONCE FAJLA"
-203 "uVE NA KONSE STROKI"
-204 "%s NE QWLQETSQ KOMANDOJ VI"
-205 "iSPOLXZOWANIE: %s"
-206 "nET SIMWOLOW DLQ UDALENIQ"
-208 "nET KOMANDY DLQ POWTORA"
-210 "kOMANDA %s NE MOVET BYTX ISPOLXZOWANA KAK KOMANDA PRODWIVENIQ"
-211 "~ISLO BOLX[E ^EM %lu"
-214 "zNA^ENIE KOLI^ESTWA OKON SLI[KOM WELIKO, MAKSIMALXNOE ZNA^ENIE = %u"
-220 "dWIVENIE KURSORA ZA KONEC \KRANA"
-221 "dWIVENIE KURSORA ZA NA^ALO \KRANA"
-223 "tENEWYH OKON NET"
-224 "nE SU]ESTWUET TENEWOGO OKNA S REDAKTIROWANIEM FAJLA %s"
-225 "wY NE MOVETE SDELATX EDINSTWENNOE OKNO TENEWYM"
-226 "|KRAN MOVET BYTX SVAT"
-227 "|KRAN NE MOVET BYTX SVAT"
-228 "|KRAN NE MOVET BYTX RAS[IREN"
-233 "dANNYJ TIP TERMINALA NE IMEET KLAWI[I %s"
-237 "nEWOZMOVNO SOZDATX WREMENNYJ FAJL"
-238 "wNIMANIE: %s SPECIALXNYJ FAJL"
-239 "%s UVE ZABLOKIROWAN, DOSTUPEN TOLXKO NA ^TENIE"
-240 "%s: UDALEN"
-241 "%s: ZAKRYT"
-242 "%s: UDALEN"
-243 "%s: UDALEN"
-244 "fAJL TOLXKO DLQ ^TENIQ, NE ZAPISAN: iSPOLXZUJTE ! DLQ OBHODA"
-245 "fAJL TOLXKO DLQ ^TENIQ, NE ZAPISAN"
-246 "%s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODA"
-247 "%s SU]ESTWUET, NE ZAPISAN"
-248 "iSPOLXZUJTE ! DLQ ^ASTI^NOJ ZAPISI FAJLA"
-249 "~ASTX FAJLA, FAJL NE ZAPISAN"
-250 "%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQ: ISPOLXZUJTE ! DLQ OBHODA"
-251 "%s: fAJL IZMENQLSQ POZDNEE, ^EM DANNAQ KOPIQ"
-252 "%s: ZA]ITA NA ZAPISX BYLA NEDOSTUPNA"
-254 "%s: wnimanie: fajl use~en"
-256 "%s: NOWYJ FAJL: %lu STROK, %lu SIMWOLOW"
-257 "%s: %lu STROK, %lu SIMWOLOW"
-258 "%s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOW"
-259 "%s SPECIALXNYJ FAJL"
-260 "%s: NE PRINADLEVIT wAM"
-261 "%s: DOSTUPEN NE TOLXKO wAM"
-262 "fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODA"
-263 "fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE :edit DLQ OBHODA"
-264 "fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODA"
-265 "fAJL WREMENNYJ: WYHOD SOTRET L@BYE IZMENENIQ"
-267 "zAPISI NA^ATY ZANOWO"
diff --git a/catalog/ru_SU.KOI8-R.check b/catalog/ru_SU.KOI8-R.check
deleted file mode 100644
index ca77b891051a..000000000000
--- a/catalog/ru_SU.KOI8-R.check
+++ /dev/null
@@ -1,169 +0,0 @@
-Unused message id's (this is okay):
-001
-008
-021
-022
-023
-024
-025
-026
-027
-028
-029
-036
-037
-057
-061
-078
-081
-090
-091
-093
-110
-145
-147
-161
-164
-167
-169
-191
-207
-209
-212
-213
-215
-216
-217
-218
-219
-222
-229
-230
-231
-232
-234
-235
-236
-253
-255
-266
-=========================
-MISSING ERROR MESSAGES (Please add!):
-008
-021
-022
-023
-024
-025
-026
-027
-028
-029
-036
-037
-057
-061
-078
-090
-091
-093
-110
-145
-147
-161
-164
-167
-169
-191
-207
-209
-212
-215
-216
-217
-218
-219
-222
-230
-231
-232
-234
-235
-236
-253
-255
-266
-268
-269
-270
-271
-272
-273
-274
-275
-276
-277
-278
-279
-280
-281
-282
-283
-284
-285
-286
-287
-289
-290
-291
-292
-293
-294
-295
-296
-297
-298
-299
-300
-301
-302
-303
-304
-305
-306
-307
-308
-309
-310
-311
-312
-313
-314
-315
-316
-317
-=========================
-Extra error messages (just delete them):
-047
-050
-051
-052
-176
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s RAS[IRILSQ W SLI[KOM BOLX[OE KOLI^ESTWO IMEN FAJLOWX
- 2 %s SU]ESTWUET, NE ZAPISAN; ISPOLXZUJTE ! DLQ OBHODAX
- 2 %s: %lu STROK, %lu SIMWOLOWX
- 2 %s: NE DO KONCA WOSSTANOWLENNYJ FAJLX
- 2 bUFER %s PUSTX
- 2 fAJL IZMENEN SO WREMENI POSLEDNEJ ZAPISI: SOHRANITE ILI ISPOLXZUJTE ! DLQ OBHODAX
- 2 set: %s OPCIQ NE QWLQETSQ DWOI^NOJX
- 2 zAPISI NE WELISX, NEWOZMOVNO OTMENITX POSLEDN@@ KOMANDUX
- 3 %s: UDALENX
- 3 nET SIMWOLOW DLQ UDALENIQX
- 4 iSPOLXZOWANIE: %sX
-=========================
diff --git a/catalog/ru_SU.KOI8-R.owner b/catalog/ru_SU.KOI8-R.owner
deleted file mode 100644
index bf4fa180298c..000000000000
--- a/catalog/ru_SU.KOI8-R.owner
+++ /dev/null
@@ -1 +0,0 @@
-Dima Ruban <dima@demos.su>
diff --git a/catalog/spanish b/catalog/spanish
deleted file mode 100644
index fb67ee9dc422..000000000000
--- a/catalog/spanish
+++ /dev/null
@@ -1,317 +0,0 @@
-VI_MESSAGE_CATALOG
-Desbordamiento de longitud de l¡neaX
-no se puede borrar la l¡nea %luX
-no se puede a¤adir la l¡nea %luX
-no se puede insertar en la l¡nea %luX
-no se puede guardar la l¡nea %luX
-no se puede obtener la £ltima l¡neaX
-Error: no se puede recuperar la l¡nea %luX
-Archivo de logX
-No se realiza log, no se puede deshacerX
-No hay cambios para deshacerX
-No se realiza log, no se puede deshacerX
-No se realiza log, no se puede remontar hacia adelanteX
-No hay cambios para rehacerX
-%s/%d: error de logX
-La entrada y salida est ndar de Vi debe ser una terminalX
-Marcar %s: no determinadoX
-Marcar %s: se borr¢ la l¡neaX
-Marcar %s: la posici¢n del cursor ya no existeX
-Error: X
-nuevo archivoX
-nombre cambiadoX
-modificadoX
-no modificadoX
-DESTRABADOX
-lectura solamenteX
-l¡nea %lu de %lu [%ld%%]X
-archivo vac¡oX
-l¡nea %luX
-El archivo %s no es un cat logo de mensajesX
-No se puede determinar la opci¢n por omisi¢n %sX
-Uso: %sX
-determinar: no hay opci¢n %s: 'determinar todo' establece todos los valores de opci¢nX
-determinar: [no] hay opci¢n %s no tiene valorX
-determinar: opci¢n %s no es booleanoX
-determinar: opci¢n %s: %sX
-determinar: opci¢n %s: %s: desbordamiento de valoresX
-determinar: opci¢n %s: %s es un n£mero ilegalX
-determinar: opci¢n %s no es booleanoX
-Las columnas en pantalla son demasiado peque¤as, menos de %dX
-Las columnas en pantalla son demasiado grandes, m s de %dX
-Las l¡neas en pantalla son demasiado peque¤as, menos de %dX
-Las l¡neas en pantalla son demasiado grandes, m s de %dX
-La opci¢n lisp no est  implementadaX
-mensajes no desconectados: %sX
-mensajes no conectados: %sX
-
-La opci¢n de p rrafo debe estar en dos grupos de caracteresX
-La opci¢n de secci¢n debe estar en dos grupos de caracteresX
-
-
-
-El buffer por omisi¢n est  vac¡oX
-El buffer %s est  vac¡oX
-Los archivos con nuevas l¡neas en el nombre son irrecuperablesX
-Las modificaciones no pueden recuperarse si la sesi¢n fallaX
-Copiando archivo para recuperaci¢n...X
-Preservaci¢n fracasada: %sX
-Las modificaciones no pueden recuperarse si la sesi¢n fallaX
-Archivo de respaldo fracasado: %sX
-Copiando archivo para recuperaci¢n...X
-Informaci¢n sobre identificaci¢n del usuario %u no encontradaX
-No se puede trabar archivo de recuperaci¢nX
-Desbordamiento de buffer de archivo de recuperaci¢nX
-Archivo de recuperaci¢nX
-%s: archivo de recuperaci¢n defectuosoX
-%s: archivo de recuperaci¢n defectuosoX
-No hay archivos denominados %s, que usted pueda leer, para recuperarX
-Existen versiones m s antiguas de este archivo que usted puede recuperarX
-Existen otros archivos que usted puede recuperarX
-no env¡a email: %sX
-Archivo vac¡o; no hay nada para buscarX
-Se alcanz¢ el final del archivo sin encontrar el patr¢nX
-No hay patr¢n anterior de b£squedaX
-No se encontr¢ el patr¢nX
- Se alcanz¢ el principio del archivo sin encontrar el patr¢nX
-B£squeda reiniciadaX
-Buscando...X
-No se encontr¢ ning£n car cter no imprimibleX
-Nombre de comando desconocidoX
-
-%s: comando no disponible en modalidad exX
-La cuenta no puede ser ceroX
-%s: mala especificaci¢n de l¡neaX
-Error interno de tabla de sintaxis (%s: %s)X
-Uso: %sX
-%s: buffer temporario no liberadoX
-Desplazamiento de marcador a antes de la l¡nea 1X
-Desplazamiento de marcador m s all  del final del archivoX
-@ con rango que corre cuando se cambia el archivo/la pantallaX
-Comando global/v que corre cuando se cambia el archivo/la pantallaX
-Comando Ex fracasado: comandos pendientes descartadosX
-Comando Ex fracasado: teclas mapeadas descartadasX
-La segunda direcci¢n es m s peque¤a que la primeraX
-No se suministra nombre de marcaX
-\\ no es seguido por / o ?X
-Referencia a un n£mero de l¡nea menor que 0X
-El comando %s es desconocidoX
-Desbordamiento de valor de direcci¢nX
-Subdesbordamiento de valor de direcci¢nX
-Combinaci¢n de direcci¢n ilegalX
-Direcci¢n ilegal: s¢lo %lu l¡neas en el archivoX
-Direcci¢n ilegal: el archivo est  vac¡oX
-El comando %s no permite una direcci¢n de 0X
-No hay abreviaturas para visualizarX
-Las abreviaturas deben terminar con un car cter de \"palabra\" X
-Las abreviaturas no pueden contener tabs o espaciosX
-Las abreviaturas no pueden mezclar caracteres palabra/no-palabra, salvo al finalX
-\"%s\" no es una abreviaturaX
-Comando Vi fracasado: teclas mapeadas descartadasX
-No hay m s archivos para editarX
-No hay archivos anteriores para editarX
-No hay archivos anteriores para rebobinarX
-No hay lista de archivos para visualizarX
-No hay un comando anterior para reemplazar a \"!\"X
-No hay nombre de archivo para sustituir por %%X
-No hay nombre de archivo para sustituir por #X
-Error: execl: %sX
-Error de E/S: %sX
-Archivo modificado desde la £ltima escritura completa; escribir o usar ! para alterarX
-No se puede encontrar la ubicaci¢n del directorio inicialX
-Nuevo directorio actual: %sX
-No hay buffers sueltos para visualizarX
-El comando %s no puede usarse como parte de un comando global o vX
-%s/%s: sin fuente: no le pertenece a usted o a ra¡zX
-%s/%s: sin fuente: no le pertenece a ustedX
-%s/%s: sin fuente: puede ser escrito por un usuario que no sea el propietarioX
-%s: sin fuente: no le pertenece a usted o a ra¡zX
-%s: sin fuente: no le pertenece a ustedX
-%s: sin fuente: puede ser escrito por un usuario que no sea el propietarioX
-No hay l¡neas siguientes para unirX
-No hay anotaciones de mapa de entradaX
-No hay anotaciones de mapa de comandoX
-El car cter %s no puede remapearseX
-\"%s\" no est  mapeado actualmenteX
-Marca de nombres debe ser un s¢lo car cterX
-%s existe, no est  escrito; usar ! para alterarX
-Nuevo archivo exrc: %sX
-La l¡nea de destino se encuentra dentro del rango de movimientoX
-El comando abierto requiere que se determine la opci¢n abiertaX
-El comando abierto no se ha implementado a£nX
-No es posible preservar este archivoX
-Archivo preservadoX
-%s: expandido a demasiados nombres de archivoX
-S¢lo pueden leerse los archivos regulares y los conductos nombradosX
-%s: traba de lectura no disponibleX
-Leyendo...X
-%s: %lu l¡neas, %lu caracteresX
-No hay pantallas de fondo para mostrarX
-El comando de script s¢lo est  disponible en modalidad viX
-No hay comando para ejecutarX
-opci¢n de ancho de desplazamiento en 0X
-Desbordamiento de cuentaX
-Subdesbordamiento de cuentaX
-Expresi¢n regular especificada; marcador r no tiene significadoX
-Los marcadores #, l y p no pueden combinarse con el marcador c en la modalidad viX
-No se encontr¢ coincidenciaX
-No se ingres¢ un identificador anteriorX
-Se encontraron menos de %s anotaciones en la pila de identificadores; usar :visualizar i[dentificadores]X
-No hay archivo %s en la pila de identificadores al que se pueda volver; usar :visualizar i[dentificadores]"
-Presionar Intro para continuar: X
-%s: no se encontr¢ el identificadorX
-%s: identificador corrompido en %sX
-%s: el n£mero de l¡nea del identificador es posterior al final del archivoX
-La pila de identificadores est  vac¡aX
-%s: patr¢n de b£squeda no encontradoX
-%d archivos m s para editarX
-El buffer %s est  vac¡oX
-¨Confirmar cambio? [n]X
-InterrumpidoX
-No hay buffer anterior para ejecutarX
-No hay expresi¢n regular anteriorX
-El comando %s requiere que se haya le¡do un archivoX
-Uso: %sX
-El comando visual requiere que se determine la opci¢n abiertaX
-
-Archivo vac¡oX
-No hay b£squeda F, f, T o t anteriorX
-%s no se encontr¢X
-No hay archivo anterior para editarX
-El cursor no est  en un n£meroX
-El n£mero resultante es demasiado grandeX
- El n£mero resultante es demasiado peque¤oX
-No hay car cter coincidente en esta l¡neaX
-No se encontr¢ un car cter coincidenteX
-No hay caracteres para reemplazarX
-No hay otra pantalla a la que se pueda pasarX
-Caracteres despu‚s de cadena de b£squeda, desplazamiento de l¡nea y/o comando zX
-No hay patr¢n anterior de b£squedaX
-B£squeda vuelve a la posici¢n inicialX
-Se super¢ el l¡mite de expansi¢n de abreviatura: se descartaron caracteresX
-Car cter ilegal; mencionar para entrarX
-Ya se encuentra al principio de la inserci¢nX
-No hay m s caracteres para borrarX
-Movimiento m s all  del final del archivoX
-Movimiento m s all  del final de la l¡neaX
-No hay movimiento del cursorX
-Ya se encuentra al principio del archivoX
-Movimiento m s all  del principio del archivoX
-Ya se encuentra en la primera columnaX
-Los buffers deben especificarse antes del comandoX
-Ya se encuentra al final del archivoX
-Ya se encuentra al final de la l¡neaX
-%s no es un comando viX
-Uso: %sX
-No hay caracteres para borrarX
-El comando Q requiere la interfase de terminal exX
-No hay comando para repetirX
-El archivo est  vac¡oX
-%s no puede usarse como comando de movimientoX
-Ya se encuentra en modalidad de comandoX
-El cursor no se encuentra en una palabraX
-
-El valor de opci¢n de Windows es demasiado grande, el m x. es %uX
-A¤adirX
-CambiarX
-ComandoX
-InsertarX
-ReemplazarX
-El movimiento va m s all  del final de la pantallaX
-El movimiento va m s all  del principio de la pantallaX
-La pantalla debe tener m s de %d l¡neas para dividirseX
-No hay pantallas de fondoX
-No hay pantalla de fondo editando un archivo denominado %sX
-No se puede poner fondo a la £nica pantalla que se visualizaX
-La pantalla s¢lo puede reducirse a %d hilerasX
-La pantalla no puede reducirseX
-La pantalla no puede aumentarseX
-
-Esta pantalla no puede suspenderseX
-Interrumpido: teclas mapeadas descartadasX
-vi: buffer temporario no liberadoX
-Esta terminal no tiene tecla %sX
-S¢lo un buffer puede especificarseX
-N£mero mayor que %luX
-InterrumpidoX
-No se puede crear archivo temporarioX
-Advertencia: %s no es un archivo regularX
-%s ya se encuentra trabado, la sesi¢n es de lectura solamenteX
-%s: eliminarX
-%s: cerrarX
-%s: eliminarX
-%s: eliminarX
-Archivo de lectura solamente, no escrito; usar ! para alterarX
- Archivo de lectura solamente, no escritoX
-%s existe, no escrito; usar ! para alterarX
-%s existe, no escritoX
-Archivo parcial, no escrito; usar ! para alterarX
-Archivo parcial, no escritoX
-%s: archivo modificado m s recientemente que esta copia; usar ! para alterarX
-%s: archivo modificado m s recientemente que esta copiaX
-%s: la traba de escritura no estaba disponibleX
-Escribiendo...X
-%s: ADVERTENCIA: ARCHIVO TRUNCADOX
-Ya se encuentra en el primer identificador de este grupoX
-%s: nuevo archivo: %lu l¡neas, %lu caracteresX
-%s: %lu l¡neas, %lu caracteresX
-%s expandido a demasiados nombres de archivosX
-%s: no es un archivo regularX
-%s: no le perteneceX
-%s: accesible por un usuario que no sea el propietarioX
-Archivo modificado desde la £ltima escritura completa; escribir o usar ! para alterarX
-Archivo modificado desde la £ltima escritura completa; escribir o usar :editar! para alterarX
-Archivo modificado desde la £ltima escritura completa; escribir o usar ! para alterarX
-El archivo es temporario; al salir se descartar n las modificacionesX
-Archivo de lectura solamente, las modificaciones no se autoescribenX
-Se reinici¢ el logX
-confirmar? [snq]X
-Presionar cualquier tecla para continuar: X
-Presionar cualquier tecla para continuar [: para ingresar m s comandos ex]: X
-Presionar cualquier tecla para continuar [q para salir]: X
-Esta forma de %s requiere la interfase terminal exX
-Ingresando en la modalidad de entrada ex.X
-Comando fracasado, no hay archivo le¡do aun.X
- cont?X
-Evento inesperado de car cterX
-Evento inesperado de final de archivoX
-No hay coincidencias para consultaX
-Evento inesperado de interrupci¢nX
-Evento inesperado de salidaX
-Evento inesperado de repinturaX
-Ya se encuentra en el £ltimo identificador de este grupoX
-El comando %s requiere la interfase terminal exX
-Esta forma de %s no se encuentra soportada cuando se determina la opci¢n de edici¢n seguraX
-Evento inesperado de cadenaX
-Evento inesperado de tiempo excedidoX
-Evento inesperado de escrituraX
-
-Las expansiones de shell no se encuentran soportadas cuando se determina la opci¢n de edici¢n seguraX
-El comando %s no se encuentra soportado cuando se determina la opci¢n de edici¢n seguraX
-determinar: la opci¢n %s puede no estar desconectadaX
-El monitor es demasiado peque¤o.X
-agregadoX
-cambiadoX
-borradoX
-unidoX
-movidoX
-desplazadoX
-arrancadoX
-l¡neaX
-l¡neasX
-Vi no se carg¢ con un int‚rprete TclX
-Archivo modificado desde la £ltima escritura.X
-Expansi¢n de shell fracasadaX
-No hay opci¢n de edici¢n %s especificadaX
-Vi no se carg¢ con un int‚rprete PerlX
-No hay comando ex para ejecutarX
-Ingresar <CR> para ejecutar un comando, :q para salirX
-Usar \"cscope ayuda\" para obtener ayudaX
-No hay conexiones cscope corriendoX
-%s: tipo de b£squeda desconocido: usar uno de %sX
-%d: no existe esta sesi¢n cscopeX
-determinar: la opci¢n %s no puede conectarse nuncaX
-determinar: la opci¢n %s no puede determinarse nunca en 0X
-%s: a¤adido: %lu l¡neas, %lu caracteresX
-Evento inesperado de modificaci¢n de tama¤oX
-%d archivos para editarX
diff --git a/catalog/spanish.base b/catalog/spanish.base
index 270199eee5c8..ee37a6d31b24 100644
--- a/catalog/spanish.base
+++ b/catalog/spanish.base
@@ -1,10 +1,10 @@
-002 "Desbordamiento de longitud de l¡nea"
-003 "no se puede borrar la l¡nea %lu"
-004 "no se puede a¤adir la l¡nea %lu"
-005 "no se puede insertar en la l¡nea %lu"
-006 "no se puede guardar la l¡nea %lu"
-007 "no se puede obtener la £ltima l¡nea"
-008 "Error: no se puede recuperar la l¡nea %lu"
+002 "Desbordamiento de longitud de línea"
+003 "no se puede borrar la línea %lu"
+004 "no se puede añadir la línea %lu"
+005 "no se puede insertar en la línea %lu"
+006 "no se puede guardar la línea %lu"
+007 "no se puede obtener la última línea"
+008 "Error: no se puede recuperar la línea %lu"
009 "Archivo de log"
010 "No se realiza log, no se puede deshacer"
011 "No hay cambios para deshacer"
@@ -12,10 +12,10 @@
013 "No se realiza log, no se puede remontar hacia adelante"
014 "No hay cambios para rehacer"
015 "%s/%d: error de log"
-016 "La entrada y salida est ndar de Vi debe ser una terminal"
+016 "La entrada y salida estándar de Vi debe ser una terminal"
017 "Marcar %s: no determinado"
-018 "Marcar %s: se borr¢ la l¡nea"
-019 "Marcar %s: la posici¢n del cursor ya no existe"
+018 "Marcar %s: se borró la línea"
+019 "Marcar %s: la posición del cursor ya no existe"
020 "Error: "
021 "nuevo archivo"
022 "nombre cambiado"
@@ -23,86 +23,85 @@
024 "no modificado"
025 "DESTRABADO"
026 "lectura solamente"
-027 "l¡nea %lu de %lu [%ld%%]"
-028 "archivo vac¡o"
-029 "l¡nea %lu"
-030 "El archivo %s no es un cat logo de mensajes"
-031 "No se puede determinar la opci¢n por omisi¢n %s"
+027 "línea %lu de %lu [%ld%%]"
+028 "archivo vacío"
+029 "línea %lu"
+030 "El archivo %s no es un catálogo de mensajes"
+031 "No se puede determinar la opción por omisión %s"
032 "Uso: %s"
-033 "determinar: no hay opci¢n %s: 'determinar todo' establece todos los valores de opci¢n"
-034 "determinar: [no] hay opci¢n %s no tiene valor"
-035 "determinar: opci¢n %s no es booleano"
-036 "determinar: opci¢n %s: %s"
-037 "determinar: opci¢n %s: %s: desbordamiento de valores"
-038 "determinar: opci¢n %s: %s es un n£mero ilegal"
-039 "determinar: opci¢n %s no es booleano"
-040 "Las columnas en pantalla son demasiado peque¤as, menos de %d"
-041 "Las columnas en pantalla son demasiado grandes, m s de %d"
-042 "Las l¡neas en pantalla son demasiado peque¤as, menos de %d"
-043 "Las l¡neas en pantalla son demasiado grandes, m s de %d"
-044 "La opci¢n lisp no est  implementada"
+033 "determinar: no hay opción %s: 'determinar todo' establece todos los valores de opción"
+034 "determinar: [no] hay opción %s no tiene valor"
+035 "determinar: opción %s no es booleano"
+036 "determinar: opción %s: %s"
+037 "determinar: opción %s: %s: desbordamiento de valores"
+038 "determinar: opción %s: %s es un número ilegal"
+039 "determinar: opción %s no es booleano"
+040 "Las columnas en pantalla son demasiado pequeñas, menos de %d"
+041 "Las columnas en pantalla son demasiado grandes, más de %d"
+042 "Las líneas en pantalla son demasiado pequeñas, menos de %d"
+043 "Las líneas en pantalla son demasiado grandes, más de %d"
+044 "La opción lisp no está implementada"
045 "mensajes no desconectados: %s"
046 "mensajes no conectados: %s"
-048 "La opci¢n de p rrafo debe estar en dos grupos de caracteres"
-049 "La opci¢n de secci¢n debe estar en dos grupos de caracteres"
-053 "El buffer por omisi¢n est  vac¡o"
-054 "El buffer %s est  vac¡o"
-055 "Los archivos con nuevas l¡neas en el nombre son irrecuperables"
-056 "Las modificaciones no pueden recuperarse si la sesi¢n falla"
-057 "Copiando archivo para recuperaci¢n..."
-058 "Preservaci¢n fracasada: %s"
-059 "Las modificaciones no pueden recuperarse si la sesi¢n falla"
+047 "La opción de %s debe estar en dos grupos de caracteres"
+053 "El buffer por omisión está vacío"
+054 "El buffer %s está vacío"
+055 "Los archivos con nuevas líneas en el nombre son irrecuperables"
+056 "Las modificaciones no pueden recuperarse si la sesión falla"
+057 "Copiando archivo para recuperación..."
+058 "Preservación fracasada: %s"
+059 "Las modificaciones no pueden recuperarse si la sesión falla"
060 "Archivo de respaldo fracasado: %s"
-061 "Copiando archivo para recuperaci¢n..."
-062 "Informaci¢n sobre identificaci¢n del usuario %u no encontrada"
-063 "No se puede trabar archivo de recuperaci¢n"
-064 "Desbordamiento de buffer de archivo de recuperaci¢n"
-065 "Archivo de recuperaci¢n"
-066 "%s: archivo de recuperaci¢n defectuoso"
-067 "%s: archivo de recuperaci¢n defectuoso"
+061 "Copiando archivo para recuperación..."
+062 "Información sobre identificación del usuario %u no encontrada"
+063 "No se puede trabar archivo de recuperación"
+064 "Desbordamiento de buffer de archivo de recuperación"
+065 "Archivo de recuperación"
+066 "%s: archivo de recuperación defectuoso"
+067 "%s: archivo de recuperación defectuoso"
068 "No hay archivos denominados %s, que usted pueda leer, para recuperar"
-069 "Existen versiones m s antiguas de este archivo que usted puede recuperar"
+069 "Existen versiones más antiguas de este archivo que usted puede recuperar"
070 "Existen otros archivos que usted puede recuperar"
-071 "no env¡a email: %s"
-072 "Archivo vac¡o; no hay nada para buscar"
-073 "Se alcanz¢ el final del archivo sin encontrar el patr¢n"
-074 "No hay patr¢n anterior de b£squeda"
-075 "No se encontr¢ el patr¢n"
-076 " Se alcanz¢ el principio del archivo sin encontrar el patr¢n"
-077 "B£squeda reiniciada"
+071 "no envía email: %s"
+072 "Archivo vacío; no hay nada para buscar"
+073 "Se alcanzó el final del archivo sin encontrar el patrón"
+074 "No hay patrón anterior de búsqueda"
+075 "No se encontró el patrón"
+076 " Se alcanzó el principio del archivo sin encontrar el patrón"
+077 "Búsqueda reiniciada"
078 "Buscando..."
-079 "No se encontr¢ ning£n car cter no imprimible"
+079 "No se encontró ningún carácter no imprimible"
080 "Nombre de comando desconocido"
082 "%s: comando no disponible en modalidad ex"
083 "La cuenta no puede ser cero"
-084 "%s: mala especificaci¢n de l¡nea"
+084 "%s: mala especificación de línea"
085 "Error interno de tabla de sintaxis (%s: %s)"
086 "Uso: %s"
087 "%s: buffer temporario no liberado"
-088 "Desplazamiento de marcador a antes de la l¡nea 1"
-089 "Desplazamiento de marcador m s all  del final del archivo"
+088 "Desplazamiento de marcador a antes de la línea 1"
+089 "Desplazamiento de marcador más allá del final del archivo"
090 "@ con rango que corre cuando se cambia el archivo/la pantalla"
091 "Comando global/v que corre cuando se cambia el archivo/la pantalla"
092 "Comando Ex fracasado: comandos pendientes descartados"
093 "Comando Ex fracasado: teclas mapeadas descartadas"
-094 "La segunda direcci¢n es m s peque¤a que la primera"
+094 "La segunda dirección es más pequeña que la primera"
095 "No se suministra nombre de marca"
096 "\\ no es seguido por / o ?"
-097 "Referencia a un n£mero de l¡nea menor que 0"
+097 "Referencia a un número de línea menor que 0"
098 "El comando %s es desconocido"
-099 "Desbordamiento de valor de direcci¢n"
-100 "Subdesbordamiento de valor de direcci¢n"
-101 "Combinaci¢n de direcci¢n ilegal"
-102 "Direcci¢n ilegal: s¢lo %lu l¡neas en el archivo"
-103 "Direcci¢n ilegal: el archivo est  vac¡o"
-104 "El comando %s no permite una direcci¢n de 0"
+099 "Desbordamiento de valor de dirección"
+100 "Subdesbordamiento de valor de dirección"
+101 "Combinación de dirección ilegal"
+102 "Dirección ilegal: sólo %lu líneas en el archivo"
+103 "Dirección ilegal: el archivo está vacío"
+104 "El comando %s no permite una dirección de 0"
105 "No hay abreviaturas para visualizar"
-106 "Las abreviaturas deben terminar con un car cter de \"palabra\" "
+106 "Las abreviaturas deben terminar con un carácter de \"palabra\" "
107 "Las abreviaturas no pueden contener tabs o espacios"
108 "Las abreviaturas no pueden mezclar caracteres palabra/no-palabra, salvo al final"
109 "\"%s\" no es una abreviatura"
110 "Comando Vi fracasado: teclas mapeadas descartadas"
-111 "No hay m s archivos para editar"
+111 "No hay más archivos para editar"
112 "No hay archivos anteriores para editar"
113 "No hay archivos anteriores para rebobinar"
114 "No hay lista de archivos para visualizar"
@@ -111,124 +110,123 @@
117 "No hay nombre de archivo para sustituir por #"
118 "Error: execl: %s"
119 "Error de E/S: %s"
-120 "Archivo modificado desde la £ltima escritura completa; escribir o usar ! para alterar"
-121 "No se puede encontrar la ubicaci¢n del directorio inicial"
+120 "Archivo modificado desde la última escritura completa; escribir o usar ! para alterar"
+121 "No se puede encontrar la ubicación del directorio inicial"
122 "Nuevo directorio actual: %s"
123 "No hay buffers sueltos para visualizar"
124 "El comando %s no puede usarse como parte de un comando global o v"
-125 "%s/%s: sin fuente: no le pertenece a usted o a ra¡z"
+125 "%s/%s: sin fuente: no le pertenece a usted o a raíz"
126 "%s/%s: sin fuente: no le pertenece a usted"
127 "%s/%s: sin fuente: puede ser escrito por un usuario que no sea el propietario"
-128 "%s: sin fuente: no le pertenece a usted o a ra¡z"
+128 "%s: sin fuente: no le pertenece a usted o a raíz"
129 "%s: sin fuente: no le pertenece a usted"
130 "%s: sin fuente: puede ser escrito por un usuario que no sea el propietario"
-131 "No hay l¡neas siguientes para unir"
+131 "No hay líneas siguientes para unir"
132 "No hay anotaciones de mapa de entrada"
133 "No hay anotaciones de mapa de comando"
-134 "El car cter %s no puede remapearse"
-135 "\"%s\" no est  mapeado actualmente"
-136 "Marca de nombres debe ser un s¢lo car cter"
-137 "%s existe, no est  escrito; usar ! para alterar"
+134 "El carácter %s no puede remapearse"
+135 "\"%s\" no está mapeado actualmente"
+136 "Marca de nombres debe ser un sólo carácter"
+137 "%s existe, no está escrito; usar ! para alterar"
138 "Nuevo archivo exrc: %s"
-139 "La l¡nea de destino se encuentra dentro del rango de movimiento"
-140 "El comando abierto requiere que se determine la opci¢n abierta"
-141 "El comando abierto no se ha implementado a£n"
+139 "La línea de destino se encuentra dentro del rango de movimiento"
+140 "El comando abierto requiere que se determine la opción abierta"
+141 "El comando abierto no se ha implementado aún"
142 "No es posible preservar este archivo"
143 "Archivo preservado"
144 "%s: expandido a demasiados nombres de archivo"
-145 "S¢lo pueden leerse los archivos regulares y los conductos nombrados"
+145 "Sólo pueden leerse los archivos regulares y los conductos nombrados"
146 "%s: traba de lectura no disponible"
147 "Leyendo..."
-148 "%s: %lu l¡neas, %lu caracteres"
+148 "%s: %lu líneas, %lu caracteres"
149 "No hay pantallas de fondo para mostrar"
-150 "El comando de script s¢lo est  disponible en modalidad vi"
+150 "El comando de script sólo está disponible en modalidad vi"
151 "No hay comando para ejecutar"
-152 "opci¢n de ancho de desplazamiento en 0"
+152 "opción de ancho de desplazamiento en 0"
153 "Desbordamiento de cuenta"
154 "Subdesbordamiento de cuenta"
-155 "Expresi¢n regular especificada; marcador r no tiene significado"
+155 "Expresión regular especificada; marcador r no tiene significado"
156 "Los marcadores #, l y p no pueden combinarse con el marcador c en la modalidad vi"
-157 "No se encontr¢ coincidencia"
-158 "No se ingres¢ un identificador anterior"
+157 "No se encontró coincidencia"
+158 "No se ingresó un identificador anterior"
159 "Se encontraron menos de %s anotaciones en la pila de identificadores; usar :visualizar i[dentificadores]"
160 "No hay archivo %s en la pila de identificadores al que se pueda volver; usar :visualizar i[dentificadores]"
161 "Presionar Intro para continuar: "
-162 "%s: no se encontr¢ el identificador"
+162 "%s: no se encontró el identificador"
163 "%s: identificador corrompido en %s"
-164 "%s: el n£mero de l¡nea del identificador es posterior al final del archivo"
-165 "La pila de identificadores est  vac¡a"
-166 "%s: patr¢n de b£squeda no encontrado"
-167 "%d archivos m s para editar"
-168 "El buffer %s est  vac¡o"
-169 "¨Confirmar cambio? [n]"
+164 "%s: el número de línea del identificador es posterior al final del archivo"
+165 "La pila de identificadores está vacía"
+166 "%s: patrón de búsqueda no encontrado"
+167 "%d archivos más para editar"
+168 "El buffer %s está vacío"
+169 "¿Confirmar cambio? [n]"
170 "Interrumpido"
171 "No hay buffer anterior para ejecutar"
-172 "No hay expresi¢n regular anterior"
-173 "El comando %s requiere que se haya le¡do un archivo"
+172 "No hay expresión regular anterior"
+173 "El comando %s requiere que se haya leído un archivo"
174 "Uso: %s"
-175 "El comando visual requiere que se determine la opci¢n abierta"
-177 "Archivo vac¡o"
-178 "No hay b£squeda F, f, T o t anterior"
-179 "%s no se encontr¢"
+175 "El comando visual requiere que se determine la opción abierta"
+177 "Archivo vacío"
+178 "No hay búsqueda F, f, T o t anterior"
+179 "%s no se encontró"
180 "No hay archivo anterior para editar"
-181 "El cursor no est  en un n£mero"
-182 "El n£mero resultante es demasiado grande"
-183 " El n£mero resultante es demasiado peque¤o"
-184 "No hay car cter coincidente en esta l¡nea"
-185 "No se encontr¢ un car cter coincidente"
+181 "El cursor no está en un número"
+182 "El número resultante es demasiado grande"
+183 " El número resultante es demasiado pequeño"
+184 "No hay carácter coincidente en esta línea"
+185 "No se encontró un carácter coincidente"
186 "No hay caracteres para reemplazar"
187 "No hay otra pantalla a la que se pueda pasar"
-188 "Caracteres despu‚s de cadena de b£squeda, desplazamiento de l¡nea y/o comando z"
-189 "No hay patr¢n anterior de b£squeda"
-190 "B£squeda vuelve a la posici¢n inicial"
-191 "Se super¢ el l¡mite de expansi¢n de abreviatura: se descartaron caracteres"
-192 "Car cter ilegal; mencionar para entrar"
-193 "Ya se encuentra al principio de la inserci¢n"
-194 "No hay m s caracteres para borrar"
-195 "Movimiento m s all  del final del archivo"
-196 "Movimiento m s all  del final de la l¡nea"
+188 "Caracteres tras de cadena de búsqueda, desplazamiento de línea y/o comando z"
+189 "No hay patrón anterior de búsqueda"
+190 "Búsqueda vuelve a la posición inicial"
+191 "Se superó el límite de expansión de abreviatura: se descartaron caracteres"
+192 "Carácter ilegal; mencionar para entrar"
+193 "Ya se encuentra al principio de la inserción"
+194 "No hay más caracteres para borrar"
+195 "Movimiento más allá del final del archivo"
+196 "Movimiento más allá del final de la línea"
197 "No hay movimiento del cursor"
198 "Ya se encuentra al principio del archivo"
-199 "Movimiento m s all  del principio del archivo"
+199 "Movimiento más allá del principio del archivo"
200 "Ya se encuentra en la primera columna"
201 "Los buffers deben especificarse antes del comando"
202 "Ya se encuentra al final del archivo"
-203 "Ya se encuentra al final de la l¡nea"
+203 "Ya se encuentra al final de la línea"
204 "%s no es un comando vi"
205 "Uso: %s"
206 "No hay caracteres para borrar"
207 "El comando Q requiere la interfase de terminal ex"
208 "No hay comando para repetir"
-209 "El archivo est  vac¡o"
-209 "El archivo est  vac¡o"
+209 "El archivo está vacío"
210 "%s no puede usarse como comando de movimiento"
211 "Ya se encuentra en modalidad de comando"
212 "El cursor no se encuentra en una palabra"
-214 "El valor de opci¢n de Windows es demasiado grande, el m x. es %u"
-215 "A¤adir"
+214 "El valor de opción de Windows es demasiado grande, el máx. es %u"
+215 "Añadir"
216 "Cambiar"
217 "Comando"
218 "Insertar"
219 "Reemplazar"
-220 "El movimiento va m s all  del final de la pantalla"
-221 "El movimiento va m s all  del principio de la pantalla"
-222 "La pantalla debe tener m s de %d l¡neas para dividirse"
+220 "El movimiento va más allá del final de la pantalla"
+221 "El movimiento va más allá del principio de la pantalla"
+222 "La pantalla debe tener más de %d líneas para dividirse"
223 "No hay pantallas de fondo"
224 "No hay pantalla de fondo editando un archivo denominado %s"
-225 "No se puede poner fondo a la £nica pantalla que se visualiza"
-226 "La pantalla s¢lo puede reducirse a %d hileras"
+225 "No se puede poner fondo a la única pantalla que se visualiza"
+226 "La pantalla sólo puede reducirse a %d hileras"
227 "La pantalla no puede reducirse"
228 "La pantalla no puede aumentarse"
230 "Esta pantalla no puede suspenderse"
231 "Interrumpido: teclas mapeadas descartadas"
232 "vi: buffer temporario no liberado"
233 "Esta terminal no tiene tecla %s"
-234 "S¢lo un buffer puede especificarse"
-235 "N£mero mayor que %lu"
+234 "Sólo un buffer puede especificarse"
+235 "Número mayor que %lu"
236 "Interrumpido"
237 "No se puede crear archivo temporario"
238 "Advertencia: %s no es un archivo regular"
-239 "%s ya se encuentra trabado, la sesi¢n es de lectura solamente"
+239 "%s ya se encuentra trabado, la sesión es de lectura solamente"
240 "%s: eliminar"
241 "%s: cerrar"
242 "%s: eliminar"
@@ -239,48 +237,48 @@
247 "%s existe, no escrito"
248 "Archivo parcial, no escrito; usar ! para alterar"
249 "Archivo parcial, no escrito"
-250 "%s: archivo modificado m s recientemente que esta copia; usar ! para alterar"
-251 "%s: archivo modificado m s recientemente que esta copia"
+250 "%s: archivo modificado más recientemente que esta copia; usar ! para alterar"
+251 "%s: archivo modificado más recientemente que esta copia"
252 "%s: la traba de escritura no estaba disponible"
253 "Escribiendo..."
254 "%s: ADVERTENCIA: ARCHIVO TRUNCADO"
255 "Ya se encuentra en el primer identificador de este grupo"
-256 "%s: nuevo archivo: %lu l¡neas, %lu caracteres"
-257 "%s: %lu l¡neas, %lu caracteres"
+256 "%s: nuevo archivo: %lu líneas, %lu caracteres"
+257 "%s: %lu líneas, %lu caracteres"
258 "%s expandido a demasiados nombres de archivos"
259 "%s: no es un archivo regular"
260 "%s: no le pertenece"
261 "%s: accesible por un usuario que no sea el propietario"
-262 "Archivo modificado desde la £ltima escritura completa; escribir o usar ! para alterar"
-263 "Archivo modificado desde la £ltima escritura completa; escribir o usar :editar! para alterar"
-264 "Archivo modificado desde la £ltima escritura completa; escribir o usar ! para alterar"
-265 "El archivo es temporario; al salir se descartar n las modificaciones"
+262 "Archivo modificado desde la última escritura completa; escribir o usar ! para alterar"
+263 "Archivo modificado desde la última escritura completa; escribir o usar :editar! para alterar"
+264 "Archivo modificado desde la última escritura completa; escribir o usar ! para alterar"
+265 "El archivo es temporario; al salir se descartarán las modificaciones"
266 "Archivo de lectura solamente, las modificaciones no se autoescriben"
-267 "Se reinici¢ el log"
+267 "Se reinició el log"
268 "confirmar? [snq]"
269 "Presionar cualquier tecla para continuar: "
-270 "Presionar cualquier tecla para continuar [: para ingresar m s comandos ex]: "
+270 "Presionar cualquier tecla para continuar [: para ingresar más comandos ex]: "
271 "Presionar cualquier tecla para continuar [q para salir]: "
272 "Esta forma de %s requiere la interfase terminal ex"
273 "Ingresando en la modalidad de entrada ex."
-274 "Comando fracasado, no hay archivo le¡do aun."
+274 "Comando fracasado, no hay archivo leído aun."
275 " cont?"
-276 "Evento inesperado de car cter"
+276 "Evento inesperado de carácter"
277 "Evento inesperado de final de archivo"
278 "No hay coincidencias para consulta"
-279 "Evento inesperado de interrupci¢n"
+279 "Evento inesperado de interrupción"
280 "Evento inesperado de salida"
281 "Evento inesperado de repintura"
-282 "Ya se encuentra en el £ltimo identificador de este grupo"
+282 "Ya se encuentra en el último identificador de este grupo"
283 "El comando %s requiere la interfase terminal ex"
-284 "Esta forma de %s no se encuentra soportada cuando se determina la opci¢n de edici¢n segura"
+284 "Esta forma de %s no se encuentra soportada cuando se determina la opción de edición segura"
285 "Evento inesperado de cadena"
286 "Evento inesperado de tiempo excedido"
287 "Evento inesperado de escritura"
-289 "Las expansiones de shell no se encuentran soportadas cuando se determina la opci¢n de edici¢n segura"
-290 "El comando %s no se encuentra soportado cuando se determina la opci¢n de edici¢n segura"
-291 "determinar: la opci¢n %s puede no estar desconectada"
-292 "El monitor es demasiado peque¤o."
+289 "Las expansiones de shell no se encuentran soportadas cuando se determina la opción de edición segura"
+290 "El comando %s no se encuentra soportado cuando se determina la opción de edición segura"
+291 "determinar: la opción %s puede no estar desconectada"
+292 "El monitor es demasiado pequeño."
293 "agregado"
294 "cambiado"
295 "borrado"
@@ -288,22 +286,21 @@
297 "movido"
298 "desplazado"
299 "arrancado"
-300 "l¡nea"
-301 "l¡neas"
-302 "Vi no se carg¢ con un int‚rprete Tcl"
-303 "Archivo modificado desde la £ltima escritura."
-304 "Expansi¢n de shell fracasada"
-304 "Expansi¢n de shell fracasada"
-305 "No hay opci¢n de edici¢n %s especificada"
-306 "Vi no se carg¢ con un int‚rprete Perl"
+300 "línea"
+301 "líneas"
+302 "Vi no se cargó con un intérprete Tcl"
+303 "Archivo modificado desde la última escritura."
+304 "Expansión de shell fracasada"
+305 "No hay opción de edición %s especificada"
+306 "Vi no se cargó con un intérprete Perl"
307 "No hay comando ex para ejecutar"
308 "Ingresar <CR> para ejecutar un comando, :q para salir"
309 "Usar \"cscope ayuda\" para obtener ayuda"
310 "No hay conexiones cscope corriendo"
-311 "%s: tipo de b£squeda desconocido: usar uno de %s"
-312 "%d: no existe esta sesi¢n cscope"
-313 "determinar: la opci¢n %s no puede conectarse nunca"
-314 "determinar: la opci¢n %s no puede determinarse nunca en 0"
-315 "%s: a¤adido: %lu l¡neas, %lu caracteres"
-316 "Evento inesperado de modificaci¢n de tama¤o"
+311 "%s: tipo de búsqueda desconocido: usar uno de %s"
+312 "%d: no existe esta sesión cscope"
+313 "determinar: la opción %s no puede conectarse nunca"
+314 "determinar: la opción %s no puede determinarse nunca en 0"
+315 "%s: añadido: %lu líneas, %lu caracteres"
+316 "Evento inesperado de modificación de tamaño"
317 "%d archivos para editar"
diff --git a/catalog/spanish.check b/catalog/spanish.check
deleted file mode 100644
index c04785e3a2ef..000000000000
--- a/catalog/spanish.check
+++ /dev/null
@@ -1,35 +0,0 @@
-Unused message id's (this is okay):
-001
-047
-050
-051
-052
-081
-176
-229
-288
-=========================
-MISSING ERROR MESSAGES (Please add!):
-=========================
-Extra error messages (just delete them):
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
- 2 209 "El archivo est  vac¡o"
- 2 304 "Expansi¢n de shell fracasada"
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s: %lu l¡neas, %lu caracteresX
- 2 %s: archivo de recuperaci¢n defectuosoX
- 2 Copiando archivo para recuperaci¢n...X
- 2 El buffer %s est  vac¡oX
- 2 InterrumpidoX
- 2 Las modificaciones no pueden recuperarse si la sesi¢n fallaX
- 2 No hay patr¢n anterior de b£squedaX
- 2 No se realiza log, no se puede deshacerX
- 2 determinar: opci¢n %s no es booleanoX
- 3 %s: eliminarX
- 3 Archivo modificado desde la £ltima escritura completa; escribir o usar ! para alterarX
- 4 Uso: %sX
-=========================
diff --git a/catalog/swedish b/catalog/swedish
deleted file mode 100644
index 044b354fa070..000000000000
--- a/catalog/swedish
+++ /dev/null
@@ -1,317 +0,0 @@
-VI_MESSAGE_CATALOG
-För långa raderX
-kan inte ta bort rad %luX
-kan inte lägga till på rad %luX
-kan inte sätta in på rad %luX
-kan inte lagra rad %luX
-kan inte hämta sista radenX
-Fel: kan inte hämta rad %luX
-LoggningsfilX
-Loggning utförs inte, ångra är inte möjligtX
-Inga ändringar att ångraX
-Loggning utförs inte, ångra är inte möjligtX
-Loggning utförs inte, ångra ångra är inte möjligtX
-Inga ändringar att återgöraX
-%s/%d: fel vid loggningX
-Vi:s standard in och ut måste gå till en terminalX
-Markering %s: inte sattX
-Markering %s: raden har tagits bortX
-Markering %s: markörpositionen finns inte längreX
-Fel: X
-ny filX
-namnet ändradesX
-ändradX
-oförändradX
-OLÅSTX
-inte skrivbarX
-rad %lu av %lu [%ld%%]X
-tom filX
-rad %luX
-Filen %s är ingen meddelandekatalogX
-Kan inte sätta standardvärde för %s flagganX
-Användning: %sX
-set: %s är en okänd flagga: "set all" visar alla flaggorX
-set: [no]%s flaggan kan inte ges ett värdeX
-set: %s flaggan är inte boleanskX
-set: %s flaggan: %sX
-set: %s flaggan: %s: för stort värdeX
-set: %s flaggan: %s är ett otillåtet talX
-set: %s flaggan är inte boleanskX
-Fönsterkolumnerna är för få, mindre än %dX
-Fönsterkolumnerna är för många, fler än %dX
-Fönsterraderna är för få, mindre än %dX
-Fönsterraderna är för många, fler än %dX
-Lisp flaggan är inte implementeradX
-meddelanden är inte avslagna: %sX
-meddelanden är inte påslagna: %sX
-
-Paragraph flaggan måste ges i teckengrupper om tvåX
-Section flaggan måste ges i teckengrupper om tvåX
-
-
-
-Standardbufferten är tomX
-Buffer %s är tomX
-Filer med radmatning i namnet kan inte återskapasX
-Ändringar kan inte återskapas om programmet krascharX
-Kopierar filen för återskapning...X
-Säkerhetskopiering misslyckades: %sX
-Ändringar kan inte återskapas om programmet krascharX
-Misslyckades att säkerhetskopiera filen: %sX
-Kopierar filen för återskapning...X
-Kan inte hitta information om användaridentitet %uX
-Kan inte låsa återskapningsfilenX
-Återskapningsfilens buffer överskrivenX
-ÅterskapningsfilX
-%s: Återskapningsfilen är korruptX
-%s: Återskapningsfilen är korruptX
-Det finns ingen fil %s, läsbar av dig, att återskapaX
-Det finns äldre versioner av denna fil som du kan återskapaX
-Det finns andra filer du kan återskapaX
-skickar inte email: %sX
-Filen är tom; inget att söka iX
-Kom till slutet på filen utan att hitta söksträngenX
-Ingen tidigare söksträngX
-Hittar inte söksträngenX
-Kom till början av filen utan att hitta söksträngenX
-Sökningen slog runtX
-Söker...X
-Inga icke skrivbara tecken funnaX
-Okänt kommandonamnX
-
-%s: kommandot är inte tillgängligt i "ex" lägeX
-Talet får inte vara nollX
-%s: Ogiltig radspecifikationX
-Fel i intern syntaxtabell (%s: %s)X
-Användning: %sX
-%s: temporärbuffert inte frisläpptX
-Offset är före rad 1X
-Offset är efter slutet på filenX
-@ med intervall exekverades när filen/fönstret ändradesX
-Global/v kommando exekverades när filen/fönstret ändradesX
-Ex kommando misslyckades: efterföljande kommandon ignoreradeX
-Ex kommando misslyckades: omdefinierade tangenter ignoreradeX
-Den andra adressen är mindre än den förstaX
-Inget namn på markering givetX
-\\ följs inte av / eller ?X
-Referens till ett radnummer mindre än 0X
-%s kommandot är inte käntX
-Värdet på adressen är för stortX
-Värdet på adressen är för litetX
-Otillåten adresskombinationX
-Otillåten adress: bara %lu rader finns i filenX
-Otillåten adress: filen är tomX
-%s kommandot tillåter inte en adress som är 0X
-Inga förkortningar att visaX
-Förkortningar måste sluta med ett "ord" teckenX
-Förkortningar kan inte innehålla mellanslag eller tabX
-Förkortningar kan inte blanda "ord"/"icke ord" tecken, utom i slutetX
-"%s" är ingen förkortningX
-Vi kommando misslyckades: omdefinierade tangenter ignoreradeX
-Inga fler filer att editeraX
-Inga tidigare filer att editeraX
-Inga tidigare filer att spela tillbakaX
-Ingen fillista att visaX
-Inget tidigare kommando att ersätta "!" medX
-Inget filnamn att ersätta %% medX
-Inget filnamn att ersätta # medX
-Fel: execl: %sX
-I/O fel: %sX
-Filen ändrad efter sista skrivning; spara eller använd !X
-Kan inte hitta hemkatalogX
-Ny nuvarande katalog: %sX
-Inga "cut buffers" att visaX
-%s kommandot kan inte används som del i ett "global" eller v kommandoX
-%s/%s: inte läst: varken du eller root är ägareX
-%s/%s: inte läst: du är inte ägareX
-%s/%s: inte läst: skrivbar av annan än ägarenX
-%s: inte läst: varken du eller root är ägareX
-%s: inte läst: du är inte ägareX
-%s: inte läst: skrivbar av annan än ägarenX
-Ingen nästa rad att sätta ihop medX
-Det finns inget i inmatningsmappningenX
-Det finns inget i kommandomappningenX
-%s tecknet kan inte mappas omX
-"%s" är inte ommappat just nuX
-Namn på markeringar måste vara ett tecken långaX
-%s finns, inget sparat; använd ! för att sparaX
-Ny exrc fil: %sX
-Målraden ligger inne i området som ska flyttasX
-Open kommandot kräver att open flaggan är sattX
-Open kommandot är inte implementerat ännuX
-Säkerhetskopiering av filen är inte möjligtX
-Filen säkerhetskopieradX
-%s expanderade till för många filnamnX
-Endast vanliga filer och namngivna rör kan läsasX
-%s: läslåset är otillgängligtX
-Läser...X
-%s: %lu rader, %lu teckenX
-Inga bakgrundsfönster att visaX
-Script kommandot finns bara i "vi" lägeX
-Inget kommando att exekveraX
-shiftwidth flaggan satt till 0X
-Talet har för stort värdeX
-Talet har för litet värdeX
-Reguljärt uttryck är givet; r flaggan är meningslösX
-#, l och p flaggorna kan inte kombineras med c flaggan i "vi" lägeX
-Ingen matchande text funnenX
-Inget tidigare märke har givitsX
-Det är färre än %s märken i stacken; använd :display t[ags]X
-Det finns ingen fil %s i märkesstacken; använd :display t[ags]X
-Tryck Enter för att fortsätta: X
-%s: märke inte funnetX
-%s: korrupt märke i %sX
-%s: märkets radnummer är bortom filslutetX
-Märkesstacken är tomX
-%s: söksträngen inte funnenX
-%d filer till att editeraX
-Buffert %s är tomX
-Bekräfta ändring? [n]X
-AvbrutenX
-Ingen tidigare buffert att exekveraX
-Inget tidigare reguljärt uttryckX
-%s kommandot kräver att en fil redan lästs inX
-Användning: %sX
-Visual kommandot kräver att open flaggan är sattX
-
-Tom filX
-Ingen tidigare F, f, T eller t sökningX
-%s inte funnenX
-Ingen tidigare fil att editeraX
-Markören är inte i ett talX
-Det resulterande talet är för stortX
-Det resulterande talet är för litetX
-Inget matchande tecken på denna radX
-Matchande tecken inte funnetX
-Det finns inga tecken att ersättaX
-Det finns inget fönster att byta tillX
-Tecken efter söksträng, radoffset och/eller z kommandotX
-Ingen tidigare söksträngX
-Sökningen slog runt till ursprungliga positionenX
-Förkortning överskred expanderingsgränsen: tecken har tagits bortX
-Ogiltigt tecken; använd "quote" för att sätta inX
-Redan i början på insättningenX
-Inga fler tecken att ta bortX
-Försök att gå bortom slutet på filenX
-Försök att gå bortom slutet på radenX
-Ingen förflyttning gjordX
-Redan i början på filenX
-Försök att gå före början på filenX
-Redan i första kolumnenX
-Buffertar måste anges före kommandotX
-Redan i slutet av filenX
-Redan på slutet av radenX
-%s är inte ett "vi" kommandoX
-Användning: %sX
-Inga tecken att ta bortX
-Q kommandot kräver "ex" i terminallägeX
-Inget kommando att repeteraX
-Filen är tomX
-%s kan inte användas som ett förflyttningskommandoX
-Redan i kommando lägeX
-Markören är inte i ett ordX
-
-Windows flaggans värde är för stor, största värde är %uX
-Lägg tillX
-ÄndraX
-KommandoX
-Sätt inX
-ErsättX
-Förflyttning bortom fönsterslutX
-Förflyttning till före fönstrets börjanX
-Fönstret måste vara större än %d rader för delningX
-Det finns inga fönster i bakgrundenX
-Det finns inget fönster i bakgrunden som editerar filen %sX
-Du får inte sätta ditt enda synliga fönster i bakgrundenX
-Fönstret kan bara krympa till %d raderX
-Fönstret kan inte krympaX
-Fönstret kan inte växaX
-
-Detta fönster kan inte pausasX
-Avbrutet: omdefinierade tangenter ignoreradeX
-vi: temporärbuffertar inte frisläpptaX
-Denna terminal har ingen %s tangentX
-Endast en buffert kan angesX
-Talet är större än %luX
-AvbrutetX
-Kan inte skapa temporär filX
-Warning: %s är inte en normal filX
-%s är redan låst, detta blir en icke skrivbar sessionX
-%s: ta bortX
-%s: stängX
-%s: ta bortX
-%s: ta bortX
-Ej skrivbar fil, filen inte sparad; använd ! för att skriva överX
-Ej skrivbar fil, filen inte sparadX
-%s finns, ej sparad; använd ! för att utföra operationenX
-%s finns, filen inte sparadX
-Ofullständig fil, filen inte sparad, använd ! för att skriva överX
-Ofullständig fil, filen inte sparadX
-%s: filen ändrad efter denna kopia togs; använd ! för att utföra operationenX
-%s: filen ändrad efter denna kopia togsX
-%s: skrivlåset är otillgängligtX
-Skriver...X
-%s: VARNING: FILEN TRUNKERADX
-Redan vid första märket i denna gruppX
-%s: ny fil: %lu rader, %lu teckenX
-%s: %lu rader, %lu teckenX
-%s expanderade till för många filnamnX
-%s är inte en normal filX
-%s ägs inte av digX
-%s är åtkomstbar av andra än ägarenX
-Filen har ändrats efter den sparats; spara eller använd !X
-Filen har ändrats efter den sparats; spara eller använd :edit!X
-Filen har ändrats efter den sparats; spara eller använd !X
-Filen är temporär; exit kastar bort ändringarnaX
-Ej skrivbar fil, ändringar har inte automatsparatsX
-Loggningen startar omX
-bekräfta? [ynq]X
-Tryck på en tangent för att fortsätta: X
-Tryck på en tangent för att fortsätta [: för att ge fler kommandon]: X
-Tryck på en tangent för att fortsätta [q för att avsluta]: X
-Den formen av %s kräver "ex" i terminallägeX
-Går till "ex" inmatningsläge.X
-Kommandot misslyckades, ingen fil inläst ännu.X
- forts?X
-Oväntad teckenhändelseX
-Oväntad filslutshändelseX
-Sökningen hittade ingentingX
-Oväntad avbrottshändelseX
-Oväntad avslutningshändelseX
-Oväntad omritningshändelseX
-Redan vid sista märket i denna gruppX
-%s kommandot kräver "ex" i terminallägeX
-Den formen av %s är inte tillgänglig när secure edit flaggan är sattX
-Oväntad stränghändelseX
-Oväntad tidshändelseX
-Oväntad skrivhändelseX
-
-Skalexpansion är inte tillgänglig när secure edit flaggan är sattX
-%s kommandot är inte tillgänglig när secure edit flaggan är sattX
-set: %s kan inte slås avX
-Fönstret för litet.X
-tillagdaX
-ändradeX
-borttagnaX
-ihopsattaX
-flyttadeX
-flyttadeX
-inklistradeX
-radX
-raderX
-Vi har inte länkats med en Tcl tolkX
-Filen har ändrats efter den sparats.X
-Skalexpansion misslyckadesX
-Ingen %s edit flagga givenX
-Vi har inte länkats med en Perl tolkX
-Inga "ex" kommandon att exekveraX
-Tryck <CR> för att exekvera kommando, :q för att avslutaX
-Gör "cscope help" för hjälpX
-Inga cscope kopplingar körsX
-%s: okänd söktyp: använd en av %sX
-%d: ingen sådan cscope sessionX
-set: %s flaggan får aldrig slås påX
-set: %s flaggan får aldrig sättas till 0X
-%s: tillagt: %lu rader, %lu teckenX
-Oväntad storleksändringX
-%d filer att editeraX
diff --git a/catalog/swedish.base b/catalog/swedish.base
index 43bf7765a25e..7143c5a7818e 100644
--- a/catalog/swedish.base
+++ b/catalog/swedish.base
@@ -29,7 +29,7 @@
030 "Filen %s är ingen meddelandekatalog"
031 "Kan inte sätta standardvärde för %s flaggan"
032 "Användning: %s"
-033 "set: %s är en okänd flagga: "set all" visar alla flaggor"
+033 "set: %s är en okänd flagga: \"set all\" visar alla flaggor"
034 "set: [no]%s flaggan kan inte ges ett värde"
035 "set: %s flaggan är inte boleansk"
036 "set: %s flaggan: %s"
@@ -43,8 +43,7 @@
044 "Lisp flaggan är inte implementerad"
045 "meddelanden är inte avslagna: %s"
046 "meddelanden är inte påslagna: %s"
-048 "Paragraph flaggan måste ges i teckengrupper om två"
-049 "Section flaggan måste ges i teckengrupper om två"
+047 "%s flaggan måste ges i teckengrupper om två"
053 "Standardbufferten är tom"
054 "Buffer %s är tom"
055 "Filer med radmatning i namnet kan inte återskapas"
@@ -73,7 +72,7 @@
078 "Söker..."
079 "Inga icke skrivbara tecken funna"
080 "Okänt kommandonamn"
-082 "%s: kommandot är inte tillgängligt i "ex" läge"
+082 "%s: kommandot är inte tillgängligt i \"ex\" läge"
083 "Talet får inte vara noll"
084 "%s: Ogiltig radspecifikation"
085 "Fel i intern syntaxtabell (%s: %s)"
@@ -97,16 +96,16 @@
103 "Otillåten adress: filen är tom"
104 "%s kommandot tillåter inte en adress som är 0"
105 "Inga förkortningar att visa"
-106 "Förkortningar måste sluta med ett "ord" tecken"
+106 "Förkortningar måste sluta med ett \"ord\" tecken"
107 "Förkortningar kan inte innehålla mellanslag eller tab"
-108 "Förkortningar kan inte blanda "ord"/"icke ord" tecken, utom i slutet"
-109 ""%s" är ingen förkortning"
+108 "Förkortningar kan inte blanda \"ord\"/\"icke ord\" tecken, utom i slutet"
+109 "\"%s\" är ingen förkortning"
110 "Vi kommando misslyckades: omdefinierade tangenter ignorerade"
111 "Inga fler filer att editera"
112 "Inga tidigare filer att editera"
113 "Inga tidigare filer att spela tillbaka"
114 "Ingen fillista att visa"
-115 "Inget tidigare kommando att ersätta "!" med"
+115 "Inget tidigare kommando att ersätta \"!\" med"
116 "Inget filnamn att ersätta %% med"
117 "Inget filnamn att ersätta # med"
118 "Fel: execl: %s"
@@ -114,8 +113,8 @@
120 "Filen ändrad efter sista skrivning; spara eller använd !"
121 "Kan inte hitta hemkatalog"
122 "Ny nuvarande katalog: %s"
-123 "Inga "cut buffers" att visa"
-124 "%s kommandot kan inte används som del i ett "global" eller v kommando"
+123 "Inga \"cut buffers\" att visa"
+124 "%s kommandot kan inte används som del i ett \"global\" eller v kommando"
125 "%s/%s: inte läst: varken du eller root är ägare"
126 "%s/%s: inte läst: du är inte ägare"
127 "%s/%s: inte läst: skrivbar av annan än ägaren"
@@ -126,7 +125,7 @@
132 "Det finns inget i inmatningsmappningen"
133 "Det finns inget i kommandomappningen"
134 "%s tecknet kan inte mappas om"
-135 ""%s" är inte ommappat just nu"
+135 "\"%s\" är inte ommappat just nu"
136 "Namn på markeringar måste vara ett tecken långa"
137 "%s finns, inget sparat; använd ! för att spara"
138 "Ny exrc fil: %s"
@@ -141,13 +140,13 @@
147 "Läser..."
148 "%s: %lu rader, %lu tecken"
149 "Inga bakgrundsfönster att visa"
-150 "Script kommandot finns bara i "vi" läge"
+150 "Script kommandot finns bara i \"vi\" läge"
151 "Inget kommando att exekvera"
152 "shiftwidth flaggan satt till 0"
153 "Talet har för stort värde"
154 "Talet har för litet värde"
155 "Reguljärt uttryck är givet; r flaggan är meningslös"
-156 "#, l och p flaggorna kan inte kombineras med c flaggan i "vi" läge"
+156 "#, l och p flaggorna kan inte kombineras med c flaggan i \"vi\" läge"
157 "Ingen matchande text funnen"
158 "Inget tidigare märke har givits"
159 "Det är färre än %s märken i stacken; använd :display t[ags]"
@@ -182,7 +181,7 @@
189 "Ingen tidigare söksträng"
190 "Sökningen slog runt till ursprungliga positionen"
191 "Förkortning överskred expanderingsgränsen: tecken har tagits bort"
-192 "Ogiltigt tecken; använd "quote" för att sätta in"
+192 "Ogiltigt tecken; använd \"quote\" för att sätta in"
193 "Redan i början på insättningen"
194 "Inga fler tecken att ta bort"
195 "Försök att gå bortom slutet på filen"
@@ -194,10 +193,10 @@
201 "Buffertar måste anges före kommandot"
202 "Redan i slutet av filen"
203 "Redan på slutet av raden"
-204 "%s är inte ett "vi" kommando"
+204 "%s är inte ett \"vi\" kommando"
205 "Användning: %s"
206 "Inga tecken att ta bort"
-207 "Q kommandot kräver "ex" i terminalläge"
+207 "Q kommandot kräver \"ex\" i terminalläge"
208 "Inget kommando att repetera"
209 "Filen är tom"
210 "%s kan inte användas som ett förflyttningskommando"
@@ -260,8 +259,8 @@
269 "Tryck på en tangent för att fortsätta: "
270 "Tryck på en tangent för att fortsätta [: för att ge fler kommandon]: "
271 "Tryck på en tangent för att fortsätta [q för att avsluta]: "
-272 "Den formen av %s kräver "ex" i terminalläge"
-273 "Går till "ex" inmatningsläge."
+272 "Den formen av %s kräver \"ex\" i terminalläge"
+273 "Går till \"ex\" inmatningsläge."
274 "Kommandot misslyckades, ingen fil inläst ännu."
275 " forts?"
276 "Oväntad teckenhändelse"
@@ -271,7 +270,7 @@
280 "Oväntad avslutningshändelse"
281 "Oväntad omritningshändelse"
282 "Redan vid sista märket i denna grupp"
-283 "%s kommandot kräver "ex" i terminalläge"
+283 "%s kommandot kräver \"ex\" i terminalläge"
284 "Den formen av %s är inte tillgänglig när secure edit flaggan är satt"
285 "Oväntad stränghändelse"
286 "Oväntad tidshändelse"
@@ -294,9 +293,9 @@
304 "Skalexpansion misslyckades"
305 "Ingen %s edit flagga given"
306 "Vi har inte länkats med en Perl tolk"
-307 "Inga "ex" kommandon att exekvera"
+307 "Inga \"ex\" kommandon att exekvera"
308 "Tryck <CR> för att exekvera kommando, :q för att avsluta"
-309 "Gör "cscope help" för hjälp"
+309 "Gör \"cscope help\" för hjälp"
310 "Inga cscope kopplingar körs"
311 "%s: okänd söktyp: använd en av %s"
312 "%d: ingen sådan cscope session"
diff --git a/catalog/swedish.check b/catalog/swedish.check
deleted file mode 100644
index c70b9bbd4095..000000000000
--- a/catalog/swedish.check
+++ /dev/null
@@ -1,34 +0,0 @@
-Unused message id's (this is okay):
-001
-047
-050
-051
-052
-081
-176
-213
-229
-288
-=========================
-MISSING ERROR MESSAGES (Please add!):
-=========================
-Extra error messages (just delete them):
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s expanderade till för många filnamnX
- 2 %s: %lu rader, %lu teckenX
- 2 %s: Återskapningsfilen är korruptX
- 2 Filen har ändrats efter den sparats; spara eller använd !X
- 2 Ingen tidigare söksträngX
- 2 Kopierar filen för återskapning...X
- 2 Loggning utförs inte, ångra är inte möjligtX
- 2 flyttadeX
- 2 set: %s flaggan är inte boleanskX
- 2 Ändringar kan inte återskapas om programmet krascharX
- 3 %s: ta bortX
- 4 Användning: %sX
-=========================
diff --git a/catalog/uk_UA.KOI8-U.base b/catalog/uk_UA.KOI8-U.base
new file mode 100644
index 000000000000..b2dfc7f52365
--- /dev/null
+++ b/catalog/uk_UA.KOI8-U.base
@@ -0,0 +1,306 @@
+002 "ðÅÒÅÐÏ×ÎÅÎÎÑ ÚÎÁÞÅÎÎÑ ÄÏ×ÖÉÎÉ ÒÑÄËÕ"
+003 "ÎÅÍÏÖÌÉ×Ï ÓÔÅÒÔÉ ÒÑÄÏË %lu"
+004 "ÎÅÍÏÖÌÉ×Ï ÄÏÄÁÔÉ ÄÏ ÒÑÄËÕ %lu"
+005 "ÎÅÍÏÖÌÉ×Ï ×ÓÔÁ×ÉÔÉ × ÒÑÄÏË %lu"
+006 "ÎÅÍÏÖÌÉ×Ï ÒÏÚͦÓÔÉÔÉ ÒÑÄÏË %lu"
+007 "ÎÅÍÏÖÌÉ×Ï Ä¦ÓÔÁÔÉ ÏÓÔÁÎÎ¦Ê ÒÑÄÏË"
+008 "ðÏÍÉÌËÁ: ÎÅÍÏÖÌÉ×Ï ÏÔÒÉÍÁÔÉ ÒÑÄÏË %lu"
+009 "æÁÊÌ ÚÁÐÉÓ¦×"
+010 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓÑ, ÎÅÍÏÖÌÉ×Ï ×¦ÄͦÎÉÔÉ ÏÓÔÁÎÎÀ ËÏÍÁÎÄÕ"
+011 "îÅÍÁ ÞÏÇÏ ×¦ÄͦÎÑÔÉ"
+012 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓÑ, ÎÅÍÏÖÌÉ×Ï ×¦ÄͦÎÉÔÉ ÏÓÔÁÎÎÀ ËÏÍÁÎÄÕ"
+013 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓÑ, ÎÅÍÏÖÌÉ×Ï ÐÒÏÄÉ×ÉÔÉÓÑ ×ÐÅÒÅÄ"
+014 "îÅÍÁ ÞÏÇÏ ÐÏ×ÔÏÒÀ×ÁÔÉ"
+015 "%s/%d: ÐÏÍÉÌËÁ ÚÁÐÉÓÕ ÐÒÏÔÏËÏÌÕ"
+016 "óÔÁÎÄÁÒÔÎÉÍ ××ÅÄÅÎÎÑÍ/×É×ÅÄÅÎÎÑÍ ÄÌÑ vi ÍÁ¤ ÂÕÔÉ ÔÅÒͦÎÁÌ"
+017 "í¦ÔËÁ %s: ÎÅ ×ÓÔÁÎÏ×ÌÅÎÏ"
+018 "í¦ÔËÁ %s: ÒÑÄÏË ÓÔÅÒÔÏ"
+019 "í¦ÔËÁ %s: ÐÏÚÉæ§ ËÕÒÓÏÒÕ Â¦ÌØÛÅ ÎÅ ¦ÓÎÕ¤"
+020 "ðÏÍÉÌËÁ: "
+021 "îÏ×ÉÊ ÆÁÊÌ"
+022 "IÍ'Ñ ÚͦÎÉÌÏÓØ"
+023 "ÚͦÎÅÎÉÊ"
+024 "ÎÅ ÚͦÎÅÎÉÊ"
+025 "òO3âìOëO÷áîO"
+026 "Ô¦ÌØËÉ ÄÌÑ ÞÉÔÁÎÎÑ"
+027 "ÒÑÄÏË %lu Ú %lu [%ld%%]"
+028 "ÐÕÓÔÉÊ ÆÁÊÌ"
+029 "ÒÑÄÏË %lu"
+030 "æÁÊÌ %s ÎÅ ¤ ÆÁÊÌÏÍ ÐÏצÄÏÍÌÅÎÎØ"
+031 "îÅÍÏÖÌÉ×Ï ×ÓÔÁÎÏ×ÉÔÉ ÏÐæÀ %s ÚÁ ÚÍÏ×ÞÁÎÎÑÍ"
+032 "÷ÉËÏÒÉÓÔÁÎÎÑ: %s"
+033 "ïÐæ§ %s ÎÅÍÁ¤: 'set all' ÐÏËÁÚÕ¤ ×Ó¦ ÍÏÖÌÉצ ÏÐæ§"
+034 "set: [no]%s ÎÅ ÎÁÂÕ×Á¤ ÔÁËÏÇÏ ÚÎÁÞÅÎÎÑ"
+035 "set: %s ÏÐÃ¦Ñ ÎÅ ¤ ÌÏǦÞÎÏÀ"
+036 "set: ÏÐÃ¦Ñ %s: %s"
+037 "set: ÏÐÃ¦Ñ %s: %s: ÐÅÒÅÐÏ×ÎÅÎÎÑ"
+038 "set: ÎÅÐÒÁ×ÉÌØÎÅ ÚÎÁÞÅÎÎÑ %s"
+039 "set: %s ÏÐÃ¦Ñ ÎÅ ¤ ÌÏǦÞÎÏÀ"
+040 "ë¦ÌØ˦ÓÔØ ËÏÌÏÎÏË ÎÁ ÜËÒÁΦ ÎÁÄÔÏ ÍÁÌÁ, ÍÅÎÛÅ Î¦Ö %d"
+041 "ë¦ÌØ˦ÓÔØ ËÏÌÏÎÏË ÎÁ ÜËÒÁΦ ÎÁÄÔÏ ×ÅÌÉËÁ, ¦ÌØÛÅ Î¦Ö %d"
+042 "ë¦ÌØ˦ÓÔØ ÒÑÄË¦× ÎÁ ÜËÒÁΦ ÎÁÄÔÏ ÍÁÌÁ, ÍÅÎÛÅ Î¦Ö %d"
+043 "ë¦ÌØ˦ÓÔØ ÒÑÄË¦× ÎÁ ÜËÒÁΦ ÎÁÄÔÏ ×ÅÌÉËÁ, ¦ÌØÛÅ Î¦Ö %d"
+044 "ïÐÃ¦Ñ lisp צÄÓÕÔÎÑ"
+045 "ðÏצÄÏÍÌÅÎÎÑ ÎÅ ×ÉÍËÎÅΦ: %s"
+046 "ðÏצÄÏÍÌÅÎÎÑ ÎÅ ×צÍËÎÅΦ: %s"
+047 "ïÐÃ¦Ñ %s ÐÏ×ÉÎÎÁ ͦÓÔÉÔÉ ÇÒÕÐÉ Ú Ä×ÏÈ ÓÉÍ×Ï̦×"
+053 "óÔÁÒÔÏ×ÉÊ ÂÕÆÅÒ ÐÏÒÏÖΦÊ"
+054 "âÕÆÅÒ %s ÐÏÒÏÖΦÊ"
+055 "îÅÍÏÖÌÉ×Ï ×¦ÄÎÏ×ÉÔÉ ÆÁÊÌ, ÝÏ Í¦ÓÔÉÔØ × ¦ÍÅΦ ÓÉÍ×ÏÌÉ ÐÅÒÅ×ÅÄÅÎÎÑ ËÁÒÅÔËÉ"
+056 "úͦÎÉ ÎÅ ÍÏÖÎÁ ÂÕÄŠצÄÎÏ×ÉÔÉ Ð¦ÓÌÑ ËÒÁÈÕ ÓÅÓ¦§"
+057 "ëÏЦÀ×ÁÎÎÑ ÆÁÊÌÕ ÄÌÑ ×¦ÄÎÏ×ÌÅÎÎÑ..."
+058 "úÂÅÒÅÖÅÎÎÑ ÎÅ ×ÄÁÌÏÓØ: %s"
+059 "úͦÎÉ ÎÅ ÍÏÖÎÁ ÂÕÄŠצÄÎÏ×ÉÔÉ Ð¦ÓÌÑ ËÒÁÈÕ ÓÅÓ¦§"
+060 "úÂÅÒÅÖÅÎÎÑ ËÏЦ§ ÆÁÊÌÕ ÎÅ ×ÄÁÌÏÓØ: %s"
+061 "ëÏЦÀ×ÁÎÎÑ ÆÁÊÌÕ ÄÌÑ ×¦ÄÎÏ×ÌÅÎÎÑ..."
+062 "IÎÆÏÒÍÁæÀ ÐÒÏ ËÏÒÉÓÔÕ×ÁÞÁ %u ÎÅ ÚÎÁÊÄÅÎÏ"
+063 "úÁÂÌÏËÕ×ÁÔÉ ×¦ÄÎÏ×ÌÅÎÎÉÊ ÆÁÊÌ ÎÅÍÏÖÌÉ×Ï"
+064 "âÕÆÅÒ ×¦ÄÎÏ×ÌÅÎÏÇÏ ÆÁÊÌÕ ÐÅÒÅÐÏ×ÎÅÎÏ"
+065 "÷¦ÄÎÏ×ÌÅÎÎÉÊ ÆÁÊÌ"
+066 "%s: ÆÁÊÌ ×¦ÄÎÏ×ÌÅÎÎÉÊ ÎÅ ÄÏ Ë¦ÎÃÑ"
+067 "%s: ÆÁÊÌ ×¦ÄÎÏ×ÌÅÎÎÉÊ ÎÅ ÄÏ Ë¦ÎÃÑ"
+068 "îÅ ¦ÓÎÕÀ¤ ÆÁÊÌ¦× Ú ¦ÍÅÎÅÍ %s, Ñ˦ ÷É ÍÏÖÅÔÅ ÐÒÏÞÉÔÁÔÉ"
+069 "IÓÎÕÀÔØ ÓÔÁÒ¦ ×ÅÒÓ¦§ ÆÁÊÌÕ, Ñ˦ ÍÏÖÎÁ צÄÎÏ×ÉÔÉ"
+070 "IÓÎÕÀÔØ ¦ÎÛ¦ ÆÁÊÌÉ, Ñ˦ ÍÏÖÎÁ צÄÎÏ×ÉÔÉ"
+071 "e-mail ΊצĦÓÌÁÎÏ: %s"
+072 "æÁÊÌ ÐÕÓÔÉÊ - ÎÅÍÁ ÞÏÇÏ ÛÕËÁÔÉ"
+073 "äÏÓÑÎÕÔÏ Ë¦ÎÃÑ ÆÁÊÌÕ ÂÅÚ ÚÎÁÈÏÖÄÅÎÎÑ ÚÒÁÚËÕ ÐÏÛÕËÕ"
+074 "îÅ ÚÁÄÁÎÏ ÚÒÁÚÏË ÐÏÛÕËÕ"
+075 "úÒÁÚÏË ÐÏÛÕËÕ ÎÅ ÚÎÁÊÄÅÎÏ"
+076 "äÏÓÑÎÕÔÏ ÐÏÞÁÔËÕ ÆÁÊÌÕ ÂÅÚ ÚÎÁÈÏÖÄÅÎÎÑ ÚÒÁÚËÕ ÐÏÛÕËÕ"
+077 "ðÏÛÕË ÚÁÃÉËÌÅÎÏ"
+078 "ðÏÛÕË..."
+079 "îÅÐÅÞÁÔÎÉÈ ÓÉÍ×ÏÌ¦× ÎÅ ÚÎÁÊÄÅÎÏ"
+080 "îÅצÄÏÍÁ ËÏÍÁÎÄÁ"
+082 "%s: ËÏÍÁÎÄÁ ÎÅ ÄÏÓÔÕÐÎÁ × ÒÅÖÉͦ ex"
+083 "ì¦ÞÉÌØÎÉË ÎÅ ÍÏÖÅ ÂÕÔÉ ÎÕÌÅÍ"
+084 "%s: ÎÅÐÒÁ×ÉÌØÎÅ ×ÉÚÎÁÞÅÎÎÑ ÒÑÄËÕ"
+085 "÷ÎÕÔÒ¦ÛÎÑ ÐÏÍÉÌËÁ × ÓÉÎÔÁËÓÉÓ¦ (%s: %s)"
+086 "÷ÉËÏÒÉÓÔÁÎÎÑ: %s"
+087 "%s: ÔÉÍÞÁÓÏ×ÉÊ ÂÕÆÅÒ ÎÅ ×ÉËÏÒÉÓÔÁÎÏ"
+088 "í¦ÔËÕ ÐÏÓÔÁ×ÌÅÎÏ ÐÅÒÅÄ ÐÅÒÛÉÍ ÒÑÄËÏÍ"
+089 "í¦ÔËÕ ÐÏÓÔÁ×ÌÅÎÏ Ð¦ÓÌÑ Ë¦ÎÃÑ ÆÁÊÌÕ"
+090 "@ Ú Ä¦ÁÐÁÚÏÎÏÍ ÐÒÁÃÀ¤ ËÏÌÉ ÚͦÎÅÎÏ ÆÁÊÌ/צËÎÏ"
+091 "ëÏÍÁÎÄÁ Global/v ÐÒÁÃÀ¤ ËÏÌÉ ÚͦÎÅÎÏ ÆÁÊÌ/צËÎÏ"
+092 "ëÏÍÁÎÄÁ ex ÎÅ ×ÄÁÌÁÓØ: ÎÁÓÔÕÐΦ ËÏÍÁÎÄÉ Ú'¦ÇÎÏÒÏ×ÁÎÏ"
+093 "ëÏÍÁÎÄÁ ex ÎÅ ×ÄÁÌÁÓØ: צÄÏÂÒÁÖÅΦ ËÌÁצۦ Ú'¦ÇÎÏÒÏ×ÁÎÏ"
+094 "äÒÕÇÁ ÁÄÒÅÓÁ ÍÅÎÛÅ Î¦Ö ÐÅÒÛÁ"
+095 "îÅ ×ËÁÚÁÎÏ ¦Í'Ñ Í¦ÔËÉ"
+096 "\\ ÎÅ ÚÁ˦ÎÞÕ¤ÔØÓÑ / ÞÉ ?"
+097 "ðÏÓÉÌÁÎÎÑ ÎÁ ÒÑÄÏË Ú ÎÏÍÅÒÏÍ, ÍÅÎÛÉÍ Î¦Ö 0"
+098 "ëÏÍÁÎÄÁ %s ÎÅצÄÏÍÁ"
+099 "ðÅÒÅÐÏ×ÎÅÎÎÑ Ì¦ÞÉÌØÎÉËÁ ÁÄÒÅÓ"
+100 "îÅÄÏÂ¦Ò Ì¦ÞÉÌØÎÉËÁ ÁÄÒÅÓ"
+101 "îÅÄÏÐÕÓÔÉÍÁ ËÏͦÎÁÃ¦Ñ × ÁÄÒÅÓ¦"
+102 "îÅÐÒÁ×ÉÌØÎÁ ÁÄÒÅÓÁ: ×ÓØÏÇÏ %lu ÒÑÄË¦× Õ ÆÁÊ̦"
+103 "îÅÐÒÁ×ÉÌØÎÁ ÁÄÒÅÓÁ: ÆÁÊÌ ÐÕÓÔÉÊ"
+104 "ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅ ×ÉËÏÒÉÓÔÏ×Õ×ÁÔÉ ÁÄÒÅÓÕ 0"
+105 "îÅÍÁ¤ ÁÂÒÅצÁÔÕÒ"
+106 "áÂÒÅצÁÔÕÒÉ ÐÏ×ÉÎΦ ÚÁ˦ÎÞÕ×ÁÔÉÓÑ ÓÉÍ×ÏÌÏÍ \"Ó̦×\""
+107 "÷ ÁÂÒÅצÁÔÕÒ¦ ÎÅ ÍÏÖÎÁ ×ÉËÏÒÉÓÔÏ×Õ×ÁÔÉ ÓÉÍ×ÏÌÉ ÔÁÂÕÌÑæ§ ÔÁ ÐÒϦÌÉ"
+108 "áÂÒÅצÁÔÕÒÉ ÎÅ ÍÏÖÕÔØ ÚͦÛÕ×ÁÔÉ ÓÉÍ×ÏÌÉ Ó̦×/ÎÅ-Ó̦×, ȦÂÁ ÝÏ × Ë¦Îæ ÒÑÄËÕ"
+109 "\"%s\" ÎÅ ÁÂÒÅצÁÔÕÒÁ"
+110 "ëÏÍÁÎÄÁ Vi ÎÅ ×ÄÁÌÁÓØ: צÄÏÂÒÁÖÅΦ ËÌÁצۦ Ú'¦ÇÎÏÒÏ×ÁÎÏ"
+111 "æÁÊÌ¦× ÄÌÑ ÒÅÄÁÇÕ×ÁÎÎÑ Â¦ÌØÛÅ ÎÅÍÁ¤"
+112 "ðÏÐÅÒÅÄÎØÏÇÏ ÆÁÊÌÕ ÄÌÑ ÒÅÄÁÇÕ×ÁÎÎÑ ÎÅÍÁ¤"
+113 "ðÏÐÅÒÅÄÎØÏÇÏ ÆÁÊÌÕ ÄÌÑ ÐÅÒÅÇÌÑÄÕ ÎÅÍÁ¤"
+114 "îÅÍÁ¤ ÆÁÊ̦×"
+115 "îÅÍÁ¤ ÐÏÐÅÒÅÄÎØϧ ËÏÍÁÎÄÉ ÄÌÑ ÚÁͦÎÉ \"!\""
+116 "÷¦ÄÓÕÔΤ ¦Í'Ñ ÆÁÊÌÕ ÄÌÑ Ð¦ÄͦÎÉ %%"
+117 "÷¦ÄÓÕÔΤ ¦Í'Ñ ÆÁÊÌÕ ÄÌÑ Ð¦ÄͦÎÉ #"
+118 "ðÏÍÉÌËÁ: execl: %s"
+119 "ðÏÍÉÌËÁ ××ÅÄÅÎÎÑ/×É×ÅÄÅÎÎÑ: %s"
+120 "æÁÊÌ ÍÏÄÉƦËÏ×ÁÎÏ Ð¦ÓÌÑ ÏÓÔÁÎÎØϧ ËÏÍÁÎÄÉ ÐÏ×ÎÏÇÏ ÚÁÐÉÓÕ: ÚÂÅÒÅÖ¦ÔØ ÞÉ ×ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÏÂÈÏÄÕ"
+121 "îÅÍÏÖÌÉ×Ï ÚÎÁÊÔÉ ÄÏÍÁÛÎ¦Ê ËÁÔÁÌÏÇ"
+122 "îÏ×ÉÊ ËÁÔÁÌÏÇ: %s"
+123 "îÅÍÁ¤ ÎÁÐÏ×ÎÅÎÉÈ ÂÕÆÅÒ¦×"
+124 "ëÏÍÁÎÄÁ %s ÎÅ ×ÉËÏÒÉÓÔÏ×Õ¤ÔØÓÑ ÑË ÞÁÓÔÉÎÁ ËÏÍÁÎÄÉ global ÞÉ v"
+125 "%s/%s: ΊצÄËÒÉÔÏ: ÎÅ ÎÁÌÅÖÉÔØ ÷ÁÍ ÞÉ ÁÄͦΦÓÔÒÁÔÏÒÕ"
+126 "%s/%s: ΊצÄËÒÉÔÏ: ÎÅ ÎÁÌÅÖÉÔØ ÷ÁÍ"
+127 "%s/%s: ΊצÄËÒÉÔÏ: ÍÏÖÌÉצÓÔØ ÚÁÐÉÓÕ ËÏÒÉÓÔÕ×ÁÞÅÍ, ÑËÉÊ ÎÅ ¤ ×ÌÁÓÎÉËÏÍ"
+128 "%s: ΊצÄËÒÉÔÏ: ÎÅ ÎÁÌÅÖÉÔØ ÷ÁÍ ÞÉ ÁÄͦΦÓÔÒÁÔÏÒÕ"
+129 "%s: ΊצÄËÒÉÔÏ: ÎÅ ÎÁÌÅÖÉÔØ ÷ÁÍ"
+130 "%s: ΊצÄËÒÉÔÏ: ÍÏÖÌÉצÓÔØ ÚÁÐÉÓÕ ËÏÒÉÓÔÕ×ÁÞÅÍ, ÑËÉÊ ÎÅ ¤ ×ÌÁÓÎÉËÏÍ"
+131 "îÅÍÁ¤ ¦ÌØÛÅ ÒÑÄË¦× ÄÌÑ ÏÂ'¤ÄÎÁÎÎÑ"
+132 "îÅÍÁ¤ ÐÁÒÁÍÅÔÒ¦× ××ÅÄÅÎÎÑ"
+133 "îÅÍÁ¤ ÐÁÒÁÍÅÔÒ¦× ËÏÍÁÎÄÉ"
+134 "óÉÍ×ÏÌ %s ÎÅ ÍÏÖÎÁ ÐÅÒÅÎÁÚÎÁÞÉÔÉ"
+135 "\"%s\" ÚÁÒÁÚ ÎÅ ÐÅÒÅÎÁÚÎÁÞÅÎÏ"
+136 "IÍ'Ñ Í¦ÔËÉ -- ÏÄÉÎ ÓÉÍ×ÏÌ"
+137 "%s ¦ÓÎÕ¤, ÎÅ ÚÁÐÉÓÁÎÏ; ×ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÏÂÈÏÄÕ"
+138 "îÏ×ÉÊ ÆÁÊÌ exrÓ: %s"
+139 "òÑÄÏË ÐÒÉÚÎÁÞÅÎÎÑ ÚÁÚÎÁÞÅÎÏ ×ÓÅÒÅÄÉΦ ĦÁÐÁÚÏÎÕ ÐÅÒÅͦÝÅÎÎÑ"
+140 "ëÏÍÁÎÄÁ open ×ÉÍÁÇÁ¤ ×ÓÔÁÎÏ×ÌÅÎÎÑ ÏÐæ§ open"
+141 "ëÏÍÁÎÄÕ open ÝÅ ÎÅ ÒÅÁ̦ÚÏ×ÁÎÏ"
+142 "úÁÈÉÓÔ ÆÁÊÌÕ ÎÅÍÏÖÌÉ×ÉÊ"
+143 "æÁÊÌ ÚÁÈÉÝÅÎÏ"
+144 "%s ÒÏÚÛÉÒÉ×ÓÑ × ÎÁÄÔÏ ×ÅÌÉËÕ Ë¦ÌØ˦ÓÔØ ¦ÍÅÎ ÆÁÊ̦×"
+145 "ðÒÏÞÉÔÁÔÉ ÍÏÖÎÁ Ô¦ÌØËÉ ÐÒÏÓÔÉÊ ÆÁÊÌ ÞÉ ¦ÍÅÎÏ×ÁÎÉÊ ËÁÎÁÌ(pipe)"
+146 "%s: ÂÌÏËÕ×ÁÎÎÑ ×¦Ä ÞÉÔÁÎÎÑ ÎÅÍÏÖÌÉ×Å"
+147 "úÞÉÔÕÀ..."
+148 "%s: %lu ÒÑÄ˦×, %lu ÓÉÍ×Ï̦×"
+149 "îÅÍÁ¤ Ô¦ÎØÏ×ÉÈ ×¦ËÏÎ"
+150 "ëÏÍÁÎÄÁ script ÄÏÓÔÕÐÎÁ ÌÉÛÅ × ÒÅÖÉͦ vi"
+151 "îÅÍÁ ËÏÍÁÎÄÉ ÄÌÑ ×ÉËÏÎÁÎÎÑ"
+152 "ïÐæÀ shiftwidth ×ÓÔÁÎÏ×ÌÅÎÏ × 0"
+153 "ðÅÒÅÐÏ×ÎÅÎÎÑ Ì¦ÞÉÌØÎÉËÁ"
+154 "ãÉËÌ ×ÉËÏÎÁÎÏ ÎÅ ÄÏ Ë¦ÎÃÑ"
+155 "÷ËÁÚÁÎÏ ÒÅÇÕÌÑÒÎÉÊ ×ÉÒÁÚ; ÐÁÒÁÍÅÔÒ 'r' ÎÅ ÍÁ¤ ÓÅÎÓÕ"
+156 "ðÁÒÁÍÅÔÒÉ #, l ÔÁ p ÎÅ ÍÏÖÎÁ ËÏͦÎÕ×ÁÔÉ Ú ÐÁÒÁÍÅÔÒÏÍ 'c' × ÒÅÖÉͦ vi"
+157 "óЦ×ÐÁÄÁÎØ ÎÅÍÁ¤"
+158 "TÅÇ ×¦ÄÓÕÔΦÊ"
+159 "íÅÎÛÅ Î¦Ö %s ÚÁÐÉÓ¦× Õ ÓÔÅËÕ ÔÅǦ×; ×ÉËÏÒÉÓÔÁÊÔÅ :display t[ags]"
+160 "îÅÍÁ¤ ÆÁÊÌÕ %s × ÓÔÅËÕ ÔÅÇ¦× ÄÌÑ ÐÏ×ÅÒÎÅÎÎÑ; ×ÉËÏÒÉÓÔÁÊÔÅ :display t[ags]"
+161 "îÁÔÉÓΦÔØ ENTER ÄÌÑ ÐÒÏÄÏ×ÖÅÎÎÑ: "
+162 "%s: ÔÅÇ ÎÅ ÚÎÁÊÄÅÎÏ"
+163 "%s: Ú¦ÐÓÏ×ÁÎÉÊ ÔÅÇ × %s"
+164 "%s: ÎÏÍÅÒ ÒÑÄËÕ ÔÅÇÁ ÚÎÁÈÏÄÉÔØÓÑ ÚÁ ˦ÎÃÅÍ ÆÁÊÌÕ"
+165 "óÔÅË ÔÅÇ¦× ÐÏÒÏÖΦÊ"
+166 "%s: ÚÒÁÚÏË ÐÏÛÕËÕ ÎÅ ÚÎÁÊÄÅÎÏ"
+167 "úÁÌÉÛÉÌÏÓØ %d ÆÁÊÌ¦× ÄÌÑ ÒÅÄÁÇÕ×ÁÎÎÑ"
+168 "âÕÆÅÒ %s ÐÏÒÏÖΦÊ"
+169 "úͦÎÉÔÉ? [n]"
+170 "ðÅÒÅÒ×ÁÎÏ"
+171 "îÅÍÁ¤ ÂÕÆÅÒÕ ÄÌÑ ×ÉËÏÒÉÓÔÁÎÎÑ"
+172 "îÅÍÁ¤ ÐÏÐÅÒÅÄÎØÏÇÏ ÒÅÇÕÌÑÒÎÏÇÏ ×ÉÒÁÚÕ"
+173 "ëÏÍÁÎÄÁ %s ×ÉÍÁÇÁ¤ ×ÖÅ ÐÒÏÞÉÔÁÎÉÊ ÆÁÊÌ"
+174 "÷ÉËÏÒÉÓÔÁÎÎÑ: %s"
+175 "ëÏÍÁÎÄÁ visual ×ÉÍÁÇÁ¤ ×ÓÔÁÎÏ×ÌÅÎÎÑ ÏÐæ§ open"
+177 "ðÕÓÔÉÊ ÆÁÊÌ"
+178 "îÅÍÁ¤ ÐÏÐÅÒÅÄÎØÏÇÏ ÐÏÛÕËÕ F, f, T, ÞÉ t"
+179 "%s ÎÅ ÚÎÁÊÄÅÎÏ"
+180 "îÅÍÁ¤ ÐÏÐÅÒÅÄÎØÏÇÏ ÆÁÊÌÕ ÄÌÑ ÒÅÄÁÇÕ×ÁÎÎÑ"
+181 "ëÕÒÓÏÒ ÓÔϧÔØ ÎÅ ÎÁ ÃÉÆÒ¦"
+182 "OÔÒÉÍÁÎÅ ÞÉÓÌÏ ÎÁÄÔÏ ×ÅÌÉËÅ"
+183 "OÔÒÉÍÁÎÅ ÞÉÓÌÏ ÎÁÄÔÏ ÍÁÌÅ"
+184 "îÅÍÁ¤ צÄÐÏצÄÎÏÇÏ ÓÉÍ×ÏÌÕ × ÃØÏÍÕ ÒÑÄËÕ"
+185 "÷¦ÄÐÏצÄÎÉÊ ÓÉÍ×ÏÌ ÎÅ ÚÎÁÊÄÅÎÏ"
+186 "îÅÍÁ¤ ÓÉÍ×ÏÌ¦× ÄÌÑ ÚÁͦÎÉ"
+187 "îÅÍÁ¤ ¦ÎÛÏÇÏ ×¦ËÎÁ"
+188 "óÉÍ×ÏÌÉ Ð¦ÓÌÑ ÒÑÄËÕ ÄÌÑ ÐÏÛÕËÕ, ÚͦÝÅÎÎÑ ÒÑÄËÕ ÔÁ/ÞÉ ËÏÍÁÎÄÉ z"
+189 "îÅÍÁ¤ ÐÏÐÅÒÅÄÎØÏÇÏ ÚÒÁÚËÕ ÐÏÛÕËÕ"
+190 "ðÏÛÕË ÚÁ˦ÎÞÉ×ÓÑ ÎÁ ÐÏÞÁÔËÏ×¦Ê ÐÏÚÉæ§"
+191 "áÂÒÅצÁÔÕÒÁ ÐÅÒÅ×ÉÝÉÌÁ Ì¦Í¦Ô ÒÏÚÛÉÒÅÎÎÑ: ÓÉÍ×ÏÌÉ Ú'¦ÇÎÏÒÏ×ÁÎÏ"
+192 "îÅÄÏÚ×ÏÌÅÎÉÊ ÓÉÍ×ÏÌ: ÚÁÄÁÊÔÅ × ÄÕÖËÁÈ"
+193 "÷ÖÅ ÎÁ ÐÏÞÁÔËÕ ×ÓÔÁ×ËÉ"
+194 "îÅÍÁ¤ ÓÉÍ×ÏÌ¦× ÄÌÑ ×ÉÄÁÌÅÎÎÑ"
+195 "òÕÈ ÚÁ ˦ÎÅÃØ ÆÁÊÌÕ"
+196 "òÕÈ ÚÁ ˦ÎÅÃØ ÒÑÄËÕ"
+197 "ëÕÒÓÏÒ ÎÅ ÐÅÒÅͦÝÕ×Á×ÓÑ"
+198 "÷ÖÅ ÎÁ ÐÏÞÁÔËÕ ÆÁÊÌÕ"
+199 "òÕÈ ËÕÒÓÏÒÕ ÚÁ ÐÏÞÁÔÏË ÆÁÊÌÕ"
+200 "÷ÖÅ × ÐÅÒÛ¦Ê ËÏÌÏÎæ"
+201 "âÕÆÅÒ ÔÒÅÂÁ ×ËÁÚÕ×ÁÔÉ ÐÅÒÅÄ ËÏÍÁÎÄÏÀ"
+202 "÷ÖÅ ÎÁ ˦Îæ ÆÁÊÌÕ"
+203 "÷ÖÅ ÎÁ ˦Îæ ÒÑÄËÕ"
+204 "%s ÎÅ ËÏÍÁÎÄÁ Vi"
+205 "÷ÉËÏÒÉÓÔÁÎÎÑ: %s"
+206 "îÅÍÁ¤ ÓÉÍ×ÏÌ¦× ÄÌÑ ×ÉÄÁÌÅÎÎÑ"
+207 "ëÏÍÁÎÄÁ Q ×ÉÍÁÇÁ¤ ¦ÎÔÅÒÆÅÊÓÕ ex"
+208 "îÅÍÁ¤ ËÏÍÁÎÄÉ ÄÌÑ ÐÏ×ÔÏÒÅÎÎÑ"
+209 "æÁÊÌ ÐÕÓÔÉÊ"
+210 "ëÏÍÁÎÄÕ %s ÎÅ ÍÏÖÎÁ ×ÉËÏÒÉÓÔÁÔÉ ÄÌÑ ÐÅÒÅͦÝÅÎÎÑ"
+211 "÷ÖÅ × ËÏÍÁÎÄÎÏÍÕ ÒÅÖÉͦ"
+212 "ëÕÒÓÏÒ ÓÔϧÔØ ÎÅ ÎÁ ÓÌÏצ"
+214 "úÎÁÞÎÅÎÎÑ ÏÐæ§ Windows ÎÁÄÔÏ ×ÅÌÉËÅ, ÍÁËÓÉÍÕÍ = %u"
+215 "äÏÐÉÓÁÔÉ"
+216 "úͦÎÉÔÉ"
+217 "ëÏÍÁÎÄÁ"
+218 "÷ÓÔÁ×ÉÔÉ"
+219 "úÁͦÎÉÔÉ"
+220 "òÕÈ ËÕÒÓÏÒÕ ÚÁ ˦ÎÅÃØ ÜËÒÁÎÕ"
+221 "òÕÈ ËÕÒÓÏÒÕ ÚÁ ÐÏÞÁÔÏË ÜËÒÁÎÕ"
+222 "äÌÑ ÒÏÚÂÉÔÔÑ ×¦ËÎÏ ÍÁ¤ ͦÓÔÉÔÉ Â¦ÌØÛÅ Î¦Ö %d ÒÑÄ˦×"
+223 "ô¦ÎØÏ×ÉÈ ×¦ËÏÎ ÎÅÍÁ¤"
+224 "îÅÍÁ¤ Ô¦ÎØÏ×ÏÇÏ ×¦ËÎÁ Ú ÒÅÄÁÇÕ×ÁÎÎÑÍ ÆÁÊÌÕ %s"
+225 "îÅ ÍÏÖÎÁ ÚÒÏÂÉÔÉ Ô¦ÎØÏ×ÉÍ ¤ÄÉΊצËÎÏ"
+226 "÷¦ËÎÏ ÍÏÖÎÁ ÓÔÉÓÎÕÔÉ ÌÉÛÅ ÄÏ %d ÒÑÄ˦×"
+227 "÷¦ËÎÏ ÎÅ ÍÏÖÎÁ ÓÔÉÓÎÕÔÉ"
+228 "÷¦ËÎÏ ÎÅ ÍÏÖÎÁ ÒÏÚÛÉÒÉÔÉ"
+230 "ãŠצËÎÏ ÎÅ ÍÏÖÎÁ ÐÒÉÚÕÐÉÎÉÔÉ"
+231 "ðÅÒÅÒ×ÁÎÏ: צÄÏÂÒÁÖÅΦ ËÌÁצۦ Ú'¦ÇÎÏÒÏ×ÁÎÏ"
+232 "vi: ÔÉÍÞÁÓÏ×ÉÊ ÂÕÆÕÒ ÎÅ ×ÉצÌØÎÅÎÏ"
+233 "ãÅÊ ÔÉÐ ÔÅÒͦÎÁÌÕ ÎÅÍÁ¤ ËÌÁצۦ %s"
+234 "íÏÖÎÁ ×ËÁÚÁÔÉ ÌÉÛÅ ÏÄÉÎ ÂÕÆÅÒ"
+235 "þÉÓÌÏ Â¦ÌØÛÅ, Î¦Ö %lu"
+236 "ðÅÒÅÒ×ÁÎÏ"
+237 "îÅÍÏÖÌÕ ÓÔ×ÏÒÉÔÉ ÔÉÍÞÁÓÏ×ÉÊ ÆÁÊÌ"
+238 "õ÷áçá: %s ÓÐÅæÁÌØÎÉÊ ÆÁÊÌ"
+239 "%s ×ÖÅ ÚÁÂÌÏËÏ×ÁÎÏ, ÄÏÓÔÕÐÎÉÊ Ô¦ÌØËÉ ÄÌÑ ÞÉÔÁÎÎÑ"
+240 "%s: ÓÔÅÒÔÏ"
+241 "%s: ÚÁËÒÉÔÏ"
+242 "%s: ÓÔÅÒÔÏ"
+243 "%s: ÓÔÅÒÔÏ"
+244 "æÁÊÌ Ô¦ÌØËÉ ÄÌÑ ÞÉÔÁÎÎÑ, ÎÅ ÚÁÐÉÓÁÎÏ: ÷ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÏÂÈÏÄÕ"
+245 "æÁÊÌ Ô¦ÌØËÉ ÄÌÑ ÞÉÔÁÎÎÑ, ÎÅ ÚÁÐÉÓÁÎÏ"
+246 "%s ¦ÓÎÕ¤, ÎÅ ÚÁÐÉÓÁÎÏ; ×ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÏÂÈÏÄÕ"
+247 "%s ¦ÓÎÕ¤, ÎÅ ÚÁÐÉÓÁÎÏ"
+248 "÷ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÞÁÓÔËÏ×ÏÇÏ ÚÁÐÉÓÕ ÆÁÊÌÕ"
+249 "þÁÓÔÉÎÁ ÆÁÊÌÕ, ÆÁÊÌ ÎÅ ÚÁÐÉÓÁÎÏ"
+250 "%s: æÁÊÌ ÚͦÎÀ×Á×ÓÑ Ð¦ÚΦÛÅ, Î¦Ö ÃÑ ËÏЦÑ: ×ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÏÂÈÏÄÕ"
+251 "%s: æÁÊÌ ÚͦÎÀ×Á×ÓÑ Ð¦ÚΦÛÅ, Î¦Ö ÃÑ ËÏЦÑ"
+252 "%s: ÚÁÈÉÓÔ ×¦Ä ÚÁÐÉÓÕ ÎÅÄÏÓÔÕÐÎÉÊ"
+253 "úÁÐÉÓ..."
+254 "%s: õ÷áçá: ÆÁÊÌ ÏÂÒ¦ÚÁÎÏ"
+255 "÷ÖÅ ÎÁ ÐÅÒÛÏÍÕ ÔÅÇÕ × Ã¦Ê ÇÒÕЦ"
+256 "%s: ÎÏ×ÉÊ ÆÁÊÌ: %lu ÒÑÄ˦×, %lu ÓÉÍ×Ï̦×"
+257 "%s: %lu ÒÑÄ˦×, %lu ÓÉÍ×Ï̦×"
+258 "%s ÒÏÚÛÉÒÉ×ÓÑ × ÎÁÄÔÏ ×ÅÌÉËÕ Ë¦ÌØ˦ÓÔØ ¦ÍÅÎ ÆÁÊ̦×"
+259 "%s: ÓÐÅæÁÌØÎÉÊ ÆÁÊÌ"
+260 "%s: ÎÅ ÎÁÌÅÖÉÔØ ÷ÁÍ"
+261 "%s: ÄÏÓÔÕÐÎÉÊ ÎÅ ÌÉÛÅ ÷ÁÍ
+262 "æÁÊÌ ÍÏÄÉƦËÏ×ÁÎÏ Ð¦ÓÌÑ ÏÓÔÁÎÎØϧ ËÏÍÁÎÄÉ ÚÁÐÉÓÕ: ÚÂÅÒÅÖ¦ÔØ ÞÉ ×ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÏÂÈÏÄÕ"
+263 "æÁÊÌ ÍÏÄÉƦËÏ×ÁÎÏ Ð¦ÓÌÑ ÏÓÔÁÎÎØϧ ËÏÍÁÎÄÉ ÚÁÐÉÓÕ: ÚÂÅÒÅÖ¦ÔØ ÞÉ ×ÉËÏÒÉÓÔÁÊÔÅ :edit ÄÌÑ ÏÂÈÏÄÕ"
+264 "æÁÊÌ ÍÏÄÉƦËÏ×ÁÎÏ Ð¦ÓÌÑ ÏÓÔÁÎÎØϧ ËÏÍÁÎÄÉ ÚÁÐÉÓÕ: ÚÂÅÒÅÖ¦ÔØ ÞÉ ×ÉËÏÒÉÓÔÁÊÔÅ ! ÄÌÑ ÏÂÈÏÄÕ"
+265 "ôÉÍÞÁÓÏ×ÉÊ ÆÁÊÌ: ×ÉÈ¦Ä Ú¦ÔÒÅ ÚͦÎÉ"
+266 "æÁÊÌ Ô¦ÌØËÉ ÄÌÑ ÞÉÔÁÎÎÑ, ÚͦÎÉ ÎÅ ÚÁÐÉÛÕÔØÓÑ Á×ÔÏÍÁÔÉÞÎÏ"
+267 "úÁÐÉÓÉ ÐÏÞÁÔ¦ ÚÁÎÏ×Ï"
+268 "ð¦ÄÔ×ÅÒÄÖÕ¤ÔÅ? [ynq]"
+269 "îÁÔÉÓΦÔØ ENTER ÄÌÑ ÐÒÏÄÏ×ÖÅÎÎÑ: "
+270 "îÁÔÉÓΦÔØ ENTER ÄÌÑ ÐÒÏÄÏ×ÖÅÎÎÑ [: ÄÌÑ ¦ÎÛÉÈ ËÏÍÁÎÄ] "
+271 "îÁÔÉÓΦÔØ ENTER ÄÌÑ ÐÒÏÄÏ×ÖÅÎÎÑ [q ÄÌÑ ×ÉÈÏÄÕ]: "
+272 "TÁËÁ ÆÏÒÍÁ %s ×ÉÍÁÇÁ¤ ¦ÎÔÅÒÆÅÊÓÕ ex"
+273 "÷ÈÏÄÉÍ × ÒÅÖÉÍ ××ÅÄÅÎÎÑ ex"
+274 "úÂ¦Ê ËÏÍÁÎÄÉ, ÆÁÊÌ ÎÅ ÐÒÏÞÉÔÁÎÏ"
+275 "ðÒÏÄÏ×ÖÉÔÉ?"
+276 "îÅÏÞ¦ËÕ×ÁÎÁ ÓÉÍ×ÏÌØÎÁ ÐÏĦÑ"
+277 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ Ë¦ÎÃÑ ÆÁÊÌÕ"
+278 "îÅÍÁ¤ ÓЦ×ÐÁÄÁÎØ ÚÁ ÚÁÐÉÔÏÍ"
+279 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ ÐÅÒÅÒÉ×ÁÎÎÑ"
+280 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ ×ÉÈÏÄÕ"
+281 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ ÐÅÒÅÒÉÓÏ×ËÉ"
+282 "÷ÖÅ ÎÁ ÏÓÔÁÎÎØÍÕ ôÅÇÕ × Ã¦Ê ÇÒÕЦ"
+283 "ëÏÍÁÎÄÁ %s ×ÉÍÁÇÁ¤ ¦ÎÔÅÒÆÅÊÓÕ ex"
+284 "TÁËÁ ÆÏÒÍÁ %s ÎÅ ÄÏÚ×ÏÌѤÔØÓÑ ÐÒÉ ×ÓÔÁÎÏ×ÌÅÎ¦Ê ÏÐæ§ secure edit"
+285 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ ÒÑÄËÕ"
+286 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ ÔÁÊÍ-ÁÕÔÕ"
+287 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ ÚÁÐÉÓÕ"
+289 "Shell'¦×ÓËÅ ÄÏÐÏ×ÎÅÎÎÑ ÎÅ ÄÏÚ×ÏÌѤÔØÓÑ ÐÒÉ ×ÓÔÁÎÏ×ÌÅÎ¦Ê ÏÐæ§ secure edit"
+290 "ëÏÍÁÎÄÁ %s ÎÅ ÄÏÚ×ÏÌѤÔØÓÑ ÐÒÉ ×ÓÔÁÎÏ×ÌÅÎ¦Ê ÏÐæ§ secure edit"
+291 "set: ÏÐæÀ %s ÎÅÍÏÖÎÁ ×ÉÓÔÁ×ÉÔÉ ×ÉÍËÎÅÎÏÀ"
+292 "åËÒÁÎ ÎÁÄÔÏ ÍÁÌÉÊ."
+293 "ÄÏÄÁÎÏ"
+294 "ÚͦÎÅÎÏ"
+295 "ÓÔÅÒÔÏ"
+296 "ÏÂ'¤ÄÎÁÎÏ"
+297 "ÐÅÒÅͦÝÅÎÏ"
+298 "ÚÄ×ÉÎÕÔÏ"
+299 "×ÓÔÁ×ÌÅÎÏ"
+300 "ÒÑÄÏË"
+301 "ÒÑÄ˦×"
+302 "Vi ÚÁ×ÁÎÔÁÖÅÎÏ ÂÅÚ ¦ÎÔÅÒÐÒÅÔÁÔÏÒÁ Tcl"
+303 "æÁÊÌ ÍÏÄÉƦËÏ×ÁÎÏ Ð¦ÓÌÑ ÏÓÔÁÎÎØϧ ËÏÍÁÎÄÉ ÚÁÐÉÓÕ."
+304 "îÅ×ÄÁÞÁ shell'¦×ÓØËÏÇÏ ÄÏÐÏ×ÎÅÎÎÑ"
+305 "OÐæ§ ÒÅÄÁÇÕ×ÁÎÎÑ %s ÎÅ ×ËÁÚÁÎÏ"
+306 "Vi ÚÁ×ÁÎÔÁÖÅÎÏ ÂÅÚ ¦ÎÔÅÒÐÒÅÔÁÔÏÒÁ Perl"
+307 "îÅÍÁ¤ ËÏÍÁÎÄÉ ex ÄÌÑ ×ÉËÏÎÁÎÎÑ"
+308 "îÁÔÉÓΦÔØ ENTER ÝÏ ×ÉËÏÎÁÔÉ ËÏÍÁÎÄÕ, q ÝÏ ×ÉÊÔÉ"
+309 "÷×ÅĦÔØ 'cscope help' ÄÌÑ ¦ÎÆÏÒÍÁæ§"
+310 "îÅÍÁ¤ cscope Ú'¤ÄÎÁÎÎØ"
+311 "%s: ÎÅצÄÏÍÉÊ ÔÉÐ ÐÏÛÕËÕ: ×ÉËÏÒÉÓÔÏ×ÕÊÔÅ ÏÄÉÎ Ú %s"
+312 "%d: ÎÅÍÁ¤ ÔÁËϧ ÓÅÓ¦§ cscope"
+313 "set: ÏÐæÀ %s ÎÅÍÏÖÎÁ ×ÉÓÔÁ×ÉÔÉ ÕצÍËÎÅÎÏÀ"
+314 "set: ÏÐæÀ %s ÎÅÍÏÖÎÁ ×ÉÓÔÁ×ÉÔÉ × 0"
+315 "%s: ÄÏÄÁÎÏ: %lu ÒÑÄ˦×, %lu ÓÉÍ×Ï̦×"
+316 "îÅÏÞ¦ËÕ×ÁÎÁ ÐÏÄ¦Ñ ÚͦÎÉ ÒÏÚͦÒÕ"
+317 "%d ÆÁÊÌ¦× ÄÌÑ ÒÅÄÁÇÕ×ÁÎÎÑ"
diff --git a/catalog/uk_UA.KOI8-U.owner b/catalog/uk_UA.KOI8-U.owner
new file mode 100644
index 000000000000..11719baa95ff
--- /dev/null
+++ b/catalog/uk_UA.KOI8-U.owner
@@ -0,0 +1 @@
+Olexander Kunytsa aka Cawko Xakep <xakep@snark.ukma.kiev.ua>
diff --git a/catalog/zh_CN.GB2312.base b/catalog/zh_CN.GB2312.base
new file mode 100644
index 000000000000..5cd8dba89106
--- /dev/null
+++ b/catalog/zh_CN.GB2312.base
@@ -0,0 +1,311 @@
+002 "Ð㤶ÈÒç³ö"
+003 "ÎÞ·¨É¾³ýµÚ %lu ÐÐ"
+004 "ÎÞ·¨ÏòµÚ %lu ÐÐ×·¼Ó"
+005 "ÎÞ·¨ÏòµÚ %lu ÐвåÈë"
+006 "ÎÞ·¨´æ´¢µÚ %lu ÐÐ"
+007 "ÎÞ·¨»ñµÃ×îºóÒ»ÐÐ"
+008 "´íÎó£ºÎÞ·¨»ñÈ¡µÚ %lu ÐÐ"
+009 "ÈÕÖ¾Îļþ"
+010 "ÈÕ־δ¼Ç¼£¬ÎÞ·¨³·Ïú"
+011 "δ×öÐ޸ģ¬ÎÞ·¨³·Ïú"
+012 "ÈÕ־δ¼Ç¼£¬ÎÞ·¨³·Ïú"
+013 "ÈÕ־δ¼Ç¼£¬ÎÞ·¨»Ø¹ö"
+014 "δ×öÐ޸ģ¬ÎÞ·¨ÖØ×ö"
+015 "%s/%d: ÈÕÖ¾´íÎó"
+016 "Vi µÄ±ê×¼ÊäÈëºÍÊä³ö±ØÐëÊÇÖÕ¶Ë"
+017 "±ê¼Ç %s: δÉèÖÃ"
+018 "±ê¼Ç %s: ¸ÃÐб»É¾³ý"
+019 "±ê¼Ç %s: ¹â±êλÖò»´æÔÚ"
+020 "´íÎó£º"
+021 "ÐÂÎļþ"
+022 "ÎļþÃû±ä¸ü"
+023 "ÒÑÐÞ¸Ä"
+024 "δÐÞ¸Ä"
+025 "ÒѽâËø"
+026 "Ö»¶Á"
+027 "µÚ %lu ÐУ¯¹² %lu ÐÐ [%ld%%]"
+028 "¿ÕÎļþ"
+029 "µÚ %lu ÐÐ"
+030 "Îļþ %s ²»ÊÇÏûϢĿ¼"
+031 "ÎÞ·¨ÉèÖÃÑ¡Ïî %s µÄĬÈÏÖµ"
+032 "Ó÷¨ %s"
+033 "set: ²»´æÔÚÑ¡Ïî %s£»Óà 'set all' ²é¿´ËùÓÐÑ¡ÏîµÄÖµ"
+034 "set: Ñ¡Ïî [no]%s ²»½ÓÊܸ³Öµ"
+035 "set: Ñ¡Ïî %s ²»ÊÇ¿ª¹Ø"
+036 "set: Ñ¡Ïî %s: %s"
+037 "set: Ñ¡Ïî %s: %s: ÖµÒç³ö"
+038 "set: Ñ¡Ïî %s: %s ÊÇÒ»¸ö·Ç·¨Êý×Ö"
+039 "set: Ñ¡Ïî %s ²»ÊÇ¿ª¹Ø"
+040 "ÆÁĻ̫խ£¬ÁпíСÓÚ %d"
+041 "ÆÁĻ̫¿í£¬Áпí´óÓÚ %d"
+042 "ÆÁĻ̫°«£¬ÐиßСÓÚ %d"
+043 "ÆÁĻ̫¸ß£¬ÐиߴóÓÚ %d"
+044 "lisp Ñ¡ÏîδʵÏÖ"
+045 "ÏûϢδ¹Ø±Õ£º%s"
+046 "ÏûϢδ´ò¿ª£º%s"
+047 "%s Ñ¡Ïî±ØÐëÿÁ½¸ö×Ö·ûÒ»×é"
+053 "ĬÈÏ»º³åÇøΪ¿Õ"
+054 "»º³åÇø %s Ϊ¿Õ"
+055 "ÎļþÃûÖÐÓл»ÐеÄÎļþÊÇÎÞ·¨»Ö¸´µÄ"
+056 "Ò»µ©»á»°Ê§°Ü£¬ÐÞ¸ÄÎÞ·¨»Ö¸´"
+057 "ÕýÔÚ±¸·ÝÎļþ¡­¡­"
+058 "±£´æʧ°Ü£º%s"
+059 "Ò»µ©»á»°Ê§°Ü£¬ÐÞ¸ÄÎÞ·¨»Ö¸´"
+060 "Îļþ±¸·Ýʧ°Ü£º%s"
+061 "ÕýÔÚ±¸·ÝÎļþ¡­¡­"
+062 "ID Ϊ %u µÄÓû§Î´ÕÒµ½"
+063 "ÎÞ·¨¸ø»Ö¸´Îļþ¼ÓËø"
+064 "»Ö¸´Îļþ»º³åÇøÒç³ö"
+065 "»Ö¸´Îļþ"
+066 "%s: »Ö¸´Îļþ¸ñʽÒì³£"
+067 "%s: »Ö¸´Îļþ¸ñʽÒì³£"
+068 "²»´æÔÚÃûΪ %s µÄ£¬¿É¶Á²¢ÐèÒª»Ö¸´µÄÎļþ"
+069 "´æÔÚ´ËÎļþµÄ¾É°æ±¾ÐèÒªÄú»Ö¸´"
+070 "´æÔÚÆäËüÐèÒªÄú»Ö¸´µÄÎļþ"
+071 "Óʼþδ·¢³ö£º%s"
+072 "ÎļþΪ¿Õ£¬ÎÞ·¨ËÑË÷"
+073 "µ½´ïÎļþβ£¬Î´ÕÒµ½Ä£Ê½"
+074 "ûÓÐÉÏÒ»¸öËÑË÷ģʽ"
+075 "ģʽδÕÒµ½"
+076 "µ½´ïÎļþÍ·£¬Î´ÕÒµ½Ä£Ê½"
+077 "ËÑË÷»Øת"
+078 "ÕýÔÚËÑË÷¡­¡­"
+079 "δÕÒµ½²»¿É´òÓ¡×Ö·û"
+080 "ÃüÁîÃû²»Ã÷"
+082 "%s: ÃüÁîÔÚ ex ģʽϲ»¿ÉÓÃ"
+083 "ÃüÁî¼ÆÊý²»¿ÉΪ 0"
+084 "%s: ´íÎóµÄÐÐÃèÊö"
+085 "ÄÚ²¿Óï·¨±í´íÎó (%s: %s)"
+086 "Ó÷¨£º%s"
+087 "%s: ÁÙʱ»º³åÇøδÊÍ·Å"
+088 "ÐÞÊηûÆ«ÒÆÁ¿ÔÚµÚÒ»ÐÐ֮ǰ"
+089 "ÐÞÊηûÆ«ÒÆÁ¿³¬¹ý×îºóÒ»ÐÐ"
+090 "Îļþ£¯ÆÁÄ»¸Ä±äʱÓдø·¶Î§µÄ @ ÃüÁîÕýÔÚÔËÐÐ"
+091 "Îļþ£¯ÆÁÄ»¸Ä±äʱÓÐÈ«¾ÖÃüÁv ÃüÁîÕýÔÚÔËÐÐ"
+092 "Ex ÃüÁîʧ°Ü£ºµÈ´ýÖеÄÃüÁîÒѶªÆú"
+093 "Ex ÃüÁîʧ°Ü£º¼üÓ³ÉäÒѶªÆú"
+094 "µÚ¶þµØַСÓÚµÚÒ»µØÖ·"
+095 "δÌṩ±ê¼ÇÃû"
+096 "\\ ûÓиúÔÚ / »ò ? ºóÃæ"
+097 "ÒýÓÃÁËСÓÚ 0 µÄÐкÅ"
+098 "%s ÃüÁî²»Ã÷"
+099 "µØÖ·ÖµÒç³ö"
+100 "µØÖ·ÖµÏÂÒç"
+101 "·Ç·¨µÄµØÖ·×éºÏ"
+102 "·Ç·¨µØÖ·£ºÎļþÖ»ÓÐ %lu ÐÐ"
+103 "·Ç·¨µØÖ·£ºÎļþΪ¿Õ"
+104 "ÃüÁî %s ²»ÔÊÐíµØַΪ 0"
+105 "ûÓпÉÏÔʾµÄËõд"
+106 "Ëõд±ØÐëÒÔ¡¸µ¥´Ê¡¹×Ö·û½áÊø"
+107 "Ëõд²»ÄÜ°üº¬ÖƱí·û»ò¿Õ¸ñ"
+108 "Ëõд²»ÄÜÔÚ½áβ֮ÍâµÄµØ·½»ìÓõ¥´Ê£¯·Çµ¥´Ê×Ö·û"
+109 "\"%s\" ²»ÊÇËõд"
+110 "Vi ÃüÁîʧ°Ü£º¼üÓ³ÉäÒѶªÆú"
+111 "ûÓÐÊ£ÓàµÄ´ý±à¼­Îļþ"
+112 "ûÓÐÉÏÒ»¸ö´ý±à¼­Îļþ"
+113 "ûÓÐÉÏÒ»¸öÐèÖØб༭µÄÎļþ"
+114 "ûÓпÉÏÔʾµÄÎļþÁбí"
+115 "ȱÉÙÓÃÓÚÌæ»» \"!\" µÄÉÏÒ»ÌõÃüÁî"
+116 "ȱÉÙÓÃÓÚÌæ»» %% µÄÎļþÃû"
+117 "ȱÉÙÓÃÓÚÌæ»» # µÄÎļþÃû"
+118 "´íÎó£ºexecl: %s"
+119 "ÊäÈ룯Êä³ö´íÎó£º%s"
+120 "ÎļþÔÚÉÏÒ»´ÎÍêÕûдÈëºó±»Ð޸ģ»Ð´ÈëÎļþ£¬»òʹÓà ! Ç¿ÖÆÇл»Ä¿Â¼"
+121 "ÎÞ·¨ÕÒµ½Óû§ÆðʼĿ¼"
+122 "еĵ±Ç°Ä¿Â¼£º%s"
+123 "ûÓпÉÏÔʾµÄ¼ôÇлº³åÇø"
+124 "%s ÃüÁî²»Äܱ»ÓÃ×÷È«¾ÖÃüÁî»ò v ÃüÁîµÄÒ»²¿·Ö"
+125 "%s/%s: δÒýÈ룺²»ÊôÓÚÄú»ò¸ùÓû§"
+126 "%s/%s: δÒýÈ룺²»ÊôÓÚÄú"
+127 "%s/%s: δÒýÈ룺¿ÉÒÔ±»ÎļþÊôÖ÷ÒÔÍâµÄÓû§Ð´Èë"
+128 "%s: δÒýÈ룺²»ÊôÓÚÄú»ò¸ùÓû§"
+129 "%s: δÒýÈ룺²»ÊôÓÚÄú"
+130 "%s: δÒýÈ룺¿ÉÒÔ±»ÎļþÊôÖ÷ÒÔÍâµÄÓû§Ð´Èë"
+131 "ȱÉÙ¿ÉÒԺϲ¢µÄÐÐ"
+132 "ȱÉÙÊäÈëÓ³Éä"
+133 "ȱÉÙÃüÁîÓ³Éä"
+134 "%s ×Ö·û²»Äܱ»ÖØÐÂÓ³Éä"
+135 "\"%s\" Ŀǰδ±»Ó³Éä"
+136 "±ê¼ÇÃû±ØÐëÊǵ¥¸ö×Ö·û"
+137 "%s ÒÑ´æÔÚ£¬Î´Ð´È룻Óà ! ¸²¸ÇÎļþ"
+138 "н¨ exrc Îļþ£º%s"
+139 "Ä¿±êÐÐÔÚÒƶ¯·¶Î§Ö®ÄÚ"
+140 "open ÒªÇó¿ªÆô open Ñ¡Ïî"
+141 "open ÃüÁîδʵÏÖ"
+142 "ÎÞ·¨±£³Ö´ËÎļþ"
+143 "ÎļþÒѱ£³Ö"
+144 "%s: Õ¹¿ªµÄÎļþÃû¹ý¶à"
+145 "Ö»ÄܶÁÈ¡³£¹æÎļþºÍ¾ßÃû¹ÜµÀ"
+146 "%s: ¶ÁËø²»¿ÉÓÃ"
+147 "ÕýÔÚ¶ÁÈ¡¡­¡­"
+148 "%s: %lu ÐУ¬%lu ¸ö×Ö·û"
+149 "ûÓпÉÏÔʾµÄºǫ́ÆÁÄ»"
+150 "script ÃüÁî½öÔÚ vi ģʽÏ¿ÉÓÃ"
+151 "ûÓÐÒªÖ´ÐеÄÃüÁî"
+152 "shiftwidth Ñ¡Ïî±»ÉèΪ 0"
+153 "ÃüÁî¼ÆÊýÒç³ö"
+154 "ÃüÁî¼ÆÊýÏÂÒç"
+155 "ÕýÔò±í´ïʽÒÑÖ¸¶¨£»r ÐÞÊηûÎÞЧ"
+156 "#, l ºÍ p ÐÞÊηûÔÚ vi ģʽϲ»ÄÜÓë c ÐÞÊηû×éºÏ"
+157 "δÕÒµ½Æ¥Åä"
+158 "ûÓÐÉÏÒ»´Î½øÈëµÄ tag"
+159 "tags Õ»ÉϵļǼÉÙÓÚ %s Ìõ£»Óà :display t[ags] ÏÔʾËüÃÇ"
+160 "tags Õ»Éϲ»´æÔÚÎļþ %s£¬ÎÞ·¨·µ»Ø£»Óà :display t[ags] ²é¿´"
+161 "°´»Ø³µ¼ü¼ÌÐø£º"
+162 "%s: tag δÕÒµ½"
+163 "%s: Ëð»µµÄ tag ÔÚ %s ÖÐ"
+164 "%s: tag µÄÐкų¬¹ýÁËÎļþβ"
+165 "tags ջΪ¿Õ"
+166 "%s: ËÑË÷ģʽδÕÒµ½"
+167 "»¹ÓÐ %d ¸ö´ý±à¼­Îļþ"
+168 "»º³åÇø %s Ϊ¿Õ"
+169 "È·ÈÏÐ޸ģ¿[n]"
+170 "ÒÑÖжÏ"
+171 "ûÓÐÉÏÒ»¸ö¿É¹©Ö´ÐеĻº³åÇø"
+172 "ûÓÐÉÏÒ»ÌõÕýÔò±í´ïʽ"
+173 "%s ÒªÇó´æÔÚÒ»¸öÒѶÁÈëµÄÎļþ"
+174 "Ó÷¨£º%s"
+175 "visual ÃüÁîÒªÇó¿ªÆô open Ñ¡Ïî"
+177 "¿ÕÎļþ"
+178 "ûÓÐÉÏÒ»´Î F, f, T »ò t ËÑË÷"
+179 "%s δÕÒµ½"
+180 "ûÓÐÉÏÒ»¸ö´ý±à¼­Îļþ"
+181 "¹â±ê²»ÔÚÊý×ÖÉÏ"
+182 "½á¹ûÊý×Ö¹ý´ó"
+183 "½á¹ûÊý×Ö¹ýС"
+184 "ÕâÒ»ÐÐÉÏûÓÐÆ¥ÅäµÄ×Ö·û"
+185 "Æ¥Åä×Ö·ûδÕÒµ½"
+186 "ûÓпÉÌæ»»µÄ×Ö·û"
+187 "ûÓÐÆäËüÆÁÄ»¿ÉÒÔÇл»"
+188 "ÔÚËÑË÷×Ö·û´®¡¢ÐÐÆ«ÒÆÁ¿»ò z ÃüÁîÖ®ºóÓжàÓà×Ö·û"
+189 "ûÓÐÉÏÒ»¸öËÑË÷ģʽ"
+190 "ËÑË÷»Øתµ½Á˳õʼλÖÃ"
+191 "Ëõдչ¿ª³¬¹ýÏÞÖÆ£º×Ö·ûÒѶªÆú"
+192 "·Ç·¨×Ö·û£»ÓÃÒýºÅÀ¨ÆðÀ´ÔÙÊäÈë"
+193 "Òѵ½²åÈëµãµÄ¿ªÊ¼"
+194 "ûÓпɲÁ³ýµÄÊ£Óà×Ö·û"
+195 "Òƶ¯³¬¹ýÎļþβ"
+196 "Òƶ¯³¬¹ýÐÐÄ©"
+197 "¹â±êδÒƶ¯"
+198 "Òѵ½ÎļþÍ·"
+199 "Òƶ¯³¬¹ýÎļþÍ·"
+200 "ÒÑλÓÚµÚÒ»ÁÐ"
+201 "»º³åÇøÓ¦ÔÚÃüÁîÇ°Ö¸¶¨"
+202 "Òѵ½Îļþβ"
+203 "Òѵ½ÐÐÄ©"
+204 "%s ²»ÊÇ vi ÃüÁî"
+205 "Ó÷¨ %s"
+206 "ûÓпÉɾ³ýµÄ×Ö·û"
+207 "Q ÃüÁîÐèÒª ex Öն˽çÃæ"
+208 "ûÓпÉÖظ´µÄÃüÁî"
+209 "ÎļþΪ¿Õ"
+210 "%s ²»Äܱ»ÓÃ×÷Òƶ¯ÃüÁî"
+211 "ÒÑ´¦ÓÚÃüÁîģʽ"
+212 "¹â±ê²»ÔÚµ¥´ÊÉÏ"
+214 "´°¿ÚÑ¡ÏîµÄÖµ¹ý´ó£¬×î´óÖµ %u"
+215 "×·¼Ó"
+216 "ÐÞ¸Ä"
+217 "ÃüÁî"
+218 "²åÈë"
+219 "Ìæ»»"
+220 "Òƶ¯³¬¹ýÆÁÄ»ÖÕµã"
+221 "Òƶ¯³¬¹ýÆÁÄ»Æðµã"
+222 "·ÖÆÁÐèÒª¶àÓÚ %d ÐÐ"
+223 "ûÓкǫ́ÆÁÄ»"
+224 "²»´æÔÚÕýÔڱ༭Îļþ %s µÄºǫ́ÆÁÄ»"
+225 "²»ÄÜ°ÑÄúΨһµÄÆÁÄ»ÖÃÓÚºǫ́"
+226 "ÆÁĻֻÄÜÊÕËõµ½ %d ÐÐ"
+227 "ÆÁÄ»²»ÄÜÊÕËõ"
+228 "ÆÁÄ»²»ÄÜÔö¸ß"
+230 "²»ÄܹÒÆð´ËÆÁÄ»"
+231 "ÒÑÖжϣº¼üÓ³ÉäÒѶªÆú"
+232 "vi: ÁÙʱ»º³åÇøδÊÍ·Å"
+233 "´ËÖÕ¶ËûÓÐ %s ¼ü"
+234 "Ö»ÄÜÖ¸¶¨Ò»¸ö»º³åÇø"
+235 "Êý×Ö´óÓÚ %lu"
+236 "ÒÑÖжÏ"
+237 "ÎÞ·¨´´½¨ÁÙʱÎļþ"
+238 "¾¯¸æ£º%s ²»Êdz£¹æÎļþ"
+239 "%s ÒѼÓËø£¬»á»°ÎªÖ»¶Á"
+240 "%s: ÒƳý"
+241 "%s: ¹Ø±Õ"
+242 "%s: ÒƳý"
+243 "%s: ÒƳý"
+244 "Ö»¶ÁÎļþ£¬Î´Ð´È룻Óà ! Ç¿ÖÆдÈë"
+245 "Ö»¶ÁÎļþ£¬Î´Ð´Èë"
+246 "%s ÒÑ´æÔÚ£¬Î´Ð´È룻Óà ! ¸²¸ÇÎļþ"
+247 "%s ÒÑ´æÔÚ£¬Î´Ð´Èë"
+248 "ÊÇÒÑ´æÔÚÎļþµÄÒ»²¿·Ö£¬Î´Ð´È룻Óà ! Ç¿ÖÆдÈë"
+249 "ÊÇÒÑ´æÔÚÎļþµÄÒ»²¿·Ö£¬Î´Ð´Èë"
+250 "%s: Îļþ±»Ð޸ģ¬ÐÂÓÚµ±Ç°¿½±´£»Óà ! Ç¿ÖÆдÈë"
+251 "%s: Îļþ±»Ð޸ģ¬ÐÂÓÚµ±Ç°¿½±´"
+252 "%s: дËø²»¿ÉÓÃ"
+253 "ÕýÔÚдÈë¡­¡­"
+254 "%s: ¾¯¸æ£ºÎļþ±»½Ø¶Ï"
+255 "ÒÑλÓÚÕâ×é tags ÖеĵÚÒ»¸ö"
+256 "%s: ÐÂÎļþ£º%lu ÐУ¬%lu ¸ö×Ö·û"
+257 "%s: %lu ÐУ¬%lu ¸ö×Ö·û"
+258 "%s: Õ¹¿ªµÄÎļþÃû¹ý¶à"
+259 "%s: ²»Êdz£¹æÎļþ"
+260 "%s: ²»ÊôÓÚÄú"
+261 "%s: ¿É±»ÎļþÊôÖ÷ÒÔÍâµÄÓû§·ÃÎÊ"
+262 "ÎļþÔÚÉÏÒ»´ÎÍêÕûдÈëºó±»Ð޸ģ»Ð´ÈëÎļþ£¬»òʹÓà ! Ç¿ÖÆÔØÈë"
+263 "ÎļþÔÚÉÏÒ»´ÎÍêÕûдÈëºó±»Ð޸ģ»Ð´ÈëÎļþ£¬»òʹÓà :edit! Ç¿ÖƱ༭"
+264 "ÎļþÔÚÉÏÒ»´ÎÍêÕûдÈëºó±»Ð޸ģ»Ð´ÈëÎļþ£¬»òʹÓà ! Ç¿ÖÆÖ´ÐÐ"
+265 "ÁÙʱÎļþ£¬Í˳ö½«¶ªÆúÈ«²¿ÐÞ¸Ä"
+266 "ÎļþÖ»¶Á£¬ÐÞ¸Äδ±»×Ô¶¯Ð´Èë"
+267 "ÈÕÖ¾ÖØÆô"
+268 "È·ÈÏ£¿[ynq]"
+269 "°´ÈÎÒâ¼ü¼ÌÐø£º"
+270 "°´ÈÎÒâ¼ü¼ÌÐø£Û°´ : ¼üÊäÈë ex ÃüÁî£Ý£º"
+271 "°´ÈÎÒâ¼ü¼ÌÐø£Û°´ q ¼üÍƳö£Ý£º"
+272 "¸ÃÐÎʽµÄ %s ÃüÁîÐèÒª ex Öն˽çÃæ"
+273 "½øÈë ex ÊäÈëģʽ"
+274 "ÃüÁîʧ°Ü£¬ÉÐδ¶ÁÈëÎļþ"
+275 " ¼ÌÐø£¿"
+276 "ÒâÍâµÄ×Ö·ûʼþ"
+277 "ÒÔÍâµÄÎļþβʼþ"
+278 "²éѯδÕÒµ½Æ¥Åä"
+279 "ÒâÍâµÄÖжÏʼþ"
+280 "ÒâÍâµÄÍ˳öʼþ"
+281 "ÒâÍâµÄÖØ»æʼþ"
+282 "ÒÑλÓÚÕâ×é tags ÖеÄ×îºóÒ»¸ö"
+283 "%s ÃüÁîÐèÒª ex Öն˽çÃæ"
+284 "secure ±à¼­Ñ¡ÏÆôʱ²»Ö§³Ö¸ÃÐÎʽµÄ %s ÃüÁî"
+285 "ÒâÍâµÄ×Ö·û´®Ê¼þ"
+286 "ÒâÍâµÄ³¬Ê±Ê¼þ"
+287 "ÒâÍâµÄдÈëʼþ"
+288 "·ÖÆÁÐèÒª¶àÓÚ %d ÁÐ"
+289 "secure ±à¼­Ñ¡ÏÆôʱ²»Ö§³Ö shell Õ¹¿ª"
+290 "secure ±à¼­Ñ¡ÏÆôʱ²»Ö§³Ö %s ÃüÁî"
+291 "set: Ñ¡Ïî %s ²»ÄܹرÕ"
+292 "ÏÔʾ¿Õ¼ä̫С"
+293 "ÒÑÌí¼Ó"
+294 "ÒÑÐÞ¸Ä"
+295 "ÒÑɾ³ý"
+296 "ÒѺϲ¢"
+297 "ÒÑÒƶ¯"
+298 "ÒÑÆ«ÒÆ"
+299 "ÒѸ´ÖÆ"
+300 "ÐÐ"
+301 "ÐÐ"
+303 "ÎļþÔÚÉÏÒ»´ÎдÈëºó±»ÐÞ¸Ä"
+304 "Shell Õ¹¿ªÊ§°Ü"
+305 "δָ¶¨ %s ±à¼­Ñ¡Ïî"
+307 "ûÓÐÒªÖ´ÐÐµÄ ex ÃüÁî"
+308 "¼üÈë»Ø³µÖ´ÐÐÒ»ÌõÃüÁ:q Í˳ö"
+309 "ʹÓà \"cscope help\" ²é¿´°ïÖú"
+310 "ûÓÐÕýÔÚÔËÐÐµÄ cscope Á¬½Ó"
+311 "%s: ËÑË÷ÀàÐͲ»Ã÷£ºÊ¹Óà %s ÖеÄÒ»¸ö"
+312 "%d: ÎÞ´Ë cscope »á»°"
+313 "set: Ñ¡Ïî %s ¾ø¶Ô²»ÄÜ¿ªÆô"
+314 "set: Ñ¡Ïî %s ¾ø¶Ô²»Äܱ»ÉèΪ 0"
+315 "%s: ÒÑ×·¼Ó£º%lu ÐУ¬%lu ¸ö×Ö·û"
+316 "ÒâÍâµÄ´óСµ÷Õûʼþ"
+317 "%d ¸ö´ý±à¼­µÄÎļþ"
+319 "%d ¸öºǫ́ÆÁÄ»£»Óà :display ÁгöËüÃÇ"
+320 "¹â±êλÖò»Ã÷"
+321 "²»Ö§³ÖÎļþ±àÂëת»»"
+322 "²»Ö§³ÖÊäÈë±àÂëת»»"
+323 "ÎÞЧÊäÈ룬ÒѽضÏ"
+324 "µÚ %d ÐÐÉÏÓÐת»»´íÎó"
diff --git a/catalog/zh_CN.GB2312.owner b/catalog/zh_CN.GB2312.owner
new file mode 100644
index 000000000000..8052caca3b63
--- /dev/null
+++ b/catalog/zh_CN.GB2312.owner
@@ -0,0 +1 @@
+Zhihao Yuan <lichray@gmail.com>
diff --git a/cl/README.signal b/cl/README.signal
index 7faa45673b75..18b3d1451b00 100644
--- a/cl/README.signal
+++ b/cl/README.signal
@@ -1,4 +1,4 @@
-# @(#)README.signal 10.1 (Berkeley) 6/23/95
+# $Id: README.signal,v 10.1 1995/06/23 10:28:17 bostic Exp $
There are six (normally) asynchronous actions about which vi cares:
SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGTSTP and SIGWINCH.
diff --git a/cl/cl.h b/cl/cl.h
index 2ef2b8d1f81e..c84ef88428c0 100644
--- a/cl/cl.h
+++ b/cl/cl.h
@@ -6,11 +6,24 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)cl.h 10.19 (Berkeley) 9/24/96
+ * $Id: cl.h,v 10.34 2011/08/15 20:07:32 zy Exp $
*/
+#ifdef USE_WIDECHAR
+#define _XOPEN_SOURCE_EXTENDED
+#endif
+#ifdef HAVE_NCURSES_H
+#include <ncurses.h>
+#else
+#include <curses.h>
+#endif
+
typedef struct _cl_private {
- CHAR_T ibuf[256]; /* Input keys. */
+ char ibuf[256]; /* Input keys. */
+
+ size_t skip; /* Remaining keys. */
+
+ CONVWIN cw; /* Conversion buffer. */
int eof_count; /* EOF count. */
@@ -24,6 +37,10 @@ typedef struct _cl_private {
char *rmso, *smso; /* Inverse video terminal strings. */
char *smcup, *rmcup; /* Terminal start/stop strings. */
+ char *oname; /* Original screen window name. */
+
+ SCR *focus; /* Screen that has the "focus". */
+
int killersig; /* Killer signal. */
#define INDX_HUP 0
#define INDX_INT 1
@@ -39,29 +56,29 @@ typedef struct _cl_private {
TE_SENT=0, TI_SENT } ti_te;
#define CL_IN_EX 0x0001 /* Currently running ex. */
-#define CL_RENAME 0x0002 /* X11 xterm icon/window renamed. */
-#define CL_RENAME_OK 0x0004 /* User wants the windows renamed. */
-#define CL_SCR_EX_INIT 0x0008 /* Ex screen initialized. */
-#define CL_SCR_VI_INIT 0x0010 /* Vi screen initialized. */
-#define CL_SIGHUP 0x0020 /* SIGHUP arrived. */
-#define CL_SIGINT 0x0040 /* SIGINT arrived. */
-#define CL_SIGTERM 0x0080 /* SIGTERM arrived. */
-#define CL_SIGWINCH 0x0100 /* SIGWINCH arrived. */
-#define CL_STDIN_TTY 0x0200 /* Talking to a terminal. */
+#define CL_LAYOUT 0x0002 /* Screen layout changed. */
+#define CL_RENAME 0x0004 /* X11 xterm icon/window renamed. */
+#define CL_RENAME_OK 0x0008 /* User wants the windows renamed. */
+#define CL_SCR_EX_INIT 0x0010 /* Ex screen initialized. */
+#define CL_SCR_VI_INIT 0x0020 /* Vi screen initialized. */
+#define CL_SIGHUP 0x0040 /* SIGHUP arrived. */
+#define CL_SIGINT 0x0080 /* SIGINT arrived. */
+#define CL_SIGTERM 0x0100 /* SIGTERM arrived. */
+#define CL_SIGWINCH 0x0200 /* SIGWINCH arrived. */
+#define CL_STDIN_TTY 0x0400 /* Talking to a terminal. */
u_int32_t flags;
} CL_PRIVATE;
#define CLP(sp) ((CL_PRIVATE *)((sp)->gp->cl_private))
#define GCLP(gp) ((CL_PRIVATE *)gp->cl_private)
+#define CLSP(sp) ((WINDOW *)((sp)->cl_private))
/* Return possibilities from the keyboard read routine. */
typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t;
-/* The screen line relative to a specific window. */
-#define RLNO(sp, lno) (sp)->woff + (lno)
-
-/* X11 xterm escape sequence to rename the icon/window. */
-#define XTERM_RENAME "\033]0;%s\007"
+/* The screen position relative to a specific window. */
+#define RCNO(sp, cno) (cno)
+#define RLNO(sp, lno) (lno)
/*
* XXX
@@ -75,4 +92,4 @@ typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t;
#define FALSE 0
#endif
-#include "cl_extern.h"
+#include "extern.h"
diff --git a/cl/cl_bsd.c b/cl/cl_bsd.c
deleted file mode 100644
index 22124e5780b2..000000000000
--- a/cl/cl_bsd.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*-
- * Copyright (c) 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)cl_bsd.c 8.29 (Berkeley) 7/1/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <curses.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "../vi/vi.h"
-#include "cl.h"
-
-static char *ke; /* Keypad on. */
-static char *ks; /* Keypad off. */
-static char *vb; /* Visible bell string. */
-
-/*
- * HP's support the entire System V curses package except for the tigetstr
- * and tigetnum functions. Ultrix supports the BSD curses package except
- * for the idlok function. Cthulu only knows why. Break things up into a
- * minimal set of functions.
- */
-
-#ifndef HAVE_CURSES_ADDNSTR
-/*
- * addnstr --
- *
- * PUBLIC: #ifndef HAVE_CURSES_ADDNSTR
- * PUBLIC: int addnstr __P((char *, int));
- * PUBLIC: #endif
- */
-int
-addnstr(s, n)
- char *s;
- int n;
-{
- int ch;
-
- while (n-- && (ch = *s++))
- addch(ch);
- return (OK);
-}
-#endif
-
-#ifndef HAVE_CURSES_BEEP
-/*
- * beep --
- *
- * PUBLIC: #ifndef HAVE_CURSES_BEEP
- * PUBLIC: void beep __P((void));
- * PUBLIC: #endif
- */
-void
-beep()
-{
- (void)write(1, "\007", 1); /* '\a' */
-}
-#endif /* !HAVE_CURSES_BEEP */
-
-#ifndef HAVE_CURSES_FLASH
-/*
- * flash --
- * Flash the screen.
- *
- * PUBLIC: #ifndef HAVE_CURSES_FLASH
- * PUBLIC: void flash __P((void));
- * PUBLIC: #endif
- */
-void
-flash()
-{
- if (vb != NULL) {
- (void)tputs(vb, 1, cl_putchar);
- (void)fflush(stdout);
- } else
- beep();
-}
-#endif /* !HAVE_CURSES_FLASH */
-
-#ifndef HAVE_CURSES_IDLOK
-/*
- * idlok --
- * Turn on/off hardware line insert/delete.
- *
- * PUBLIC: #ifndef HAVE_CURSES_IDLOK
- * PUBLIC: void idlok __P((WINDOW *, int));
- * PUBLIC: #endif
- */
-void
-idlok(win, bf)
- WINDOW *win;
- int bf;
-{
- return;
-}
-#endif /* !HAVE_CURSES_IDLOK */
-
-#ifndef HAVE_CURSES_KEYPAD
-/*
- * keypad --
- * Put the keypad/cursor arrows into or out of application mode.
- *
- * PUBLIC: #ifndef HAVE_CURSES_KEYPAD
- * PUBLIC: int keypad __P((void *, int));
- * PUBLIC: #endif
- */
-int
-keypad(a, on)
- void *a;
- int on;
-{
- char *p;
-
- if ((p = tigetstr(on ? "smkx" : "rmkx")) != (char *)-1) {
- (void)tputs(p, 0, cl_putchar);
- (void)fflush(stdout);
- }
- return (0);
-}
-#endif /* !HAVE_CURSES_KEYPAD */
-
-#ifndef HAVE_CURSES_NEWTERM
-/*
- * newterm --
- * Create a new curses screen.
- *
- * PUBLIC: #ifndef HAVE_CURSES_NEWTERM
- * PUBLIC: void *newterm __P((const char *, FILE *, FILE *));
- * PUBLIC: #endif
- */
-void *
-newterm(a, b, c)
- const char *a;
- FILE *b, *c;
-{
- return (initscr());
-}
-#endif /* !HAVE_CURSES_NEWTERM */
-
-#ifndef HAVE_CURSES_SETUPTERM
-/*
- * setupterm --
- * Set up terminal.
- *
- * PUBLIC: #ifndef HAVE_CURSES_SETUPTERM
- * PUBLIC: void setupterm __P((char *, int, int *));
- * PUBLIC: #endif
- */
-void
-setupterm(ttype, fno, errp)
- char *ttype;
- int fno, *errp;
-{
- static char buf[2048];
- char *p;
-
- if ((*errp = tgetent(buf, ttype)) > 0) {
- if (ke != NULL)
- free(ke);
- ke = ((p = tigetstr("rmkx")) == (char *)-1) ?
- NULL : strdup(p);
- if (ks != NULL)
- free(ks);
- ks = ((p = tigetstr("smkx")) == (char *)-1) ?
- NULL : strdup(p);
- if (vb != NULL)
- free(vb);
- vb = ((p = tigetstr("flash")) == (char *)-1) ?
- NULL : strdup(p);
- }
-}
-#endif /* !HAVE_CURSES_SETUPTERM */
-
-#ifndef HAVE_CURSES_TIGETSTR
-/* Terminfo-to-termcap translation table. */
-typedef struct _tl {
- char *terminfo; /* Terminfo name. */
- char *termcap; /* Termcap name. */
-} TL;
-static const TL list[] = {
- "cols", "co", /* Terminal columns. */
- "cup", "cm", /* Cursor up. */
- "cuu1", "up", /* Cursor up. */
- "el", "ce", /* Clear to end-of-line. */
- "flash", "vb", /* Visible bell. */
- "kcub1", "kl", /* Cursor left. */
- "kcud1", "kd", /* Cursor down. */
- "kcuf1", "kr", /* Cursor right. */
- "kcuu1", "ku", /* Cursor up. */
- "kdch1", "kD", /* Delete character. */
- "kdl1", "kL", /* Delete line. */
- "ked", "kS", /* Delete to end of screen. */
- "kel", "kE", /* Delete to eol. */
- "kend", "@7", /* Go to eol. */
- "khome", "kh", /* Go to sol. */
- "kich1", "kI", /* Insert at cursor. */
- "kil1", "kA", /* Insert line. */
- "kind", "kF", /* Scroll down. */
- "kll", "kH", /* Go to eol. */
- "knp", "kN", /* Page down. */
- "kpp", "kP", /* Page up. */
- "kri", "kR", /* Scroll up. */
- "lines", "li", /* Terminal lines. */
- "rmcup", "te", /* Terminal end string. */
- "rmkx", "ke", /* Exit "keypad-transmit" mode. */
- "rmso", "se", /* Standout end. */
- "smcup", "ti", /* Terminal initialization string. */
- "smkx", "ks", /* Enter "keypad-transmit" mode. */
- "smso", "so", /* Standout begin. */
-};
-
-#ifdef _AIX
-/*
- * AIX's implementation for function keys greater than 10 is different and
- * only goes as far as 36.
- */
-static const char codes[] = {
-/* 0-10 */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';',
-/* 11-20 */ '<', '>', '!', '@', '#', '$', '%', '^', '&', '*',
-/* 21-30 */ '(', ')', '-', '_', '+', ',', ':', '?', '[', ']',
-/* 31-36 */ '{', '}', '|', '~', '/', '='
-};
-
-#else
-
-/*
- * !!!
- * Historically, the 4BSD termcap code didn't support functions keys greater
- * than 9. This was silently enforced -- asking for key k12 would return the
- * value for k1. We try and get around this by using the tables specified in
- * the terminfo(TI_ENV) man page from the 3rd Edition SVID. This assumes the
- * implementors of any System V compatibility code or an extended termcap used
- * those codes.
- */
-static const char codes[] = {
-/* 0-10 */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';',
-/* 11-19 */ '1', '2', '3', '4', '5', '6', '7', '8', '9',
-/* 20-63 */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
-};
-#endif /* _AIX */
-
-/*
- * lcmp --
- * list comparison routine for bsearch.
- */
-static int
-lcmp(a, b)
- const void *a, *b;
-{
- return (strcmp(a, ((TL *)b)->terminfo));
-}
-
-/*
- * tigetstr --
- *
- * Vendors put the prototype for tigetstr into random include files, including
- * <term.h>, which we can't include because it makes other systems unhappy.
- * Try and work around the problem, since we only care about the return value.
- *
- * PUBLIC: #ifdef HAVE_CURSES_TIGETSTR
- * PUBLIC: char *tigetstr();
- * PUBLIC: #else
- * PUBLIC: char *tigetstr __P((char *));
- * PUBLIC: #endif
- */
-char *
-tigetstr(name)
- char *name;
-{
- static char sbuf[256];
- TL *tlp;
- int n;
- char *p, keyname[3];
-
- if ((tlp = bsearch(name,
- list, sizeof(list) / sizeof(TL), sizeof(TL), lcmp)) == NULL) {
-#ifdef _AIX
- if (name[0] == 'k' &&
- name[1] == 'f' && (n = atoi(name + 2)) <= 36) {
- keyname[0] = 'k';
- keyname[1] = codes[n];
- keyname[2] = '\0';
-#else
- if (name[0] == 'k' &&
- name[1] == 'f' && (n = atoi(name + 2)) <= 63) {
- keyname[0] = n <= 10 ? 'k' : 'F';
- keyname[1] = codes[n];
- keyname[2] = '\0';
-#endif
- name = keyname;
- }
- } else
- name = tlp->termcap;
-
- p = sbuf;
-#ifdef _AIX
- return ((p = tgetstr(name, &p)) == NULL ? (char *)-1 : strcpy(sbuf, p));
-#else
- return (tgetstr(name, &p) == NULL ? (char *)-1 : sbuf);
-#endif
-}
-
-/*
- * tigetnum --
- *
- * PUBLIC: #ifndef HAVE_CURSES_TIGETSTR
- * PUBLIC: int tigetnum __P((char *));
- * PUBLIC: #endif
- */
-int
-tigetnum(name)
- char *name;
-{
- TL *tlp;
- int val;
-
- if ((tlp = bsearch(name,
- list, sizeof(list) / sizeof(TL), sizeof(TL), lcmp)) != NULL) {
- name = tlp->termcap;
- }
-
- return ((val = tgetnum(name)) == -1 ? -2 : val);
-}
-#endif /* !HAVE_CURSES_TIGETSTR */
diff --git a/cl/cl_funcs.c b/cl/cl_funcs.c
index 40315ee85e89..8b14e8da747d 100644
--- a/cl/cl_funcs.c
+++ b/cl/cl_funcs.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_funcs.c 10.50 (Berkeley) 9/24/96";
+static const char sccsid[] = "$Id: cl_funcs.c,v 10.74 2012/10/11 10:30:16 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -19,11 +19,13 @@ static const char sccsid[] = "@(#)cl_funcs.c 10.50 (Berkeley) 9/24/96";
#include <bitstring.h>
#include <ctype.h>
-#include <curses.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_TERM_H
+#include <term.h>
+#endif
#include <termios.h>
#include <unistd.h>
@@ -31,59 +33,83 @@ static const char sccsid[] = "@(#)cl_funcs.c 10.50 (Berkeley) 9/24/96";
#include "../vi/vi.h"
#include "cl.h"
-/*
- * cl_addstr --
- * Add len bytes from the string at the cursor, advancing the cursor.
- *
- * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
- */
-int
-cl_addstr(sp, str, len)
- SCR *sp;
- const char *str;
- size_t len;
+static void cl_rdiv __P((SCR *));
+
+static int
+addstr4(SCR *sp, void *str, size_t len, int wide)
{
CL_PRIVATE *clp;
- size_t oldy, oldx;
+ WINDOW *win;
+ size_t y, x;
int iv;
clp = CLP(sp);
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
/*
* If ex isn't in control, it's the last line of the screen and
* it's a split screen, use inverse video.
*/
iv = 0;
- getyx(stdscr, oldy, oldx);
+ getyx(win, y, x);
if (!F_ISSET(sp, SC_SCR_EXWROTE) &&
- oldy == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) {
+ y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) {
iv = 1;
- (void)standout();
+ (void)wstandout(win);
}
- if (addnstr(str, len) == ERR)
+#ifdef USE_WIDECHAR
+ if (wide) {
+ if (waddnwstr(win, str, len) == ERR)
return (1);
+ } else
+#endif
+ if (waddnstr(win, str, len) == ERR)
+ return (1);
if (iv)
- (void)standend();
+ (void)wstandend(win);
return (0);
}
/*
+ * cl_waddstr --
+ * Add len bytes from the string at the cursor, advancing the cursor.
+ *
+ * PUBLIC: int cl_waddstr __P((SCR *, const CHAR_T *, size_t));
+ */
+int
+cl_waddstr(SCR *sp, const CHAR_T *str, size_t len)
+{
+ return addstr4(sp, (void *)str, len, 1);
+}
+
+/*
+ * cl_addstr --
+ * Add len bytes from the string at the cursor, advancing the cursor.
+ *
+ * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t));
+ */
+int
+cl_addstr(SCR *sp, const char *str, size_t len)
+{
+ return addstr4(sp, (void *)str, len, 0);
+}
+
+/*
* cl_attr --
* Toggle a screen attribute on/off.
*
* PUBLIC: int cl_attr __P((SCR *, scr_attr_t, int));
*/
int
-cl_attr(sp, attribute, on)
- SCR *sp;
- scr_attr_t attribute;
- int on;
+cl_attr(SCR *sp, scr_attr_t attribute, int on)
{
CL_PRIVATE *clp;
+ WINDOW *win;
clp = CLP(sp);
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
switch (attribute) {
case SA_ALTERNATE:
@@ -146,9 +172,9 @@ cl_attr(sp, attribute, on)
(void)fflush(stdout);
} else {
if (on)
- (void)standout();
+ (void)wstandout(win);
else
- (void)standend();
+ (void)wstandend(win);
}
break;
default:
@@ -164,9 +190,7 @@ cl_attr(sp, attribute, on)
* PUBLIC: int cl_baud __P((SCR *, u_long *));
*/
int
-cl_baud(sp, ratep)
- SCR *sp;
- u_long *ratep;
+cl_baud(SCR *sp, u_long *ratep)
{
CL_PRIVATE *clp;
@@ -207,10 +231,9 @@ cl_baud(sp, ratep)
* PUBLIC: int cl_bell __P((SCR *));
*/
int
-cl_bell(sp)
- SCR *sp;
+cl_bell(SCR *sp)
{
- if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE))
+ if (F_ISSET(sp, SC_EX | SC_SCR_EXWROTE | SC_SCR_EX))
(void)write(STDOUT_FILENO, "\07", 1); /* \a */
else {
/*
@@ -232,10 +255,26 @@ cl_bell(sp)
* PUBLIC: int cl_clrtoeol __P((SCR *));
*/
int
-cl_clrtoeol(sp)
- SCR *sp;
+cl_clrtoeol(SCR *sp)
{
- return (clrtoeol() == ERR);
+ WINDOW *win;
+#if 0
+ size_t spcnt, y, x;
+#endif
+
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
+
+#if 0
+ if (IS_VSPLIT(sp)) {
+ /* The cursor must be returned to its original position. */
+ getyx(win, y, x);
+ for (spcnt = (sp->coff + sp->cols) - x; spcnt > 0; --spcnt)
+ (void)waddch(win, ' ');
+ (void)wmove(win, y, x);
+ return (0);
+ } else
+#endif
+ return (wclrtoeol(win) == ERR);
}
/*
@@ -245,10 +284,10 @@ cl_clrtoeol(sp)
* PUBLIC: int cl_cursor __P((SCR *, size_t *, size_t *));
*/
int
-cl_cursor(sp, yp, xp)
- SCR *sp;
- size_t *yp, *xp;
+cl_cursor(SCR *sp, size_t *yp, size_t *xp)
{
+ WINDOW *win;
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
/*
* The curses screen support splits a single underlying curses screen
* into multiple screens to support split screen semantics. For this
@@ -256,8 +295,11 @@ cl_cursor(sp, yp, xp)
* current screen, and not absolute. Screens that implement the split
* using physically distinct screens won't need this hack.
*/
- getyx(stdscr, *yp, *xp);
- *yp -= sp->woff;
+ getyx(win, *yp, *xp);
+ /*
+ *yp -= sp->roff;
+ *xp -= sp->coff;
+ */
return (0);
}
@@ -268,14 +310,14 @@ cl_cursor(sp, yp, xp)
* PUBLIC: int cl_deleteln __P((SCR *));
*/
int
-cl_deleteln(sp)
- SCR *sp;
+cl_deleteln(SCR *sp)
{
- CHAR_T ch;
CL_PRIVATE *clp;
- size_t col, lno, spcnt, oldy, oldx;
+ WINDOW *win;
+ size_t y, x;
clp = CLP(sp);
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
/*
* This clause is required because the curses screen uses reverse
@@ -284,45 +326,58 @@ cl_deleteln(sp)
*
* If the bottom line was in reverse video, rewrite it in normal
* video before it's scrolled.
- *
- * Check for the existence of a chgat function; XSI requires it, but
- * historic implementations of System V curses don't. If it's not
- * a #define, we'll fall back to doing it by hand, which is slow but
- * acceptable.
- *
- * By hand means walking through the line, retrieving and rewriting
- * each character. Curses has no EOL marker, so track strings of
- * spaces, and copy the trailing spaces only if there's a non-space
- * character following.
*/
if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
- getyx(stdscr, oldy, oldx);
-#ifdef mvchgat
- mvchgat(RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
-#else
- for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
- (void)move(lno, col);
- ch = winch(stdscr);
- if (isblank(ch))
- ++spcnt;
- else {
- (void)move(lno, col - spcnt);
- for (; spcnt > 0; --spcnt)
- (void)addch(' ');
- (void)addch(ch);
- }
- if (++col >= sp->cols)
- break;
- }
-#endif
- (void)move(oldy, oldx);
+ getyx(win, y, x);
+ mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
+ (void)wmove(win, y, x);
}
/*
* The bottom line is expected to be blank after this operation,
* and other screens must support that semantic.
*/
- return (deleteln() == ERR);
+ return (wdeleteln(win) == ERR);
+}
+
+/*
+ * cl_discard --
+ * Discard a screen.
+ *
+ * PUBLIC: int cl_discard __P((SCR *, SCR **));
+ */
+int
+cl_discard(SCR *discardp, SCR **acquirep)
+{
+ CL_PRIVATE *clp;
+ SCR* tsp;
+
+ if (discardp) {
+ clp = CLP(discardp);
+ F_SET(clp, CL_LAYOUT);
+
+ if (CLSP(discardp)) {
+ delwin(CLSP(discardp));
+ discardp->cl_private = NULL;
+ }
+ }
+
+ /* no screens got a piece; we're done */
+ if (!acquirep)
+ return 0;
+
+ for (; (tsp = *acquirep) != NULL; ++acquirep) {
+ clp = CLP(tsp);
+ F_SET(clp, CL_LAYOUT);
+
+ if (CLSP(tsp))
+ delwin(CLSP(tsp));
+ tsp->cl_private = subwin(stdscr, tsp->rows, tsp->cols,
+ tsp->roff, tsp->coff);
+ }
+
+ /* discardp is going away, acquirep is taking up its space. */
+ return (0);
}
/*
@@ -333,9 +388,7 @@ cl_deleteln(sp)
* PUBLIC: int cl_ex_adjust __P((SCR *, exadj_t));
*/
int
-cl_ex_adjust(sp, action)
- SCR *sp;
- exadj_t action;
+cl_ex_adjust(SCR *sp, exadj_t action)
{
CL_PRIVATE *clp;
int cnt;
@@ -390,14 +443,15 @@ cl_ex_adjust(sp, action)
* PUBLIC: int cl_insertln __P((SCR *));
*/
int
-cl_insertln(sp)
- SCR *sp;
+cl_insertln(SCR *sp)
{
+ WINDOW *win;
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
/*
* The current line is expected to be blank after this operation,
* and the screen must support that semantic.
*/
- return (insertln() == ERR);
+ return (winsertln(win) == ERR);
}
/*
@@ -407,11 +461,7 @@ cl_insertln(sp)
* PUBLIC: int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
*/
int
-cl_keyval(sp, val, chp, dnep)
- SCR *sp;
- scr_keyval_t val;
- CHAR_T *chp;
- int *dnep;
+cl_keyval(SCR *sp, scr_keyval_t val, CHAR_T *chp, int *dnep)
{
CL_PRIVATE *clp;
@@ -449,14 +499,14 @@ cl_keyval(sp, val, chp, dnep)
* PUBLIC: int cl_move __P((SCR *, size_t, size_t));
*/
int
-cl_move(sp, lno, cno)
- SCR *sp;
- size_t lno, cno;
+cl_move(SCR *sp, size_t lno, size_t cno)
{
+ WINDOW *win;
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
/* See the comment in cl_cursor. */
- if (move(RLNO(sp, lno), cno) == ERR) {
- msgq(sp, M_ERR,
- "Error: move: l(%u) c(%u) o(%u)", lno, cno, sp->woff);
+ if (wmove(win, RLNO(sp, lno), RCNO(sp, cno)) == ERR) {
+ msgq(sp, M_ERR, "Error: move: l(%zu + %zu) c(%zu + %zu)",
+ lno, sp->roff, cno, sp->coff);
return (1);
}
return (0);
@@ -469,13 +519,17 @@ cl_move(sp, lno, cno)
* PUBLIC: int cl_refresh __P((SCR *, int));
*/
int
-cl_refresh(sp, repaint)
- SCR *sp;
- int repaint;
+cl_refresh(SCR *sp, int repaint)
{
+ GS *gp;
CL_PRIVATE *clp;
+ WINDOW *win;
+ SCR *psp, *tsp;
+ size_t y, x;
+ gp = sp->gp;
clp = CLP(sp);
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
/*
* If we received a killer signal, we're done, there's no point
@@ -488,13 +542,57 @@ cl_refresh(sp, repaint)
* If repaint is set, the editor is telling us that we don't know
* what's on the screen, so we have to repaint from scratch.
*
+ * If repaint set or the screen layout changed, we need to redraw
+ * any lines separating vertically split screens. If the horizontal
+ * offsets are the same, then the split was vertical, and need to
+ * draw a dividing line.
+ */
+ if (repaint || F_ISSET(clp, CL_LAYOUT)) {
+ getyx(stdscr, y, x);
+ for (psp = sp; psp != NULL; psp = TAILQ_NEXT(psp, q))
+ for (tsp = TAILQ_NEXT(psp, q); tsp != NULL;
+ tsp = TAILQ_NEXT(tsp, q))
+ if (psp->roff == tsp->roff) {
+ if (psp->coff + psp->cols + 1 == tsp->coff)
+ cl_rdiv(psp);
+ else
+ if (tsp->coff + tsp->cols + 1 == psp->coff)
+ cl_rdiv(tsp);
+ }
+ (void)wmove(stdscr, y, x);
+ F_CLR(clp, CL_LAYOUT);
+ }
+
+ /*
* In the curses library, doing wrefresh(curscr) is okay, but the
* screen flashes when we then apply the refresh() to bring it up
* to date. So, use clearok().
*/
if (repaint)
clearok(curscr, 1);
- return (refresh() == ERR);
+ /*
+ * Only do an actual refresh, when this is the focus window,
+ * i.e. the one holding the cursor. This assumes that refresh
+ * is called for that window after refreshing the others.
+ * This prevents the cursor being drawn in the other windows.
+ */
+ return (wnoutrefresh(stdscr) == ERR ||
+ wnoutrefresh(win) == ERR ||
+ (sp == clp->focus && doupdate() == ERR));
+}
+
+/*
+ * cl_rdiv --
+ * Draw a dividing line between two vertically split screens.
+ */
+static void
+cl_rdiv(SCR *sp)
+{
+#ifdef __NetBSD__
+ mvvline(sp->roff, sp->cols + sp->coff, '|', sp->rows);
+#else
+ mvvline(sp->roff, sp->cols + sp->coff, ACS_VLINE, sp->rows);
+#endif
}
/*
@@ -504,59 +602,116 @@ cl_refresh(sp, repaint)
* PUBLIC: int cl_rename __P((SCR *, char *, int));
*/
int
-cl_rename(sp, name, on)
- SCR *sp;
- char *name;
- int on;
+cl_rename(SCR *sp, char *name, int on)
{
GS *gp;
CL_PRIVATE *clp;
- char *ttype;
+ FILE *pfp;
+ char buf[256], *s, *e;
+ char * wid;
+ char cmd[64];
gp = sp->gp;
clp = CLP(sp);
- ttype = OG_STR(gp, GO_TERM);
-
/*
* XXX
* We can only rename windows for xterm.
*/
if (on) {
- if (F_ISSET(clp, CL_RENAME_OK) &&
- !strncmp(ttype, "xterm", sizeof("xterm") - 1)) {
- F_SET(clp, CL_RENAME);
- (void)printf(XTERM_RENAME, name);
- (void)fflush(stdout);
+ clp->focus = sp;
+ if (!F_ISSET(clp, CL_RENAME_OK) ||
+ strncmp(OG_STR(gp, GO_TERM), "xterm", 5))
+ return (0);
+
+ if (clp->oname == NULL && (wid = getenv("WINDOWID"))) {
+ snprintf(cmd, sizeof(cmd), "xprop -id %s WM_NAME", wid);
+ if ((pfp = popen(cmd, "r")) == NULL)
+ goto rename;
+ if (fgets(buf, sizeof(buf), pfp) == NULL) {
+ pclose(pfp);
+ goto rename;
+ }
+ pclose(pfp);
+ if ((s = strchr(buf, '"')) != NULL &&
+ (e = strrchr(buf, '"')) != NULL)
+ clp->oname = strndup(s + 1, e - s - 1);
}
+
+rename: cl_setname(gp, name);
+
+ F_SET(clp, CL_RENAME);
} else
if (F_ISSET(clp, CL_RENAME)) {
+ cl_setname(gp, clp->oname);
+
F_CLR(clp, CL_RENAME);
- (void)printf(XTERM_RENAME, ttype);
- (void)fflush(stdout);
}
return (0);
}
/*
+ * cl_setname --
+ * Set a X11 icon/window name.
+ *
+ * PUBLIC: void cl_setname __P((GS *, char *));
+ */
+void
+cl_setname(GS *gp, char *name)
+{
+/* X11 xterm escape sequence to rename the icon/window. */
+#define XTERM_RENAME "\033]0;%s\007"
+
+ (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name);
+ (void)fflush(stdout);
+#undef XTERM_RENAME
+}
+
+/*
+ * cl_split --
+ * Split a screen.
+ *
+ * PUBLIC: int cl_split __P((SCR *, SCR *));
+ */
+int
+cl_split(SCR *origp, SCR *newp)
+{
+ CL_PRIVATE *clp;
+
+ clp = CLP(origp);
+ F_SET(clp, CL_LAYOUT);
+
+ if (CLSP(origp))
+ delwin(CLSP(origp));
+
+ origp->cl_private = subwin(stdscr, origp->rows, origp->cols,
+ origp->roff, origp->coff);
+ newp->cl_private = subwin(stdscr, newp->rows, newp->cols,
+ newp->roff, newp->coff);
+
+ /* origp is the original screen, giving up space to newp. */
+ return (0);
+}
+
+/*
* cl_suspend --
* Suspend a screen.
*
* PUBLIC: int cl_suspend __P((SCR *, int *));
*/
int
-cl_suspend(sp, allowedp)
- SCR *sp;
- int *allowedp;
+cl_suspend(SCR *sp, int *allowedp)
{
struct termios t;
CL_PRIVATE *clp;
+ WINDOW *win;
GS *gp;
- size_t oldy, oldx;
+ size_t y, x;
int changed;
gp = sp->gp;
clp = CLP(sp);
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
*allowedp = 1;
/*
@@ -596,9 +751,9 @@ cl_suspend(sp, allowedp)
* Not sure this is necessary in System V implementations, but it
* shouldn't hurt.
*/
- getyx(stdscr, oldy, oldx);
- (void)move(LINES - 1, 0);
- (void)refresh();
+ getyx(win, y, x);
+ (void)wmove(win, LINES - 1, 0);
+ (void)wrefresh(win);
/*
* Temporarily end the screen. System V introduced a semantic where
@@ -607,10 +762,8 @@ cl_suspend(sp, allowedp)
* restarting after endwin(), so we have to do what clean up we can
* without calling it.
*/
-#ifdef HAVE_BSD_CURSES
/* Save the terminal settings. */
(void)tcgetattr(STDIN_FILENO, &t);
-#endif
/* Restore the cursor keys to normal mode. */
(void)keypad(stdscr, FALSE);
@@ -618,11 +771,8 @@ cl_suspend(sp, allowedp)
/* Restore the window name. */
(void)cl_rename(sp, NULL, 0);
-#ifdef HAVE_BSD_CURSES
- (void)cl_attr(sp, SA_ALTERNATE, 0);
-#else
(void)endwin();
-#endif
+
/*
* XXX
* Restore the original terminal settings. This is bad -- the
@@ -647,14 +797,11 @@ cl_suspend(sp, allowedp)
return (0);
}
-#ifdef HAVE_BSD_CURSES
/* Restore terminal settings. */
+ wrefresh(win); /* Needed on SunOs/Solaris ? */
if (F_ISSET(clp, CL_STDIN_TTY))
(void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
- (void)cl_attr(sp, SA_ALTERNATE, 1);
-#endif
-
/* Set the window name. */
(void)cl_rename(sp, sp->frp->name, 1);
@@ -662,7 +809,7 @@ cl_suspend(sp, allowedp)
(void)keypad(stdscr, TRUE);
/* Refresh and repaint the screen. */
- (void)move(oldy, oldx);
+ (void)wmove(win, y, x);
(void)cl_refresh(sp, 1);
/* If the screen changed size, set the SIGWINCH bit. */
@@ -681,7 +828,7 @@ cl_suspend(sp, allowedp)
* PUBLIC: void cl_usage __P((void));
*/
void
-cl_usage()
+cl_usage(void)
{
#define USAGE "\
usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
@@ -695,8 +842,9 @@ usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
* gdbrefresh --
* Stub routine so can flush out curses screen changes using gdb.
*/
-int
-gdbrefresh()
+static int
+ __attribute__((unused))
+gdbrefresh(void)
{
refresh();
return (0); /* XXX Convince gdb to run it. */
diff --git a/cl/cl_main.c b/cl/cl_main.c
index 2889f709cbb2..98f13136a061 100644
--- a/cl/cl_main.c
+++ b/cl/cl_main.c
@@ -10,27 +10,26 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_main.c 10.36 (Berkeley) 10/14/96";
+static const char sccsid[] = "$Id: cl_main.c,v 10.55 2011/08/15 19:52:28 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <bitstring.h>
-#include <curses.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_TERM_H
+#include <term.h>
+#endif
#include <termios.h>
#include <unistd.h>
#include "../common/common.h"
-#ifdef RUNNING_IP
-#include "../ip/ip.h"
-#endif
#include "cl.h"
#include "pathnames.h"
@@ -50,16 +49,14 @@ static void term_init __P((char *, char *));
* This is the main loop for the standalone curses editor.
*/
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char **argv)
{
static int reenter;
CL_PRIVATE *clp;
GS *gp;
size_t rows, cols;
int rval;
- char *ip_arg, **p_av, **t_av, *ttype;
+ char **p_av, **t_av, *ttype;
/* If loaded at 0 and jumping through a NULL pointer, stop. */
if (reenter++)
@@ -73,8 +70,6 @@ main(argc, argv)
* no way to portably call getopt twice, so arguments parsed here must
* be removed from the argument list.
*/
-#ifdef RUNNING_IP
- ip_arg = NULL;
for (p_av = t_av = argv;;) {
if (*t_av == NULL) {
*p_av = NULL;
@@ -84,33 +79,9 @@ main(argc, argv)
while ((*p_av++ = *t_av++) != NULL);
break;
}
- if (!memcmp(*t_av, "-I", sizeof("-I") - 1)) {
- if (t_av[0][2] != '\0') {
- ip_arg = t_av[0] + 2;
- ++t_av;
- --argc;
- continue;
- }
- if (t_av[1] != NULL) {
- ip_arg = t_av[1];
- t_av += 2;
- argc -= 2;
- continue;
- }
- }
*p_av++ = *t_av++;
}
- /*
- * If we're being called as an editor library, we're done here, we
- * get loaded with the curses screen, we don't share much code.
- */
- if (ip_arg != NULL)
- exit (ip_main(argc, argv, gp, ip_arg));
-#else
- ip_arg = argv[0];
-#endif
-
/* Create and initialize the CL_PRIVATE structure. */
clp = cl_init(gp);
@@ -164,10 +135,8 @@ main(argc, argv)
* XXX
* Reset the X11 xterm icon/window name.
*/
- if (F_ISSET(clp, CL_RENAME)) {
- (void)printf(XTERM_RENAME, ttype);
- (void)fflush(stdout);
- }
+ if (F_ISSET(clp, CL_RENAME))
+ cl_setname(gp, clp->oname);
/* If a killer signal arrived, pretend we just got it. */
if (clp->killersig) {
@@ -178,7 +147,10 @@ main(argc, argv)
/* Free the global and CL private areas. */
#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
+ if (clp->oname != NULL)
+ free(clp->oname);
free(clp);
+ free(OG_STR(gp, GO_TERM));
free(gp);
#endif
@@ -190,10 +162,8 @@ main(argc, argv)
* Create and partially initialize the GS structure.
*/
static GS *
-gs_init(name)
- char *name;
+gs_init(char *name)
{
- CL_PRIVATE *clp;
GS *gp;
char *p;
@@ -206,7 +176,6 @@ gs_init(name)
if (gp == NULL)
perr(name, NULL);
-
gp->progname = name;
return (gp);
}
@@ -216,8 +185,7 @@ gs_init(name)
* Create and partially initialize the CL structure.
*/
static CL_PRIVATE *
-cl_init(gp)
- GS *gp;
+cl_init(GS *gp)
{
CL_PRIVATE *clp;
int fd;
@@ -265,8 +233,7 @@ tcfail: perr(gp->progname, "tcgetattr");
* Initialize terminal information.
*/
static void
-term_init(name, ttype)
- char *name, *ttype;
+term_init(char *name, char *ttype)
{
int err;
@@ -287,8 +254,7 @@ term_init(name, ttype)
#define GLOBAL_CLP \
CL_PRIVATE *clp = GCLP(__global_list);
static void
-h_hup(signo)
- int signo;
+h_hup(int signo)
{
GLOBAL_CLP;
@@ -297,8 +263,7 @@ h_hup(signo)
}
static void
-h_int(signo)
- int signo;
+h_int(int signo)
{
GLOBAL_CLP;
@@ -306,8 +271,7 @@ h_int(signo)
}
static void
-h_term(signo)
- int signo;
+h_term(int signo)
{
GLOBAL_CLP;
@@ -316,8 +280,7 @@ h_term(signo)
}
static void
-h_winch(signo)
- int signo;
+h_winch(int signo)
{
GLOBAL_CLP;
@@ -332,9 +295,7 @@ h_winch(signo)
* PUBLIC: int sig_init __P((GS *, SCR *));
*/
int
-sig_init(gp, sp)
- GS *gp;
- SCR *sp;
+sig_init(GS *gp, SCR *sp)
{
CL_PRIVATE *clp;
@@ -376,10 +337,7 @@ sig_init(gp, sp)
* Set a signal handler.
*/
static int
-setsig(signo, oactp, handler)
- int signo;
- struct sigaction *oactp;
- void (*handler) __P((int));
+setsig(int signo, struct sigaction *oactp, void (*handler) (int))
{
struct sigaction act;
@@ -410,8 +368,7 @@ setsig(signo, oactp, handler)
* End signal setup.
*/
static void
-sig_end(gp)
- GS *gp;
+sig_end(GS *gp)
{
CL_PRIVATE *clp;
@@ -429,17 +386,20 @@ sig_end(gp)
* Initialize the standard curses functions.
*/
static void
-cl_func_std(gp)
- GS *gp;
+cl_func_std(GS *gp)
{
gp->scr_addstr = cl_addstr;
+ gp->scr_waddstr = cl_waddstr;
gp->scr_attr = cl_attr;
gp->scr_baud = cl_baud;
gp->scr_bell = cl_bell;
gp->scr_busy = NULL;
+ gp->scr_child = NULL;
gp->scr_clrtoeol = cl_clrtoeol;
gp->scr_cursor = cl_cursor;
gp->scr_deleteln = cl_deleteln;
+ gp->scr_reply = NULL;
+ gp->scr_discard = cl_discard;
gp->scr_event = cl_event;
gp->scr_ex_adjust = cl_ex_adjust;
gp->scr_fmap = cl_fmap;
@@ -451,6 +411,7 @@ cl_func_std(gp)
gp->scr_refresh = cl_refresh;
gp->scr_rename = cl_rename;
gp->scr_screen = cl_screen;
+ gp->scr_split = cl_split;
gp->scr_suspend = cl_suspend;
gp->scr_usage = cl_usage;
}
@@ -460,8 +421,7 @@ cl_func_std(gp)
* Print system error.
*/
static void
-perr(name, msg)
- char *name, *msg;
+perr(char *name, char *msg)
{
(void)fprintf(stderr, "%s:", name);
if (msg != NULL)
diff --git a/cl/cl_read.c b/cl/cl_read.c
index 8a95a77b2438..410cdd4318cc 100644
--- a/cl/cl_read.c
+++ b/cl/cl_read.c
@@ -10,18 +10,14 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_read.c 10.15 (Berkeley) 9/24/96";
+static const char sccsid[] = "$Id: cl_read.c,v 10.30 2012/07/12 18:28:58 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
-#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
-#endif
-#include <sys/time.h>
#include <bitstring.h>
-#include <curses.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
@@ -35,8 +31,12 @@ static const char sccsid[] = "@(#)cl_read.c 10.15 (Berkeley) 9/24/96";
#include "../ex/script.h"
#include "cl.h"
+/* Pollution by Solaris curses. */
+#undef columns
+#undef lines
+
static input_t cl_read __P((SCR *,
- u_int32_t, CHAR_T *, size_t, int *, struct timeval *));
+ u_int32_t, char *, size_t, int *, struct timeval *));
static int cl_resize __P((SCR *, size_t, size_t));
/*
@@ -46,16 +46,15 @@ static int cl_resize __P((SCR *, size_t, size_t));
* PUBLIC: int cl_event __P((SCR *, EVENT *, u_int32_t, int));
*/
int
-cl_event(sp, evp, flags, ms)
- SCR *sp;
- EVENT *evp;
- u_int32_t flags;
- int ms;
+cl_event(SCR *sp, EVENT *evp, u_int32_t flags, int ms)
{
struct timeval t, *tp;
CL_PRIVATE *clp;
size_t lines, columns;
- int changed, nr;
+ int changed, nr = 0;
+ CHAR_T *wp;
+ size_t wlen;
+ int rc;
/*
* Queue signal based events. We never clear SIGHUP or SIGTERM events,
@@ -102,12 +101,25 @@ retest: if (LF_ISSET(EC_INTERRUPT) || F_ISSET(clp, CL_SIGINT)) {
}
/* Read input characters. */
+read:
switch (cl_read(sp, LF_ISSET(EC_QUOTED | EC_RAW),
- clp->ibuf, sizeof(clp->ibuf), &nr, tp)) {
+ clp->ibuf + clp->skip, SIZE(clp->ibuf) - clp->skip, &nr, tp)) {
case INP_OK:
- evp->e_csp = clp->ibuf;
- evp->e_len = nr;
+ rc = INPUT2INT5(sp, clp->cw, clp->ibuf, nr + clp->skip,
+ wp, wlen);
+ evp->e_csp = wp;
+ evp->e_len = wlen;
evp->e_event = E_STRING;
+ if (rc < 0) {
+ int n = -rc;
+ memmove(clp->ibuf, clp->ibuf + nr + clp->skip - n, n);
+ clp->skip = n;
+ if (wlen == 0)
+ goto read;
+ } else if (rc == 0)
+ clp->skip = 0;
+ else
+ msgq(sp, M_ERR, "323|Invalid input. Truncated.");
break;
case INP_EOF:
evp->e_event = E_EOF;
@@ -131,19 +143,11 @@ retest: if (LF_ISSET(EC_INTERRUPT) || F_ISSET(clp, CL_SIGINT)) {
* Read characters from the input.
*/
static input_t
-cl_read(sp, flags, bp, blen, nrp, tp)
- SCR *sp;
- u_int32_t flags;
- CHAR_T *bp;
- size_t blen;
- int *nrp;
- struct timeval *tp;
+cl_read(SCR *sp, u_int32_t flags, char *bp, size_t blen, int *nrp, struct timeval *tp)
{
struct termios term1, term2;
- struct timeval poll;
CL_PRIVATE *clp;
GS *gp;
- SCR *tsp;
fd_set rdfd;
input_t rval;
int maxfd, nr, term_reset;
@@ -175,13 +179,10 @@ cl_read(sp, flags, bp, blen, nrp, tp)
* 2: A read with an associated timeout, e.g., trying to complete
* a map sequence. If input exists, we fall into #3.
*/
- FD_ZERO(&rdfd);
- poll.tv_sec = 0;
- poll.tv_usec = 0;
if (tp != NULL) {
+ FD_ZERO(&rdfd);
FD_SET(STDIN_FILENO, &rdfd);
- switch (select(STDIN_FILENO + 1,
- &rdfd, NULL, NULL, tp == NULL ? &poll : tp)) {
+ switch (select(STDIN_FILENO + 1, &rdfd, NULL, NULL, tp)) {
case 0:
return (INP_TIMEOUT);
case -1:
@@ -225,13 +226,11 @@ cl_read(sp, flags, bp, blen, nrp, tp)
loop: FD_ZERO(&rdfd);
FD_SET(STDIN_FILENO, &rdfd);
maxfd = STDIN_FILENO;
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
- if (F_ISSET(sp, SC_SCRIPT)) {
- FD_SET(sp->script->sh_master, &rdfd);
- if (sp->script->sh_master > maxfd)
- maxfd = sp->script->sh_master;
- }
+ if (F_ISSET(sp, SC_SCRIPT)) {
+ FD_SET(sp->script->sh_master, &rdfd);
+ if (sp->script->sh_master > maxfd)
+ maxfd = sp->script->sh_master;
+ }
switch (select(maxfd + 1, &rdfd, NULL, NULL, NULL)) {
case 0:
abort();
@@ -309,12 +308,10 @@ err: if (errno == EINTR)
* Reset the options for a resize event.
*/
static int
-cl_resize(sp, lines, columns)
- SCR *sp;
- size_t lines, columns;
+cl_resize(SCR *sp, size_t lines, size_t columns)
{
ARGS *argv[2], a, b;
- char b1[1024];
+ CHAR_T b1[1024];
a.bp = b1;
b.bp = NULL;
@@ -322,12 +319,10 @@ cl_resize(sp, lines, columns)
argv[0] = &a;
argv[1] = &b;
- (void)snprintf(b1, sizeof(b1), "lines=%lu", (u_long)lines);
- a.len = strlen(b1);
+ a.len = SPRINTF(b1, sizeof(b1), L("lines=%lu"), (u_long)lines);
if (opts_set(sp, argv, NULL))
return (1);
- (void)snprintf(b1, sizeof(b1), "columns=%lu", (u_long)columns);
- a.len = strlen(b1);
+ a.len = SPRINTF(b1, sizeof(b1), L("columns=%lu"), (u_long)columns);
if (opts_set(sp, argv, NULL))
return (1);
return (0);
diff --git a/cl/cl_screen.c b/cl/cl_screen.c
index 2ce58e80cc78..91ff2789961e 100644
--- a/cl/cl_screen.c
+++ b/cl/cl_screen.c
@@ -10,19 +10,22 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_screen.c 10.49 (Berkeley) 9/24/96";
+static const char sccsid[] = "$Id: cl_screen.c,v 10.56 2002/05/03 19:59:44 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
-#include <curses.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_TERM_H
+#include <term.h>
+#endif
#include <termios.h>
#include <unistd.h>
@@ -43,26 +46,30 @@ static int cl_putenv __P((char *, char *, u_long));
* PUBLIC: int cl_screen __P((SCR *, u_int32_t));
*/
int
-cl_screen(sp, flags)
- SCR *sp;
- u_int32_t flags;
+cl_screen(SCR *sp, u_int32_t flags)
{
CL_PRIVATE *clp;
+ WINDOW *win;
GS *gp;
gp = sp->gp;
clp = CLP(sp);
+ win = CLSP(sp) ? CLSP(sp) : stdscr;
/* See if the current information is incorrect. */
if (F_ISSET(gp, G_SRESTART)) {
+ if (CLSP(sp)) {
+ delwin(CLSP(sp));
+ sp->cl_private = NULL;
+ }
if (cl_quit(gp))
return (1);
F_CLR(gp, G_SRESTART);
}
/* See if we're already in the right mode. */
- if (LF_ISSET(SC_EX) && F_ISSET(sp, SC_SCR_EX) ||
- LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI))
+ if ((LF_ISSET(SC_EX) && F_ISSET(sp, SC_SCR_EX)) ||
+ (LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI)))
return (0);
/*
@@ -90,12 +97,12 @@ cl_screen(sp, flags)
if (F_ISSET(sp, SC_SCR_VI)) {
F_CLR(sp, SC_SCR_VI);
- if (sp->q.cqe_next != (void *)&gp->dq) {
- (void)move(RLNO(sp, sp->rows), 0);
- clrtobot();
+ if (TAILQ_NEXT(sp, q) != NULL) {
+ (void)wmove(win, RLNO(sp, sp->rows), 0);
+ wclrtobot(win);
}
- (void)move(RLNO(sp, sp->rows) - 1, 0);
- refresh();
+ (void)wmove(win, RLNO(sp, sp->rows) - 1, 0);
+ wrefresh(win);
}
/* Enter the requested mode. */
@@ -127,8 +134,7 @@ cl_screen(sp, flags)
* PUBLIC: int cl_quit __P((GS *));
*/
int
-cl_quit(gp)
- GS *gp;
+cl_quit(GS *gp)
{
CL_PRIVATE *clp;
int rval;
@@ -178,8 +184,7 @@ cl_quit(gp)
* Initialize the curses vi screen.
*/
static int
-cl_vi_init(sp)
- SCR *sp;
+cl_vi_init(SCR *sp)
{
CL_PRIVATE *clp;
GS *gp;
@@ -242,6 +247,7 @@ cl_vi_init(sp)
* The HP/UX newterm doesn't support the NULL first argument, so we
* have to specify the terminal type.
*/
+ (void)del_curterm(cur_term);
errno = 0;
if (newterm(ttype, stdout, stdin) == NULL) {
if (errno)
@@ -368,6 +374,8 @@ cl_vi_init(sp)
fast: /* Set the terminal modes. */
if (tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &clp->vi_enter)) {
+ if (errno == EINTR)
+ goto fast;
msgq(sp, M_SYSERR, "tcsetattr");
err: (void)cl_vi_end(sp->gp);
return (1);
@@ -380,8 +388,7 @@ err: (void)cl_vi_end(sp->gp);
* Shutdown the vi screen.
*/
static int
-cl_vi_end(gp)
- GS *gp;
+cl_vi_end(GS *gp)
{
CL_PRIVATE *clp;
@@ -424,8 +431,7 @@ cl_vi_end(gp)
* Initialize the ex screen.
*/
static int
-cl_ex_init(sp)
- SCR *sp;
+cl_ex_init(SCR *sp)
{
CL_PRIVATE *clp;
@@ -486,6 +492,8 @@ cl_ex_init(sp)
#endif
fast: if (tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->ex_enter)) {
+ if (errno == EINTR)
+ goto fast;
msgq(sp, M_SYSERR, "tcsetattr");
return (1);
}
@@ -497,8 +505,7 @@ fast: if (tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->ex_enter)) {
* Shutdown the ex screen.
*/
static int
-cl_ex_end(gp)
- GS *gp;
+cl_ex_end(GS *gp)
{
CL_PRIVATE *clp;
@@ -516,9 +523,7 @@ cl_ex_end(gp)
* PUBLIC: int cl_getcap __P((SCR *, char *, char **));
*/
int
-cl_getcap(sp, name, elementp)
- SCR *sp;
- char *name, **elementp;
+cl_getcap(SCR *sp, char *name, char **elementp)
{
size_t len;
char *t;
@@ -536,8 +541,7 @@ cl_getcap(sp, name, elementp)
* Free any allocated termcap/terminfo strings.
*/
static void
-cl_freecap(clp)
- CL_PRIVATE *clp;
+cl_freecap(CL_PRIVATE *clp)
{
if (clp->el != NULL) {
free(clp->el);
@@ -559,6 +563,12 @@ cl_freecap(clp)
free(clp->smso);
clp->smso = NULL;
}
+ /* Required by libcursesw :) */
+ if (clp->cw.bp1.c != NULL) {
+ free(clp->cw.bp1.c);
+ clp->cw.bp1.c = NULL;
+ clp->cw.blen1 = 0;
+ }
}
/*
@@ -566,10 +576,7 @@ cl_freecap(clp)
* Put a value into the environment.
*/
static int
-cl_putenv(name, str, value)
- char *name, *str;
- u_long value;
-
+cl_putenv(char *name, char *str, u_long value)
{
char buf[40];
diff --git a/cl/cl_term.c b/cl/cl_term.c
index c36bb3830e9f..3d8cdb2e2b52 100644
--- a/cl/cl_term.c
+++ b/cl/cl_term.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_term.c 10.22 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: cl_term.c,v 10.33 2012/04/21 23:51:46 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -19,13 +19,15 @@ static const char sccsid[] = "@(#)cl_term.c 10.22 (Berkeley) 9/15/96";
#include <sys/stat.h>
#include <bitstring.h>
-#include <curses.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_TERM_H
+#include <term.h>
+#endif
#include <termios.h>
#include <unistd.h>
@@ -82,20 +84,30 @@ static TKLIST const m2_tklist[] = { /* Input mappings (set or delete). */
* PUBLIC: int cl_term_init __P((SCR *));
*/
int
-cl_term_init(sp)
- SCR *sp;
+cl_term_init(SCR *sp)
{
KEYLIST *kp;
SEQ *qp;
TKLIST const *tkp;
char *t;
+ CHAR_T name[60];
+ CHAR_T output[5];
+ CHAR_T ts[20];
+ CHAR_T *wp;
+ size_t wlen;
/* Command mappings. */
for (tkp = c_tklist; tkp->name != NULL; ++tkp) {
if ((t = tigetstr(tkp->ts)) == NULL || t == (char *)-1)
continue;
- if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t),
- tkp->output, strlen(tkp->output), SEQ_COMMAND,
+ CHAR2INT(sp, tkp->name, strlen(tkp->name), wp, wlen);
+ MEMCPY(name, wp, wlen);
+ CHAR2INT(sp, t, strlen(t), wp, wlen);
+ MEMCPY(ts, wp, wlen);
+ CHAR2INT(sp, tkp->output, strlen(tkp->output), wp, wlen);
+ MEMCPY(output, wp, wlen);
+ if (seq_set(sp, name, strlen(tkp->name), ts, strlen(t),
+ output, strlen(tkp->output), SEQ_COMMAND,
SEQ_NOOVERWRITE | SEQ_SCREEN))
return (1);
}
@@ -109,8 +121,13 @@ cl_term_init(sp)
break;
if (kp == NULL)
continue;
- if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t),
- &kp->ch, 1, SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
+ CHAR2INT(sp, tkp->name, strlen(tkp->name), wp, wlen);
+ MEMCPY(name, wp, wlen);
+ CHAR2INT(sp, t, strlen(t), wp, wlen);
+ MEMCPY(ts, wp, wlen);
+ output[0] = (UCHAR_T)kp->ch;
+ if (seq_set(sp, name, strlen(tkp->name), ts, strlen(t),
+ output, 1, SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
return (1);
}
@@ -128,22 +145,33 @@ cl_term_init(sp)
if (!strcmp(t, "\b"))
continue;
if (tkp->output == NULL) {
- if (seq_set(sp, tkp->name, strlen(tkp->name),
- t, strlen(t), NULL, 0,
+ CHAR2INT(sp, tkp->name, strlen(tkp->name), wp, wlen);
+ MEMCPY(name, wp, wlen);
+ CHAR2INT(sp, t, strlen(t), wp, wlen);
+ MEMCPY(ts, wp, wlen);
+ if (seq_set(sp, name, strlen(tkp->name),
+ ts, strlen(t), NULL, 0,
SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
return (1);
- } else
- if (seq_set(sp, tkp->name, strlen(tkp->name),
- t, strlen(t), tkp->output, strlen(tkp->output),
+ } else {
+ CHAR2INT(sp, tkp->name, strlen(tkp->name), wp, wlen);
+ MEMCPY(name, wp, wlen);
+ CHAR2INT(sp, t, strlen(t), wp, wlen);
+ MEMCPY(ts, wp, wlen);
+ CHAR2INT(sp, tkp->output, strlen(tkp->output), wp, wlen);
+ MEMCPY(output, wp, wlen);
+ if (seq_set(sp, name, strlen(tkp->name),
+ ts, strlen(t), output, strlen(tkp->output),
SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN))
return (1);
+ }
}
/*
* Rework any function key mappings that were set before the
* screen was initialized.
*/
- for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next)
+ SLIST_FOREACH(qp, sp->gp->seqq, q)
if (F_ISSET(qp, SEQ_FUNCMAP))
(void)cl_pfmap(sp, qp->stype,
qp->input, qp->ilen, qp->output, qp->olen);
@@ -157,17 +185,16 @@ cl_term_init(sp)
* PUBLIC: int cl_term_end __P((GS *));
*/
int
-cl_term_end(gp)
- GS *gp;
+cl_term_end(GS *gp)
{
SEQ *qp, *nqp;
/* Delete screen specific mappings. */
- for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
- nqp = qp->q.le_next;
- if (F_ISSET(qp, SEQ_SCREEN))
- (void)seq_mdel(qp);
- }
+ SLIST_FOREACH_SAFE(qp, gp->seqq, q, nqp)
+ if (F_ISSET(qp, SEQ_SCREEN)) {
+ SLIST_REMOVE_HEAD(gp->seqq, q);
+ (void)seq_free(qp);
+ }
return (0);
}
@@ -178,11 +205,7 @@ cl_term_end(gp)
* PUBLIC: int cl_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
*/
int
-cl_fmap(sp, stype, from, flen, to, tlen)
- SCR *sp;
- seq_t stype;
- CHAR_T *from, *to;
- size_t flen, tlen;
+cl_fmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to, size_t tlen)
{
/* Ignore until the screen is running, do the real work then. */
if (F_ISSET(sp, SC_VI) && !F_ISSET(sp, SC_SCR_VI))
@@ -198,28 +221,33 @@ cl_fmap(sp, stype, from, flen, to, tlen)
* Map a function key (private version).
*/
static int
-cl_pfmap(sp, stype, from, flen, to, tlen)
- SCR *sp;
- seq_t stype;
- CHAR_T *from, *to;
- size_t flen, tlen;
+cl_pfmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to, size_t tlen)
{
size_t nlen;
- char *p, keyname[64];
-
- (void)snprintf(keyname, sizeof(keyname), "kf%d", atoi(from + 1));
- if ((p = tigetstr(keyname)) == NULL ||
+ char *p;
+ char name[64];
+ CHAR_T keyname[64];
+ CHAR_T ts[20];
+ CHAR_T *wp;
+ size_t wlen;
+
+ (void)snprintf(name, sizeof(name), "kf%d",
+ (int)STRTOL(from+1,NULL,10));
+ if ((p = tigetstr(name)) == NULL ||
p == (char *)-1 || strlen(p) == 0)
p = NULL;
if (p == NULL) {
- msgq_str(sp, M_ERR, from, "233|This terminal has no %s key");
+ msgq_wstr(sp, M_ERR, from, "233|This terminal has no %s key");
return (1);
}
- nlen = snprintf(keyname,
- sizeof(keyname), "function key %d", atoi(from + 1));
+ nlen = SPRINTF(keyname,
+ SIZE(keyname), L("function key %d"),
+ (int)STRTOL(from+1,NULL,10));
+ CHAR2INT(sp, p, strlen(p), wp, wlen);
+ MEMCPY(ts, wp, wlen);
return (seq_set(sp, keyname, nlen,
- p, strlen(p), to, tlen, stype, SEQ_NOOVERWRITE | SEQ_SCREEN));
+ ts, strlen(p), to, tlen, stype, SEQ_NOOVERWRITE | SEQ_SCREEN));
}
/*
@@ -229,11 +257,7 @@ cl_pfmap(sp, stype, from, flen, to, tlen)
* PUBLIC: int cl_optchange __P((SCR *, int, char *, u_long *));
*/
int
-cl_optchange(sp, opt, str, valp)
- SCR *sp;
- int opt;
- char *str;
- u_long *valp;
+cl_optchange(SCR *sp, int opt, char *str, u_long *valp)
{
CL_PRIVATE *clp;
@@ -251,14 +275,10 @@ cl_optchange(sp, opt, str, valp)
F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
break;
case O_MESG:
- (void)cl_omesg(sp, clp, !*valp);
+ (void)cl_omesg(sp, clp, *valp);
break;
case O_WINDOWNAME:
if (*valp) {
- F_CLR(clp, CL_RENAME_OK);
-
- (void)cl_rename(sp, NULL, 0);
- } else {
F_SET(clp, CL_RENAME_OK);
/*
@@ -267,6 +287,10 @@ cl_optchange(sp, opt, str, valp)
*/
if (sp->frp != NULL && sp->frp->name != NULL)
(void)cl_rename(sp, sp->frp->name, 1);
+ } else {
+ F_CLR(clp, CL_RENAME_OK);
+
+ (void)cl_rename(sp, NULL, 0);
}
break;
}
@@ -280,10 +304,7 @@ cl_optchange(sp, opt, str, valp)
* PUBLIC: int cl_omesg __P((SCR *, CL_PRIVATE *, int));
*/
int
-cl_omesg(sp, clp, on)
- SCR *sp;
- CL_PRIVATE *clp;
- int on;
+cl_omesg(SCR *sp, CL_PRIVATE *clp, int on)
{
struct stat sb;
char *tty;
@@ -329,15 +350,9 @@ cl_omesg(sp, clp, on)
* PUBLIC: int cl_ssize __P((SCR *, int, size_t *, size_t *, int *));
*/
int
-cl_ssize(sp, sigwinch, rowp, colp, changedp)
- SCR *sp;
- int sigwinch;
- size_t *rowp, *colp;
- int *changedp;
+cl_ssize(SCR *sp, int sigwinch, size_t *rowp, size_t *colp, int *changedp)
{
-#ifdef TIOCGWINSZ
struct winsize win;
-#endif
size_t col, row;
int rval;
char *p;
@@ -358,12 +373,10 @@ cl_ssize(sp, sigwinch, rowp, colp, changedp)
* Try TIOCGWINSZ.
*/
row = col = 0;
-#ifdef TIOCGWINSZ
if (ioctl(STDERR_FILENO, TIOCGWINSZ, &win) != -1) {
row = win.ws_row;
col = win.ws_col;
}
-#endif
/* If here because of suspend or a signal, only trust TIOCGWINSZ. */
if (sigwinch) {
/*
@@ -453,8 +466,7 @@ noterm: if (row == 0)
* PUBLIC: int cl_putchar __P((int));
*/
int
-cl_putchar(ch)
- int ch;
+cl_putchar(int ch)
{
return (putchar(ch));
}
diff --git a/include/cl_extern.h b/cl/extern.h
index bafeb944e969..626f4fbea167 100644
--- a/include/cl_extern.h
+++ b/cl/extern.h
@@ -1,32 +1,4 @@
-#ifndef HAVE_CURSES_ADDNSTR
-int addnstr __P((char *, int));
-#endif
-#ifndef HAVE_CURSES_BEEP
-void beep __P((void));
-#endif
-#ifndef HAVE_CURSES_FLASH
-void flash __P((void));
-#endif
-#ifndef HAVE_CURSES_IDLOK
-void idlok __P((WINDOW *, int));
-#endif
-#ifndef HAVE_CURSES_KEYPAD
-int keypad __P((void *, int));
-#endif
-#ifndef HAVE_CURSES_NEWTERM
-void *newterm __P((const char *, FILE *, FILE *));
-#endif
-#ifndef HAVE_CURSES_SETUPTERM
-void setupterm __P((char *, int, int *));
-#endif
-#ifdef HAVE_CURSES_TIGETSTR
-char *tigetstr();
-#else
-char *tigetstr __P((char *));
-#endif
-#ifndef HAVE_CURSES_TIGETSTR
-int tigetnum __P((char *));
-#endif
+int cl_waddstr __P((SCR *, const CHAR_T *, size_t));
int cl_addstr __P((SCR *, const char *, size_t));
int cl_attr __P((SCR *, scr_attr_t, int));
int cl_baud __P((SCR *, u_long *));
@@ -34,12 +6,15 @@ int cl_bell __P((SCR *));
int cl_clrtoeol __P((SCR *));
int cl_cursor __P((SCR *, size_t *, size_t *));
int cl_deleteln __P((SCR *));
+int cl_discard __P((SCR *, SCR **));
int cl_ex_adjust __P((SCR *, exadj_t));
int cl_insertln __P((SCR *));
int cl_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
int cl_move __P((SCR *, size_t, size_t));
int cl_refresh __P((SCR *, int));
int cl_rename __P((SCR *, char *, int));
+void cl_setname __P((GS *, char *));
+int cl_split __P((SCR *, SCR *));
int cl_suspend __P((SCR *, int *));
void cl_usage __P((void));
int sig_init __P((GS *, SCR *));
diff --git a/clib/env.c b/clib/env.c
deleted file mode 100644
index 5a45dc1760a6..000000000000
--- a/clib/env.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 1987, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)getenv.c 8.1 (Berkeley) 6/4/93";
-static const char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdlib.h>
-#include <string.h>
-
-/*
- * __findenv --
- * Returns pointer to value associated with name, if any, else NULL.
- * Sets offset to be the offset of the name/value combination in the
- * environmental array, for use by setenv(3) and unsetenv(3).
- * Explicitly removes '=' in argument name.
- *
- * This routine *should* be a static; don't use it.
- */
-static char *
-__findenv(name, offset)
- register char *name;
- int *offset;
-{
- extern char **environ;
- register int len;
- register char *np;
- register char **p, *c;
-
- if (name == NULL || environ == NULL)
- return (NULL);
- for (np = name; *np && *np != '='; ++np)
- continue;
- len = np - name;
- for (p = environ; (c = *p) != NULL; ++p)
- if (strncmp(c, name, len) == 0 && c[len] == '=') {
- *offset = p - environ;
- return (c + len + 1);
- }
- return (NULL);
-}
-
-#ifndef HAVE_SETENV
-/*
- * setenv --
- * Set the value of the environmental variable "name" to be
- * "value". If rewrite is set, replace any current value.
- *
- * PUBLIC: #ifndef HAVE_SETENV
- * PUBLIC: int setenv __P((const char *, const char *, int));
- * PUBLIC: #endif
- */
-setenv(name, value, rewrite)
- register char *name;
- register char *value;
- int rewrite;
-{
- extern char **environ;
- static int alloced; /* if allocated space before */
- register char *c;
- int l_value, offset;
-
- if (*value == '=') /* no `=' in value */
- ++value;
- l_value = strlen(value);
- if ((c = __findenv(name, &offset))) { /* find if already exists */
- if (!rewrite)
- return (0);
- if (strlen(c) >= l_value) { /* old larger; copy over */
- while (*c++ = *value++);
- return (0);
- }
- } else { /* create new slot */
- register int cnt;
- register char **p;
-
- for (p = environ, cnt = 0; *p; ++p, ++cnt);
- if (alloced) { /* just increase size */
- environ = (char **)realloc((char *)environ,
- (size_t)(sizeof(char *) * (cnt + 2)));
- if (!environ)
- return (-1);
- }
- else { /* get new space */
- alloced = 1; /* copy old entries into it */
- p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
- if (!p)
- return (-1);
- memmove(p, environ, cnt * sizeof(char *));
- environ = p;
- }
- environ[cnt + 1] = NULL;
- offset = cnt;
- }
- for (c = (char *)name; *c && *c != '='; ++c); /* no `=' in name */
- if (!(environ[offset] = /* name + `=' + value */
- malloc((size_t)((int)(c - name) + l_value + 2))))
- return (-1);
- for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
- for (*c++ = '='; *c++ = *value++;);
- return (0);
-}
-#endif
-
-#ifndef HAVE_UNSETENV
-/*
- * unsetenv(name) --
- * Delete environmental variable "name".
- *
- * PUBLIC: #ifndef HAVE_UNSETENV
- * PUBLIC: void unsetenv __P((const char *));
- * PUBLIC: #endif
- */
-void
-unsetenv(name)
- char *name;
-{
- extern char **environ;
- register char **p;
- int offset;
-
- while (__findenv(name, &offset)) /* if set multiple times */
- for (p = &environ[offset];; ++p)
- if (!(*p = *(p + 1)))
- break;
-}
-#endif
diff --git a/clib/gethostname.c b/clib/gethostname.c
deleted file mode 100644
index 5b8e85acf9f2..000000000000
--- a/clib/gethostname.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "config.h"
-
-/*
- * Solaris doesn't include the gethostname call by default.
- */
-#include <sys/utsname.h>
-#include <sys/systeminfo.h>
-
-#include <netdb.h>
-
-/*
- * PUBLIC: #ifndef HAVE_GETHOSTNAME
- * PUBLIC: int gethostname __P((char *, int));
- * PUBLIC: #endif
- */
-int
-gethostname(host, len)
- char *host;
- int len;
-{
- return (sysinfo(SI_HOSTNAME, host, len) == -1 ? -1 : 0);
-}
diff --git a/clib/getopt.c b/clib/getopt.c
deleted file mode 100644
index b173017503e1..000000000000
--- a/clib/getopt.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 1987, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int opterr = 1, /* if error message should be printed */
- optind = 1, /* index into parent argv vector */
- optopt, /* character checked for validity */
- optreset; /* reset getopt */
-char *optarg; /* argument associated with option */
-
-#define BADCH (int)'?'
-#define BADARG (int)':'
-#define EMSG ""
-
-/*
- * getopt --
- * Parse argc/argv argument vector.
- *
- * PUBLIC: #ifndef HAVE_GETOPT
- * PUBLIC: int getopt __P((int, char * const *, const char *));
- * PUBLIC: #endif
- */
-int
-getopt(nargc, nargv, ostr)
- int nargc;
- char * const *nargv;
- const char *ostr;
-{
- static char *progname;
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
-
- if (!progname) {
- if ((progname = strrchr(*nargv, '/')) == NULL)
- progname = *nargv;
- else
- ++progname;
- }
-
- if (optreset || !*place) { /* update scanning pointer */
- optreset = 0;
- if (optind >= nargc || *(place = nargv[optind]) != '-') {
- place = EMSG;
- return (EOF);
- }
- if (place[1] && *++place == '-') { /* found "--" */
- ++optind;
- place = EMSG;
- return (EOF);
- }
- } /* option letter okay? */
- if ((optopt = (int)*place++) == (int)':' ||
- !(oli = strchr(ostr, optopt))) {
- /*
- * if the user didn't specify '-' as an option,
- * assume it means EOF.
- */
- if (optopt == (int)'-')
- return (EOF);
- if (!*place)
- ++optind;
- if (opterr && *ostr != ':')
- (void)fprintf(stderr,
- "%s: illegal option -- %c\n", progname, optopt);
- return (BADCH);
- }
- if (*++oli != ':') { /* don't need argument */
- optarg = NULL;
- if (!*place)
- ++optind;
- }
- else { /* need an argument */
- if (*place) /* no white space */
- optarg = place;
- else if (nargc <= ++optind) { /* no arg */
- place = EMSG;
- if (*ostr == ':')
- return (BADARG);
- if (opterr)
- (void)fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- progname, optopt);
- return (BADCH);
- }
- else /* white space */
- optarg = nargv[optind];
- place = EMSG;
- ++optind;
- }
- return (optopt); /* dump back option letter */
-}
diff --git a/clib/memmove.c b/clib/memmove.c
deleted file mode 100644
index 7f4376272b67..000000000000
--- a/clib/memmove.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <string.h>
-
-/*
- * sizeof(word) MUST BE A POWER OF TWO
- * SO THAT wmask BELOW IS ALL ONES
- */
-typedef int word; /* "word" used for optimal copy speed */
-
-#define wsize sizeof(word)
-#define wmask (wsize - 1)
-
-/*
- * Copy a block of memory, handling overlap.
- * This is the routine that actually implements
- * (the portable versions of) bcopy, memcpy, and memmove.
- *
- * PUBLIC: #ifndef HAVE_MEMCPY
- * PUBLIC: void *memcpy __P((void *, const void *, size_t));
- * PUBLIC: #endif
- * PUBLIC: #ifndef HAVE_MEMMOVE
- * PUBLIC: void *memmove __P((void *, const void *, size_t));
- * PUBLIC: #endif
- */
-#ifdef MEMCOPY
-void *
-memcpy(dst0, src0, length)
-#else
-#ifdef MEMMOVE
-void *
-memmove(dst0, src0, length)
-#else
-void
-bcopy(src0, dst0, length)
-#endif
-#endif
- void *dst0;
- const void *src0;
- register size_t length;
-{
- register char *dst = dst0;
- register const char *src = src0;
- register size_t t;
-
- if (length == 0 || dst == src) /* nothing to do */
- goto done;
-
- /*
- * Macros: loop-t-times; and loop-t-times, t>0
- */
-#define TLOOP(s) if (t) TLOOP1(s)
-#define TLOOP1(s) do { s; } while (--t)
-
- if ((unsigned long)dst < (unsigned long)src) {
- /*
- * Copy forward.
- */
- t = (int)src; /* only need low bits */
- if ((t | (int)dst) & wmask) {
- /*
- * Try to align operands. This cannot be done
- * unless the low bits match.
- */
- if ((t ^ (int)dst) & wmask || length < wsize)
- t = length;
- else
- t = wsize - (t & wmask);
- length -= t;
- TLOOP1(*dst++ = *src++);
- }
- /*
- * Copy whole words, then mop up any trailing bytes.
- */
- t = length / wsize;
- TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
- t = length & wmask;
- TLOOP(*dst++ = *src++);
- } else {
- /*
- * Copy backwards. Otherwise essentially the same.
- * Alignment works as before, except that it takes
- * (t&wmask) bytes to align, not wsize-(t&wmask).
- */
- src += length;
- dst += length;
- t = (int)src;
- if ((t | (int)dst) & wmask) {
- if ((t ^ (int)dst) & wmask || length <= wsize)
- t = length;
- else
- t &= wmask;
- length -= t;
- TLOOP1(*--dst = *--src);
- }
- t = length / wsize;
- TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
- t = length & wmask;
- TLOOP(*--dst = *--src);
- }
-done:
-#if defined(MEMCOPY) || defined(MEMMOVE)
- return (dst0);
-#else
- return;
-#endif
-}
diff --git a/clib/memset.c b/clib/memset.c
deleted file mode 100644
index 0013d66df06d..000000000000
--- a/clib/memset.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Mike Hibler and Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-
-#include <limits.h>
-#include <string.h>
-
-/*
- * PUBLIC: #ifndef HAVE_MEMSET
- * PUBLIC: void *memset __P((void *, int, size_t));
- * PUBLIC: #endif
- */
-#define wsize sizeof(u_int)
-#define wmask (wsize - 1)
-
-#ifdef BZERO
-#define RETURN return
-#define VAL 0
-#define WIDEVAL 0
-
-void
-bzero(dst0, length)
- void *dst0;
- register size_t length;
-#else
-#define RETURN return (dst0)
-#define VAL c0
-#define WIDEVAL c
-
-void *
-memset(dst0, c0, length)
- void *dst0;
- register int c0;
- register size_t length;
-#endif
-{
- register size_t t;
- register u_int c;
- register u_char *dst;
-
- dst = dst0;
- /*
- * If not enough words, just fill bytes. A length >= 2 words
- * guarantees that at least one of them is `complete' after
- * any necessary alignment. For instance:
- *
- * |-----------|-----------|-----------|
- * |00|01|02|03|04|05|06|07|08|09|0A|00|
- * ^---------------------^
- * dst dst+length-1
- *
- * but we use a minimum of 3 here since the overhead of the code
- * to do word writes is substantial.
- */
- if (length < 3 * wsize) {
- while (length != 0) {
- *dst++ = VAL;
- --length;
- }
- RETURN;
- }
-
-#ifndef BZERO
- if ((c = (u_char)c0) != 0) { /* Fill the word. */
- c = (c << 8) | c; /* u_int is 16 bits. */
-#if UINT_MAX > 0xffff
- c = (c << 16) | c; /* u_int is 32 bits. */
-#endif
-#if UINT_MAX > 0xffffffff
- c = (c << 32) | c; /* u_int is 64 bits. */
-#endif
- }
-#endif
- /* Align destination by filling in bytes. */
- if ((t = (int)dst & wmask) != 0) {
- t = wsize - t;
- length -= t;
- do {
- *dst++ = VAL;
- } while (--t != 0);
- }
-
- /* Fill words. Length was >= 2*words so we know t >= 1 here. */
- t = length / wsize;
- do {
- *(u_int *)dst = WIDEVAL;
- dst += wsize;
- } while (--t != 0);
-
- /* Mop up trailing bytes, if any. */
- t = length & wmask;
- if (t != 0)
- do {
- *dst++ = VAL;
- } while (--t != 0);
- RETURN;
-}
diff --git a/clib/mkstemp.c b/clib/mkstemp.c
deleted file mode 100644
index 1faffddfbe2d..000000000000
--- a/clib/mkstemp.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 1987, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <ctype.h>
-
-static int _gettemp();
-
-/*
- * PUBLIC: #ifndef HAVE_MKSTEMP
- * PUBLIC: int mkstemp __P((char *));
- * PUBLIC: #endif
- */
-mkstemp(path)
- char *path;
-{
- int fd;
-
- return (_gettemp(path, &fd) ? fd : -1);
-}
-
-char *
-mktemp(path)
- char *path;
-{
- return(_gettemp(path, (int *)NULL) ? path : (char *)NULL);
-}
-
-static
-_gettemp(path, doopen)
- char *path;
- register int *doopen;
-{
- extern int errno;
- register char *start, *trv;
- struct stat sbuf;
- u_int pid;
-
- pid = getpid();
- for (trv = path; *trv; ++trv); /* extra X's get set to 0's */
- while (*--trv == 'X') {
- *trv = (pid % 10) + '0';
- pid /= 10;
- }
-
- /*
- * check the target directory; if you have six X's and it
- * doesn't exist this runs for a *very* long time.
- */
- for (start = trv + 1;; --trv) {
- if (trv <= path)
- break;
- if (*trv == '/') {
- *trv = '\0';
- if (stat(path, &sbuf))
- return(0);
- if (!S_ISDIR(sbuf.st_mode)) {
- errno = ENOTDIR;
- return(0);
- }
- *trv = '/';
- break;
- }
- }
-
- for (;;) {
- if (doopen) {
- if ((*doopen =
- open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
- return(1);
- if (errno != EEXIST)
- return(0);
- }
- else if (stat(path, &sbuf))
- return(errno == ENOENT ? 1 : 0);
-
- /* tricky little algorithm for backward compatibility */
- for (trv = start;;) {
- if (!*trv)
- return(0);
- if (*trv == 'z')
- *trv++ = 'a';
- else {
- if (isdigit(*trv))
- *trv = 'a';
- else
- ++*trv;
- break;
- }
- }
- }
- /*NOTREACHED*/
-}
diff --git a/clib/mmap.c b/clib/mmap.c
deleted file mode 100644
index 7cea169650b4..000000000000
--- a/clib/mmap.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "config.h"
-
-#include <sys/types.h>
-
-#include <stdlib.h>
-#include <unistd.h>
-
-/*
- * This function fakes mmap() by reading `len' bytes from the file descriptor
- * `fd' and returning a pointer to that memory. The "mapped" region can later
- * be deallocated with munmap().
- *
- * Note: ONLY reading is supported and only reading of the exact size of the
- * file will work.
- *
- * PUBLIC: #ifndef HAVE_MMAP
- * PUBLIC: char *mmap __P((char *, size_t, int, int, int, off_t));
- * PUBLIC: #endif
- */
-char *
-mmap(addr, len, prot, flags, fd, off)
- char *addr;
- size_t len;
- int prot, flags, fd;
- off_t off;
-{
- char *ptr;
-
- if ((ptr = (char *)malloc(len)) == 0)
- return ((char *)-1);
- if (read(fd, ptr, len) < 0) {
- free(ptr);
- return ((char *)-1);
- }
- return (ptr);
-}
-
-/*
- * PUBLIC: #ifndef HAVE_MMAP
- * PUBLIC: int munmap __P((char *, size_t));
- * PUBLIC: #endif
- */
-int
-munmap(addr, len)
- char *addr;
- size_t len;
-{
- free(addr);
- return (0);
-}
diff --git a/clib/snprintf.c b/clib/snprintf.c
deleted file mode 100644
index 935522ce5436..000000000000
--- a/clib/snprintf.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "config.h"
-
-#include <sys/types.h>
-
-#include <stdio.h>
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-/*
- * PUBLIC: #ifndef HAVE_SNPRINTF
- * PUBLIC: int snprintf __P((char *, size_t, const char *, ...));
- * PUBLIC: #endif
- */
-int
-#ifdef __STDC__
-snprintf(char *str, size_t n, const char *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
- char *str;
- size_t n;
- const char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
- int rval;
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
-#ifdef SPRINTF_RET_CHARPNT
- (void)vsprintf(str, fmt, ap);
- va_end(ap);
- return (strlen(str));
-#else
- rval = vsprintf(str, fmt, ap);
- va_end(ap);
- return (rval);
-#endif
-}
diff --git a/clib/strerror.c b/clib/strerror.c
deleted file mode 100644
index cf5910d0fc83..000000000000
--- a/clib/strerror.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <string.h>
-
-/*
- * PUBLIC: #ifndef HAVE_STRERROR
- * PUBLIC: char *strerror __P((int));
- * PUBLIC: #endif
- */
-char *
-strerror(num)
- int num;
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
-#define UPREFIX "Unknown error: "
- static char ebuf[40] = UPREFIX; /* 64-bit number + slop */
- register unsigned int errnum;
- register char *p, *t;
- char tmp[40];
-
- errnum = num; /* convert to unsigned */
- if (errnum < sys_nerr)
- return(sys_errlist[errnum]);
-
- /* Do this by hand, so we don't include stdio(3). */
- t = tmp;
- do {
- *t++ = "0123456789"[errnum % 10];
- } while (errnum /= 10);
- for (p = ebuf + sizeof(UPREFIX) - 1;;) {
- *p++ = *--t;
- if (t <= tmp)
- break;
- }
- return(ebuf);
-}
diff --git a/clib/strsep.c b/clib/strsep.c
deleted file mode 100644
index 33115f0e4121..000000000000
--- a/clib/strsep.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <string.h>
-#include <stdio.h>
-
-/*
- * Get next token from string *stringp, where tokens are possibly-empty
- * strings separated by characters from delim.
- *
- * Writes NULs into the string at *stringp to end tokens.
- * delim need not remain constant from call to call.
- * On return, *stringp points past the last NUL written (if there might
- * be further tokens), or is NULL (if there are definitely no more tokens).
- *
- * If *stringp is NULL, strsep returns NULL.
- *
- * PUBLIC: #ifndef HAVE_STRSEP
- * PUBLIC: char *strsep __P((char **, const char *));
- * PUBLIC: #endif
- */
-char *
-strsep(stringp, delim)
- register char **stringp;
- register const char *delim;
-{
- register char *s;
- register const char *spanp;
- register int c, sc;
- char *tok;
-
- if ((s = *stringp) == NULL)
- return (NULL);
- for (tok = s;;) {
- c = *s++;
- spanp = delim;
- do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
- s = NULL;
- else
- s[-1] = 0;
- *stringp = s;
- return (tok);
- }
- } while (sc != 0);
- }
- /* NOTREACHED */
-}
diff --git a/clib/strtol.c b/clib/strtol.c
deleted file mode 100644
index 50c724ff432f..000000000000
--- a/clib/strtol.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <limits.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/*
- * Convert a string to a long integer.
- *
- * Ignores `locale' stuff. Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- *
- * PUBLIC: #ifndef HAVE_STRTOL
- * PUBLIC: long strtol __P((const char *, char **, int));
- * PUBLIC: #endif
- */
-long
-strtol(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- register int base;
-{
- register const char *s = nptr;
- register unsigned long acc;
- register int c;
- register unsigned long cutoff;
- register int neg = 0, any, cutlim;
-
- /*
- * Skip white space and pick up leading +/- sign if any.
- * If base is 0, allow 0x for hex and 0 for octal, else
- * assume decimal; if base is already 16, allow 0x.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
-
- /*
- * Compute the cutoff value between legal numbers and illegal
- * numbers. That is the largest legal value, divided by the
- * base. An input number that is greater than this value, if
- * followed by a legal input character, is too big. One that
- * is equal to this value may be valid or not; the limit
- * between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for longs is
- * [-2147483648..2147483647] and the input base is 10,
- * cutoff will be set to 214748364 and cutlim to either
- * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
- * a value > 214748364, or equal but the next digit is > 7 (or 8),
- * the number is too big, and we will return a range error.
- *
- * Set any if any `digits' consumed; make it negative to indicate
- * overflow.
- */
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
- cutlim = cutoff % (unsigned long)base;
- cutoff /= (unsigned long)base;
- for (acc = 0, any = 0;; c = *s++) {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = neg ? LONG_MIN : LONG_MAX;
- errno = ERANGE;
- } else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = (char *)(any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/clib/strtoul.c b/clib/strtoul.c
deleted file mode 100644
index 890bdbd747a7..000000000000
--- a/clib/strtoul.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <limits.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/*
- * Convert a string to an unsigned long integer.
- *
- * Ignores `locale' stuff. Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- *
- * PUBLIC: #ifndef HAVE_STRTOUL
- * PUBLIC: unsigned long strtoul __P((const char *, char **, int));
- * PUBLIC: #endif
- */
-unsigned long
-strtoul(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- register int base;
-{
- register const char *s = nptr;
- register unsigned long acc;
- register int c;
- register unsigned long cutoff;
- register int neg = 0, any, cutlim;
-
- /*
- * See strtol for comments as to the logic used.
- */
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else if (c == '+')
- c = *s++;
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
- cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
- for (acc = 0, any = 0;; c = *s++) {
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
- any = -1;
- else {
- any = 1;
- acc *= base;
- acc += c;
- }
- }
- if (any < 0) {
- acc = ULONG_MAX;
- errno = ERANGE;
- } else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = (char *)(any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/clib/vsnprintf.c b/clib/vsnprintf.c
deleted file mode 100644
index a1b013ad196f..000000000000
--- a/clib/vsnprintf.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "config.h"
-
-#include <sys/types.h>
-
-#include <stdio.h>
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-/*
- * PUBLIC: #ifndef HAVE_VSNPRINTF
- * PUBLIC: int vsnprintf __P((char *, size_t, const char *, ...));
- * PUBLIC: #endif
- */
-int
-vsnprintf(str, n, fmt, ap)
- char *str;
- size_t n;
- const char *fmt;
- va_list ap;
-{
-#ifdef SPRINTF_RET_CHARPNT
- (void)vsprintf(str, fmt, ap);
- return (strlen(str));
-#else
- return (vsprintf(str, fmt, ap));
-#endif
-}
diff --git a/common/api.c b/common/api.c
deleted file mode 100644
index 35d9f0c8f66e..000000000000
--- a/common/api.c
+++ /dev/null
@@ -1,525 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- * Copyright (c) 1995
- * George V. Neville-Neil. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)api.c 8.26 (Berkeley) 10/14/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-extern GS *__global_list; /* XXX */
-
-/*
- * api_fscreen --
- * Return a pointer to the screen specified by the screen id
- * or a file name.
- *
- * PUBLIC: SCR *api_fscreen __P((int, char *));
- */
-SCR *
-api_fscreen(id, name)
- int id;
- char *name;
-{
- GS *gp;
- SCR *tsp;
-
- gp = __global_list;
-
- /* Search the displayed list. */
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
- if (name == NULL) {
- if (id == tsp->id)
- return (tsp);
- } else if (!strcmp(name, tsp->frp->name))
- return (tsp);
-
- /* Search the hidden list. */
- for (tsp = gp->hq.cqh_first;
- tsp != (void *)&gp->hq; tsp = tsp->q.cqe_next)
- if (name == NULL) {
- if (id == tsp->id)
- return (tsp);
- } else if (!strcmp(name, tsp->frp->name))
- return (tsp);
- return (NULL);
-}
-
-/*
- * api_aline --
- * Append a line.
- *
- * PUBLIC: int api_aline __P((SCR *, recno_t, char *, size_t));
- */
-int
-api_aline(sp, lno, line, len)
- SCR *sp;
- recno_t lno;
- char *line;
- size_t len;
-{
- return (db_append(sp, 1, lno, line, len));
-}
-
-/*
- * api_dline --
- * Delete a line.
- *
- * PUBLIC: int api_dline __P((SCR *, recno_t));
- */
-int
-api_dline(sp, lno)
- SCR *sp;
- recno_t lno;
-{
- return (db_delete(sp, lno));
-}
-
-/*
- * api_gline --
- * Get a line.
- *
- * PUBLIC: int api_gline __P((SCR *, recno_t, char **, size_t *));
- */
-int
-api_gline(sp, lno, linepp, lenp)
- SCR *sp;
- recno_t lno;
- char **linepp;
- size_t *lenp;
-{
- int isempty;
-
- if (db_eget(sp, lno, linepp, lenp, &isempty)) {
- if (isempty)
- msgq(sp, M_ERR, "209|The file is empty");
- return (1);
- }
- return (0);
-}
-
-/*
- * api_iline --
- * Insert a line.
- *
- * PUBLIC: int api_iline __P((SCR *, recno_t, char *, size_t));
- */
-int
-api_iline(sp, lno, line, len)
- SCR *sp;
- recno_t lno;
- char *line;
- size_t len;
-{
- return (db_insert(sp, lno, line, len));
-}
-
-/*
- * api_lline --
- * Return the line number of the last line in the file.
- *
- * PUBLIC: int api_lline __P((SCR *, recno_t *));
- */
-int
-api_lline(sp, lnop)
- SCR *sp;
- recno_t *lnop;
-{
- return (db_last(sp, lnop));
-}
-
-/*
- * api_sline --
- * Set a line.
- *
- * PUBLIC: int api_sline __P((SCR *, recno_t, char *, size_t));
- */
-int
-api_sline(sp, lno, line, len)
- SCR *sp;
- recno_t lno;
- char *line;
- size_t len;
-{
- return (db_set(sp, lno, line, len));
-}
-
-/*
- * api_getmark --
- * Get the mark.
- *
- * PUBLIC: int api_getmark __P((SCR *, int, MARK *));
- */
-int
-api_getmark(sp, markname, mp)
- SCR *sp;
- int markname;
- MARK *mp;
-{
- return (mark_get(sp, (ARG_CHAR_T)markname, mp, M_ERR));
-}
-
-/*
- * api_setmark --
- * Set the mark.
- *
- * PUBLIC: int api_setmark __P((SCR *, int, MARK *));
- */
-int
-api_setmark(sp, markname, mp)
- SCR *sp;
- int markname;
- MARK *mp;
-{
- return (mark_set(sp, (ARG_CHAR_T)markname, mp, 1));
-}
-
-/*
- * api_nextmark --
- * Return the first mark if next not set, otherwise return the
- * subsequent mark.
- *
- * PUBLIC: int api_nextmark __P((SCR *, int, char *));
- */
-int
-api_nextmark(sp, next, namep)
- SCR *sp;
- int next;
- char *namep;
-{
- LMARK *mp;
-
- mp = sp->ep->marks.lh_first;
- if (next)
- for (; mp != NULL; mp = mp->q.le_next)
- if (mp->name == *namep) {
- mp = mp->q.le_next;
- break;
- }
- if (mp == NULL)
- return (1);
- *namep = mp->name;
- return (0);
-}
-
-/*
- * api_getcursor --
- * Get the cursor.
- *
- * PUBLIC: int api_getcursor __P((SCR *, MARK *));
- */
-int
-api_getcursor(sp, mp)
- SCR *sp;
- MARK *mp;
-{
- mp->lno = sp->lno;
- mp->cno = sp->cno;
- return (0);
-}
-
-/*
- * api_setcursor --
- * Set the cursor.
- *
- * PUBLIC: int api_setcursor __P((SCR *, MARK *));
- */
-int
-api_setcursor(sp, mp)
- SCR *sp;
- MARK *mp;
-{
- size_t len;
-
- if (db_get(sp, mp->lno, DBG_FATAL, NULL, &len))
- return (1);
- if (mp->cno < 0 || mp->cno > len) {
- msgq(sp, M_ERR, "Cursor set to nonexistent column");
- return (1);
- }
-
- /* Set the cursor. */
- sp->lno = mp->lno;
- sp->cno = mp->cno;
- return (0);
-}
-
-/*
- * api_emessage --
- * Print an error message.
- *
- * PUBLIC: void api_emessage __P((SCR *, char *));
- */
-void
-api_emessage(sp, text)
- SCR *sp;
- char *text;
-{
- msgq(sp, M_ERR, "%s", text);
-}
-
-/*
- * api_imessage --
- * Print an informational message.
- *
- * PUBLIC: void api_imessage __P((SCR *, char *));
- */
-void
-api_imessage(sp, text)
- SCR *sp;
- char *text;
-{
- msgq(sp, M_INFO, "%s", text);
-}
-
-/*
- * api_edit
- * Create a new screen and return its id
- * or edit a new file in the current screen.
- *
- * PUBLIC: int api_edit __P((SCR *, char *, SCR **, int));
- */
-int
-api_edit(sp, file, spp, newscreen)
- SCR *sp;
- char *file;
- SCR **spp;
- int newscreen;
-{
- ARGS *ap[2], a;
- EXCMD cmd;
-
- if (file) {
- ex_cinit(&cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0, ap);
- ex_cadd(&cmd, &a, file, strlen(file));
- } else
- ex_cinit(&cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0, NULL);
- if (newscreen)
- cmd.flags |= E_NEWSCREEN; /* XXX */
- if (cmd.cmd->fn(sp, &cmd))
- return (1);
- *spp = sp->nextdisp;
- return (0);
-}
-
-/*
- * api_escreen
- * End a screen.
- *
- * PUBLIC: int api_escreen __P((SCR *));
- */
-int
-api_escreen(sp)
- SCR *sp;
-{
- EXCMD cmd;
-
- /*
- * XXX
- * If the interpreter exits anything other than the current
- * screen, vi isn't going to update everything correctly.
- */
- ex_cinit(&cmd, C_QUIT, 0, OOBLNO, OOBLNO, 0, NULL);
- return (cmd.cmd->fn(sp, &cmd));
-}
-
-/*
- * api_swscreen --
- * Switch to a new screen.
- *
- * PUBLIC: int api_swscreen __P((SCR *, SCR *));
- */
-int
-api_swscreen(sp, new)
- SCR *sp, *new;
-{
- /*
- * XXX
- * If the interpreter switches from anything other than the
- * current screen, vi isn't going to update everything correctly.
- */
- sp->nextdisp = new;
- F_SET(sp, SC_SSWITCH);
-
- return (0);
-}
-
-/*
- * api_map --
- * Map a key.
- *
- * PUBLIC: int api_map __P((SCR *, char *, char *, size_t));
- */
-int
-api_map(sp, name, map, len)
- SCR *sp;
- char *name, *map;
- size_t len;
-{
- ARGS *ap[3], a, b;
- EXCMD cmd;
-
- ex_cinit(&cmd, C_MAP, 0, OOBLNO, OOBLNO, 0, ap);
- ex_cadd(&cmd, &a, name, strlen(name));
- ex_cadd(&cmd, &b, map, len);
- return (cmd.cmd->fn(sp, &cmd));
-}
-
-/*
- * api_unmap --
- * Unmap a key.
- *
- * PUBLIC: int api_unmap __P((SCR *, char *));
- */
-int
-api_unmap(sp, name)
- SCR *sp;
- char *name;
-{
- ARGS *ap[2], a;
- EXCMD cmd;
-
- ex_cinit(&cmd, C_UNMAP, 0, OOBLNO, OOBLNO, 0, ap);
- ex_cadd(&cmd, &a, name, strlen(name));
- return (cmd.cmd->fn(sp, &cmd));
-}
-
-/*
- * api_opts_get --
- * Return a option value as a string, in allocated memory.
- * If the option is of type boolean, boolvalue is (un)set
- * according to the value; otherwise boolvalue is -1.
- *
- * PUBLIC: int api_opts_get __P((SCR *, char *, char **, int *));
- */
-int
-api_opts_get(sp, name, value, boolvalue)
- SCR *sp;
- char *name, **value;
- int *boolvalue;
-{
- OPTLIST const *op;
- int offset;
-
- if ((op = opts_search(name)) == NULL) {
- opts_nomatch(sp, name);
- return (1);
- }
-
- offset = op - optlist;
- if (boolvalue != NULL)
- *boolvalue = -1;
- switch (op->type) {
- case OPT_0BOOL:
- case OPT_1BOOL:
- MALLOC_RET(sp, *value, char *, strlen(op->name) + 2 + 1);
- (void)sprintf(*value,
- "%s%s", O_ISSET(sp, offset) ? "" : "no", op->name);
- if (boolvalue != NULL)
- *boolvalue = O_ISSET(sp, offset);
- break;
- case OPT_NUM:
- MALLOC_RET(sp, *value, char *, 20);
- (void)sprintf(*value, "%lu", (u_long)O_VAL(sp, offset));
- break;
- case OPT_STR:
- if (O_STR(sp, offset) == NULL) {
- MALLOC_RET(sp, *value, char *, 2);
- value[0] = '\0';
- } else {
- MALLOC_RET(sp,
- *value, char *, strlen(O_STR(sp, offset)) + 1);
- (void)sprintf(*value, "%s", O_STR(sp, offset));
- }
- break;
- }
- return (0);
-}
-
-/*
- * api_opts_set --
- * Set options.
- *
- * PUBLIC: int api_opts_set __P((SCR *, char *, char *, u_long, int));
- */
-int
-api_opts_set(sp, name, str_value, num_value, bool_value)
- SCR *sp;
- char *name, *str_value;
- u_long num_value;
- int bool_value;
-{
- ARGS *ap[2], a, b;
- OPTLIST const *op;
- int rval;
- size_t blen;
- char *bp;
-
- if ((op = opts_search(name)) == NULL) {
- opts_nomatch(sp, name);
- return (1);
- }
-
- switch (op->type) {
- case OPT_0BOOL:
- case OPT_1BOOL:
- GET_SPACE_RET(sp, bp, blen, 64);
- a.len = snprintf(bp, 64, "%s%s", bool_value ? "" : "no", name);
- break;
- case OPT_NUM:
- GET_SPACE_RET(sp, bp, blen, 64);
- a.len = snprintf(bp, 64, "%s=%lu", name, num_value);
- break;
- case OPT_STR:
- GET_SPACE_RET(sp, bp, blen, 1024);
- a.len = snprintf(bp, 1024, "%s=%s", name, str_value);
- break;
- }
- a.bp = bp;
- b.len = 0;
- b.bp = NULL;
- ap[0] = &a;
- ap[1] = &b;
- rval = opts_set(sp, ap, NULL);
-
- FREE_SPACE(sp, bp, blen);
-
- return (rval);
-}
-
-/*
- * api_run_str --
- * Execute a string as an ex command.
- *
- * PUBLIC: int api_run_str __P((SCR *, char *));
- */
-int
-api_run_str(sp, cmd)
- SCR *sp;
- char *cmd;
-{
- return (ex_run_str(sp, NULL, cmd, strlen(cmd), 0, 0));
-}
diff --git a/common/args.h b/common/args.h
index e84dc2ca04c1..b23699c250e3 100644
--- a/common/args.h
+++ b/common/args.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)args.h 10.2 (Berkeley) 3/6/96
+ * $Id: args.h,v 10.2 1996/03/06 19:50:07 bostic Exp $
*/
/*
diff --git a/common/common.h b/common/common.h
index 0e13fc80b844..71f4c7fb69cb 100644
--- a/common/common.h
+++ b/common/common.h
@@ -6,16 +6,10 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)common.h 10.13 (Berkeley) 9/25/96
+ * $Id: common.h,v 10.22 2012/04/13 05:21:50 zy Exp $
*/
/*
- * Porting information built at configuration time. Included before
- * any of nvi's include files.
- */
-#include "port.h"
-
-/*
* Pseudo-local includes. These are files that are unlikely to exist
* on most machines to which we're porting vi, and we want to include
* them in a very specific order, regardless.
@@ -29,6 +23,8 @@
*/
typedef struct _cb CB;
typedef struct _csc CSC;
+typedef struct _conv CONV;
+typedef struct _conv_win CONVWIN;
typedef struct _event EVENT;
typedef struct _excmd EXCMD;
typedef struct _exf EXF;
@@ -48,7 +44,7 @@ typedef struct _tagq TAGQ;
typedef struct _text TEXT;
/* Autoindent state. */
-typedef enum { C_NOTSET, C_CARATSET, C_NOCHANGE, C_ZEROSET } carat_t;
+typedef enum { C_NOTSET, C_CARATSET, C_ZEROSET } carat_t;
/* Busy message types. */
typedef enum { BUSY_ON = 1, BUSY_OFF, BUSY_UPDATE } busy_t;
@@ -86,6 +82,7 @@ typedef enum { SEQ_ABBREV, SEQ_COMMAND, SEQ_INPUT } seq_t;
#include "seq.h" /* Required by screen.h. */
#include "util.h" /* Required by ex.h. */
#include "mark.h" /* Required by gs.h. */
+#include "conv.h" /* Required by ex.h and screen.h */
#include "../ex/ex.h" /* Required by gs.h. */
#include "gs.h" /* Required by screen.h. */
#include "screen.h" /* Required by exf.h. */
@@ -93,4 +90,4 @@ typedef enum { SEQ_ABBREV, SEQ_COMMAND, SEQ_INPUT } seq_t;
#include "log.h"
#include "mem.h"
-#include "com_extern.h"
+#include "extern.h"
diff --git a/common/conv.c b/common/conv.c
new file mode 100644
index 000000000000..7803cec9922e
--- /dev/null
+++ b/common/conv.c
@@ -0,0 +1,446 @@
+/*-
+ * Copyright (c) 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1993, 1994, 1995, 1996
+ * Keith Bostic. All rights reserved.
+ * Copyright (c) 2011, 2012
+ * Zhihao Yuan. All rights reserved.
+ *
+ * See the LICENSE file for redistribution information.
+ */
+
+#include "config.h"
+
+#ifndef lint
+static const char sccsid[] = "$Id: conv.c,v 2.39 2013/07/01 23:28:13 zy Exp $";
+#endif /* not lint */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/time.h>
+
+#include <bitstring.h>
+#include <errno.h>
+#include <limits.h>
+#include <langinfo.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+
+#include "common.h"
+
+/*
+ * codeset --
+ * Get the locale encoding.
+ *
+ * PUBLIC: char * codeset __P((void));
+ */
+char *
+codeset(void) {
+ static char *cs;
+
+ if (cs == NULL)
+ cs = nl_langinfo(CODESET);
+ return cs;
+}
+
+#ifdef USE_WIDECHAR
+static int
+raw2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, CHAR_T **dst)
+{
+ int i;
+ CHAR_T **tostr = &cw->bp1.wc;
+ size_t *blen = &cw->blen1;
+
+ BINC_RETW(NULL, *tostr, *blen, len);
+
+ *tolen = len;
+ for (i = 0; i < len; ++i)
+ (*tostr)[i] = (u_char) str[i];
+
+ *dst = cw->bp1.wc;
+
+ return 0;
+}
+
+#define CONV_BUFFER_SIZE 512
+/* fill the buffer with codeset encoding of string pointed to by str
+ * left has the number of bytes left in str and is adjusted
+ * len contains the number of bytes put in the buffer
+ */
+#ifdef USE_ICONV
+#define CONVERT(str, left, src, len) \
+ do { \
+ size_t outleft; \
+ char *bp = buffer; \
+ outleft = CONV_BUFFER_SIZE; \
+ errno = 0; \
+ if (iconv(id, (iconv_src_t)&str, &left, &bp, &outleft) == -1 && \
+ errno != E2BIG) \
+ goto err; \
+ if ((len = CONV_BUFFER_SIZE - outleft) == 0) { \
+ error = -left; \
+ goto err; \
+ } \
+ src = buffer; \
+ } while (0)
+
+#define IC_RESET() \
+ do { \
+ if (id != (iconv_t)-1) \
+ iconv(id, NULL, NULL, NULL, NULL); \
+ } while(0)
+#else
+#define CONVERT(str, left, src, len)
+#define IC_RESET()
+#endif
+
+static int
+default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, CHAR_T **dst, iconv_t id)
+{
+ size_t i = 0, j;
+ CHAR_T **tostr = &cw->bp1.wc;
+ size_t *blen = &cw->blen1;
+ mbstate_t mbs;
+ size_t n;
+ ssize_t nlen = len;
+ char *src = (char *)str;
+#ifdef USE_ICONV
+ char buffer[CONV_BUFFER_SIZE];
+#endif
+ size_t left = len;
+ int error = 1;
+
+ BZERO(&mbs, 1);
+ BINC_RETW(NULL, *tostr, *blen, nlen);
+
+#ifdef USE_ICONV
+ if (id != (iconv_t)-1)
+ CONVERT(str, left, src, len);
+#endif
+
+ for (i = 0, j = 0; j < len; ) {
+ n = mbrtowc((*tostr)+i, src+j, len-j, &mbs);
+ /* NULL character converted */
+ if (n == -2) error = -(len-j);
+ if (n == -1 || n == -2) goto err;
+ if (n == 0) n = 1;
+ j += n;
+ if (++i >= *blen) {
+ nlen += 256;
+ BINC_RETW(NULL, *tostr, *blen, nlen);
+ }
+ if (id != (iconv_t)-1 && j == len && left) {
+ CONVERT(str, left, src, len);
+ j = 0;
+ }
+ }
+
+ error = 0;
+err:
+ *tolen = i;
+ *dst = cw->bp1.wc;
+ IC_RESET();
+
+ return error;
+}
+
+static int
+fe_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, CHAR_T **dst)
+{
+ return default_char2int(sp, str, len, cw, tolen, dst,
+ sp->conv.id[IC_FE_CHAR2INT]);
+}
+
+static int
+ie_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, CHAR_T **dst)
+{
+ return default_char2int(sp, str, len, cw, tolen, dst,
+ sp->conv.id[IC_IE_CHAR2INT]);
+}
+
+static int
+cs_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, CHAR_T **dst)
+{
+ return default_char2int(sp, str, len, cw, tolen, dst,
+ (iconv_t)-1);
+}
+
+static int
+int2raw(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, char **dst)
+{
+ int i;
+ char **tostr = &cw->bp1.c;
+ size_t *blen = &cw->blen1;
+
+ BINC_RETC(NULL, *tostr, *blen, len);
+
+ *tolen = len;
+ for (i = 0; i < len; ++i)
+ (*tostr)[i] = str[i];
+
+ *dst = cw->bp1.c;
+
+ return 0;
+}
+
+static int
+default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, char **pdst, iconv_t id)
+{
+ size_t i, j, offset = 0;
+ char **tostr = &cw->bp1.c;
+ size_t *blen = &cw->blen1;
+ mbstate_t mbs;
+ size_t n;
+ ssize_t nlen = len + MB_CUR_MAX;
+ char *dst;
+ size_t buflen;
+#ifdef USE_ICONV
+ char buffer[CONV_BUFFER_SIZE];
+#endif
+ int error = 1;
+
+/* convert first len bytes of buffer and append it to cw->bp
+ * len is adjusted => 0
+ * offset contains the offset in cw->bp and is adjusted
+ * cw->bp is grown as required
+ */
+#ifdef USE_ICONV
+#define CONVERT2(_buffer, lenp, cw, offset) \
+ do { \
+ char *bp = _buffer; \
+ int ret; \
+ do { \
+ size_t outleft = cw->blen1 - offset; \
+ char *obp = cw->bp1.c + offset; \
+ if (cw->blen1 < offset + MB_CUR_MAX) { \
+ nlen += 256; \
+ BINC_RETC(NULL, cw->bp1.c, cw->blen1, nlen); \
+ } \
+ errno = 0; \
+ ret = iconv(id, (iconv_src_t)&bp, lenp, &obp, &outleft); \
+ if (ret == -1 && errno != E2BIG) \
+ goto err; \
+ offset = cw->blen1 - outleft; \
+ } while (ret != 0); \
+ } while (0)
+#else
+#define CONVERT2(_buffer, lenp, cw, offset)
+#endif
+
+
+ BZERO(&mbs, 1);
+ BINC_RETC(NULL, *tostr, *blen, nlen);
+ dst = *tostr; buflen = *blen;
+
+#ifdef USE_ICONV
+ if (id != (iconv_t)-1) {
+ dst = buffer; buflen = CONV_BUFFER_SIZE;
+ }
+#endif
+
+ for (i = 0, j = 0; i < len; ++i) {
+ n = wcrtomb(dst+j, str[i], &mbs);
+ if (n == -1) goto err;
+ j += n;
+ if (buflen < j + MB_CUR_MAX) {
+ if (id != (iconv_t)-1) {
+ CONVERT2(buffer, &j, cw, offset);
+ } else {
+ nlen += 256;
+ BINC_RETC(NULL, *tostr, *blen, nlen);
+ dst = *tostr; buflen = *blen;
+ }
+ }
+ }
+
+ n = wcrtomb(dst+j, L'\0', &mbs);
+ j += n - 1; /* don't count NUL at the end */
+ *tolen = j;
+
+ if (id != (iconv_t)-1) {
+ CONVERT2(buffer, &j, cw, offset);
+ CONVERT2(NULL, NULL, cw, offset); /* back to the initial state */
+ *tolen = offset;
+ }
+
+ error = 0;
+err:
+ if (error)
+ *tolen = j;
+ *pdst = cw->bp1.c;
+ IC_RESET();
+
+ return error;
+}
+
+static int
+fe_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, char **dst)
+{
+ return default_int2char(sp, str, len, cw, tolen, dst,
+ sp->conv.id[IC_FE_INT2CHAR]);
+}
+
+static int
+cs_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw,
+ size_t *tolen, char **dst)
+{
+ return default_int2char(sp, str, len, cw, tolen, dst,
+ (iconv_t)-1);
+}
+
+#endif
+
+/*
+ * conv_init --
+ * Initialize the iconv environment.
+ *
+ * PUBLIC: void conv_init __P((SCR *, SCR *));
+ */
+void
+conv_init(SCR *orig, SCR *sp)
+{
+ int i;
+
+ if (orig == NULL)
+ setlocale(LC_ALL, "");
+ if (orig != NULL)
+ BCOPY(&orig->conv, &sp->conv, 1);
+#ifdef USE_WIDECHAR
+ else {
+ char *ctype = setlocale(LC_CTYPE, NULL);
+
+ /*
+ * XXX
+ * This hack fixes the libncursesw issue on FreeBSD.
+ */
+ if (!strcmp(ctype, "ko_KR.CP949"))
+ setlocale(LC_CTYPE, "ko_KR.eucKR");
+ else if (!strcmp(ctype, "zh_CN.GB2312"))
+ setlocale(LC_CTYPE, "zh_CN.eucCN");
+ else if (!strcmp(ctype, "zh_CN.GBK"))
+ setlocale(LC_CTYPE, "zh_CN.GB18030");
+
+ /*
+ * Switch to 8bit mode if locale is C;
+ * LC_CTYPE should be reseted to C if unmatched.
+ */
+ if (!strcmp(ctype, "C") || !strcmp(ctype, "POSIX")) {
+ sp->conv.sys2int = sp->conv.file2int = raw2int;
+ sp->conv.int2sys = sp->conv.int2file = int2raw;
+ sp->conv.input2int = raw2int;
+ } else {
+ sp->conv.sys2int = cs_char2int;
+ sp->conv.int2sys = cs_int2char;
+ sp->conv.file2int = fe_char2int;
+ sp->conv.int2file = fe_int2char;
+ sp->conv.input2int = ie_char2int;
+ }
+#ifdef USE_ICONV
+ o_set(sp, O_INPUTENCODING, OS_STRDUP, codeset(), 0);
+#endif
+ }
+#endif
+
+ /* iconv descriptors must be distinct to screens. */
+ for (i = 0; i <= IC_IE_TO_UTF16; ++i)
+ sp->conv.id[i] = (iconv_t)-1;
+#ifdef USE_ICONV
+ conv_enc(sp, O_INPUTENCODING, 0);
+#endif
+}
+
+/*
+ * conv_enc --
+ * Convert file/input encoding.
+ *
+ * PUBLIC: int conv_enc __P((SCR *, int, char *));
+ */
+int
+conv_enc(SCR *sp, int option, char *enc)
+{
+#if defined(USE_WIDECHAR) && defined(USE_ICONV)
+ iconv_t *c2w, *w2c;
+
+ switch (option) {
+ case O_FILEENCODING:
+ c2w = sp->conv.id + IC_FE_CHAR2INT;
+ w2c = sp->conv.id + IC_FE_INT2CHAR;
+ if (!enc) enc = O_STR(sp, O_FILEENCODING);
+ if (*c2w != (iconv_t)-1)
+ iconv_close(*c2w);
+ if (*w2c != (iconv_t)-1)
+ iconv_close(*w2c);
+ if (strcasecmp(codeset(), enc)) {
+ if ((*c2w = iconv_open(codeset(), enc)) == (iconv_t)-1)
+ goto err;
+ if ((*w2c = iconv_open(enc, codeset())) == (iconv_t)-1)
+ goto err;
+ } else *c2w = *w2c = (iconv_t)-1;
+ break;
+ case O_INPUTENCODING:
+ c2w = sp->conv.id + IC_IE_CHAR2INT;
+ w2c = sp->conv.id + IC_IE_TO_UTF16;
+ if (!enc) enc = O_STR(sp, O_INPUTENCODING);
+ if (*c2w != (iconv_t)-1)
+ iconv_close(*c2w);
+ if (*w2c != (iconv_t)-1)
+ iconv_close(*w2c);
+ if (strcasecmp(codeset(), enc)) {
+ if ((*c2w = iconv_open(codeset(), enc)) == (iconv_t)-1)
+ goto err;
+ } else *c2w = (iconv_t)-1;
+ /* UTF-16 can not be locale and can not be inputed. */
+ if ((*w2c = iconv_open("utf-16be", enc)) == (iconv_t)-1)
+ goto err;
+ break;
+ }
+
+ F_CLR(sp, SC_CONV_ERROR);
+ F_SET(sp, SC_SCR_REFORMAT);
+
+ return 0;
+err:
+#endif
+ switch (option) {
+ case O_FILEENCODING:
+ msgq(sp, M_ERR,
+ "321|File encoding conversion not supported");
+ break;
+ case O_INPUTENCODING:
+ msgq(sp, M_ERR,
+ "322|Input encoding conversion not supported");
+ break;
+ }
+ return 1;
+}
+
+/*
+ * conv_end --
+ * Close the iconv descriptors, release the buffer.
+ *
+ * PUBLIC: void conv_end __P((SCR *));
+ */
+void
+conv_end(SCR *sp)
+{
+#if defined(USE_WIDECHAR) && defined(USE_ICONV)
+ int i;
+ for (i = 0; i <= IC_IE_TO_UTF16; ++i)
+ if (sp->conv.id[i] != (iconv_t)-1)
+ iconv_close(sp->conv.id[i]);
+ if (sp->cw.bp1.c != NULL)
+ free(sp->cw.bp1.c);
+#endif
+}
diff --git a/common/conv.h b/common/conv.h
new file mode 100644
index 000000000000..b17c3bb24ace
--- /dev/null
+++ b/common/conv.h
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996
+ * Keith Bostic. All rights reserved.
+ * Copyright (c) 2011, 2012
+ * Zhihao Yuan. All rights reserved.
+ *
+ * See the LICENSE file for redistribution information.
+ *
+ * $Id: conv.h,v 2.32 2013/03/11 01:20:53 zy Exp $
+ */
+
+#ifdef USE_ICONV
+#include <iconv.h>
+#ifdef ICONV_TRADITIONAL
+typedef char ** iconv_src_t;
+#else
+typedef char const ** iconv_src_t;
+#endif
+#else
+typedef int iconv_t;
+#endif
+
+/*
+ * XXX
+ * We can not use MB_CUR_MAX here, since UTF-8 may report it as 6, but
+ * a sequence longer than 4 is deprecated by RFC 3629.
+ */
+#define KEY_NEEDSWIDE(sp, ch) \
+ (INTISWIDE(ch) && KEY_LEN(sp, ch) <= 4)
+#define KEY_COL(sp, ch) \
+ (KEY_NEEDSWIDE(sp, ch) ? CHAR_WIDTH(sp, ch) : KEY_LEN(sp, ch))
+
+enum { IC_FE_CHAR2INT, IC_FE_INT2CHAR, IC_IE_CHAR2INT, IC_IE_TO_UTF16 };
+
+struct _conv_win {
+ union {
+ char *c;
+ CHAR_T *wc;
+ } bp1;
+ size_t blen1;
+};
+
+typedef int (*char2wchar_t)
+ (SCR *, const char *, ssize_t, struct _conv_win *, size_t *, CHAR_T **);
+typedef int (*wchar2char_t)
+ (SCR *, const CHAR_T *, ssize_t, struct _conv_win *, size_t *, char **);
+
+struct _conv {
+ char2wchar_t sys2int;
+ wchar2char_t int2sys;
+ char2wchar_t file2int;
+ wchar2char_t int2file;
+ char2wchar_t input2int;
+ iconv_t id[IC_IE_TO_UTF16 + 1];
+};
diff --git a/common/cut.c b/common/cut.c
index faceecd11166..11db42fb8158 100644
--- a/common/cut.c
+++ b/common/cut.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cut.c 10.10 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: cut.c,v 10.12 2012/02/11 15:52:33 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -64,14 +64,15 @@ static void cb_rotate __P((SCR *));
* PUBLIC: int cut __P((SCR *, CHAR_T *, MARK *, MARK *, int));
*/
int
-cut(sp, namep, fm, tm, flags)
- SCR *sp;
- CHAR_T *namep;
- MARK *fm, *tm;
- int flags;
+cut(
+ SCR *sp,
+ CHAR_T *namep,
+ MARK *fm,
+ MARK *tm,
+ int flags)
{
CB *cbp;
- CHAR_T name;
+ CHAR_T name = '\0';
recno_t lno;
int append, copy_one, copy_def;
@@ -100,19 +101,19 @@ cut(sp, namep, fm, tm, flags)
append = copy_one = copy_def = 0;
if (namep != NULL) {
name = *namep;
- if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) &&
- (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) {
+ if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) &&
+ (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno))) {
copy_one = 1;
cb_rotate(sp);
}
- if ((append = isupper(name)) == 1) {
+ if ((append = isupper(name))) {
if (!copy_one)
copy_def = 1;
name = tolower(name);
}
namecb: CBNAME(sp, cbp, name);
- } else if (LF_ISSET(CUT_NUMREQ) || LF_ISSET(CUT_NUMOPT) &&
- (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno)) {
+ } else if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) &&
+ (LF_ISSET(CUT_LINEMODE) || fm->lno != tm->lno))) {
name = '1';
cb_rotate(sp);
goto namecb;
@@ -127,26 +128,25 @@ copyloop:
if (cbp == NULL) {
CALLOC_RET(sp, cbp, CB *, 1, sizeof(CB));
cbp->name = name;
- CIRCLEQ_INIT(&cbp->textq);
- LIST_INSERT_HEAD(&sp->gp->cutq, cbp, q);
+ TAILQ_INIT(cbp->textq);
+ SLIST_INSERT_HEAD(sp->gp->cutq, cbp, q);
} else if (!append) {
- text_lfree(&cbp->textq);
+ text_lfree(cbp->textq);
cbp->len = 0;
cbp->flags = 0;
}
-#define ENTIRE_LINE 0
/* In line mode, it's pretty easy, just cut the lines. */
if (LF_ISSET(CUT_LINEMODE)) {
cbp->flags |= CB_LMODE;
for (lno = fm->lno; lno <= tm->lno; ++lno)
- if (cut_line(sp, lno, 0, 0, cbp))
+ if (cut_line(sp, lno, 0, ENTIRE_LINE, cbp))
goto cut_line_err;
} else {
/*
- * Get the first line. A length of 0 causes cut_line
- * to cut from the MARK to the end of the line.
+ * Get the first line. A length of ENTIRE_LINE causes
+ * cut_line to cut from the MARK to the end of the line.
*/
if (cut_line(sp, fm->lno, fm->cno, fm->lno != tm->lno ?
ENTIRE_LINE : (tm->cno - fm->cno) + 1, cbp))
@@ -180,7 +180,7 @@ copyloop:
return (0);
cut_line_err:
- text_lfree(&cbp->textq);
+ text_lfree(cbp->textq);
cbp->len = 0;
cbp->flags = 0;
return (1);
@@ -191,45 +191,29 @@ cut_line_err:
* Rotate the numbered buffers up one.
*/
static void
-cb_rotate(sp)
- SCR *sp;
+cb_rotate(SCR *sp)
{
- CB *cbp, *del_cbp;
+ CB *cbp, *del_cbp = NULL, *pre_cbp = NULL;
- del_cbp = NULL;
- for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next)
+ SLIST_FOREACH(cbp, sp->gp->cutq, q) {
switch(cbp->name) {
- case '1':
- cbp->name = '2';
- break;
- case '2':
- cbp->name = '3';
- break;
- case '3':
- cbp->name = '4';
- break;
- case '4':
- cbp->name = '5';
- break;
- case '5':
- cbp->name = '6';
- break;
- case '6':
- cbp->name = '7';
- break;
- case '7':
- cbp->name = '8';
- break;
- case '8':
- cbp->name = '9';
+ case '1': case '2': case '3':
+ case '4': case '5': case '6':
+ case '7': case '8':
+ cbp->name += 1;
break;
case '9':
+ if (cbp == SLIST_FIRST(sp->gp->cutq))
+ SLIST_REMOVE_HEAD(sp->gp->cutq, q);
+ else
+ SLIST_REMOVE_AFTER(pre_cbp, q);
del_cbp = cbp;
break;
}
+ pre_cbp = cbp;
+ }
if (del_cbp != NULL) {
- LIST_REMOVE(del_cbp, q);
- text_lfree(&del_cbp->textq);
+ text_lfree(del_cbp->textq);
free(del_cbp);
}
}
@@ -241,15 +225,16 @@ cb_rotate(sp)
* PUBLIC: int cut_line __P((SCR *, recno_t, size_t, size_t, CB *));
*/
int
-cut_line(sp, lno, fcno, clen, cbp)
- SCR *sp;
- recno_t lno;
- size_t fcno, clen;
- CB *cbp;
+cut_line(
+ SCR *sp,
+ recno_t lno,
+ size_t fcno,
+ size_t clen,
+ CB *cbp)
{
TEXT *tp;
size_t len;
- char *p;
+ CHAR_T *p;
/* Get the line. */
if (db_get(sp, lno, DBG_FATAL, &p, &len))
@@ -264,14 +249,14 @@ cut_line(sp, lno, fcno, clen, cbp)
* copy the portion we want, and reset the TEXT length.
*/
if (len != 0) {
- if (clen == 0)
+ if (clen == ENTIRE_LINE)
clen = len - fcno;
- memcpy(tp->lb, p + fcno, clen);
+ MEMCPY(tp->lb, p + fcno, clen);
tp->len = clen;
}
/* Append to the end of the cut buffer. */
- CIRCLEQ_INSERT_TAIL(&cbp->textq, tp, q);
+ TAILQ_INSERT_TAIL(cbp->textq, tp, q);
cbp->len += tp->len;
return (0);
@@ -284,36 +269,36 @@ cut_line(sp, lno, fcno, clen, cbp)
* PUBLIC: void cut_close __P((GS *));
*/
void
-cut_close(gp)
- GS *gp;
+cut_close(GS *gp)
{
CB *cbp;
/* Free cut buffer list. */
- while ((cbp = gp->cutq.lh_first) != NULL) {
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
- text_lfree(&cbp->textq);
- LIST_REMOVE(cbp, q);
+ while ((cbp = SLIST_FIRST(gp->cutq)) != NULL) {
+ if (!TAILQ_EMPTY(cbp->textq))
+ text_lfree(cbp->textq);
+ SLIST_REMOVE_HEAD(gp->cutq, q);
free(cbp);
}
/* Free default cut storage. */
cbp = &gp->dcb_store;
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
- text_lfree(&cbp->textq);
+ if (!TAILQ_EMPTY(cbp->textq))
+ text_lfree(cbp->textq);
}
/*
* text_init --
* Allocate a new TEXT structure.
*
- * PUBLIC: TEXT *text_init __P((SCR *, const char *, size_t, size_t));
+ * PUBLIC: TEXT *text_init __P((SCR *, const CHAR_T *, size_t, size_t));
*/
TEXT *
-text_init(sp, p, len, total_len)
- SCR *sp;
- const char *p;
- size_t len, total_len;
+text_init(
+ SCR *sp,
+ const CHAR_T *p,
+ size_t len,
+ size_t total_len)
{
TEXT *tp;
@@ -321,14 +306,14 @@ text_init(sp, p, len, total_len)
if (tp == NULL)
return (NULL);
/* ANSI C doesn't define a call to malloc(3) for 0 bytes. */
- if ((tp->lb_len = total_len) != 0) {
+ if ((tp->lb_len = total_len * sizeof(CHAR_T)) != 0) {
MALLOC(sp, tp->lb, CHAR_T *, tp->lb_len);
if (tp->lb == NULL) {
free(tp);
return (NULL);
}
if (p != NULL && len != 0)
- memcpy(tp->lb, p, len);
+ MEMCPY(tp->lb, p, len);
}
tp->len = len;
return (tp);
@@ -341,13 +326,12 @@ text_init(sp, p, len, total_len)
* PUBLIC: void text_lfree __P((TEXTH *));
*/
void
-text_lfree(headp)
- TEXTH *headp;
+text_lfree(TEXTH *headp)
{
TEXT *tp;
- while ((tp = headp->cqh_first) != (void *)headp) {
- CIRCLEQ_REMOVE(headp, tp, q);
+ while ((tp = TAILQ_FIRST(headp)) != NULL) {
+ TAILQ_REMOVE(headp, tp, q);
text_free(tp);
}
}
@@ -359,8 +343,7 @@ text_lfree(headp)
* PUBLIC: void text_free __P((TEXT *));
*/
void
-text_free(tp)
- TEXT *tp;
+text_free(TEXT *tp)
{
if (tp->lb != NULL)
free(tp->lb);
diff --git a/common/cut.h b/common/cut.h
index 43f3ca817efd..30e9350dbb75 100644
--- a/common/cut.h
+++ b/common/cut.h
@@ -6,16 +6,17 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)cut.h 10.5 (Berkeley) 4/3/96
+ * $Id: cut.h,v 10.10 2012/02/11 15:52:33 zy Exp $
*/
typedef struct _texth TEXTH; /* TEXT list head structure. */
-CIRCLEQ_HEAD(_texth, _text);
+TAILQ_HEAD(_texth, _text);
/* Cut buffers. */
struct _cb {
- LIST_ENTRY(_cb) q; /* Linked list of cut buffers. */
- TEXTH textq; /* Linked list of TEXT structures. */
+ SLIST_ENTRY(_cb) q; /* Linked list of cut buffers. */
+ TEXTH textq[1]; /* Linked list of TEXT structures. */
+ /* XXXX Needed ? Can non ascii-chars be cut buffer names ? */
CHAR_T name; /* Cut buffer name. */
size_t len; /* Total length of cut text. */
@@ -25,13 +26,15 @@ struct _cb {
/* Lines/blocks of text. */
struct _text { /* Text: a linked list of lines. */
- CIRCLEQ_ENTRY(_text) q; /* Linked list of text structures. */
- char *lb; /* Line buffer. */
+ TAILQ_ENTRY(_text) q; /* Linked list of text structures. */
+ CHAR_T *lb; /* Line buffer. */
size_t lb_len; /* Line buffer length. */
size_t len; /* Line length. */
/* These fields are used by the vi text input routine. */
recno_t lno; /* 1-N: file line. */
+
+#define ENTIRE_LINE ((size_t)-1) /* cno: end of the line. */
size_t cno; /* 0-N: file character in line. */
size_t ai; /* 0-N: autoindent bytes. */
size_t insert; /* 0-N: bytes to insert (push). */
@@ -65,8 +68,7 @@ struct _text { /* Text: a linked list of lines. */
#define CBNAME(sp, cbp, nch) { \
CHAR_T L__name; \
L__name = isupper(nch) ? tolower(nch) : (nch); \
- for (cbp = sp->gp->cutq.lh_first; \
- cbp != NULL; cbp = cbp->q.le_next) \
+ SLIST_FOREACH(cbp, sp->gp->cutq, q) \
if (cbp->name == L__name) \
break; \
}
diff --git a/common/delete.c b/common/delete.c
index 001788f9bb38..bb476c0c8a7c 100644
--- a/common/delete.c
+++ b/common/delete.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)delete.c 10.12 (Berkeley) 10/23/96";
+static const char sccsid[] = "$Id: delete.c,v 10.18 2012/02/11 15:52:33 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
@@ -32,14 +33,15 @@ static const char sccsid[] = "@(#)delete.c 10.12 (Berkeley) 10/23/96";
* PUBLIC: int del __P((SCR *, MARK *, MARK *, int));
*/
int
-del(sp, fm, tm, lmode)
- SCR *sp;
- MARK *fm, *tm;
- int lmode;
+del(
+ SCR *sp,
+ MARK *fm,
+ MARK *tm,
+ int lmode)
{
recno_t lno;
size_t blen, len, nlen, tlen;
- char *bp, *p;
+ CHAR_T *bp, *p;
int eof, rval;
bp = NULL;
@@ -66,7 +68,7 @@ del(sp, fm, tm, lmode)
if (tm->lno == lno) {
if (db_get(sp, lno, DBG_FATAL, &p, &len))
return (1);
- eof = tm->cno >= len ? 1 : 0;
+ eof = tm->cno != ENTIRE_LINE && tm->cno >= len ? 1 : 0;
} else
eof = 1;
if (eof) {
@@ -80,8 +82,8 @@ del(sp, fm, tm, lmode)
}
if (db_get(sp, fm->lno, DBG_FATAL, &p, &len))
return (1);
- GET_SPACE_RET(sp, bp, blen, fm->cno);
- memcpy(bp, p, fm->cno);
+ GET_SPACE_RETW(sp, bp, blen, fm->cno);
+ MEMCPY(bp, p, fm->cno);
if (db_set(sp, fm->lno, bp, fm->cno))
return (1);
goto done;
@@ -92,10 +94,11 @@ del(sp, fm, tm, lmode)
if (tm->lno == fm->lno) {
if (db_get(sp, fm->lno, DBG_FATAL, &p, &len))
return (1);
- GET_SPACE_RET(sp, bp, blen, len);
+ GET_SPACE_RETW(sp, bp, blen, len);
if (fm->cno != 0)
- memcpy(bp, p, fm->cno);
- memcpy(bp + fm->cno, p + (tm->cno + 1), len - (tm->cno + 1));
+ MEMCPY(bp, p, fm->cno);
+ MEMCPY(bp + fm->cno, p + (tm->cno + 1),
+ len - (tm->cno + 1));
if (db_set(sp, fm->lno,
bp, len - ((tm->cno - fm->cno) + 1)))
goto err;
@@ -110,8 +113,8 @@ del(sp, fm, tm, lmode)
if ((tlen = fm->cno) != 0) {
if (db_get(sp, fm->lno, DBG_FATAL, &p, NULL))
return (1);
- GET_SPACE_RET(sp, bp, blen, tlen + 256);
- memcpy(bp, p, tlen);
+ GET_SPACE_RETW(sp, bp, blen, tlen + 256);
+ MEMCPY(bp, p, tlen);
}
/* Copy the end partial line into place. */
@@ -130,11 +133,11 @@ del(sp, fm, tm, lmode)
goto err;
}
if (tlen == 0) {
- GET_SPACE_RET(sp, bp, blen, nlen);
+ GET_SPACE_RETW(sp, bp, blen, nlen);
} else
- ADD_SPACE_RET(sp, bp, blen, nlen);
+ ADD_SPACE_RETW(sp, bp, blen, nlen);
- memcpy(bp + tlen, p + (tm->cno + 1), len - (tm->cno + 1));
+ MEMCPY(bp + tlen, p + (tm->cno + 1), len - (tm->cno + 1));
tlen += len - (tm->cno + 1);
}
@@ -155,6 +158,6 @@ done: rval = 0;
if (0)
err: rval = 1;
if (bp != NULL)
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
return (rval);
}
diff --git a/common/encoding.c b/common/encoding.c
new file mode 100644
index 000000000000..6de509e5b8ec
--- /dev/null
+++ b/common/encoding.c
@@ -0,0 +1,230 @@
+/*-
+ * Copyright (c) 2011, 2012
+ * Zhihao Yuan. All rights reserved.
+ *
+ * See the LICENSE file for redistribution information.
+ */
+
+#ifndef lint
+static const char sccsid[] = "$Id: encoding.c,v 1.4 2011/12/13 19:40:52 zy Exp $";
+#endif /* not lint */
+
+#include <sys/types.h>
+
+int looks_utf8 __P((const char *, size_t));
+int looks_utf16 __P((const char *, size_t));
+int decode_utf8 __P((const char *));
+int decode_utf16 __P((const char *, int));
+
+#define F 0 /* character never appears in text */
+#define T 1 /* character appears in plain ASCII text */
+#define I 2 /* character appears in ISO-8859 text */
+#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
+
+static char text_chars[256] = {
+ /* BEL BS HT LF FF CR */
+ F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
+ /* ESC */
+ F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */
+ /* NEL */
+ X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */
+ X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
+};
+
+/*
+ * looks_utf8 --
+ * Decide whether some text looks like UTF-8. Returns:
+ *
+ * -1: invalid UTF-8
+ * 0: uses odd control characters, so doesn't look like text
+ * 1: 7-bit text
+ * 2: definitely UTF-8 text (valid high-bit set bytes)
+ *
+ * Based on RFC 3629. UTF-8 with BOM is not accepted.
+ *
+ * PUBLIC: int looks_utf8 __P((const char *, size_t));
+ */
+int
+looks_utf8(const char *ibuf, size_t nbytes)
+{
+ const u_char *buf = (u_char *)ibuf;
+ size_t i;
+ int n;
+ int gotone = 0, ctrl = 0;
+
+ for (i = 0; i < nbytes; i++) {
+ if ((buf[i] & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
+ /*
+ * Even if the whole file is valid UTF-8 sequences,
+ * still reject it if it uses weird control characters.
+ */
+
+ if (text_chars[buf[i]] != T)
+ ctrl = 1;
+ } else if ((buf[i] & 0x40) == 0) { /* 10xxxxxx never 1st byte */
+ return -1;
+ } else { /* 11xxxxxx begins UTF-8 */
+ int following;
+
+ if ((buf[i] & 0x20) == 0) /* 110xxxxx */
+ if (buf[i] > 0xC1) /* C0, C1 */
+ following = 1;
+ else return -1;
+ else if ((buf[i] & 0x10) == 0) /* 1110xxxx */
+ following = 2;
+ else if ((buf[i] & 0x08) == 0) /* 11110xxx */
+ if (buf[i] < 0xF5)
+ following = 3;
+ else return -1; /* F5, F6, F7 */
+ else
+ return -1; /* F8~FF */
+
+ for (n = 0; n < following; n++) {
+ i++;
+ if (i >= nbytes)
+ goto done;
+
+ if (buf[i] & 0x40) /* 10xxxxxx */
+ return -1;
+ }
+
+ gotone = 1;
+ }
+ }
+done:
+ return ctrl ? 0 : (gotone ? 2 : 1);
+}
+
+/*
+ * looks_utf16 --
+ * Decide whether some text looks like UTF-16. Returns:
+ *
+ * 0: invalid UTF-16
+ * 1: Little-endian UTF-16
+ * 2: Big-endian UTF-16
+ *
+ * PUBLIC: int looks_utf16 __P((const char *, size_t));
+ */
+int
+looks_utf16(const char *ibuf, size_t nbytes)
+{
+ const u_char *buf = (u_char *)ibuf;
+ int bigend;
+ size_t i;
+ unsigned int c;
+ int bom;
+ int following = 0;
+
+ if (nbytes < 2)
+ return 0;
+
+ bom = buf[0] << 8 ^ buf[1];
+ if (bom == 0xFFFE)
+ bigend = 0;
+ else if (bom == 0xFEFF)
+ bigend = 1;
+ else
+ return 0;
+
+ for (i = 2; i + 1 < nbytes; i += 2) {
+ if (bigend)
+ c = buf[i] << 8 ^ buf[i + 1];
+ else
+ c = buf[i] ^ buf[i + 1] << 8;
+
+ if (!following)
+ if (c < 0xD800 || c > 0xDFFF)
+ if (c < 128 && text_chars[c] != T)
+ return 0;
+ else
+ following = 0;
+ else if (c > 0xDBFF)
+ return 0;
+ else {
+ following = 1;
+ continue;
+ }
+ else if (c < 0xDC00 || c > 0xDFFF)
+ return 0;
+ }
+
+ return 1 + bigend;
+}
+
+#undef F
+#undef T
+#undef I
+#undef X
+
+/*
+ * decode_utf8 --
+ * Decode a UTF-8 character from byte string to Unicode.
+ * Returns -1 if the first byte is a not UTF-8 leader.
+ *
+ * Based on RFC 3629, but without error detection.
+ *
+ * PUBLIC: int decode_utf8 __P((const char *));
+ */
+int decode_utf8(const char *ibuf) {
+ const u_char *buf = (u_char *)ibuf;
+ int u = -1;
+
+ if ((buf[0] & 0x80) == 0)
+ u = buf[0];
+ else if ((buf[0] & 0x40) == 0);
+ else {
+ if ((buf[0] & 0x20) == 0)
+ u = (buf[0] ^ 0xC0) << 6 ^ (buf[1] ^ 0x80);
+ else if ((buf[0] & 0x10) == 0)
+ u = (buf[0] ^ 0xE0) << 12 ^ (buf[1] ^ 0x80) << 6
+ ^ (buf[2] ^ 0x80);
+ else if (((buf[0] & 0x08) == 0))
+ u = (buf[0] ^ 0xF0) << 18 ^ (buf[1] ^ 0x80) << 12
+ ^ (buf[2] ^ 0x80) << 6 ^ (buf[3] ^ 0x80);
+ }
+ return u;
+}
+
+/*
+ * decode_utf16 --
+ * Decode a UTF-16 character from byte string to Unicode.
+ * Returns -1 if the first unsigned integer is invalid.
+ *
+ * No error detection on supplementary bytes.
+ *
+ * PUBLIC: int decode_utf16 __P((const char *, int));
+ */
+int decode_utf16(const char* ibuf, int bigend) {
+ const u_char *buf = (u_char *)ibuf;
+ int u = -1;
+ unsigned int w1, w2;
+
+ if (bigend)
+ w1 = buf[0] << 8 ^ buf[1];
+ else
+ w1 = buf[0] ^ buf[1] << 8;
+
+ if (w1 < 0xD800 || w1 > 0xDFFF)
+ u = w1;
+ else if (w1 > 0xDBFF);
+ else {
+ if (bigend)
+ w2 = buf[2] << 8 ^ buf[3];
+ else
+ w2 = buf[2] ^ buf[3] << 8;
+ u = ((w1 ^ 0xD800) << 10 ^ (w2 ^ 0xDC00)) + 0x10000;
+ }
+ return u;
+}
diff --git a/common/exf.c b/common/exf.c
index 2993b0f4a8a5..6579ab2118d3 100644
--- a/common/exf.c
+++ b/common/exf.c
@@ -10,13 +10,13 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)exf.c 10.49 (Berkeley) 10/10/96";
+static const char sccsid[] = "$Id: exf.c,v 10.62 2013/07/01 23:28:13 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
-#include <sys/types.h> /* XXX: param.h may not have included types.h */
+#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
+#include <sys/time.h>
/*
* We include <sys/file.h>, because the flock(2) and open(2) #defines
@@ -39,6 +39,7 @@ static const char sccsid[] = "@(#)exf.c 10.49 (Berkeley) 10/10/96";
static int file_backup __P((SCR *, char *, char *));
static void file_cinit __P((SCR *));
+static void file_encinit __P((SCR *));
static void file_comment __P((SCR *));
static int file_spath __P((SCR *, FREF *, struct stat *, int *));
@@ -55,12 +56,12 @@ static int file_spath __P((SCR *, FREF *, struct stat *, int *));
* vi now remembers the last location in any file that it has ever edited,
* not just the previously edited file.
*
- * PUBLIC: FREF *file_add __P((SCR *, CHAR_T *));
+ * PUBLIC: FREF *file_add __P((SCR *, char *));
*/
FREF *
-file_add(sp, name)
- SCR *sp;
- CHAR_T *name;
+file_add(
+ SCR *sp,
+ char *name)
{
GS *gp;
FREF *frp, *tfrp;
@@ -76,15 +77,12 @@ file_add(sp, name)
*/
gp = sp->gp;
if (name != NULL)
- for (frp = gp->frefq.cqh_first;
- frp != (FREF *)&gp->frefq; frp = frp->q.cqe_next) {
+ TAILQ_FOREACH_SAFE(frp, gp->frefq, q, tfrp) {
if (frp->name == NULL) {
- tfrp = frp->q.cqe_next;
- CIRCLEQ_REMOVE(&gp->frefq, frp, q);
+ TAILQ_REMOVE(gp->frefq, frp, q);
if (frp->name != NULL)
free(frp->name);
free(frp);
- frp = tfrp;
continue;
}
if (!strcmp(frp->name, name))
@@ -109,7 +107,7 @@ file_add(sp, name)
}
/* Append into the chain of file names. */
- CIRCLEQ_INSERT_TAIL(&gp->frefq, frp, q);
+ TAILQ_INSERT_TAIL(gp->frefq, frp, q);
return (frp);
}
@@ -123,18 +121,18 @@ file_add(sp, name)
* PUBLIC: int file_init __P((SCR *, FREF *, char *, int));
*/
int
-file_init(sp, frp, rcv_name, flags)
- SCR *sp;
- FREF *frp;
- char *rcv_name;
- int flags;
+file_init(
+ SCR *sp,
+ FREF *frp,
+ char *rcv_name,
+ int flags)
{
EXF *ep;
- RECNOINFO oinfo;
+ RECNOINFO oinfo = { 0 };
struct stat sb;
size_t psize;
int fd, exists, open_err, readonly;
- char *oname, tname[MAXPATHLEN];
+ char *oname, *tname;
open_err = readonly = 0;
@@ -164,7 +162,7 @@ file_init(sp, frp, rcv_name, flags)
*/
CALLOC_RET(sp, ep, EXF *, 1, sizeof(EXF));
ep->c_lno = ep->c_nlines = OOBLNO;
- ep->rcv_fd = ep->fcntl_fd = -1;
+ ep->rcv_fd = -1;
F_SET(ep, F_FIRSTMODIFY);
/*
@@ -182,52 +180,56 @@ file_init(sp, frp, rcv_name, flags)
*/
oname = frp->name;
if (LF_ISSET(FS_OPENERR) || oname == NULL || !exists) {
- if (opts_empty(sp, O_DIRECTORY, 0))
+ struct stat sb;
+
+ if (opts_empty(sp, O_TMPDIR, 0))
goto err;
- (void)snprintf(tname, sizeof(tname),
- "%s/vi.XXXXXX", O_STR(sp, O_DIRECTORY));
- if ((fd = mkstemp(tname)) == -1) {
+ if ((tname =
+ join(O_STR(sp, O_TMPDIR), "vi.XXXXXXXXXX")) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ goto err;
+ }
+ if ((fd = mkstemp(tname)) == -1 || fstat(fd, &sb)) {
+ free(tname);
msgq(sp, M_SYSERR,
"237|Unable to create temporary file");
goto err;
}
(void)close(fd);
- if (frp->name == NULL)
+ frp->tname = tname;
+ if (frp->name == NULL) {
F_SET(frp, FR_TMPFILE);
- if ((frp->tname = strdup(tname)) == NULL ||
- frp->name == NULL && (frp->name = strdup(tname)) == NULL) {
- if (frp->tname != NULL)
- free(frp->tname);
- msgq(sp, M_SYSERR, NULL);
- (void)unlink(tname);
- goto err;
+ if ((frp->name = strdup(tname)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ goto err;
+ }
}
oname = frp->tname;
psize = 1024;
if (!LF_ISSET(FS_OPENERR))
F_SET(frp, FR_NEWFILE);
- time(&ep->mtime);
+ ep->mtim = sb.st_mtimespec;
} else {
/*
* XXX
* A seat of the pants calculation: try to keep the file in
- * 15 pages or less. Don't use a page size larger than 10K
+ * 15 pages or less. Don't use a page size larger than 16K
* (vi should have good locality) or smaller than 1K.
*/
psize = ((sb.st_size / 15) + 1023) / 1024;
- if (psize > 10)
- psize = 10;
+ if (psize > 16)
+ psize = 16;
if (psize == 0)
psize = 1;
- psize *= 1024;
+ psize = p2roundup(psize) << 10;
F_SET(ep, F_DEVSET);
ep->mdev = sb.st_dev;
ep->minode = sb.st_ino;
- ep->mtime = sb.st_mtime;
+ ep->mtim = sb.st_mtimespec;
if (!S_ISREG(sb.st_mode))
msgq_str(sp, M_ERR, oname,
@@ -235,7 +237,6 @@ file_init(sp, frp, rcv_name, flags)
}
/* Set up recovery. */
- memset(&oinfo, 0, sizeof(RECNOINFO));
oinfo.bval = '\n'; /* Always set. */
oinfo.psize = psize;
oinfo.flags = F_ISSET(sp->gp, G_SNAPSHOT) ? R_SNAPSHOT : 0;
@@ -333,8 +334,7 @@ file_init(sp, frp, rcv_name, flags)
* an error.
*/
if (rcv_name == NULL)
- switch (file_lock(sp, oname,
- &ep->fcntl_fd, ep->db->fd(ep->db), 0)) {
+ switch (file_lock(sp, oname, ep->db->fd(ep->db), 0)) {
case LOCK_FAILED:
F_SET(frp, FR_UNLOCKED);
break;
@@ -391,9 +391,9 @@ file_init(sp, frp, rcv_name, flags)
* probably isn't a problem for vi when it's running standalone.
*/
if (readonly || F_ISSET(sp, SC_READONLY) ||
- !F_ISSET(frp, FR_NEWFILE) &&
+ (!F_ISSET(frp, FR_NEWFILE) &&
(!(sb.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) ||
- access(frp->name, W_OK)))
+ access(frp->name, W_OK))))
O_SET(sp, O_READONLY);
else
O_CLR(sp, O_READONLY);
@@ -403,6 +403,9 @@ file_init(sp, frp, rcv_name, flags)
sp->ep = ep;
sp->frp = frp;
+ /* Detect and set the file encoding */
+ file_encinit(sp);
+
/* Set the initial cursor position, queue initial command. */
file_cinit(sp);
@@ -441,16 +444,16 @@ oerr: if (F_ISSET(ep, F_RCV_ON))
* try and open.
*/
static int
-file_spath(sp, frp, sbp, existsp)
- SCR *sp;
- FREF *frp;
- struct stat *sbp;
- int *existsp;
+file_spath(
+ SCR *sp,
+ FREF *frp,
+ struct stat *sbp,
+ int *existsp)
{
- CHAR_T savech;
+ int savech;
size_t len;
int found;
- char *name, *p, *t, path[MAXPATHLEN];
+ char *name, *p, *t, *path;
/*
* If the name is NULL or an explicit reference (i.e., the first
@@ -461,8 +464,8 @@ file_spath(sp, frp, sbp, existsp)
*existsp = 0;
return (0);
}
- if (name[0] == '/' || name[0] == '.' &&
- (name[1] == '/' || name[1] == '.' && name[2] == '/')) {
+ if (name[0] == '/' || (name[0] == '.' &&
+ (name[1] == '/' || (name[1] == '.' && name[2] == '/')))) {
*existsp = !stat(name, sbp);
return (0);
}
@@ -476,16 +479,24 @@ file_spath(sp, frp, sbp, existsp)
/* Try the O_PATH option values. */
for (found = 0, p = t = O_STR(sp, O_PATH);; ++p)
if (*p == ':' || *p == '\0') {
- if (t < p - 1) {
+ /*
+ * Ignore the empty strings and ".", since we've already
+ * tried the current directory.
+ */
+ if (t < p && (p - t != 1 || *t != '.')) {
savech = *p;
*p = '\0';
- len = snprintf(path,
- sizeof(path), "%s/%s", t, name);
+ if ((path = join(t, name)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ break;
+ }
+ len = strlen(path);
*p = savech;
if (!stat(path, sbp)) {
found = 1;
break;
}
+ free(path);
}
t = p + 1;
if (*p == '\0')
@@ -494,10 +505,8 @@ file_spath(sp, frp, sbp, existsp)
/* If we found it, build a new pathname and discard the old one. */
if (found) {
- MALLOC_RET(sp, p, char *, len + 1);
- memcpy(p, path, len + 1);
free(frp->name);
- frp->name = p;
+ frp->name = path;
}
*existsp = found;
return (0);
@@ -508,13 +517,14 @@ file_spath(sp, frp, sbp, existsp)
* Set up the initial cursor position.
*/
static void
-file_cinit(sp)
- SCR *sp;
+file_cinit(SCR *sp)
{
GS *gp;
MARK m;
size_t len;
int nb;
+ CHAR_T *wp;
+ size_t wlen;
/* Set some basic defaults. */
sp->lno = 1;
@@ -548,8 +558,9 @@ file_cinit(sp)
sp->lno = 1;
sp->cno = 0;
}
- if (ex_run_str(sp,
- "-c option", gp->c_option, strlen(gp->c_option), 1, 1))
+ CHAR2INT(sp, gp->c_option, strlen(gp->c_option) + 1,
+ wp, wlen);
+ if (ex_run_str(sp, "-c option", wp, wlen - 1, 1, 1))
return;
gp->c_option = NULL;
} else if (F_ISSET(sp, SC_EX)) {
@@ -617,10 +628,10 @@ file_cinit(sp)
* PUBLIC: int file_end __P((SCR *, EXF *, int));
*/
int
-file_end(sp, ep, force)
- SCR *sp;
- EXF *ep;
- int force;
+file_end(
+ SCR *sp,
+ EXF *ep,
+ int force)
{
FREF *frp;
@@ -665,7 +676,7 @@ file_end(sp, ep, force)
free(frp->tname);
frp->tname = NULL;
if (F_ISSET(frp, FR_TMPFILE)) {
- CIRCLEQ_REMOVE(&sp->gp->frefq, frp, q);
+ TAILQ_REMOVE(sp->gp->frefq, frp, q);
if (frp->name != NULL)
free(frp->name);
free(frp);
@@ -707,14 +718,14 @@ file_end(sp, ep, force)
if (ep->rcv_mpath != NULL && unlink(ep->rcv_mpath))
msgq_str(sp, M_SYSERR, ep->rcv_mpath, "243|%s: remove");
}
- if (ep->fcntl_fd != -1)
- (void)close(ep->fcntl_fd);
if (ep->rcv_fd != -1)
(void)close(ep->rcv_fd);
if (ep->rcv_path != NULL)
free(ep->rcv_path);
if (ep->rcv_mpath != NULL)
free(ep->rcv_mpath);
+ if (ep->c_blen > 0)
+ free(ep->c_lp);
free(ep);
return (0);
@@ -729,11 +740,12 @@ file_end(sp, ep, force)
* PUBLIC: int file_write __P((SCR *, MARK *, MARK *, char *, int));
*/
int
-file_write(sp, fm, tm, name, flags)
- SCR *sp;
- MARK *fm, *tm;
- char *name;
- int flags;
+file_write(
+ SCR *sp,
+ MARK *fm,
+ MARK *tm,
+ char *name,
+ int flags)
{
enum { NEWFILE, OLDFILE } mtype;
struct stat sb;
@@ -744,7 +756,7 @@ file_write(sp, fm, tm, name, flags)
size_t len;
u_long nlno, nch;
int fd, nf, noname, oflags, rval;
- char *p, *s, *t, buf[MAXPATHLEN + 64];
+ char *p, *s, *t, buf[1024];
const char *msgstr;
ep = sp->ep;
@@ -807,9 +819,9 @@ file_write(sp, fm, tm, name, flags)
mtype = NEWFILE;
else {
if (noname && !LF_ISSET(FS_FORCE | FS_APPEND) &&
- (F_ISSET(ep, F_DEVSET) &&
- (sb.st_dev != ep->mdev || sb.st_ino != ep->minode) ||
- sb.st_mtime != ep->mtime)) {
+ ((F_ISSET(ep, F_DEVSET) &&
+ (sb.st_dev != ep->mdev || sb.st_ino != ep->minode)) ||
+ timespeccmp(&sb.st_mtimespec, &ep->mtim, !=))) {
msgq_str(sp, M_ERR, name, LF_ISSET(FS_POSSIBLE) ?
"250|%s: file modified more recently than this copy; use ! to override" :
"251|%s: file modified more recently than this copy");
@@ -832,32 +844,46 @@ file_write(sp, fm, tm, name, flags)
SIGBLOCK;
if ((fd = open(name, oflags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) {
+ if (errno == EACCES && LF_ISSET(FS_FORCE)) {
+ /*
+ * If the user owns the file but does not
+ * have write permission on it, grant it
+ * automatically for the duration of the
+ * opening of the file, if possible.
+ */
+ struct stat sb;
+ mode_t fmode;
+
+ if (stat(name, &sb) != 0)
+ goto fail_open;
+ fmode = sb.st_mode;
+ if (!(sb.st_mode & S_IWUSR) && sb.st_uid == getuid())
+ fmode |= S_IWUSR;
+ else
+ goto fail_open;
+ if (chmod(name, fmode) != 0)
+ goto fail_open;
+ fd = open(name, oflags, S_IRUSR | S_IWUSR |
+ S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ if (fd == -1)
+ goto fail_open;
+ (void)fchmod(fd, sb.st_mode);
+ goto success_open;
+ fail_open:
+ errno = EACCES;
+ }
msgq_str(sp, M_SYSERR, name, "%s");
SIGUNBLOCK;
return (1);
}
+success_open:
SIGUNBLOCK;
/* Try and get a lock. */
- if (!noname && file_lock(sp, NULL, NULL, fd, 0) == LOCK_UNAVAIL)
+ if (!noname && file_lock(sp, NULL, fd, 0) == LOCK_UNAVAIL)
msgq_str(sp, M_ERR, name,
"252|%s: write lock was unavailable");
-#if __linux__
- /*
- * XXX
- * In libc 4.5.x, fdopen(fd, "w") clears the O_APPEND flag (if set).
- * This bug is fixed in libc 4.6.x.
- *
- * This code works around this problem for libc 4.5.x users.
- * Note that this code is harmless if you're using libc 4.6.x.
- */
- if (LF_ISSET(FS_APPEND) && lseek(fd, (off_t)0, SEEK_END) < 0) {
- msgq(sp, M_SYSERR, name);
- return (1);
- }
-#endif
-
/*
* Use stdio for buffering.
*
@@ -891,13 +917,13 @@ file_write(sp, fm, tm, name, flags)
*/
if (noname)
if (stat(name, &sb))
- time(&ep->mtime);
+ timepoint_system(&ep->mtim);
else {
F_SET(ep, F_DEVSET);
ep->mdev = sb.st_dev;
ep->minode = sb.st_ino;
- ep->mtime = sb.st_mtime;
+ ep->mtim = sb.st_mtimespec;
}
/*
@@ -970,7 +996,7 @@ file_write(sp, fm, tm, name, flags)
*--s = '.';
}
}
- msgq(sp, M_INFO, s);
+ msgq(sp, M_INFO, "%s", s);
if (nf)
FREE_SPACE(sp, p, 0);
return (0);
@@ -989,9 +1015,10 @@ file_write(sp, fm, tm, name, flags)
* recreate the file. So, let's not risk it.
*/
static int
-file_backup(sp, name, bname)
- SCR *sp;
- char *name, *bname;
+file_backup(
+ SCR *sp,
+ char *name,
+ char *bname)
{
struct dirent *dp;
struct stat sb;
@@ -1001,6 +1028,10 @@ file_backup(sp, name, bname)
size_t blen;
int flags, maxnum, nr, num, nw, rfd, wfd, version;
char *bp, *estr, *p, *pct, *slash, *t, *wfname, buf[8192];
+ CHAR_T *wp;
+ size_t wlen;
+ size_t nlen;
+ char *d = NULL;
rfd = wfd = -1;
bp = estr = wfname = NULL;
@@ -1030,15 +1061,20 @@ file_backup(sp, name, bname)
*
* Shell and file name expand the option's value.
*/
- argv_init(sp, &cmd);
- ex_cinit(&cmd, 0, 0, 0, 0, 0, NULL);
+ ex_cinit(sp, &cmd, 0, 0, 0, 0, 0);
if (bname[0] == 'N') {
version = 1;
++bname;
} else
version = 0;
- if (argv_exp2(sp, &cmd, bname, strlen(bname)))
+ CHAR2INT(sp, bname, strlen(bname), wp, wlen);
+ if ((wp = v_wstrdup(sp, wp, wlen)) == NULL)
return (1);
+ if (argv_exp2(sp, &cmd, wp, wlen)) {
+ free(wp);
+ return (1);
+ }
+ free(wp);
/*
* 0 args: impossible.
@@ -1061,9 +1097,13 @@ file_backup(sp, name, bname)
* by one.
*/
if (version) {
- GET_SPACE_GOTO(sp, bp, blen, cmd.argv[0]->len * 2 + 50);
- for (t = bp, slash = NULL,
- p = cmd.argv[0]->bp; p[0] != '\0'; *t++ = *p++)
+ GET_SPACE_GOTOC(sp, bp, blen, cmd.argv[0]->len * 2 + 50);
+ INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1,
+ p, nlen);
+ d = strdup(p);
+ p = d;
+ for (t = bp, slash = NULL;
+ p[0] != '\0'; *t++ = *p++)
if (p[0] == '%') {
if (p[1] != '%')
*t++ = '%';
@@ -1084,7 +1124,8 @@ file_backup(sp, name, bname)
p = slash + 1;
}
if (dirp == NULL) {
- estr = cmd.argv[0]->bp;
+ INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1,
+ estr, nlen);
goto err;
}
@@ -1098,7 +1139,8 @@ file_backup(sp, name, bname)
wfname = bp;
} else {
bp = NULL;
- wfname = cmd.argv[0]->bp;
+ INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1,
+ wfname, nlen);
}
/* Open the backup file, avoiding lurkers. */
@@ -1158,22 +1200,69 @@ err: if (rfd != -1)
}
if (estr)
msgq_str(sp, M_SYSERR, estr, "%s");
+ if (d != NULL)
+ free(d);
if (bp != NULL)
FREE_SPACE(sp, bp, blen);
return (1);
}
/*
+ * file_encinit --
+ * Read the first line and set the O_FILEENCODING.
+ */
+static void
+file_encinit(SCR *sp)
+{
+#if defined(USE_WIDECHAR) && defined(USE_ICONV)
+ size_t len;
+ char *p;
+ size_t blen = 0;
+ char buf[4096]; /* not need to be '\0'-terminated */
+ recno_t ln = 1;
+ EXF *ep;
+
+ ep = sp->ep;
+
+ while (!db_rget(sp, ln++, &p, &len)) {
+ if (blen + len > sizeof(buf))
+ len = sizeof(buf) - blen;
+ memcpy(buf + blen, p, len);
+ blen += len;
+ if (blen == sizeof(buf))
+ break;
+ else
+ buf[blen++] = '\n';
+ }
+
+ /*
+ * Detect UTF-8 and fallback to the locale/preset encoding.
+ *
+ * XXX
+ * A manually set O_FILEENCODING indicates the "fallback
+ * encoding", but UTF-8, which can be safely detected, is not
+ * inherited from the old screen.
+ */
+ if (looks_utf8(buf, blen) > 1)
+ o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-8", 0);
+ else if (!O_ISSET(sp, O_FILEENCODING) ||
+ !strncasecmp(O_STR(sp, O_FILEENCODING), "utf-8", 5))
+ o_set(sp, O_FILEENCODING, OS_STRDUP, codeset(), 0);
+
+ conv_enc(sp, O_FILEENCODING, 0);
+#endif
+}
+
+/*
* file_comment --
* Skip the first comment.
*/
static void
-file_comment(sp)
- SCR *sp;
+file_comment(SCR *sp)
{
recno_t lno;
size_t len;
- char *p;
+ CHAR_T *p;
for (lno = 1; !db_get(sp, lno, 0, &p, &len) && len == 0; ++lno);
if (p == NULL)
@@ -1216,9 +1305,10 @@ file_comment(sp)
* PUBLIC: int file_m1 __P((SCR *, int, int));
*/
int
-file_m1(sp, force, flags)
- SCR *sp;
- int force, flags;
+file_m1(
+ SCR *sp,
+ int force,
+ int flags)
{
EXF *ep;
@@ -1256,9 +1346,9 @@ file_m1(sp, force, flags)
* PUBLIC: int file_m2 __P((SCR *, int));
*/
int
-file_m2(sp, force)
- SCR *sp;
- int force;
+file_m2(
+ SCR *sp,
+ int force)
{
EXF *ep;
@@ -1288,9 +1378,9 @@ file_m2(sp, force)
* PUBLIC: int file_m3 __P((SCR *, int));
*/
int
-file_m3(sp, force)
- SCR *sp;
- int force;
+file_m3(
+ SCR *sp,
+ int force)
{
EXF *ep;
@@ -1324,9 +1414,9 @@ file_m3(sp, force)
* PUBLIC: int file_aw __P((SCR *, int));
*/
int
-file_aw(sp, flags)
- SCR *sp;
- int flags;
+file_aw(
+ SCR *sp,
+ int flags)
{
if (!F_ISSET(sp->ep, F_MODIFIED))
return (0);
@@ -1385,9 +1475,9 @@ file_aw(sp, flags)
* PUBLIC: void set_alt_name __P((SCR *, char *));
*/
void
-set_alt_name(sp, name)
- SCR *sp;
- char *name;
+set_alt_name(
+ SCR *sp,
+ char *name)
{
if (sp->alt_name != NULL)
free(sp->alt_name);
@@ -1401,35 +1491,18 @@ set_alt_name(sp, name)
* file_lock --
* Get an exclusive lock on a file.
*
- * XXX
- * The default locking is flock(2) style, not fcntl(2). The latter is
- * known to fail badly on some systems, and its only advantage is that
- * it occasionally works over NFS.
- *
- * Furthermore, the semantics of fcntl(2) are wrong. The problems are
- * two-fold: you can't close any file descriptor associated with the file
- * without losing all of the locks, and you can't get an exclusive lock
- * unless you have the file open for writing. Someone ought to be shot,
- * but it's probably too late, they may already have reproduced. To get
- * around these problems, nvi opens the files for writing when it can and
- * acquires a second file descriptor when it can't. The recovery files
- * are examples of the former, they're always opened for writing. The DB
- * files can't be opened for writing because the semantics of DB are that
- * files opened for writing are flushed back to disk when the DB session
- * is ended. So, in that case we have to acquire an extra file descriptor.
- *
- * PUBLIC: lockr_t file_lock __P((SCR *, char *, int *, int, int));
+ * PUBLIC: lockr_t file_lock __P((SCR *, char *, int, int));
*/
lockr_t
-file_lock(sp, name, fdp, fd, iswrite)
- SCR *sp;
- char *name;
- int *fdp, fd, iswrite;
+file_lock(
+ SCR *sp,
+ char *name,
+ int fd,
+ int iswrite)
{
if (!O_ISSET(sp, O_LOCKFILES))
return (LOCK_SUCCESS);
-#ifdef HAVE_LOCK_FLOCK /* Hurrah! We've got flock(2). */
/*
* !!!
* We need to distinguish a lock not being available for the file
@@ -1438,61 +1511,13 @@ file_lock(sp, name, fdp, fd, iswrite)
* they are the former. There's no portable way to do this.
*/
errno = 0;
- return (flock(fd, LOCK_EX | LOCK_NB) ? errno == EAGAIN
-#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
-#endif
- ? LOCK_UNAVAIL : LOCK_FAILED : LOCK_SUCCESS);
-#endif
-#ifdef HAVE_LOCK_FCNTL /* Gag me. We've got fcntl(2). */
-{
- struct flock arg;
- int didopen, sverrno;
-
- arg.l_type = F_WRLCK;
- arg.l_whence = 0; /* SEEK_SET */
- arg.l_start = arg.l_len = 0;
- arg.l_pid = 0;
-
- /*
- * If the file descriptor isn't opened for writing, it must fail.
- * If we fail because we can't get a read/write file descriptor,
- * we return LOCK_SUCCESS, believing that the file is readonly
- * and that will be sufficient to warn the user.
- */
- if (!iswrite) {
- if (name == NULL || fdp == NULL)
- return (LOCK_FAILED);
- if ((fd = open(name, O_RDWR, 0)) == -1)
- return (LOCK_SUCCESS);
- *fdp = fd;
- didopen = 1;
- }
-
- errno = 0;
- if (!fcntl(fd, F_SETLK, &arg))
+ if (!flock(fd, LOCK_EX | LOCK_NB)) {
+ fcntl(fd, F_SETFD, 1);
return (LOCK_SUCCESS);
- if (didopen) {
- sverrno = errno;
- (void)close(fd);
- errno = sverrno;
}
-
- /*
- * !!!
- * We need to distinguish a lock not being available for the file
- * from the file system not supporting locking. Fcntl is documented
- * as returning EACCESS and EAGAIN; add EWOULDBLOCK for good measure,
- * and assume they are the former. There's no portable way to do this.
- */
- return (errno == EACCES || errno == EAGAIN
+ return (errno == EAGAIN
#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
-#endif
- ? LOCK_UNAVAIL : LOCK_FAILED);
-}
-#endif
-#if !defined(HAVE_LOCK_FLOCK) && !defined(HAVE_LOCK_FCNTL)
- return (LOCK_SUCCESS);
+ || errno == EWOULDBLOCK
#endif
+ ? LOCK_UNAVAIL : LOCK_FAILED);
}
diff --git a/common/exf.h b/common/exf.h
index cdfaa8294485..8f70d51dbb61 100644
--- a/common/exf.h
+++ b/common/exf.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)exf.h 10.7 (Berkeley) 7/9/96
+ * $Id: exf.h,v 10.10 2012/07/06 16:03:37 zy Exp $
*/
/* Undo direction. */
/*
@@ -18,8 +18,9 @@ struct _exf {
/* Underlying database state. */
DB *db; /* File db structure. */
- char *c_lp; /* Cached line. */
+ CHAR_T *c_lp; /* Cached line. */
size_t c_len; /* Cached line length. */
+ size_t c_blen; /* Cached line buffer length. */
recno_t c_lno; /* Cached line number. */
recno_t c_nlines; /* Cached lines in the file. */
@@ -31,17 +32,12 @@ struct _exf {
MARK l_cursor; /* Log cursor position. */
dir_t lundo; /* Last undo direction. */
- LIST_HEAD(_markh, _lmark) marks;/* Linked list of file MARK's. */
+ /* Linked list of file MARK's. */
+ SLIST_HEAD(_markh, _lmark) marks[1];
- /*
- * XXX
- * Mtime should be a struct timespec, but time_t is more portable.
- */
- dev_t mdev; /* Device. */
- ino_t minode; /* Inode. */
- time_t mtime; /* Last modification time. */
-
- int fcntl_fd; /* Fcntl locking fd; see exf.c. */
+ dev_t mdev; /* Device. */
+ ino_t minode; /* Inode. */
+ struct timespec mtim; /* Last modification time. */
/*
* Recovery in general, and these fields specifically, are described
diff --git a/include/com_extern.h b/common/extern.h
index f140f9e34232..20672e380b14 100644
--- a/include/com_extern.h
+++ b/common/extern.h
@@ -1,94 +1,19 @@
-#ifndef HAVE_BSEARCH
-void *bsearch __P((const void *, const void *, size_t,
- size_t, int (*)(const void *, const void *)));
-#endif
-#ifndef HAVE_SETENV
-int setenv __P((const char *, const char *, int));
-#endif
-#ifndef HAVE_UNSETENV
-void unsetenv __P((const char *));
-#endif
-#ifndef HAVE_GETHOSTNAME
-int gethostname __P((char *, int));
-#endif
-#ifndef HAVE_GETOPT
-int getopt __P((int, char * const *, const char *));
-#endif
-#ifndef HAVE_MEMCHR
-void *memchr __P((const void *, int, size_t));
-#endif
-#ifndef HAVE_MEMCPY
-void *memcpy __P((void *, const void *, size_t));
-#endif
-#ifndef HAVE_MEMMOVE
-void *memmove __P((void *, const void *, size_t));
-#endif
-#ifndef HAVE_MEMSET
-void *memset __P((void *, int, size_t));
-#endif
-#ifndef HAVE_MKSTEMP
-int mkstemp __P((char *));
-#endif
-#ifndef HAVE_MMAP
-char *mmap __P((char *, size_t, int, int, int, off_t));
-#endif
-#ifndef HAVE_MMAP
-int munmap __P((char *, size_t));
-#endif
-#ifndef HAVE_SNPRINTF
-int snprintf __P((char *, size_t, const char *, ...));
-#endif
-#ifndef HAVE_STRDUP
-char *strdup __P((const char *));
-#endif
-#ifndef HAVE_STRERROR
-char *strerror __P((int));
-#endif
-#ifndef HAVE_STRPBRK
-char *strpbrk __P((const char *, const char *));
-#endif
-#ifndef HAVE_STRSEP
-char *strsep __P((char **, const char *));
-#endif
-#ifndef HAVE_STRTOL
-long strtol __P((const char *, char **, int));
-#endif
-#ifndef HAVE_STRTOUL
-unsigned long strtoul __P((const char *, char **, int));
-#endif
-#ifndef HAVE_VSNPRINTF
-int vsnprintf __P((char *, size_t, const char *, ...));
-#endif
-SCR *api_fscreen __P((int, char *));
-int api_aline __P((SCR *, recno_t, char *, size_t));
-int api_dline __P((SCR *, recno_t));
-int api_gline __P((SCR *, recno_t, char **, size_t *));
-int api_iline __P((SCR *, recno_t, char *, size_t));
-int api_lline __P((SCR *, recno_t *));
-int api_sline __P((SCR *, recno_t, char *, size_t));
-int api_getmark __P((SCR *, int, MARK *));
-int api_setmark __P((SCR *, int, MARK *));
-int api_nextmark __P((SCR *, int, char *));
-int api_getcursor __P((SCR *, MARK *));
-int api_setcursor __P((SCR *, MARK *));
-void api_emessage __P((SCR *, char *));
-void api_imessage __P((SCR *, char *));
-int api_edit __P((SCR *, char *, SCR **, int));
-int api_escreen __P((SCR *));
-int api_swscreen __P((SCR *, SCR *));
-int api_map __P((SCR *, char *, char *, size_t));
-int api_unmap __P((SCR *, char *));
-int api_opts_get __P((SCR *, char *, char **, int *));
-int api_opts_set __P((SCR *, char *, char *, u_long, int));
-int api_run_str __P((SCR *, char *));
+char * codeset __P((void));
+void conv_init __P((SCR *, SCR *));
+int conv_enc __P((SCR *, int, char *));
+void conv_end __P((SCR *));
int cut __P((SCR *, CHAR_T *, MARK *, MARK *, int));
int cut_line __P((SCR *, recno_t, size_t, size_t, CB *));
void cut_close __P((GS *));
-TEXT *text_init __P((SCR *, const char *, size_t, size_t));
+TEXT *text_init __P((SCR *, const CHAR_T *, size_t, size_t));
void text_lfree __P((TEXTH *));
void text_free __P((TEXT *));
int del __P((SCR *, MARK *, MARK *, int));
-FREF *file_add __P((SCR *, CHAR_T *));
+int looks_utf8 __P((const char *, size_t));
+int looks_utf16 __P((const char *, size_t));
+int decode_utf8 __P((const char *));
+int decode_utf16 __P((const char *, int));
+FREF *file_add __P((SCR *, char *));
int file_init __P((SCR *, FREF *, char *, int));
int file_end __P((SCR *, EXF *, int));
int file_write __P((SCR *, MARK *, MARK *, char *, int));
@@ -97,24 +22,26 @@ int file_m2 __P((SCR *, int));
int file_m3 __P((SCR *, int));
int file_aw __P((SCR *, int));
void set_alt_name __P((SCR *, char *));
-lockr_t file_lock __P((SCR *, char *, int *, int, int));
+lockr_t file_lock __P((SCR *, char *, int, int));
int v_key_init __P((SCR *));
void v_key_ilookup __P((SCR *));
size_t v_key_len __P((SCR *, ARG_CHAR_T));
-CHAR_T *v_key_name __P((SCR *, ARG_CHAR_T));
-int v_key_val __P((SCR *, ARG_CHAR_T));
+char *v_key_name __P((SCR *, ARG_CHAR_T));
+e_key_t v_key_val __P((SCR *, ARG_CHAR_T));
int v_event_push __P((SCR *, EVENT *, CHAR_T *, size_t, u_int));
int v_event_get __P((SCR *, EVENT *, int, u_int32_t));
void v_event_err __P((SCR *, EVENT *));
int v_event_flush __P((SCR *, u_int));
-int db_eget __P((SCR *, recno_t, char **, size_t *, int *));
-int db_get __P((SCR *, recno_t, u_int32_t, char **, size_t *));
+int db_eget __P((SCR *, recno_t, CHAR_T **, size_t *, int *));
+int db_get __P((SCR *, recno_t, u_int32_t, CHAR_T **, size_t *));
int db_delete __P((SCR *, recno_t));
-int db_append __P((SCR *, int, recno_t, char *, size_t));
-int db_insert __P((SCR *, recno_t, char *, size_t));
-int db_set __P((SCR *, recno_t, char *, size_t));
+int db_append __P((SCR *, int, recno_t, CHAR_T *, size_t));
+int db_insert __P((SCR *, recno_t, CHAR_T *, size_t));
+int db_set __P((SCR *, recno_t, CHAR_T *, size_t));
int db_exist __P((SCR *, recno_t));
int db_last __P((SCR *, recno_t *));
+int db_rget __P((SCR *, recno_t, char **, size_t *));
+int db_rset __P((SCR *, recno_t, char *, size_t));
void db_err __P((SCR *, recno_t));
int log_init __P((SCR *, EXF *));
int log_end __P((SCR *, EXF *));
@@ -132,7 +59,8 @@ int mark_get __P((SCR *, ARG_CHAR_T, MARK *, mtype_t));
int mark_set __P((SCR *, ARG_CHAR_T, MARK *, int));
int mark_insdel __P((SCR *, lnop_t, recno_t));
void msgq __P((SCR *, mtype_t, const char *, ...));
-void msgq_str __P((SCR *, mtype_t, char *, char *));
+void msgq_wstr __P((SCR *, mtype_t, const CHAR_T *, const char *));
+void msgq_str __P((SCR *, mtype_t, const char *, const char *));
void mod_rpt __P((SCR *));
void msgq_status __P((SCR *, recno_t, u_int));
int msg_open __P((SCR *, char *));
@@ -146,8 +74,8 @@ int o_set __P((SCR *, int, u_int, char *, u_long));
int opts_empty __P((SCR *, int, int));
void opts_dump __P((SCR *, enum optdisp));
int opts_save __P((SCR *, FILE *));
-OPTLIST const *opts_search __P((char *));
-void opts_nomatch __P((SCR *, char *));
+OPTLIST const *opts_search __P((CHAR_T *));
+void opts_nomatch __P((SCR *, CHAR_T *));
int opts_copy __P((SCR *, SCR *));
void opts_free __P((SCR *));
int f_altwerase __P((SCR *, OPTION *, char *, u_long *));
@@ -155,17 +83,16 @@ int f_columns __P((SCR *, OPTION *, char *, u_long *));
int f_lines __P((SCR *, OPTION *, char *, u_long *));
int f_lisp __P((SCR *, OPTION *, char *, u_long *));
int f_msgcat __P((SCR *, OPTION *, char *, u_long *));
-int f_paragraph __P((SCR *, OPTION *, char *, u_long *));
int f_print __P((SCR *, OPTION *, char *, u_long *));
int f_readonly __P((SCR *, OPTION *, char *, u_long *));
int f_recompile __P((SCR *, OPTION *, char *, u_long *));
int f_reformat __P((SCR *, OPTION *, char *, u_long *));
-int f_section __P((SCR *, OPTION *, char *, u_long *));
int f_ttywerase __P((SCR *, OPTION *, char *, u_long *));
int f_w300 __P((SCR *, OPTION *, char *, u_long *));
int f_w1200 __P((SCR *, OPTION *, char *, u_long *));
int f_w9600 __P((SCR *, OPTION *, char *, u_long *));
int f_window __P((SCR *, OPTION *, char *, u_long *));
+int f_encoding __P((SCR *, OPTION *, char *, u_long *));
int put __P((SCR *, CB *, CHAR_T *, MARK *, MARK *, int));
int rcv_tmp __P((SCR *, EXF *, char *));
int rcv_init __P((SCR *));
@@ -176,14 +103,14 @@ int screen_init __P((GS *, SCR *, SCR **));
int screen_end __P((SCR *));
SCR *screen_next __P((SCR *));
int f_search __P((SCR *,
- MARK *, MARK *, char *, size_t, char **, u_int));
+ MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int));
int b_search __P((SCR *,
- MARK *, MARK *, char *, size_t, char **, u_int));
+ MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int));
void search_busy __P((SCR *, busy_t));
int seq_set __P((SCR *, CHAR_T *,
size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int));
int seq_delete __P((SCR *, CHAR_T *, size_t, seq_t));
-int seq_mdel __P((SEQ *));
+int seq_free __P((SEQ *));
SEQ *seq_find
__P((SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *));
void seq_close __P((GS *));
@@ -193,7 +120,13 @@ int e_memcmp __P((CHAR_T *, EVENT *, size_t));
void *binc __P((SCR *, void *, size_t *, size_t));
int nonblank __P((SCR *, recno_t, size_t *));
char *tail __P((char *));
-CHAR_T *v_strdup __P((SCR *, const CHAR_T *, size_t));
-enum nresult nget_uslong __P((u_long *, const char *, char **, int));
-enum nresult nget_slong __P((long *, const char *, char **, int));
+char *join __P((char *, char *));
+char *expanduser __P((char *));
+char *quote __P((char *));
+char *v_strdup __P((SCR *, const char *, size_t));
+CHAR_T *v_wstrdup __P((SCR *, const CHAR_T *, size_t));
+enum nresult nget_uslong __P((u_long *, const CHAR_T *, CHAR_T **, int));
+enum nresult nget_slong __P((long *, const CHAR_T *, CHAR_T **, int));
+void timepoint_steady __P((struct timespec *));
+void timepoint_system __P((struct timespec *));
void TRACE __P((SCR *, const char *, ...));
diff --git a/common/gs.h b/common/gs.h
index e5a43a656ac2..33a02458b0f9 100644
--- a/common/gs.h
+++ b/common/gs.h
@@ -6,11 +6,13 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)gs.h 10.34 (Berkeley) 9/24/96
+ * $Id: gs.h,v 11.0 2012/10/17 06:34:37 zy Exp $
*/
#define TEMPORARY_FILE_STRING "/tmp" /* Default temporary file name. */
+#include <nl_types.h>
+
/*
* File reference structure (FREF). The structure contains the name of the
* file, along with the information that follows the name.
@@ -19,7 +21,7 @@
* The read-only bit follows the file name, not the file itself.
*/
struct _fref {
- CIRCLEQ_ENTRY(_fref) q; /* Linked list of file references. */
+ TAILQ_ENTRY(_fref) q; /* Linked list of file references. */
char *name; /* File name. */
char *tname; /* Backing temporary file name. */
@@ -56,20 +58,15 @@ struct _gs {
char *progname; /* Programe name. */
int id; /* Last allocated screen id. */
- CIRCLEQ_HEAD(_dqh, _scr) dq; /* Displayed screens. */
- CIRCLEQ_HEAD(_hqh, _scr) hq; /* Hidden screens. */
+ TAILQ_HEAD(_dqh, _scr) dq[1]; /* Displayed screens. */
+ TAILQ_HEAD(_hqh, _scr) hq[1]; /* Hidden screens. */
SCR *ccl_sp; /* Colon command-line screen. */
- void *perl_interp; /* Perl interpreter. */
- void *tcl_interp; /* Tcl_Interp *: Tcl interpreter. */
-
void *cl_private; /* Curses support private area. */
- void *ip_private; /* IP support private area. */
- void *tk_private; /* Tk/Tcl support private area. */
/* File references. */
- CIRCLEQ_HEAD(_frefh, _fref) frefq;
+ TAILQ_HEAD(_frefh, _fref) frefq[1];
#define GO_COLUMNS 0 /* Global options: columns. */
#define GO_LINES 1 /* Global options: lines. */
@@ -77,10 +74,10 @@ struct _gs {
#define GO_TERM 3 /* Global options: terminal type. */
OPTION opts[GO_TERM + 1];
- DB *msg; /* Message catalog DB. */
- MSGH msgq; /* User message list. */
+ nl_catd catd; /* Message catalog descriptor. */
+ MSGH msgq[1]; /* User message list. */
#define DEFAULT_NOPRINT '\1' /* Emergency non-printable character. */
- CHAR_T noprint; /* Cached, unprintable character. */
+ int noprint; /* Cached, unprintable character. */
char *tmp_bp; /* Temporary buffer. */
size_t tmp_blen; /* Temporary buffer size. */
@@ -89,8 +86,9 @@ struct _gs {
* Ex command structures (EXCMD). Defined here because ex commands
* exist outside of any particular screen or file.
*/
-#define EXCMD_RUNNING(gp) ((gp)->ecq.lh_first->clen != 0)
- LIST_HEAD(_excmdh, _excmd) ecq; /* Ex command linked list. */
+#define EXCMD_RUNNING(gp) (SLIST_FIRST((gp)->ecq)->clen != 0)
+ /* Ex command linked list. */
+ SLIST_HEAD(_excmdh, _excmd) ecq[1];
EXCMD excmd; /* Default ex command structure. */
char *if_name; /* Current associated file. */
recno_t if_lno; /* Current associated line number. */
@@ -108,30 +106,28 @@ struct _gs {
CB *dcbp; /* Default cut buffer pointer. */
CB dcb_store; /* Default cut buffer storage. */
- LIST_HEAD(_cuth, _cb) cutq; /* Linked list of cut buffers. */
+ SLIST_HEAD(_cuth, _cb) cutq[1]; /* Linked list of cut buffers. */
-#define MAX_BIT_SEQ 128 /* Max + 1 fast check character. */
- LIST_HEAD(_seqh, _seq) seqq; /* Linked list of maps, abbrevs. */
- bitstr_t bit_decl(seqb, MAX_BIT_SEQ);
+#define MAX_BIT_SEQ 0x7f /* Max + 1 fast check character. */
+ SLIST_HEAD(_seqh, _seq) seqq[1];/* Linked list of maps, abbrevs. */
+ bitstr_t bit_decl(seqb, MAX_BIT_SEQ + 1);
-#define MAX_FAST_KEY 254 /* Max fast check character.*/
+#define MAX_FAST_KEY 0xff /* Max fast check character.*/
#define KEY_LEN(sp, ch) \
- ((unsigned char)(ch) <= MAX_FAST_KEY ? \
+ (((ch) & ~MAX_FAST_KEY) == 0 ? \
sp->gp->cname[(unsigned char)ch].len : v_key_len(sp, ch))
#define KEY_NAME(sp, ch) \
- ((unsigned char)(ch) <= MAX_FAST_KEY ? \
+ (((ch) & ~MAX_FAST_KEY) == 0 ? \
sp->gp->cname[(unsigned char)ch].name : v_key_name(sp, ch))
struct {
- CHAR_T name[MAX_CHARACTER_COLUMNS + 1];
+ char name[MAX_CHARACTER_COLUMNS + 1];
u_int8_t len;
} cname[MAX_FAST_KEY + 1]; /* Fast lookup table. */
#define KEY_VAL(sp, ch) \
- ((unsigned char)(ch) <= MAX_FAST_KEY ? \
- sp->gp->special_key[(unsigned char)ch] : \
- (unsigned char)(ch) > sp->gp->max_special ? 0 : v_key_val(sp,ch))
- CHAR_T max_special; /* Max special character. */
- u_char /* Fast lookup table. */
+ (((ch) & ~MAX_FAST_KEY) == 0 ? \
+ sp->gp->special_key[(unsigned char)ch] : v_key_val(sp,ch))
+ e_key_t /* Fast lookup table. */
special_key[MAX_FAST_KEY + 1];
/* Flags. */
@@ -149,6 +145,8 @@ struct _gs {
/* Screen interface functions. */
/* Add a string to the screen. */
int (*scr_addstr) __P((SCR *, const char *, size_t));
+ /* Add a string to the screen. */
+ int (*scr_waddstr) __P((SCR *, const CHAR_T *, size_t));
/* Toggle a screen attribute. */
int (*scr_attr) __P((SCR *, scr_attr_t, int));
/* Terminal baud rate. */
@@ -157,12 +155,16 @@ struct _gs {
int (*scr_bell) __P((SCR *));
/* Display a busy message. */
void (*scr_busy) __P((SCR *, const char *, busy_t));
+ /* Prepare child. */
+ int (*scr_child) __P((SCR *));
/* Clear to the end of the line. */
int (*scr_clrtoeol) __P((SCR *));
/* Return the cursor location. */
int (*scr_cursor) __P((SCR *, size_t *, size_t *));
/* Delete a line. */
int (*scr_deleteln) __P((SCR *));
+ /* Discard a screen. */
+ int (*scr_discard) __P((SCR *, SCR **));
/* Get a keyboard event. */
int (*scr_event) __P((SCR *, EVENT *, u_int32_t, int));
/* Ex: screen adjustment routine. */
@@ -183,8 +185,12 @@ struct _gs {
int (*scr_refresh) __P((SCR *, int));
/* Rename the file. */
int (*scr_rename) __P((SCR *, char *, int));
+ /* Reply to an event. */
+ int (*scr_reply) __P((SCR *, int, char *));
/* Set the screen type. */
int (*scr_screen) __P((SCR *, u_int32_t));
+ /* Split the screen. */
+ int (*scr_split) __P((SCR *, SCR *));
/* Suspend the editor. */
int (*scr_suspend) __P((SCR *, int *));
/* Print usage message. */
diff --git a/common/key.c b/common/key.c
index e1311ab571b0..652b8f3eae00 100644
--- a/common/key.c
+++ b/common/key.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)key.c 10.33 (Berkeley) 9/24/96";
+static const char sccsid[] = "$Id: key.c,v 10.53 2013/03/11 01:20:53 yamt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -21,10 +21,10 @@ static const char sccsid[] = "@(#)key.c 10.33 (Berkeley) 9/24/96";
#include <ctype.h>
#include <errno.h>
#include <limits.h>
-#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include "common.h"
@@ -100,32 +100,15 @@ static int nkeylist =
* PUBLIC: int v_key_init __P((SCR *));
*/
int
-v_key_init(sp)
- SCR *sp;
+v_key_init(SCR *sp)
{
- CHAR_T ch;
+ int ch;
GS *gp;
KEYLIST *kp;
int cnt;
gp = sp->gp;
- /*
- * XXX
- * 8-bit only, for now. Recompilation should get you any 8-bit
- * character set, as long as nul isn't a character.
- */
- (void)setlocale(LC_ALL, "");
-#if __linux__
- /*
- * In libc 4.5.26, setlocale(LC_ALL, ""), doesn't setup the table
- * for ctype(3c) correctly. This bug is fixed in libc 4.6.x.
- *
- * This code works around this problem for libc 4.5.x users.
- * Note that this code is harmless if you're using libc 4.6.x.
- */
- (void)setlocale(LC_CTYPE, "");
-#endif
v_key_ilookup(sp);
v_keyval(sp, K_CNTRLD, KEY_VEOF);
@@ -137,15 +120,11 @@ v_key_init(sp)
qsort(keylist, nkeylist, sizeof(keylist[0]), v_key_cmp);
/* Initialize the fast lookup table. */
- for (gp->max_special = 0, kp = keylist, cnt = nkeylist; cnt--; ++kp) {
- if (gp->max_special < kp->value)
- gp->max_special = kp->value;
- if (kp->ch <= MAX_FAST_KEY)
- gp->special_key[kp->ch] = kp->value;
- }
+ for (kp = keylist, cnt = nkeylist; cnt--; ++kp)
+ gp->special_key[kp->ch] = kp->value;
/* Find a non-printable character to use as a message separator. */
- for (ch = 1; ch <= MAX_CHAR_T; ++ch)
+ for (ch = 1; ch <= UCHAR_MAX; ++ch)
if (!isprint(ch)) {
gp->noprint = ch;
break;
@@ -166,10 +145,10 @@ v_key_init(sp)
* in the table, so we check for that first.
*/
static void
-v_keyval(sp, val, name)
- SCR *sp;
- int val;
- scr_keyval_t name;
+v_keyval(
+ SCR *sp,
+ int val,
+ scr_keyval_t name)
{
KEYLIST *kp;
CHAR_T ch;
@@ -203,17 +182,20 @@ v_keyval(sp, val, name)
* PUBLIC: void v_key_ilookup __P((SCR *));
*/
void
-v_key_ilookup(sp)
- SCR *sp;
+v_key_ilookup(SCR *sp)
{
- CHAR_T ch, *p, *t;
+ UCHAR_T ch;
+ char *p, *t;
GS *gp;
size_t len;
- for (gp = sp->gp, ch = 0; ch <= MAX_FAST_KEY; ++ch)
+ for (gp = sp->gp, ch = 0;; ++ch) {
for (p = gp->cname[ch].name, t = v_key_name(sp, ch),
len = gp->cname[ch].len = sp->clen; len--;)
*p++ = *t++;
+ if (ch == MAX_FAST_KEY)
+ break;
+ }
}
/*
@@ -224,9 +206,9 @@ v_key_ilookup(sp)
* PUBLIC: size_t v_key_len __P((SCR *, ARG_CHAR_T));
*/
size_t
-v_key_len(sp, ch)
- SCR *sp;
- ARG_CHAR_T ch;
+v_key_len(
+ SCR *sp,
+ ARG_CHAR_T ch)
{
(void)v_key_name(sp, ch);
return (sp->clen);
@@ -237,30 +219,43 @@ v_key_len(sp, ch)
* Return the string that will display the key. This routine
* is the backup for the KEY_NAME() macro.
*
- * PUBLIC: CHAR_T *v_key_name __P((SCR *, ARG_CHAR_T));
+ * PUBLIC: char *v_key_name __P((SCR *, ARG_CHAR_T));
*/
-CHAR_T *
-v_key_name(sp, ach)
- SCR *sp;
- ARG_CHAR_T ach;
+char *
+v_key_name(
+ SCR *sp,
+ ARG_CHAR_T ach)
{
- static const CHAR_T hexdigit[] = "0123456789abcdef";
- static const CHAR_T octdigit[] = "01234567";
- CHAR_T ch, *chp, mask;
+ static const char hexdigit[] = "0123456789abcdef";
+ static const char octdigit[] = "01234567";
+ int ch;
size_t len;
- int cnt, shift;
+ char *chp;
+
+ /*
+ * Cache the last checked character. It won't be a problem
+ * since nvi will rescan the mapping when settings changed.
+ */
+ if (ach && sp->lastc == ach)
+ return (sp->cname);
+ sp->lastc = ach;
+
+#ifdef USE_WIDECHAR
+ len = wctomb(sp->cname, ach);
+ if (len > MB_CUR_MAX)
+#endif
+ sp->cname[(len = 1)-1] = (u_char)ach;
- ch = ach;
+ ch = (u_char)sp->cname[0];
+ sp->cname[len] = '\0';
/* See if the character was explicitly declared printable or not. */
if ((chp = O_STR(sp, O_PRINT)) != NULL)
- for (; *chp != '\0'; ++chp)
- if (*chp == ch)
- goto pr;
+ if (strstr(chp, sp->cname) != NULL)
+ goto done;
if ((chp = O_STR(sp, O_NOPRINT)) != NULL)
- for (; *chp != '\0'; ++chp)
- if (*chp == ch)
- goto nopr;
+ if (strstr(chp, sp->cname) != NULL)
+ goto nopr;
/*
* Historical (ARPA standard) mappings. Printable characters are left
@@ -274,41 +269,55 @@ v_key_name(sp, ach)
* told that this is a reasonable assumption...
*
* XXX
- * This code will only work with CHAR_T's that are multiples of 8-bit
- * bytes.
- *
- * XXX
- * NB: There's an assumption here that all printable characters take
- * up a single column on the screen. This is not always correct.
+ * The code prints non-printable wide characters in 4 or 5 digits
+ * Unicode escape sequences, so only supports plane 0 to 15.
*/
- if (isprint(ch)) {
-pr: sp->cname[0] = ch;
- len = 1;
+ if (ISPRINT(ach))
goto done;
- }
nopr: if (iscntrl(ch) && (ch < 0x20 || ch == 0x7f)) {
sp->cname[0] = '^';
sp->cname[1] = ch == 0x7f ? '?' : '@' + ch;
len = 2;
- } else if (O_ISSET(sp, O_OCTAL)) {
-#define BITS (sizeof(CHAR_T) * 8)
-#define SHIFT (BITS - BITS % 3)
-#define TOPMASK (BITS % 3 == 2 ? 3 : 1) << (BITS - BITS % 3)
+ goto done;
+ }
+#ifdef USE_WIDECHAR
+ if (INTISWIDE(ach)) {
+ int uc = -1;
+
+ if (!strcmp(codeset(), "UTF-8"))
+ uc = decode_utf8(sp->cname);
+#ifdef USE_ICONV
+ else {
+ char buf[sizeof(sp->cname)] = "";
+ size_t left = sizeof(sp->cname);
+ char *in = sp->cname;
+ char *out = buf;
+ iconv(sp->conv.id[IC_IE_TO_UTF16],
+ (iconv_src_t)&in, &len, &out, &left);
+ iconv(sp->conv.id[IC_IE_TO_UTF16],
+ NULL, NULL, NULL, NULL);
+ uc = decode_utf16(buf, 1);
+ }
+#endif
+ if (uc >= 0) {
+ len = snprintf(sp->cname, sizeof(sp->cname),
+ uc < 0x10000 ? "\\u%04x" : "\\U%05X", uc);
+ goto done;
+ }
+ }
+#endif
+ if (O_ISSET(sp, O_OCTAL)) {
sp->cname[0] = '\\';
- sp->cname[1] = octdigit[(ch & TOPMASK) >> SHIFT];
- shift = SHIFT - 3;
- for (len = 2, mask = 7 << (SHIFT - 3),
- cnt = BITS / 3; cnt-- > 0; mask >>= 3, shift -= 3)
- sp->cname[len++] = octdigit[(ch & mask) >> shift];
+ sp->cname[1] = octdigit[(ch & 0300) >> 6];
+ sp->cname[2] = octdigit[(ch & 070) >> 3];
+ sp->cname[3] = octdigit[ ch & 07 ];
} else {
sp->cname[0] = '\\';
sp->cname[1] = 'x';
- for (len = 2, chp = (u_int8_t *)&ch,
- cnt = sizeof(CHAR_T); cnt-- > 0; ++chp) {
- sp->cname[len++] = hexdigit[(*chp & 0xf0) >> 4];
- sp->cname[len++] = hexdigit[*chp & 0x0f];
- }
+ sp->cname[2] = hexdigit[(ch & 0xf0) >> 4];
+ sp->cname[3] = hexdigit[ ch & 0x0f ];
}
+ len = 4;
done: sp->cname[sp->clen = len] = '\0';
return (sp->cname);
}
@@ -318,12 +327,12 @@ done: sp->cname[sp->clen = len] = '\0';
* Fill in the value for a key. This routine is the backup
* for the KEY_VAL() macro.
*
- * PUBLIC: int v_key_val __P((SCR *, ARG_CHAR_T));
+ * PUBLIC: e_key_t v_key_val __P((SCR *, ARG_CHAR_T));
*/
-int
-v_key_val(sp, ch)
- SCR *sp;
- ARG_CHAR_T ch;
+e_key_t
+v_key_val(
+ SCR *sp,
+ ARG_CHAR_T ch)
{
KEYLIST k, *kp;
@@ -345,12 +354,12 @@ v_key_val(sp, ch)
* PUBLIC: int v_event_push __P((SCR *, EVENT *, CHAR_T *, size_t, u_int));
*/
int
-v_event_push(sp, p_evp, p_s, nitems, flags)
- SCR *sp;
- EVENT *p_evp; /* Push event. */
- CHAR_T *p_s; /* Push characters. */
- size_t nitems; /* Number of items to push. */
- u_int flags; /* CH_* flags. */
+v_event_push(
+ SCR *sp,
+ EVENT *p_evp, /* Push event. */
+ CHAR_T *p_s, /* Push characters. */
+ size_t nitems, /* Number of items to push. */
+ u_int flags) /* CH_* flags. */
{
EVENT *evp;
GS *gp;
@@ -375,8 +384,8 @@ v_event_push(sp, p_evp, p_s, nitems, flags)
if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64)))
return (1);
if (gp->i_cnt)
- MEMMOVE(gp->i_event + TERM_PUSH_SHIFT + nitems,
- gp->i_event + gp->i_next, gp->i_cnt);
+ BCOPY(gp->i_event + gp->i_next,
+ gp->i_event + TERM_PUSH_SHIFT + nitems, gp->i_cnt);
gp->i_next = TERM_PUSH_SHIFT;
/* Put the new items into the queue. */
@@ -399,9 +408,9 @@ copy: gp->i_cnt += nitems;
* Append events onto the tail of the buffer.
*/
static int
-v_event_append(sp, argp)
- SCR *sp;
- EVENT *argp;
+v_event_append(
+ SCR *sp,
+ EVENT *argp)
{
CHAR_T *s; /* Characters. */
EVENT *evp;
@@ -526,11 +535,11 @@ v_event_append(sp, argp)
* PUBLIC: int v_event_get __P((SCR *, EVENT *, int, u_int32_t));
*/
int
-v_event_get(sp, argp, timeout, flags)
- SCR *sp;
- EVENT *argp;
- int timeout;
- u_int32_t flags;
+v_event_get(
+ SCR *sp,
+ EVENT *argp,
+ int timeout,
+ u_int32_t flags)
{
EVENT *evp, ev;
GS *gp;
@@ -630,7 +639,8 @@ newmap: evp = &gp->i_event[gp->i_next];
*/
if (istimeout || F_ISSET(&evp->e_ch, CH_NOMAP) ||
!LF_ISSET(EC_MAPCOMMAND | EC_MAPINPUT) ||
- evp->e_c < MAX_BIT_SEQ && !bit_test(gp->seqb, evp->e_c))
+ ((evp->e_c & ~MAX_BIT_SEQ) == 0 &&
+ !bit_test(gp->seqb, evp->e_c)))
goto nomap;
/* Search the map. */
@@ -664,7 +674,7 @@ newmap: evp = &gp->i_event[gp->i_next];
/* If no map, return the character. */
if (qp == NULL) {
-nomap: if (!isdigit(evp->e_c) && LF_ISSET(EC_MAPNODIGIT))
+nomap: if (!ISDIGIT(evp->e_c) && LF_ISSET(EC_MAPNODIGIT))
goto not_digit;
*argp = *evp;
QREM(1);
@@ -676,7 +686,7 @@ nomap: if (!isdigit(evp->e_c) && LF_ISSET(EC_MAPNODIGIT))
* of the map is it, pretend we haven't seen the character.
*/
if (LF_ISSET(EC_MAPNODIGIT) &&
- qp->output != NULL && !isdigit(qp->output[0])) {
+ qp->output != NULL && !ISDIGIT(qp->output[0])) {
not_digit: argp->e_c = CH_NOT_DIGIT;
argp->e_value = K_NOTUSED;
argp->e_event = E_CHARACTER;
@@ -744,16 +754,16 @@ not_digit: argp->e_c = CH_NOT_DIGIT;
* Walk the screen lists, sync'ing files to their backup copies.
*/
static void
-v_sync(sp, flags)
- SCR *sp;
- int flags;
+v_sync(
+ SCR *sp,
+ int flags)
{
GS *gp;
gp = sp->gp;
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ TAILQ_FOREACH(sp, gp->dq, q)
rcv_sync(sp, flags);
- for (sp = gp->hq.cqh_first; sp != (void *)&gp->hq; sp = sp->q.cqe_next)
+ TAILQ_FOREACH(sp, gp->hq, q)
rcv_sync(sp, flags);
}
@@ -764,9 +774,9 @@ v_sync(sp, flags)
* PUBLIC: void v_event_err __P((SCR *, EVENT *));
*/
void
-v_event_err(sp, evp)
- SCR *sp;
- EVENT *evp;
+v_event_err(
+ SCR *sp,
+ EVENT *evp)
{
switch (evp->e_event) {
case E_CHARACTER:
@@ -778,9 +788,6 @@ v_event_err(sp, evp)
case E_INTERRUPT:
msgq(sp, M_ERR, "279|Unexpected interrupt event");
break;
- case E_QUIT:
- msgq(sp, M_ERR, "280|Unexpected quit event");
- break;
case E_REPAINT:
msgq(sp, M_ERR, "281|Unexpected repaint event");
break;
@@ -793,9 +800,6 @@ v_event_err(sp, evp)
case E_WRESIZE:
msgq(sp, M_ERR, "316|Unexpected resize event");
break;
- case E_WRITE:
- msgq(sp, M_ERR, "287|Unexpected write event");
- break;
/*
* Theoretically, none of these can occur, as they're handled at the
@@ -820,9 +824,9 @@ v_event_err(sp, evp)
* PUBLIC: int v_event_flush __P((SCR *, u_int));
*/
int
-v_event_flush(sp, flags)
- SCR *sp;
- u_int flags;
+v_event_flush(
+ SCR *sp,
+ u_int flags)
{
GS *gp;
int rval;
@@ -838,9 +842,9 @@ v_event_flush(sp, flags)
* Grow the terminal queue.
*/
static int
-v_event_grow(sp, add)
- SCR *sp;
- int add;
+v_event_grow(
+ SCR *sp,
+ int add)
{
GS *gp;
size_t new_nelem, olen;
@@ -848,7 +852,7 @@ v_event_grow(sp, add)
gp = sp->gp;
new_nelem = gp->i_nelem + add;
olen = gp->i_nelem * sizeof(gp->i_event[0]);
- BINC_RET(sp, gp->i_event, olen, new_nelem * sizeof(gp->i_event[0]));
+ BINC_RET(sp, EVENT, gp->i_event, olen, new_nelem * sizeof(gp->i_event[0]));
gp->i_nelem = olen / sizeof(gp->i_event[0]);
return (0);
}
@@ -858,8 +862,9 @@ v_event_grow(sp, add)
* Compare two keys for sorting.
*/
static int
-v_key_cmp(ap, bp)
- const void *ap, *bp;
+v_key_cmp(
+ const void *ap,
+ const void *bp)
{
return (((KEYLIST *)ap)->ch - ((KEYLIST *)bp)->ch);
}
diff --git a/common/key.h b/common/key.h
index 76fb64f8e1ec..3eeca124a00a 100644
--- a/common/key.h
+++ b/common/key.h
@@ -6,27 +6,47 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)key.h 10.18 (Berkeley) 6/30/96
+ * $Id: key.h,v 10.55 2012/10/07 01:31:17 zy Exp $
*/
-/*
- * Fundamental character types.
- *
- * CHAR_T An integral type that can hold any character.
- * ARG_CHAR_T The type of a CHAR_T when passed as an argument using
- * traditional promotion rules. It should also be able
- * to be compared against any CHAR_T for equality without
- * problems.
- * MAX_CHAR_T The maximum value of any character.
- *
- * If no integral type can hold a character, don't even try the port.
- */
-typedef u_char CHAR_T;
-typedef u_int ARG_CHAR_T;
-#define MAX_CHAR_T 0xff
+#include "multibyte.h"
+
+#ifdef USE_WIDECHAR
+#define FILE2INT5(sp,buf,n,nlen,w,wlen) \
+ sp->conv.file2int(sp, n, nlen, &buf, &wlen, &w)
+#define INT2FILE(sp,w,wlen,n,nlen) \
+ sp->conv.int2file(sp, w, wlen, &sp->cw, &nlen, &n)
+#define CHAR2INT5(sp,buf,n,nlen,w,wlen) \
+ sp->conv.sys2int(sp, n, nlen, &buf, &wlen, &w)
+#define INT2CHAR(sp,w,wlen,n,nlen) \
+ sp->conv.int2sys(sp, w, wlen, &sp->cw, &nlen, &n)
+#define INPUT2INT5(sp,cw,n,nlen,w,wlen) \
+ sp->conv.input2int(sp, n, nlen, &(cw), &wlen, &w)
+#define CONST
+#define CHAR_WIDTH(sp, ch) wcwidth(ch)
+#define INTISWIDE(c) (wctob(c) == EOF)
+#else
+#define FILE2INT5(sp,buf,n,nlen,w,wlen) \
+ (w = n, wlen = nlen, 0)
+#define INT2FILE(sp,w,wlen,n,nlen) \
+ (n = w, nlen = wlen, 0)
+#define CHAR2INT5(sp,buf,n,nlen,w,wlen) \
+ (w = n, wlen = nlen, 0)
+#define INT2CHAR(sp,w,wlen,n,nlen) \
+ (n = w, nlen = wlen, 0)
+#define INPUT2INT5(sp,buf,n,nlen,w,wlen) \
+ (w = n, wlen = nlen, 0)
+#define CONST const
+#define INTISWIDE(c) 0
+#define CHAR_WIDTH(sp, ch) 1
+#endif
+#define FILE2INT(sp,n,nlen,w,wlen) \
+ FILE2INT5(sp,sp->cw,n,nlen,w,wlen)
+#define CHAR2INT(sp,n,nlen,w,wlen) \
+ CHAR2INT5(sp,sp->cw,n,nlen,w,wlen)
/* The maximum number of columns any character can take up on a screen. */
-#define MAX_CHARACTER_COLUMNS 4
+#define MAX_CHARACTER_COLUMNS 7
/*
* Event types.
@@ -42,14 +62,12 @@ typedef enum {
E_EOF, /* End of input (NOT ^D). */
E_ERR, /* Input error. */
E_INTERRUPT, /* Interrupt. */
- E_QUIT, /* Quit. */
E_REPAINT, /* Repaint: e_flno, e_tlno set. */
E_SIGHUP, /* SIGHUP. */
E_SIGTERM, /* SIGTERM. */
E_STRING, /* Input string: e_csp, e_len set. */
E_TIMEOUT, /* Timeout. */
E_WRESIZE, /* Window resize. */
- E_WRITE /* Write. */
} e_event_t;
/*
@@ -124,7 +142,7 @@ struct _event {
typedef struct _keylist {
e_key_t value; /* Special value. */
- CHAR_T ch; /* Key. */
+ int ch; /* Key. */
} KEYLIST;
extern KEYLIST keylist[];
@@ -137,15 +155,13 @@ extern KEYLIST keylist[];
/*
* Ex/vi commands are generally separated by whitespace characters. We
* can't use the standard isspace(3) macro because it returns true for
- * characters like ^K in the ASCII character set. The 4.4BSD isblank(3)
- * macro does exactly what we want, but it's not portable yet.
+ * characters like ^K in the ASCII character set. The POSIX isblank(3)
+ * has the same problem for non-ASCII locale, so we need a standalone one.
*
* XXX
* Note side effect, ch is evaluated multiple times.
*/
-#ifndef isblank
-#define isblank(ch) ((ch) == ' ' || (ch) == '\t')
-#endif
+#define cmdskip(ch) ((ch) == ' ' || (ch) == '\t')
/* The "standard" tab width, for displaying things to users. */
#define STANDARD_TAB 6
diff --git a/common/line.c b/common/line.c
index bcb9e0c86bcb..0bceccfa5bcc 100644
--- a/common/line.c
+++ b/common/line.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)line.c 10.21 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: line.c,v 10.26 2011/08/12 12:36:41 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -32,15 +32,15 @@ static int scr_update __P((SCR *, recno_t, lnop_t, int));
* db_eget --
* Front-end to db_get, special case handling for empty files.
*
- * PUBLIC: int db_eget __P((SCR *, recno_t, char **, size_t *, int *));
+ * PUBLIC: int db_eget __P((SCR *, recno_t, CHAR_T **, size_t *, int *));
*/
int
-db_eget(sp, lno, pp, lenp, isemptyp)
- SCR *sp;
- recno_t lno; /* Line number. */
- char **pp; /* Pointer store. */
- size_t *lenp; /* Length store. */
- int *isemptyp;
+db_eget(
+ SCR *sp,
+ recno_t lno, /* Line number. */
+ CHAR_T **pp, /* Pointer store. */
+ size_t *lenp, /* Length store. */
+ int *isemptyp)
{
recno_t l1;
@@ -60,7 +60,7 @@ db_eget(sp, lno, pp, lenp, isemptyp)
return (1);
/* If the file isn't empty, fail loudly. */
- if (lno != 0 && lno != 1 || l1 != 0) {
+ if ((lno != 0 && lno != 1) || l1 != 0) {
db_err(sp, lno);
return (1);
}
@@ -76,20 +76,23 @@ db_eget(sp, lno, pp, lenp, isemptyp)
* Look in the text buffers for a line, followed by the cache, followed
* by the database.
*
- * PUBLIC: int db_get __P((SCR *, recno_t, u_int32_t, char **, size_t *));
+ * PUBLIC: int db_get __P((SCR *, recno_t, u_int32_t, CHAR_T **, size_t *));
*/
int
-db_get(sp, lno, flags, pp, lenp)
- SCR *sp;
- recno_t lno; /* Line number. */
- u_int32_t flags;
- char **pp; /* Pointer store. */
- size_t *lenp; /* Length store. */
+db_get(
+ SCR *sp,
+ recno_t lno, /* Line number. */
+ u_int32_t flags,
+ CHAR_T **pp, /* Pointer store. */
+ size_t *lenp) /* Length store. */
{
DBT data, key;
EXF *ep;
TEXT *tp;
recno_t l1, l2;
+ CHAR_T *wp;
+ size_t wlen;
+ size_t nlen;
/*
* The underlying recno stuff handles zero by returning NULL, but
@@ -113,14 +116,14 @@ db_get(sp, lno, flags, pp, lenp)
* is there.
*/
if (F_ISSET(sp, SC_TINPUT)) {
- l1 = ((TEXT *)sp->tiq.cqh_first)->lno;
- l2 = ((TEXT *)sp->tiq.cqh_last)->lno;
+ l1 = ((TEXT *)TAILQ_FIRST(sp->tiq))->lno;
+ l2 = ((TEXT *)TAILQ_LAST(sp->tiq, _texth))->lno;
if (l1 <= lno && l2 >= lno) {
#if defined(DEBUG) && 0
TRACE(sp, "retrieve TEXT buffer line %lu\n", (u_long)lno);
#endif
- for (tp = sp->tiq.cqh_first;
- tp->lno != lno; tp = tp->q.cqe_next);
+ for (tp = TAILQ_FIRST(sp->tiq);
+ tp->lno != lno; tp = TAILQ_NEXT(tp, q));
if (lenp != NULL)
*lenp = tp->len;
if (pp != NULL)
@@ -149,32 +152,52 @@ db_get(sp, lno, flags, pp, lenp)
ep->c_lno = OOBLNO;
nocache:
+ nlen = 1024;
+retry:
/* Get the line from the underlying database. */
key.data = &lno;
key.size = sizeof(lno);
switch (ep->db->get(ep->db, &key, &data, 0)) {
- case -1:
+ case -1:
goto err2;
case 1:
err1: if (LF_ISSET(DBG_FATAL))
err2: db_err(sp, lno);
+alloc_err:
err3: if (lenp != NULL)
*lenp = 0;
if (pp != NULL)
*pp = NULL;
return (1);
+ case 0:
+ if (data.size > nlen) {
+ nlen = data.size;
+ goto retry;
+ }
+ }
+
+ if (FILE2INT(sp, data.data, data.size, wp, wlen)) {
+ if (!F_ISSET(sp, SC_CONV_ERROR)) {
+ F_SET(sp, SC_CONV_ERROR);
+ msgq(sp, M_ERR, "324|Conversion error on line %d", lno);
+ }
+ goto err3;
}
/* Reset the cache. */
+ if (wp != data.data) {
+ BINC_GOTOW(sp, ep->c_lp, ep->c_blen, wlen);
+ MEMCPY(ep->c_lp, wp, wlen);
+ } else
+ ep->c_lp = data.data;
ep->c_lno = lno;
- ep->c_len = data.size;
- ep->c_lp = data.data;
+ ep->c_len = wlen;
#if defined(DEBUG) && 0
TRACE(sp, "retrieve DB line %lu\n", (u_long)lno);
#endif
if (lenp != NULL)
- *lenp = data.size;
+ *lenp = wlen;
if (pp != NULL)
*pp = ep->c_lp;
return (0);
@@ -187,9 +210,9 @@ err3: if (lenp != NULL)
* PUBLIC: int db_delete __P((SCR *, recno_t));
*/
int
-db_delete(sp, lno)
- SCR *sp;
- recno_t lno;
+db_delete(
+ SCR *sp,
+ recno_t lno)
{
DBT key;
EXF *ep;
@@ -242,18 +265,20 @@ db_delete(sp, lno)
* db_append --
* Append a line into the file.
*
- * PUBLIC: int db_append __P((SCR *, int, recno_t, char *, size_t));
+ * PUBLIC: int db_append __P((SCR *, int, recno_t, CHAR_T *, size_t));
*/
int
-db_append(sp, update, lno, p, len)
- SCR *sp;
- int update;
- recno_t lno;
- char *p;
- size_t len;
+db_append(
+ SCR *sp,
+ int update,
+ recno_t lno,
+ CHAR_T *p,
+ size_t len)
{
DBT data, key;
EXF *ep;
+ char *fp;
+ size_t flen;
int rval;
#if defined(DEBUG) && 0
@@ -265,11 +290,13 @@ db_append(sp, update, lno, p, len)
return (1);
}
+ INT2FILE(sp, p, len, fp, flen);
+
/* Update file. */
key.data = &lno;
key.size = sizeof(lno);
- data.data = p;
- data.size = len;
+ data.data = fp;
+ data.size = flen;
SIGBLOCK;
if (ep->db->put(ep->db, &key, &data, R_IAFTER) == -1) {
msgq(sp, M_SYSERR,
@@ -316,17 +343,19 @@ db_append(sp, update, lno, p, len)
* db_insert --
* Insert a line into the file.
*
- * PUBLIC: int db_insert __P((SCR *, recno_t, char *, size_t));
+ * PUBLIC: int db_insert __P((SCR *, recno_t, CHAR_T *, size_t));
*/
int
-db_insert(sp, lno, p, len)
- SCR *sp;
- recno_t lno;
- char *p;
- size_t len;
+db_insert(
+ SCR *sp,
+ recno_t lno,
+ CHAR_T *p,
+ size_t len)
{
DBT data, key;
EXF *ep;
+ char *fp;
+ size_t flen;
int rval;
#if defined(DEBUG) && 0
@@ -339,11 +368,13 @@ db_insert(sp, lno, p, len)
return (1);
}
+ INT2FILE(sp, p, len, fp, flen);
+
/* Update file. */
key.data = &lno;
key.size = sizeof(lno);
- data.data = p;
- data.size = len;
+ data.data = fp;
+ data.size = flen;
SIGBLOCK;
if (ep->db->put(ep->db, &key, &data, R_IBEFORE) == -1) {
msgq(sp, M_SYSERR,
@@ -381,23 +412,24 @@ db_insert(sp, lno, p, len)
* db_set --
* Store a line in the file.
*
- * PUBLIC: int db_set __P((SCR *, recno_t, char *, size_t));
+ * PUBLIC: int db_set __P((SCR *, recno_t, CHAR_T *, size_t));
*/
int
-db_set(sp, lno, p, len)
- SCR *sp;
- recno_t lno;
- char *p;
- size_t len;
+db_set(
+ SCR *sp,
+ recno_t lno,
+ CHAR_T *p,
+ size_t len)
{
DBT data, key;
EXF *ep;
+ char *fp;
+ size_t flen;
#if defined(DEBUG) && 0
TRACE(sp, "replace line %lu: len %lu {%.*s}\n",
(u_long)lno, (u_long)len, MIN(len, 20), p);
#endif
-
/* Check for no underlying file. */
if ((ep = sp->ep) == NULL) {
ex_emsg(sp, NULL, EXM_NOFILEYET);
@@ -407,11 +439,13 @@ db_set(sp, lno, p, len)
/* Log before change. */
log_line(sp, lno, LOG_LINE_RESET_B);
+ INT2FILE(sp, p, len, fp, flen);
+
/* Update file. */
key.data = &lno;
key.size = sizeof(lno);
- data.data = p;
- data.size = len;
+ data.data = fp;
+ data.size = flen;
SIGBLOCK;
if (ep->db->put(ep->db, &key, &data, 0) == -1) {
msgq(sp, M_SYSERR,
@@ -443,9 +477,9 @@ db_set(sp, lno, p, len)
* PUBLIC: int db_exist __P((SCR *, recno_t));
*/
int
-db_exist(sp, lno)
- SCR *sp;
- recno_t lno;
+db_exist(
+ SCR *sp,
+ recno_t lno)
{
EXF *ep;
@@ -464,8 +498,8 @@ db_exist(sp, lno)
*/
if (ep->c_nlines != OOBLNO)
return (lno <= (F_ISSET(sp, SC_TINPUT) ?
- ep->c_nlines + (((TEXT *)sp->tiq.cqh_last)->lno -
- ((TEXT *)sp->tiq.cqh_first)->lno) : ep->c_nlines));
+ ep->c_nlines + (((TEXT *)TAILQ_LAST(sp->tiq, _texth))->lno -
+ ((TEXT *)TAILQ_FIRST(sp->tiq))->lno) : ep->c_nlines));
/* Go get the line. */
return (!db_get(sp, lno, 0, NULL, NULL));
@@ -478,13 +512,15 @@ db_exist(sp, lno)
* PUBLIC: int db_last __P((SCR *, recno_t *));
*/
int
-db_last(sp, lnop)
- SCR *sp;
- recno_t *lnop;
+db_last(
+ SCR *sp,
+ recno_t *lnop)
{
DBT data, key;
EXF *ep;
recno_t lno;
+ CHAR_T *wp;
+ size_t wlen;
/* Check for no underlying file. */
if ((ep = sp->ep) == NULL) {
@@ -499,8 +535,8 @@ db_last(sp, lnop)
if (ep->c_nlines != OOBLNO) {
*lnop = ep->c_nlines;
if (F_ISSET(sp, SC_TINPUT))
- *lnop += ((TEXT *)sp->tiq.cqh_last)->lno -
- ((TEXT *)sp->tiq.cqh_first)->lno;
+ *lnop += ((TEXT *)TAILQ_LAST(sp->tiq, _texth))->lno -
+ ((TEXT *)TAILQ_FIRST(sp->tiq))->lno;
return (0);
}
@@ -508,27 +544,104 @@ db_last(sp, lnop)
key.size = sizeof(lno);
switch (ep->db->seq(ep->db, &key, &data, R_LAST)) {
- case -1:
+ case -1:
+alloc_err:
msgq(sp, M_SYSERR, "007|unable to get last line");
*lnop = 0;
return (1);
- case 1:
+ case 1:
*lnop = 0;
return (0);
- default:
- break;
+ case 0:
+ ;
}
- /* Fill the cache. */
memcpy(&lno, key.data, sizeof(lno));
- ep->c_nlines = ep->c_lno = lno;
- ep->c_len = data.size;
- ep->c_lp = data.data;
+
+ if (lno != ep->c_lno) {
+ FILE2INT(sp, data.data, data.size, wp, wlen);
+
+ /* Fill the cache. */
+ if (wp != data.data) {
+ BINC_GOTOW(sp, ep->c_lp, ep->c_blen, wlen);
+ MEMCPY(ep->c_lp, wp, wlen);
+ } else
+ ep->c_lp = data.data;
+ ep->c_lno = lno;
+ ep->c_len = wlen;
+ }
+ ep->c_nlines = lno;
/* Return the value. */
*lnop = (F_ISSET(sp, SC_TINPUT) &&
- ((TEXT *)sp->tiq.cqh_last)->lno > lno ?
- ((TEXT *)sp->tiq.cqh_last)->lno : lno);
+ ((TEXT *)TAILQ_LAST(sp->tiq, _texth))->lno > lno ?
+ ((TEXT *)TAILQ_LAST(sp->tiq, _texth))->lno : lno);
+ return (0);
+}
+
+/*
+ * db_rget --
+ * Retrieve a raw line from database. No cache, no conversion.
+ *
+ * PUBLIC: int db_rget __P((SCR *, recno_t, char **, size_t *));
+ */
+int
+db_rget(
+ SCR *sp,
+ recno_t lno, /* Line number. */
+ char **pp, /* Pointer store. */
+ size_t *lenp) /* Length store. */
+{
+ DBT data, key;
+ EXF *ep;
+
+ /* Check for no underlying file. */
+ if ((ep = sp->ep) == NULL)
+ return (1);
+
+ /* Get the line from the underlying database. */
+ key.data = &lno;
+ key.size = sizeof(lno);
+ if (ep->db->get(ep->db, &key, &data, 0))
+ /* We do not report error, and do not ensure the size! */
+ return (1);
+
+ if (lenp != NULL)
+ *lenp = data.size;
+ if (pp != NULL)
+ *pp = data.data;
+ return (0);
+}
+
+/*
+ * db_rset --
+ * Store a line in the file. No log, no conversion.
+ *
+ * PUBLIC: int db_rset __P((SCR *, recno_t, char *, size_t));
+ */
+int
+db_rset(
+ SCR *sp,
+ recno_t lno,
+ char *p,
+ size_t len)
+{
+ DBT data, key;
+ EXF *ep;
+
+ /* Check for no underlying file. */
+ if ((ep = sp->ep) == NULL)
+ return (1);
+
+ /* Update file. */
+ key.data = &lno;
+ key.size = sizeof(lno);
+ data.data = p;
+ data.size = len;
+ if (ep->db->put(ep->db, &key, &data, 0) == -1)
+ /* We do not report error, and do not ensure the size! */
+ return (1);
+
return (0);
}
@@ -539,9 +652,9 @@ db_last(sp, lnop)
* PUBLIC: void db_err __P((SCR *, recno_t));
*/
void
-db_err(sp, lno)
- SCR *sp;
- recno_t lno;
+db_err(
+ SCR *sp,
+ recno_t lno)
{
msgq(sp, M_ERR,
"008|Error: unable to retrieve line %lu", (u_long)lno);
@@ -553,11 +666,11 @@ db_err(sp, lno)
* just changed.
*/
static int
-scr_update(sp, lno, op, current)
- SCR *sp;
- recno_t lno;
- lnop_t op;
- int current;
+scr_update(
+ SCR *sp,
+ recno_t lno,
+ lnop_t op,
+ int current)
{
EXF *ep;
SCR *tsp;
@@ -567,8 +680,7 @@ scr_update(sp, lno, op, current)
ep = sp->ep;
if (ep->refcnt != 1)
- for (tsp = sp->gp->dq.cqh_first;
- tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
+ TAILQ_FOREACH(tsp, sp->gp->dq, q)
if (sp != tsp && tsp->ep == ep)
if (vs_change(tsp, lno, op))
return (1);
diff --git a/common/log.c b/common/log.c
index 9a9fe793ffb8..eb8d85bc84cf 100644
--- a/common/log.c
+++ b/common/log.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)log.c 10.8 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: log.c,v 10.27 2011/07/13 06:25:50 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -21,6 +21,7 @@ static const char sccsid[] = "@(#)log.c 10.8 (Berkeley) 3/6/96";
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -67,6 +68,8 @@ static void log_err __P((SCR *, char *, int));
#if defined(DEBUG) && 0
static void log_trace __P((SCR *, char *, recno_t, u_char *));
#endif
+static int apply_with __P((int (*)(SCR *, recno_t, CHAR_T *, size_t),
+ SCR *, recno_t, u_char *, size_t));
/* Try and restart the log on failure, i.e. if we run out of memory. */
#define LOG_ERR { \
@@ -74,6 +77,15 @@ static void log_trace __P((SCR *, char *, recno_t, u_char *));
return (1); \
}
+/* offset of CHAR_T string in log needs to be aligned on some systems
+ * because it is passed to db_set as a string
+ */
+typedef struct {
+ char data[sizeof(u_char) /* type */ + sizeof(recno_t)];
+ CHAR_T str[1];
+} log_t;
+#define CHAR_T_OFFSET ((char *)(((log_t*)0)->str) - (char *)0)
+
/*
* log_init --
* Initialize the logging subsystem.
@@ -81,9 +93,9 @@ static void log_trace __P((SCR *, char *, recno_t, u_char *));
* PUBLIC: int log_init __P((SCR *, EXF *));
*/
int
-log_init(sp, ep)
- SCR *sp;
- EXF *ep;
+log_init(
+ SCR *sp,
+ EXF *ep)
{
/*
* !!!
@@ -117,9 +129,9 @@ log_init(sp, ep)
* PUBLIC: int log_end __P((SCR *, EXF *));
*/
int
-log_end(sp, ep)
- SCR *sp;
- EXF *ep;
+log_end(
+ SCR *sp,
+ EXF *ep)
{
/*
* !!!
@@ -147,8 +159,7 @@ log_end(sp, ep)
* PUBLIC: int log_cursor __P((SCR *));
*/
int
-log_cursor(sp)
- SCR *sp;
+log_cursor(SCR *sp)
{
EXF *ep;
@@ -175,15 +186,16 @@ log_cursor(sp)
* Actually push a cursor record out.
*/
static int
-log_cursor1(sp, type)
- SCR *sp;
- int type;
+log_cursor1(
+ SCR *sp,
+ int type)
{
DBT data, key;
EXF *ep;
ep = sp->ep;
- BINC_RET(sp, ep->l_lp, ep->l_len, sizeof(u_char) + sizeof(MARK));
+
+ BINC_RETC(sp, ep->l_lp, ep->l_len, sizeof(u_char) + sizeof(MARK));
ep->l_lp[0] = type;
memmove(ep->l_lp + sizeof(u_char), &ep->l_cursor, sizeof(MARK));
@@ -212,15 +224,16 @@ log_cursor1(sp, type)
* PUBLIC: int log_line __P((SCR *, recno_t, u_int));
*/
int
-log_line(sp, lno, action)
- SCR *sp;
- recno_t lno;
- u_int action;
+log_line(
+ SCR *sp,
+ recno_t lno,
+ u_int action)
{
DBT data, key;
EXF *ep;
size_t len;
- char *lp;
+ CHAR_T *lp;
+ recno_t lcur;
ep = sp->ep;
if (F_ISSET(ep, F_NOLOG))
@@ -254,28 +267,30 @@ log_line(sp, lno, action)
return (1);
}
len = 0;
- lp = "";
+ lp = L("");
}
} else
if (db_get(sp, lno, DBG_FATAL, &lp, &len))
return (1);
- BINC_RET(sp,
- ep->l_lp, ep->l_len, len + sizeof(u_char) + sizeof(recno_t));
+ BINC_RETC(sp,
+ ep->l_lp, ep->l_len,
+ len * sizeof(CHAR_T) + CHAR_T_OFFSET);
ep->l_lp[0] = action;
memmove(ep->l_lp + sizeof(u_char), &lno, sizeof(recno_t));
- memmove(ep->l_lp + sizeof(u_char) + sizeof(recno_t), lp, len);
+ memmove(ep->l_lp + CHAR_T_OFFSET, lp, len * sizeof(CHAR_T));
- key.data = &ep->l_cur;
+ lcur = ep->l_cur;
+ key.data = &lcur;
key.size = sizeof(recno_t);
data.data = ep->l_lp;
- data.size = len + sizeof(u_char) + sizeof(recno_t);
+ data.size = len * sizeof(CHAR_T) + CHAR_T_OFFSET;
if (ep->log->put(ep->log, &key, &data, 0) == -1)
LOG_ERR;
#if defined(DEBUG) && 0
switch (action) {
case LOG_LINE_APPEND:
- TRACE(sp, "%u: log_line: append: %lu {%u}\n",
+ TRACE(sp, "%lu: log_line: append: %lu {%u}\n",
ep->l_cur, lno, len);
break;
case LOG_LINE_DELETE:
@@ -312,9 +327,9 @@ log_line(sp, lno, action)
* PUBLIC: int log_mark __P((SCR *, LMARK *));
*/
int
-log_mark(sp, lmp)
- SCR *sp;
- LMARK *lmp;
+log_mark(
+ SCR *sp,
+ LMARK *lmp)
{
DBT data, key;
EXF *ep;
@@ -330,7 +345,7 @@ log_mark(sp, lmp)
ep->l_cursor.lno = OOBLNO;
}
- BINC_RET(sp, ep->l_lp,
+ BINC_RETC(sp, ep->l_lp,
ep->l_len, sizeof(u_char) + sizeof(LMARK));
ep->l_lp[0] = LOG_MARK;
memmove(ep->l_lp + sizeof(u_char), lmp, sizeof(LMARK));
@@ -358,9 +373,9 @@ log_mark(sp, lmp)
* PUBLIC: int log_backward __P((SCR *, MARK *));
*/
int
-log_backward(sp, rp)
- SCR *sp;
- MARK *rp;
+log_backward(
+ SCR *sp,
+ MARK *rp)
{
DBT key, data;
EXF *ep;
@@ -414,9 +429,8 @@ log_backward(sp, rp)
case LOG_LINE_DELETE:
didop = 1;
memmove(&lno, p + sizeof(u_char), sizeof(recno_t));
- if (db_insert(sp, lno, p + sizeof(u_char) +
- sizeof(recno_t), data.size - sizeof(u_char) -
- sizeof(recno_t)))
+ if (apply_with(db_insert, sp, lno,
+ p + CHAR_T_OFFSET, data.size - CHAR_T_OFFSET))
goto err;
++sp->rptlines[L_ADDED];
break;
@@ -425,9 +439,8 @@ log_backward(sp, rp)
case LOG_LINE_RESET_B:
didop = 1;
memmove(&lno, p + sizeof(u_char), sizeof(recno_t));
- if (db_set(sp, lno, p + sizeof(u_char) +
- sizeof(recno_t), data.size - sizeof(u_char) -
- sizeof(recno_t)))
+ if (apply_with(db_set, sp, lno,
+ p + CHAR_T_OFFSET, data.size - CHAR_T_OFFSET))
goto err;
if (sp->rptlchange != lno) {
sp->rptlchange = lno;
@@ -464,8 +477,7 @@ err: F_CLR(ep, F_NOLOG);
* PUBLIC: int log_setline __P((SCR *));
*/
int
-log_setline(sp)
- SCR *sp;
+log_setline(SCR *sp)
{
DBT key, data;
EXF *ep;
@@ -488,7 +500,6 @@ log_setline(sp)
key.data = &ep->l_cur; /* Initialize db request. */
key.size = sizeof(recno_t);
-
for (;;) {
--ep->l_cur;
if (ep->log->get(ep->log, &key, &data, 0))
@@ -520,9 +531,8 @@ log_setline(sp)
case LOG_LINE_RESET_B:
memmove(&lno, p + sizeof(u_char), sizeof(recno_t));
if (lno == sp->lno &&
- db_set(sp, lno, p + sizeof(u_char) +
- sizeof(recno_t), data.size - sizeof(u_char) -
- sizeof(recno_t)))
+ apply_with(db_set, sp, lno,
+ p + CHAR_T_OFFSET, data.size - CHAR_T_OFFSET))
goto err;
if (sp->rptlchange != lno) {
sp->rptlchange = lno;
@@ -551,9 +561,9 @@ err: F_CLR(ep, F_NOLOG);
* PUBLIC: int log_forward __P((SCR *, MARK *));
*/
int
-log_forward(sp, rp)
- SCR *sp;
- MARK *rp;
+log_forward(
+ SCR *sp,
+ MARK *rp)
{
DBT key, data;
EXF *ep;
@@ -601,9 +611,8 @@ log_forward(sp, rp)
case LOG_LINE_INSERT:
didop = 1;
memmove(&lno, p + sizeof(u_char), sizeof(recno_t));
- if (db_insert(sp, lno, p + sizeof(u_char) +
- sizeof(recno_t), data.size - sizeof(u_char) -
- sizeof(recno_t)))
+ if (apply_with(db_insert, sp, lno,
+ p + CHAR_T_OFFSET, data.size - CHAR_T_OFFSET))
goto err;
++sp->rptlines[L_ADDED];
break;
@@ -619,9 +628,8 @@ log_forward(sp, rp)
case LOG_LINE_RESET_F:
didop = 1;
memmove(&lno, p + sizeof(u_char), sizeof(recno_t));
- if (db_set(sp, lno, p + sizeof(u_char) +
- sizeof(recno_t), data.size - sizeof(u_char) -
- sizeof(recno_t)))
+ if (apply_with(db_set, sp, lno,
+ p + CHAR_T_OFFSET, data.size - CHAR_T_OFFSET))
goto err;
if (sp->rptlchange != lno) {
sp->rptlchange = lno;
@@ -650,10 +658,10 @@ err: F_CLR(ep, F_NOLOG);
* Try and restart the log on failure, i.e. if we run out of memory.
*/
static void
-log_err(sp, file, line)
- SCR *sp;
- char *file;
- int line;
+log_err(
+ SCR *sp,
+ char *file,
+ int line)
{
EXF *ep;
@@ -666,11 +674,11 @@ log_err(sp, file, line)
#if defined(DEBUG) && 0
static void
-log_trace(sp, msg, rno, p)
- SCR *sp;
- char *msg;
- recno_t rno;
- u_char *p;
+log_trace(
+ SCR *sp,
+ char *msg,
+ recno_t rno,
+ u_char *p)
{
LMARK lm;
MARK m;
@@ -715,3 +723,45 @@ log_trace(sp, msg, rno, p)
}
}
#endif
+
+/*
+ * apply_with --
+ * Apply a realigned line from the log db to the file db.
+ */
+static int
+apply_with(
+ int (*db_func)(SCR *, recno_t, CHAR_T *, size_t),
+ SCR *sp,
+ recno_t lno,
+ u_char *p,
+ size_t len)
+{
+#ifdef USE_WIDECHAR
+ typedef unsigned long nword;
+
+ static size_t blen;
+ static nword *bp;
+ nword *lp = (nword *)((uintptr_t)p / sizeof(nword) * sizeof(nword));
+
+ if (lp != (nword *)p) {
+ int offl = ((uintptr_t)p - (uintptr_t)lp) << 3;
+ int offr = (sizeof(nword) << 3) - offl;
+ size_t i, cnt = (len + sizeof(nword) / 2) / sizeof(nword);
+
+ if (len > blen) {
+ blen = p2roundup(MAX(len, 512));
+ REALLOC(sp, bp, nword *, blen);
+ if (bp == NULL)
+ return (1);
+ }
+ for (i = 0; i < cnt; ++i)
+#if BYTE_ORDER == BIG_ENDIAN
+ bp[i] = (lp[i] << offl) ^ (lp[i+1] >> offr);
+#else
+ bp[i] = (lp[i] >> offl) ^ (lp[i+1] << offr);
+#endif
+ p = (u_char *)bp;
+ }
+#endif
+ return db_func(sp, lno, (CHAR_T *)p, len / sizeof(CHAR_T));
+}
diff --git a/common/main.c b/common/main.c
index 6fb2ed1fe2f0..16b3fb19e22d 100644
--- a/common/main.c
+++ b/common/main.c
@@ -11,20 +11,19 @@
#ifndef lint
static const char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
+"%Z% Copyright (c) 1992, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n\
-@(#) Copyright (c) 1992, 1993, 1994, 1995, 1996\n\
+%Z% Copyright (c) 1992, 1993, 1994, 1995, 1996\n\
Keith Bostic. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static const char sccsid[] = "@(#)main.c 10.48 (Berkeley) 10/11/96";
+static const char sccsid[] = "$Id: main.c,v 11.0 2012/10/17 06:34:37 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
@@ -50,10 +49,10 @@ static int v_obsolete __P((char *, char *[]));
* PUBLIC: int editor __P((GS *, int, char *[]));
*/
int
-editor(gp, argc, argv)
- GS *gp;
- int argc;
- char *argv[];
+editor(
+ GS *gp,
+ int argc,
+ char *argv[])
{
extern int optind;
extern char *optarg;
@@ -65,6 +64,8 @@ editor(gp, argc, argv)
u_int flags;
int ch, flagchk, lflag, secure, startup, readonly, rval, silent;
char *tag_f, *wsizearg, path[256];
+ CHAR_T *w;
+ size_t wlen;
/* Initialize the busy routine, if not defined by the screen. */
if (gp->scr_busy == NULL)
@@ -72,19 +73,20 @@ editor(gp, argc, argv)
/* Initialize the message routine, if not defined by the screen. */
if (gp->scr_msg == NULL)
gp->scr_msg = vs_msg;
+ gp->catd = (nl_catd)-1;
/* Common global structure initialization. */
- CIRCLEQ_INIT(&gp->dq);
- CIRCLEQ_INIT(&gp->hq);
- LIST_INIT(&gp->ecq);
- LIST_INSERT_HEAD(&gp->ecq, &gp->excmd, q);
+ TAILQ_INIT(gp->dq);
+ TAILQ_INIT(gp->hq);
+ SLIST_INIT(gp->ecq);
+ SLIST_INSERT_HEAD(gp->ecq, &gp->excmd, q);
gp->noprint = DEFAULT_NOPRINT;
/* Structures shared by screens so stored in the GS structure. */
- CIRCLEQ_INIT(&gp->frefq);
- CIRCLEQ_INIT(&gp->dcb_store.textq);
- LIST_INIT(&gp->cutq);
- LIST_INIT(&gp->seqq);
+ TAILQ_INIT(gp->frefq);
+ TAILQ_INIT(gp->dcb_store.textq);
+ SLIST_INIT(gp->cutq);
+ SLIST_INIT(gp->seqq);
/* Set initial screen type and mode based on the program name. */
readonly = 0;
@@ -236,11 +238,11 @@ editor(gp, argc, argv)
*/
if (screen_init(gp, NULL, &sp)) {
if (sp != NULL)
- CIRCLEQ_INSERT_HEAD(&gp->dq, sp, q);
+ TAILQ_INSERT_HEAD(gp->dq, sp, q);
goto err;
}
F_SET(sp, SC_EX);
- CIRCLEQ_INSERT_HEAD(&gp->dq, sp, q);
+ TAILQ_INSERT_HEAD(gp->dq, sp, q);
if (v_key_init(sp)) /* Special key initialization. */
goto err;
@@ -331,8 +333,11 @@ editor(gp, argc, argv)
}
/* Open a tag file if specified. */
- if (tag_f != NULL && ex_tag_first(sp, tag_f))
- goto err;
+ if (tag_f != NULL) {
+ CHAR2INT(sp, tag_f, strlen(tag_f) + 1, w, wlen);
+ if (ex_tag_first(sp, w))
+ goto err;
+ }
/*
* Append any remaining arguments as file names. Files are recovery
@@ -342,13 +347,11 @@ editor(gp, argc, argv)
if (*argv != NULL) {
if (sp->frp != NULL) {
/* Cheat -- we know we have an extra argv slot. */
- MALLOC_NOMSG(sp,
- *--argv, char *, strlen(sp->frp->name) + 1);
+ *--argv = strdup(sp->frp->name);
if (*argv == NULL) {
v_estr(gp->progname, errno, NULL);
goto err;
}
- (void)strcpy(*argv, sp->frp->name);
}
sp->argv = sp->cargv = argv;
F_SET(sp, SC_ARGNOFREE);
@@ -366,7 +369,7 @@ editor(gp, argc, argv)
if ((frp = file_add(sp, NULL)) == NULL)
goto err;
} else {
- if ((frp = file_add(sp, (CHAR_T *)sp->argv[0])) == NULL)
+ if ((frp = file_add(sp, sp->argv[0])) == NULL)
goto err;
if (F_ISSET(sp, SC_ARGRECOVER))
F_SET(frp, FR_RECOVER);
@@ -400,8 +403,8 @@ editor(gp, argc, argv)
if (v_event_get(sp, &ev, 0, 0))
goto err;
if (ev.e_event == E_INTERRUPT ||
- ev.e_event == E_CHARACTER &&
- (ev.e_value == K_CR || ev.e_value == K_NL))
+ (ev.e_event == E_CHARACTER &&
+ (ev.e_value == K_CR || ev.e_value == K_NL)))
break;
(void)gp->scr_bell(sp);
}
@@ -447,20 +450,16 @@ v_end(gp)
(void)file_end(gp->ccl_sp, NULL, 1);
(void)screen_end(gp->ccl_sp);
}
- while ((sp = gp->dq.cqh_first) != (void *)&gp->dq)
+ while ((sp = TAILQ_FIRST(gp->dq)) != NULL)
(void)screen_end(sp);
- while ((sp = gp->hq.cqh_first) != (void *)&gp->hq)
+ while ((sp = TAILQ_FIRST(gp->hq)) != NULL)
(void)screen_end(sp);
-#ifdef HAVE_PERL_INTERP
- perl_end(gp);
-#endif
-
#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
{ FREF *frp;
/* Free FREF's. */
- while ((frp = gp->frefq.cqh_first) != (FREF *)&gp->frefq) {
- CIRCLEQ_REMOVE(&gp->frefq, frp, q);
+ while ((frp = TAILQ_FIRST(gp->frefq)) != NULL) {
+ TAILQ_REMOVE(gp->frefq, frp, q);
if (frp->name != NULL)
free(frp->name);
if (frp->tname != NULL)
@@ -480,7 +479,7 @@ v_end(gp)
seq_close(gp);
/* Free default buffer storage. */
- (void)text_lfree(&gp->dcb_store.textq);
+ (void)text_lfree(gp->dcb_store.textq);
/* Close message catalogs. */
msg_close(gp);
@@ -496,10 +495,10 @@ v_end(gp)
* it's possible that the user is sourcing a file that exits from the
* editor).
*/
- while ((mp = gp->msgq.lh_first) != NULL) {
+ while ((mp = SLIST_FIRST(gp->msgq)) != NULL) {
(void)fprintf(stderr, "%s%.*s",
mp->mtype == M_ERR ? "ex/vi: " : "", (int)mp->len, mp->buf);
- LIST_REMOVE(mp, q);
+ SLIST_REMOVE_HEAD(gp->msgq, q);
#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
free(mp->buf);
free(mp);
@@ -524,8 +523,9 @@ v_end(gp)
* Convert historic arguments into something getopt(3) will like.
*/
static int
-v_obsolete(name, argv)
- char *name, *argv[];
+v_obsolete(
+ char *name,
+ char *argv[])
{
size_t len;
char *p;
@@ -546,28 +546,26 @@ v_obsolete(name, argv)
while (*++argv && strcmp(argv[0], "--"))
if (argv[0][0] == '+') {
if (argv[0][1] == '\0') {
- MALLOC_NOMSG(NULL, argv[0], char *, 4);
+ argv[0] = strdup("-c$");
if (argv[0] == NULL)
goto nomem;
- (void)strcpy(argv[0], "-c$");
} else {
p = argv[0];
len = strlen(argv[0]);
- MALLOC_NOMSG(NULL, argv[0], char *, len + 2);
+ argv[0] = malloc(len + 2);
if (argv[0] == NULL)
goto nomem;
argv[0][0] = '-';
argv[0][1] = 'c';
- (void)strcpy(argv[0] + 2, p + 1);
+ (void)strlcpy(argv[0] + 2, p + 1, len);
}
} else if (argv[0][0] == '-')
if (argv[0][1] == '\0') {
- MALLOC_NOMSG(NULL, argv[0], char *, 3);
+ argv[0] = strdup("-s");
if (argv[0] == NULL) {
nomem: v_estr(name, errno, NULL);
return (1);
}
- (void)strcpy(argv[0], "-s");
} else
if ((argv[0][1] == 'c' || argv[0][1] == 'T' ||
argv[0][1] == 't' || argv[0][1] == 'w') &&
@@ -578,8 +576,7 @@ nomem: v_estr(name, errno, NULL);
#ifdef DEBUG
static void
-attach(gp)
- GS *gp;
+attach(GS *gp)
{
int fd;
char ch;
@@ -604,9 +601,10 @@ attach(gp)
#endif
static void
-v_estr(name, eno, msg)
- char *name, *msg;
- int eno;
+v_estr(
+ char *name,
+ int eno,
+ char *msg)
{
(void)fprintf(stderr, "%s", name);
if (msg != NULL)
diff --git a/common/mark.c b/common/mark.c
index 0ac1fc28bf9c..7a954392278c 100644
--- a/common/mark.c
+++ b/common/mark.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)mark.c 10.13 (Berkeley) 7/19/96";
+static const char sccsid[] = "$Id: mark.c,v 10.14 2011/07/04 14:42:58 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
@@ -28,7 +29,7 @@ static const char sccsid[] = "@(#)mark.c 10.13 (Berkeley) 7/19/96";
static LMARK *mark_find __P((SCR *, ARG_CHAR_T));
/*
- * Marks are maintained in a key sorted doubly linked list. We can't
+ * Marks are maintained in a key sorted singly linked list. We can't
* use arrays because we have no idea how big an index key could be.
* The underlying assumption is that users don't have more than, say,
* 10 marks at any one time, so this will be is fast enough.
@@ -65,9 +66,9 @@ static LMARK *mark_find __P((SCR *, ARG_CHAR_T));
* PUBLIC: int mark_init __P((SCR *, EXF *));
*/
int
-mark_init(sp, ep)
- SCR *sp;
- EXF *ep;
+mark_init(
+ SCR *sp,
+ EXF *ep)
{
/*
* !!!
@@ -75,7 +76,7 @@ mark_init(sp, ep)
*
* Set up the marks.
*/
- LIST_INIT(&ep->marks);
+ SLIST_INIT(ep->marks);
return (0);
}
@@ -86,9 +87,9 @@ mark_init(sp, ep)
* PUBLIC: int mark_end __P((SCR *, EXF *));
*/
int
-mark_end(sp, ep)
- SCR *sp;
- EXF *ep;
+mark_end(
+ SCR *sp,
+ EXF *ep)
{
LMARK *lmp;
@@ -96,8 +97,8 @@ mark_end(sp, ep)
* !!!
* ep MAY NOT BE THE SAME AS sp->ep, DON'T USE THE LATTER.
*/
- while ((lmp = ep->marks.lh_first) != NULL) {
- LIST_REMOVE(lmp, q);
+ while ((lmp = SLIST_FIRST(ep->marks)) != NULL) {
+ SLIST_REMOVE_HEAD(ep->marks, q);
free(lmp);
}
return (0);
@@ -110,11 +111,11 @@ mark_end(sp, ep)
* PUBLIC: int mark_get __P((SCR *, ARG_CHAR_T, MARK *, mtype_t));
*/
int
-mark_get(sp, key, mp, mtype)
- SCR *sp;
- ARG_CHAR_T key;
- MARK *mp;
- mtype_t mtype;
+mark_get(
+ SCR *sp,
+ ARG_CHAR_T key,
+ MARK *mp,
+ mtype_t mtype)
{
LMARK *lmp;
@@ -155,11 +156,11 @@ mark_get(sp, key, mp, mtype)
* PUBLIC: int mark_set __P((SCR *, ARG_CHAR_T, MARK *, int));
*/
int
-mark_set(sp, key, value, userset)
- SCR *sp;
- ARG_CHAR_T key;
- MARK *value;
- int userset;
+mark_set(
+ SCR *sp,
+ ARG_CHAR_T key,
+ MARK *value,
+ int userset)
{
LMARK *lmp, *lmt;
@@ -176,9 +177,9 @@ mark_set(sp, key, value, userset)
if (lmp == NULL || lmp->name != key) {
MALLOC_RET(sp, lmt, LMARK *, sizeof(LMARK));
if (lmp == NULL) {
- LIST_INSERT_HEAD(&sp->ep->marks, lmt, q);
+ SLIST_INSERT_HEAD(sp->ep->marks, lmt, q);
} else
- LIST_INSERT_AFTER(lmp, lmt, q);
+ SLIST_INSERT_AFTER(lmp, lmt, q);
lmp = lmt;
} else if (!userset &&
!F_ISSET(lmp, MARK_DELETED) && F_ISSET(lmp, MARK_USERSET))
@@ -197,20 +198,21 @@ mark_set(sp, key, value, userset)
* where it would go.
*/
static LMARK *
-mark_find(sp, key)
- SCR *sp;
- ARG_CHAR_T key;
+mark_find(
+ SCR *sp,
+ ARG_CHAR_T key)
{
- LMARK *lmp, *lastlmp;
+ LMARK *lmp, *lastlmp = NULL;
/*
* Return the requested mark or the slot immediately before
* where it should go.
*/
- for (lastlmp = NULL, lmp = sp->ep->marks.lh_first;
- lmp != NULL; lastlmp = lmp, lmp = lmp->q.le_next)
+ SLIST_FOREACH(lmp, sp->ep->marks, q) {
if (lmp->name >= key)
return (lmp->name == key ? lmp : lastlmp);
+ lastlmp = lmp;
+ }
return (lastlmp);
}
@@ -221,10 +223,10 @@ mark_find(sp, key)
* PUBLIC: int mark_insdel __P((SCR *, lnop_t, recno_t));
*/
int
-mark_insdel(sp, op, lno)
- SCR *sp;
- lnop_t op;
- recno_t lno;
+mark_insdel(
+ SCR *sp,
+ lnop_t op,
+ recno_t lno)
{
LMARK *lmp;
recno_t lline;
@@ -234,8 +236,7 @@ mark_insdel(sp, op, lno)
/* All insert/append operations are done as inserts. */
abort();
case LINE_DELETE:
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ SLIST_FOREACH(lmp, sp->ep->marks, q)
if (lmp->lno >= lno)
if (lmp->lno == lno) {
F_SET(lmp, MARK_DELETED);
@@ -265,8 +266,7 @@ mark_insdel(sp, op, lno)
return (0);
}
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ SLIST_FOREACH(lmp, sp->ep->marks, q)
if (lmp->lno >= lno)
++lmp->lno;
break;
diff --git a/common/mark.h b/common/mark.h
index 9c63e183e83f..44b8a19938ca 100644
--- a/common/mark.h
+++ b/common/mark.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)mark.h 10.3 (Berkeley) 3/6/96
+ * $Id: mark.h,v 10.6 2011/07/04 14:41:51 zy Exp $
*/
/*
@@ -28,9 +28,10 @@ struct _mark {
};
struct _lmark {
- LIST_ENTRY(_lmark) q; /* Linked list of marks. */
+ SLIST_ENTRY(_lmark) q; /* Linked list of marks. */
recno_t lno; /* Line number. */
size_t cno; /* Column number. */
+ /* XXXX Needed ? Can non ascii-chars be mark names ? */
CHAR_T name; /* Mark name. */
#define MARK_DELETED 0x01 /* Mark was deleted. */
diff --git a/common/mem.h b/common/mem.h
index af42e6bcd1de..b2b44b62ec8e 100644
--- a/common/mem.h
+++ b/common/mem.h
@@ -6,13 +6,21 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)mem.h 10.7 (Berkeley) 3/30/96
+ * $Id: mem.h,v 10.17 2012/10/07 00:40:29 zy Exp $
*/
+#ifdef DEBUG
+#define CHECK_TYPE(type, var) \
+ type L__lp __attribute__((unused)) = var;
+#else
+#define CHECK_TYPE(type, var)
+#endif
+
/* Increase the size of a malloc'd buffer. Two versions, one that
* returns, one that jumps to an error label.
*/
-#define BINC_GOTO(sp, lp, llen, nlen) { \
+#define BINC_GOTO(sp, type, lp, llen, nlen) { \
+ CHECK_TYPE(type *, lp) \
void *L__bincp; \
if ((nlen) > llen) { \
if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \
@@ -24,7 +32,12 @@
lp = L__bincp; \
} \
}
-#define BINC_RET(sp, lp, llen, nlen) { \
+#define BINC_GOTOC(sp, lp, llen, nlen) \
+ BINC_GOTO(sp, char, lp, llen, nlen)
+#define BINC_GOTOW(sp, lp, llen, nlen) \
+ BINC_GOTO(sp, CHAR_T, lp, llen, (nlen) * sizeof(CHAR_T))
+#define BINC_RET(sp, type, lp, llen, nlen) { \
+ CHECK_TYPE(type *, lp) \
void *L__bincp; \
if ((nlen) > llen) { \
if ((L__bincp = binc(sp, lp, &(llen), nlen)) == NULL) \
@@ -36,65 +49,89 @@
lp = L__bincp; \
} \
}
+#define BINC_RETC(sp, lp, llen, nlen) \
+ BINC_RET(sp, char, lp, llen, nlen)
+#define BINC_RETW(sp, lp, llen, nlen) \
+ BINC_RET(sp, CHAR_T, lp, llen, (nlen) * sizeof(CHAR_T))
/*
* Get some temporary space, preferably from the global temporary buffer,
* from a malloc'd buffer otherwise. Two versions, one that returns, one
* that jumps to an error label.
*/
-#define GET_SPACE_GOTO(sp, bp, blen, nlen) { \
+#define GET_SPACE_GOTO(sp, type, bp, blen, nlen) { \
+ CHECK_TYPE(type *, bp) \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) { \
bp = NULL; \
blen = 0; \
- BINC_GOTO(sp, bp, blen, nlen); \
+ BINC_GOTO(sp, type, bp, blen, nlen); \
} else { \
- BINC_GOTO(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
+ BINC_GOTOC(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
+ bp = (type *) L__gp->tmp_bp; \
blen = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} \
}
-#define GET_SPACE_RET(sp, bp, blen, nlen) { \
+#define GET_SPACE_GOTOC(sp, bp, blen, nlen) \
+ GET_SPACE_GOTO(sp, char, bp, blen, nlen)
+#define GET_SPACE_GOTOW(sp, bp, blen, nlen) \
+ GET_SPACE_GOTO(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T))
+#define GET_SPACE_RET(sp, type, bp, blen, nlen) { \
+ CHECK_TYPE(type *, bp) \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
if (L__gp == NULL || F_ISSET(L__gp, G_TMP_INUSE)) { \
bp = NULL; \
blen = 0; \
- BINC_RET(sp, bp, blen, nlen); \
+ BINC_RET(sp, type, bp, blen, nlen); \
} else { \
- BINC_RET(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
+ BINC_RETC(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
+ bp = (type *) L__gp->tmp_bp; \
blen = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} \
}
+#define GET_SPACE_RETC(sp, bp, blen, nlen) \
+ GET_SPACE_RET(sp, char, bp, blen, nlen)
+#define GET_SPACE_RETW(sp, bp, blen, nlen) \
+ GET_SPACE_RET(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T))
/*
* Add space to a GET_SPACE returned buffer. Two versions, one that
* returns, one that jumps to an error label.
*/
-#define ADD_SPACE_GOTO(sp, bp, blen, nlen) { \
+#define ADD_SPACE_GOTO(sp, type, bp, blen, nlen) { \
+ CHECK_TYPE(type *, bp) \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
- if (L__gp == NULL || bp == L__gp->tmp_bp) { \
+ if (L__gp == NULL || bp == (type *)L__gp->tmp_bp) { \
F_CLR(L__gp, G_TMP_INUSE); \
- BINC_GOTO(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
+ BINC_GOTOC(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
+ bp = (type *) L__gp->tmp_bp; \
blen = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} else \
- BINC_GOTO(sp, bp, blen, nlen); \
-}
-#define ADD_SPACE_RET(sp, bp, blen, nlen) { \
+ BINC_GOTO(sp, type, bp, blen, nlen); \
+}
+#define ADD_SPACE_GOTOC(sp, bp, blen, nlen) \
+ ADD_SPACE_GOTO(sp, char, bp, blen, nlen)
+#define ADD_SPACE_GOTOW(sp, bp, blen, nlen) \
+ ADD_SPACE_GOTO(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T))
+#define ADD_SPACE_RET(sp, type, bp, blen, nlen) { \
+ CHECK_TYPE(type *, bp) \
GS *L__gp = (sp) == NULL ? NULL : (sp)->gp; \
- if (L__gp == NULL || bp == L__gp->tmp_bp) { \
+ if (L__gp == NULL || bp == (type *)L__gp->tmp_bp) { \
F_CLR(L__gp, G_TMP_INUSE); \
- BINC_RET(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
- bp = L__gp->tmp_bp; \
+ BINC_RETC(sp, L__gp->tmp_bp, L__gp->tmp_blen, nlen); \
+ bp = (type *) L__gp->tmp_bp; \
blen = L__gp->tmp_blen; \
F_SET(L__gp, G_TMP_INUSE); \
} else \
- BINC_RET(sp, bp, blen, nlen); \
+ BINC_RET(sp, type, bp, blen, nlen); \
}
+#define ADD_SPACE_RETC(sp, bp, blen, nlen) \
+ ADD_SPACE_RET(sp, char, bp, blen, nlen)
+#define ADD_SPACE_RETW(sp, bp, blen, nlen) \
+ ADD_SPACE_RET(sp, CHAR_T, bp, blen, (nlen) * sizeof(CHAR_T))
/* Free a GET_SPACE returned buffer. */
#define FREE_SPACE(sp, bp, blen) { \
@@ -104,6 +141,10 @@
else \
free(bp); \
}
+#define FREE_SPACEW(sp, bp, blen) { \
+ CHECK_TYPE(CHAR_T *, bp) \
+ FREE_SPACE(sp, (char *)bp, blen); \
+}
/*
* Malloc a buffer, casting the return pointer. Various versions.
@@ -150,19 +191,50 @@
return (1); \
} \
}
+
/*
- * XXX
- * Don't depend on realloc(NULL, size) working.
+ * Resize a buffer, free any already held memory if we can't get more.
+ * FreeBSD's reallocf(3) does the same thing, but it's not portable yet.
*/
#define REALLOC(sp, p, cast, size) { \
- if ((p = (cast)(p == NULL ? \
- malloc(size) : realloc(p, size))) == NULL) \
+ cast newp; \
+ if ((newp = (cast)realloc(p, size)) == NULL) { \
+ if (p != NULL) \
+ free(p); \
msgq(sp, M_SYSERR, NULL); \
+ } \
+ p = newp; \
}
/*
- * Versions of memmove(3) and memset(3) that use the size of the
+ * Versions of bcopy(3) and bzero(3) that use the size of the
* initial pointer to figure out how much memory to manipulate.
*/
-#define MEMMOVE(p, t, len) memmove(p, t, (len) * sizeof(*(p)))
-#define MEMSET(p, value, len) memset(p, value, (len) * sizeof(*(p)))
+#define BCOPY(p, t, len) bcopy(p, t, (len) * sizeof(*(p)))
+#define BZERO(p, len) bzero(p, (len) * sizeof(*(p)))
+
+/*
+ * p2roundup --
+ * Get next power of 2; convenient for realloc.
+ *
+ * Reference: FreeBSD /usr/src/lib/libc/stdio/getdelim.c
+ */
+static __inline size_t
+p2roundup(size_t n)
+{
+ n--;
+ n |= n >> 1;
+ n |= n >> 2;
+ n |= n >> 4;
+ n |= n >> 8;
+ n |= n >> 16;
+#if SIZE_T_MAX > 0xffffffffU
+ n |= n >> 32;
+#endif
+ n++;
+ return (n);
+}
+
+/* Additional TAILQ helper. */
+#define TAILQ_ENTRY_ISVALID(elm, field) \
+ ((elm)->field.tqe_prev != NULL)
diff --git a/common/msg.c b/common/msg.c
index 2b18082c7ab8..c0930b88afcd 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -10,31 +10,25 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)msg.c 10.48 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: msg.c,v 11.0 2012/10/17 06:34:37 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
-#include <sys/types.h> /* XXX: param.h may not have included types.h */
+#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <locale.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
#include "common.h"
#include "../vi/vi.h"
@@ -45,15 +39,11 @@ static const char sccsid[] = "@(#)msg.c 10.48 (Berkeley) 9/15/96";
* PUBLIC: void msgq __P((SCR *, mtype_t, const char *, ...));
*/
void
-#ifdef __STDC__
-msgq(SCR *sp, mtype_t mt, const char *fmt, ...)
-#else
-msgq(sp, mt, fmt, va_alist)
- SCR *sp;
- mtype_t mt;
- const char *fmt;
- va_dcl
-#endif
+msgq(
+ SCR *sp,
+ mtype_t mt,
+ const char *fmt,
+ ...)
{
#ifndef NL_ARGMAX
#define __NL_ARGMAX 20 /* Set to 9 by System V. */
@@ -66,12 +56,17 @@ msgq(sp, mt, fmt, va_alist)
} str[__NL_ARGMAX];
#endif
static int reenter; /* STATIC: Re-entrancy check. */
- CHAR_T ch;
GS *gp;
- size_t blen, cnt1, cnt2, len, mlen, nlen, soff;
- const char *p, *t, *u;
- char *bp, *mp, *rbp, *s_rbp;
+ size_t blen, len, mlen, nlen;
+ const char *p;
+ char *bp, *mp;
va_list ap;
+#ifndef NL_ARGMAX
+ int ch;
+ char *rbp, *s_rbp;
+ const char *t, *u;
+ size_t cnt1, cnt2, soff;
+#endif
/*
* !!!
@@ -130,7 +125,7 @@ retry: FREE_SPACE(sp, bp, blen);
}
bp = NULL;
blen = 0;
- GET_SPACE_GOTO(sp, bp, blen, nlen);
+ GET_SPACE_GOTOC(sp, bp, blen, nlen);
/*
* Error prefix.
@@ -157,8 +152,12 @@ retry: FREE_SPACE(sp, bp, blen);
*/
if ((mt == M_ERR || mt == M_SYSERR) &&
sp != NULL && gp != NULL && gp->if_name != NULL) {
- for (p = gp->if_name; *p != '\0'; ++p) {
- len = snprintf(mp, REM, "%s", KEY_NAME(sp, *p));
+ CHAR_T *wp;
+ size_t wlen;
+
+ CHAR2INT(sp, gp->if_name, strlen(gp->if_name) + 1, wp, wlen);
+ for (; *wp != '\0'; ++wp) {
+ len = snprintf(mp, REM, "%s", KEY_NAME(sp, *wp));
mp += len;
if ((mlen += len) > blen)
goto retry;
@@ -272,12 +271,10 @@ retry: FREE_SPACE(sp, bp, blen);
fmt = rbp;
#endif
+#ifndef NL_ARGMAX
format: /* Format the arguments into the string. */
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
#endif
+ va_start(ap, fmt);
len = vsnprintf(mp, REM, fmt, ap);
va_end(ap);
if (len >= nlen)
@@ -347,28 +344,56 @@ nofmt: mp += len;
(void)fprintf(stderr, "%.*s", (int)mlen, bp);
/* Cleanup. */
-ret: FREE_SPACE(sp, bp, blen);
+#ifndef NL_ARGMAX
+ret:
+#endif
+ FREE_SPACE(sp, bp, blen);
alloc_err:
reenter = 0;
}
/*
+ * msgq_wstr --
+ * Display a message with an embedded string.
+ *
+ * PUBLIC: void msgq_wstr __P((SCR *, mtype_t, const CHAR_T *, const char *));
+ */
+void
+msgq_wstr(
+ SCR *sp,
+ mtype_t mtype,
+ const CHAR_T *str,
+ const char *fmt)
+{
+ size_t nlen;
+ CONST char *nstr;
+
+ if (str == NULL) {
+ msgq(sp, mtype, "%s", fmt);
+ return;
+ }
+ INT2CHAR(sp, str, STRLEN(str) + 1, nstr, nlen);
+ msgq_str(sp, mtype, nstr, fmt);
+}
+
+/*
* msgq_str --
* Display a message with an embedded string.
*
- * PUBLIC: void msgq_str __P((SCR *, mtype_t, char *, char *));
+ * PUBLIC: void msgq_str __P((SCR *, mtype_t, const char *, const char *));
*/
void
-msgq_str(sp, mtype, str, fmt)
- SCR *sp;
- mtype_t mtype;
- char *str, *fmt;
+msgq_str(
+ SCR *sp,
+ mtype_t mtype,
+ const char *str,
+ const char *fmt)
{
int nf, sv_errno;
char *p;
if (str == NULL) {
- msgq(sp, mtype, fmt);
+ msgq(sp, mtype, "%s", fmt);
return;
}
@@ -401,8 +426,7 @@ msgq_str(sp, mtype, str, fmt)
* PUBLIC: void mod_rpt __P((SCR *));
*/
void
-mod_rpt(sp)
- SCR *sp;
+mod_rpt(SCR *sp)
{
static char * const action[] = {
"293|added",
@@ -461,7 +485,7 @@ mod_rpt(sp)
}
/* Build and display the message. */
- GET_SPACE_GOTO(sp, bp, blen, sizeof(action) * MAXNUM + 1);
+ GET_SPACE_GOTOC(sp, bp, blen, sizeof(action) * MAXNUM + 1);
for (p = bp, first = 1, tlen = 0,
ap = action, cnt = 0; cnt < ARSIZE(action); ++ap, ++cnt)
if (sp->rptlines[cnt] != 0) {
@@ -472,7 +496,8 @@ mod_rpt(sp)
*p++ = ' ';
tlen += 2;
}
- len = snprintf(p, MAXNUM, "%lu ", sp->rptlines[cnt]);
+ len = snprintf(p, MAXNUM, "%lu ",
+ (u_long)sp->rptlines[cnt]);
p += len;
tlen += len;
t = msg_cat(sp,
@@ -511,27 +536,32 @@ alloc_err:
* PUBLIC: void msgq_status __P((SCR *, recno_t, u_int));
*/
void
-msgq_status(sp, lno, flags)
- SCR *sp;
- recno_t lno;
- u_int flags;
+msgq_status(
+ SCR *sp,
+ recno_t lno,
+ u_int flags)
{
- static int poisoned;
recno_t last;
size_t blen, len;
int cnt, needsep;
const char *t;
- char **ap, *bp, *np, *p, *s;
+ char **ap, *bp, *np, *p, *s, *ep;
+ CHAR_T *wp;
+ size_t wlen;
/* Get sufficient memory. */
len = strlen(sp->frp->name);
- GET_SPACE_GOTO(sp, bp, blen, len * MAX_CHARACTER_COLUMNS + 128);
+ GET_SPACE_GOTOC(sp, bp, blen, len * MAX_CHARACTER_COLUMNS + 128);
p = bp;
+ ep = bp + blen;
+
+ /* Convert the filename. */
+ CHAR2INT(sp, sp->frp->name, len + 1, wp, wlen);
/* Copy in the filename. */
- for (p = bp, t = sp->frp->name; *t != '\0'; ++t) {
- len = KEY_LEN(sp, *t);
- memcpy(p, KEY_NAME(sp, *t), len);
+ for (; *wp != '\0'; ++wp) {
+ len = KEY_LEN(sp, *wp);
+ memcpy(p, KEY_NAME(sp, *wp), len);
p += len;
}
np = p;
@@ -542,7 +572,7 @@ msgq_status(sp, lno, flags)
if (F_ISSET(sp, SC_STATUS_CNT) && sp->argv != NULL) {
for (cnt = 0, ap = sp->argv; *ap != NULL; ++ap, ++cnt);
if (cnt > 1) {
- (void)sprintf(p,
+ (void)snprintf(p, ep - p,
msg_cat(sp, "317|%d files to edit", NULL), cnt);
p += strlen(p);
*p++ = ':';
@@ -617,16 +647,17 @@ msgq_status(sp, lno, flags)
p += len;
} else {
t = msg_cat(sp, "027|line %lu of %lu [%ld%%]", &len);
- (void)sprintf(p, t, lno, last, (lno * 100) / last);
+ (void)snprintf(p, ep - p, t, lno, last,
+ ((u_long)lno * 100) / last);
p += strlen(p);
}
} else {
t = msg_cat(sp, "029|line %lu", &len);
- (void)sprintf(p, t, lno);
+ (void)snprintf(p, ep - p, t, (u_long)lno);
p += strlen(p);
}
#ifdef DEBUG
- (void)sprintf(p, " (pid %lu)", (u_long)getpid());
+ (void)snprintf(p, ep - p, " (pid %lu)", (u_long)getpid());
p += strlen(p);
#endif
*p++ = '\n';
@@ -677,9 +708,9 @@ alloc_err:
* PUBLIC: int msg_open __P((SCR *, char *));
*/
int
-msg_open(sp, file)
- SCR *sp;
- char *file;
+msg_open(
+ SCR *sp,
+ char *file)
{
/*
* !!!
@@ -691,54 +722,50 @@ msg_open(sp, file)
* message will be repeated every time nvi is started up.
*/
static int first = 1;
- DB *db;
- DBT data, key;
- recno_t msgno;
- char *p, *t, buf[MAXPATHLEN];
-
- if ((p = strrchr(file, '/')) != NULL && p[1] == '\0' &&
- ((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0' ||
- (t = getenv("LANG")) != NULL && t[0] != '\0')) {
- (void)snprintf(buf, sizeof(buf), "%s%s", file, t);
- p = buf;
- } else
- p = file;
- if ((db = dbopen(p,
- O_NONBLOCK | O_RDONLY, 0, DB_RECNO, NULL)) == NULL) {
- if (first) {
- first = 0;
+ nl_catd catd;
+ char *p;
+ int rval = 0;
+
+ if ((p = strrchr(file, '/')) != NULL && p[1] == '\0') {
+ /* Confirms to XPG4. */
+ if ((p = join(file, setlocale(LC_MESSAGES, NULL))) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
+ } else {
+ /* Make sure it's recognized as a path by catopen(3). */
+ if ((p = join(".", file)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
return (1);
}
- msgq_str(sp, M_SYSERR, p, "%s");
- return (1);
}
-
- /*
- * Test record 1 for the magic string. The msgq call is here so
- * the message catalog build finds it.
- */
-#define VMC "VI_MESSAGE_CATALOG"
- key.data = &msgno;
- key.size = sizeof(recno_t);
- msgno = 1;
- if (db->get(db, &key, &data, 0) != 0 ||
- data.size != sizeof(VMC) - 1 ||
- memcmp(data.data, VMC, sizeof(VMC) - 1)) {
- (void)db->close(db);
+ errno = 0;
+ if ((catd = catopen(p, NL_CAT_LOCALE)) == (nl_catd)-1) {
if (first) {
first = 0;
- return (1);
+ rval = 1;
+ goto ret;
}
- msgq_str(sp, M_ERR, p,
- "030|The file %s is not a message catalog");
- return (1);
+
+ /*
+ * POSIX.1-2008 gives no instruction on how to report a
+ * corrupt catalog file. Errno == 0 is not rare; add
+ * EFTYPE, which is seen on FreeBSD, for a good measure.
+ */
+ if (errno == 0 || errno == EFTYPE)
+ msgq_str(sp, M_ERR, p,
+ "030|The file %s is not a message catalog");
+ else
+ msgq_str(sp, M_SYSERR, p, "%s");
+ rval = 1;
+ goto ret;
}
first = 0;
- if (sp->gp->msg != NULL)
- (void)sp->gp->msg->close(sp->gp->msg);
- sp->gp->msg = db;
- return (0);
+ msg_close(sp->gp);
+ sp->gp->catd = catd;
+ret: free(p);
+ return (rval);
}
/*
@@ -748,11 +775,10 @@ msg_open(sp, file)
* PUBLIC: void msg_close __P((GS *));
*/
void
-msg_close(gp)
- GS *gp;
+msg_close(GS *gp)
{
- if (gp->msg != NULL)
- (void)gp->msg->close(gp->msg);
+ if (gp->catd != (nl_catd)-1)
+ (void)catclose(gp->catd);
}
/*
@@ -762,10 +788,10 @@ msg_close(gp)
* PUBLIC: const char *msg_cmsg __P((SCR *, cmsg_t, size_t *));
*/
const char *
-msg_cmsg(sp, which, lenp)
- SCR *sp;
- cmsg_t which;
- size_t *lenp;
+msg_cmsg(
+ SCR *sp,
+ cmsg_t which,
+ size_t *lenp)
{
switch (which) {
case CMSG_CONF:
@@ -800,14 +826,14 @@ msg_cmsg(sp, which, lenp)
* PUBLIC: const char *msg_cat __P((SCR *, const char *, size_t *));
*/
const char *
-msg_cat(sp, str, lenp)
- SCR *sp;
- const char *str;
- size_t *lenp;
+msg_cat(
+ SCR *sp,
+ const char *str,
+ size_t *lenp)
{
GS *gp;
- DBT data, key;
- recno_t msgno;
+ char *p;
+ int msgno;
/*
* If it's not a catalog message, i.e. has doesn't have a leading
@@ -815,28 +841,16 @@ msg_cat(sp, str, lenp)
*/
if (isdigit(str[0]) &&
isdigit(str[1]) && isdigit(str[2]) && str[3] == '|') {
- key.data = &msgno;
- key.size = sizeof(recno_t);
msgno = atoi(str);
+ str = &str[4];
- /*
- * XXX
- * Really sleazy hack -- we put an extra character on the
- * end of the format string, and then we change it to be
- * the nul termination of the string. There ought to be
- * a better way. Once we can allocate multiple temporary
- * memory buffers, maybe we can use one of them instead.
- */
gp = sp == NULL ? NULL : sp->gp;
- if (gp != NULL && gp->msg != NULL &&
- gp->msg->get(gp->msg, &key, &data, 0) == 0 &&
- data.size != 0) {
+ if (gp != NULL && gp->catd != (nl_catd)-1 &&
+ (p = catgets(gp->catd, 1, msgno, str)) != NULL) {
if (lenp != NULL)
- *lenp = data.size - 1;
- ((char *)data.data)[data.size - 1] = '\0';
- return (data.data);
+ *lenp = strlen(p);
+ return (p);
}
- str = &str[4];
}
if (lenp != NULL)
*lenp = strlen(str);
@@ -850,19 +864,22 @@ msg_cat(sp, str, lenp)
* PUBLIC: char *msg_print __P((SCR *, const char *, int *));
*/
char *
-msg_print(sp, s, needfree)
- SCR *sp;
- const char *s;
- int *needfree;
+msg_print(
+ SCR *sp,
+ const char *s,
+ int *needfree)
{
size_t blen, nlen;
- const char *cp;
char *bp, *ep, *p, *t;
+ CHAR_T *wp, *cp;
+ size_t wlen;
*needfree = 0;
- for (cp = s; *cp != '\0'; ++cp)
- if (!isprint(*cp))
+ /* XXX Not good for debugging ex_read & ex_filter.*/
+ CHAR2INT5(sp, EXP(sp)->ibcw, (char *)s, strlen(s) + 1, wp, wlen);
+ for (cp = wp; *cp != '\0'; ++cp)
+ if (!ISPRINT(*cp))
break;
if (*cp == '\0')
return ((char *)s); /* SAFE: needfree set to 0. */
@@ -873,21 +890,21 @@ retry: if (sp == NULL)
free(bp);
else
FREE_SPACE(sp, bp, blen);
- needfree = 0;
+ *needfree = 0;
}
nlen += 256;
if (sp == NULL) {
if ((bp = malloc(nlen)) == NULL)
goto alloc_err;
} else
- GET_SPACE_GOTO(sp, bp, blen, nlen);
+ GET_SPACE_GOTOC(sp, bp, blen, nlen);
if (0) {
alloc_err: return ("");
}
*needfree = 1;
- for (p = bp, ep = (bp + blen) - 1, cp = s; *cp != '\0' && p < ep; ++cp)
- for (t = KEY_NAME(sp, *cp); *t != '\0' && p < ep; *p++ = *t++);
+ for (p = bp, ep = (bp + blen) - 1; *wp != '\0' && p < ep; ++wp)
+ for (t = KEY_NAME(sp, *wp); *t != '\0' && p < ep; *p++ = *t++);
if (p == ep)
goto retry;
*p = '\0';
diff --git a/common/msg.h b/common/msg.h
index b10f4ccae5c6..d65bb1aaf542 100644
--- a/common/msg.h
+++ b/common/msg.h
@@ -52,9 +52,9 @@ typedef enum {
* messages.
*/
typedef struct _msgh MSGH; /* MSGS list head structure. */
-LIST_HEAD(_msgh, _msg);
+SLIST_HEAD(_msgh, _msg);
struct _msg {
- LIST_ENTRY(_msg) q; /* Linked list of messages. */
+ SLIST_ENTRY(_msg) q; /* Linked list of messages. */
mtype_t mtype; /* Message type: M_NONE, M_ERR, M_INFO. */
char *buf; /* Message buffer. */
size_t len; /* Message length. */
diff --git a/common/multibyte.h b/common/multibyte.h
new file mode 100644
index 000000000000..40e352100ec3
--- /dev/null
+++ b/common/multibyte.h
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996
+ * Keith Bostic. All rights reserved.
+ *
+ * See the LICENSE file for redistribution information.
+ *
+ * $Id: multibyte.h,v 1.32 2012/10/07 01:35:58 zy Exp $
+ */
+
+#ifndef MULTIBYTE_H
+#define MULTIBYTE_H
+
+/*
+ * Fundamental character types.
+ *
+ * CHAR_T An integral type that can hold any character.
+ * ARG_CHAR_T The type of a CHAR_T when passed as an argument using
+ * traditional promotion rules. It should also be able
+ * to be compared against any CHAR_T for equality without
+ * problems.
+ * UCHAR_T The shortest unified character type (8-bit clean).
+ * RCHAR_T The character type used by the internal regex engine.
+ *
+ * If no integral type can hold a character, don't even try the port.
+ */
+typedef int ARG_CHAR_T;
+
+#ifdef USE_WIDECHAR
+#include <wchar.h>
+#include <wctype.h>
+
+typedef wchar_t CHAR_T;
+typedef wint_t UCHAR_T;
+typedef wchar_t RCHAR_T;
+#define REOF WEOF
+
+#define STRLEN wcslen
+#define STRTOL wcstol
+#define STRTOUL wcstoul
+#define SPRINTF swprintf
+#define STRCMP wcscmp
+#define STRPBRK wcspbrk
+#define ISBLANK iswblank
+#define ISCNTRL iswcntrl
+#define ISDIGIT iswdigit
+#define ISXDIGIT iswxdigit
+#define ISGRAPH iswgraph
+#define ISLOWER iswlower
+#define ISPRINT iswprint
+#define ISPUNCT iswpunct
+#define ISSPACE iswspace
+#define ISUPPER iswupper
+#define TOLOWER towlower
+#define TOUPPER towupper
+#define STRSET wmemset
+#define STRCHR wcschr
+#define STRRCHR wcsrchr
+#define GETC getwc
+
+#define L(ch) L ## ch
+#define WS "%ls"
+#define WVS "%*ls"
+#define WC "%lc"
+
+#else
+typedef u_char CHAR_T;
+typedef u_char UCHAR_T;
+typedef char RCHAR_T;
+#define REOF EOF
+
+#define STRLEN strlen
+#define STRTOL(a,b,c) (strtol(a,(char**)b,c))
+#define STRTOUL(a,b,c) (strtoul(a,(char**)b,c))
+#define SPRINTF snprintf
+#define STRCMP strcmp
+#define STRPBRK strpbrk
+#define ISBLANK isblank
+#define ISCNTRL iscntrl
+#define ISDIGIT isdigit
+#define ISXDIGIT isxdigit
+#define ISGRAPH isgraph
+#define ISLOWER islower
+#define ISPRINT isprint
+#define ISPUNCT ispunct
+#define ISSPACE isspace
+#define ISUPPER isupper
+#define TOLOWER tolower
+#define TOUPPER toupper
+#define STRSET memset
+#define STRCHR strchr
+#define STRRCHR strrchr
+#define GETC getc
+
+#define L(ch) ch
+#define WS "%s"
+#define WVS "%*s"
+#define WC "%c"
+
+#endif
+
+#if defined(USE_WIDECHAR) && defined(DEBUG)
+#define MEMCPY wmemcpy
+#define MEMMOVE wmemmove
+#define MEMCMP wmemcmp
+#else
+#define MEMCPY(p, t, len) memcpy(p, t, (len) * sizeof(CHAR_T))
+#define MEMMOVE(p, t, len) memmove(p, t, (len) * sizeof(CHAR_T))
+#define MEMCMP(p, t, len) memcmp(p, t, (len) * sizeof(CHAR_T))
+#endif
+
+#define SIZE(w) (sizeof(w) / sizeof(*w))
+
+#endif
diff --git a/common/options.c b/common/options.c
index 973778c78bbd..71a5e43e58cb 100644
--- a/common/options.c
+++ b/common/options.c
@@ -10,13 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)options.c 10.51 (Berkeley) 10/14/96";
+static const char sccsid[] = "$Id: options.c,v 10.73 2012/10/09 06:14:07 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -35,6 +34,12 @@ static int opts_abbcmp __P((const void *, const void *));
static int opts_cmp __P((const void *, const void *));
static int opts_print __P((SCR *, OPTLIST const *));
+#ifdef USE_WIDECHAR
+#define OPT_WC 0
+#else
+#define OPT_WC (OPT_NOSAVE | OPT_NDISP)
+#endif
+
/*
* O'Reilly noted options and abbreviations are from "Learning the VI Editor",
* Fifth Edition, May 1992. There's no way of knowing what systems they are
@@ -45,73 +50,81 @@ static int opts_print __P((SCR *, OPTLIST const *));
*/
OPTLIST const optlist[] = {
/* O_ALTWERASE 4.4BSD */
- {"altwerase", f_altwerase, OPT_0BOOL, 0},
+ {L("altwerase"), f_altwerase, OPT_0BOOL, 0},
/* O_AUTOINDENT 4BSD */
- {"autoindent", NULL, OPT_0BOOL, 0},
+ {L("autoindent"), NULL, OPT_0BOOL, 0},
/* O_AUTOPRINT 4BSD */
- {"autoprint", NULL, OPT_1BOOL, 0},
+ {L("autoprint"), NULL, OPT_1BOOL, 0},
/* O_AUTOWRITE 4BSD */
- {"autowrite", NULL, OPT_0BOOL, 0},
+ {L("autowrite"), NULL, OPT_0BOOL, 0},
/* O_BACKUP 4.4BSD */
- {"backup", NULL, OPT_STR, 0},
+ {L("backup"), NULL, OPT_STR, 0},
/* O_BEAUTIFY 4BSD */
- {"beautify", NULL, OPT_0BOOL, 0},
+ {L("beautify"), NULL, OPT_0BOOL, 0},
/* O_CDPATH 4.4BSD */
- {"cdpath", NULL, OPT_STR, 0},
+ {L("cdpath"), NULL, OPT_STR, 0},
/* O_CEDIT 4.4BSD */
- {"cedit", NULL, OPT_STR, 0},
+ {L("cedit"), NULL, OPT_STR, 0},
/* O_COLUMNS 4.4BSD */
- {"columns", f_columns, OPT_NUM, OPT_NOSAVE},
+ {L("columns"), f_columns, OPT_NUM, OPT_NOSAVE},
+/* O_COMBINED */
+ {L("combined"), NULL, OPT_0BOOL, OPT_NOSET|OPT_WC},
/* O_COMMENT 4.4BSD */
- {"comment", NULL, OPT_0BOOL, 0},
-/* O_DIRECTORY 4BSD */
- {"directory", NULL, OPT_STR, 0},
+ {L("comment"), NULL, OPT_0BOOL, 0},
+/* O_TMPDIR 4BSD */
+ {L("directory"), NULL, OPT_STR, 0},
/* O_EDCOMPATIBLE 4BSD */
- {"edcompatible",NULL, OPT_0BOOL, 0},
-/* O_ESCAPETIME 4.4BSD */
- {"escapetime", NULL, OPT_NUM, 0},
+ {L("edcompatible"),NULL, OPT_0BOOL, 0},
/* O_ERRORBELLS 4BSD */
- {"errorbells", NULL, OPT_0BOOL, 0},
+ {L("errorbells"), NULL, OPT_0BOOL, 0},
+/* O_ESCAPETIME 4.4BSD */
+ {L("escapetime"), NULL, OPT_NUM, 0},
/* O_EXRC System V (undocumented) */
- {"exrc", NULL, OPT_0BOOL, 0},
+ {L("exrc"), NULL, OPT_0BOOL, 0},
/* O_EXTENDED 4.4BSD */
- {"extended", f_recompile, OPT_0BOOL, 0},
+ {L("extended"), f_recompile, OPT_0BOOL, 0},
/* O_FILEC 4.4BSD */
- {"filec", NULL, OPT_STR, 0},
+ {L("filec"), NULL, OPT_STR, 0},
+/* O_FILEENCODING */
+ {L("fileencoding"),f_encoding, OPT_STR, OPT_WC},
/* O_FLASH HPUX */
- {"flash", NULL, OPT_1BOOL, 0},
+ {L("flash"), NULL, OPT_1BOOL, 0},
/* O_HARDTABS 4BSD */
- {"hardtabs", NULL, OPT_NUM, 0},
+ {L("hardtabs"), NULL, OPT_NUM, 0},
/* O_ICLOWER 4.4BSD */
- {"iclower", f_recompile, OPT_0BOOL, 0},
+ {L("iclower"), f_recompile, OPT_0BOOL, 0},
/* O_IGNORECASE 4BSD */
- {"ignorecase", f_recompile, OPT_0BOOL, 0},
+ {L("ignorecase"), f_recompile, OPT_0BOOL, 0},
+/* O_INPUTENCODING */
+ {L("inputencoding"),f_encoding, OPT_STR, OPT_WC},
/* O_KEYTIME 4.4BSD */
- {"keytime", NULL, OPT_NUM, 0},
+ {L("keytime"), NULL, OPT_NUM, 0},
/* O_LEFTRIGHT 4.4BSD */
- {"leftright", f_reformat, OPT_0BOOL, 0},
+ {L("leftright"), f_reformat, OPT_0BOOL, 0},
/* O_LINES 4.4BSD */
- {"lines", f_lines, OPT_NUM, OPT_NOSAVE},
+ {L("lines"), f_lines, OPT_NUM, OPT_NOSAVE},
/* O_LISP 4BSD
* XXX
* When the lisp option is implemented, delete the OPT_NOSAVE flag,
* so that :mkexrc dumps it.
*/
- {"lisp", f_lisp, OPT_0BOOL, OPT_NOSAVE},
+ {L("lisp"), f_lisp, OPT_0BOOL, OPT_NOSAVE},
/* O_LIST 4BSD */
- {"list", f_reformat, OPT_0BOOL, 0},
+ {L("list"), f_reformat, OPT_0BOOL, 0},
/* O_LOCKFILES 4.4BSD
* XXX
* Locking isn't reliable enough over NFS to require it, in addition,
* it's a serious startup performance problem over some remote links.
*/
- {"lock", NULL, OPT_1BOOL, 0},
+ {L("lock"), NULL, OPT_1BOOL, 0},
/* O_MAGIC 4BSD */
- {"magic", NULL, OPT_1BOOL, 0},
+ {L("magic"), NULL, OPT_1BOOL, 0},
+/* O_MATCHCHARS NetBSD 2.0 */
+ {L("matchchars"), NULL, OPT_STR, OPT_PAIRS},
/* O_MATCHTIME 4.4BSD */
- {"matchtime", NULL, OPT_NUM, 0},
+ {L("matchtime"), NULL, OPT_NUM, 0},
/* O_MESG 4BSD */
- {"mesg", NULL, OPT_1BOOL, 0},
+ {L("mesg"), NULL, OPT_1BOOL, 0},
/* O_MODELINE 4BSD
* !!!
* This has been documented in historical systems as both "modeline"
@@ -120,61 +133,61 @@ OPTLIST const optlist[] = {
* example of what your intro CS professor referred to as the perils of
* mixing code and data. Don't add it, or I will kill you.
*/
- {"modeline", NULL, OPT_0BOOL, OPT_NOSET},
+ {L("modeline"), NULL, OPT_0BOOL, OPT_NOSET},
/* O_MSGCAT 4.4BSD */
- {"msgcat", f_msgcat, OPT_STR, 0},
+ {L("msgcat"), f_msgcat, OPT_STR, 0},
/* O_NOPRINT 4.4BSD */
- {"noprint", f_print, OPT_STR, 0},
+ {L("noprint"), f_print, OPT_STR, 0},
/* O_NUMBER 4BSD */
- {"number", f_reformat, OPT_0BOOL, 0},
+ {L("number"), f_reformat, OPT_0BOOL, 0},
/* O_OCTAL 4.4BSD */
- {"octal", f_print, OPT_0BOOL, 0},
+ {L("octal"), f_print, OPT_0BOOL, 0},
/* O_OPEN 4BSD */
- {"open", NULL, OPT_1BOOL, 0},
+ {L("open"), NULL, OPT_1BOOL, 0},
/* O_OPTIMIZE 4BSD */
- {"optimize", NULL, OPT_1BOOL, 0},
+ {L("optimize"), NULL, OPT_1BOOL, 0},
/* O_PARAGRAPHS 4BSD */
- {"paragraphs", f_paragraph, OPT_STR, 0},
+ {L("paragraphs"), NULL, OPT_STR, OPT_PAIRS},
/* O_PATH 4.4BSD */
- {"path", NULL, OPT_STR, 0},
+ {L("path"), NULL, OPT_STR, 0},
/* O_PRINT 4.4BSD */
- {"print", f_print, OPT_STR, 0},
+ {L("print"), f_print, OPT_STR, 0},
/* O_PROMPT 4BSD */
- {"prompt", NULL, OPT_1BOOL, 0},
+ {L("prompt"), NULL, OPT_1BOOL, 0},
/* O_READONLY 4BSD (undocumented) */
- {"readonly", f_readonly, OPT_0BOOL, OPT_ALWAYS},
+ {L("readonly"), f_readonly, OPT_0BOOL, OPT_ALWAYS},
/* O_RECDIR 4.4BSD */
- {"recdir", NULL, OPT_STR, 0},
+ {L("recdir"), NULL, OPT_STR, 0},
/* O_REDRAW 4BSD */
- {"redraw", NULL, OPT_0BOOL, 0},
+ {L("redraw"), NULL, OPT_0BOOL, 0},
/* O_REMAP 4BSD */
- {"remap", NULL, OPT_1BOOL, 0},
+ {L("remap"), NULL, OPT_1BOOL, 0},
/* O_REPORT 4BSD */
- {"report", NULL, OPT_NUM, 0},
+ {L("report"), NULL, OPT_NUM, 0},
/* O_RULER 4.4BSD */
- {"ruler", NULL, OPT_0BOOL, 0},
+ {L("ruler"), NULL, OPT_0BOOL, 0},
/* O_SCROLL 4BSD */
- {"scroll", NULL, OPT_NUM, 0},
+ {L("scroll"), NULL, OPT_NUM, 0},
/* O_SEARCHINCR 4.4BSD */
- {"searchincr", NULL, OPT_0BOOL, 0},
+ {L("searchincr"), NULL, OPT_0BOOL, 0},
/* O_SECTIONS 4BSD */
- {"sections", f_section, OPT_STR, 0},
+ {L("sections"), NULL, OPT_STR, OPT_PAIRS},
/* O_SECURE 4.4BSD */
- {"secure", NULL, OPT_0BOOL, OPT_NOUNSET},
+ {L("secure"), NULL, OPT_0BOOL, OPT_NOUNSET},
/* O_SHELL 4BSD */
- {"shell", NULL, OPT_STR, 0},
+ {L("shell"), NULL, OPT_STR, 0},
/* O_SHELLMETA 4.4BSD */
- {"shellmeta", NULL, OPT_STR, 0},
+ {L("shellmeta"), NULL, OPT_STR, 0},
/* O_SHIFTWIDTH 4BSD */
- {"shiftwidth", NULL, OPT_NUM, OPT_NOZERO},
+ {L("shiftwidth"), NULL, OPT_NUM, OPT_NOZERO},
/* O_SHOWMATCH 4BSD */
- {"showmatch", NULL, OPT_0BOOL, 0},
+ {L("showmatch"), NULL, OPT_0BOOL, 0},
/* O_SHOWMODE 4.4BSD */
- {"showmode", NULL, OPT_0BOOL, 0},
+ {L("showmode"), NULL, OPT_0BOOL, 0},
/* O_SIDESCROLL 4.4BSD */
- {"sidescroll", NULL, OPT_NUM, OPT_NOZERO},
+ {L("sidescroll"), NULL, OPT_NUM, OPT_NOZERO},
/* O_SLOWOPEN 4BSD */
- {"slowopen", NULL, OPT_0BOOL, 0},
+ {L("slowopen"), NULL, OPT_0BOOL, 0},
/* O_SOURCEANY 4BSD (undocumented)
* !!!
* Historic vi, on startup, source'd $HOME/.exrc and ./.exrc, if they
@@ -183,95 +196,97 @@ OPTLIST const optlist[] = {
* .exrc files the user didn't own. This is an obvious security problem,
* and we ignore the option.
*/
- {"sourceany", NULL, OPT_0BOOL, OPT_NOSET},
+ {L("sourceany"), NULL, OPT_0BOOL, OPT_NOSET},
/* O_TABSTOP 4BSD */
- {"tabstop", f_reformat, OPT_NUM, OPT_NOZERO},
+ {L("tabstop"), f_reformat, OPT_NUM, OPT_NOZERO},
/* O_TAGLENGTH 4BSD */
- {"taglength", NULL, OPT_NUM, 0},
+ {L("taglength"), NULL, OPT_NUM, 0},
/* O_TAGS 4BSD */
- {"tags", NULL, OPT_STR, 0},
+ {L("tags"), NULL, OPT_STR, 0},
/* O_TERM 4BSD
* !!!
* By default, the historic vi always displayed information about two
* options, redraw and term. Term seems sufficient.
*/
- {"term", NULL, OPT_STR, OPT_ADISP|OPT_NOSAVE},
+ {L("term"), NULL, OPT_STR, OPT_ADISP|OPT_NOSAVE},
/* O_TERSE 4BSD */
- {"terse", NULL, OPT_0BOOL, 0},
+ {L("terse"), NULL, OPT_0BOOL, 0},
/* O_TILDEOP 4.4BSD */
- {"tildeop", NULL, OPT_0BOOL, 0},
+ {L("tildeop"), NULL, OPT_0BOOL, 0},
/* O_TIMEOUT 4BSD (undocumented) */
- {"timeout", NULL, OPT_1BOOL, 0},
+ {L("timeout"), NULL, OPT_1BOOL, 0},
/* O_TTYWERASE 4.4BSD */
- {"ttywerase", f_ttywerase, OPT_0BOOL, 0},
+ {L("ttywerase"), f_ttywerase, OPT_0BOOL, 0},
/* O_VERBOSE 4.4BSD */
- {"verbose", NULL, OPT_0BOOL, 0},
+ {L("verbose"), NULL, OPT_0BOOL, 0},
/* O_W1200 4BSD */
- {"w1200", f_w1200, OPT_NUM, OPT_NDISP|OPT_NOSAVE},
+ {L("w1200"), f_w1200, OPT_NUM, OPT_NDISP|OPT_NOSAVE},
/* O_W300 4BSD */
- {"w300", f_w300, OPT_NUM, OPT_NDISP|OPT_NOSAVE},
+ {L("w300"), f_w300, OPT_NUM, OPT_NDISP|OPT_NOSAVE},
/* O_W9600 4BSD */
- {"w9600", f_w9600, OPT_NUM, OPT_NDISP|OPT_NOSAVE},
+ {L("w9600"), f_w9600, OPT_NUM, OPT_NDISP|OPT_NOSAVE},
/* O_WARN 4BSD */
- {"warn", NULL, OPT_1BOOL, 0},
+ {L("warn"), NULL, OPT_1BOOL, 0},
/* O_WINDOW 4BSD */
- {"window", f_window, OPT_NUM, 0},
+ {L("window"), f_window, OPT_NUM, 0},
/* O_WINDOWNAME 4BSD */
- {"windowname", NULL, OPT_0BOOL, 0},
+ {L("windowname"), NULL, OPT_0BOOL, 0},
/* O_WRAPLEN 4.4BSD */
- {"wraplen", NULL, OPT_NUM, 0},
+ {L("wraplen"), NULL, OPT_NUM, 0},
/* O_WRAPMARGIN 4BSD */
- {"wrapmargin", NULL, OPT_NUM, 0},
+ {L("wrapmargin"), NULL, OPT_NUM, 0},
/* O_WRAPSCAN 4BSD */
- {"wrapscan", NULL, OPT_1BOOL, 0},
+ {L("wrapscan"), NULL, OPT_1BOOL, 0},
/* O_WRITEANY 4BSD */
- {"writeany", NULL, OPT_0BOOL, 0},
+ {L("writeany"), NULL, OPT_0BOOL, 0},
{NULL},
};
typedef struct abbrev {
- char *name;
+ CHAR_T *name;
int offset;
} OABBREV;
static OABBREV const abbrev[] = {
- {"ai", O_AUTOINDENT}, /* 4BSD */
- {"ap", O_AUTOPRINT}, /* 4BSD */
- {"aw", O_AUTOWRITE}, /* 4BSD */
- {"bf", O_BEAUTIFY}, /* 4BSD */
- {"co", O_COLUMNS}, /* 4.4BSD */
- {"dir", O_DIRECTORY}, /* 4BSD */
- {"eb", O_ERRORBELLS}, /* 4BSD */
- {"ed", O_EDCOMPATIBLE}, /* 4BSD */
- {"ex", O_EXRC}, /* System V (undocumented) */
- {"ht", O_HARDTABS}, /* 4BSD */
- {"ic", O_IGNORECASE}, /* 4BSD */
- {"li", O_LINES}, /* 4.4BSD */
- {"modelines", O_MODELINE}, /* HPUX */
- {"nu", O_NUMBER}, /* 4BSD */
- {"opt", O_OPTIMIZE}, /* 4BSD */
- {"para", O_PARAGRAPHS}, /* 4BSD */
- {"re", O_REDRAW}, /* O'Reilly */
- {"ro", O_READONLY}, /* 4BSD (undocumented) */
- {"scr", O_SCROLL}, /* 4BSD (undocumented) */
- {"sect", O_SECTIONS}, /* O'Reilly */
- {"sh", O_SHELL}, /* 4BSD */
- {"slow", O_SLOWOPEN}, /* 4BSD */
- {"sm", O_SHOWMATCH}, /* 4BSD */
- {"smd", O_SHOWMODE}, /* 4BSD */
- {"sw", O_SHIFTWIDTH}, /* 4BSD */
- {"tag", O_TAGS}, /* 4BSD (undocumented) */
- {"tl", O_TAGLENGTH}, /* 4BSD */
- {"to", O_TIMEOUT}, /* 4BSD (undocumented) */
- {"ts", O_TABSTOP}, /* 4BSD */
- {"tty", O_TERM}, /* 4BSD (undocumented) */
- {"ttytype", O_TERM}, /* 4BSD (undocumented) */
- {"w", O_WINDOW}, /* O'Reilly */
- {"wa", O_WRITEANY}, /* 4BSD */
- {"wi", O_WINDOW}, /* 4BSD (undocumented) */
- {"wl", O_WRAPLEN}, /* 4.4BSD */
- {"wm", O_WRAPMARGIN}, /* 4BSD */
- {"ws", O_WRAPSCAN}, /* 4BSD */
+ {L("ai"), O_AUTOINDENT}, /* 4BSD */
+ {L("ap"), O_AUTOPRINT}, /* 4BSD */
+ {L("aw"), O_AUTOWRITE}, /* 4BSD */
+ {L("bf"), O_BEAUTIFY}, /* 4BSD */
+ {L("co"), O_COLUMNS}, /* 4.4BSD */
+ {L("dir"), O_TMPDIR}, /* 4BSD */
+ {L("eb"), O_ERRORBELLS}, /* 4BSD */
+ {L("ed"), O_EDCOMPATIBLE}, /* 4BSD */
+ {L("ex"), O_EXRC}, /* System V (undocumented) */
+ {L("fe"), O_FILEENCODING},
+ {L("ht"), O_HARDTABS}, /* 4BSD */
+ {L("ic"), O_IGNORECASE}, /* 4BSD */
+ {L("ie"), O_INPUTENCODING},
+ {L("li"), O_LINES}, /* 4.4BSD */
+ {L("modelines"), O_MODELINE}, /* HPUX */
+ {L("nu"), O_NUMBER}, /* 4BSD */
+ {L("opt"), O_OPTIMIZE}, /* 4BSD */
+ {L("para"), O_PARAGRAPHS}, /* 4BSD */
+ {L("re"), O_REDRAW}, /* O'Reilly */
+ {L("ro"), O_READONLY}, /* 4BSD (undocumented) */
+ {L("scr"), O_SCROLL}, /* 4BSD (undocumented) */
+ {L("sect"), O_SECTIONS}, /* O'Reilly */
+ {L("sh"), O_SHELL}, /* 4BSD */
+ {L("slow"), O_SLOWOPEN}, /* 4BSD */
+ {L("sm"), O_SHOWMATCH}, /* 4BSD */
+ {L("smd"), O_SHOWMODE}, /* 4BSD */
+ {L("sw"), O_SHIFTWIDTH}, /* 4BSD */
+ {L("tag"), O_TAGS}, /* 4BSD (undocumented) */
+ {L("tl"), O_TAGLENGTH}, /* 4BSD */
+ {L("to"), O_TIMEOUT}, /* 4BSD (undocumented) */
+ {L("ts"), O_TABSTOP}, /* 4BSD */
+ {L("tty"), O_TERM}, /* 4BSD (undocumented) */
+ {L("ttytype"), O_TERM}, /* 4BSD (undocumented) */
+ {L("w"), O_WINDOW}, /* O'Reilly */
+ {L("wa"), O_WRITEANY}, /* 4BSD */
+ {L("wi"), O_WINDOW}, /* 4BSD (undocumented) */
+ {L("wl"), O_WRAPLEN}, /* 4.4BSD */
+ {L("wm"), O_WRAPMARGIN}, /* 4BSD */
+ {L("ws"), O_WRAPSCAN}, /* 4BSD */
{NULL},
};
@@ -282,17 +297,18 @@ static OABBREV const abbrev[] = {
* PUBLIC: int opts_init __P((SCR *, int *));
*/
int
-opts_init(sp, oargs)
- SCR *sp;
- int *oargs;
+opts_init(
+ SCR *sp,
+ int *oargs)
{
ARGS *argv[2], a, b;
OPTLIST const *op;
u_long v;
- int cnt, optindx;
- char *s, b1[1024];
+ int cnt, optindx = 0;
+ char *s;
+ CHAR_T b2[1024];
- a.bp = b1;
+ a.bp = b2;
b.bp = NULL;
a.len = b.len = 0;
argv[0] = &a;
@@ -300,9 +316,9 @@ opts_init(sp, oargs)
/* Set numeric and string default values. */
#define OI(indx, str) { \
- if (str != b1) /* GCC puts strings in text-space. */ \
- (void)strcpy(b1, str); \
- a.len = strlen(b1); \
+ a.len = STRLEN(str); \
+ if ((CHAR_T*)str != b2) /* GCC puts strings in text-space. */ \
+ (void)MEMCPY(b2, str, a.len+1); \
if (opts_set(sp, argv, NULL)) { \
optindx = indx; \
goto err; \
@@ -327,9 +343,10 @@ opts_init(sp, oargs)
F_SET(&sp->opts[O_SECURE], OPT_GLOBAL);
/* Initialize string values. */
- (void)snprintf(b1, sizeof(b1),
- "cdpath=%s", (s = getenv("CDPATH")) == NULL ? ":" : s);
- OI(O_CDPATH, b1);
+ (void)SPRINTF(b2, SIZE(b2),
+ L("cdpath=%s"), (s = getenv("CDPATH")) == NULL ? ":" : s);
+ OI(O_CDPATH, b2);
+ OI(O_CEDIT, L("cedit=\033"));
/*
* !!!
@@ -338,30 +355,32 @@ opts_init(sp, oargs)
* are two ways to change this -- the user can set either the directory
* option or the TMPDIR environmental variable.
*/
- (void)snprintf(b1, sizeof(b1),
- "directory=%s", (s = getenv("TMPDIR")) == NULL ? _PATH_TMP : s);
- OI(O_DIRECTORY, b1);
- OI(O_ESCAPETIME, "escapetime=1");
- OI(O_KEYTIME, "keytime=6");
- OI(O_MATCHTIME, "matchtime=7");
- (void)snprintf(b1, sizeof(b1), "msgcat=%s", _PATH_MSGCAT);
- OI(O_MSGCAT, b1);
- OI(O_REPORT, "report=5");
- OI(O_PARAGRAPHS, "paragraphs=IPLPPPQPP LIpplpipbp");
- (void)snprintf(b1, sizeof(b1), "path=%s", "");
- OI(O_PATH, b1);
- (void)snprintf(b1, sizeof(b1), "recdir=%s", _PATH_PRESERVE);
- OI(O_RECDIR, b1);
- OI(O_SECTIONS, "sections=NHSHH HUnhsh");
- (void)snprintf(b1, sizeof(b1),
- "shell=%s", (s = getenv("SHELL")) == NULL ? _PATH_BSHELL : s);
- OI(O_SHELL, b1);
- OI(O_SHELLMETA, "shellmeta=~{[*?$`'\"\\");
- OI(O_SHIFTWIDTH, "shiftwidth=8");
- OI(O_SIDESCROLL, "sidescroll=16");
- OI(O_TABSTOP, "tabstop=8");
- (void)snprintf(b1, sizeof(b1), "tags=%s", _PATH_TAGS);
- OI(O_TAGS, b1);
+ (void)SPRINTF(b2, SIZE(b2),
+ L("directory=%s"), (s = getenv("TMPDIR")) == NULL ? _PATH_TMP : s);
+ OI(O_TMPDIR, b2);
+ OI(O_ESCAPETIME, L("escapetime=6"));
+ OI(O_FILEC, L("filec=\t"));
+ OI(O_KEYTIME, L("keytime=6"));
+ OI(O_MATCHCHARS, L("matchchars=()[]{}"));
+ OI(O_MATCHTIME, L("matchtime=7"));
+ (void)SPRINTF(b2, SIZE(b2), L("msgcat=%s"), _PATH_MSGCAT);
+ OI(O_MSGCAT, b2);
+ OI(O_REPORT, L("report=5"));
+ OI(O_PARAGRAPHS, L("paragraphs=IPLPPPQPP LIpplpipbp"));
+ (void)SPRINTF(b2, SIZE(b2), L("path=%s"), "");
+ OI(O_PATH, b2);
+ (void)SPRINTF(b2, SIZE(b2), L("recdir=%s"), _PATH_PRESERVE);
+ OI(O_RECDIR, b2);
+ OI(O_SECTIONS, L("sections=NHSHH HUnhsh"));
+ (void)SPRINTF(b2, SIZE(b2),
+ L("shell=%s"), (s = getenv("SHELL")) == NULL ? _PATH_BSHELL : s);
+ OI(O_SHELL, b2);
+ OI(O_SHELLMETA, L("shellmeta=~{[*?$`'\"\\"));
+ OI(O_SHIFTWIDTH, L("shiftwidth=8"));
+ OI(O_SIDESCROLL, L("sidescroll=16"));
+ OI(O_TABSTOP, L("tabstop=8"));
+ (void)SPRINTF(b2, SIZE(b2), L("tags=%s"), _PATH_TAGS);
+ OI(O_TAGS, b2);
/*
* XXX
@@ -370,8 +389,8 @@ opts_init(sp, oargs)
*/
if ((v = (O_VAL(sp, O_LINES) - 1) / 2) == 0)
v = 1;
- (void)snprintf(b1, sizeof(b1), "scroll=%ld", v);
- OI(O_SCROLL, b1);
+ (void)SPRINTF(b2, SIZE(b2), L("scroll=%ld"), v);
+ OI(O_SCROLL, b2);
/*
* The default window option values are:
@@ -388,16 +407,19 @@ opts_init(sp, oargs)
v = 8;
else if (v <= 1200)
v = 16;
- else
- v = O_VAL(sp, O_LINES) - 1;
- (void)snprintf(b1, sizeof(b1), "window=%lu", v);
- OI(O_WINDOW, b1);
+ else if ((v = O_VAL(sp, O_LINES) - 1) == 0)
+ v = 1;
+
+ (void)SPRINTF(b2, SIZE(b2), L("window=%lu"), v);
+ OI(O_WINDOW, b2);
/*
* Set boolean default values, and copy all settings into the default
* information. OS_NOFREE is set, we're copying, not replacing.
*/
- for (op = optlist, cnt = 0; op->name != NULL; ++op, ++cnt)
+ for (op = optlist, cnt = 0; op->name != NULL; ++op, ++cnt) {
+ if (F_ISSET(op, OPT_GLOBAL))
+ continue;
switch (op->type) {
case OPT_0BOOL:
break;
@@ -416,6 +438,7 @@ opts_init(sp, oargs)
default:
abort();
}
+ }
/*
* !!!
@@ -425,11 +448,11 @@ opts_init(sp, oargs)
*/
for (; *oargs != -1; ++oargs)
OI(*oargs, optlist[*oargs].name);
- return (0);
#undef OI
+ return (0);
-err: msgq(sp, M_ERR,
- "031|Unable to set default %s option", optlist[optindx].name);
+err: msgq_wstr(sp, M_ERR, optlist[optindx].name,
+ "031|Unable to set default %s option");
return (1);
}
@@ -440,18 +463,21 @@ err: msgq(sp, M_ERR,
* PUBLIC: int opts_set __P((SCR *, ARGS *[], char *));
*/
int
-opts_set(sp, argv, usage)
- SCR *sp;
- ARGS *argv[];
- char *usage;
+opts_set(
+ SCR *sp,
+ ARGS *argv[],
+ char *usage)
{
enum optdisp disp;
enum nresult nret;
OPTLIST const *op;
OPTION *spo;
- u_long value, turnoff;
+ u_long isset, turnoff, value;
int ch, equals, nf, nf2, offset, qmark, rval;
- char *endp, *name, *p, *sep, *t;
+ CHAR_T *endp, *name, *p, *sep;
+ char *p2, *t2;
+ char *np;
+ size_t nlen;
disp = NO_DISPLAY;
for (rval = 0; argv[0]->len != 0; ++argv) {
@@ -459,7 +485,7 @@ opts_set(sp, argv, usage)
* The historic vi dumped the options for each occurrence of
* "all" in the set list. Puhleeze.
*/
- if (!strcmp(argv[0]->bp, "all")) {
+ if (!STRCMP(argv[0]->bp, L("all"))) {
disp = ALL_DISPLAY;
continue;
}
@@ -521,7 +547,7 @@ opts_set(sp, argv, usage)
case OPT_1BOOL:
/* Some options may not be reset. */
if (F_ISSET(op, OPT_NOUNSET) && turnoff) {
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
"291|set: the %s option may not be turned off");
rval = 1;
break;
@@ -529,14 +555,14 @@ opts_set(sp, argv, usage)
/* Some options may not be set. */
if (F_ISSET(op, OPT_NOSET) && !turnoff) {
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
"313|set: the %s option may never be turned on");
rval = 1;
break;
}
if (equals) {
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
"034|set: [no]%s option doesn't take a value");
rval = 1;
break;
@@ -552,34 +578,34 @@ opts_set(sp, argv, usage)
* Do nothing if the value is unchanged, the underlying
* functions can be expensive.
*/
+ isset = !turnoff;
if (!F_ISSET(op, OPT_ALWAYS))
- if (turnoff) {
- if (!O_ISSET(sp, offset))
- break;
- } else {
+ if (isset) {
if (O_ISSET(sp, offset))
break;
- }
+ } else
+ if (!O_ISSET(sp, offset))
+ break;
/* Report to subsystems. */
- if (op->func != NULL &&
- op->func(sp, spo, NULL, &turnoff) ||
- ex_optchange(sp, offset, NULL, &turnoff) ||
- v_optchange(sp, offset, NULL, &turnoff) ||
- sp->gp->scr_optchange(sp, offset, NULL, &turnoff)) {
+ if ((op->func != NULL &&
+ op->func(sp, spo, NULL, &isset)) ||
+ ex_optchange(sp, offset, NULL, &isset) ||
+ v_optchange(sp, offset, NULL, &isset) ||
+ sp->gp->scr_optchange(sp, offset, NULL, &isset)) {
rval = 1;
break;
}
/* Set the value. */
- if (turnoff)
- O_CLR(sp, offset);
- else
+ if (isset)
O_SET(sp, offset);
+ else
+ O_CLR(sp, offset);
break;
case OPT_NUM:
if (turnoff) {
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
"035|set: %s option isn't a boolean");
rval = 1;
break;
@@ -591,48 +617,56 @@ opts_set(sp, argv, usage)
break;
}
- if (!isdigit(sep[0]))
+ if (!ISDIGIT(sep[0]))
goto badnum;
if ((nret =
nget_uslong(&value, sep, &endp, 10)) != NUM_OK) {
- p = msg_print(sp, name, &nf);
- t = msg_print(sp, sep, &nf2);
+ INT2CHAR(sp, name, STRLEN(name) + 1,
+ np, nlen);
+ p2 = msg_print(sp, np, &nf);
+ INT2CHAR(sp, sep, STRLEN(sep) + 1,
+ np, nlen);
+ t2 = msg_print(sp, np, &nf2);
switch (nret) {
case NUM_ERR:
msgq(sp, M_SYSERR,
- "036|set: %s option: %s", p, t);
+ "036|set: %s option: %s", p2, t2);
break;
case NUM_OVER:
msgq(sp, M_ERR,
- "037|set: %s option: %s: value overflow", p, t);
+ "037|set: %s option: %s: value overflow", p2, t2);
break;
case NUM_OK:
case NUM_UNDER:
abort();
}
if (nf)
- FREE_SPACE(sp, p, 0);
+ FREE_SPACE(sp, p2, 0);
if (nf2)
- FREE_SPACE(sp, t, 0);
+ FREE_SPACE(sp, t2, 0);
rval = 1;
break;
}
- if (*endp && !isblank(*endp)) {
-badnum: p = msg_print(sp, name, &nf);
- t = msg_print(sp, sep, &nf2);
+ if (*endp && !cmdskip(*endp)) {
+badnum: INT2CHAR(sp, name, STRLEN(name) + 1,
+ np, nlen);
+ p2 = msg_print(sp, np, &nf);
+ INT2CHAR(sp, sep, STRLEN(sep) + 1,
+ np, nlen);
+ t2 = msg_print(sp, np, &nf2);
msgq(sp, M_ERR,
- "038|set: %s option: %s is an illegal number", p, t);
+ "038|set: %s option: %s is an illegal number", p2, t2);
if (nf)
- FREE_SPACE(sp, p, 0);
+ FREE_SPACE(sp, p2, 0);
if (nf2)
- FREE_SPACE(sp, t, 0);
+ FREE_SPACE(sp, t2, 0);
rval = 1;
break;
}
/* Some options may never be set to zero. */
if (F_ISSET(op, OPT_NOZERO) && value == 0) {
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
"314|set: the %s option may never be set to 0");
rval = 1;
break;
@@ -647,11 +681,12 @@ badnum: p = msg_print(sp, name, &nf);
break;
/* Report to subsystems. */
- if (op->func != NULL &&
- op->func(sp, spo, sep, &value) ||
- ex_optchange(sp, offset, sep, &value) ||
- v_optchange(sp, offset, sep, &value) ||
- sp->gp->scr_optchange(sp, offset, sep, &value)) {
+ INT2CHAR(sp, sep, STRLEN(sep) + 1, np, nlen);
+ if ((op->func != NULL &&
+ op->func(sp, spo, np, &value)) ||
+ ex_optchange(sp, offset, np, &value) ||
+ v_optchange(sp, offset, np, &value) ||
+ sp->gp->scr_optchange(sp, offset, np, &value)) {
rval = 1;
break;
}
@@ -662,7 +697,7 @@ badnum: p = msg_print(sp, name, &nf);
break;
case OPT_STR:
if (turnoff) {
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
"039|set: %s option isn't a boolean");
rval = 1;
break;
@@ -674,27 +709,36 @@ badnum: p = msg_print(sp, name, &nf);
break;
}
+ /* Check for strings that must have even length. */
+ if (F_ISSET(op, OPT_PAIRS) && STRLEN(sep) & 1) {
+ msgq_wstr(sp, M_ERR, name,
+ "047|The %s option must be in two character groups");
+ rval = 1;
+ break;
+ }
+
/*
* Do nothing if the value is unchanged, the underlying
* functions can be expensive.
*/
+ INT2CHAR(sp, sep, STRLEN(sep) + 1, np, nlen);
if (!F_ISSET(op, OPT_ALWAYS) &&
O_STR(sp, offset) != NULL &&
- !strcmp(O_STR(sp, offset), sep))
+ !strcmp(O_STR(sp, offset), np))
break;
/* Report to subsystems. */
- if (op->func != NULL &&
- op->func(sp, spo, sep, NULL) ||
- ex_optchange(sp, offset, sep, NULL) ||
- v_optchange(sp, offset, sep, NULL) ||
- sp->gp->scr_optchange(sp, offset, sep, NULL)) {
+ if ((op->func != NULL &&
+ op->func(sp, spo, np, NULL)) ||
+ ex_optchange(sp, offset, np, NULL) ||
+ v_optchange(sp, offset, np, NULL) ||
+ sp->gp->scr_optchange(sp, offset, np, NULL)) {
rval = 1;
break;
}
/* Set the value. */
- if (o_set(sp, offset, OS_STRDUP, sep, 0))
+ if (o_set(sp, offset, OS_STRDUP, np, 0))
rval = 1;
break;
default:
@@ -713,12 +757,12 @@ badnum: p = msg_print(sp, name, &nf);
* PUBLIC: int o_set __P((SCR *, int, u_int, char *, u_long));
*/
int
-o_set(sp, opt, flags, str, val)
- SCR *sp;
- int opt;
- u_int flags;
- char *str;
- u_long val;
+o_set(
+ SCR *sp,
+ int opt,
+ u_int flags,
+ char *str,
+ u_long val)
{
OPTION *op;
@@ -757,15 +801,16 @@ o_set(sp, opt, flags, str, val)
* PUBLIC: int opts_empty __P((SCR *, int, int));
*/
int
-opts_empty(sp, off, silent)
- SCR *sp;
- int off, silent;
+opts_empty(
+ SCR *sp,
+ int off,
+ int silent)
{
char *p;
if ((p = O_STR(sp, off)) == NULL || p[0] == '\0') {
if (!silent)
- msgq_str(sp, M_ERR, optlist[off].name,
+ msgq_wstr(sp, M_ERR, optlist[off].name,
"305|No %s edit option specified");
return (1);
}
@@ -779,9 +824,9 @@ opts_empty(sp, off, silent)
* PUBLIC: void opts_dump __P((SCR *, enum optdisp));
*/
void
-opts_dump(sp, type)
- SCR *sp;
- enum optdisp type;
+opts_dump(
+ SCR *sp,
+ enum optdisp type)
{
OPTLIST const *op;
int base, b_num, cnt, col, colwidth, curlen, s_num;
@@ -836,8 +881,8 @@ opts_dump(sp, type)
break;
case OPT_STR:
if (O_STR(sp, cnt) == O_D_STR(sp, cnt) ||
- O_D_STR(sp, cnt) != NULL &&
- !strcmp(O_STR(sp, cnt), O_D_STR(sp, cnt)))
+ (O_D_STR(sp, cnt) != NULL &&
+ !strcmp(O_STR(sp, cnt), O_D_STR(sp, cnt))))
continue;
break;
}
@@ -852,7 +897,7 @@ opts_dump(sp, type)
}
F_CLR(&sp->opts[cnt], OPT_SELECTED);
- curlen = strlen(op->name);
+ curlen = STRLEN(op->name);
switch (op->type) {
case OPT_0BOOL:
case OPT_1BOOL:
@@ -913,9 +958,9 @@ opts_dump(sp, type)
* Print out an option.
*/
static int
-opts_print(sp, op)
- SCR *sp;
- OPTLIST const *op;
+opts_print(
+ SCR *sp,
+ OPTLIST const *op)
{
int curlen, offset;
@@ -925,13 +970,13 @@ opts_print(sp, op)
case OPT_0BOOL:
case OPT_1BOOL:
curlen += ex_printf(sp,
- "%s%s", O_ISSET(sp, offset) ? "" : "no", op->name);
+ "%s"WS, O_ISSET(sp, offset) ? "" : "no", op->name);
break;
case OPT_NUM:
- curlen += ex_printf(sp, "%s=%ld", op->name, O_VAL(sp, offset));
+ curlen += ex_printf(sp, WS"=%ld", op->name, O_VAL(sp, offset));
break;
case OPT_STR:
- curlen += ex_printf(sp, "%s=\"%s\"", op->name,
+ curlen += ex_printf(sp, WS"=\"%s\"", op->name,
O_STR(sp, offset) == NULL ? "" : O_STR(sp, offset));
break;
}
@@ -945,13 +990,14 @@ opts_print(sp, op)
* PUBLIC: int opts_save __P((SCR *, FILE *));
*/
int
-opts_save(sp, fp)
- SCR *sp;
- FILE *fp;
+opts_save(
+ SCR *sp,
+ FILE *fp)
{
OPTLIST const *op;
- int ch, cnt;
- char *p;
+ CHAR_T ch, *p;
+ char nch, *np;
+ int cnt;
for (op = optlist; op->name != NULL; ++op) {
if (F_ISSET(op, OPT_NOSAVE))
@@ -961,28 +1007,28 @@ opts_save(sp, fp)
case OPT_0BOOL:
case OPT_1BOOL:
if (O_ISSET(sp, cnt))
- (void)fprintf(fp, "set %s\n", op->name);
+ (void)fprintf(fp, "set "WS"\n", op->name);
else
- (void)fprintf(fp, "set no%s\n", op->name);
+ (void)fprintf(fp, "set no"WS"\n", op->name);
break;
case OPT_NUM:
(void)fprintf(fp,
- "set %s=%-3ld\n", op->name, O_VAL(sp, cnt));
+ "set "WS"=%-3ld\n", op->name, O_VAL(sp, cnt));
break;
case OPT_STR:
if (O_STR(sp, cnt) == NULL)
break;
(void)fprintf(fp, "set ");
for (p = op->name; (ch = *p) != '\0'; ++p) {
- if (isblank(ch) || ch == '\\')
+ if (cmdskip(ch) || ch == '\\')
(void)putc('\\', fp);
- (void)putc(ch, fp);
+ fprintf(fp, WC, ch);
}
(void)putc('=', fp);
- for (p = O_STR(sp, cnt); (ch = *p) != '\0'; ++p) {
- if (isblank(ch) || ch == '\\')
+ for (np = O_STR(sp, cnt); (nch = *np) != '\0'; ++np) {
+ if (cmdskip(nch) || nch == '\\')
(void)putc('\\', fp);
- (void)putc(ch, fp);
+ (void)putc(nch, fp);
}
(void)putc('\n', fp);
break;
@@ -999,11 +1045,10 @@ opts_save(sp, fp)
* opts_search --
* Search for an option.
*
- * PUBLIC: OPTLIST const *opts_search __P((char *));
+ * PUBLIC: OPTLIST const *opts_search __P((CHAR_T *));
*/
OPTLIST const *
-opts_search(name)
- char *name;
+opts_search(CHAR_T *name)
{
OPTLIST const *op, *found;
OABBREV atmp, *ap;
@@ -1026,13 +1071,13 @@ opts_search(name)
* Check to see if the name is the prefix of one (and only one)
* option. If so, return the option.
*/
- len = strlen(name);
+ len = STRLEN(name);
for (found = NULL, op = optlist; op->name != NULL; ++op) {
if (op->name[0] < name[0])
continue;
if (op->name[0] > name[0])
break;
- if (!memcmp(op->name, name, len)) {
+ if (!MEMCMP(op->name, name, len)) {
if (found != NULL)
return (NULL);
found = op;
@@ -1045,29 +1090,31 @@ opts_search(name)
* opts_nomatch --
* Standard nomatch error message for options.
*
- * PUBLIC: void opts_nomatch __P((SCR *, char *));
+ * PUBLIC: void opts_nomatch __P((SCR *, CHAR_T *));
*/
void
-opts_nomatch(sp, name)
- SCR *sp;
- char *name;
+opts_nomatch(
+ SCR *sp,
+ CHAR_T *name)
{
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
"033|set: no %s option: 'set all' gives all option values");
}
static int
-opts_abbcmp(a, b)
- const void *a, *b;
+opts_abbcmp(
+ const void *a,
+ const void *b)
{
- return(strcmp(((OABBREV *)a)->name, ((OABBREV *)b)->name));
+ return(STRCMP(((OABBREV *)a)->name, ((OABBREV *)b)->name));
}
static int
-opts_cmp(a, b)
- const void *a, *b;
+opts_cmp(
+ const void *a,
+ const void *b)
{
- return(strcmp(((OPTLIST *)a)->name, ((OPTLIST *)b)->name));
+ return(STRCMP(((OPTLIST *)a)->name, ((OPTLIST *)b)->name));
}
/*
@@ -1077,8 +1124,9 @@ opts_cmp(a, b)
* PUBLIC: int opts_copy __P((SCR *, SCR *));
*/
int
-opts_copy(orig, sp)
- SCR *orig, *sp;
+opts_copy(
+ SCR *orig,
+ SCR *sp)
{
int cnt, rval;
@@ -1088,7 +1136,7 @@ opts_copy(orig, sp)
/* Copy the string edit options. */
for (cnt = rval = 0; cnt < O_OPTIONCOUNT; ++cnt) {
if (optlist[cnt].type != OPT_STR ||
- F_ISSET(&optlist[cnt], OPT_GLOBAL))
+ F_ISSET(&sp->opts[cnt], OPT_GLOBAL))
continue;
/*
* If never set, or already failed, NULL out the entries --
@@ -1124,14 +1172,13 @@ nomem: msgq(orig, M_SYSERR, NULL);
* PUBLIC: void opts_free __P((SCR *));
*/
void
-opts_free(sp)
- SCR *sp;
+opts_free(SCR *sp)
{
int cnt;
for (cnt = 0; cnt < O_OPTIONCOUNT; ++cnt) {
if (optlist[cnt].type != OPT_STR ||
- F_ISSET(&optlist[cnt], OPT_GLOBAL))
+ F_ISSET(&sp->opts[cnt], OPT_GLOBAL))
continue;
if (O_STR(sp, cnt) != NULL)
free(O_STR(sp, cnt));
diff --git a/common/options.h b/common/options.h
index 2646dc301b5a..fe1f80f5f16d 100644
--- a/common/options.h
+++ b/common/options.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)options.h 10.19 (Berkeley) 10/10/96
+ * $Id: options.h,v 10.21 2012/02/10 20:24:58 zy Exp $
*/
/*
@@ -76,7 +76,7 @@ struct _option {
/* List of option names, associated update functions and information. */
struct _optlist {
- char *name; /* Name. */
+ CHAR_T *name; /* Name. */
/* Change function. */
int (*func) __P((SCR *, OPTION *, char *, u_long *));
/* Type of object. */
@@ -89,6 +89,7 @@ struct _optlist {
#define OPT_NOSET 0x010 /* Option may not be set. */
#define OPT_NOUNSET 0x020 /* Option may not be unset. */
#define OPT_NOZERO 0x040 /* Option may not be set to 0. */
+#define OPT_PAIRS 0x080 /* String with even length. */
u_int8_t flags;
};
diff --git a/common/options_def.h b/common/options_def.h
new file mode 100644
index 000000000000..8e232786cfe6
--- /dev/null
+++ b/common/options_def.h
@@ -0,0 +1,83 @@
+#define O_ALTWERASE 0
+#define O_AUTOINDENT 1
+#define O_AUTOPRINT 2
+#define O_AUTOWRITE 3
+#define O_BACKUP 4
+#define O_BEAUTIFY 5
+#define O_CDPATH 6
+#define O_CEDIT 7
+#define O_COLUMNS 8
+#define O_COMBINED 9
+#define O_COMMENT 10
+#define O_TMPDIR 11
+#define O_EDCOMPATIBLE 12
+#define O_ERRORBELLS 13
+#define O_ESCAPETIME 14
+#define O_EXRC 15
+#define O_EXTENDED 16
+#define O_FILEC 17
+#define O_FILEENCODING 18
+#define O_FLASH 19
+#define O_HARDTABS 20
+#define O_ICLOWER 21
+#define O_IGNORECASE 22
+#define O_INPUTENCODING 23
+#define O_KEYTIME 24
+#define O_LEFTRIGHT 25
+#define O_LINES 26
+#define O_LISP 27
+#define O_LIST 28
+#define O_LOCKFILES 29
+#define O_MAGIC 30
+#define O_MATCHCHARS 31
+#define O_MATCHTIME 32
+#define O_MESG 33
+#define O_MODELINE 34
+#define O_MSGCAT 35
+#define O_NOPRINT 36
+#define O_NUMBER 37
+#define O_OCTAL 38
+#define O_OPEN 39
+#define O_OPTIMIZE 40
+#define O_PARAGRAPHS 41
+#define O_PATH 42
+#define O_PRINT 43
+#define O_PROMPT 44
+#define O_READONLY 45
+#define O_RECDIR 46
+#define O_REDRAW 47
+#define O_REMAP 48
+#define O_REPORT 49
+#define O_RULER 50
+#define O_SCROLL 51
+#define O_SEARCHINCR 52
+#define O_SECTIONS 53
+#define O_SECURE 54
+#define O_SHELL 55
+#define O_SHELLMETA 56
+#define O_SHIFTWIDTH 57
+#define O_SHOWMATCH 58
+#define O_SHOWMODE 59
+#define O_SIDESCROLL 60
+#define O_SLOWOPEN 61
+#define O_SOURCEANY 62
+#define O_TABSTOP 63
+#define O_TAGLENGTH 64
+#define O_TAGS 65
+#define O_TERM 66
+#define O_TERSE 67
+#define O_TILDEOP 68
+#define O_TIMEOUT 69
+#define O_TTYWERASE 70
+#define O_VERBOSE 71
+#define O_W1200 72
+#define O_W300 73
+#define O_W9600 74
+#define O_WARN 75
+#define O_WINDOW 76
+#define O_WINDOWNAME 77
+#define O_WRAPLEN 78
+#define O_WRAPMARGIN 79
+#define O_WRAPSCAN 80
+#define O_WRITEANY 81
+#define O_OPTIONCOUNT 82
diff --git a/common/options_f.c b/common/options_f.c
index ea3c61160cf5..482a37e39d39 100644
--- a/common/options_f.c
+++ b/common/options_f.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)options_f.c 10.25 (Berkeley) 7/12/96";
+static const char sccsid[] = "$Id: options_f.c,v 10.34 04/07/11 16:06:29 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -32,13 +32,13 @@ static const char sccsid[] = "@(#)options_f.c 10.25 (Berkeley) 7/12/96";
* PUBLIC: int f_altwerase __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_altwerase(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_altwerase(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
- if (!*valp)
+ if (*valp)
O_CLR(sp, O_TTYWERASE);
return (0);
}
@@ -47,11 +47,11 @@ f_altwerase(sp, op, str, valp)
* PUBLIC: int f_columns __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_columns(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_columns(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
/* Validate the number. */
if (*valp < MINIMUM_SCREEN_COLS) {
@@ -81,11 +81,11 @@ f_columns(sp, op, str, valp)
* PUBLIC: int f_lines __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_lines(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_lines(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
/* Validate the number. */
if (*valp < MINIMUM_SCREEN_ROWS) {
@@ -138,11 +138,11 @@ f_lines(sp, op, str, valp)
* PUBLIC: int f_lisp __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_lisp(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_lisp(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
msgq(sp, M_ERR, "044|The lisp option is not implemented");
return (0);
@@ -152,44 +152,37 @@ f_lisp(sp, op, str, valp)
* PUBLIC: int f_msgcat __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_msgcat(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_msgcat(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
(void)msg_open(sp, str);
return (0);
}
/*
- * PUBLIC: int f_paragraph __P((SCR *, OPTION *, char *, u_long *));
- */
-int
-f_paragraph(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
-{
- if (strlen(str) & 1) {
- msgq(sp, M_ERR,
- "048|The paragraph option must be in two character groups");
- return (1);
- }
- return (0);
-}
-
-/*
* PUBLIC: int f_print __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_print(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_print(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
+ int offset = op - sp->opts;
+
+ /* Preset the value, needed for reinitialization of lookup table. */
+ if (offset == O_OCTAL) {
+ if (*valp)
+ O_SET(sp, offset);
+ else
+ O_CLR(sp, offset);
+ } else if (o_set(sp, offset, OS_STRDUP, str, 0))
+ return(1);
+
/* Reinitialize the key fast lookup table. */
v_key_ilookup(sp);
@@ -202,20 +195,20 @@ f_print(sp, op, str, valp)
* PUBLIC: int f_readonly __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_readonly(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_readonly(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
/*
* !!!
* See the comment in exf.c.
*/
if (*valp)
- F_CLR(sp, SC_READONLY);
- else
F_SET(sp, SC_READONLY);
+ else
+ F_CLR(sp, SC_READONLY);
return (0);
}
@@ -223,11 +216,11 @@ f_readonly(sp, op, str, valp)
* PUBLIC: int f_recompile __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_recompile(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_recompile(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
if (F_ISSET(sp, SC_RE_SEARCH)) {
regfree(&sp->re_c);
@@ -244,45 +237,27 @@ f_recompile(sp, op, str, valp)
* PUBLIC: int f_reformat __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_reformat(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_reformat(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
F_SET(sp, SC_SCR_REFORMAT);
return (0);
}
/*
- * PUBLIC: int f_section __P((SCR *, OPTION *, char *, u_long *));
- */
-int
-f_section(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
-{
- if (strlen(str) & 1) {
- msgq(sp, M_ERR,
- "049|The section option must be in two character groups");
- return (1);
- }
- return (0);
-}
-
-/*
* PUBLIC: int f_ttywerase __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_ttywerase(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_ttywerase(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
- if (!*valp)
+ if (*valp)
O_CLR(sp, O_ALTWERASE);
return (0);
}
@@ -291,11 +266,11 @@ f_ttywerase(sp, op, str, valp)
* PUBLIC: int f_w300 __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_w300(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_w300(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
u_long v;
@@ -312,11 +287,11 @@ f_w300(sp, op, str, valp)
* PUBLIC: int f_w1200 __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_w1200(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_w1200(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
u_long v;
@@ -333,11 +308,11 @@ f_w1200(sp, op, str, valp)
* PUBLIC: int f_w9600 __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_w9600(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_w9600(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
u_long v;
@@ -354,14 +329,29 @@ f_w9600(sp, op, str, valp)
* PUBLIC: int f_window __P((SCR *, OPTION *, char *, u_long *));
*/
int
-f_window(sp, op, str, valp)
- SCR *sp;
- OPTION *op;
- char *str;
- u_long *valp;
+f_window(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
{
if (*valp >= O_VAL(sp, O_LINES) - 1 &&
(*valp = O_VAL(sp, O_LINES) - 1) == 0)
*valp = 1;
return (0);
}
+
+/*
+ * PUBLIC: int f_encoding __P((SCR *, OPTION *, char *, u_long *));
+ */
+int
+f_encoding(
+ SCR *sp,
+ OPTION *op,
+ char *str,
+ u_long *valp)
+{
+ int offset = op - sp->opts;
+
+ return conv_enc(sp, offset, str);
+}
diff --git a/common/put.c b/common/put.c
index 8c0ca4b7c14f..6e9dc09902de 100644
--- a/common/put.c
+++ b/common/put.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)put.c 10.11 (Berkeley) 9/23/96";
+static const char sccsid[] = "$Id: put.c,v 10.19 04/07/11 17:00:24 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -32,19 +33,21 @@ static const char sccsid[] = "@(#)put.c 10.11 (Berkeley) 9/23/96";
* PUBLIC: int put __P((SCR *, CB *, CHAR_T *, MARK *, MARK *, int));
*/
int
-put(sp, cbp, namep, cp, rp, append)
- SCR *sp;
- CB *cbp;
- CHAR_T *namep;
- MARK *cp, *rp;
- int append;
+put(
+ SCR *sp,
+ CB *cbp,
+ CHAR_T *namep,
+ MARK *cp,
+ MARK *rp,
+ int append)
{
CHAR_T name;
TEXT *ltp, *tp;
recno_t lno;
size_t blen, clen, len;
int rval;
- char *bp, *p, *t;
+ CHAR_T *bp, *t;
+ CHAR_T *p;
if (cbp == NULL)
if (namep == NULL) {
@@ -63,7 +66,7 @@ put(sp, cbp, namep, cp, rp, append)
return (1);
}
}
- tp = cbp->textq.cqh_first;
+ tp = TAILQ_FIRST(cbp->textq);
/*
* It's possible to do a put into an empty file, meaning that the cut
@@ -84,8 +87,8 @@ put(sp, cbp, namep, cp, rp, append)
if (db_last(sp, &lno))
return (1);
if (lno == 0) {
- for (; tp != (void *)&cbp->textq;
- ++lno, ++sp->rptlines[L_ADDED], tp = tp->q.cqe_next)
+ for (; tp != NULL;
+ ++lno, ++sp->rptlines[L_ADDED], tp = TAILQ_NEXT(tp, q))
if (db_append(sp, 1, lno, tp->lb, tp->len))
return (1);
rp->lno = 1;
@@ -98,8 +101,8 @@ put(sp, cbp, namep, cp, rp, append)
if (F_ISSET(cbp, CB_LMODE)) {
lno = append ? cp->lno : cp->lno - 1;
rp->lno = lno + 1;
- for (; tp != (void *)&cbp->textq;
- ++lno, ++sp->rptlines[L_ADDED], tp = tp->q.cqe_next)
+ for (; tp != NULL;
+ ++lno, ++sp->rptlines[L_ADDED], tp = TAILQ_NEXT(tp, q))
if (db_append(sp, 1, lno, tp->lb, tp->len))
return (1);
rp->cno = 0;
@@ -120,19 +123,19 @@ put(sp, cbp, namep, cp, rp, append)
if (db_get(sp, lno, DBG_FATAL, &p, &len))
return (1);
- GET_SPACE_RET(sp, bp, blen, tp->len + len + 1);
+ GET_SPACE_RETW(sp, bp, blen, tp->len + len + 1);
t = bp;
/* Original line, left of the split. */
if (len > 0 && (clen = cp->cno + (append ? 1 : 0)) > 0) {
- memcpy(bp, p, clen);
+ MEMCPY(bp, p, clen);
p += clen;
t += clen;
}
/* First line from the CB. */
if (tp->len != 0) {
- memcpy(t, tp->lb, tp->len);
+ MEMCPY(t, tp->lb, tp->len);
t += tp->len;
}
@@ -161,9 +164,9 @@ put(sp, cbp, namep, cp, rp, append)
* the intermediate lines, because the line changes will lose
* the cached line.
*/
- if (tp->q.cqe_next == (void *)&cbp->textq) {
+ if (TAILQ_NEXT(tp, q) == NULL) {
if (clen > 0) {
- memcpy(t, p, clen);
+ MEMCPY(t, p, clen);
t += clen;
}
if (db_set(sp, lno, bp, t - bp))
@@ -183,15 +186,15 @@ put(sp, cbp, namep, cp, rp, append)
* Last part of original line; check for space, reset
* the pointer into the buffer.
*/
- ltp = cbp->textq.cqh_last;
+ ltp = TAILQ_LAST(cbp->textq, _texth);
len = t - bp;
- ADD_SPACE_RET(sp, bp, blen, ltp->len + clen);
+ ADD_SPACE_RETW(sp, bp, blen, ltp->len + clen);
t = bp + len;
/* Add in last part of the CB. */
- memcpy(t, ltp->lb, ltp->len);
+ MEMCPY(t, ltp->lb, ltp->len);
if (clen)
- memcpy(t + ltp->len, p, clen);
+ MEMCPY(t + ltp->len, p, clen);
clen += ltp->len;
/*
@@ -211,9 +214,8 @@ put(sp, cbp, namep, cp, rp, append)
}
/* Output any intermediate lines in the CB. */
- for (tp = tp->q.cqe_next;
- tp->q.cqe_next != (void *)&cbp->textq;
- ++lno, ++sp->rptlines[L_ADDED], tp = tp->q.cqe_next)
+ for (tp = TAILQ_NEXT(tp, q); TAILQ_NEXT(tp, q) != NULL;
+ ++lno, ++sp->rptlines[L_ADDED], tp = TAILQ_NEXT(tp, q))
if (db_append(sp, 1, lno, tp->lb, tp->len))
goto err;
@@ -226,6 +228,6 @@ put(sp, cbp, namep, cp, rp, append)
if (0)
err: rval = 1;
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
return (rval);
}
diff --git a/common/recover.c b/common/recover.c
index f3abaab5a536..b20471f111b2 100644
--- a/common/recover.c
+++ b/common/recover.c
@@ -10,11 +10,10 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)recover.c 10.21 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: recover.c,v 11.2 2012/10/09 08:06:58 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
-#include <sys/types.h> /* XXX: param.h may not have included types.h */
+#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -31,12 +30,15 @@ static const char sccsid[] = "@(#)recover.c 10.21 (Berkeley) 9/15/96";
#include <fcntl.h>
#include <limits.h>
#include <pwd.h>
+#include <netinet/in.h> /* Required by resolv.h. */
+#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include "../ex/version.h"
#include "common.h"
#include "pathnames.h"
@@ -57,12 +59,7 @@ static const char sccsid[] = "@(#)recover.c 10.21 (Berkeley) 9/15/96";
* file exists, and is exclusively locked.
*
* In the EXF structure we maintain a file descriptor that is the locked
- * file descriptor for the mail recovery file. NOTE: we sometimes have to
- * do locking with fcntl(2). This is a problem because if you close(2) any
- * file descriptor associated with the file, ALL of the locks go away. Be
- * sure to remember that if you have to modify the recovery code. (It has
- * been rhetorically asked of what the designers could have been thinking
- * when they did that interface. The answer is simple: they weren't.)
+ * file descriptor for the mail recovery file.
*
* To find out if a recovery file/backing file pair are in use, try to get
* a lock on the recovery file.
@@ -93,27 +90,24 @@ static const char sccsid[] = "@(#)recover.c 10.21 (Berkeley) 9/15/96";
* means that the data structures (SCR, EXF, the underlying tree structures)
* must be consistent when the signal arrives.
*
- * The recovery mail file contains normal mail headers, with two additions,
- * which occur in THIS order, as the FIRST TWO headers:
+ * The recovery mail file contains normal mail headers, with two additional
*
- * X-vi-recover-file: file_name
- * X-vi-recover-path: recover_path
+ * X-vi-data: <file|path>;<base64 encoded path>
*
- * Since newlines delimit the headers, this means that file names cannot have
- * newlines in them, but that's probably okay. As these files aren't intended
- * to be long-lived, changing their format won't be too painful.
+ * MIME headers; the folding character is limited to ' '.
*
- * Btree files are named "vi.XXXX" and recovery files are named "recover.XXXX".
+ * Btree files are named "vi.XXXXXX" and recovery files are named
+ * "recover.XXXXXX".
*/
-#define VI_FHEADER "X-vi-recover-file: "
-#define VI_PHEADER "X-vi-recover-path: "
+#define VI_DHEADER "X-vi-data:"
static int rcv_copy __P((SCR *, int, char *));
static void rcv_email __P((SCR *, char *));
-static char *rcv_gets __P((char *, size_t, int));
static int rcv_mailfile __P((SCR *, int, char *));
-static int rcv_mktemp __P((SCR *, char *, char *, int));
+static int rcv_mktemp __P((SCR *, char *, char *));
+static int rcv_dlnwrite __P((SCR *, const char *, const char *, FILE *));
+static int rcv_dlnread __P((SCR *, char **, char **, FILE *));
/*
* rcv_tmp --
@@ -122,14 +116,14 @@ static int rcv_mktemp __P((SCR *, char *, char *, int));
* PUBLIC: int rcv_tmp __P((SCR *, EXF *, char *));
*/
int
-rcv_tmp(sp, ep, name)
- SCR *sp;
- EXF *ep;
- char *name;
+rcv_tmp(
+ SCR *sp,
+ EXF *ep,
+ char *name)
{
struct stat sb;
int fd;
- char *dp, *p, path[MAXPATHLEN];
+ char *dp, *path;
/*
* !!!
@@ -153,22 +147,17 @@ rcv_tmp(sp, ep, name)
(void)chmod(dp, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
}
- /* Newlines delimit the mail messages. */
- for (p = name; *p; ++p)
- if (*p == '\n') {
- msgq(sp, M_ERR,
- "055|Files with newlines in the name are unrecoverable");
- goto err;
- }
-
- (void)snprintf(path, sizeof(path), "%s/vi.XXXXXX", dp);
- if ((fd = rcv_mktemp(sp, path, dp, S_IRWXU)) == -1)
+ if ((path = join(dp, "vi.XXXXXX")) == NULL)
goto err;
+ if ((fd = rcv_mktemp(sp, path, dp)) == -1) {
+ free(path);
+ goto err;
+ }
+ (void)fchmod(fd, S_IRWXU);
(void)close(fd);
- if ((ep->rcv_path = strdup(path)) == NULL) {
- msgq(sp, M_SYSERR, NULL);
- (void)unlink(path);
+ ep->rcv_path = path;
+ if (0) {
err: msgq(sp, M_ERR,
"056|Modifications not recoverable if the session fails");
return (1);
@@ -186,8 +175,7 @@ err: msgq(sp, M_ERR,
* PUBLIC: int rcv_init __P((SCR *));
*/
int
-rcv_init(sp)
- SCR *sp;
+rcv_init(SCR *sp)
{
EXF *ep;
recno_t lno;
@@ -249,13 +237,13 @@ err: msgq(sp, M_ERR,
* PUBLIC: int rcv_sync __P((SCR *, u_int));
*/
int
-rcv_sync(sp, flags)
- SCR *sp;
- u_int flags;
+rcv_sync(
+ SCR *sp,
+ u_int flags)
{
EXF *ep;
int fd, rval;
- char *dp, buf[1024];
+ char *dp, *buf;
/* Make sure that there's something to recover/sync. */
ep = sp->ep;
@@ -298,9 +286,14 @@ rcv_sync(sp, flags)
if (opts_empty(sp, O_RECDIR, 0))
goto err;
dp = O_STR(sp, O_RECDIR);
- (void)snprintf(buf, sizeof(buf), "%s/vi.XXXXXX", dp);
- if ((fd = rcv_mktemp(sp, buf, dp, S_IRUSR | S_IWUSR)) == -1)
+ if ((buf = join(dp, "vi.XXXXXX")) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ goto err;
+ }
+ if ((fd = rcv_mktemp(sp, buf, dp)) == -1) {
+ free(buf);
goto err;
+ }
sp->gp->scr_busy(sp,
"061|Copying file for recovery...", BUSY_ON);
if (rcv_copy(sp, fd, ep->rcv_path) ||
@@ -309,6 +302,7 @@ rcv_sync(sp, flags)
(void)close(fd);
rval = 1;
}
+ free(buf);
sp->gp->scr_busy(sp, NULL, BUSY_OFF);
}
if (0) {
@@ -327,30 +321,32 @@ err: rval = 1;
* Build the file to mail to the user.
*/
static int
-rcv_mailfile(sp, issync, cp_path)
- SCR *sp;
- int issync;
- char *cp_path;
+rcv_mailfile(
+ SCR *sp,
+ int issync,
+ char *cp_path)
{
EXF *ep;
GS *gp;
struct passwd *pw;
- size_t len;
+ int len;
time_t now;
uid_t uid;
int fd;
- char *dp, *p, *t, buf[4096], mpath[MAXPATHLEN];
+ FILE *fp;
+ char *dp, *p, *t, *qt, *buf, *mpath;
char *t1, *t2, *t3;
+ int st;
/*
* XXX
- * MAXHOSTNAMELEN is in various places on various systems, including
- * <netdb.h> and <sys/socket.h>. If not found, use a large default.
+ * MAXHOSTNAMELEN/HOST_NAME_MAX are deprecated. We try sysconf(3)
+ * first, then fallback to _POSIX_HOST_NAME_MAX.
*/
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 1024
-#endif
- char host[MAXHOSTNAMELEN];
+ char *host;
+ long hostmax = sysconf(_SC_HOST_NAME_MAX);
+ if (hostmax < 0)
+ hostmax = _POSIX_HOST_NAME_MAX;
gp = sp->gp;
if ((pw = getpwuid(uid = getuid())) == NULL) {
@@ -362,9 +358,19 @@ rcv_mailfile(sp, issync, cp_path)
if (opts_empty(sp, O_RECDIR, 0))
return (1);
dp = O_STR(sp, O_RECDIR);
- (void)snprintf(mpath, sizeof(mpath), "%s/recover.XXXXXX", dp);
- if ((fd = rcv_mktemp(sp, mpath, dp, S_IRUSR | S_IWUSR)) == -1)
+ if ((mpath = join(dp, "recover.XXXXXX")) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
+ if ((fd = rcv_mktemp(sp, mpath, dp)) == -1) {
+ free(mpath);
return (1);
+ }
+ if ((fp = fdopen(fd, "w")) == NULL) {
+ free(mpath);
+ close(fd);
+ return (1);
+ }
/*
* XXX
@@ -374,56 +380,64 @@ rcv_mailfile(sp, issync, cp_path)
* and the lock, but it's pretty small.
*/
ep = sp->ep;
- if (file_lock(sp, NULL, NULL, fd, 1) != LOCK_SUCCESS)
+ if (file_lock(sp, NULL, fd, 1) != LOCK_SUCCESS)
msgq(sp, M_SYSERR, "063|Unable to lock recovery file");
if (!issync) {
/* Save the recover file descriptor, and mail path. */
- ep->rcv_fd = fd;
- if ((ep->rcv_mpath = strdup(mpath)) == NULL) {
- msgq(sp, M_SYSERR, NULL);
- goto err;
- }
+ ep->rcv_fd = dup(fd);
+ ep->rcv_mpath = mpath;
cp_path = ep->rcv_path;
}
- /*
- * XXX
- * We can't use stdio(3) here. The problem is that we may be using
- * fcntl(2), so if ANY file descriptor into the file is closed, the
- * lock is lost. So, we could never close the FILE *, even if we
- * dup'd the fd first.
- */
t = sp->frp->name;
if ((p = strrchr(t, '/')) == NULL)
p = t;
else
++p;
(void)time(&now);
- (void)gethostname(host, sizeof(host));
- len = snprintf(buf, sizeof(buf),
- "%s%s\n%s%s\n%s\n%s\n%s%s\n%s%s\n%s\n\n",
- VI_FHEADER, t, /* Non-standard. */
- VI_PHEADER, cp_path, /* Non-standard. */
- "Reply-To: root",
- "From: root (Nvi recovery program)",
- "To: ", pw->pw_name,
+
+ if ((st = rcv_dlnwrite(sp, "file", t, fp))) {
+ if (st == 1)
+ goto werr;
+ goto err;
+ }
+ if ((st = rcv_dlnwrite(sp, "path", cp_path, fp))) {
+ if (st == 1)
+ goto werr;
+ goto err;
+ }
+
+ MALLOC(sp, host, char *, hostmax + 1);
+ if (host == NULL)
+ goto err;
+ (void)gethostname(host, hostmax + 1);
+
+ len = fprintf(fp, "%s%s%s\n%s%s%s%s\n%s%.40s\n%s\n\n",
+ "From: root@", host, " (Nvi recovery program)",
+ "To: ", pw->pw_name, "@", host,
"Subject: Nvi saved the file ", p,
"Precedence: bulk"); /* For vacation(1). */
- if (len > sizeof(buf) - 1)
- goto lerr;
- if (write(fd, buf, len) != len)
+ if (len < 0) {
+ free(host);
goto werr;
+ }
- len = snprintf(buf, sizeof(buf),
- "%s%.24s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n\n",
+ if ((qt = quote(t)) == NULL) {
+ free(host);
+ msgq(sp, M_SYSERR, NULL);
+ goto err;
+ }
+ len = asprintf(&buf, "%s%.24s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n\n",
"On ", ctime(&now), ", the user ", pw->pw_name,
" was editing a file named ", t, " on the machine ",
host, ", when it was saved for recovery. ",
"You can recover most, if not all, of the changes ",
"to this file using the -r option to ", gp->progname, ":\n\n\t",
- gp->progname, " -r ", t);
- if (len > sizeof(buf) - 1) {
-lerr: msgq(sp, M_ERR, "064|Recovery file buffer overrun");
+ gp->progname, " -r ", qt);
+ free(qt);
+ free(host);
+ if (buf == NULL) {
+ msgq(sp, M_SYSERR, NULL);
goto err;
}
@@ -457,23 +471,29 @@ lerr: msgq(sp, M_ERR, "064|Recovery file buffer overrun");
wout: *t2++ = '\n';
/* t2 points one after the last character to display. */
- if (write(fd, t1, t2 - t1) != t2 - t1)
+ if (fwrite(t1, 1, t2 - t1, fp) != t2 - t1) {
+ free(buf);
goto werr;
+ }
}
if (issync) {
+ fflush(fp);
rcv_email(sp, mpath);
- if (close(fd)) {
-werr: msgq(sp, M_SYSERR, "065|Recovery file");
- goto err;
- }
+ free(mpath);
+ }
+ if (fclose(fp)) {
+ free(buf);
+werr: msgq(sp, M_SYSERR, "065|Recovery file");
+ goto err;
}
+ free(buf);
return (0);
err: if (!issync)
ep->rcv_fd = -1;
- if (fd != -1)
- (void)close(fd);
+ if (fp != NULL)
+ (void)fclose(fp);
return (1);
}
@@ -488,15 +508,16 @@ err: if (!issync)
* PUBLIC: int rcv_list __P((SCR *));
*/
int
-rcv_list(sp)
- SCR *sp;
+rcv_list(SCR *sp)
{
struct dirent *dp;
struct stat sb;
DIR *dirp;
FILE *fp;
int found;
- char *p, *t, file[MAXPATHLEN], path[MAXPATHLEN];
+ char *p, *file, *path;
+ char *dtype, *data;
+ int st;
/* Open the recovery directory for reading. */
if (opts_empty(sp, O_RECDIR, 0))
@@ -512,18 +533,11 @@ rcv_list(sp)
if (strncmp(dp->d_name, "recover.", 8))
continue;
- /*
- * If it's readable, it's recoverable.
- *
- * XXX
- * Should be "r", we don't want to write the file. However,
- * if we're using fcntl(2), there's no way to lock a file
- * descriptor that's not open for writing.
- */
- if ((fp = fopen(dp->d_name, "r+")) == NULL)
+ /* If it's readable, it's recoverable. */
+ if ((fp = fopen(dp->d_name, "r")) == NULL)
continue;
- switch (file_lock(sp, NULL, NULL, fileno(fp), 1)) {
+ switch (file_lock(sp, NULL, fileno(fp), 1)) {
case LOCK_FAILED:
/*
* XXX
@@ -542,17 +556,23 @@ rcv_list(sp)
}
/* Check the headers. */
- if (fgets(file, sizeof(file), fp) == NULL ||
- strncmp(file, VI_FHEADER, sizeof(VI_FHEADER) - 1) ||
- (p = strchr(file, '\n')) == NULL ||
- fgets(path, sizeof(path), fp) == NULL ||
- strncmp(path, VI_PHEADER, sizeof(VI_PHEADER) - 1) ||
- (t = strchr(path, '\n')) == NULL) {
- msgq_str(sp, M_ERR, dp->d_name,
- "066|%s: malformed recovery file");
- goto next;
+ for (file = NULL, path = NULL;
+ file == NULL || path == NULL;) {
+ if ((st = rcv_dlnread(sp, &dtype, &data, fp))) {
+ if (st == 1)
+ msgq_str(sp, M_ERR, dp->d_name,
+ "066|%s: malformed recovery file");
+ goto next;
+ }
+ if (dtype == NULL)
+ continue;
+ if (!strcmp(dtype, "file"))
+ file = data;
+ else if (!strcmp(dtype, "path"))
+ path = data;
+ else
+ free(data);
}
- *p = *t = '\0';
/*
* If the file doesn't exist, it's an orphaned recovery file,
@@ -563,7 +583,7 @@ rcv_list(sp)
* before deleting the email file.
*/
errno = 0;
- if (stat(path + sizeof(VI_PHEADER) - 1, &sb) &&
+ if (stat(path, &sb) &&
errno == ENOENT) {
(void)unlink(dp->d_name);
goto next;
@@ -572,14 +592,18 @@ rcv_list(sp)
/* Get the last modification time and display. */
(void)fstat(fileno(fp), &sb);
(void)printf("%.24s: %s\n",
- ctime(&sb.st_mtime), file + sizeof(VI_FHEADER) - 1);
+ ctime(&sb.st_mtime), file);
found = 1;
/* Close, discarding lock. */
next: (void)fclose(fp);
+ if (file != NULL)
+ free(file);
+ if (path != NULL)
+ free(path);
}
if (found == 0)
- (void)printf("vi: no files to recover.\n");
+ (void)printf("%s: No files to recover\n", sp->gp->progname);
(void)closedir(dirp);
return (0);
}
@@ -591,18 +615,21 @@ next: (void)fclose(fp);
* PUBLIC: int rcv_read __P((SCR *, FREF *));
*/
int
-rcv_read(sp, frp)
- SCR *sp;
- FREF *frp;
+rcv_read(
+ SCR *sp,
+ FREF *frp)
{
struct dirent *dp;
struct stat sb;
DIR *dirp;
+ FILE *fp;
EXF *ep;
- time_t rec_mtime;
- int fd, found, locked, requested, sv_fd;
+ struct timespec rec_mtim = { 0, 0 };
+ int found, locked = 0, requested, sv_fd;
char *name, *p, *t, *rp, *recp, *pathp;
- char file[MAXPATHLEN], path[MAXPATHLEN], recpath[MAXPATHLEN];
+ char *file, *path, *recpath;
+ char *dtype, *data;
+ int st;
if (opts_empty(sp, O_RECDIR, 0))
return (1);
@@ -614,30 +641,22 @@ rcv_read(sp, frp)
name = frp->name;
sv_fd = -1;
- rec_mtime = 0;
recp = pathp = NULL;
for (found = requested = 0; (dp = readdir(dirp)) != NULL;) {
if (strncmp(dp->d_name, "recover.", 8))
continue;
- (void)snprintf(recpath,
- sizeof(recpath), "%s/%s", rp, dp->d_name);
+ if ((recpath = join(rp, dp->d_name)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ continue;
+ }
- /*
- * If it's readable, it's recoverable. It would be very
- * nice to use stdio(3), but, we can't because that would
- * require closing and then reopening the file so that we
- * could have a lock and still close the FP. Another tip
- * of the hat to fcntl(2).
- *
- * XXX
- * Should be O_RDONLY, we don't want to write it. However,
- * if we're using fcntl(2), there's no way to lock a file
- * descriptor that's not open for writing.
- */
- if ((fd = open(recpath, O_RDWR, 0)) == -1)
+ /* If it's readable, it's recoverable. */
+ if ((fp = fopen(recpath, "r")) == NULL) {
+ free(recpath);
continue;
+ }
- switch (file_lock(sp, NULL, NULL, fd, 1)) {
+ switch (file_lock(sp, NULL, fileno(fp), 1)) {
case LOCK_FAILED:
/*
* XXX
@@ -653,22 +672,28 @@ rcv_read(sp, frp)
break;
case LOCK_UNAVAIL:
/* If it's locked, it's live. */
- (void)close(fd);
+ (void)fclose(fp);
continue;
}
/* Check the headers. */
- if (rcv_gets(file, sizeof(file), fd) == NULL ||
- strncmp(file, VI_FHEADER, sizeof(VI_FHEADER) - 1) ||
- (p = strchr(file, '\n')) == NULL ||
- rcv_gets(path, sizeof(path), fd) == NULL ||
- strncmp(path, VI_PHEADER, sizeof(VI_PHEADER) - 1) ||
- (t = strchr(path, '\n')) == NULL) {
- msgq_str(sp, M_ERR, recpath,
- "067|%s: malformed recovery file");
- goto next;
+ for (file = NULL, path = NULL;
+ file == NULL || path == NULL;) {
+ if ((st = rcv_dlnread(sp, &dtype, &data, fp))) {
+ if (st == 1)
+ msgq_str(sp, M_ERR, dp->d_name,
+ "067|%s: malformed recovery file");
+ goto next;
+ }
+ if (dtype == NULL)
+ continue;
+ if (!strcmp(dtype, "file"))
+ file = data;
+ else if (!strcmp(dtype, "path"))
+ path = data;
+ else
+ free(data);
}
- *p = *t = '\0';
++found;
/*
@@ -680,52 +705,42 @@ rcv_read(sp, frp)
* before deleting the email file.
*/
errno = 0;
- if (stat(path + sizeof(VI_PHEADER) - 1, &sb) &&
+ if (stat(path, &sb) &&
errno == ENOENT) {
(void)unlink(dp->d_name);
goto next;
}
/* Check the file name. */
- if (strcmp(file + sizeof(VI_FHEADER) - 1, name))
+ if (strcmp(file, name))
goto next;
++requested;
- /*
- * If we've found more than one, take the most recent.
- *
- * XXX
- * Since we're using st_mtime, for portability reasons,
- * we only get a single second granularity, instead of
- * getting it right.
- */
- (void)fstat(fd, &sb);
- if (recp == NULL || rec_mtime < sb.st_mtime) {
+ /* If we've found more than one, take the most recent. */
+ (void)fstat(fileno(fp), &sb);
+ if (recp == NULL ||
+ timespeccmp(&rec_mtim, &sb.st_mtimespec, <)) {
p = recp;
t = pathp;
- if ((recp = strdup(recpath)) == NULL) {
- msgq(sp, M_SYSERR, NULL);
- recp = p;
- goto next;
- }
- if ((pathp = strdup(path)) == NULL) {
- msgq(sp, M_SYSERR, NULL);
- free(recp);
- recp = p;
- pathp = t;
- goto next;
- }
+ recp = recpath;
+ pathp = path;
if (p != NULL) {
free(p);
free(t);
}
- rec_mtime = sb.st_mtime;
+ rec_mtim = sb.st_mtimespec;
if (sv_fd != -1)
(void)close(sv_fd);
- sv_fd = fd;
- } else
-next: (void)close(fd);
+ sv_fd = dup(fileno(fp));
+ } else {
+next: free(recpath);
+ if (path != NULL)
+ free(path);
+ }
+ (void)fclose(fp);
+ if (file != NULL)
+ free(file);
}
(void)closedir(dirp);
@@ -749,12 +764,13 @@ next: (void)close(fd);
* XXX
* file_init() is going to set ep->rcv_path.
*/
- if (file_init(sp, frp, pathp + sizeof(VI_PHEADER) - 1, 0)) {
+ if (file_init(sp, frp, pathp, 0)) {
free(recp);
free(pathp);
(void)close(sv_fd);
return (1);
}
+ free(pathp);
/*
* We keep an open lock on the file so that the recover option can
@@ -777,10 +793,10 @@ next: (void)close(fd);
* Copy a recovery file.
*/
static int
-rcv_copy(sp, wfd, fname)
- SCR *sp;
- int wfd;
- char *fname;
+rcv_copy(
+ SCR *sp,
+ int wfd,
+ char *fname)
{
int nr, nw, off, rfd;
char buf[8 * 1024];
@@ -799,52 +815,19 @@ err: msgq_str(sp, M_SYSERR, fname, "%s");
}
/*
- * rcv_gets --
- * Fgets(3) for a file descriptor.
- */
-static char *
-rcv_gets(buf, len, fd)
- char *buf;
- size_t len;
- int fd;
-{
- int nr;
- char *p;
-
- if ((nr = read(fd, buf, len - 1)) == -1)
- return (NULL);
- if ((p = strchr(buf, '\n')) == NULL)
- return (NULL);
- (void)lseek(fd, (off_t)((p - buf) + 1), SEEK_SET);
- return (buf);
-}
-
-/*
* rcv_mktemp --
* Paranoid make temporary file routine.
*/
static int
-rcv_mktemp(sp, path, dname, perms)
- SCR *sp;
- char *path, *dname;
- int perms;
+rcv_mktemp(
+ SCR *sp,
+ char *path,
+ char *dname)
{
int fd;
- /*
- * !!!
- * We expect mkstemp(3) to set the permissions correctly. On
- * historic System V systems, mkstemp didn't. Do it here, on
- * GP's.
- *
- * XXX
- * The variable perms should really be a mode_t, and it would
- * be nice to use fchmod(2) instead of chmod(2), here.
- */
if ((fd = mkstemp(path)) == -1)
msgq_str(sp, M_SYSERR, dname, "%s");
- else
- (void)chmod(path, perms);
return (fd);
}
@@ -853,26 +836,141 @@ rcv_mktemp(sp, path, dname, perms)
* Send email.
*/
static void
-rcv_email(sp, fname)
- SCR *sp;
- char *fname;
+rcv_email(
+ SCR *sp,
+ char *fname)
{
- struct stat sb;
- char buf[MAXPATHLEN * 2 + 20];
+ char *buf;
- if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, &sb))
- msgq_str(sp, M_SYSERR,
- _PATH_SENDMAIL, "071|not sending email: %s");
- else {
- /*
- * !!!
- * If you need to port this to a system that doesn't have
- * sendmail, the -t flag causes sendmail to read the message
- * for the recipients instead of specifying them some other
- * way.
- */
- (void)snprintf(buf, sizeof(buf),
- "%s -t < %s", _PATH_SENDMAIL, fname);
- (void)system(buf);
+ (void)asprintf(&buf, _PATH_SENDMAIL " -odb -t < %s", fname);
+ if (buf == NULL) {
+ msgq_str(sp, M_ERR, strerror(errno),
+ "071|not sending email: %s");
+ return;
+ }
+ (void)system(buf);
+ free(buf);
+}
+
+/*
+ * rcv_dlnwrite --
+ * Encode a string into an X-vi-data line and write it.
+ */
+static int
+rcv_dlnwrite(
+ SCR *sp,
+ const char *dtype,
+ const char *src,
+ FILE *fp)
+{
+ char *bp = NULL, *p;
+ size_t blen = 0;
+ size_t dlen, len;
+ int plen, xlen;
+
+ len = strlen(src);
+ dlen = strlen(dtype);
+ GET_SPACE_GOTOC(sp, bp, blen, (len + 2) / 3 * 4 + dlen + 2);
+ (void)memcpy(bp, dtype, dlen);
+ bp[dlen] = ';';
+ if ((xlen = b64_ntop((u_char *)src,
+ len, bp + dlen + 1, blen)) == -1)
+ goto err;
+ xlen += dlen + 1;
+
+ /* Output as an MIME folding header. */
+ if ((plen = fprintf(fp, VI_DHEADER " %.*s\n",
+ FMTCOLS - (int)sizeof(VI_DHEADER), bp)) < 0)
+ goto err;
+ plen -= (int)sizeof(VI_DHEADER) + 1;
+ for (p = bp, xlen -= plen; xlen > 0; xlen -= plen) {
+ p += plen;
+ if ((plen = fprintf(fp, " %.*s\n", FMTCOLS - 1, p)) < 0)
+ goto err;
+ plen -= 2;
+ }
+ FREE_SPACE(sp, bp, blen);
+ return (0);
+
+err: FREE_SPACE(sp, bp, blen);
+ return (1);
+alloc_err:
+ msgq(sp, M_SYSERR, NULL);
+ return (-1);
+}
+
+/*
+ * rcv_dlnread --
+ * Read an X-vi-data line and decode it.
+ */
+static int
+rcv_dlnread(
+ SCR *sp,
+ char **dtypep,
+ char **datap, /* free *datap if != NULL after use. */
+ FILE *fp)
+{
+ int ch;
+ char buf[1024];
+ char *bp = NULL, *p, *src;
+ size_t blen = 0;
+ size_t len, off, dlen;
+ char *dtype, *data;
+ int xlen;
+
+ if (fgets(buf, sizeof(buf), fp) == NULL)
+ return (1);
+ if (strncmp(buf, VI_DHEADER, sizeof(VI_DHEADER) - 1)) {
+ *dtypep = NULL;
+ *datap = NULL;
+ return (0);
+ }
+
+ /* Fetch an MIME folding header. */
+ len = strlen(buf) - sizeof(VI_DHEADER) + 1;
+ GET_SPACE_GOTOC(sp, bp, blen, len);
+ (void)memcpy(bp, buf + sizeof(VI_DHEADER) - 1, len);
+ p = bp + len;
+ while ((ch = fgetc(fp)) == ' ') {
+ if (fgets(buf, sizeof(buf), fp) == NULL)
+ goto err;
+ off = strlen(buf);
+ len += off;
+ ADD_SPACE_GOTOC(sp, bp, blen, len);
+ p = bp + len - off;
+ (void)memcpy(p, buf, off);
+ }
+ bp[len] = '\0';
+ (void)ungetc(ch, fp);
+
+ for (p = bp; *p == ' ' || *p == '\n'; p++);
+ if ((src = strchr(p, ';')) == NULL)
+ goto err;
+ dlen = src - p;
+ src += 1;
+ len -= src - bp;
+
+ /* Memory looks like: "<data>\0<dtype>\0". */
+ MALLOC(sp, data, char *, dlen + len / 4 * 3 + 2);
+ if (data == NULL)
+ goto err;
+ if ((xlen = (b64_pton(p + dlen + 1,
+ (u_char *)data, len / 4 * 3 + 1))) == -1) {
+ free(data);
+ goto err;
}
+ data[xlen] = '\0';
+ dtype = data + xlen + 1;
+ (void)memcpy(dtype, p, dlen);
+ dtype[dlen] = '\0';
+ FREE_SPACE(sp, bp, blen);
+ *dtypep = dtype;
+ *datap = data;
+ return (0);
+
+err: FREE_SPACE(sp, bp, blen);
+ return (1);
+alloc_err:
+ msgq(sp, M_SYSERR, NULL);
+ return (-1);
}
diff --git a/common/screen.c b/common/screen.c
index ba9e287b648b..9ff684509d94 100644
--- a/common/screen.c
+++ b/common/screen.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)screen.c 10.15 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: screen.c,v 10.25 2011/12/04 04:06:45 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -35,9 +35,10 @@ static const char sccsid[] = "@(#)screen.c 10.15 (Berkeley) 9/15/96";
* PUBLIC: int screen_init __P((GS *, SCR *, SCR **));
*/
int
-screen_init(gp, orig, spp)
- GS *gp;
- SCR *orig, **spp;
+screen_init(
+ GS *gp,
+ SCR *orig,
+ SCR **spp)
{
SCR *sp;
size_t len;
@@ -50,9 +51,9 @@ screen_init(gp, orig, spp)
sp->id = ++gp->id;
sp->refcnt = 1;
- sp->gp = gp; /* All ref the GS structure. */
+ sp->gp = gp; /* All ref the GS structure. */
- sp->ccnt = 2; /* Anything > 1 */
+ sp->ccnt = 2; /* Anything > 1 */
/*
* XXX
@@ -60,7 +61,7 @@ screen_init(gp, orig, spp)
* we don't have the option information yet.
*/
- CIRCLEQ_INIT(&sp->tiq);
+ TAILQ_INIT(sp->tiq);
/* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
if (orig == NULL) {
@@ -80,15 +81,15 @@ screen_init(gp, orig, spp)
/* Retain searching/substitution information. */
sp->searchdir = orig->searchdir == NOTSET ? NOTSET : FORWARD;
if (orig->re != NULL && (sp->re =
- v_strdup(sp, orig->re, orig->re_len)) == NULL)
+ v_wstrdup(sp, orig->re, orig->re_len)) == NULL)
goto mem;
sp->re_len = orig->re_len;
if (orig->subre != NULL && (sp->subre =
- v_strdup(sp, orig->subre, orig->subre_len)) == NULL)
+ v_wstrdup(sp, orig->subre, orig->subre_len)) == NULL)
goto mem;
sp->subre_len = orig->subre_len;
if (orig->repl != NULL && (sp->repl =
- v_strdup(sp, orig->repl, orig->repl_len)) == NULL)
+ v_wstrdup(sp, orig->repl, orig->repl_len)) == NULL)
goto mem;
sp->repl_len = orig->repl_len;
if (orig->newl_len) {
@@ -113,6 +114,8 @@ mem: msgq(orig, M_SYSERR, NULL);
goto err;
if (v_screen_copy(orig, sp)) /* Vi. */
goto err;
+ sp->cl_private = 0; /* XXX */
+ conv_init(orig, sp); /* XXX */
*spp = sp;
return (0);
@@ -129,8 +132,7 @@ err: screen_end(sp);
* PUBLIC: int screen_end __P((SCR *));
*/
int
-screen_end(sp)
- SCR *sp;
+screen_end(SCR *sp)
{
int rval;
@@ -144,17 +146,13 @@ screen_end(sp)
* If a created screen failed during initialization, it may not
* be linked into the chain.
*/
- if (sp->q.cqe_next != NULL)
- CIRCLEQ_REMOVE(&sp->gp->dq, sp, q);
+ if (TAILQ_ENTRY_ISVALID(sp, q))
+ TAILQ_REMOVE(sp->gp->dq, sp, q);
/* The screen is no longer real. */
F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
rval = 0;
-#ifdef HAVE_PERL_INTERP
- if (perl_screen_end(sp)) /* End perl. */
- rval = 1;
-#endif
if (v_screen_end(sp)) /* End vi. */
rval = 1;
if (ex_screen_end(sp)) /* End ex. */
@@ -170,8 +168,8 @@ screen_end(sp)
}
/* Free any text input. */
- if (sp->tiq.cqh_first != NULL)
- text_lfree(&sp->tiq);
+ if (!TAILQ_EMPTY(sp->tiq))
+ text_lfree(sp->tiq);
/* Free alternate file name. */
if (sp->alt_name != NULL)
@@ -191,6 +189,9 @@ screen_end(sp)
if (sp->newl != NULL)
free(sp->newl);
+ /* Free the iconv environment */
+ conv_end(sp);
+
/* Free all the options */
opts_free(sp);
@@ -207,26 +208,24 @@ screen_end(sp)
* PUBLIC: SCR *screen_next __P((SCR *));
*/
SCR *
-screen_next(sp)
- SCR *sp;
+screen_next(SCR *sp)
{
GS *gp;
SCR *next;
/* Try the display queue, without returning the current screen. */
gp = sp->gp;
- for (next = gp->dq.cqh_first;
- next != (void *)&gp->dq; next = next->q.cqe_next)
+ TAILQ_FOREACH(next, gp->dq, q)
if (next != sp)
break;
- if (next != (void *)&gp->dq)
+ if (next != NULL)
return (next);
/* Try the hidden queue; if found, move screen to the display queue. */
- if (gp->hq.cqh_first != (void *)&gp->hq) {
- next = gp->hq.cqh_first;
- CIRCLEQ_REMOVE(&gp->hq, next, q);
- CIRCLEQ_INSERT_HEAD(&gp->dq, next, q);
+ if (!TAILQ_EMPTY(gp->hq)) {
+ next = TAILQ_FIRST(gp->hq);
+ TAILQ_REMOVE(gp->hq, next, q);
+ TAILQ_INSERT_HEAD(gp->dq, next, q);
return (next);
}
return (NULL);
diff --git a/common/screen.h b/common/screen.h
index bb7254f62a21..a762706834dd 100644
--- a/common/screen.h
+++ b/common/screen.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)screen.h 10.24 (Berkeley) 7/19/96
+ * $Id: screen.h,v 10.26 2011/12/12 22:31:36 zy Exp $
*/
/*
@@ -32,7 +32,7 @@
*/
struct _scr {
/* INITIALIZED AT SCREEN CREATE. */
- CIRCLEQ_ENTRY(_scr) q; /* Screens. */
+ TAILQ_ENTRY(_scr) q; /* Screens. */
int id; /* Screen id #. */
int refcnt; /* Reference count. */
@@ -55,7 +55,8 @@ struct _scr {
size_t t_rows; /* 1-N: cur number of text rows. */
size_t t_maxrows; /* 1-N: max number of text rows. */
size_t t_minrows; /* 1-N: min number of text rows. */
- size_t woff; /* 0-N: screen offset in frame. */
+ size_t coff; /* 0-N: screen col offset in display. */
+ size_t roff; /* 0-N: screen row offset in display. */
/* Cursor's: */
recno_t lno; /* 1-N: file line. */
@@ -73,15 +74,16 @@ struct _scr {
recno_t rptlchange; /* Ex/vi: last L_CHANGED lno. */
recno_t rptlines[L_YANKED + 1];/* Ex/vi: lines changed by last op. */
- TEXTH tiq; /* Ex/vi: text input queue. */
+ TEXTH tiq[1]; /* Ex/vi: text input queue. */
SCRIPT *script; /* Vi: script mode information .*/
recno_t defscroll; /* Vi: ^D, ^U scroll information. */
/* Display character. */
- CHAR_T cname[MAX_CHARACTER_COLUMNS + 1];
+ char cname[MAX_CHARACTER_COLUMNS + 1];
size_t clen; /* Length of display character. */
+ ARG_CHAR_T lastc; /* The last display character. */
enum { /* Vi editor mode. */
SM_APPEND = 0, SM_CHANGE, SM_COMMAND, SM_INSERT,
@@ -89,7 +91,10 @@ struct _scr {
void *ex_private; /* Ex private area. */
void *vi_private; /* Vi private area. */
- void *perl_private; /* Perl private area. */
+ void *cl_private; /* Curses private area. */
+
+ CONV conv; /* Conversion functions. */
+ CONVWIN cw; /* Conversion buffer. */
/* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
char *alt_name; /* Ex/vi: alternate file name. */
@@ -103,8 +108,10 @@ struct _scr {
#define RE_C_SUBST 0x0008 /* Compile substitute replacement. */
#define RE_C_TAG 0x0010 /* Compile ctag pattern. */
-#define RE_WSTART "[[:<:]]" /* Ex/vi: not-in-word search pattern. */
-#define RE_WSTOP "[[:>:]]"
+#define RE_WSTART L("[[:<:]]") /* Ex/vi: not-in-word search pattern. */
+#define RE_WSTOP L("[[:>:]]")
+#define RE_WSTART_LEN (SIZE(RE_WSTART) - 1)
+#define RE_WSTOP_LEN (SIZE(RE_WSTOP) - 1)
/* Ex/vi: flags to search routines. */
#define SEARCH_CSCOPE 0x0001 /* Search for a cscope pattern. */
#define SEARCH_EOL 0x0002 /* Offset past EOL is okay. */
@@ -119,12 +126,12 @@ struct _scr {
/* Ex/vi: RE information. */
dir_t searchdir; /* Last file search direction. */
regex_t re_c; /* Search RE: compiled form. */
- char *re; /* Search RE: uncompiled form. */
+ CHAR_T *re; /* Search RE: uncompiled form. */
size_t re_len; /* Search RE: uncompiled length. */
regex_t subre_c; /* Substitute RE: compiled form. */
- char *subre; /* Substitute RE: uncompiled form. */
+ CHAR_T *subre; /* Substitute RE: uncompiled form. */
size_t subre_len; /* Substitute RE: uncompiled length). */
- char *repl; /* Substitute replacement. */
+ CHAR_T *repl; /* Substitute replacement. */
size_t repl_len; /* Substitute replacement length.*/
size_t *newl; /* Newline offset array. */
size_t newl_len; /* Newline array size. */
@@ -199,5 +206,6 @@ struct _scr {
#define SC_STATUS_CNT 0x04000000 /* Welcome message plus file count. */
#define SC_TINPUT 0x08000000 /* Doing text input. */
#define SC_TINPUT_INFO 0x10000000 /* Doing text input on info line. */
+#define SC_CONV_ERROR 0x20000000 /* Met with a conversion error. */
u_int32_t flags;
};
diff --git a/common/search.c b/common/search.c
index 3fd2719778fa..22f020315070 100644
--- a/common/search.c
+++ b/common/search.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)search.c 10.25 (Berkeley) 6/30/96";
+static const char sccsid[] = "$Id: search.c,v 10.26 2011/07/04 20:16:26 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -30,23 +31,24 @@ static const char sccsid[] = "@(#)search.c 10.25 (Berkeley) 6/30/96";
typedef enum { S_EMPTY, S_EOF, S_NOPREV, S_NOTFOUND, S_SOF, S_WRAP } smsg_t;
static void search_msg __P((SCR *, smsg_t));
-static int search_init __P((SCR *, dir_t, char *, size_t, char **, u_int));
+static int search_init __P((SCR *, dir_t, CHAR_T *, size_t, CHAR_T **, u_int));
/*
* search_init --
* Set up a search.
*/
static int
-search_init(sp, dir, ptrn, plen, epp, flags)
- SCR *sp;
- dir_t dir;
- char *ptrn, **epp;
- size_t plen;
- u_int flags;
+search_init(
+ SCR *sp,
+ dir_t dir,
+ CHAR_T *ptrn,
+ size_t plen,
+ CHAR_T **epp,
+ u_int flags)
{
recno_t lno;
int delim;
- char *p, *t;
+ CHAR_T *p, *t;
/* If the file is empty, it's a fast search. */
if (sp->lno <= 1) {
@@ -141,22 +143,24 @@ prev: if (sp->re == NULL) {
* Do a forward search.
*
* PUBLIC: int f_search __P((SCR *,
- * PUBLIC: MARK *, MARK *, char *, size_t, char **, u_int));
+ * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int));
*/
int
-f_search(sp, fm, rm, ptrn, plen, eptrn, flags)
- SCR *sp;
- MARK *fm, *rm;
- char *ptrn, **eptrn;
- size_t plen;
- u_int flags;
+f_search(
+ SCR *sp,
+ MARK *fm,
+ MARK *rm,
+ CHAR_T *ptrn,
+ size_t plen,
+ CHAR_T **eptrn,
+ u_int flags)
{
busy_t btype;
recno_t lno;
regmatch_t match[1];
size_t coff, len;
int cnt, eval, rval, wrapped;
- char *l;
+ CHAR_T *l;
if (search_init(sp, FORWARD, ptrn, plen, eptrn, flags))
return (1);
@@ -210,7 +214,7 @@ f_search(sp, fm, rm, ptrn, plen, eptrn, flags)
}
cnt = INTERRUPT_CHECK;
}
- if (wrapped && lno > fm->lno || db_get(sp, lno, 0, &l, &len)) {
+ if ((wrapped && lno > fm->lno) || db_get(sp, lno, 0, &l, &len)) {
if (wrapped) {
if (LF_ISSET(SEARCH_MSG))
search_msg(sp, S_NOTFOUND);
@@ -285,22 +289,24 @@ f_search(sp, fm, rm, ptrn, plen, eptrn, flags)
* Do a backward search.
*
* PUBLIC: int b_search __P((SCR *,
- * PUBLIC: MARK *, MARK *, char *, size_t, char **, u_int));
+ * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int));
*/
int
-b_search(sp, fm, rm, ptrn, plen, eptrn, flags)
- SCR *sp;
- MARK *fm, *rm;
- char *ptrn, **eptrn;
- size_t plen;
- u_int flags;
+b_search(
+ SCR *sp,
+ MARK *fm,
+ MARK *rm,
+ CHAR_T *ptrn,
+ size_t plen,
+ CHAR_T **eptrn,
+ u_int flags)
{
busy_t btype;
recno_t lno;
regmatch_t match[1];
size_t coff, last, len;
int cnt, eval, rval, wrapped;
- char *l;
+ CHAR_T *l;
if (search_init(sp, BACKWARD, ptrn, plen, eptrn, flags))
return (1);
@@ -342,7 +348,7 @@ b_search(sp, fm, rm, ptrn, plen, eptrn, flags)
}
cnt = INTERRUPT_CHECK;
}
- if (wrapped && lno < fm->lno || lno == 0) {
+ if ((wrapped && lno < fm->lno) || lno == 0) {
if (wrapped) {
if (LF_ISSET(SEARCH_MSG))
search_msg(sp, S_NOTFOUND);
@@ -447,9 +453,9 @@ err: if (LF_ISSET(SEARCH_MSG))
* Display one of the search messages.
*/
static void
-search_msg(sp, msg)
- SCR *sp;
- smsg_t msg;
+search_msg(
+ SCR *sp,
+ smsg_t msg)
{
switch (msg) {
case S_EMPTY:
@@ -484,9 +490,9 @@ search_msg(sp, msg)
* PUBLIC: void search_busy __P((SCR *, busy_t));
*/
void
-search_busy(sp, btype)
- SCR *sp;
- busy_t btype;
+search_busy(
+ SCR *sp,
+ busy_t btype)
{
sp->gp->scr_busy(sp, "078|Searching...", btype);
}
diff --git a/common/seq.c b/common/seq.c
index e2be879ab686..45c6c1111083 100644
--- a/common/seq.c
+++ b/common/seq.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)seq.c 10.10 (Berkeley) 3/30/96";
+static const char sccsid[] = "$Id: seq.c,v 10.18 2011/12/11 23:13:00 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -34,12 +35,16 @@ static const char sccsid[] = "@(#)seq.c 10.10 (Berkeley) 3/30/96";
* PUBLIC: size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int));
*/
int
-seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags)
- SCR *sp;
- CHAR_T *name, *input, *output;
- size_t nlen, ilen, olen;
- seq_t stype;
- int flags;
+seq_set(
+ SCR *sp,
+ CHAR_T *name,
+ size_t nlen,
+ CHAR_T *input,
+ size_t ilen,
+ CHAR_T *output,
+ size_t olen,
+ seq_t stype,
+ int flags)
{
CHAR_T *p;
SEQ *lastqp, *qp;
@@ -59,7 +64,7 @@ seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags)
if (output == NULL || olen == 0) {
p = NULL;
olen = 0;
- } else if ((p = v_strdup(sp, output, olen)) == NULL) {
+ } else if ((p = v_wstrdup(sp, output, olen)) == NULL) {
sv_errno = errno;
goto mem1;
}
@@ -80,14 +85,14 @@ seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags)
/* Name. */
if (name == NULL || nlen == 0)
qp->name = NULL;
- else if ((qp->name = v_strdup(sp, name, nlen)) == NULL) {
+ else if ((qp->name = v_wstrdup(sp, name, nlen)) == NULL) {
sv_errno = errno;
goto mem2;
}
qp->nlen = nlen;
/* Input. */
- if ((qp->input = v_strdup(sp, input, ilen)) == NULL) {
+ if ((qp->input = v_wstrdup(sp, input, ilen)) == NULL) {
sv_errno = errno;
goto mem3;
}
@@ -97,7 +102,7 @@ seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags)
if (output == NULL) {
qp->output = NULL;
olen = 0;
- } else if ((qp->output = v_strdup(sp, output, olen)) == NULL) {
+ } else if ((qp->output = v_wstrdup(sp, output, olen)) == NULL) {
sv_errno = errno;
free(qp->input);
mem3: if (qp->name != NULL)
@@ -115,13 +120,13 @@ mem1: errno = sv_errno;
/* Link into the chain. */
if (lastqp == NULL) {
- LIST_INSERT_HEAD(&sp->gp->seqq, qp, q);
+ SLIST_INSERT_HEAD(sp->gp->seqq, qp, q);
} else {
- LIST_INSERT_AFTER(lastqp, qp, q);
+ SLIST_INSERT_AFTER(lastqp, qp, q);
}
/* Set the fast lookup bit. */
- if (qp->input[0] < MAX_BIT_SEQ)
+ if ((qp->input[0] & ~MAX_BIT_SEQ) == 0)
bit_set(sp->gp->seqb, qp->input[0]);
return (0);
@@ -134,33 +139,48 @@ mem1: errno = sv_errno;
* PUBLIC: int seq_delete __P((SCR *, CHAR_T *, size_t, seq_t));
*/
int
-seq_delete(sp, input, ilen, stype)
- SCR *sp;
- CHAR_T *input;
- size_t ilen;
- seq_t stype;
+seq_delete(
+ SCR *sp,
+ CHAR_T *input,
+ size_t ilen,
+ seq_t stype)
{
- SEQ *qp;
+ SEQ *qp, *pre_qp = NULL;
+ int diff;
- if ((qp = seq_find(sp, NULL, NULL, input, ilen, stype, NULL)) == NULL)
- return (1);
- return (seq_mdel(qp));
+ SLIST_FOREACH(qp, sp->gp->seqq, q) {
+ if (qp->stype == stype && qp->ilen == ilen) {
+ diff = MEMCMP(qp->input, input, ilen);
+ if (!diff) {
+ if (F_ISSET(qp, SEQ_FUNCMAP))
+ break;
+ if (qp == SLIST_FIRST(sp->gp->seqq))
+ SLIST_REMOVE_HEAD(sp->gp->seqq, q);
+ else
+ SLIST_REMOVE_AFTER(pre_qp, q);
+ return (seq_free(qp));
+ }
+ if (diff > 0)
+ break;
+ }
+ pre_qp = qp;
+ }
+ return (1);
}
/*
- * seq_mdel --
- * Delete a map entry, without lookup.
+ * seq_free --
+ * Free a map entry.
*
- * PUBLIC: int seq_mdel __P((SEQ *));
+ * PUBLIC: int seq_free __P((SEQ *));
*/
int
-seq_mdel(qp)
- SEQ *qp;
+seq_free(SEQ *qp)
{
- LIST_REMOVE(qp, q);
if (qp->name != NULL)
free(qp->name);
- free(qp->input);
+ if (qp->input != NULL)
+ free(qp->input);
if (qp->output != NULL)
free(qp->output);
free(qp);
@@ -176,16 +196,16 @@ seq_mdel(qp)
* PUBLIC: __P((SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *));
*/
SEQ *
-seq_find(sp, lastqp, e_input, c_input, ilen, stype, ispartialp)
- SCR *sp;
- SEQ **lastqp;
- EVENT *e_input;
- CHAR_T *c_input;
- size_t ilen;
- seq_t stype;
- int *ispartialp;
+seq_find(
+ SCR *sp,
+ SEQ **lastqp,
+ EVENT *e_input,
+ CHAR_T *c_input,
+ size_t ilen,
+ seq_t stype,
+ int *ispartialp)
{
- SEQ *lqp, *qp;
+ SEQ *lqp = NULL, *qp;
int diff;
/*
@@ -200,8 +220,8 @@ seq_find(sp, lastqp, e_input, c_input, ilen, stype, ispartialp)
*/
if (ispartialp != NULL)
*ispartialp = 0;
- for (lqp = NULL, qp = sp->gp->seqq.lh_first;
- qp != NULL; lqp = qp, qp = qp->q.le_next) {
+ for (qp = SLIST_FIRST(sp->gp->seqq); qp != NULL;
+ lqp = qp, qp = SLIST_NEXT(qp, q)) {
/*
* Fast checks on the first character and type, and then
* a real comparison.
@@ -212,7 +232,7 @@ seq_find(sp, lastqp, e_input, c_input, ilen, stype, ispartialp)
if (qp->input[0] < c_input[0] ||
qp->stype != stype || F_ISSET(qp, SEQ_FUNCMAP))
continue;
- diff = memcmp(qp->input, c_input, MIN(qp->ilen, ilen));
+ diff = MEMCMP(qp->input, c_input, MIN(qp->ilen, ilen));
} else {
if (qp->input[0] > e_input->e_c)
break;
@@ -261,20 +281,13 @@ seq_find(sp, lastqp, e_input, c_input, ilen, stype, ispartialp)
* PUBLIC: void seq_close __P((GS *));
*/
void
-seq_close(gp)
- GS *gp;
+seq_close(GS *gp)
{
SEQ *qp;
- while ((qp = gp->seqq.lh_first) != NULL) {
- if (qp->name != NULL)
- free(qp->name);
- if (qp->input != NULL)
- free(qp->input);
- if (qp->output != NULL)
- free(qp->output);
- LIST_REMOVE(qp, q);
- free(qp);
+ while ((qp = SLIST_FIRST(gp->seqq)) != NULL) {
+ SLIST_REMOVE_HEAD(gp->seqq, q);
+ (void)seq_free(qp);
}
}
@@ -285,10 +298,10 @@ seq_close(gp)
* PUBLIC: int seq_dump __P((SCR *, seq_t, int));
*/
int
-seq_dump(sp, stype, isname)
- SCR *sp;
- seq_t stype;
- int isname;
+seq_dump(
+ SCR *sp,
+ seq_t stype,
+ int isname)
{
CHAR_T *p;
GS *gp;
@@ -297,7 +310,7 @@ seq_dump(sp, stype, isname)
cnt = 0;
gp = sp->gp;
- for (qp = gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next) {
+ SLIST_FOREACH(qp, sp->gp->seqq, q) {
if (stype != qp->stype || F_ISSET(qp, SEQ_FUNCMAP))
continue;
++cnt;
@@ -333,11 +346,11 @@ seq_dump(sp, stype, isname)
* PUBLIC: int seq_save __P((SCR *, FILE *, char *, seq_t));
*/
int
-seq_save(sp, fp, prefix, stype)
- SCR *sp;
- FILE *fp;
- char *prefix;
- seq_t stype;
+seq_save(
+ SCR *sp,
+ FILE *fp,
+ char *prefix,
+ seq_t stype)
{
CHAR_T *p;
SEQ *qp;
@@ -345,7 +358,7 @@ seq_save(sp, fp, prefix, stype)
int ch;
/* Write a sequence command for all keys the user defined. */
- for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next) {
+ SLIST_FOREACH(qp, sp->gp->seqq, q) {
if (stype != qp->stype || !F_ISSET(qp, SEQ_USERDEF))
continue;
if (prefix)
@@ -353,7 +366,7 @@ seq_save(sp, fp, prefix, stype)
for (p = qp->input, olen = qp->ilen; olen > 0; --olen) {
ch = *p++;
if (ch == CH_LITERAL || ch == '|' ||
- isblank(ch) || KEY_VAL(sp, ch) == K_NL)
+ cmdskip(ch) || KEY_VAL(sp, ch) == K_NL)
(void)putc(CH_LITERAL, fp);
(void)putc(ch, fp);
}
@@ -379,10 +392,10 @@ seq_save(sp, fp, prefix, stype)
* PUBLIC: int e_memcmp __P((CHAR_T *, EVENT *, size_t));
*/
int
-e_memcmp(p1, ep, n)
- CHAR_T *p1;
- EVENT *ep;
- size_t n;
+e_memcmp(
+ CHAR_T *p1,
+ EVENT *ep,
+ size_t n)
{
if (n != 0) {
do {
diff --git a/common/seq.h b/common/seq.h
index 984bb6c0bd18..2c5ae576e3ee 100644
--- a/common/seq.h
+++ b/common/seq.h
@@ -6,13 +6,13 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)seq.h 10.3 (Berkeley) 3/6/96
+ * $Id: seq.h,v 10.4 2011/12/11 21:43:39 zy Exp $
*/
/*
* Map and abbreviation structures.
*
- * The map structure is doubly linked list, sorted by input string and by
+ * The map structure is singly linked list, sorted by input string and by
* input length within the string. (The latter is necessary so that short
* matches will happen before long matches when the list is searched.)
* Additionally, there is a bitmap which has bits set if there are entries
@@ -27,7 +27,7 @@
* things, though, so it's probably not a big deal.
*/
struct _seq {
- LIST_ENTRY(_seq) q; /* Linked list of all sequences. */
+ SLIST_ENTRY(_seq) q; /* Linked list of all sequences. */
seq_t stype; /* Sequence type. */
CHAR_T *name; /* Sequence name (if any). */
size_t nlen; /* Name length. */
diff --git a/common/util.c b/common/util.c
index 5a4422a2c422..43fa9d1e9f20 100644
--- a/common/util.c
+++ b/common/util.c
@@ -10,18 +10,27 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)util.c 10.11 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: util.c,v 10.30 2013/03/19 10:00:27 yamt Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#ifdef __APPLE__
+#include <mach/clock.h>
+#include <mach/mach.h>
+#include <mach/mach_time.h>
+#endif
+
#include <bitstring.h>
+#include <ctype.h>
#include <errno.h>
#include <limits.h>
+#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include "common.h"
@@ -33,10 +42,11 @@ static const char sccsid[] = "@(#)util.c 10.11 (Berkeley) 9/15/96";
* PUBLIC: void *binc __P((SCR *, void *, size_t *, size_t));
*/
void *
-binc(sp, bp, bsizep, min)
- SCR *sp; /* sp MAY BE NULL!!! */
- void *bp;
- size_t *bsizep, min;
+binc(
+ SCR *sp, /* sp MAY BE NULL!!! */
+ void *bp,
+ size_t *bsizep,
+ size_t min)
{
size_t csize;
@@ -44,14 +54,10 @@ binc(sp, bp, bsizep, min)
if (min && *bsizep >= min)
return (bp);
- csize = *bsizep + MAX(min, 256);
+ csize = p2roundup(MAX(min, 256));
REALLOC(sp, bp, void *, csize);
if (bp == NULL) {
- /*
- * Theoretically, realloc is supposed to leave any already
- * held memory alone if it can't get more. Don't trust it.
- */
*bsizep = 0;
return (NULL);
}
@@ -73,12 +79,12 @@ binc(sp, bp, bsizep, min)
* PUBLIC: int nonblank __P((SCR *, recno_t, size_t *));
*/
int
-nonblank(sp, lno, cnop)
- SCR *sp;
- recno_t lno;
- size_t *cnop;
+nonblank(
+ SCR *sp,
+ recno_t lno,
+ size_t *cnop)
{
- char *p;
+ CHAR_T *p;
size_t cnt, len, off;
int isempty;
@@ -95,7 +101,7 @@ nonblank(sp, lno, cnop)
return (0);
for (cnt = off, p = &p[off],
- len -= off; len && isblank(*p); ++cnt, ++p, --len);
+ len -= off; len && ISBLANK(*p); ++cnt, ++p, --len);
/* Set the return. */
*cnop = len ? cnt : cnt - 1;
@@ -109,8 +115,7 @@ nonblank(sp, lno, cnop)
* PUBLIC: char *tail __P((char *));
*/
char *
-tail(path)
- char *path;
+tail(char *path)
{
char *p;
@@ -120,23 +125,161 @@ tail(path)
}
/*
+ * join --
+ * Join two paths; need free.
+ *
+ * PUBLIC: char *join __P((char *, char *));
+ */
+char *
+join(
+ char *path1,
+ char *path2)
+{
+ char *p;
+
+ if (path1[0] == '\0' || path2[0] == '/')
+ return strdup(path2);
+ (void)asprintf(&p, path1[strlen(path1)-1] == '/' ?
+ "%s%s" : "%s/%s", path1, path2);
+ return p;
+}
+
+/*
+ * expanduser --
+ * Return a "~" or "~user" expanded path; need free.
+ *
+ * PUBLIC: char *expanduser __P((char *));
+ */
+char *
+expanduser(char *str)
+{
+ struct passwd *pwd;
+ char *p, *t, *u, *h;
+
+ /*
+ * This function always expands the content between the
+ * leading '~' and the first '/' or '\0' from the input.
+ * Return NULL whenever we fail to do so.
+ */
+ if (*str != '~')
+ return (NULL);
+ p = str + 1;
+ for (t = p; *t != '/' && *t != '\0'; ++t)
+ continue;
+ if (t == p) {
+ /* ~ */
+ if (issetugid() != 0 ||
+ (h = getenv("HOME")) == NULL) {
+ if (((h = getlogin()) != NULL &&
+ (pwd = getpwnam(h)) != NULL) ||
+ (pwd = getpwuid(getuid())) != NULL)
+ h = pwd->pw_dir;
+ else
+ return (NULL);
+ }
+ } else {
+ /* ~user */
+ if ((u = strndup(p, t - p)) == NULL)
+ return (NULL);
+ if ((pwd = getpwnam(u)) == NULL) {
+ free(u);
+ return (NULL);
+ } else
+ h = pwd->pw_dir;
+ free(u);
+ }
+
+ for (; *t == '/' && *t != '\0'; ++t)
+ continue;
+ return (join(h, t));
+}
+
+/*
+ * quote --
+ * Return a escaped string for /bin/sh; need free.
+ *
+ * PUBLIC: char *quote __P((char *));
+ */
+char *
+quote(char *str)
+{
+ char *p, *t;
+ size_t i = 0, n = 0;
+ int unsafe = 0;
+
+ for (p = str; *p != '\0'; p++, i++) {
+ if (*p == '\'')
+ n++;
+ if (unsafe)
+ continue;
+ if (isascii(*p)) {
+ if (isalnum(*p))
+ continue;
+ switch (*p) {
+ case '%': case '+': case ',': case '-': case '.':
+ case '/': case ':': case '=': case '@': case '_':
+ continue;
+ }
+ }
+ unsafe = 1;
+ }
+ if (!unsafe)
+ t = strdup(str);
+#define SQT "'\\''"
+ else if ((p = t = malloc(i + n * (sizeof(SQT) - 2) + 3)) != NULL) {
+ *p++ = '\'';
+ for (; *str != '\0'; str++) {
+ if (*str == '\'') {
+ (void)memcpy(p, SQT, sizeof(SQT) - 1);
+ p += sizeof(SQT) - 1;
+ } else
+ *p++ = *str;
+ }
+ *p++ = '\'';
+ *p = '\0';
+ }
+ return t;
+}
+
+/*
* v_strdup --
+ * Strdup for 8-bit character strings with an associated length.
+ *
+ * PUBLIC: char *v_strdup __P((SCR *, const char *, size_t));
+ */
+char *
+v_strdup(
+ SCR *sp,
+ const char *str,
+ size_t len)
+{
+ char *copy;
+
+ MALLOC(sp, copy, char *, len + 1);
+ if (copy == NULL)
+ return (NULL);
+ memcpy(copy, str, len);
+ copy[len] = '\0';
+ return (copy);
+}
+
+/*
+ * v_wstrdup --
* Strdup for wide character strings with an associated length.
*
- * PUBLIC: CHAR_T *v_strdup __P((SCR *, const CHAR_T *, size_t));
+ * PUBLIC: CHAR_T *v_wstrdup __P((SCR *, const CHAR_T *, size_t));
*/
CHAR_T *
-v_strdup(sp, str, len)
- SCR *sp;
- const CHAR_T *str;
- size_t len;
+v_wstrdup(SCR *sp,
+ const CHAR_T *str,
+ size_t len)
{
CHAR_T *copy;
- MALLOC(sp, copy, CHAR_T *, len + 1);
+ MALLOC(sp, copy, CHAR_T *, (len + 1) * sizeof(CHAR_T));
if (copy == NULL)
return (NULL);
- memcpy(copy, str, len * sizeof(CHAR_T));
+ MEMCPY(copy, str, len);
copy[len] = '\0';
return (copy);
}
@@ -145,17 +288,17 @@ v_strdup(sp, str, len)
* nget_uslong --
* Get an unsigned long, checking for overflow.
*
- * PUBLIC: enum nresult nget_uslong __P((u_long *, const char *, char **, int));
+ * PUBLIC: enum nresult nget_uslong __P((u_long *, const CHAR_T *, CHAR_T **, int));
*/
enum nresult
-nget_uslong(valp, p, endp, base)
- u_long *valp;
- const char *p;
- char **endp;
- int base;
+nget_uslong(
+ u_long *valp,
+ const CHAR_T *p,
+ CHAR_T **endp,
+ int base)
{
errno = 0;
- *valp = strtoul(p, endp, base);
+ *valp = STRTOUL(p, endp, base);
if (errno == 0)
return (NUM_OK);
if (errno == ERANGE && *valp == ULONG_MAX)
@@ -167,17 +310,17 @@ nget_uslong(valp, p, endp, base)
* nget_slong --
* Convert a signed long, checking for overflow and underflow.
*
- * PUBLIC: enum nresult nget_slong __P((long *, const char *, char **, int));
+ * PUBLIC: enum nresult nget_slong __P((long *, const CHAR_T *, CHAR_T **, int));
*/
enum nresult
-nget_slong(valp, p, endp, base)
- long *valp;
- const char *p;
- char **endp;
- int base;
+nget_slong(
+ long *valp,
+ const CHAR_T *p,
+ CHAR_T **endp,
+ int base)
{
errno = 0;
- *valp = strtol(p, endp, base);
+ *valp = STRTOL(p, endp, base);
if (errno == 0)
return (NUM_OK);
if (errno == ERANGE) {
@@ -189,12 +332,70 @@ nget_slong(valp, p, endp, base)
return (NUM_ERR);
}
-#ifdef DEBUG
-#ifdef __STDC__
-#include <stdarg.h>
+/*
+ * timepoint_steady --
+ * Get a timestamp from a monotonic clock.
+ *
+ * PUBLIC: void timepoint_steady __P((struct timespec *));
+ */
+void
+timepoint_steady(
+ struct timespec *ts)
+{
+#ifdef __APPLE__
+ static mach_timebase_info_data_t base = { 0 };
+ uint64_t val;
+ uint64_t ns;
+
+ if (base.denom == 0)
+ (void)mach_timebase_info(&base);
+
+ val = mach_absolute_time();
+ ns = val * base.numer / base.denom;
+ ts->tv_sec = ns / 1000000000;
+ ts->tv_nsec = ns % 1000000000;
+#else
+#ifdef CLOCK_MONOTONIC_FAST
+ (void)clock_gettime(CLOCK_MONOTONIC_FAST, ts);
#else
-#include <varargs.h>
+ (void)clock_gettime(CLOCK_MONOTONIC, ts);
+#endif
#endif
+}
+
+/*
+ * timepoint_system --
+ * Get the current calendar time.
+ *
+ * PUBLIC: void timepoint_system __P((struct timespec *));
+ */
+void
+timepoint_system(
+ struct timespec *ts)
+{
+#ifdef __APPLE__
+ clock_serv_t clk;
+ mach_timespec_t mts;
+ kern_return_t kr;
+
+ kr = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &clk);
+ if (kr != KERN_SUCCESS)
+ return;
+ (void)clock_get_time(clk, &mts);
+ (void)mach_port_deallocate(mach_task_self(), clk);
+ ts->tv_sec = mts.tv_sec;
+ ts->tv_nsec = mts.tv_nsec;
+#else
+#ifdef CLOCK_REALTIME_FAST
+ (void)clock_gettime(CLOCK_REALTIME_FAST, ts);
+#else
+ (void)clock_gettime(CLOCK_REALTIME, ts);
+#endif
+#endif
+}
+
+#ifdef DEBUG
+#include <stdarg.h>
/*
* TRACE --
@@ -203,25 +404,17 @@ nget_slong(valp, p, endp, base)
* PUBLIC: void TRACE __P((SCR *, const char *, ...));
*/
void
-#ifdef __STDC__
-TRACE(SCR *sp, const char *fmt, ...)
-#else
-TRACE(sp, fmt, va_alist)
- SCR *sp;
- char *fmt;
- va_dcl
-#endif
+TRACE(
+ SCR *sp,
+ const char *fmt,
+ ...)
{
FILE *tfp;
va_list ap;
if ((tfp = sp->gp->tracefp) == NULL)
return;
-#ifdef __STDC__
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
(void)vfprintf(tfp, fmt, ap);
va_end(ap);
diff --git a/common/util.h b/common/util.h
index 46edb4aae5a8..e6b2bec94e15 100644
--- a/common/util.h
+++ b/common/util.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)util.h 10.5 (Berkeley) 3/16/96
+ * $Id: util.h,v 10.7 2013/02/24 21:00:10 zy Exp $
*/
/* Macros to init/set/clear/test flags. */
@@ -54,3 +54,40 @@ enum nresult { NUM_ERR, NUM_OK, NUM_OVER, NUM_UNDER };
NUM_OK)
#define NADD_USLONG(sp, v1, v2) \
(NPFITS(ULONG_MAX, (v1), (v2)) ? NUM_OK : NUM_OVER)
+
+/* Macros for min/max. */
+#undef MIN
+#undef MAX
+#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
+#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a))
+
+/* Operations on timespecs */
+#undef timespecclear
+#undef timespecisset
+#undef timespeccmp
+#undef timespecadd
+#undef timespecsub
+#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
+#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)
+#define timespeccmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define timespecadd(vvp, uvp) \
+ do { \
+ (vvp)->tv_sec += (uvp)->tv_sec; \
+ (vvp)->tv_nsec += (uvp)->tv_nsec; \
+ if ((vvp)->tv_nsec >= 1000000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_nsec -= 1000000000; \
+ } \
+ } while (0)
+#define timespecsub(vvp, uvp) \
+ do { \
+ (vvp)->tv_sec -= (uvp)->tv_sec; \
+ (vvp)->tv_nsec -= (uvp)->tv_nsec; \
+ if ((vvp)->tv_nsec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_nsec += 1000000000; \
+ } \
+ } while (0)
diff --git a/docs/USD.doc/vi.man/vi.1 b/docs/USD.doc/vi.man/vi.1
index 22aee3e7e952..1292eef3ffa8 100644
--- a/docs/USD.doc/vi.man/vi.1
+++ b/docs/USD.doc/vi.man/vi.1
@@ -2,15 +2,17 @@
.\" The Regents of the University of California. All rights reserved.
.\" Copyright (c) 1994, 1995, 1996
.\" Keith Bostic. All rights reserved.
+.\" Copyright (c) 2011
+.\" Zhihao Yuan. All rights reserved.
.\"
.\" This document may not be republished without written permission from
.\" Keith Bostic.
.\"
.\" See the LICENSE file for redistribution information.
.\"
-.\" @(#)vi.1 8.51 (Berkeley) 10/10/96
+.\" $Id: vi.1,v 8.59 2012/02/12 12:56:37 zy Exp $
.\"
-.TH VI 1 "October 10, 1996"
+.TH VI 1 "11 February, 2012"
.UC
.SH NAME
ex, vi, view \- text editors
@@ -150,7 +152,7 @@ Batch mode is useful when running
scripts.
Prompts, informative messages and other user oriented message
are turned off,
-and no startup files or environmental variables are read.
+and no startup files or environment variables are read.
This is the POSIX 1003.2 interface for the historic ``\-'' argument.
.I \&Nex/nvi
supports both the old and new syntax.
@@ -1103,10 +1105,13 @@ Regular expressions are extended (i.e.
.IR egrep (1)\-\c
style) expressions.
.TP
-.B "filec [no default]"
+.B "filec [<tab>]"
Set the character to perform file path completion on the colon
command line.
.TP
+.B "fileencoding, fe [auto detect]"
+Set the encoding of the current file.
+.TP
.B "flash [on]"
Flash the screen instead of beeping the keyboard on error.
.TP
@@ -1120,6 +1125,9 @@ as long as an upper-case letter does not appear in the search string.
.B "ignorecase, ic [off]"
Ignore case differences in regular expressions.
.TP
+.B "inputencoding, ie [locale]"
+Set the encoding of your input characters.
+.TP
.B "keytime [6]"
The 10th's of a second
.I ex/vi
@@ -1151,6 +1159,11 @@ read or written.
.B "magic [on]"
Treat certain characters specially in regular expressions.
.TP
+.B "matchchars [[]{}()]"
+Character pairs looked for by the
+.B %
+command.
+.TP
.B "matchtime [7]"
.I \&Vi
only.
@@ -1291,7 +1304,7 @@ Set the autoindent and shift command indentation width.
.B "showmatch, sm [off]"
.I \&Vi
only.
-Note matching ``{'' and ``('' for ``}'' and ``)'' characters.
+Note the left matching characters when the right ones are inserted.
.TP
.B "showmode, smd [off]"
.I \&Vi
@@ -1372,8 +1385,7 @@ command.
Set the window size for the screen.
.TP
.B "windowname [off]"
-Change the icon/window name to the current file name even if it can't
-be restored on editor exit.
+Change the icon/window name to the current file name.
.TP
.B "wraplen, wl [0]"
.I \&Vi
@@ -1406,14 +1418,14 @@ Set searches to wrap around the end or beginning of the file.
.TP
.B "writeany, wa [off]"
Turn off file-overwriting checks.
-.SH ENVIRONMENTAL VARIABLES
+.SH ENVIRONMENT VARIABLES
.TP
.I COLUMNS
The number of columns on the screen.
This value overrides any system or terminal specific values.
If the
.I COLUMNS
-environmental variable is not set when
+environment variable is not set when
.I ex/vi
runs, or the
.B columns
@@ -1442,7 +1454,7 @@ The number of rows on the screen.
This value overrides any system or terminal specific values.
If the
.I LINES
-environmental variable is not set when
+environment variable is not set when
.I ex/vi
runs, or the
.B lines
@@ -1465,7 +1477,7 @@ The user's terminal type.
The default is the type ``unknown''.
If the
.I TERM
-environmental variable is not set when
+environment variable is not set when
.I ex/vi
runs, or the
.B term
@@ -1542,58 +1554,12 @@ $HOME/.exrc
2nd choice for local directory startup file.
.SH SEE ALSO
.IR ctags (1),
-.IR more (3),
+.IR iconv (1),
+.IR more (1),
.IR curses (3),
.IR dbopen (3)
.sp
-The ``Vi Quick Reference'' card.
-.sp
-``An Introduction to Display Editing with Vi'', found in the
-``UNIX User's Manual Supplementary Documents''
-section of both the 4.3BSD and 4.4BSD manual sets.
-This document is the closest thing available to an introduction to the
-.I \&vi
-screen editor.
-.sp
-``Ex Reference Manual (Version 3.7)'',
-found in the
-``UNIX User's Manual Supplementary Documents''
-section of both the 4.3BSD and 4.4BSD manual sets.
-This document is the final reference for the
-.I \&ex
-editor, as distributed in most historic 4BSD and System V systems.
-.sp
-``Edit: A tutorial'',
-found in the
-``UNIX User's Manual Supplementary Documents''
-section of the 4.3BSD manual set.
-This document is an introduction to a simple version of the
-.I \&ex
-screen editor.
-.sp
-``Ex/Vi Reference Manual'',
-found in the
-``UNIX User's Manual Supplementary Documents''
-section of the 4.4BSD manual set.
-This document is the final reference for the
-.I \&nex/nvi
-text editors, as distributed in 4.4BSD and 4.4BSD-Lite.
-.PP
-.I Roff
-source for all of these documents is distributed with
-.I nex/nvi
-in the
-.I nvi/USD.doc
-directory of the
-.I nex/nvi
-source code.
-.sp
-The files ``autowrite'', ``input'', ``quoting'' and ``structures''
-found in the
-.I nvi/docs/internals
-directory of the
-.I nex/nvi
-source code.
+``UNIX User's Manual Supplementary Documents: Text Editing''.
.SH HISTORY
The
.I nex/nvi
diff --git a/docs/USD.doc/vi.ref/vi.ref b/docs/USD.doc/vi.ref/vi.ref
index a880c1659e11..12a483f1edb1 100644
--- a/docs/USD.doc/vi.ref/vi.ref
+++ b/docs/USD.doc/vi.ref/vi.ref
@@ -10,6 +10,7 @@
.\"
.\" @(#)vi.ref 8.88 (Berkeley) 10/19/96
.\"
+.\" $FreeBSD$
.\"
.so ref.so
.tp
@@ -27,7 +28,6 @@ Department of Electrical Engineering and Computer Science
University of California, Berkeley
Berkeley, California 94720
.sp 1
-\*(td
.)l
.sp 3
.(l C
diff --git a/docs/help b/docs/help
index 81df84aa1353..a7b5d748e043 100644
--- a/docs/help
+++ b/docs/help
@@ -129,7 +129,7 @@ EX COMMANDS:
^D: scroll lines
!: filter lines through commands or run commands
#: display numbered lines
- &: repeat the last subsitution
+ &: repeat the last substitution
*: execute a buffer
<: shift lines left
=: display line number
diff --git a/ex/ex.c b/ex/ex.c
index f92d8f7c4f9a..609f961bbe46 100644
--- a/ex/ex.c
+++ b/ex/ex.c
@@ -10,13 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex.c 10.57 (Berkeley) 10/10/96";
+static const char sccsid[] = "$Id: ex.c,v 10.80 2012/10/03 16:24:40 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -35,11 +34,11 @@ static const char sccsid[] = "@(#)ex.c 10.57 (Berkeley) 10/10/96";
static void ex_comlog __P((SCR *, EXCMD *));
#endif
static EXCMDLIST const *
- ex_comm_search __P((char *, size_t));
+ ex_comm_search __P((CHAR_T *, size_t));
static int ex_discard __P((SCR *));
static int ex_line __P((SCR *, EXCMD *, MARK *, int *, int *));
static int ex_load __P((SCR *));
-static void ex_unknown __P((SCR *, char *, size_t));
+static void ex_unknown __P((SCR *, CHAR_T *, size_t));
/*
* ex --
@@ -48,8 +47,7 @@ static void ex_unknown __P((SCR *, char *, size_t));
* PUBLIC: int ex __P((SCR **));
*/
int
-ex(spp)
- SCR **spp;
+ex(SCR **spp)
{
EX_PRIVATE *exp;
GS *gp;
@@ -67,9 +65,9 @@ ex(spp)
return (1);
/* Flush any saved messages. */
- while ((mp = gp->msgq.lh_first) != NULL) {
+ while ((mp = SLIST_FIRST(gp->msgq)) != NULL) {
gp->scr_msg(sp, mp->mtype, mp->buf, mp->len);
- LIST_REMOVE(mp, q);
+ SLIST_REMOVE_HEAD(gp->msgq, q);
free(mp->buf);
free(mp);
}
@@ -105,7 +103,7 @@ ex(spp)
/* Clear any current interrupts, and get a command. */
CLR_INTERRUPT(sp);
- if (ex_txt(sp, &sp->tiq, ':', flags))
+ if (ex_txt(sp, sp->tiq, ':', flags))
return (1);
if (INTERRUPTED(sp)) {
(void)ex_puts(sp, "\n");
@@ -120,9 +118,9 @@ ex(spp)
* If the user entered a single carriage return, send
* ex_cmd() a separator -- it discards single newlines.
*/
- tp = sp->tiq.cqh_first;
+ tp = TAILQ_FIRST(sp->tiq);
if (tp->len == 0) {
- gp->excmd.cp = " "; /* __TK__ why not |? */
+ gp->excmd.cp = L(" "); /* __TK__ why not |? */
gp->excmd.clen = 1;
} else {
gp->excmd.cp = tp->lb;
@@ -192,8 +190,7 @@ ex(spp)
* PUBLIC: int ex_cmd __P((SCR *));
*/
int
-ex_cmd(sp)
- SCR *sp;
+ex_cmd(SCR *sp)
{
enum nresult nret;
EX_PRIVATE *exp;
@@ -205,9 +202,12 @@ ex_cmd(sp)
u_int32_t flags;
long ltmp;
int at_found, gv_found;
- int ch, cnt, delim, isaddr, namelen;
+ int cnt, delim, isaddr, namelen;
int newscreen, notempty, tmp, vi_address;
- char *arg1, *p, *s, *t;
+ CHAR_T *arg1, *s, *p, *t;
+ CHAR_T ch = '\0';
+ CHAR_T *n;
+ char *np;
gp = sp->gp;
exp = EXP(sp);
@@ -217,7 +217,7 @@ ex_cmd(sp)
* This means that *everything* must be resolved when we leave
* this function for any reason.
*/
-loop: ecp = gp->ecq.lh_first;
+loop: ecp = SLIST_FIRST(gp->ecq);
/* If we're reading a command from a file, set up error information. */
if (ecp->if_name != NULL) {
@@ -259,7 +259,7 @@ loop: ecp = gp->ecq.lh_first;
if ((ch = *ecp->cp) == '\n') {
++gp->if_lno;
++ecp->if_lno;
- } else if (isblank(ch))
+ } else if (cmdskip(ch))
notempty = 1;
else
break;
@@ -298,7 +298,7 @@ loop: ecp = gp->ecq.lh_first;
/* Skip whitespace. */
for (; ecp->clen > 0; ++ecp->cp, --ecp->clen) {
ch = *ecp->cp;
- if (!isblank(ch))
+ if (!cmdskip(ch))
break;
}
@@ -321,7 +321,7 @@ loop: ecp = gp->ecq.lh_first;
(!notempty || F_ISSET(sp, SC_VI) || F_ISSET(ecp, E_BLIGNORE))) {
if (ex_load(sp))
goto rfail;
- ecp = gp->ecq.lh_first;
+ ecp = SLIST_FIRST(gp->ecq);
if (ecp->clen == 0)
goto rsuccess;
goto loop;
@@ -353,7 +353,7 @@ loop: ecp = gp->ecq.lh_first;
*/
for (; ecp->clen > 0; ++ecp->cp, --ecp->clen) {
ch = *ecp->cp;
- if (!isblank(ch) && ch != ':')
+ if (!cmdskip(ch) && ch != ':')
break;
}
@@ -377,10 +377,10 @@ loop: ecp = gp->ecq.lh_first;
* from vi mode, and displayed lines 2, 3, and 4, so we do a default
* command for each separator.
*/
-#define SINGLE_CHAR_COMMANDS "\004!#&*<=>@~"
+#define SINGLE_CHAR_COMMANDS L("\004!#&*<=>@~")
newscreen = 0;
if (ecp->clen != 0 && ecp->cp[0] != '|' && ecp->cp[0] != '\n') {
- if (strchr(SINGLE_CHAR_COMMANDS, *ecp->cp)) {
+ if (STRCHR(SINGLE_CHAR_COMMANDS, *ecp->cp)) {
p = ecp->cp;
++ecp->cp;
--ecp->clen;
@@ -388,7 +388,7 @@ loop: ecp = gp->ecq.lh_first;
} else {
for (p = ecp->cp;
ecp->clen > 0; --ecp->clen, ++ecp->cp)
- if (!isalpha(*ecp->cp))
+ if (!isascii(*ecp->cp) || !isalpha(*ecp->cp))
break;
if ((namelen = ecp->cp - p) == 0) {
msgq(sp, M_ERR, "080|Unknown command name");
@@ -415,7 +415,7 @@ loop: ecp = gp->ecq.lh_first;
switch (p[0]) {
case 'd':
for (s = p,
- t = cmds[C_DELETE].name; *s == *t; ++s, ++t);
+ n = cmds[C_DELETE].name; *s == *n; ++s, ++n);
if (s[0] == 'l' || s[0] == 'p' || s[0] == '+' ||
s[0] == '-' || s[0] == '^' || s[0] == '#') {
len = (ecp->cp - p) - (s - p);
@@ -510,7 +510,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
/* Secure means no shell access. */
if (F_ISSET(ecp->cmd, E_SECURE) && O_ISSET(sp, O_SECURE)) {
- ex_emsg(sp, ecp->cmd->name, EXM_SECURE);
+ ex_wemsg(sp, ecp->cmd->name, EXM_SECURE);
goto err;
}
@@ -574,8 +574,8 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
/* Check for ex mode legality. */
if (F_ISSET(sp, SC_EX) && (F_ISSET(ecp->cmd, E_VIONLY) || newscreen)) {
- msgq(sp, M_ERR,
- "082|%s: command not available in ex mode", ecp->cmd->name);
+ msgq_wstr(sp, M_ERR, ecp->cmd->name,
+ "082|%s: command not available in ex mode");
goto err;
}
@@ -629,7 +629,8 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
arg1_len = 0;
ecp->save_cmd = ecp->cp;
if (ecp->cmd == &cmds[C_EDIT] || ecp->cmd == &cmds[C_EX] ||
- ecp->cmd == &cmds[C_NEXT] || ecp->cmd == &cmds[C_VISUAL_VI]) {
+ ecp->cmd == &cmds[C_NEXT] || ecp->cmd == &cmds[C_VISUAL_VI] ||
+ ecp->cmd == &cmds[C_VSPLIT]) {
/*
* Move to the next non-whitespace character. A '!'
* immediately following the command is eaten as a
@@ -644,7 +645,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
ecp->save_cmd = ecp->cp;
}
for (; ecp->clen > 0; --ecp->clen, ++ecp->cp)
- if (!isblank(*ecp->cp))
+ if (!cmdskip(*ecp->cp))
break;
/*
* QUOTING NOTE:
@@ -666,7 +667,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
++discard;
--ecp->clen;
ch = *++ecp->cp;
- } else if (isblank(ch))
+ } else if (cmdskip(ch))
break;
*p++ = ch;
}
@@ -710,7 +711,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
*/
for (tmp = 0; ecp->clen > 0; --ecp->clen, ++ecp->cp) {
ch = *ecp->cp;
- if (isblank(ch))
+ if (cmdskip(ch))
tmp = 1;
else
break;
@@ -728,10 +729,11 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
* into something like ":s g", so use the special s command.
*/
for (; ecp->clen > 0; --ecp->clen, ++ecp->cp)
- if (!isblank(ecp->cp[0]))
+ if (!cmdskip(ecp->cp[0]))
break;
- if (isalnum(ecp->cp[0]) || ecp->cp[0] == '|') {
+ if (!isascii(ecp->cp[0]) ||
+ isalnum(ecp->cp[0]) || ecp->cp[0] == '|') {
ecp->rcmd = cmds[C_SUBSTITUTE];
ecp->rcmd.fn = ex_subagain;
ecp->cmd = &ecp->rcmd;
@@ -775,7 +777,7 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
for (p = ecp->cp; ecp->clen > 0; --ecp->clen, ++ecp->cp) {
ch = ecp->cp[0];
if (IS_ESCAPE(sp, ecp, ch) && ecp->clen > 1) {
- tmp = ecp->cp[1];
+ CHAR_T tmp = ecp->cp[1];
if (tmp == '\n' || tmp == '|') {
if (tmp == '\n') {
++gp->if_lno;
@@ -816,7 +818,10 @@ skip_srch: if (ecp->cmd == &cmds[C_VISUAL_EX] && F_ISSET(sp, SC_VI))
*/
if (ecp->cmd == &cmds[C_SET])
for (p = ecp->cp, len = ecp->clen; len > 0; --len, ++p)
- if (*p == '\\')
+ if (IS_ESCAPE(sp, ecp, *p) && len > 1) {
+ --len;
+ ++p;
+ } else if (*p == '\\')
*p = CH_LITERAL;
/*
@@ -935,13 +940,13 @@ two_addr: switch (ecp->addrcnt) {
}
ecp->flagoff = 0;
- for (p = ecp->cmd->syntax; *p != '\0'; ++p) {
+ for (np = ecp->cmd->syntax; *np != '\0'; ++np) {
/*
* The force flag is sensitive to leading whitespace, i.e.
* "next !" is different from "next!". Handle it before
* skipping leading <blank>s.
*/
- if (*p == '!') {
+ if (*np == '!') {
if (ecp->clen > 0 && *ecp->cp == '!') {
++ecp->cp;
--ecp->clen;
@@ -952,12 +957,12 @@ two_addr: switch (ecp->addrcnt) {
/* Skip leading <blank>s. */
for (; ecp->clen > 0; --ecp->clen, ++ecp->cp)
- if (!isblank(*ecp->cp))
+ if (!cmdskip(*ecp->cp))
break;
if (ecp->clen == 0)
break;
- switch (*p) {
+ switch (*np) {
case '1': /* +, -, #, l, p */
/*
* !!!
@@ -1012,7 +1017,7 @@ end_case1: break;
FL_SET(ecp->iflags, E_C_CARAT);
break;
case '=':
- if (*p == '3') {
+ if (*np == '3') {
FL_SET(ecp->iflags, E_C_EQUAL);
break;
}
@@ -1032,7 +1037,7 @@ end_case23: break;
*/
if ((ecp->cp[0] == '+' || ecp->cp[0] == '-' ||
ecp->cp[0] == '^' || ecp->cp[0] == '#') &&
- strchr(p, '1') != NULL)
+ strchr(np, '1') != NULL)
break;
/*
* !!!
@@ -1040,7 +1045,7 @@ end_case23: break;
* command "d2" would be a delete into buffer '2', and
* not a two-line deletion.
*/
- if (!isdigit(ecp->cp[0])) {
+ if (!ISDIGIT(ecp->cp[0])) {
ecp->buffer = *ecp->cp;
++ecp->cp;
--ecp->clen;
@@ -1048,9 +1053,9 @@ end_case23: break;
}
break;
case 'c': /* count [01+a] */
- ++p;
+ ++np;
/* Validate any signed value. */
- if (!isdigit(*ecp->cp) && (*p != '+' ||
+ if (!ISDIGIT(*ecp->cp) && (*np != '+' ||
(*ecp->cp != '+' && *ecp->cp != '-')))
break;
/* If a signed value, set appropriate flags. */
@@ -1063,7 +1068,7 @@ end_case23: break;
ex_badaddr(sp, NULL, A_NOTSET, nret);
goto err;
}
- if (ltmp == 0 && *p != '0') {
+ if (ltmp == 0 && *np != '0') {
msgq(sp, M_ERR, "083|Count may not be zero");
goto err;
}
@@ -1079,7 +1084,7 @@ end_case23: break;
* join) do different things with counts than with
* line addresses.
*/
- if (*p == 'a') {
+ if (*np == 'a') {
ecp->addr1 = ecp->addr2;
ecp->addr2.lno = ecp->addr1.lno + ltmp - 1;
} else
@@ -1106,7 +1111,7 @@ end_case23: break;
/* Line specifications are always required. */
if (!isaddr) {
- msgq_str(sp, M_ERR, ecp->cp,
+ msgq_wstr(sp, M_ERR, ecp->cp,
"084|%s: bad line specification");
goto err;
}
@@ -1149,7 +1154,7 @@ end_case23: break;
ecp, ch) && ecp->clen > 1) {
--ecp->clen;
*p++ = *++ecp->cp;
- } else if (isblank(ch)) {
+ } else if (cmdskip(ch)) {
++ecp->cp;
--ecp->clen;
break;
@@ -1163,7 +1168,7 @@ end_case23: break;
for (; ecp->clen > 0;
--ecp->clen, ++ecp->cp) {
ch = *ecp->cp;
- if (!isblank(ch))
+ if (!cmdskip(ch))
break;
}
if (ecp->clen == 0)
@@ -1186,29 +1191,35 @@ end_case23: break;
case 'w': /* word */
if (argv_exp3(sp, ecp, ecp->cp, ecp->clen))
goto err;
-arg_cnt_chk: if (*++p != 'N') { /* N */
+arg_cnt_chk: if (*++np != 'N') { /* N */
/*
* If a number is specified, must either be
* 0 or that number, if optional, and that
* number, if required.
*/
- tmp = *p - '0';
- if ((*++p != 'o' || exp->argsoff != 0) &&
+ tmp = *np - '0';
+ if ((*++np != 'o' || exp->argsoff != 0) &&
exp->argsoff != tmp)
goto usage;
}
goto addr_verify;
- default:
+ default: {
+ size_t nlen;
+ char *nstr;
+
+ INT2CHAR(sp, ecp->cmd->name, STRLEN(ecp->cmd->name) + 1,
+ nstr, nlen);
msgq(sp, M_ERR,
"085|Internal syntax table error (%s: %s)",
- ecp->cmd->name, KEY_NAME(sp, *p));
+ nstr, KEY_NAME(sp, *np));
+ }
}
}
/* Skip trailing whitespace. */
for (; ecp->clen > 0; --ecp->clen) {
ch = *ecp->cp++;
- if (!isblank(ch))
+ if (!cmdskip(ch))
break;
}
@@ -1216,7 +1227,7 @@ arg_cnt_chk: if (*++p != 'N') { /* N */
* There shouldn't be anything left, and no more required fields,
* i.e neither 'l' or 'r' in the syntax string.
*/
- if (ecp->clen != 0 || strpbrk(p, "lr")) {
+ if (ecp->clen != 0 || strpbrk(np, "lr")) {
usage: msgq(sp, M_ERR, "086|Usage: %s", ecp->cmd->usage);
goto err;
}
@@ -1379,8 +1390,8 @@ addr_verify:
/* Make sure no function left global temporary space locked. */
if (F_ISSET(gp, G_TMP_INUSE)) {
F_CLR(gp, G_TMP_INUSE);
- msgq(sp, M_ERR, "087|%s: temporary buffer not released",
- ecp->cmd->name);
+ msgq_wstr(sp, M_ERR, ecp->cmd->name,
+ "087|%s: temporary buffer not released");
}
#endif
/*
@@ -1493,7 +1504,7 @@ addr_verify:
ecp->save_cmd -= arg1_len;
ecp->save_cmdlen += arg1_len;
- memcpy(ecp->save_cmd, arg1, arg1_len);
+ MEMCPY(ecp->save_cmd, arg1, arg1_len);
/*
* Any commands executed from a +cmd are executed starting at
@@ -1527,8 +1538,7 @@ addr_verify:
*/
if (F_ISSET(sp, SC_EXIT | SC_EXIT_FORCE | SC_FSWITCH | SC_SSWITCH)) {
at_found = gv_found = 0;
- for (ecp = sp->gp->ecq.lh_first;
- ecp != NULL; ecp = ecp->q.le_next)
+ SLIST_FOREACH(ecp, sp->gp->ecq, q)
switch (ecp->agv_flags) {
case 0:
case AGV_AT_NORANGE:
@@ -1580,7 +1590,7 @@ err: /*
break;
}
}
- if (ecp->save_cmdlen != 0 || gp->ecq.lh_first != &gp->excmd) {
+ if (ecp->save_cmdlen != 0 || SLIST_FIRST(gp->ecq) != &gp->excmd) {
discard: msgq(sp, M_BERR,
"092|Ex command failed: pending commands discarded");
ex_discard(sp);
@@ -1609,10 +1619,7 @@ rsuccess: tmp = 0;
* PUBLIC: int ex_range __P((SCR *, EXCMD *, int *));
*/
int
-ex_range(sp, ecp, errp)
- SCR *sp;
- EXCMD *ecp;
- int *errp;
+ex_range(SCR *sp, EXCMD *ecp, int *errp)
{
enum { ADDR_FOUND, ADDR_NEED, ADDR_NONE } addr;
GS *gp;
@@ -1811,19 +1818,15 @@ ret: if (F_ISSET(ecp, E_VISEARCH))
* it's fairly close.
*/
static int
-ex_line(sp, ecp, mp, isaddrp, errp)
- SCR *sp;
- EXCMD *ecp;
- MARK *mp;
- int *isaddrp, *errp;
+ex_line(SCR *sp, EXCMD *ecp, MARK *mp, int *isaddrp, int *errp)
{
enum nresult nret;
EX_PRIVATE *exp;
GS *gp;
long total, val;
int isneg;
- int (*sf) __P((SCR *, MARK *, MARK *, char *, size_t, char **, u_int));
- char *endp;
+ int (*sf) __P((SCR *, MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int));
+ CHAR_T *endp;
gp = sp->gp;
exp = EXP(sp);
@@ -1832,7 +1835,7 @@ ex_line(sp, ecp, mp, isaddrp, errp)
F_CLR(ecp, E_DELTA);
/* No addresses permitted until a file has been read in. */
- if (sp->ep == NULL && strchr("$0123456789'\\/?.+-^", *ecp->cp)) {
+ if (sp->ep == NULL && STRCHR(L("$0123456789'\\/?.+-^"), *ecp->cp)) {
ex_badaddr(sp, NULL, A_EMPTY, NUM_OK);
*errp = 1;
return (0);
@@ -1893,7 +1896,7 @@ ex_line(sp, ecp, mp, isaddrp, errp)
* difference. C'est la vie.
*/
if (ecp->clen < 2 ||
- ecp->cp[1] != '/' && ecp->cp[1] != '?') {
+ (ecp->cp[1] != '/' && ecp->cp[1] != '?')) {
msgq(sp, M_ERR, "096|\\ not followed by / or ?");
*errp = 1;
return (0);
@@ -1943,7 +1946,7 @@ search: mp->lno = sp->lno;
* the '+' could be omitted. (This feature is found in ed
* as well.)
*/
- if (ecp->clen > 1 && isdigit(ecp->cp[1]))
+ if (ecp->clen > 1 && ISDIGIT(ecp->cp[1]))
*ecp->cp = '+';
else {
++ecp->cp;
@@ -1954,14 +1957,14 @@ search: mp->lno = sp->lno;
/* Skip trailing <blank>s. */
for (; ecp->clen > 0 &&
- isblank(ecp->cp[0]); ++ecp->cp, --ecp->clen);
+ cmdskip(ecp->cp[0]); ++ecp->cp, --ecp->clen);
/*
* Evaluate any offset. If no address yet found, the offset
* is relative to ".".
*/
total = 0;
- if (ecp->clen != 0 && (isdigit(ecp->cp[0]) ||
+ if (ecp->clen != 0 && (ISDIGIT(ecp->cp[0]) ||
ecp->cp[0] == '+' || ecp->cp[0] == '-' ||
ecp->cp[0] == '^')) {
if (!*isaddrp) {
@@ -1997,14 +2000,14 @@ search: mp->lno = sp->lno;
*/
F_SET(ecp, E_DELTA);
for (;;) {
- for (; ecp->clen > 0 && isblank(ecp->cp[0]);
+ for (; ecp->clen > 0 && cmdskip(ecp->cp[0]);
++ecp->cp, --ecp->clen);
- if (ecp->clen == 0 || !isdigit(ecp->cp[0]) &&
+ if (ecp->clen == 0 || (!ISDIGIT(ecp->cp[0]) &&
ecp->cp[0] != '+' && ecp->cp[0] != '-' &&
- ecp->cp[0] != '^')
+ ecp->cp[0] != '^'))
break;
- if (!isdigit(ecp->cp[0]) &&
- !isdigit(ecp->cp[1])) {
+ if (!ISDIGIT(ecp->cp[0]) &&
+ !ISDIGIT(ecp->cp[1])) {
total += ecp->cp[0] == '+' ? 1 : -1;
--ecp->clen;
++ecp->cp;
@@ -2062,8 +2065,7 @@ search: mp->lno = sp->lno;
* Load up the next command, which may be an @ buffer or global command.
*/
static int
-ex_load(sp)
- SCR *sp;
+ex_load(SCR *sp)
{
GS *gp;
EXCMD *ecp;
@@ -2076,16 +2078,18 @@ ex_load(sp)
* can't be an AGV command, which makes things a bit easier.
*/
for (gp = sp->gp;;) {
+ ecp = SLIST_FIRST(gp->ecq);
+
+ /* Discard the allocated source name as requested. */
+ if (F_ISSET(ecp, E_NAMEDISCARD))
+ free(ecp->if_name);
+
/*
* If we're back to the original structure, leave it around,
- * but discard any allocated source name, we've returned to
- * the beginning of the command stack.
+ * since we've returned to the beginning of the command stack.
*/
- if ((ecp = gp->ecq.lh_first) == &gp->excmd) {
- if (F_ISSET(ecp, E_NAMEDISCARD)) {
- free(ecp->if_name);
- ecp->if_name = NULL;
- }
+ if (ecp == &gp->excmd) {
+ ecp->if_name = NULL;
return (0);
}
@@ -2105,15 +2109,15 @@ ex_load(sp)
*/
if (FL_ISSET(ecp->agv_flags, AGV_ALL)) {
/* Discard any exhausted ranges. */
- while ((rp = ecp->rq.cqh_first) != (void *)&ecp->rq)
+ while ((rp = TAILQ_FIRST(ecp->rq)) != NULL)
if (rp->start > rp->stop) {
- CIRCLEQ_REMOVE(&ecp->rq, rp, q);
+ TAILQ_REMOVE(ecp->rq, rp, q);
free(rp);
} else
break;
/* If there's another range, continue with it. */
- if (rp != (void *)&ecp->rq)
+ if (rp != NULL)
break;
/* If it's a global/v command, fix up the last line. */
@@ -2131,7 +2135,7 @@ ex_load(sp)
}
/* Discard the EXCMD. */
- LIST_REMOVE(ecp, q);
+ SLIST_REMOVE_HEAD(gp->ecq, q);
free(ecp);
}
@@ -2142,7 +2146,7 @@ ex_load(sp)
* so we have play games.
*/
ecp->cp = ecp->o_cp;
- memcpy(ecp->cp, ecp->cp + ecp->o_clen, ecp->o_clen);
+ MEMCPY(ecp->cp, ecp->cp + ecp->o_clen, ecp->o_clen);
ecp->clen = ecp->o_clen;
ecp->range_lno = sp->lno = rp->start++;
@@ -2156,8 +2160,7 @@ ex_load(sp)
* Discard any pending ex commands.
*/
static int
-ex_discard(sp)
- SCR *sp;
+ex_discard(SCR *sp)
{
GS *gp;
EXCMD *ecp;
@@ -2167,18 +2170,26 @@ ex_discard(sp)
* We know the first command can't be an AGV command, so we don't
* process it specially. We do, however, nail the command itself.
*/
- for (gp = sp->gp; (ecp = gp->ecq.lh_first) != &gp->excmd;) {
+ for (gp = sp->gp;;) {
+ ecp = SLIST_FIRST(gp->ecq);
+ if (F_ISSET(ecp, E_NAMEDISCARD))
+ free(ecp->if_name);
+ /* Reset the last command without dropping it. */
+ if (ecp == &gp->excmd)
+ break;
if (FL_ISSET(ecp->agv_flags, AGV_ALL)) {
- while ((rp = ecp->rq.cqh_first) != (void *)&ecp->rq) {
- CIRCLEQ_REMOVE(&ecp->rq, rp, q);
+ while ((rp = TAILQ_FIRST(ecp->rq)) != NULL) {
+ TAILQ_REMOVE(ecp->rq, rp, q);
free(rp);
}
free(ecp->o_cp);
}
- LIST_REMOVE(ecp, q);
+ SLIST_REMOVE_HEAD(gp->ecq, q);
free(ecp);
}
- gp->ecq.lh_first->clen = 0;
+
+ ecp->if_name = NULL;
+ ecp->clen = 0;
return (0);
}
@@ -2187,19 +2198,16 @@ ex_discard(sp)
* Display an unknown command name.
*/
static void
-ex_unknown(sp, cmd, len)
- SCR *sp;
- char *cmd;
- size_t len;
+ex_unknown(SCR *sp, CHAR_T *cmd, size_t len)
{
size_t blen;
- char *bp;
+ CHAR_T *bp;
- GET_SPACE_GOTO(sp, bp, blen, len + 1);
+ GET_SPACE_GOTOW(sp, bp, blen, len + 1);
bp[len] = '\0';
- memcpy(bp, cmd, len);
- msgq_str(sp, M_ERR, bp, "098|The %s command is unknown");
- FREE_SPACE(sp, bp, blen);
+ MEMCPY(bp, cmd, len);
+ msgq_wstr(sp, M_ERR, bp, "098|The %s command is unknown");
+ FREE_SPACEW(sp, bp, blen);
alloc_err:
return;
@@ -2211,12 +2219,10 @@ alloc_err:
* [un]abbreviate command, so it can turn off abbreviations. See
* the usual ranting in the vi/v_txt_ev.c:txt_abbrev() routine.
*
- * PUBLIC: int ex_is_abbrev __P((char *, size_t));
+ * PUBLIC: int ex_is_abbrev __P((CHAR_T *, size_t));
*/
int
-ex_is_abbrev(name, len)
- char *name;
- size_t len;
+ex_is_abbrev(CHAR_T *name, size_t len)
{
EXCMDLIST const *cp;
@@ -2230,12 +2236,10 @@ ex_is_abbrev(name, len)
* unmap command, so it can turn off input mapping. See the usual
* ranting in the vi/v_txt_ev.c:txt_unmap() routine.
*
- * PUBLIC: int ex_is_unmap __P((char *, size_t));
+ * PUBLIC: int ex_is_unmap __P((CHAR_T *, size_t));
*/
int
-ex_is_unmap(name, len)
- char *name;
- size_t len;
+ex_is_unmap(CHAR_T *name, size_t len)
{
EXCMDLIST const *cp;
@@ -2255,9 +2259,7 @@ ex_is_unmap(name, len)
* Search for a command name.
*/
static EXCMDLIST const *
-ex_comm_search(name, len)
- char *name;
- size_t len;
+ex_comm_search(CHAR_T *name, size_t len)
{
EXCMDLIST const *cp;
@@ -2266,7 +2268,7 @@ ex_comm_search(name, len)
return (NULL);
if (cp->name[0] != name[0])
continue;
- if (!memcmp(name, cp->name, len))
+ if (!MEMCMP(name, cp->name, len))
return (cp);
}
return (NULL);
@@ -2280,11 +2282,7 @@ ex_comm_search(name, len)
* PUBLIC: __P((SCR *, EXCMDLIST const *, enum badaddr, enum nresult));
*/
void
-ex_badaddr(sp, cp, ba, nret)
- SCR *sp;
- EXCMDLIST const *cp;
- enum badaddr ba;
- enum nresult nret;
+ex_badaddr(SCR *sp, const EXCMDLIST *cp, enum badaddr ba, enum nresult nret)
{
recno_t lno;
@@ -2307,7 +2305,7 @@ ex_badaddr(sp, cp, ba, nret)
* underlying file, that's the real problem.
*/
if (sp->ep == NULL) {
- ex_emsg(sp, cp->name, EXM_NOFILEYET);
+ ex_wemsg(sp, cp ? cp->name : NULL, EXM_NOFILEYET);
return;
}
@@ -2321,7 +2319,7 @@ ex_badaddr(sp, cp, ba, nret)
if (lno != 0) {
msgq(sp, M_ERR,
"102|Illegal address: only %lu lines in the file",
- lno);
+ (u_long)lno);
break;
}
/* FALLTHROUGH */
@@ -2332,9 +2330,8 @@ ex_badaddr(sp, cp, ba, nret)
abort();
/* NOTREACHED */
case A_ZERO:
- msgq(sp, M_ERR,
- "104|The %s command doesn't permit an address of 0",
- cp->name);
+ msgq_wstr(sp, M_ERR, cp->name,
+ "104|The %s command doesn't permit an address of 0");
break;
}
return;
@@ -2350,7 +2347,7 @@ ex_comlog(sp, ecp)
SCR *sp;
EXCMD *ecp;
{
- TRACE(sp, "ecmd: %s", ecp->cmd->name);
+ TRACE(sp, "ecmd: "WS, ecp->cmd->name);
if (ecp->addrcnt > 0) {
TRACE(sp, " a1 %d", ecp->addr1.lno);
if (ecp->addrcnt > 1)
@@ -2360,11 +2357,13 @@ ex_comlog(sp, ecp)
TRACE(sp, " line %d", ecp->lineno);
if (ecp->flags)
TRACE(sp, " flags 0x%x", ecp->flags);
- if (F_ISSET(&exc, E_BUFFER))
- TRACE(sp, " buffer %c", ecp->buffer);
- if (ecp->argc)
+ if (FL_ISSET(ecp->iflags, E_C_BUFFER))
+ TRACE(sp, " buffer "WC, ecp->buffer);
+ if (ecp->argc) {
+ int cnt;
for (cnt = 0; cnt < ecp->argc; ++cnt)
- TRACE(sp, " arg %d: {%s}", cnt, ecp->argv[cnt]->bp);
+ TRACE(sp, " arg %d: {"WS"}", cnt, ecp->argv[cnt]->bp);
+ }
TRACE(sp, "\n");
}
#endif
diff --git a/ex/ex.h b/ex/ex.h
index 5870990b744e..f5ba4c2311aa 100644
--- a/ex/ex.h
+++ b/ex/ex.h
@@ -6,13 +6,13 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)ex.h 10.24 (Berkeley) 8/12/96
+ * $Id: ex.h,v 10.31 2012/10/03 02:33:24 zy Exp $
*/
#define PROMPTCHAR ':' /* Prompt using a colon. */
typedef struct _excmdlist { /* Ex command table structure. */
- char *name; /* Command name, underlying function. */
+ CHAR_T *name; /* Command name, underlying function. */
int (*fn) __P((SCR *, EXCMD *));
#define E_ADDR1 0x00000001 /* One address. */
@@ -49,6 +49,9 @@ extern EXCMDLIST const cmds[]; /* Table of ex commands. */
(F_ISSET(cmdp, E_VLITONLY) ? \
(ch) == CH_LITERAL : KEY_VAL(sp, ch) == K_VLNEXT)
+#define IS_SHELLMETA(sp, ch) \
+ ((ch) <= CHAR_MAX && strchr(O_STR(sp, O_SHELLMETA), ch) != NULL)
+
/*
* File state must be checked for each command -- any ex command may be entered
* at any time, and most of them won't work well if a file hasn't yet been read
@@ -56,7 +59,7 @@ extern EXCMDLIST const cmds[]; /* Table of ex commands. */
*/
#define NEEDFILE(sp, cmdp) { \
if ((sp)->ep == NULL) { \
- ex_emsg(sp, (cmdp)->cmd->name, EXM_NOFILEYET); \
+ ex_wemsg(sp, (cmdp)->cmd->name, EXM_NOFILEYET); \
return (1); \
} \
}
@@ -64,13 +67,13 @@ extern EXCMDLIST const cmds[]; /* Table of ex commands. */
/* Range structures for global and @ commands. */
typedef struct _range RANGE;
struct _range { /* Global command range. */
- CIRCLEQ_ENTRY(_range) q; /* Linked list of ranges. */
+ TAILQ_ENTRY(_range) q; /* Linked list of ranges. */
recno_t start, stop; /* Start/stop of the range. */
};
/* Ex command structure. */
struct _excmd {
- LIST_ENTRY(_excmd) q; /* Linked list of commands. */
+ SLIST_ENTRY(_excmd) q; /* Linked list of commands. */
char *if_name; /* Associated file. */
recno_t if_lno; /* Associated line number. */
@@ -80,18 +83,18 @@ struct _excmd {
memset(&((cmdp)->cp), 0, ((char *)&(cmdp)->flags - \
(char *)&((cmdp)->cp)) + sizeof((cmdp)->flags))
- char *cp; /* Current command text. */
+ CHAR_T *cp; /* Current command text. */
size_t clen; /* Current command length. */
- char *save_cmd; /* Remaining command. */
+ CHAR_T *save_cmd; /* Remaining command. */
size_t save_cmdlen; /* Remaining command length. */
EXCMDLIST const *cmd; /* Command: entry in command table. */
EXCMDLIST rcmd; /* Command: table entry/replacement. */
- CIRCLEQ_HEAD(_rh, _range) rq; /* @/global range: linked list. */
+ TAILQ_HEAD(_rh, _range) rq[1]; /* @/global range: linked list. */
recno_t range_lno; /* @/global range: set line number. */
- char *o_cp; /* Original @/global command. */
+ CHAR_T *o_cp; /* Original @/global command. */
size_t o_clen; /* Original @/global command length. */
#define AGV_AT 0x01 /* @ buffer execution. */
#define AGV_AT_NORANGE 0x02 /* @ buffer execution without range. */
@@ -133,7 +136,7 @@ struct _excmd {
#define E_C_PRINT 0x01000 /* p flag. */
u_int16_t iflags; /* User input information. */
-#define __INUSE2 0x000004ff /* Same name space as EXCMDLIST. */
+#define __INUSE2 0x000007ff /* Same name space as EXCMDLIST. */
#define E_BLIGNORE 0x00000800 /* Ignore blank lines. */
#define E_NAMEDISCARD 0x00001000 /* Free/discard the name. */
#define E_NOAUTO 0x00002000 /* Don't do autoprint output. */
@@ -157,10 +160,11 @@ struct _excmd {
/* Ex private, per-screen memory. */
typedef struct _ex_private {
- CIRCLEQ_HEAD(_tqh, _tagq) tq; /* Tag queue. */
- TAILQ_HEAD(_tagfh, _tagf) tagfq;/* Tag file list. */
- LIST_HEAD(_csch, _csc) cscq; /* Cscope connection list. */
- char *tag_last; /* Saved last tag string. */
+ /* Tag file list. */
+ TAILQ_HEAD(_tagfh, _tagf) tagfq[1];
+ TAILQ_HEAD(_tqh, _tagq) tq[1]; /* Tag queue. */
+ SLIST_HEAD(_csch, _csc) cscq[1];/* Cscope connection list. */
+ CHAR_T *tag_last; /* Saved last tag string. */
CHAR_T *lastbcomm; /* Last bang command. */
@@ -172,6 +176,7 @@ typedef struct _ex_private {
char *ibp; /* File line input buffer. */
size_t ibp_len; /* File line input buffer length. */
+ CONVWIN ibcw; /* File line input conversion buffer. */
/*
* Buffers for the ex output. The screen/vi support doesn't do any
@@ -225,4 +230,4 @@ typedef enum {
} tagmsg_t;
#include "ex_def.h"
-#include "ex_extern.h"
+#include "extern.h"
diff --git a/ex/ex_abbrev.c b/ex/ex_abbrev.c
index 231098ce7d25..662488966717 100644
--- a/ex/ex_abbrev.c
+++ b/ex/ex_abbrev.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_abbrev.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_abbrev.c,v 10.10 2001/12/16 18:18:54 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -34,9 +34,7 @@ static const char sccsid[] = "@(#)ex_abbrev.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int ex_abbr __P((SCR *, EXCMD *));
*/
int
-ex_abbr(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_abbr(SCR *sp, EXCMD *cmdp)
{
CHAR_T *p;
size_t len;
@@ -71,7 +69,7 @@ ex_abbr(sp, cmdp)
return (1);
}
for (p = cmdp->argv[0]->bp; *p != '\0'; ++p)
- if (isblank(p[0])) {
+ if (ISBLANK(p[0])) {
msgq(sp, M_ERR,
"107|Abbreviations may not contain tabs or spaces");
return (1);
@@ -100,16 +98,14 @@ ex_abbr(sp, cmdp)
* PUBLIC: int ex_unabbr __P((SCR *, EXCMD *));
*/
int
-ex_unabbr(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_unabbr(SCR *sp, EXCMD *cmdp)
{
ARGS *ap;
ap = cmdp->argv[0];
if (!F_ISSET(sp->gp, G_ABBREV) ||
seq_delete(sp, ap->bp, ap->len, SEQ_ABBREV)) {
- msgq_str(sp, M_ERR, ap->bp,
+ msgq_wstr(sp, M_ERR, ap->bp,
"109|\"%s\" is not an abbreviation");
return (1);
}
diff --git a/ex/ex_append.c b/ex/ex_append.c
index 8d89e125f51f..de224f82589d 100644
--- a/ex/ex_append.c
+++ b/ex/ex_append.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_append.c 10.30 (Berkeley) 10/23/96";
+static const char sccsid[] = "$Id: ex_append.c,v 10.34 2001/06/25 15:19:14 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -36,9 +37,7 @@ static int ex_aci __P((SCR *, EXCMD *, enum which));
* PUBLIC: int ex_append __P((SCR *, EXCMD *));
*/
int
-ex_append(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_append(SCR *sp, EXCMD *cmdp)
{
return (ex_aci(sp, cmdp, APPEND));
}
@@ -50,9 +49,7 @@ ex_append(sp, cmdp)
* PUBLIC: int ex_change __P((SCR *, EXCMD *));
*/
int
-ex_change(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_change(SCR *sp, EXCMD *cmdp)
{
return (ex_aci(sp, cmdp, CHANGE));
}
@@ -65,9 +62,7 @@ ex_change(sp, cmdp)
* PUBLIC: int ex_insert __P((SCR *, EXCMD *));
*/
int
-ex_insert(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_insert(SCR *sp, EXCMD *cmdp)
{
return (ex_aci(sp, cmdp, INSERT));
}
@@ -77,16 +72,13 @@ ex_insert(sp, cmdp)
* Append, change, insert in ex.
*/
static int
-ex_aci(sp, cmdp, cmd)
- SCR *sp;
- EXCMD *cmdp;
- enum which cmd;
+ex_aci(SCR *sp, EXCMD *cmdp, enum which cmd)
{
CHAR_T *p, *t;
GS *gp;
TEXT *tp;
- TEXTH tiq;
- recno_t cnt, lno;
+ TEXTH tiq[] = {{ 0 }};
+ recno_t cnt = 0, lno;
size_t len;
u_int32_t flags;
int need_newline;
@@ -175,7 +167,7 @@ ex_aci(sp, cmdp, cmd)
if (len != 0) {
++t;
if (--len == 0 &&
- db_append(sp, 1, lno++, "", 0))
+ db_append(sp, 1, lno++, NULL, 0))
return (1);
}
}
@@ -213,7 +205,7 @@ ex_aci(sp, cmdp, cmd)
*/
if (F_ISSET(sp, SC_VI)) {
if (gp->scr_screen(sp, SC_EX)) {
- ex_emsg(sp, cmdp->cmd->name, EXM_NOCANON);
+ ex_wemsg(sp, cmdp->cmd->name, EXM_NOCANON);
return (1);
}
@@ -254,16 +246,16 @@ ex_aci(sp, cmdp, cmd)
* characters in the common TEXTH structure when they were inserted
* into the file, above.)
*/
- memset(&tiq, 0, sizeof(TEXTH));
- CIRCLEQ_INIT(&tiq);
+ TAILQ_INIT(tiq);
- if (ex_txt(sp, &tiq, 0, flags))
+ if (ex_txt(sp, tiq, 0, flags))
return (1);
- for (cnt = 0, tp = tiq.cqh_first;
- tp != (TEXT *)&tiq; ++cnt, tp = tp->q.cqe_next)
+ TAILQ_FOREACH(tp, tiq, q) {
if (db_append(sp, 1, lno++, tp->lb, tp->len))
return (1);
+ ++cnt;
+ }
/*
* Set sp->lno to the final line number value (correcting for a
diff --git a/ex/ex_args.c b/ex/ex_args.c
index bc37109fc130..2105d2d057d0 100644
--- a/ex/ex_args.c
+++ b/ex/ex_args.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_args.c 10.16 (Berkeley) 7/13/96";
+static const char sccsid[] = "$Id: ex_args.c,v 10.19 2011/12/16 16:18:10 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -42,14 +42,16 @@ static int ex_N_next __P((SCR *, EXCMD *));
* PUBLIC: int ex_next __P((SCR *, EXCMD *));
*/
int
-ex_next(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_next(SCR *sp, EXCMD *cmdp)
{
ARGS **argv;
FREF *frp;
int noargs;
char **ap;
+ CHAR_T *wp;
+ size_t wlen;
+ char *np;
+ size_t nlen;
/* Check for file to move to. */
if (cmdp->argc == 0 && (sp->cargv == NULL || sp->cargv[1] == NULL)) {
@@ -60,8 +62,9 @@ ex_next(sp, cmdp)
if (F_ISSET(cmdp, E_NEWSCREEN)) {
/* By default, edit the next file in the old argument list. */
if (cmdp->argc == 0) {
- if (argv_exp0(sp,
- cmdp, sp->cargv[1], strlen(sp->cargv[1])))
+ CHAR2INT(sp, sp->cargv[1], strlen(sp->cargv[1]) + 1,
+ wp, wlen);
+ if (argv_exp0(sp, cmdp, wp, wlen - 1))
return (1);
return (ex_edit(sp, cmdp));
}
@@ -88,10 +91,11 @@ ex_next(sp, cmdp)
CALLOC_RET(sp,
sp->argv, char **, cmdp->argc + 1, sizeof(char *));
for (ap = sp->argv,
- argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv)
- if ((*ap =
- v_strdup(sp, argv[0]->bp, argv[0]->len)) == NULL)
+ argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv) {
+ INT2CHAR(sp, argv[0]->bp, argv[0]->len, np, nlen);
+ if ((*ap = v_strdup(sp, np, nlen)) == NULL)
return (1);
+ }
*ap = NULL;
/* Switch to the first file. */
@@ -125,12 +129,12 @@ ex_next(sp, cmdp)
* New screen version of ex_next.
*/
static int
-ex_N_next(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_N_next(SCR *sp, EXCMD *cmdp)
{
SCR *new;
FREF *frp;
+ char *np;
+ size_t nlen;
/* Get a new screen. */
if (screen_init(sp->gp, sp, &new))
@@ -141,7 +145,8 @@ ex_N_next(sp, cmdp)
}
/* Get a backing file. */
- if ((frp = file_add(new, cmdp->argv[0]->bp)) == NULL ||
+ INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, np, nlen);
+ if ((frp = file_add(new, np)) == NULL ||
file_init(new, frp, NULL,
(FL_ISSET(cmdp->iflags, E_C_FORCE) ? FS_FORCE : 0))) {
(void)vs_discard(new, NULL);
@@ -169,11 +174,11 @@ ex_N_next(sp, cmdp)
* PUBLIC: int ex_prev __P((SCR *, EXCMD *));
*/
int
-ex_prev(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_prev(SCR *sp, EXCMD *cmdp)
{
FREF *frp;
+ size_t wlen;
+ CHAR_T *wp;
if (sp->cargv == sp->argv) {
msgq(sp, M_ERR, "112|No previous files to edit");
@@ -181,7 +186,9 @@ ex_prev(sp, cmdp)
}
if (F_ISSET(cmdp, E_NEWSCREEN)) {
- if (argv_exp0(sp, cmdp, sp->cargv[-1], strlen(sp->cargv[-1])))
+ CHAR2INT(sp, sp->cargv[-1], strlen(sp->cargv[-1]) + 1,
+ wp, wlen);
+ if (argv_exp0(sp, cmdp, wp, wlen - 1))
return (1);
return (ex_edit(sp, cmdp));
}
@@ -216,9 +223,7 @@ ex_prev(sp, cmdp)
* PUBLIC: int ex_rew __P((SCR *, EXCMD *));
*/
int
-ex_rew(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_rew(SCR *sp, EXCMD *cmdp)
{
FREF *frp;
@@ -256,9 +261,7 @@ ex_rew(sp, cmdp)
* PUBLIC: int ex_args __P((SCR *, EXCMD *));
*/
int
-ex_args(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_args(SCR *sp, EXCMD *cmdp)
{
GS *gp;
int cnt, col, len, sep;
@@ -299,14 +302,13 @@ ex_args(sp, cmdp)
* PUBLIC: char **ex_buildargv __P((SCR *, EXCMD *, char *));
*/
char **
-ex_buildargv(sp, cmdp, name)
- SCR *sp;
- EXCMD *cmdp;
- char *name;
+ex_buildargv(SCR *sp, EXCMD *cmdp, char *name)
{
ARGS **argv;
int argc;
char **ap, **s_argv;
+ char *np;
+ size_t nlen;
argc = cmdp == NULL ? 1 : cmdp->argc;
CALLOC(sp, s_argv, char **, argc + 1, sizeof(char *));
@@ -318,10 +320,11 @@ ex_buildargv(sp, cmdp, name)
return (NULL);
++ap;
} else
- for (argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv)
- if ((*ap =
- v_strdup(sp, argv[0]->bp, argv[0]->len)) == NULL)
+ for (argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv) {
+ INT2CHAR(sp, argv[0]->bp, argv[0]->len, np, nlen);
+ if ((*ap = v_strdup(sp, np, nlen)) == NULL)
return (NULL);
+ }
*ap = NULL;
return (s_argv);
}
diff --git a/ex/ex_argv.c b/ex/ex_argv.c
index cc5a201bea26..b3e3edf1a7e9 100644
--- a/ex/ex_argv.c
+++ b/ex/ex_argv.c
@@ -10,17 +10,19 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_argv.c 10.26 (Berkeley) 9/20/96";
+static const char sccsid[] = "$Id: ex_argv.c,v 11.2 2012/10/09 23:00:29 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
+#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,9 +33,9 @@ static const char sccsid[] = "@(#)ex_argv.c 10.26 (Berkeley) 9/20/96";
static int argv_alloc __P((SCR *, size_t));
static int argv_comp __P((const void *, const void *));
static int argv_fexp __P((SCR *, EXCMD *,
- char *, size_t, char *, size_t *, char **, size_t *, int));
-static int argv_lexp __P((SCR *, EXCMD *, char *));
-static int argv_sexp __P((SCR *, char **, size_t *, size_t *));
+ CHAR_T *, size_t, CHAR_T *, size_t *, CHAR_T **, size_t *, int));
+static int argv_sexp __P((SCR *, CHAR_T **, size_t *, size_t *));
+static int argv_flt_user __P((SCR *, EXCMD *, CHAR_T *, size_t));
/*
* argv_init --
@@ -42,9 +44,7 @@ static int argv_sexp __P((SCR *, char **, size_t *, size_t *));
* PUBLIC: int argv_init __P((SCR *, EXCMD *));
*/
int
-argv_init(sp, excp)
- SCR *sp;
- EXCMD *excp;
+argv_init(SCR *sp, EXCMD *excp)
{
EX_PRIVATE *exp;
@@ -61,20 +61,16 @@ argv_init(sp, excp)
* argv_exp0 --
* Append a string to the argument list.
*
- * PUBLIC: int argv_exp0 __P((SCR *, EXCMD *, char *, size_t));
+ * PUBLIC: int argv_exp0 __P((SCR *, EXCMD *, CHAR_T *, size_t));
*/
int
-argv_exp0(sp, excp, cmd, cmdlen)
- SCR *sp;
- EXCMD *excp;
- char *cmd;
- size_t cmdlen;
+argv_exp0(SCR *sp, EXCMD *excp, CHAR_T *cmd, size_t cmdlen)
{
EX_PRIVATE *exp;
exp = EXP(sp);
argv_alloc(sp, cmdlen);
- memcpy(exp->args[exp->argsoff]->bp, cmd, cmdlen);
+ MEMCPY(exp->args[exp->argsoff]->bp, cmd, cmdlen);
exp->args[exp->argsoff]->bp[cmdlen] = '\0';
exp->args[exp->argsoff]->len = cmdlen;
++exp->argsoff;
@@ -88,33 +84,28 @@ argv_exp0(sp, excp, cmd, cmdlen)
* Do file name expansion on a string, and append it to the
* argument list.
*
- * PUBLIC: int argv_exp1 __P((SCR *, EXCMD *, char *, size_t, int));
+ * PUBLIC: int argv_exp1 __P((SCR *, EXCMD *, CHAR_T *, size_t, int));
*/
int
-argv_exp1(sp, excp, cmd, cmdlen, is_bang)
- SCR *sp;
- EXCMD *excp;
- char *cmd;
- size_t cmdlen;
- int is_bang;
+argv_exp1(SCR *sp, EXCMD *excp, CHAR_T *cmd, size_t cmdlen, int is_bang)
{
EX_PRIVATE *exp;
size_t blen, len;
- char *bp, *p, *t;
+ CHAR_T *p, *t, *bp;
- GET_SPACE_RET(sp, bp, blen, 512);
+ GET_SPACE_RETW(sp, bp, blen, 512);
len = 0;
exp = EXP(sp);
if (argv_fexp(sp, excp, cmd, cmdlen, bp, &len, &bp, &blen, is_bang)) {
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
return (1);
}
/* If it's empty, we're done. */
if (len != 0) {
for (p = bp, t = bp + len; p < t; ++p)
- if (!isblank(*p))
+ if (!cmdskip(*p))
break;
if (p == t)
goto ret;
@@ -123,7 +114,7 @@ argv_exp1(sp, excp, cmd, cmdlen, is_bang)
(void)argv_exp0(sp, excp, bp, len);
-ret: FREE_SPACE(sp, bp, blen);
+ret: FREE_SPACEW(sp, bp, blen);
return (0);
}
@@ -132,24 +123,20 @@ ret: FREE_SPACE(sp, bp, blen);
* Do file name and shell expansion on a string, and append it to
* the argument list.
*
- * PUBLIC: int argv_exp2 __P((SCR *, EXCMD *, char *, size_t));
+ * PUBLIC: int argv_exp2 __P((SCR *, EXCMD *, CHAR_T *, size_t));
*/
int
-argv_exp2(sp, excp, cmd, cmdlen)
- SCR *sp;
- EXCMD *excp;
- char *cmd;
- size_t cmdlen;
+argv_exp2(SCR *sp, EXCMD *excp, CHAR_T *cmd, size_t cmdlen)
{
size_t blen, len, n;
int rval;
- char *bp, *mp, *p;
+ CHAR_T *bp, *p;
- GET_SPACE_RET(sp, bp, blen, 512);
+ GET_SPACE_RETW(sp, bp, blen, 512);
-#define SHELLECHO "echo "
-#define SHELLOFFSET (sizeof(SHELLECHO) - 1)
- memcpy(bp, SHELLECHO, SHELLOFFSET);
+#define SHELLECHO L("echo ")
+#define SHELLOFFSET (SIZE(SHELLECHO) - 1)
+ MEMCPY(bp, SHELLECHO, SHELLOFFSET);
p = bp + SHELLOFFSET;
len = SHELLOFFSET;
@@ -175,28 +162,15 @@ argv_exp2(sp, excp, cmd, cmdlen)
* but then, if your shell was csh, the above example will behave
* differently in nvi than in vi. If you want to get other characters
* passed through to your shell, change the "meta" option.
- *
- * To avoid a function call per character, we do a first pass through
- * the meta characters looking for characters that aren't expected
- * to be there, and then we can ignore them in the user's argument.
*/
if (opts_empty(sp, O_SHELL, 1) || opts_empty(sp, O_SHELLMETA, 1))
n = 0;
else {
- for (p = mp = O_STR(sp, O_SHELLMETA); *p != '\0'; ++p)
- if (isblank(*p) || isalnum(*p))
- break;
p = bp + SHELLOFFSET;
n = len - SHELLOFFSET;
- if (*p != '\0') {
- for (; n > 0; --n, ++p)
- if (strchr(mp, *p) != NULL)
- break;
- } else
- for (; n > 0; --n, ++p)
- if (!isblank(*p) &&
- !isalnum(*p) && strchr(mp, *p) != NULL)
- break;
+ for (; n > 0; --n, ++p)
+ if (IS_SHELLMETA(sp, *p))
+ break;
}
/*
@@ -204,13 +178,11 @@ argv_exp2(sp, excp, cmd, cmdlen)
* it. Unfortunately, this is comparatively slow. Historically, it
* didn't matter much, since users don't enter meta characters as part
* of pathnames that frequently. The addition of filename completion
- * broke that assumption because it's easy to use. As a result, lots
- * folks have complained that the expansion code is too slow. So, we
- * detect filename completion as a special case, and do it internally.
- * Note that this code assumes that the <asterisk> character is the
- * match-anything meta character. That feels safe -- if anyone writes
- * a shell that doesn't follow that convention, I'd suggest giving them
- * a festive hot-lead enema.
+ * broke that assumption because it's easy to use. To increase the
+ * completion performance, nvi used to have an internal routine to
+ * handle "filename*". However, the shell special characters does not
+ * limit to "shellmeta", so such a hack breaks historic practice.
+ * After it all, we split the completion logic out from here.
*/
switch (n) {
case 0:
@@ -218,13 +190,6 @@ argv_exp2(sp, excp, cmd, cmdlen)
len -= SHELLOFFSET;
rval = argv_exp3(sp, excp, p, len);
break;
- case 1:
- if (*p == '*') {
- *p = '\0';
- rval = argv_lexp(sp, excp, bp + SHELLOFFSET);
- break;
- }
- /* FALLTHROUGH */
default:
if (argv_sexp(sp, &bp, &blen, &len)) {
rval = 1;
@@ -235,7 +200,7 @@ argv_exp2(sp, excp, cmd, cmdlen)
break;
}
-err: FREE_SPACE(sp, bp, blen);
+err: FREE_SPACEW(sp, bp, blen);
return (rval);
}
@@ -244,25 +209,21 @@ err: FREE_SPACE(sp, bp, blen);
* Take a string and break it up into an argv, which is appended
* to the argument list.
*
- * PUBLIC: int argv_exp3 __P((SCR *, EXCMD *, char *, size_t));
+ * PUBLIC: int argv_exp3 __P((SCR *, EXCMD *, CHAR_T *, size_t));
*/
int
-argv_exp3(sp, excp, cmd, cmdlen)
- SCR *sp;
- EXCMD *excp;
- char *cmd;
- size_t cmdlen;
+argv_exp3(SCR *sp, EXCMD *excp, CHAR_T *cmd, size_t cmdlen)
{
EX_PRIVATE *exp;
size_t len;
int ch, off;
- char *ap, *p;
+ CHAR_T *ap, *p;
for (exp = EXP(sp); cmdlen > 0; ++exp->argsoff) {
/* Skip any leading whitespace. */
for (; cmdlen > 0; --cmdlen, ++cmd) {
ch = *cmd;
- if (!isblank(ch))
+ if (!cmdskip(ch))
break;
}
if (cmdlen == 0)
@@ -282,7 +243,7 @@ argv_exp3(sp, excp, cmd, cmdlen)
if (IS_ESCAPE(sp, excp, ch) && cmdlen > 1) {
++cmd;
--cmdlen;
- } else if (isblank(ch))
+ } else if (cmdskip(ch))
break;
}
@@ -312,20 +273,99 @@ argv_exp3(sp, excp, cmd, cmdlen)
}
/*
+ * argv_flt_ex --
+ * Filter the ex commands with a prefix, and append the results to
+ * the argument list.
+ *
+ * PUBLIC: int argv_flt_ex __P((SCR *, EXCMD *, CHAR_T *, size_t));
+ */
+int
+argv_flt_ex(SCR *sp, EXCMD *excp, CHAR_T *cmd, size_t cmdlen)
+{
+ EX_PRIVATE *exp;
+ EXCMDLIST const *cp;
+ int off;
+ size_t len;
+
+ exp = EXP(sp);
+
+ for (off = exp->argsoff, cp = cmds; cp->name != NULL; ++cp) {
+ len = STRLEN(cp->name);
+ if (cmdlen > 0 &&
+ (cmdlen > len || MEMCMP(cmd, cp->name, cmdlen)))
+ continue;
+
+ /* Copy the matched ex command name. */
+ argv_alloc(sp, len + 1);
+ MEMCPY(exp->args[exp->argsoff]->bp, cp->name, len + 1);
+ exp->args[exp->argsoff]->len = len;
+ ++exp->argsoff;
+ excp->argv = exp->args;
+ excp->argc = exp->argsoff;
+ }
+
+ return (0);
+}
+
+/*
+ * argv_flt_user --
+ * Filter the ~user list on the system with a prefix, and append
+ * the results to the argument list.
+ */
+static int
+argv_flt_user(SCR *sp, EXCMD *excp, CHAR_T *uname, size_t ulen)
+{
+ EX_PRIVATE *exp;
+ struct passwd *pw;
+ int off;
+ char *np;
+ size_t len, nlen;
+
+ exp = EXP(sp);
+ off = exp->argsoff;
+
+ /* The input must come with a leading '~'. */
+ INT2CHAR(sp, uname + 1, ulen - 1, np, nlen);
+ if ((np = v_strdup(sp, np, nlen)) == NULL)
+ return (1);
+
+ setpwent();
+ while ((pw = getpwent()) != NULL) {
+ len = strlen(pw->pw_name);
+ if (nlen > 0 &&
+ (nlen > len || memcmp(np, pw->pw_name, nlen)))
+ continue;
+
+ /* Copy '~' + the matched user name. */
+ CHAR2INT(sp, pw->pw_name, len + 1, uname, ulen);
+ argv_alloc(sp, ulen + 1);
+ exp->args[exp->argsoff]->bp[0] = '~';
+ MEMCPY(exp->args[exp->argsoff]->bp + 1, uname, ulen);
+ exp->args[exp->argsoff]->len = ulen;
+ ++exp->argsoff;
+ excp->argv = exp->args;
+ excp->argc = exp->argsoff;
+ }
+ endpwent();
+ free(np);
+
+ qsort(exp->args + off, exp->argsoff - off, sizeof(ARGS *), argv_comp);
+ return (0);
+}
+
+/*
* argv_fexp --
* Do file name and bang command expansion.
*/
static int
-argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
- SCR *sp;
- EXCMD *excp;
- char *cmd, *p, **bpp;
- size_t cmdlen, *lenp, *blenp;
- int is_bang;
+argv_fexp(SCR *sp, EXCMD *excp, CHAR_T *cmd, size_t cmdlen, CHAR_T *p, size_t *lenp, CHAR_T **bpp, size_t *blenp, int is_bang)
{
EX_PRIVATE *exp;
- char *bp, *t;
+ char *t;
size_t blen, len, off, tlen;
+ CHAR_T *bp;
+ CHAR_T *wp;
+ size_t wlen;
/* Replace file name characters. */
for (bp = *bpp, blen = *blenp, len = *lenp; cmdlen > 0; --cmdlen, ++cmd)
@@ -339,11 +379,11 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
"115|No previous command to replace \"!\"");
return (1);
}
- len += tlen = strlen(exp->lastbcomm);
+ len += tlen = STRLEN(exp->lastbcomm);
off = p - bp;
- ADD_SPACE_RET(sp, bp, blen, len);
+ ADD_SPACE_RETW(sp, bp, blen, len);
p = bp + off;
- memcpy(p, exp->lastbcomm, tlen);
+ MEMCPY(p, exp->lastbcomm, tlen);
p += tlen;
F_SET(excp, E_MODIFY);
break;
@@ -356,10 +396,11 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
tlen = strlen(t);
len += tlen;
off = p - bp;
- ADD_SPACE_RET(sp, bp, blen, len);
+ ADD_SPACE_RETW(sp, bp, blen, len);
p = bp + off;
- memcpy(p, t, tlen);
- p += tlen;
+ CHAR2INT(sp, t, tlen, wp, wlen);
+ MEMCPY(p, wp, wlen);
+ p += wlen;
F_SET(excp, E_MODIFY);
break;
case '#':
@@ -370,10 +411,11 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
}
len += tlen = strlen(t);
off = p - bp;
- ADD_SPACE_RET(sp, bp, blen, len);
+ ADD_SPACE_RETW(sp, bp, blen, len);
p = bp + off;
- memcpy(p, t, tlen);
- p += tlen;
+ CHAR2INT(sp, t, tlen, wp, wlen);
+ MEMCPY(p, wp, wlen);
+ p += wlen;
F_SET(excp, E_MODIFY);
break;
case '\\':
@@ -392,7 +434,7 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
default:
ins_ch: ++len;
off = p - bp;
- ADD_SPACE_RET(sp, bp, blen, len);
+ ADD_SPACE_RETW(sp, bp, blen, len);
p = bp + off;
*p++ = *cmd;
}
@@ -400,7 +442,7 @@ ins_ch: ++len;
/* Nul termination. */
++len;
off = p - bp;
- ADD_SPACE_RET(sp, bp, blen, len);
+ ADD_SPACE_RETW(sp, bp, blen, len);
p = bp + off;
*p = '\0';
@@ -416,9 +458,7 @@ ins_ch: ++len;
* Make more space for arguments.
*/
static int
-argv_alloc(sp, len)
- SCR *sp;
- size_t len;
+argv_alloc(SCR *sp, size_t len)
{
ARGS *ap;
EX_PRIVATE *exp;
@@ -483,8 +523,7 @@ mem: msgq(sp, M_SYSERR, NULL);
* PUBLIC: int argv_free __P((SCR *));
*/
int
-argv_free(sp)
- SCR *sp;
+argv_free(SCR *sp)
{
EX_PRIVATE *exp;
int off;
@@ -507,89 +546,103 @@ argv_free(sp)
}
/*
- * argv_lexp --
+ * argv_flt_path --
* Find all file names matching the prefix and append them to the
- * buffer.
+ * argument list.
+ *
+ * PUBLIC: int argv_flt_path __P((SCR *, EXCMD *, CHAR_T *, size_t));
*/
-static int
-argv_lexp(sp, excp, path)
- SCR *sp;
- EXCMD *excp;
- char *path;
+int
+argv_flt_path(SCR *sp, EXCMD *excp, CHAR_T *path, size_t plen)
{
struct dirent *dp;
DIR *dirp;
EX_PRIVATE *exp;
int off;
size_t dlen, len, nlen;
- char *dname, *name, *p;
+ CHAR_T *dname;
+ CHAR_T *p, *np, *n;
+ char *name, *tp, *epd = NULL;
+ CHAR_T *wp;
+ size_t wlen;
exp = EXP(sp);
/* Set up the name and length for comparison. */
- if ((p = strrchr(path, '/')) == NULL) {
- dname = ".";
+ if ((path = v_wstrdup(sp, path, plen)) == NULL)
+ return (1);
+ if ((p = STRRCHR(path, '/')) == NULL) {
+ if (*path == '~') {
+ int rc;
+
+ /* Filter ~user list instead. */
+ rc = argv_flt_user(sp, excp, path, plen);
+ free(path);
+ return (rc);
+ }
+ dname = L(".");
dlen = 0;
- name = path;
- } else {
+ np = path;
+ } else {
if (p == path) {
- dname = "/";
+ dname = L("/");
dlen = 1;
} else {
*p = '\0';
dname = path;
- dlen = strlen(path);
+ dlen = p - path;
}
- name = p + 1;
+ np = p + 1;
}
- nlen = strlen(name);
- /*
- * XXX
- * We don't use the d_namlen field, it's not portable enough; we
- * assume that d_name is nul terminated, instead.
- */
- if ((dirp = opendir(dname)) == NULL) {
- msgq_str(sp, M_SYSERR, dname, "%s");
+ INT2CHAR(sp, dname, dlen + 1, tp, nlen);
+ if ((epd = expanduser(tp)) != NULL)
+ tp = epd;
+ if ((dirp = opendir(tp)) == NULL) {
+ free(epd);
+ free(path);
return (1);
}
+ free(epd);
+
+ INT2CHAR(sp, np, STRLEN(np), tp, nlen);
+ if ((name = v_strdup(sp, tp, nlen)) == NULL) {
+ free(path);
+ return (1);
+ }
+
for (off = exp->argsoff; (dp = readdir(dirp)) != NULL;) {
if (nlen == 0) {
if (dp->d_name[0] == '.')
continue;
- len = strlen(dp->d_name);
+ len = dp->d_namlen;
} else {
- len = strlen(dp->d_name);
+ len = dp->d_namlen;
if (len < nlen || memcmp(dp->d_name, name, nlen))
continue;
}
/* Directory + name + slash + null. */
- argv_alloc(sp, dlen + len + 2);
- p = exp->args[exp->argsoff]->bp;
+ CHAR2INT(sp, dp->d_name, len + 1, wp, wlen);
+ argv_alloc(sp, dlen + wlen + 1);
+ n = exp->args[exp->argsoff]->bp;
if (dlen != 0) {
- memcpy(p, dname, dlen);
- p += dlen;
+ MEMCPY(n, dname, dlen);
+ n += dlen;
if (dlen > 1 || dname[0] != '/')
- *p++ = '/';
+ *n++ = '/';
+ exp->args[exp->argsoff]->len = dlen + 1;
}
- memcpy(p, dp->d_name, len + 1);
- exp->args[exp->argsoff]->len = dlen + len + 1;
+ MEMCPY(n, wp, wlen);
+ exp->args[exp->argsoff]->len += wlen - 1;
++exp->argsoff;
excp->argv = exp->args;
excp->argc = exp->argsoff;
}
closedir(dirp);
+ free(name);
+ free(path);
- if (off == exp->argsoff) {
- /*
- * If we didn't find a match, complain that the expansion
- * failed. We can't know for certain that's the error, but
- * it's a good guess, and it matches historic practice.
- */
- msgq(sp, M_ERR, "304|Shell expansion failed");
- return (1);
- }
qsort(exp->args + off, exp->argsoff - off, sizeof(ARGS *), argv_comp);
return (0);
}
@@ -599,10 +652,9 @@ argv_lexp(sp, excp, path)
* Alphabetic comparison.
*/
static int
-argv_comp(a, b)
- const void *a, *b;
+argv_comp(const void *a, const void *b)
{
- return (strcmp((char *)(*(ARGS **)a)->bp, (char *)(*(ARGS **)b)->bp));
+ return (STRCMP((*(ARGS **)a)->bp, (*(ARGS **)b)->bp));
}
/*
@@ -611,17 +663,17 @@ argv_comp(a, b)
* a buffer.
*/
static int
-argv_sexp(sp, bpp, blenp, lenp)
- SCR *sp;
- char **bpp;
- size_t *blenp, *lenp;
+argv_sexp(SCR *sp, CHAR_T **bpp, size_t *blenp, size_t *lenp)
{
enum { SEXP_ERR, SEXP_EXPANSION_ERR, SEXP_OK } rval;
FILE *ifp;
pid_t pid;
size_t blen, len;
int ch, std_output[2];
- char *bp, *p, *sh, *sh_path;
+ CHAR_T *bp, *p;
+ char *sh, *sh_path;
+ char *np;
+ size_t nlen;
/* Secure means no shell access. */
if (O_ISSET(sp, O_SECURE)) {
@@ -689,7 +741,8 @@ err: if (ifp != NULL)
* XXX
* Assume that all shells have -c.
*/
- execl(sh_path, sh, "-c", bp, NULL);
+ INT2CHAR(sp, bp, STRLEN(bp)+1, np, nlen);
+ execl(sh_path, sh, "-c", np, (char *)NULL);
msgq_str(sp, M_SYSERR, sh_path, "118|Error: execl: %s");
_exit(127);
default: /* Parent. */
@@ -707,9 +760,9 @@ err: if (ifp != NULL)
* shell that does that is broken.
*/
for (p = bp, len = 0, ch = EOF;
- (ch = getc(ifp)) != EOF; *p++ = ch, --blen, ++len)
+ (ch = GETC(ifp)) != EOF; *p++ = ch, blen-=sizeof(CHAR_T), ++len)
if (blen < 5) {
- ADD_SPACE_GOTO(sp, bp, *blenp, *blenp * 2);
+ ADD_SPACE_GOTOW(sp, bp, *blenp, *blenp * 2);
p = bp + len;
blen = *blenp - len;
}
@@ -744,7 +797,7 @@ alloc_err: rval = SEXP_ERR;
rval = SEXP_EXPANSION_ERR;
for (p = bp; len; ++p, --len)
- if (!isblank(*p))
+ if (!cmdskip(*p))
break;
if (len == 0)
rval = SEXP_EXPANSION_ERR;
@@ -754,3 +807,108 @@ alloc_err: rval = SEXP_ERR;
return (rval == SEXP_OK ? 0 : 1);
}
+
+/*
+ * argv_esc --
+ * Escape a string into an ex and shell argument.
+ *
+ * PUBLIC: CHAR_T *argv_esc __P((SCR *, EXCMD *, CHAR_T *, size_t));
+ */
+CHAR_T *
+argv_esc(SCR *sp, EXCMD *excp, CHAR_T *str, size_t len)
+{
+ size_t blen, off;
+ CHAR_T *bp, *p;
+ int ch;
+
+ GET_SPACE_GOTOW(sp, bp, blen, len + 1);
+
+ /*
+ * Leaving the first '~' unescaped causes the user to need a
+ * "./" prefix to edit a file which really starts with a '~'.
+ * However, the file completion happens to not work for these
+ * files without the prefix.
+ *
+ * All ex expansion characters, "!%#", are double escaped.
+ */
+ for (p = bp; len > 0; ++str, --len) {
+ ch = *str;
+ off = p - bp;
+ if (blen / sizeof(CHAR_T) - off < 3) {
+ ADD_SPACE_GOTOW(sp, bp, blen, off + 3);
+ p = bp + off;
+ }
+ if (cmdskip(ch) || ch == '\n' ||
+ IS_ESCAPE(sp, excp, ch)) /* Ex. */
+ *p++ = CH_LITERAL;
+ else switch (ch) {
+ case '~': /* ~user. */
+ if (p != bp)
+ *p++ = '\\';
+ break;
+ case '+': /* Ex +cmd. */
+ if (p == bp)
+ *p++ = '\\';
+ break;
+ case '!': case '%': case '#': /* Ex exp. */
+ *p++ = '\\';
+ *p++ = '\\';
+ break;
+ case ',': case '-': case '.': case '/': /* Safe. */
+ case ':': case '=': case '@': case '_':
+ break;
+ default: /* Unsafe. */
+ if (isascii(ch) && !isalnum(ch))
+ *p++ = '\\';
+ }
+ *p++ = ch;
+ }
+ *p = '\0';
+
+ return bp;
+
+alloc_err:
+ return NULL;
+}
+
+/*
+ * argv_uesc --
+ * Unescape an escaped ex and shell argument.
+ *
+ * PUBLIC: CHAR_T *argv_uesc __P((SCR *, EXCMD *, CHAR_T *, size_t));
+ */
+CHAR_T *
+argv_uesc(SCR *sp, EXCMD *excp, CHAR_T *str, size_t len)
+{
+ size_t blen;
+ CHAR_T *bp, *p;
+
+ GET_SPACE_GOTOW(sp, bp, blen, len + 1);
+
+ for (p = bp; len > 0; ++str, --len) {
+ if (IS_ESCAPE(sp, excp, *str)) {
+ if (--len < 1)
+ break;
+ ++str;
+ } else if (*str == '\\') {
+ if (--len < 1)
+ break;
+ ++str;
+
+ /* Check for double escaping. */
+ if (*str == '\\' && len > 1)
+ switch (str[1]) {
+ case '!': case '%': case '#':
+ ++str;
+ --len;
+ }
+ }
+ *p++ = *str;
+ }
+ *p = '\0';
+
+ return bp;
+
+alloc_err:
+ return NULL;
+}
diff --git a/ex/ex_at.c b/ex/ex_at.c
index e9c6c592d60b..0c12e6ce8e5a 100644
--- a/ex/ex_at.c
+++ b/ex/ex_at.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_at.c 10.12 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: ex_at.c,v 10.16 2001/06/25 15:19:14 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -34,17 +35,15 @@ static const char sccsid[] = "@(#)ex_at.c 10.12 (Berkeley) 9/15/96";
* PUBLIC: int ex_at __P((SCR *, EXCMD *));
*/
int
-ex_at(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_at(SCR *sp, EXCMD *cmdp)
{
CB *cbp;
CHAR_T name;
EXCMD *ecp;
RANGE *rp;
TEXT *tp;
- size_t len;
- char *p;
+ size_t len = 0;
+ CHAR_T *p;
/*
* !!!
@@ -84,7 +83,7 @@ ex_at(sp, cmdp)
* means @ buffers are still useful in a multi-screen environment.
*/
CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD));
- CIRCLEQ_INIT(&ecp->rq);
+ TAILQ_INIT(ecp->rq);
CALLOC_RET(sp, rp, RANGE *, 1, sizeof(RANGE));
rp->start = cmdp->addr1.lno;
if (F_ISSET(cmdp, E_ADDR_DEF)) {
@@ -94,7 +93,7 @@ ex_at(sp, cmdp)
rp->stop = cmdp->addr2.lno;
FL_SET(ecp->agv_flags, AGV_AT);
}
- CIRCLEQ_INSERT_HEAD(&ecp->rq, rp, q);
+ TAILQ_INSERT_HEAD(ecp->rq, rp, q);
/*
* Buffers executed in ex mode or from the colon command line in vi
@@ -104,23 +103,22 @@ ex_at(sp, cmdp)
* Build two copies of the command. We need two copies because the
* ex parser may step on the command string when it's parsing it.
*/
- for (len = 0, tp = cbp->textq.cqh_last;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_prev)
+ TAILQ_FOREACH_REVERSE(tp, cbp->textq, _texth, q)
len += tp->len + 1;
- MALLOC_RET(sp, ecp->cp, char *, len * 2);
+ MALLOC_RET(sp, ecp->cp, CHAR_T *, len * 2 * sizeof(CHAR_T));
ecp->o_cp = ecp->cp;
ecp->o_clen = len;
ecp->cp[len] = '\0';
/* Copy the buffer into the command space. */
- for (p = ecp->cp + len, tp = cbp->textq.cqh_last;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_prev) {
- memcpy(p, tp->lb, tp->len);
+ p = ecp->cp + len;
+ TAILQ_FOREACH_REVERSE(tp, cbp->textq, _texth, q) {
+ MEMCPY(p, tp->lb, tp->len);
p += tp->len;
*p++ = '\n';
}
- LIST_INSERT_HEAD(&sp->gp->ecq, ecp, q);
+ SLIST_INSERT_HEAD(sp->gp->ecq, ecp, q);
return (0);
}
diff --git a/ex/ex_bang.c b/ex/ex_bang.c
index 25f3f7732ab0..4b6f75e8d0f7 100644
--- a/ex/ex_bang.c
+++ b/ex/ex_bang.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_bang.c 10.33 (Berkeley) 9/23/96";
+static const char sccsid[] = "$Id: ex_bang.c,v 10.36 2001/06/25 15:19:14 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -47,9 +47,7 @@ static const char sccsid[] = "@(#)ex_bang.c 10.33 (Berkeley) 9/23/96";
* PUBLIC: int ex_bang __P((SCR *, EXCMD *));
*/
int
-ex_bang(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_bang(SCR *sp, EXCMD *cmdp)
{
enum filtertype ftype;
ARGS *ap;
@@ -58,6 +56,8 @@ ex_bang(sp, cmdp)
recno_t lno;
int rval;
const char *msg;
+ char *np;
+ size_t nlen;
ap = cmdp->argv[0];
if (ap->len == 0) {
@@ -69,7 +69,7 @@ ex_bang(sp, cmdp)
exp = EXP(sp);
if (exp->lastbcomm != NULL)
free(exp->lastbcomm);
- if ((exp->lastbcomm = strdup(ap->bp)) == NULL) {
+ if ((exp->lastbcomm = v_wstrdup(sp, ap->bp, ap->len)) == NULL) {
msgq(sp, M_SYSERR, NULL);
return (1);
}
@@ -88,7 +88,7 @@ ex_bang(sp, cmdp)
if (F_ISSET(sp, SC_VI))
vs_update(sp, "!", ap->bp);
else {
- (void)ex_printf(sp, "!%s\n", ap->bp);
+ (void)ex_printf(sp, "!"WS"\n", ap->bp);
(void)ex_fflush(sp);
}
}
@@ -112,8 +112,9 @@ ex_bang(sp, cmdp)
NULL);
/* If we're still in a vi screen, move out explicitly. */
+ INT2CHAR(sp, ap->bp, ap->len+1, np, nlen);
(void)ex_exec_proc(sp,
- cmdp, ap->bp, msg, !F_ISSET(sp, SC_EX | SC_SCR_EXWROTE));
+ cmdp, np, msg, !F_ISSET(sp, SC_EX | SC_SCR_EXWROTE));
}
/*
diff --git a/ex/ex_cd.c b/ex/ex_cd.c
index 3307c7b6306b..30a596f3c365 100644
--- a/ex/ex_cd.c
+++ b/ex/ex_cd.c
@@ -10,11 +10,11 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_cd.c 10.10 (Berkeley) 8/12/96";
+static const char sccsid[] = "$Id: ex_cd.c,v 10.13 2012/04/12 06:28:27 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
@@ -34,15 +34,14 @@ static const char sccsid[] = "@(#)ex_cd.c 10.10 (Berkeley) 8/12/96";
* PUBLIC: int ex_cd __P((SCR *, EXCMD *));
*/
int
-ex_cd(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_cd(SCR *sp, EXCMD *cmdp)
{
struct passwd *pw;
ARGS *ap;
- CHAR_T savech;
- char *dir, *p, *t; /* XXX: END OF THE STACK, DON'T TRUST GETCWD. */
- char buf[MAXPATHLEN * 2];
+ int savech;
+ char *dir, *p, *t;
+ char *buf;
+ size_t dlen;
/*
* !!!
@@ -71,7 +70,8 @@ ex_cd(sp, cmdp)
}
break;
case 1:
- dir = cmdp->argv[0]->bp;
+ INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1,
+ dir, dlen);
break;
default:
abort();
@@ -91,33 +91,35 @@ ex_cd(sp, cmdp)
*/
if (cmdp->argc == 0 ||
(ap = cmdp->argv[0])->bp[0] == '/' ||
- ap->len == 1 && ap->bp[0] == '.' ||
- ap->len >= 2 && ap->bp[0] == '.' && ap->bp[1] == '.' &&
- (ap->bp[2] == '/' || ap->bp[2] == '\0'))
+ (ap->len == 1 && ap->bp[0] == '.') ||
+ (ap->len >= 2 && ap->bp[0] == '.' && ap->bp[1] == '.' &&
+ (ap->bp[2] == '/' || ap->bp[2] == '\0')))
goto err;
/* Try the O_CDPATH option values. */
for (p = t = O_STR(sp, O_CDPATH);; ++p)
if (*p == '\0' || *p == ':') {
/*
- * Empty strings specify ".". The only way to get an
- * empty string is a leading colon, colons in a row,
- * or a trailing colon. Or, to put it the other way,
- * if the length is 1 or less, then we're dealing with
- * ":XXX", "XXX::XXXX" , "XXX:", or "". Since we've
- * already tried dot, we ignore tham all.
+ * Ignore the empty strings and ".", since we've already
+ * tried the current directory.
*/
- if (t < p - 1) {
+ if (t < p && (p - t != 1 || *t != '.')) {
savech = *p;
*p = '\0';
- (void)snprintf(buf,
- sizeof(buf), "%s/%s", t, dir);
+ if ((buf = join(t, dir)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
*p = savech;
if (!chdir(buf)) {
- if (getcwd(buf, sizeof(buf)) != NULL)
+ free(buf);
+ if ((buf = getcwd(NULL, 0)) != NULL) {
msgq_str(sp, M_INFO, buf, "122|New current directory: %s");
+ free(buf);
+ }
return (0);
}
+ free(buf);
}
t = p + 1;
if (*p == '\0')
diff --git a/ex/ex_cmd.c b/ex/ex_cmd.c
index 8f7fc8da7a13..87e32d2a4cf5 100644
--- a/ex/ex_cmd.c
+++ b/ex/ex_cmd.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_cmd.c 10.20 (Berkeley) 10/10/96";
+static const char sccsid[] = "$Id: ex_cmd.c,v 10.26 2011/07/14 15:11:16 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -50,92 +51,92 @@ static const char sccsid[] = "@(#)ex_cmd.c 10.20 (Berkeley) 10/10/96";
*/
EXCMDLIST const cmds[] = {
/* C_SCROLL */
- {"\004", ex_pr, E_ADDR2,
+ {L("\004"), ex_pr, E_ADDR2,
"",
"^D",
"scroll lines"},
/* C_BANG */
- {"!", ex_bang, E_ADDR2_NONE | E_SECURE,
+ {L("!"), ex_bang, E_ADDR2_NONE|E_SECURE,
"S",
"[line [,line]] ! command",
"filter lines through commands or run commands"},
/* C_HASH */
- {"#", ex_number, E_ADDR2|E_CLRFLAG,
+ {L("#"), ex_number, E_ADDR2|E_CLRFLAG,
"ca1",
"[line [,line]] # [count] [l]",
"display numbered lines"},
/* C_SUBAGAIN */
- {"&", ex_subagain, E_ADDR2,
+ {L("&"), ex_subagain, E_ADDR2|E_ADDR_ZERO,
"s",
"[line [,line]] & [cgr] [count] [#lp]",
"repeat the last subsitution"},
/* C_STAR */
- {"*", ex_at, 0,
+ {L("*"), ex_at, 0,
"b",
"* [buffer]",
"execute a buffer"},
/* C_SHIFTL */
- {"<", ex_shiftl, E_ADDR2|E_AUTOPRINT,
+ {L("<"), ex_shiftl, E_ADDR2|E_AUTOPRINT,
"ca1",
"[line [,line]] <[<...] [count] [flags]",
"shift lines left"},
/* C_EQUAL */
- {"=", ex_equal, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
+ {L("="), ex_equal, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
"1",
"[line] = [flags]",
"display line number"},
/* C_SHIFTR */
- {">", ex_shiftr, E_ADDR2|E_AUTOPRINT,
+ {L(">"), ex_shiftr, E_ADDR2|E_AUTOPRINT,
"ca1",
"[line [,line]] >[>...] [count] [flags]",
"shift lines right"},
/* C_AT */
- {"@", ex_at, E_ADDR2,
+ {L("@"), ex_at, E_ADDR2,
"b",
"@ [buffer]",
"execute a buffer"},
/* C_APPEND */
- {"append", ex_append, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
+ {L("append"), ex_append, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
"!",
"[line] a[ppend][!]",
"append input to a line"},
/* C_ABBR */
- {"abbreviate", ex_abbr, 0,
+ {L("abbreviate"), ex_abbr, 0,
"W",
"ab[brev] [word replace]",
"specify an input abbreviation"},
/* C_ARGS */
- {"args", ex_args, 0,
+ {L("args"), ex_args, 0,
"",
"ar[gs]",
"display file argument list"},
/* C_BG */
- {"bg", ex_bg, E_VIONLY,
+ {L("bg"), ex_bg, E_VIONLY,
"",
"bg",
"put a foreground screen into the background"},
/* C_CHANGE */
- {"change", ex_change, E_ADDR2|E_ADDR_ZERODEF,
+ {L("change"), ex_change, E_ADDR2|E_ADDR_ZERODEF,
"!ca",
"[line [,line]] c[hange][!] [count]",
"change lines to input"},
/* C_CD */
- {"cd", ex_cd, 0,
+ {L("cd"), ex_cd, 0,
"!f1o",
"cd[!] [directory]",
"change the current directory"},
/* C_CHDIR */
- {"chdir", ex_cd, 0,
+ {L("chdir"), ex_cd, 0,
"!f1o",
"chd[ir][!] [directory]",
"change the current directory"},
/* C_COPY */
- {"copy", ex_copy, E_ADDR2|E_AUTOPRINT,
+ {L("copy"), ex_copy, E_ADDR2|E_AUTOPRINT,
"l1",
"[line [,line]] co[py] line [flags]",
"copy lines elsewhere in the file"},
/* C_CSCOPE */
- {"cscope", ex_cscope, 0,
+ {L("cscope"), ex_cscope, 0,
"!s",
"cs[cope] command [args]",
"create a set of tags using a cscope command"},
@@ -145,160 +146,148 @@ EXCMDLIST const cmds[] = {
* in ex_cmd() (the ex parser). Read through the comments there, first.
*/
/* C_DELETE */
- {"delete", ex_delete, E_ADDR2|E_AUTOPRINT,
+ {L("delete"), ex_delete, E_ADDR2|E_AUTOPRINT,
"bca1",
"[line [,line]] d[elete][flags] [buffer] [count] [flags]",
"delete lines from the file"},
/* C_DISPLAY */
- {"display", ex_display, 0,
+ {L("display"), ex_display, 0,
"w1r",
"display b[uffers] | c[onnections] | s[creens] | t[ags]",
"display buffers, connections, screens or tags"},
/* C_EDIT */
- {"edit", ex_edit, E_NEWSCREEN,
+ {L("edit"), ex_edit, E_NEWSCREEN,
"f1o",
"[Ee][dit][!] [+cmd] [file]",
"begin editing another file"},
/* C_EX */
- {"ex", ex_edit, E_NEWSCREEN,
+ {L("ex"), ex_edit, E_NEWSCREEN,
"f1o",
"[Ee]x[!] [+cmd] [file]",
"begin editing another file"},
/* C_EXUSAGE */
- {"exusage", ex_usage, 0,
+ {L("exusage"), ex_usage, 0,
"w1o",
"[exu]sage [command]",
"display ex command usage statement"},
/* C_FILE */
- {"file", ex_file, 0,
+ {L("file"), ex_file, 0,
"f1o",
"f[ile] [name]",
"display (and optionally set) file name"},
/* C_FG */
- {"fg", ex_fg, E_NEWSCREEN|E_VIONLY,
+ {L("fg"), ex_fg, E_NEWSCREEN|E_VIONLY,
"f1o",
"[Ff]g [file]",
"bring a backgrounded screen into the foreground"},
/* C_GLOBAL */
- {"global", ex_global, E_ADDR2_ALL,
+ {L("global"), ex_global, E_ADDR2_ALL,
"!s",
"[line [,line]] g[lobal][!] [;/]RE[;/] [commands]",
"execute a global command on lines matching an RE"},
/* C_HELP */
- {"help", ex_help, 0,
+ {L("help"), ex_help, 0,
"",
"he[lp]",
"display help statement"},
/* C_INSERT */
- {"insert", ex_insert, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
+ {L("insert"), ex_insert, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
"!",
"[line] i[nsert][!]",
"insert input before a line"},
/* C_JOIN */
- {"join", ex_join, E_ADDR2|E_AUTOPRINT,
+ {L("join"), ex_join, E_ADDR2|E_AUTOPRINT,
"!ca1",
"[line [,line]] j[oin][!] [count] [flags]",
"join lines into a single line"},
/* C_K */
- {"k", ex_mark, E_ADDR1,
+ {L("k"), ex_mark, E_ADDR1,
"w1r",
"[line] k key",
"mark a line position"},
/* C_LIST */
- {"list", ex_list, E_ADDR2|E_CLRFLAG,
+ {L("list"), ex_list, E_ADDR2|E_CLRFLAG,
"ca1",
"[line [,line]] l[ist] [count] [#]",
"display lines in an unambiguous form"},
/* C_MOVE */
- {"move", ex_move, E_ADDR2|E_AUTOPRINT,
+ {L("move"), ex_move, E_ADDR2|E_AUTOPRINT,
"l",
"[line [,line]] m[ove] line",
"move lines elsewhere in the file"},
/* C_MARK */
- {"mark", ex_mark, E_ADDR1,
+ {L("mark"), ex_mark, E_ADDR1,
"w1r",
"[line] ma[rk] key",
"mark a line position"},
/* C_MAP */
- {"map", ex_map, 0,
+ {L("map"), ex_map, 0,
"!W",
"map[!] [keys replace]",
"map input or commands to one or more keys"},
/* C_MKEXRC */
- {"mkexrc", ex_mkexrc, 0,
+ {L("mkexrc"), ex_mkexrc, 0,
"!f1r",
"mkexrc[!] file",
"write a .exrc file"},
/* C_NEXT */
- {"next", ex_next, E_NEWSCREEN,
+ {L("next"), ex_next, E_NEWSCREEN,
"!fN",
"[Nn][ext][!] [+cmd] [file ...]",
"edit (and optionally specify) the next file"},
/* C_NUMBER */
- {"number", ex_number, E_ADDR2|E_CLRFLAG,
+ {L("number"), ex_number, E_ADDR2|E_CLRFLAG,
"ca1",
"[line [,line]] nu[mber] [count] [l]",
"change display to number lines"},
/* C_OPEN */
- {"open", ex_open, E_ADDR1,
+ {L("open"), ex_open, E_ADDR1,
"s",
"[line] o[pen] [/RE/] [flags]",
"enter \"open\" mode (not implemented)"},
/* C_PRINT */
- {"print", ex_pr, E_ADDR2|E_CLRFLAG,
+ {L("print"), ex_pr, E_ADDR2|E_CLRFLAG,
"ca1",
"[line [,line]] p[rint] [count] [#l]",
"display lines"},
-/* C_PERLCMD */
- {"perl", ex_perl, E_ADDR2_ALL|E_ADDR_ZERO|
- E_ADDR_ZERODEF|E_SECURE,
- "s",
- "pe[rl] cmd",
- "run the perl interpreter with the command"},
-/* C_PERLDOCMD */
- {"perldo", ex_perl, E_ADDR2_ALL|E_ADDR_ZERO|
- E_ADDR_ZERODEF|E_SECURE,
- "s",
- "perld[o] cmd",
- "run the perl interpreter with the command, on each line"},
/* C_PRESERVE */
- {"preserve", ex_preserve, 0,
+ {L("preserve"), ex_preserve, 0,
"",
"pre[serve]",
"preserve an edit session for recovery"},
/* C_PREVIOUS */
- {"previous", ex_prev, E_NEWSCREEN,
+ {L("previous"), ex_prev, E_NEWSCREEN,
"!",
"[Pp]rev[ious][!]",
"edit the previous file in the file argument list"},
/* C_PUT */
- {"put", ex_put,
+ {L("put"), ex_put,
E_ADDR1|E_AUTOPRINT|E_ADDR_ZERO|E_ADDR_ZERODEF,
"b",
"[line] pu[t] [buffer]",
"append a cut buffer to the line"},
/* C_QUIT */
- {"quit", ex_quit, 0,
+ {L("quit"), ex_quit, 0,
"!",
"q[uit][!]",
"exit ex/vi"},
/* C_READ */
- {"read", ex_read, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
+ {L("read"), ex_read, E_ADDR1|E_ADDR_ZERO|E_ADDR_ZERODEF,
"s",
"[line] r[ead] [!cmd | [file]]",
"append input from a command or file to the line"},
/* C_RECOVER */
- {"recover", ex_recover, 0,
+ {L("recover"), ex_recover, 0,
"!f1r",
"recover[!] file",
"recover a saved file"},
/* C_RESIZE */
- {"resize", ex_resize, E_VIONLY,
+ {L("resize"), ex_resize, E_VIONLY,
"c+",
"resize [+-]rows",
"grow or shrink the current screen"},
/* C_REWIND */
- {"rewind", ex_rew, 0,
+ {L("rewind"), ex_rew, 0,
"!",
"rew[ind][!]",
"re-edit all the files in the file argument list"},
@@ -308,148 +297,147 @@ EXCMDLIST const cmds[] = {
* in ex_cmd() (the ex parser). Read through the comments there, first.
*/
/* C_SUBSTITUTE */
- {"s", ex_s, E_ADDR2,
+ {L("s"), ex_s, E_ADDR2|E_ADDR_ZERO,
"s",
"[line [,line]] s [[/;]RE[/;]repl[/;] [cgr] [count] [#lp]]",
"substitute on lines matching an RE"},
/* C_SCRIPT */
- {"script", ex_script, E_SECURE,
+ {L("script"), ex_script, E_SECURE,
"!f1o",
"sc[ript][!] [file]",
"run a shell in a screen"},
/* C_SET */
- {"set", ex_set, 0,
+ {L("set"), ex_set, 0,
"wN",
"se[t] [option[=[value]]...] [nooption ...] [option? ...] [all]",
"set options (use \":set all\" to see all options)"},
/* C_SHELL */
- {"shell", ex_shell, E_SECURE,
+ {L("shell"), ex_shell, E_SECURE,
"",
"sh[ell]",
"suspend editing and run a shell"},
/* C_SOURCE */
- {"source", ex_source, 0,
+ {L("source"), ex_source, 0,
"f1r",
"so[urce] file",
"read a file of ex commands"},
/* C_STOP */
- {"stop", ex_stop, E_SECURE,
+ {L("stop"), ex_stop, E_SECURE,
"!",
"st[op][!]",
"suspend the edit session"},
/* C_SUSPEND */
- {"suspend", ex_stop, E_SECURE,
+ {L("suspend"), ex_stop, E_SECURE,
"!",
"su[spend][!]",
"suspend the edit session"},
/* C_T */
- {"t", ex_copy, E_ADDR2|E_AUTOPRINT,
+ {L("t"), ex_copy, E_ADDR2|E_AUTOPRINT,
"l1",
"[line [,line]] t line [flags]",
"copy lines elsewhere in the file"},
/* C_TAG */
- {"tag", ex_tag_push, E_NEWSCREEN,
+ {L("tag"), ex_tag_push, E_NEWSCREEN,
"!w1o",
"[Tt]a[g][!] [string]",
"edit the file containing the tag"},
/* C_TAGNEXT */
- {"tagnext", ex_tag_next, 0,
+ {L("tagnext"), ex_tag_next, 0,
"!",
"tagn[ext][!]",
"move to the next tag"},
/* C_TAGPOP */
- {"tagpop", ex_tag_pop, 0,
+ {L("tagpop"), ex_tag_pop, 0,
"!w1o",
"tagp[op][!] [number | file]",
"return to the previous group of tags"},
/* C_TAGPREV */
- {"tagprev", ex_tag_prev, 0,
+ {L("tagprev"), ex_tag_prev, 0,
"!",
"tagpr[ev][!]",
"move to the previous tag"},
/* C_TAGTOP */
- {"tagtop", ex_tag_top, 0,
+ {L("tagtop"), ex_tag_top, 0,
"!",
"tagt[op][!]",
"discard all tags"},
-/* C_TCLCMD */
- {"tcl", ex_tcl, E_ADDR2_ALL|E_ADDR_ZERO|
- E_ADDR_ZERODEF|E_SECURE,
- "s",
- "tc[l] cmd",
- "run the tcl interpreter with the command"},
/* C_UNDO */
- {"undo", ex_undo, E_AUTOPRINT,
+ {L("undo"), ex_undo, E_AUTOPRINT,
"",
"u[ndo]",
"undo the most recent change"},
/* C_UNABBREVIATE */
- {"unabbreviate",ex_unabbr, 0,
+ {L("unabbreviate"),ex_unabbr, 0,
"w1r",
"una[bbrev] word",
"delete an abbreviation"},
/* C_UNMAP */
- {"unmap", ex_unmap, 0,
+ {L("unmap"), ex_unmap, 0,
"!w1r",
"unm[ap][!] word",
"delete an input or command map"},
/* C_V */
- {"v", ex_v, E_ADDR2_ALL,
+ {L("v"), ex_v, E_ADDR2_ALL,
"s",
"[line [,line]] v [;/]RE[;/] [commands]",
"execute a global command on lines NOT matching an RE"},
/* C_VERSION */
- {"version", ex_version, 0,
+ {L("version"), ex_version, 0,
"",
"version",
"display the program version information"},
/* C_VISUAL_EX */
- {"visual", ex_visual, E_ADDR1|E_ADDR_ZERODEF,
+ {L("visual"), ex_visual, E_ADDR1|E_ADDR_ZERODEF,
"2c11",
"[line] vi[sual] [-|.|+|^] [window_size] [flags]",
"enter visual (vi) mode from ex mode"},
/* C_VISUAL_VI */
- {"visual", ex_edit, E_NEWSCREEN,
+ {L("visual"), ex_edit, E_NEWSCREEN,
"f1o",
"[Vv]i[sual][!] [+cmd] [file]",
"edit another file (from vi mode only)"},
/* C_VIUSAGE */
- {"viusage", ex_viusage, 0,
+ {L("viusage"), ex_viusage, 0,
"w1o",
"[viu]sage [key]",
"display vi key usage statement"},
+/* C_VSPLIT */
+ {L("vsplit"), ex_edit, E_VIONLY,
+ "f1o",
+ "vs[plit] [+cmd] [file]",
+ "split the current screen vertically"},
/* C_WRITE */
- {"write", ex_write, E_ADDR2_ALL|E_ADDR_ZERODEF,
+ {L("write"), ex_write, E_ADDR2_ALL|E_ADDR_ZERODEF,
"!s",
"[line [,line]] w[rite][!] [ !cmd | [>>] [file]]",
"write the file"},
/* C_WN */
- {"wn", ex_wn, E_ADDR2_ALL|E_ADDR_ZERODEF,
+ {L("wn"), ex_wn, E_ADDR2_ALL|E_ADDR_ZERODEF,
"!s",
"[line [,line]] wn[!] [>>] [file]",
"write the file and switch to the next file"},
/* C_WQ */
- {"wq", ex_wq, E_ADDR2_ALL|E_ADDR_ZERODEF,
+ {L("wq"), ex_wq, E_ADDR2_ALL|E_ADDR_ZERODEF,
"!s",
"[line [,line]] wq[!] [>>] [file]",
"write the file and exit"},
/* C_XIT */
- {"xit", ex_xit, E_ADDR2_ALL|E_ADDR_ZERODEF,
+ {L("xit"), ex_xit, E_ADDR2_ALL|E_ADDR_ZERODEF,
"!f1o",
"[line [,line]] x[it][!] [file]",
"exit"},
/* C_YANK */
- {"yank", ex_yank, E_ADDR2,
+ {L("yank"), ex_yank, E_ADDR2,
"bca",
"[line [,line]] ya[nk] [buffer] [count]",
"copy lines to a cut buffer"},
/* C_Z */
- {"z", ex_z, E_ADDR1,
+ {L("z"), ex_z, E_ADDR1,
"3c01",
"[line] z [-|.|+|^|=] [count] [flags]",
"display different screens of the file"},
/* C_SUBTILDE */
- {"~", ex_subtilde, E_ADDR2,
+ {L("~"), ex_subtilde, E_ADDR2|E_ADDR_ZERO,
"s",
"[line [,line]] ~ [cgr] [count] [#lp]",
"replace previous RE with previous replacement string,"},
diff --git a/ex/ex_cscope.c b/ex/ex_cscope.c
index c2fa0a5c454b..afc7fa93ee8c 100644
--- a/ex/ex_cscope.c
+++ b/ex/ex_cscope.c
@@ -10,14 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_cscope.c 10.13 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: ex_cscope.c,v 10.25 2012/10/04 09:23:03 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
-#include <sys/types.h> /* XXX: param.h may not have included types.h */
+#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <sys/wait.h>
#include <bitstring.h>
@@ -25,6 +23,7 @@ static const char sccsid[] = "@(#)ex_cscope.c 10.13 (Berkeley) 9/15/96";
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@@ -62,15 +61,15 @@ find c|d|e|f|g|i|s|t buffer|pattern\n\
s: find all uses of name\n\
t: find assignments to name"
-static int cscope_add __P((SCR *, EXCMD *, char *));
-static int cscope_find __P((SCR *, EXCMD*, char *));
-static int cscope_help __P((SCR *, EXCMD *, char *));
-static int cscope_kill __P((SCR *, EXCMD *, char *));
-static int cscope_reset __P((SCR *, EXCMD *, char *));
+static int cscope_add __P((SCR *, EXCMD *, CHAR_T *));
+static int cscope_find __P((SCR *, EXCMD*, CHAR_T *));
+static int cscope_help __P((SCR *, EXCMD *, CHAR_T *));
+static int cscope_kill __P((SCR *, EXCMD *, CHAR_T *));
+static int cscope_reset __P((SCR *, EXCMD *, CHAR_T *));
typedef struct _cc {
char *name;
- int (*function) __P((SCR *, EXCMD *, char *));
+ int (*function) __P((SCR *, EXCMD *, CHAR_T *));
char *help_msg;
char *usage_msg;
} CC;
@@ -108,14 +107,15 @@ static int terminate __P((SCR *, CSC *, int));
* PUBLIC: int ex_cscope __P((SCR *, EXCMD *));
*/
int
-ex_cscope(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_cscope(SCR *sp, EXCMD *cmdp)
{
CC const *ccp;
EX_PRIVATE *exp;
int i;
- char *cmd, *p;
+ CHAR_T *cmd;
+ CHAR_T *p;
+ char *np;
+ size_t nlen;
/* Initialize the default cscope directories. */
exp = EXP(sp);
@@ -139,7 +139,8 @@ ex_cscope(sp, cmdp)
for (; *p && isspace(*p); ++p);
}
- if ((ccp = lookup_ccmd(cmd)) == NULL) {
+ INT2CHAR(sp, cmd, STRLEN(cmd) + 1, np, nlen);
+ if ((ccp = lookup_ccmd(np)) == NULL) {
usage: msgq(sp, M_ERR, "309|Use \"cscope help\" for help");
return (1);
}
@@ -153,12 +154,12 @@ usage: msgq(sp, M_ERR, "309|Use \"cscope help\" for help");
* Initialize the cscope package.
*/
static int
-start_cscopes(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+start_cscopes(SCR *sp, EXCMD *cmdp)
{
size_t blen, len;
char *bp, *cscopes, *p, *t;
+ CHAR_T *wp;
+ size_t wlen;
/*
* EXTENSION #1:
@@ -175,12 +176,14 @@ start_cscopes(sp, cmdp)
if ((cscopes = getenv("CSCOPE_DIRS")) == NULL)
return (0);
len = strlen(cscopes);
- GET_SPACE_RET(sp, bp, blen, len);
+ GET_SPACE_RETC(sp, bp, blen, len);
memcpy(bp, cscopes, len + 1);
for (cscopes = t = bp; (p = strsep(&t, "\t :")) != NULL;)
- if (*p != '\0')
- (void)cscope_add(sp, cmdp, p);
+ if (*p != '\0') {
+ CHAR2INT(sp, p, strlen(p) + 1, wp, wlen);
+ (void)cscope_add(sp, cmdp, wp);
+ }
FREE_SPACE(sp, bp, blen);
return (0);
@@ -191,17 +194,16 @@ start_cscopes(sp, cmdp)
* The cscope add command.
*/
static int
-cscope_add(sp, cmdp, dname)
- SCR *sp;
- EXCMD *cmdp;
- char *dname;
+cscope_add(SCR *sp, EXCMD *cmdp, CHAR_T *dname)
{
struct stat sb;
EX_PRIVATE *exp;
CSC *csc;
size_t len;
int cur_argc;
- char *dbname, path[MAXPATHLEN];
+ char *dbname, *path;
+ char *np = NULL;
+ size_t nlen;
exp = EXP(sp);
@@ -211,8 +213,9 @@ cscope_add(sp, cmdp, dname)
* >1 additional args: object, too many args.
*/
cur_argc = cmdp->argc;
- if (argv_exp2(sp, cmdp, dname, strlen(dname)))
+ if (argv_exp2(sp, cmdp, dname, STRLEN(dname))) {
return (1);
+ }
if (cmdp->argc == cur_argc) {
(void)csc_help(sp, "add");
return (1);
@@ -220,10 +223,12 @@ cscope_add(sp, cmdp, dname)
if (cmdp->argc == cur_argc + 1)
dname = cmdp->argv[cur_argc]->bp;
else {
- ex_emsg(sp, dname, EXM_FILECOUNT);
+ ex_emsg(sp, np, EXM_FILECOUNT);
return (1);
}
+ INT2CHAR(sp, dname, STRLEN(dname)+1, np, nlen);
+
/*
* The user can specify a specific file (so they can have multiple
* Cscope databases in a single directory) or a directory. If the
@@ -231,28 +236,36 @@ cscope_add(sp, cmdp, dname)
* standard database file name and try again. Store the directory
* name regardless so that we can use it as a base for searches.
*/
- if (stat(dname, &sb)) {
- msgq(sp, M_SYSERR, dname);
+ if (stat(np, &sb)) {
+ msgq(sp, M_SYSERR, "%s", np);
return (1);
}
if (S_ISDIR(sb.st_mode)) {
- (void)snprintf(path, sizeof(path),
- "%s/%s", dname, CSCOPE_DBFILE);
+ if ((path = join(np, CSCOPE_DBFILE)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
if (stat(path, &sb)) {
- msgq(sp, M_SYSERR, path);
+ msgq(sp, M_SYSERR, "%s", path);
+ free(path);
return (1);
}
+ free(path);
dbname = CSCOPE_DBFILE;
- } else if ((dbname = strrchr(dname, '/')) != NULL)
+ } else if ((dbname = strrchr(np, '/')) != NULL)
*dbname++ = '\0';
+ else {
+ dbname = np;
+ np = ".";
+ }
/* Allocate a cscope connection structure and initialize its fields. */
- len = strlen(dname);
+ len = strlen(np);
CALLOC_RET(sp, csc, CSC *, 1, sizeof(CSC) + len);
csc->dname = csc->buf;
csc->dlen = len;
- memcpy(csc->dname, dname, len);
- csc->mtime = sb.st_mtime;
+ memcpy(csc->dname, np, len);
+ csc->mtim = sb.st_mtimespec;
/* Get the search paths for the cscope. */
if (get_paths(sp, csc))
@@ -267,15 +280,10 @@ cscope_add(sp, cmdp, dname)
* on error, we have to call terminate, which expects the csc to
* be on the chain.
*/
- LIST_INSERT_HEAD(&exp->cscq, csc, q);
+ SLIST_INSERT_HEAD(exp->cscq, csc, q);
/* Read the initial prompt from the cscope to make sure it's okay. */
- if (read_prompt(sp, csc)) {
- terminate(sp, csc, 0);
- return (1);
- }
-
- return (0);
+ return read_prompt(sp, csc);
err: free(csc);
return (1);
@@ -287,14 +295,12 @@ err: free(csc);
* cscope database.
*/
static int
-get_paths(sp, csc)
- SCR *sp;
- CSC *csc;
+get_paths(SCR *sp, CSC *csc)
{
struct stat sb;
int fd, nentries;
size_t len;
- char *p, **pathp, buf[MAXPATHLEN * 2];
+ char *p, **pathp, *buf;
/*
* EXTENSION #2:
@@ -308,7 +314,10 @@ get_paths(sp, csc)
* directory. To fix this, rewrite the each path using the cscope
* directory as a prefix.
*/
- (void)snprintf(buf, sizeof(buf), "%s/%s", csc->dname, CSCOPE_PATHS);
+ if ((buf = join(csc->dname, CSCOPE_PATHS)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
if (stat(buf, &sb) == 0) {
/* Read in the CSCOPE_PATHS file. */
len = sb.st_size;
@@ -318,9 +327,11 @@ get_paths(sp, csc)
msgq_str(sp, M_SYSERR, buf, "%s");
if (fd >= 0)
(void)close(fd);
+ free(buf);
return (1);
}
(void)close(fd);
+ free(buf);
csc->pbuf[len] = '\0';
/* Count up the entries. */
@@ -336,6 +347,7 @@ get_paths(sp, csc)
*pathp++ = p;
return (0);
}
+ free(buf);
/*
* If the CSCOPE_PATHS file doesn't exist, we look for files
@@ -362,24 +374,22 @@ alloc_err:
* Fork off the cscope process.
*/
static int
-run_cscope(sp, csc, dbname)
- SCR *sp;
- CSC *csc;
- char *dbname;
+run_cscope(SCR *sp, CSC *csc, char *dbname)
{
int to_cs[2], from_cs[2];
- char cmd[MAXPATHLEN * 2];
+ char *cmd;
/*
* Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
* from_cs[0] and writes to to_cs[1].
*/
- to_cs[0] = to_cs[1] = from_cs[0] = from_cs[0] = -1;
+ to_cs[0] = to_cs[1] = from_cs[0] = from_cs[1] = -1;
if (pipe(to_cs) < 0 || pipe(from_cs) < 0) {
msgq(sp, M_SYSERR, "pipe");
goto err;
}
switch (csc->pid = vfork()) {
+ char *dn, *dbn;
case -1:
msgq(sp, M_SYSERR, "vfork");
err: if (to_cs[0] != -1)
@@ -401,11 +411,23 @@ err: if (to_cs[0] != -1)
(void)close(from_cs[0]);
/* Run the cscope command. */
-#define CSCOPE_CMD_FMT "cd '%s' && exec cscope -dl -f %s"
- (void)snprintf(cmd, sizeof(cmd),
- CSCOPE_CMD_FMT, csc->dname, dbname);
- (void)execl(_PATH_BSHELL, "sh", "-c", cmd, NULL);
+#define CSCOPE_CMD_FMT "cd %s && exec cscope -dl -f %s"
+ if ((dn = quote(csc->dname)) == NULL)
+ goto nomem;
+ if ((dbn = quote(dbname)) == NULL) {
+ free(dn);
+ goto nomem;
+ }
+ (void)asprintf(&cmd, CSCOPE_CMD_FMT, dn, dbn);
+ free(dbn);
+ free(dn);
+ if (cmd == NULL) {
+nomem: msgq(sp, M_SYSERR, NULL);
+ _exit (1);
+ }
+ (void)execl(_PATH_BSHELL, "sh", "-c", cmd, (char *)NULL);
msgq_str(sp, M_SYSERR, cmd, "execl: %s");
+ free(cmd);
_exit (127);
/* NOTREACHED */
default: /* parent. */
@@ -431,10 +453,7 @@ err: if (to_cs[0] != -1)
* The cscope find command.
*/
static int
-cscope_find(sp, cmdp, pattern)
- SCR *sp;
- EXCMD *cmdp;
- char *pattern;
+cscope_find(SCR *sp, EXCMD *cmdp, CHAR_T *pattern)
{
CSC *csc, *csc_next;
EX_PRIVATE *exp;
@@ -444,11 +463,13 @@ cscope_find(sp, cmdp, pattern)
recno_t lno;
size_t cno, search;
int force, istmp, matches;
+ char *np = NULL;
+ size_t nlen;
exp = EXP(sp);
/* Check for connections. */
- if (exp->cscq.lh_first == NULL) {
+ if (SLIST_EMPTY(exp->cscq)) {
msgq(sp, M_ERR, "310|No cscope connections running");
return (1);
}
@@ -460,20 +481,24 @@ cscope_find(sp, cmdp, pattern)
*/
rtp = NULL;
rtqp = NULL;
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (TAILQ_EMPTY(exp->tq)) {
/* Initialize the `local context' tag queue structure. */
CALLOC_GOTO(sp, rtqp, TAGQ *, 1, sizeof(TAGQ));
- CIRCLEQ_INIT(&rtqp->tagq);
+ TAILQ_INIT(rtqp->tagq);
/* Initialize and link in its tag structure. */
CALLOC_GOTO(sp, rtp, TAG *, 1, sizeof(TAG));
- CIRCLEQ_INSERT_HEAD(&rtqp->tagq, rtp, q);
- rtqp->current = rtp;
+ TAILQ_INSERT_HEAD(rtqp->tagq, rtp, q);
+ rtqp->current = rtp;
}
/* Create the cscope command. */
- if ((tqp = create_cs_cmd(sp, pattern, &search)) == NULL)
+ INT2CHAR(sp, pattern, STRLEN(pattern) + 1, np, nlen);
+ np = strdup(np);
+ if ((tqp = create_cs_cmd(sp, np, &search)) == NULL)
goto err;
+ if (np != NULL)
+ free(np);
/*
* Stick the current context in a convenient place, we'll lose it
@@ -486,35 +511,32 @@ cscope_find(sp, cmdp, pattern)
/* Search all open connections for a match. */
matches = 0;
- for (csc = exp->cscq.lh_first; csc != NULL; csc = csc_next) {
- /* Copy csc->q.lh_next here in case csc is killed. */
- csc_next = csc->q.le_next;
-
+ /* Copy next connect here in case csc is killed. */
+ SLIST_FOREACH_SAFE(csc, exp->cscq, q, csc_next) {
/*
* Send the command to the cscope program. (We skip the
* first two bytes of the command, because we stored the
* search cscope command character and a leading space
* there.)
*/
- (void)fprintf(csc->to_fp, "%d%s\n", search, tqp->tag + 2);
+ (void)fprintf(csc->to_fp, "%lu%s\n", search, tqp->tag + 2);
(void)fflush(csc->to_fp);
/* Read the output. */
- if (parse(sp, csc, tqp, &matches)) {
- if (rtqp != NULL)
- free(rtqp);
- tagq_free(sp, tqp);
- return (1);
- }
+ if (parse(sp, csc, tqp, &matches))
+ goto nomatch;
}
if (matches == 0) {
msgq(sp, M_INFO, "278|No matches for query");
- return (0);
+nomatch: if (rtp != NULL)
+ free(rtp);
+ if (rtqp != NULL)
+ free(rtqp);
+ tagq_free(sp, tqp);
+ return (1);
}
- tqp->current = tqp->tagq.cqh_first;
-
/* Try to switch to the first tag. */
force = FL_ISSET(cmdp->iflags, E_C_FORCE);
if (F_ISSET(cmdp, E_NEWSCREEN)) {
@@ -533,13 +555,13 @@ cscope_find(sp, cmdp, pattern)
* in place, so we can pop all the way back to the current mark.
* Note, it doesn't point to much of anything, it's a placeholder.
*/
- if (exp->tq.cqh_first == (void *)&exp->tq) {
- CIRCLEQ_INSERT_HEAD(&exp->tq, rtqp, q);
+ if (TAILQ_EMPTY(exp->tq)) {
+ TAILQ_INSERT_HEAD(exp->tq, rtqp, q);
} else
- rtqp = exp->tq.cqh_first;
+ rtqp = TAILQ_FIRST(exp->tq);
/* Link the current TAGQ structure into place. */
- CIRCLEQ_INSERT_HEAD(&exp->tq, tqp, q);
+ TAILQ_INSERT_HEAD(exp->tq, tqp, q);
(void)cscope_search(sp, tqp, tqp->current);
@@ -570,6 +592,8 @@ alloc_err:
free(rtqp);
if (rtp != NULL)
free(rtp);
+ if (np != NULL)
+ free(np);
return (1);
}
@@ -578,10 +602,7 @@ alloc_err:
* Build a cscope command, creating and initializing the base TAGQ.
*/
static TAGQ *
-create_cs_cmd(sp, pattern, searchp)
- SCR *sp;
- char *pattern;
- size_t *searchp;
+create_cs_cmd(SCR *sp, char *pattern, size_t *searchp)
{
CB *cbp;
TAGQ *tqp;
@@ -601,8 +622,8 @@ create_cs_cmd(sp, pattern, searchp)
goto usage;
/* Skip leading blanks, check for command character. */
- for (; isblank(pattern[0]); ++pattern);
- if (pattern[0] == '\0' || !isblank(pattern[1]))
+ for (; cmdskip(pattern[0]); ++pattern);
+ if (pattern[0] == '\0' || !cmdskip(pattern[1]))
goto usage;
for (*searchp = 0, p = CSCOPE_QUERIES;
*p != '\0' && *p != pattern[0]; ++*searchp, ++p);
@@ -614,7 +635,7 @@ create_cs_cmd(sp, pattern, searchp)
}
/* Skip <blank> characters to the pattern. */
- for (p = pattern + 1; *p != '\0' && isblank(*p); ++p);
+ for (p = pattern + 1; *p != '\0' && cmdskip(*p); ++p);
if (*p == '\0') {
usage: (void)csc_help(sp, "find");
return (NULL);
@@ -625,8 +646,8 @@ usage: (void)csc_help(sp, "find");
if (p[0] == '"' && p[1] != '\0' && p[2] == '\0')
CBNAME(sp, cbp, p[1]);
if (cbp != NULL) {
- p = cbp->textq.cqh_first->lb;
- tlen = cbp->textq.cqh_first->len;
+ INT2CHAR(sp, TAILQ_FIRST(cbp->textq)->lb,
+ TAILQ_FIRST(cbp->textq)->len, p, tlen);
} else
tlen = strlen(p);
@@ -634,7 +655,7 @@ usage: (void)csc_help(sp, "find");
CALLOC(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + tlen + 3);
if (tqp == NULL)
return (NULL);
- CIRCLEQ_INIT(&tqp->tagq);
+ TAILQ_INIT(tqp->tagq);
tqp->tag = tqp->buf;
tqp->tag[0] = pattern[0];
tqp->tag[1] = ' ';
@@ -651,17 +672,15 @@ usage: (void)csc_help(sp, "find");
* Parse the cscope output.
*/
static int
-parse(sp, csc, tqp, matchesp)
- SCR *sp;
- CSC *csc;
- TAGQ *tqp;
- int *matchesp;
+parse(SCR *sp, CSC *csc, TAGQ *tqp, int *matchesp)
{
TAG *tp;
- recno_t slno;
- size_t dlen, nlen, slen;
- int ch, i, isolder, nlines;
- char *dname, *name, *search, *p, *t, dummy[2], buf[2048];
+ recno_t slno = 0;
+ size_t dlen, nlen = 0, slen = 0;
+ int ch, i, isolder = 0, nlines;
+ char *dname = NULL, *name = NULL, *search, *p, *t, dummy[2], buf[2048];
+ CHAR_T *wp;
+ size_t wlen;
for (;;) {
if (!fgets(buf, sizeof(buf), csc->from_fp))
@@ -738,9 +757,12 @@ parse(sp, csc, tqp, matchesp)
* length cscope information that follows it.
*/
CALLOC_RET(sp, tp,
- TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 + slen + 1);
- tp->fname = tp->buf;
- if (dlen != 0) {
+ TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 +
+ (slen + 1) * sizeof(CHAR_T));
+ tp->fname = (char *)tp->buf;
+ if (dlen == 1 && *dname == '.')
+ --dlen;
+ else if (dlen != 0) {
memcpy(tp->fname, dname, dlen);
tp->fname[dlen] = '/';
++dlen;
@@ -748,17 +770,23 @@ parse(sp, csc, tqp, matchesp)
memcpy(tp->fname + dlen, name, nlen + 1);
tp->fnlen = dlen + nlen;
tp->slno = slno;
- if (slen != 0) {
- tp->search = tp->fname + tp->fnlen + 1;
- memcpy(tp->search, search, (tp->slen = slen) + 1);
- }
- CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q);
+ tp->search = (CHAR_T*)(tp->fname + tp->fnlen + 1);
+ CHAR2INT(sp, search, slen + 1, wp, wlen);
+ MEMCPY(tp->search, wp, (tp->slen = slen) + 1);
+ TAILQ_INSERT_TAIL(tqp->tagq, tp, q);
+
+ /* Try to preset the tag within the current file. */
+ if (sp->frp != NULL && sp->frp->name != NULL &&
+ tqp->current == NULL && !strcmp(tp->fname, sp->frp->name))
+ tqp->current = tp;
++*matchesp;
}
- (void)read_prompt(sp, csc);
- return (0);
+ if (tqp->current == NULL)
+ tqp->current = TAILQ_FIRST(tqp->tagq);
+
+ return read_prompt(sp, csc);
io_err: if (feof(csc->from_fp))
errno = EIO;
@@ -772,15 +800,10 @@ io_err: if (feof(csc->from_fp))
* Search for the right path to this file.
*/
static void
-csc_file(sp, csc, name, dirp, dlenp, isolderp)
- SCR *sp;
- CSC *csc;
- char *name, **dirp;
- size_t *dlenp;
- int *isolderp;
+csc_file(SCR *sp, CSC *csc, char *name, char **dirp, size_t *dlenp, int *isolderp)
{
struct stat sb;
- char **pp, buf[MAXPATHLEN];
+ char **pp, *buf;
/*
* Check for the file in all of the listed paths. If we don't
@@ -790,13 +813,20 @@ csc_file(sp, csc, name, dirp, dlenp, isolderp)
* lives.
*/
for (pp = csc->paths; *pp != NULL; ++pp) {
- (void)snprintf(buf, sizeof(buf), "%s/%s", *pp, name);
+ if ((buf = join(*pp, name)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ *dlenp = 0;
+ return;
+ }
if (stat(buf, &sb) == 0) {
+ free(buf);
*dirp = *pp;
*dlenp = strlen(*pp);
- *isolderp = sb.st_mtime < csc->mtime;
+ *isolderp = timespeccmp(
+ &sb.st_mtimespec, &csc->mtim, <);
return;
}
+ free(buf);
}
*dlenp = 0;
}
@@ -806,12 +836,13 @@ csc_file(sp, csc, name, dirp, dlenp, isolderp)
* The cscope help command.
*/
static int
-cscope_help(sp, cmdp, subcmd)
- SCR *sp;
- EXCMD *cmdp;
- char *subcmd;
+cscope_help(SCR *sp, EXCMD *cmdp, CHAR_T *subcmd)
{
- return (csc_help(sp, subcmd));
+ char *np;
+ size_t nlen;
+
+ INT2CHAR(sp, subcmd, STRLEN(subcmd) + 1, np, nlen);
+ return (csc_help(sp, np));
}
/*
@@ -819,9 +850,7 @@ cscope_help(sp, cmdp, subcmd)
* Display help/usage messages.
*/
static int
-csc_help(sp, cmd)
- SCR *sp;
- char *cmd;
+csc_help(SCR *sp, char *cmd)
{
CC const *ccp;
@@ -848,12 +877,17 @@ csc_help(sp, cmd)
* The cscope kill command.
*/
static int
-cscope_kill(sp, cmdp, cn)
- SCR *sp;
- EXCMD *cmdp;
- char *cn;
+cscope_kill(SCR *sp, EXCMD *cmdp, CHAR_T *cn)
{
- return (terminate(sp, NULL, atoi(cn)));
+ char *np;
+ size_t nlen;
+ int n = 1;
+
+ if (*cn) {
+ INT2CHAR(sp, cn, STRLEN(cn) + 1, np, nlen);
+ n = atoi(np);
+ }
+ return (terminate(sp, NULL, n));
}
/*
@@ -861,49 +895,54 @@ cscope_kill(sp, cmdp, cn)
* Detach from a cscope process.
*/
static int
-terminate(sp, csc, n)
- SCR *sp;
- CSC *csc;
- int n;
+terminate(SCR *sp, CSC *csc, int n)
{
EX_PRIVATE *exp;
- int i, pstat;
+ int i = 0, pstat;
+ CSC *cp, *pre_cp = NULL;
exp = EXP(sp);
/*
- * We either get a csc structure or a number. If not provided a
- * csc structure, find the right one.
+ * We either get a csc structure or a number. Locate and remove
+ * the candidate which matches the structure or the number.
*/
- if (csc == NULL) {
- if (n < 1)
- goto badno;
- for (i = 1, csc = exp->cscq.lh_first;
- csc != NULL; csc = csc->q.le_next, i++)
- if (i == n)
- break;
- if (csc == NULL) {
-badno: msgq(sp, M_ERR, "312|%d: no such cscope session", n);
- return (1);
+ if (csc == NULL && n < 1)
+ goto badno;
+ SLIST_FOREACH(cp, exp->cscq, q) {
+ ++i;
+ if (csc == NULL ? i != n : cp != csc) {
+ pre_cp = cp;
+ continue;
}
+ if (cp == SLIST_FIRST(exp->cscq))
+ SLIST_REMOVE_HEAD(exp->cscq, q);
+ else
+ SLIST_REMOVE_AFTER(pre_cp, q);
+ csc = cp;
+ break;
+ }
+ if (csc == NULL) {
+badno: msgq(sp, M_ERR, "312|%d: no such cscope session", n);
+ return (1);
}
/*
* XXX
* Theoretically, we have the only file descriptors to the process,
* so closing them should let it exit gracefully, deleting temporary
- * files, etc. The original vi cscope integration sent the cscope
- * connection a SIGTERM signal, so I'm not sure if closing the file
- * descriptors is sufficient.
+ * files, etc. However, the earlier created cscope processes seems
+ * to refuse to quit unless we send a SIGTERM signal.
*/
if (csc->from_fp != NULL)
(void)fclose(csc->from_fp);
if (csc->to_fp != NULL)
(void)fclose(csc->to_fp);
+ if (i > 1)
+ (void)kill(csc->pid, SIGTERM);
(void)waitpid(csc->pid, &pstat, 0);
/* Discard cscope connection information. */
- LIST_REMOVE(csc, q);
if (csc->pbuf != NULL)
free(csc->pbuf);
if (csc->paths != NULL)
@@ -917,15 +956,24 @@ badno: msgq(sp, M_ERR, "312|%d: no such cscope session", n);
* The cscope reset command.
*/
static int
-cscope_reset(sp, cmdp, notusedp)
- SCR *sp;
- EXCMD *cmdp;
- char *notusedp;
+cscope_reset(SCR *sp, EXCMD *cmdp, CHAR_T *notusedp)
+{
+ return cscope_end(sp);
+}
+
+/*
+ * cscope_end --
+ * End all cscope connections.
+ *
+ * PUBLIC: int cscope_end __P((SCR *));
+ */
+int
+cscope_end(SCR *sp)
{
EX_PRIVATE *exp;
- for (exp = EXP(sp); exp->cscq.lh_first != NULL;)
- if (cscope_kill(sp, cmdp, "1"))
+ for (exp = EXP(sp); !SLIST_EMPTY(exp->cscq);)
+ if (terminate(sp, NULL, 1))
return (1);
return (0);
}
@@ -937,22 +985,20 @@ cscope_reset(sp, cmdp, notusedp)
* PUBLIC: int cscope_display __P((SCR *));
*/
int
-cscope_display(sp)
- SCR *sp;
+cscope_display(SCR *sp)
{
EX_PRIVATE *exp;
CSC *csc;
- int i;
+ int i = 0;
exp = EXP(sp);
- if (exp->cscq.lh_first == NULL) {
+ if (SLIST_EMPTY(exp->cscq)) {
ex_printf(sp, "No cscope connections.\n");
return (0);
}
- for (i = 1,
- csc = exp->cscq.lh_first; csc != NULL; ++i, csc = csc->q.le_next)
- ex_printf(sp,
- "%2d %s (process %lu)\n", i, csc->dname, (u_long)csc->pid);
+ SLIST_FOREACH(csc, exp->cscq, q)
+ ex_printf(sp, "%2d %s (process %lu)\n",
+ ++i, csc->dname, (u_long)csc->pid);
return (0);
}
@@ -963,10 +1009,7 @@ cscope_display(sp)
* PUBLIC: int cscope_search __P((SCR *, TAGQ *, TAG *));
*/
int
-cscope_search(sp, tqp, tp)
- SCR *sp;
- TAGQ *tqp;
- TAG *tp;
+cscope_search(SCR *sp, TAGQ *tqp, TAG *tp)
{
MARK m;
@@ -1015,8 +1058,7 @@ cscope_search(sp, tqp, tp)
* Return a pointer to the command structure.
*/
static CC const *
-lookup_ccmd(name)
- char *name;
+lookup_ccmd(char *name)
{
CC const *ccp;
size_t len;
@@ -1033,9 +1075,7 @@ lookup_ccmd(name)
* Read a prompt from cscope.
*/
static int
-read_prompt(sp, csc)
- SCR *sp;
- CSC *csc;
+read_prompt(SCR *sp, CSC *csc)
{
int ch;
diff --git a/ex/ex_def.h b/ex/ex_def.h
new file mode 100644
index 000000000000..7afb7b19d677
--- /dev/null
+++ b/ex/ex_def.h
@@ -0,0 +1,76 @@
+#define C_SCROLL 0
+#define C_BANG 1
+#define C_HASH 2
+#define C_SUBAGAIN 3
+#define C_STAR 4
+#define C_SHIFTL 5
+#define C_EQUAL 6
+#define C_SHIFTR 7
+#define C_AT 8
+#define C_APPEND 9
+#define C_ABBR 10
+#define C_ARGS 11
+#define C_BG 12
+#define C_CHANGE 13
+#define C_CD 14
+#define C_CHDIR 15
+#define C_COPY 16
+#define C_CSCOPE 17
+#define C_DELETE 18
+#define C_DISPLAY 19
+#define C_EDIT 20
+#define C_EX 21
+#define C_EXUSAGE 22
+#define C_FILE 23
+#define C_FG 24
+#define C_GLOBAL 25
+#define C_HELP 26
+#define C_INSERT 27
+#define C_JOIN 28
+#define C_K 29
+#define C_LIST 30
+#define C_MOVE 31
+#define C_MARK 32
+#define C_MAP 33
+#define C_MKEXRC 34
+#define C_NEXT 35
+#define C_NUMBER 36
+#define C_OPEN 37
+#define C_PRINT 38
+#define C_PRESERVE 39
+#define C_PREVIOUS 40
+#define C_PUT 41
+#define C_QUIT 42
+#define C_READ 43
+#define C_RECOVER 44
+#define C_RESIZE 45
+#define C_REWIND 46
+#define C_SUBSTITUTE 47
+#define C_SCRIPT 48
+#define C_SET 49
+#define C_SHELL 50
+#define C_SOURCE 51
+#define C_STOP 52
+#define C_SUSPEND 53
+#define C_T 54
+#define C_TAG 55
+#define C_TAGNEXT 56
+#define C_TAGPOP 57
+#define C_TAGPREV 58
+#define C_TAGTOP 59
+#define C_UNDO 60
+#define C_UNABBREVIATE 61
+#define C_UNMAP 62
+#define C_V 63
+#define C_VERSION 64
+#define C_VISUAL_EX 65
+#define C_VISUAL_VI 66
+#define C_VIUSAGE 67
+#define C_VSPLIT 68
+#define C_WRITE 69
+#define C_WN 70
+#define C_WQ 71
+#define C_XIT 72
+#define C_YANK 73
+#define C_Z 74
+#define C_SUBTILDE 75
diff --git a/ex/ex_delete.c b/ex/ex_delete.c
index 58734bbcfce4..34bbee480d4c 100644
--- a/ex/ex_delete.c
+++ b/ex/ex_delete.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_delete.c 10.9 (Berkeley) 10/23/96";
+static const char sccsid[] = "$Id: ex_delete.c,v 10.11 2001/06/25 15:19:15 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -30,9 +31,7 @@ static const char sccsid[] = "@(#)ex_delete.c 10.9 (Berkeley) 10/23/96";
* PUBLIC: int ex_delete __P((SCR *, EXCMD *));
*/
int
-ex_delete(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_delete(SCR *sp, EXCMD *cmdp)
{
recno_t lno;
diff --git a/ex/ex_display.c b/ex/ex_display.c
index 75315170f95e..6142a44a2cfa 100644
--- a/ex/ex_display.c
+++ b/ex/ex_display.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_display.c 10.12 (Berkeley) 4/10/96";
+static const char sccsid[] = "$Id: ex_display.c,v 10.15 2001/06/25 15:19:15 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -25,8 +26,9 @@ static const char sccsid[] = "@(#)ex_display.c 10.12 (Berkeley) 4/10/96";
#include "../common/common.h"
#include "tag.h"
+static int is_prefix __P((ARGS *, CHAR_T *));
static int bdisplay __P((SCR *));
-static void db __P((SCR *, CB *, CHAR_T *));
+static void db __P((SCR *, CB *, const char *));
/*
* ex_display -- :display b[uffers] | c[onnections] | s[creens] | t[ags]
@@ -36,37 +38,27 @@ static void db __P((SCR *, CB *, CHAR_T *));
* PUBLIC: int ex_display __P((SCR *, EXCMD *));
*/
int
-ex_display(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_display(SCR *sp, EXCMD *cmdp)
{
- switch (cmdp->argv[0]->bp[0]) {
+ ARGS *arg;
+
+ arg = cmdp->argv[0];
+
+ switch (arg->bp[0]) {
case 'b':
-#undef ARG
-#define ARG "buffers"
- if (cmdp->argv[0]->len >= sizeof(ARG) ||
- memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
+ if (!is_prefix(arg, L("buffers")))
break;
return (bdisplay(sp));
case 'c':
-#undef ARG
-#define ARG "connections"
- if (cmdp->argv[0]->len >= sizeof(ARG) ||
- memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
+ if (!is_prefix(arg, L("connections")))
break;
return (cscope_display(sp));
case 's':
-#undef ARG
-#define ARG "screens"
- if (cmdp->argv[0]->len >= sizeof(ARG) ||
- memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
+ if (!is_prefix(arg, L("screens")))
break;
return (ex_sdisplay(sp));
case 't':
-#undef ARG
-#define ARG "tags"
- if (cmdp->argv[0]->len >= sizeof(ARG) ||
- memcmp(cmdp->argv[0]->bp, ARG, cmdp->argv[0]->len))
+ if (!is_prefix(arg, L("tags")))
break;
return (ex_tag_display(sp));
}
@@ -75,35 +67,45 @@ ex_display(sp, cmdp)
}
/*
+ * is_prefix --
+ *
+ * Check that a command argument matches a prefix of a given string.
+ */
+static int
+is_prefix(ARGS *arg, CHAR_T *str)
+{
+ return arg->len <= STRLEN(str) && !MEMCMP(arg->bp, str, arg->len);
+}
+
+/*
* bdisplay --
*
* Display buffers.
*/
static int
-bdisplay(sp)
- SCR *sp;
+bdisplay(SCR *sp)
{
CB *cbp;
- if (sp->gp->cutq.lh_first == NULL && sp->gp->dcbp == NULL) {
+ if (SLIST_EMPTY(sp->gp->cutq) && sp->gp->dcbp == NULL) {
msgq(sp, M_INFO, "123|No cut buffers to display");
return (0);
}
/* Display regular cut buffers. */
- for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
+ SLIST_FOREACH(cbp, sp->gp->cutq, q) {
if (isdigit(cbp->name))
continue;
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ if (!TAILQ_EMPTY(cbp->textq))
db(sp, cbp, NULL);
if (INTERRUPTED(sp))
return (0);
}
/* Display numbered buffers. */
- for (cbp = sp->gp->cutq.lh_first; cbp != NULL; cbp = cbp->q.le_next) {
+ SLIST_FOREACH(cbp, sp->gp->cutq, q) {
if (!isdigit(cbp->name))
continue;
- if (cbp->textq.cqh_first != (void *)&cbp->textq)
+ if (!TAILQ_EMPTY(cbp->textq))
db(sp, cbp, NULL);
if (INTERRUPTED(sp))
return (0);
@@ -119,10 +121,7 @@ bdisplay(sp)
* Display a buffer.
*/
static void
-db(sp, cbp, name)
- SCR *sp;
- CB *cbp;
- CHAR_T *name;
+db(SCR *sp, CB *cbp, const char *name)
{
CHAR_T *p;
GS *gp;
@@ -133,8 +132,7 @@ db(sp, cbp, name)
(void)ex_printf(sp, "********** %s%s\n",
name == NULL ? KEY_NAME(sp, cbp->name) : name,
F_ISSET(cbp, CB_LMODE) ? " (line mode)" : " (character mode)");
- for (tp = cbp->textq.cqh_first;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_next) {
+ TAILQ_FOREACH(tp, cbp->textq, q) {
for (len = tp->len, p = tp->lb; len--; ++p) {
(void)ex_puts(sp, KEY_NAME(sp, *p));
if (INTERRUPTED(sp))
diff --git a/ex/ex_edit.c b/ex/ex_edit.c
index 8b18e0f0bbca..ce0f9a41407c 100644
--- a/ex/ex_edit.c
+++ b/ex/ex_edit.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_edit.c 10.10 (Berkeley) 4/27/96";
+static const char sccsid[] = "$Id: ex_edit.c,v 10.15 2011/12/22 23:26:50 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -46,12 +46,12 @@ static int ex_N_edit __P((SCR *, EXCMD *, FREF *, int));
* PUBLIC: int ex_edit __P((SCR *, EXCMD *));
*/
int
-ex_edit(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_edit(SCR *sp, EXCMD *cmdp)
{
FREF *frp;
int attach, setalt;
+ char *np;
+ size_t nlen;
switch (cmdp->argc) {
case 0:
@@ -72,17 +72,19 @@ ex_edit(sp, cmdp)
setalt = 0;
break;
case 1:
- if ((frp = file_add(sp, cmdp->argv[0]->bp)) == NULL)
+ INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1,
+ np, nlen);
+ if ((frp = file_add(sp, np)) == NULL)
return (1);
attach = 0;
setalt = 1;
- set_alt_name(sp, cmdp->argv[0]->bp);
+ set_alt_name(sp, np);
break;
default:
abort();
}
- if (F_ISSET(cmdp, E_NEWSCREEN))
+ if (F_ISSET(cmdp, E_NEWSCREEN) || cmdp->cmd == &cmds[C_VSPLIT])
return (ex_N_edit(sp, cmdp, frp, attach));
/*
@@ -108,18 +110,15 @@ ex_edit(sp, cmdp)
* New screen version of ex_edit.
*/
static int
-ex_N_edit(sp, cmdp, frp, attach)
- SCR *sp;
- EXCMD *cmdp;
- FREF *frp;
- int attach;
+ex_N_edit(SCR *sp, EXCMD *cmdp, FREF *frp, int attach)
{
SCR *new;
/* Get a new screen. */
if (screen_init(sp->gp, sp, &new))
return (1);
- if (vs_split(sp, new, 0)) {
+ if ((cmdp->cmd == &cmds[C_VSPLIT] && vs_vsplit(sp, new)) ||
+ (cmdp->cmd != &cmds[C_VSPLIT] && vs_split(sp, new, 0))) {
(void)screen_end(new);
return (1);
}
@@ -135,6 +134,13 @@ ex_N_edit(sp, cmdp, frp, attach)
new->lno = sp->lno;
new->cno = sp->cno;
+
+#if defined(USE_WIDECHAR) && defined(USE_ICONV)
+ /* Synchronize the iconv environments. */
+ o_set(new, O_FILEENCODING, OS_STRDUP,
+ O_STR(sp, O_FILEENCODING), 0);
+ conv_enc(new, O_FILEENCODING, 0);
+#endif
} else if (file_init(new, frp, NULL,
(FL_ISSET(cmdp->iflags, E_C_FORCE) ? FS_FORCE : 0))) {
(void)vs_discard(new, NULL);
diff --git a/ex/ex_equal.c b/ex/ex_equal.c
index 565df66bd0a9..7da5a20a3054 100644
--- a/ex/ex_equal.c
+++ b/ex/ex_equal.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_equal.c 10.10 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_equal.c,v 10.12 2001/06/25 15:19:15 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -28,9 +29,7 @@ static const char sccsid[] = "@(#)ex_equal.c 10.10 (Berkeley) 3/6/96";
* PUBLIC: int ex_equal __P((SCR *, EXCMD *));
*/
int
-ex_equal(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_equal(SCR *sp, EXCMD *cmdp)
{
recno_t lno;
diff --git a/ex/ex_file.c b/ex/ex_file.c
index 3492f9c7bf0d..12714a3974ba 100644
--- a/ex/ex_file.c
+++ b/ex/ex_file.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_file.c 10.12 (Berkeley) 7/12/96";
+static const char sccsid[] = "$Id: ex_file.c,v 10.14 2001/06/25 15:19:16 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
@@ -32,12 +33,12 @@ static const char sccsid[] = "@(#)ex_file.c 10.12 (Berkeley) 7/12/96";
* PUBLIC: int ex_file __P((SCR *, EXCMD *));
*/
int
-ex_file(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_file(SCR *sp, EXCMD *cmdp)
{
- CHAR_T *p;
+ char *p;
FREF *frp;
+ char *np;
+ size_t nlen;
NEEDFILE(sp, cmdp);
@@ -48,8 +49,9 @@ ex_file(sp, cmdp)
frp = sp->frp;
/* Make sure can allocate enough space. */
- if ((p = v_strdup(sp,
- cmdp->argv[0]->bp, cmdp->argv[0]->len)) == NULL)
+ INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1,
+ np, nlen);
+ if ((p = v_strdup(sp, np, nlen - 1)) == NULL)
return (1);
/* If already have a file name, it becomes the alternate. */
diff --git a/ex/ex_filter.c b/ex/ex_filter.c
index 2e86e58b3ba2..9af9a7c7becc 100644
--- a/ex/ex_filter.c
+++ b/ex/ex_filter.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_filter.c 10.34 (Berkeley) 10/23/96";
+static const char sccsid[] = "$Id: ex_filter.c,v 10.44 2003/11/05 17:11:54 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -36,21 +36,18 @@ static int filter_ldisplay __P((SCR *, FILE *));
* the utility.
*
* PUBLIC: int ex_filter __P((SCR *,
- * PUBLIC: EXCMD *, MARK *, MARK *, MARK *, char *, enum filtertype));
+ * PUBLIC: EXCMD *, MARK *, MARK *, MARK *, CHAR_T *, enum filtertype));
*/
int
-ex_filter(sp, cmdp, fm, tm, rp, cmd, ftype)
- SCR *sp;
- EXCMD *cmdp;
- MARK *fm, *tm, *rp;
- char *cmd;
- enum filtertype ftype;
+ex_filter(SCR *sp, EXCMD *cmdp, MARK *fm, MARK *tm, MARK *rp, CHAR_T *cmd, enum filtertype ftype)
{
FILE *ifp, *ofp;
pid_t parent_writer_pid, utility_pid;
recno_t nread;
int input[2], output[2], rval;
char *name;
+ char *np;
+ size_t nlen;
rval = 0;
@@ -141,7 +138,8 @@ err: if (input[0] != -1)
else
++name;
- execl(O_STR(sp, O_SHELL), name, "-c", cmd, NULL);
+ INT2CHAR(sp, cmd, STRLEN(cmd)+1, np, nlen);
+ execl(O_STR(sp, O_SHELL), name, "-c", np, (char *)NULL);
msgq_str(sp, M_SYSERR, O_STR(sp, O_SHELL), "execl: %s");
_exit (127);
/* NOTREACHED */
@@ -285,7 +283,8 @@ err: if (input[0] != -1)
* Ignore errors on vi file reads, to make reads prettier. It's
* completely inconsistent, and historic practice.
*/
-uwait: return (proc_wait(sp, (long)utility_pid, cmd,
+uwait: INT2CHAR(sp, cmd, STRLEN(cmd) + 1, np, nlen);
+ return (proc_wait(sp, (long)utility_pid, np,
ftype == FILTER_READ && F_ISSET(sp, SC_VI) ? 1 : 0, 0) || rval);
}
@@ -298,17 +297,19 @@ uwait: return (proc_wait(sp, (long)utility_pid, cmd,
* We use the ex print routines to make sure they're printable.
*/
static int
-filter_ldisplay(sp, fp)
- SCR *sp;
- FILE *fp;
+filter_ldisplay(SCR *sp, FILE *fp)
{
size_t len;
+ size_t wlen;
+ CHAR_T *wp;
EX_PRIVATE *exp;
- for (exp = EXP(sp); !ex_getline(sp, fp, &len) && !INTERRUPTED(sp);)
- if (ex_ldisplay(sp, exp->ibp, len, 0, 0))
+ for (exp = EXP(sp); !ex_getline(sp, fp, &len) && !INTERRUPTED(sp);) {
+ FILE2INT5(sp, exp->ibcw, exp->ibp, len, wp, wlen);
+ if (ex_ldisplay(sp, wp, wlen, 0, 0))
break;
+ }
if (ferror(fp))
msgq(sp, M_SYSERR, "filter read");
(void)fclose(fp);
diff --git a/ex/ex_global.c b/ex/ex_global.c
index aba9dc5fabe3..5dbbb07db0a7 100644
--- a/ex/ex_global.c
+++ b/ex/ex_global.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_global.c 10.22 (Berkeley) 10/10/96";
+static const char sccsid[] = "$Id: ex_global.c,v 10.32 2011/12/26 23:37:01 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -38,9 +39,7 @@ static int ex_g_setup __P((SCR *, EXCMD *, enum which));
* PUBLIC: int ex_global __P((SCR *, EXCMD *));
*/
int
-ex_global(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_global(SCR *sp, EXCMD *cmdp)
{
return (ex_g_setup(sp,
cmdp, FL_ISSET(cmdp->iflags, E_C_FORCE) ? V : GLOBAL));
@@ -53,9 +52,7 @@ ex_global(sp, cmdp)
* PUBLIC: int ex_v __P((SCR *, EXCMD *));
*/
int
-ex_v(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_v(SCR *sp, EXCMD *cmdp)
{
return (ex_g_setup(sp, cmdp, V));
}
@@ -65,10 +62,7 @@ ex_v(sp, cmdp)
* Ex global and v commands.
*/
static int
-ex_g_setup(sp, cmdp, cmd)
- SCR *sp;
- EXCMD *cmdp;
- enum which cmd;
+ex_g_setup(SCR *sp, EXCMD *cmdp, enum which cmd)
{
CHAR_T *ptrn, *p, *t;
EXCMD *ecp;
@@ -80,14 +74,13 @@ ex_g_setup(sp, cmdp, cmd)
regmatch_t match[1];
size_t len;
int cnt, delim, eval;
- char *dbp;
+ CHAR_T *dbp;
NEEDFILE(sp, cmdp);
if (F_ISSET(sp, SC_EX_GLOBAL)) {
- msgq(sp, M_ERR,
- "124|The %s command can't be used as part of a global or v command",
- cmdp->cmd->name);
+ msgq_wstr(sp, M_ERR, cmdp->cmd->name,
+ "124|The %s command can't be used as part of a global or v command");
return (1);
}
@@ -97,8 +90,8 @@ ex_g_setup(sp, cmdp, cmd)
*/
if (cmdp->argc == 0)
goto usage;
- for (p = cmdp->argv[0]->bp; isblank(*p); ++p);
- if (*p == '\0' || isalnum(*p) ||
+ for (p = cmdp->argv[0]->bp; cmdskip(*p); ++p);
+ if (!isascii(*p) || *p == '\0' || isalnum(*p) ||
*p == '\\' || *p == '|' || *p == '\n') {
usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
return (1);
@@ -139,13 +132,14 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
}
/* Re-compile the RE if necessary. */
- if (!F_ISSET(sp, SC_RE_SEARCH) && re_compile(sp,
- sp->re, sp->re_len, NULL, NULL, &sp->re_c, RE_C_SEARCH))
+ if (!F_ISSET(sp, SC_RE_SEARCH) &&
+ re_compile(sp, sp->re, sp->re_len,
+ NULL, NULL, &sp->re_c, RE_C_SEARCH))
return (1);
} else {
/* Compile the RE. */
- if (re_compile(sp, ptrn, t - ptrn,
- &sp->re, &sp->re_len, &sp->re_c, RE_C_SEARCH))
+ if (re_compile(sp, ptrn, t - ptrn, &sp->re,
+ &sp->re_len, &sp->re_c, RE_C_SEARCH))
return (1);
/*
@@ -164,7 +158,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
/* Get an EXCMD structure. */
CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD));
- CIRCLEQ_INIT(&ecp->rq);
+ TAILQ_INIT(ecp->rq);
/*
* Get a copy of the command string; the default command is print.
@@ -174,17 +168,17 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
* parsing it.
*/
if ((len = cmdp->argv[0]->len - (p - cmdp->argv[0]->bp)) == 0) {
- p = "pp";
+ p = L("p");
len = 1;
}
- MALLOC_RET(sp, ecp->cp, char *, len * 2);
+ MALLOC_RET(sp, ecp->cp, CHAR_T *, (len * 2) * sizeof(CHAR_T));
ecp->o_cp = ecp->cp;
ecp->o_clen = len;
- memcpy(ecp->cp + len, p, len);
+ MEMCPY(ecp->cp + len, p, len);
ecp->range_lno = OOBLNO;
FL_SET(ecp->agv_flags, cmd == GLOBAL ? AGV_GLOBAL : AGV_V);
- LIST_INSERT_HEAD(&sp->gp->ecq, ecp, q);
+ SLIST_INSERT_HEAD(sp->gp->ecq, ecp, q);
/*
* For each line... The semantics of global matching are that we first
@@ -204,7 +198,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
end = cmdp->addr2.lno; start <= end; ++start) {
if (cnt-- == 0) {
if (INTERRUPTED(sp)) {
- LIST_REMOVE(ecp, q);
+ SLIST_REMOVE_HEAD(sp->gp->ecq, q);
free(ecp->cp);
free(ecp);
break;
@@ -233,7 +227,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
}
/* If follows the last entry, extend the last entry's range. */
- if ((rp = ecp->rq.cqh_last) != (void *)&ecp->rq &&
+ if ((rp = TAILQ_LAST(ecp->rq, _rh)) != NULL &&
rp->stop == start - 1) {
++rp->stop;
continue;
@@ -244,7 +238,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
if (rp == NULL)
return (1);
rp->start = rp->stop = start;
- CIRCLEQ_INSERT_TAIL(&ecp->rq, rp, q);
+ TAILQ_INSERT_TAIL(ecp->rq, rp, q);
}
search_busy(sp, BUSY_OFF);
return (0);
@@ -257,10 +251,7 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
* PUBLIC: int ex_g_insdel __P((SCR *, lnop_t, recno_t));
*/
int
-ex_g_insdel(sp, op, lno)
- SCR *sp;
- lnop_t op;
- recno_t lno;
+ex_g_insdel(SCR *sp, lnop_t op, recno_t lno)
{
EXCMD *ecp;
RANGE *nrp, *rp;
@@ -272,12 +263,10 @@ ex_g_insdel(sp, op, lno)
if (op == LINE_RESET)
return (0);
- for (ecp = sp->gp->ecq.lh_first; ecp != NULL; ecp = ecp->q.le_next) {
+ SLIST_FOREACH(ecp, sp->gp->ecq, q) {
if (!FL_ISSET(ecp->agv_flags, AGV_AT | AGV_GLOBAL | AGV_V))
continue;
- for (rp = ecp->rq.cqh_first; rp != (void *)&ecp->rq; rp = nrp) {
- nrp = rp->q.cqe_next;
-
+ TAILQ_FOREACH_SAFE(rp, ecp->rq, q, nrp) {
/* If range less than the line, ignore it. */
if (rp->stop < lno)
continue;
@@ -305,7 +294,7 @@ ex_g_insdel(sp, op, lno)
*/
if (op == LINE_DELETE) {
if (rp->start > --rp->stop) {
- CIRCLEQ_REMOVE(&ecp->rq, rp, q);
+ TAILQ_REMOVE(ecp->rq, rp, q);
free(rp);
}
} else {
@@ -313,8 +302,7 @@ ex_g_insdel(sp, op, lno)
nrp->start = lno + 1;
nrp->stop = rp->stop + 1;
rp->stop = lno - 1;
- CIRCLEQ_INSERT_AFTER(&ecp->rq, rp, nrp, q);
- rp = nrp;
+ TAILQ_INSERT_AFTER(ecp->rq, rp, nrp, q);
}
}
diff --git a/ex/ex_init.c b/ex/ex_init.c
index 6a78416a3344..5b93e5bbccab 100644
--- a/ex/ex_init.c
+++ b/ex/ex_init.c
@@ -10,11 +10,10 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_init.c 10.26 (Berkeley) 8/12/96";
+static const char sccsid[] = "$Id: ex_init.c,v 10.33 2012/04/11 19:12:34 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
-#include <sys/types.h> /* XXX: param.h may not have included types.h */
+#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -42,8 +41,7 @@ static int ex_run_file __P((SCR *, char *));
* PUBLIC: int ex_screen_copy __P((SCR *, SCR *));
*/
int
-ex_screen_copy(orig, sp)
- SCR *orig, *sp;
+ex_screen_copy(SCR *orig, SCR *sp)
{
EX_PRIVATE *oexp, *nexp;
@@ -52,16 +50,17 @@ ex_screen_copy(orig, sp)
sp->ex_private = nexp;
/* Initialize queues. */
- CIRCLEQ_INIT(&nexp->tq);
- TAILQ_INIT(&nexp->tagfq);
- LIST_INIT(&nexp->cscq);
+ TAILQ_INIT(nexp->tq);
+ TAILQ_INIT(nexp->tagfq);
+ SLIST_INIT(nexp->cscq);
if (orig == NULL) {
} else {
oexp = EXP(orig);
if (oexp->lastbcomm != NULL &&
- (nexp->lastbcomm = strdup(oexp->lastbcomm)) == NULL) {
+ (nexp->lastbcomm = v_wstrdup(sp, oexp->lastbcomm,
+ STRLEN(oexp->lastbcomm))) == NULL) {
msgq(sp, M_SYSERR, NULL);
return(1);
}
@@ -78,8 +77,7 @@ ex_screen_copy(orig, sp)
* PUBLIC: int ex_screen_end __P((SCR *));
*/
int
-ex_screen_end(sp)
- SCR *sp;
+ex_screen_end(SCR *sp)
{
EX_PRIVATE *exp;
int rval;
@@ -102,9 +100,15 @@ ex_screen_end(sp)
if (exp->lastbcomm != NULL)
free(exp->lastbcomm);
+ if (exp->ibcw.bp1.c != NULL)
+ free(exp->ibcw.bp1.c);
+
if (ex_tag_free(sp))
rval = 1;
+ if (cscope_end(sp))
+ rval = 1;
+
/* Free private memory. */
free(exp);
sp->ex_private = NULL;
@@ -119,11 +123,7 @@ ex_screen_end(sp)
* PUBLIC: int ex_optchange __P((SCR *, int, char *, u_long *));
*/
int
-ex_optchange(sp, offset, str, valp)
- SCR *sp;
- int offset;
- char *str;
- u_long *valp;
+ex_optchange(SCR *sp, int offset, char *str, u_long *valp)
{
switch (offset) {
case O_TAGS:
@@ -140,11 +140,12 @@ ex_optchange(sp, offset, str, valp)
* PUBLIC: int ex_exrc __P((SCR *));
*/
int
-ex_exrc(sp)
- SCR *sp;
+ex_exrc(SCR *sp)
{
struct stat hsb, lsb;
- char *p, path[MAXPATHLEN];
+ char *p, *path;
+ CHAR_T *wp;
+ size_t wlen;
/*
* Source the system, environment, $HOME and local .exrc values.
@@ -187,28 +188,41 @@ ex_exrc(sp)
return (0);
if ((p = getenv("NEXINIT")) != NULL) {
- if (ex_run_str(sp, "NEXINIT", p, strlen(p), 1, 0))
+ CHAR2INT(sp, p, strlen(p) + 1, wp, wlen);
+ if (ex_run_str(sp, "NEXINIT", wp, wlen - 1, 1, 0))
return (1);
} else if ((p = getenv("EXINIT")) != NULL) {
- if (ex_run_str(sp, "EXINIT", p, strlen(p), 1, 0))
+ CHAR2INT(sp, p, strlen(p) + 1, wp, wlen);
+ if (ex_run_str(sp, "EXINIT", wp, wlen - 1, 1, 0))
return (1);
} else if ((p = getenv("HOME")) != NULL && *p) {
- (void)snprintf(path, sizeof(path), "%s/%s", p, _PATH_NEXRC);
+ int st = 0;
+
+ if ((path = join(p, _PATH_NEXRC)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
switch (exrc_isok(sp, &hsb, path, 0, 1)) {
case NOEXIST:
- (void)snprintf(path,
- sizeof(path), "%s/%s", p, _PATH_EXRC);
+ free(path);
+ if ((path = join(p, _PATH_EXRC)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
if (exrc_isok(sp,
&hsb, path, 0, 1) == RCOK && ex_run_file(sp, path))
- return (1);
+ st = 1;
break;
case NOPERM:
break;
case RCOK:
if (ex_run_file(sp, path))
- return (1);
+ st = 1;
break;
}
+ free(path);
+ if (st)
+ return st;
}
/* Run the commands. */
@@ -251,15 +265,15 @@ ex_exrc(sp)
* Set up a file of ex commands to run.
*/
static int
-ex_run_file(sp, name)
- SCR *sp;
- char *name;
+ex_run_file(SCR *sp, char *name)
{
- ARGS *ap[2], a;
EXCMD cmd;
+ CHAR_T *wp;
+ size_t wlen;
- ex_cinit(&cmd, C_SOURCE, 0, OOBLNO, OOBLNO, 0, ap);
- ex_cadd(&cmd, &a, name, strlen(name));
+ ex_cinit(sp, &cmd, C_SOURCE, 0, OOBLNO, OOBLNO, 0);
+ CHAR2INT(sp, name, strlen(name)+1, wp, wlen);
+ argv_exp0(sp, &cmd, wp, wlen - 1);
return (ex_source(sp, &cmd));
}
@@ -267,14 +281,10 @@ ex_run_file(sp, name)
* ex_run_str --
* Set up a string of ex commands to run.
*
- * PUBLIC: int ex_run_str __P((SCR *, char *, char *, size_t, int, int));
+ * PUBLIC: int ex_run_str __P((SCR *, char *, CHAR_T *, size_t, int, int));
*/
int
-ex_run_str(sp, name, str, len, ex_flags, nocopy)
- SCR *sp;
- char *name, *str;
- size_t len;
- int ex_flags, nocopy;
+ex_run_str(SCR *sp, char *name, CHAR_T *str, size_t len, int ex_flags, int nocopy)
{
GS *gp;
EXCMD *ecp;
@@ -282,7 +292,7 @@ ex_run_str(sp, name, str, len, ex_flags, nocopy)
gp = sp->gp;
if (EXCMD_RUNNING(gp)) {
CALLOC_RET(sp, ecp, EXCMD *, 1, sizeof(EXCMD));
- LIST_INSERT_HEAD(&gp->ecq, ecp, q);
+ SLIST_INSERT_HEAD(gp->ecq, ecp, q);
} else
ecp = &gp->excmd;
@@ -292,7 +302,7 @@ ex_run_str(sp, name, str, len, ex_flags, nocopy)
if (nocopy)
ecp->cp = str;
else
- if ((ecp->cp = v_strdup(sp, str, len)) == NULL)
+ if ((ecp->cp = v_wstrdup(sp, str, len)) == NULL)
return (1);
ecp->clen = len;
@@ -345,16 +355,12 @@ ex_run_str(sp, name, str, len, ex_flags, nocopy)
* files.
*/
static enum rc
-exrc_isok(sp, sbp, path, rootown, rootid)
- SCR *sp;
- struct stat *sbp;
- char *path;
- int rootown, rootid;
+exrc_isok(SCR *sp, struct stat *sbp, char *path, int rootown, int rootid)
{
enum { ROOTOWN, OWN, WRITER } etype;
uid_t euid;
int nf1, nf2;
- char *a, *b, buf[MAXPATHLEN];
+ char *a, *b, *buf;
/* Check for the file's existence. */
if (stat(path, sbp))
@@ -376,23 +382,30 @@ exrc_isok(sp, sbp, path, rootown, rootid)
return (RCOK);
denied: a = msg_print(sp, path, &nf1);
- if (strchr(path, '/') == NULL && getcwd(buf, sizeof(buf)) != NULL) {
+ if (strchr(path, '/') == NULL && (buf = getcwd(NULL, 0)) != NULL) {
+ char *p;
+
b = msg_print(sp, buf, &nf2);
+ if ((p = join(b, a)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ goto err;
+ }
switch (etype) {
case ROOTOWN:
msgq(sp, M_ERR,
- "125|%s/%s: not sourced: not owned by you or root",
- b, a);
+ "128|%s: not sourced: not owned by you or root", p);
break;
case OWN:
msgq(sp, M_ERR,
- "126|%s/%s: not sourced: not owned by you", b, a);
+ "129|%s: not sourced: not owned by you", p);
break;
case WRITER:
msgq(sp, M_ERR,
- "127|%s/%s: not sourced: writeable by a user other than the owner", b, a);
+ "130|%s: not sourced: writeable by a user other than the owner", p);
break;
}
+ free(p);
+err: free(buf);
if (nf2)
FREE_SPACE(sp, b, 0);
} else
diff --git a/ex/ex_join.c b/ex/ex_join.c
index c26c4243178a..822ed79c4854 100644
--- a/ex/ex_join.c
+++ b/ex/ex_join.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_join.c 10.10 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: ex_join.c,v 10.17 2004/03/16 14:14:04 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -32,14 +33,13 @@ static const char sccsid[] = "@(#)ex_join.c 10.10 (Berkeley) 9/15/96";
* PUBLIC: int ex_join __P((SCR *, EXCMD *));
*/
int
-ex_join(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_join(SCR *sp, EXCMD *cmdp)
{
recno_t from, to;
size_t blen, clen, len, tlen;
- int echar, extra, first;
- char *bp, *p, *tbp;
+ int echar = 0, extra, first;
+ CHAR_T *bp, *tbp = NULL;
+ CHAR_T *p;
NEEDFILE(sp, cmdp);
@@ -52,20 +52,13 @@ ex_join(sp, cmdp)
return (1);
}
- GET_SPACE_RET(sp, bp, blen, 256);
+ GET_SPACE_RETW(sp, bp, blen, 256);
/*
* The count for the join command was off-by-one,
* historically, to other counts for other commands.
*/
- if (FL_ISSET(cmdp->iflags, E_C_COUNT))
- ++cmdp->addr2.lno;
-
- /*
- * If only a single address specified, or, the same address
- * specified twice, the from/two addresses will be the same.
- */
- if (cmdp->addr1.lno == cmdp->addr2.lno)
+ if (F_ISSET(cmdp, E_ADDR_DEF) || cmdp->addrcnt == 1)
++cmdp->addr2.lno;
clen = tlen = 0;
@@ -90,7 +83,7 @@ ex_join(sp, cmdp)
* tbp - bp is the length of the new line.
*/
tlen += len + 2;
- ADD_SPACE_RET(sp, bp, blen, tlen);
+ ADD_SPACE_RETW(sp, bp, blen, tlen);
tbp = bp + clen;
/*
@@ -114,7 +107,7 @@ ex_join(sp, cmdp)
if (isblank(echar))
for (; len && isblank(*p); --len, ++p);
else if (p[0] != ')') {
- if (strchr(".?!", echar)) {
+ if (STRCHR(L(".?!"), echar)) {
*tbp++ = ' ';
++clen;
extra = 1;
@@ -126,7 +119,7 @@ ex_join(sp, cmdp)
}
if (len != 0) {
- memcpy(tbp, p, len);
+ MEMCPY(tbp, p, len);
tbp += len;
clen += len;
echar = p[len - 1];
@@ -167,10 +160,10 @@ ex_join(sp, cmdp)
/* If the original line changed, reset it. */
if (!first && db_set(sp, from, bp, tbp - bp)) {
-err: FREE_SPACE(sp, bp, blen);
+err: FREE_SPACEW(sp, bp, blen);
return (1);
}
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
sp->rptlines[L_JOINED] += (cmdp->addr2.lno - cmdp->addr1.lno) + 1;
return (0);
diff --git a/ex/ex_map.c b/ex/ex_map.c
index bc2cf0855919..60dbfe07d66f 100644
--- a/ex/ex_map.c
+++ b/ex/ex_map.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_map.c 10.9 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_map.c,v 10.11 2001/06/25 15:19:17 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -42,9 +43,7 @@ static const char sccsid[] = "@(#)ex_map.c 10.9 (Berkeley) 3/6/96";
* PUBLIC: int ex_map __P((SCR *, EXCMD *));
*/
int
-ex_map(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_map(SCR *sp, EXCMD *cmdp)
{
seq_t stype;
CHAR_T *input, *p;
@@ -107,13 +106,11 @@ nofunc: if (stype == SEQ_COMMAND && input[1] == '\0')
* PUBLIC: int ex_unmap __P((SCR *, EXCMD *));
*/
int
-ex_unmap(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_unmap(SCR *sp, EXCMD *cmdp)
{
if (seq_delete(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len,
FL_ISSET(cmdp->iflags, E_C_FORCE) ? SEQ_INPUT : SEQ_COMMAND)) {
- msgq_str(sp, M_INFO,
+ msgq_wstr(sp, M_INFO,
cmdp->argv[0]->bp, "135|\"%s\" isn't currently mapped");
return (1);
}
diff --git a/ex/ex_mark.c b/ex/ex_mark.c
index 08ad8c2aa30b..8c8ec3405ab3 100644
--- a/ex/ex_mark.c
+++ b/ex/ex_mark.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_mark.c 10.8 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_mark.c,v 10.9 2001/06/25 15:19:17 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -31,9 +32,7 @@ static const char sccsid[] = "@(#)ex_mark.c 10.8 (Berkeley) 3/6/96";
* PUBLIC: int ex_mark __P((SCR *, EXCMD *));
*/
int
-ex_mark(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_mark(SCR *sp, EXCMD *cmdp)
{
NEEDFILE(sp, cmdp);
diff --git a/ex/ex_mkexrc.c b/ex/ex_mkexrc.c
index 0eb15d408cf7..87530149addc 100644
--- a/ex/ex_mkexrc.c
+++ b/ex/ex_mkexrc.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_mkexrc.c 10.11 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_mkexrc.c,v 10.13 2001/06/25 15:19:17 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -37,21 +37,21 @@ static const char sccsid[] = "@(#)ex_mkexrc.c 10.11 (Berkeley) 3/6/96";
* PUBLIC: int ex_mkexrc __P((SCR *, EXCMD *));
*/
int
-ex_mkexrc(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_mkexrc(SCR *sp, EXCMD *cmdp)
{
struct stat sb;
FILE *fp;
int fd, sverrno;
char *fname;
+ size_t flen;
switch (cmdp->argc) {
case 0:
fname = _PATH_EXRC;
break;
case 1:
- fname = cmdp->argv[0]->bp;
+ INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1,
+ fname, flen);
set_alt_name(sp, fname);
break;
default:
diff --git a/ex/ex_move.c b/ex/ex_move.c
index d6e45c373964..c2499fd79a8f 100644
--- a/ex/ex_move.c
+++ b/ex/ex_move.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_move.c 10.10 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: ex_move.c,v 10.16 2012/02/11 15:52:33 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -31,11 +32,9 @@ static const char sccsid[] = "@(#)ex_move.c 10.10 (Berkeley) 9/15/96";
* PUBLIC: int ex_copy __P((SCR *, EXCMD *));
*/
int
-ex_copy(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_copy(SCR *sp, EXCMD *cmdp)
{
- CB cb;
+ CB cb = {{ 0 }};
MARK fm1, fm2, m, tm;
recno_t cnt;
int rval;
@@ -51,10 +50,9 @@ ex_copy(sp, cmdp)
*/
fm1 = cmdp->addr1;
fm2 = cmdp->addr2;
- memset(&cb, 0, sizeof(cb));
- CIRCLEQ_INIT(&cb.textq);
+ TAILQ_INIT(cb.textq);
for (cnt = fm1.lno; cnt <= fm2.lno; ++cnt)
- if (cut_line(sp, cnt, 0, 0, &cb)) {
+ if (cut_line(sp, cnt, 0, ENTIRE_LINE, &cb)) {
rval = 1;
goto err;
}
@@ -75,7 +73,7 @@ ex_copy(sp, cmdp)
sp->lno = m.lno + (cnt - 1);
sp->cno = 0;
}
-err: text_lfree(&cb.textq);
+err: text_lfree(cb.textq);
return (rval);
}
@@ -86,16 +84,15 @@ err: text_lfree(&cb.textq);
* PUBLIC: int ex_move __P((SCR *, EXCMD *));
*/
int
-ex_move(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_move(SCR *sp, EXCMD *cmdp)
{
LMARK *lmp;
MARK fm1, fm2;
recno_t cnt, diff, fl, tl, mfl, mtl;
size_t blen, len;
int mark_reset;
- char *bp, *p;
+ CHAR_T *bp;
+ CHAR_T *p;
NEEDFILE(sp, cmdp);
@@ -126,7 +123,7 @@ ex_move(sp, cmdp)
/* Log the old positions of the marks. */
mark_reset = 0;
- for (lmp = sp->ep->marks.lh_first; lmp != NULL; lmp = lmp->q.le_next)
+ SLIST_FOREACH(lmp, sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno >= fl && lmp->lno <= tl) {
mark_reset = 1;
@@ -135,7 +132,7 @@ ex_move(sp, cmdp)
}
/* Get memory for the copy. */
- GET_SPACE_RET(sp, bp, blen, 256);
+ GET_SPACE_RETW(sp, bp, blen, 256);
/* Move the lines. */
diff = (fm2.lno - fm1.lno) + 1;
@@ -145,13 +142,12 @@ ex_move(sp, cmdp)
for (cnt = diff; cnt--;) {
if (db_get(sp, fl, DBG_FATAL, &p, &len))
return (1);
- BINC_RET(sp, bp, blen, len);
- memcpy(bp, p, len);
+ BINC_RETW(sp, bp, blen, len);
+ MEMCPY(bp, p, len);
if (db_append(sp, 1, tl, bp, len))
return (1);
if (mark_reset)
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ SLIST_FOREACH(lmp, sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno == fl)
lmp->lno = tl + 1;
@@ -164,13 +160,12 @@ ex_move(sp, cmdp)
for (cnt = diff; cnt--;) {
if (db_get(sp, fl, DBG_FATAL, &p, &len))
return (1);
- BINC_RET(sp, bp, blen, len);
- memcpy(bp, p, len);
+ BINC_RETW(sp, bp, blen, len);
+ MEMCPY(bp, p, len);
if (db_append(sp, 1, tl++, bp, len))
return (1);
if (mark_reset)
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ SLIST_FOREACH(lmp, sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno == fl)
lmp->lno = tl;
@@ -179,15 +174,14 @@ ex_move(sp, cmdp)
return (1);
}
}
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
sp->lno = tl; /* Last line moved. */
sp->cno = 0;
/* Log the new positions of the marks. */
if (mark_reset)
- for (lmp = sp->ep->marks.lh_first;
- lmp != NULL; lmp = lmp->q.le_next)
+ SLIST_FOREACH(lmp, sp->ep->marks, q)
if (lmp->name != ABSMARK1 &&
lmp->lno >= mfl && lmp->lno <= mtl)
(void)log_mark(sp, lmp);
diff --git a/ex/ex_open.c b/ex/ex_open.c
index afffaeb2202d..97414b93e3dc 100644
--- a/ex/ex_open.c
+++ b/ex/ex_open.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_open.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_open.c,v 10.8 2001/06/25 15:19:17 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -30,9 +31,7 @@ static const char sccsid[] = "@(#)ex_open.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int ex_open __P((SCR *, EXCMD *));
*/
int
-ex_open(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_open(SCR *sp, EXCMD *cmdp)
{
/* If open option off, disallow open command. */
if (!O_ISSET(sp, O_OPEN)) {
diff --git a/ex/ex_perl.c b/ex/ex_perl.c
deleted file mode 100644
index e620352ab518..000000000000
--- a/ex/ex_perl.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- * Copyright (c) 1995
- * George V. Neville-Neil. All rights reserved.
- * Copyright (c) 1996
- * Sven Verdoolaege. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ex_perl.c 8.10 (Berkeley) 9/15/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-/*
- * ex_perl -- :[line [,line]] perl [command]
- * Run a command through the perl interpreter.
- *
- * ex_perldo -- :[line [,line]] perldo [command]
- * Run a set of lines through the perl interpreter.
- *
- * PUBLIC: int ex_perl __P((SCR*, EXCMD *));
- */
-int
-ex_perl(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
-{
-#ifdef HAVE_PERL_INTERP
- CHAR_T *p;
- size_t len;
-
- /* Skip leading white space. */
- if (cmdp->argc != 0)
- for (p = cmdp->argv[0]->bp,
- len = cmdp->argv[0]->len; len > 0; --len, ++p)
- if (!isblank(*p))
- break;
- if (cmdp->argc == 0 || len == 0) {
- ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
- return (1);
- }
- return (cmdp->cmd == &cmds[C_PERLCMD] ?
- perl_ex_perl(sp, p, len, cmdp->addr1.lno, cmdp->addr2.lno) :
- perl_ex_perldo(sp, p, len, cmdp->addr1.lno, cmdp->addr2.lno));
-#else
- msgq(sp, M_ERR, "306|Vi was not loaded with a Perl interpreter");
- return (1);
-#endif
-}
diff --git a/ex/ex_preserve.c b/ex/ex_preserve.c
index 5614c88d753a..bda4bb44b695 100644
--- a/ex/ex_preserve.c
+++ b/ex/ex_preserve.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_preserve.c 10.12 (Berkeley) 4/27/96";
+static const char sccsid[] = "$Id: ex_preserve.c,v 10.15 2001/06/25 15:19:18 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
@@ -31,9 +32,7 @@ static const char sccsid[] = "@(#)ex_preserve.c 10.12 (Berkeley) 4/27/96";
* PUBLIC: int ex_preserve __P((SCR *, EXCMD *));
*/
int
-ex_preserve(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_preserve(SCR *sp, EXCMD *cmdp)
{
recno_t lno;
@@ -67,17 +66,18 @@ ex_preserve(sp, cmdp)
* PUBLIC: int ex_recover __P((SCR *, EXCMD *));
*/
int
-ex_recover(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_recover(SCR *sp, EXCMD *cmdp)
{
ARGS *ap;
FREF *frp;
+ char *np;
+ size_t nlen;
ap = cmdp->argv[0];
/* Set the alternate file name. */
- set_alt_name(sp, ap->bp);
+ INT2CHAR(sp, ap->bp, ap->len+1, np, nlen);
+ set_alt_name(sp, np);
/*
* Check for modifications. Autowrite did not historically
@@ -87,7 +87,8 @@ ex_recover(sp, cmdp)
return (1);
/* Get a file structure for the file. */
- if ((frp = file_add(sp, ap->bp)) == NULL)
+ INT2CHAR(sp, ap->bp, ap->len+1, np, nlen);
+ if ((frp = file_add(sp, np)) == NULL)
return (1);
/* Set the recover bit. */
diff --git a/ex/ex_print.c b/ex/ex_print.c
index 4218e08e0978..2c9208aa6729 100644
--- a/ex/ex_print.c
+++ b/ex/ex_print.c
@@ -10,27 +10,24 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_print.c 10.18 (Berkeley) 5/12/96";
+static const char sccsid[] = "$Id: ex_print.c,v 10.25 2011/12/12 22:12:20 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
#include <limits.h>
+#include <stdarg.h>
#include <stdio.h>
#include <string.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
#include "../common/common.h"
-static int ex_prchars __P((SCR *, const char *, size_t *, size_t, u_int, int));
+static int ex_prchars __P((SCR *, const CHAR_T *, size_t *, size_t,
+ u_int, int));
/*
* ex_list -- :[line [,line]] l[ist] [count] [flags]
@@ -40,9 +37,7 @@ static int ex_prchars __P((SCR *, const char *, size_t *, size_t, u_int, int));
* PUBLIC: int ex_list __P((SCR *, EXCMD *));
*/
int
-ex_list(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_list(SCR *sp, EXCMD *cmdp)
{
if (ex_print(sp, cmdp,
&cmdp->addr1, &cmdp->addr2, cmdp->iflags | E_C_LIST))
@@ -60,9 +55,7 @@ ex_list(sp, cmdp)
* PUBLIC: int ex_number __P((SCR *, EXCMD *));
*/
int
-ex_number(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_number(SCR *sp, EXCMD *cmdp)
{
if (ex_print(sp, cmdp,
&cmdp->addr1, &cmdp->addr2, cmdp->iflags | E_C_HASH))
@@ -80,9 +73,7 @@ ex_number(sp, cmdp)
* PUBLIC: int ex_pr __P((SCR *, EXCMD *));
*/
int
-ex_pr(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_pr(SCR *sp, EXCMD *cmdp)
{
if (ex_print(sp, cmdp, &cmdp->addr1, &cmdp->addr2, cmdp->iflags))
return (1);
@@ -98,16 +89,13 @@ ex_pr(sp, cmdp)
* PUBLIC: int ex_print __P((SCR *, EXCMD *, MARK *, MARK *, u_int32_t));
*/
int
-ex_print(sp, cmdp, fp, tp, flags)
- SCR *sp;
- EXCMD *cmdp;
- MARK *fp, *tp;
- u_int32_t flags;
+ex_print(SCR *sp, EXCMD *cmdp, MARK *fp, MARK *tp, u_int32_t flags)
{
GS *gp;
recno_t from, to;
size_t col, len;
- char *p, buf[10];
+ CHAR_T *p;
+ CHAR_T buf[10];
NEEDFILE(sp, cmdp);
@@ -122,10 +110,10 @@ ex_print(sp, cmdp, fp, tp, flags)
*/
if (LF_ISSET(E_C_HASH)) {
if (from <= 999999) {
- snprintf(buf, sizeof(buf), "%6ld ", from);
+ SPRINTF(buf, SIZE(buf), L("%6u "), from);
p = buf;
} else
- p = "TOOBIG ";
+ p = L("TOOBIG ");
if (ex_prchars(sp, p, &col, 8, 0, 0))
return (1);
}
@@ -153,19 +141,15 @@ ex_print(sp, cmdp, fp, tp, flags)
* ex_ldisplay --
* Display a line without any preceding number.
*
- * PUBLIC: int ex_ldisplay __P((SCR *, const char *, size_t, size_t, u_int));
+ * PUBLIC: int ex_ldisplay __P((SCR *, const CHAR_T *, size_t, size_t, u_int));
*/
int
-ex_ldisplay(sp, p, len, col, flags)
- SCR *sp;
- const char *p;
- size_t len, col;
- u_int flags;
+ex_ldisplay(SCR *sp, const CHAR_T *p, size_t len, size_t col, u_int flags)
{
if (len > 0 && ex_prchars(sp, p, &col, len, LF_ISSET(E_C_LIST), 0))
return (1);
if (!INTERRUPTED(sp) && LF_ISSET(E_C_LIST)) {
- p = "$";
+ p = L("$");
if (ex_prchars(sp, p, &col, 1, LF_ISSET(E_C_LIST), 0))
return (1);
}
@@ -181,21 +165,19 @@ ex_ldisplay(sp, p, len, col, flags)
* PUBLIC: int ex_scprint __P((SCR *, MARK *, MARK *));
*/
int
-ex_scprint(sp, fp, tp)
- SCR *sp;
- MARK *fp, *tp;
+ex_scprint(SCR *sp, MARK *fp, MARK *tp)
{
- const char *p;
+ CHAR_T *p;
size_t col, len;
col = 0;
if (O_ISSET(sp, O_NUMBER)) {
- p = " ";
+ p = L(" ");
if (ex_prchars(sp, p, &col, 8, 0, 0))
return (1);
}
- if (db_get(sp, fp->lno, DBG_FATAL, (char **)&p, &len))
+ if (db_get(sp, fp->lno, DBG_FATAL, &p, &len))
return (1);
if (ex_prchars(sp, p, &col, fp->cno, 0, ' '))
@@ -206,7 +188,7 @@ ex_scprint(sp, fp, tp)
return (1);
if (INTERRUPTED(sp))
return (1);
- p = "[ynq]"; /* XXX: should be msg_cat. */
+ p = L("[ynq]"); /* XXX: should be msg_cat. */
if (ex_prchars(sp, p, &col, 5, 0, 0))
return (1);
(void)ex_fflush(sp);
@@ -218,14 +200,11 @@ ex_scprint(sp, fp, tp)
* Local routine to dump characters to the screen.
*/
static int
-ex_prchars(sp, p, colp, len, flags, repeatc)
- SCR *sp;
- const char *p;
- size_t *colp, len;
- u_int flags;
- int repeatc;
+ex_prchars(SCR *sp, const CHAR_T *p, size_t *colp, size_t len,
+ u_int flags, int repeatc)
{
- CHAR_T ch, *kp;
+ CHAR_T ch;
+ char *kp;
GS *gp;
size_t col, tlen, ts;
@@ -271,14 +250,10 @@ intr: *colp = col;
* PUBLIC: int ex_printf __P((SCR *, const char *, ...));
*/
int
-#ifdef __STDC__
-ex_printf(SCR *sp, const char *fmt, ...)
-#else
-ex_printf(sp, fmt, va_alist)
- SCR *sp;
- const char *fmt;
- va_dcl
-#endif
+ex_printf(
+ SCR *sp,
+ const char *fmt,
+ ...)
{
EX_PRIVATE *exp;
va_list ap;
@@ -286,11 +261,7 @@ ex_printf(sp, fmt, va_alist)
exp = EXP(sp);
-#ifdef __STDC__
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
exp->obp_len += n = vsnprintf(exp->obp + exp->obp_len,
sizeof(exp->obp) - exp->obp_len, fmt, ap);
va_end(ap);
@@ -309,9 +280,7 @@ ex_printf(sp, fmt, va_alist)
* PUBLIC: int ex_puts __P((SCR *, const char *));
*/
int
-ex_puts(sp, str)
- SCR *sp;
- const char *str;
+ex_puts(SCR *sp, const char *str)
{
EX_PRIVATE *exp;
int doflush, n;
@@ -337,8 +306,7 @@ ex_puts(sp, str)
* PUBLIC: int ex_fflush __P((SCR *sp));
*/
int
-ex_fflush(sp)
- SCR *sp;
+ex_fflush(SCR *sp)
{
EX_PRIVATE *exp;
diff --git a/ex/ex_put.c b/ex/ex_put.c
index 2facb03f0fb5..7a3996be77c8 100644
--- a/ex/ex_put.c
+++ b/ex/ex_put.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_put.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_put.c,v 10.8 2001/06/25 15:19:18 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -31,9 +32,7 @@ static const char sccsid[] = "@(#)ex_put.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int ex_put __P((SCR *, EXCMD *));
*/
int
-ex_put(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_put(SCR *sp, EXCMD *cmdp)
{
MARK m;
diff --git a/ex/ex_quit.c b/ex/ex_quit.c
index 705fa1a64ade..2cfaeb1dc0fc 100644
--- a/ex/ex_quit.c
+++ b/ex/ex_quit.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_quit.c 10.7 (Berkeley) 4/27/96";
+static const char sccsid[] = "$Id: ex_quit.c,v 10.8 2001/06/25 15:19:18 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -29,9 +30,7 @@ static const char sccsid[] = "@(#)ex_quit.c 10.7 (Berkeley) 4/27/96";
* PUBLIC: int ex_quit __P((SCR *, EXCMD *));
*/
int
-ex_quit(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_quit(SCR *sp, EXCMD *cmdp)
{
int force;
diff --git a/ex/ex_read.c b/ex/ex_read.c
index 78296ff28ca6..187f0902398a 100644
--- a/ex/ex_read.c
+++ b/ex/ex_read.c
@@ -10,13 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_read.c 10.38 (Berkeley) 8/12/96";
+static const char sccsid[] = "$Id: ex_read.c,v 10.44 2001/06/25 15:19:19 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -40,20 +39,20 @@ static const char sccsid[] = "@(#)ex_read.c 10.38 (Berkeley) 8/12/96";
* PUBLIC: int ex_read __P((SCR *, EXCMD *));
*/
int
-ex_read(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_read(SCR *sp, EXCMD *cmdp)
{
enum { R_ARG, R_EXPANDARG, R_FILTER } which;
struct stat sb;
- CHAR_T *arg, *name;
+ CHAR_T *arg = NULL;
+ char *name = NULL;
+ size_t nlen;
EX_PRIVATE *exp;
FILE *fp;
FREF *frp;
GS *gp;
MARK rm;
recno_t nlines;
- size_t arglen;
+ size_t arglen = 0;
int argc, rval;
char *p;
@@ -77,7 +76,7 @@ ex_read(sp, cmdp)
/* Secure means no shell access. */
if (O_ISSET(sp, O_SECURE)) {
- ex_emsg(sp, cmdp->cmd->name, EXM_SECURE_F);
+ ex_wemsg(sp, cmdp->cmd->name, EXM_SECURE_F);
return (1);
}
} else
@@ -116,7 +115,8 @@ ex_read(sp, cmdp)
if (exp->lastbcomm != NULL)
free(exp->lastbcomm);
if ((exp->lastbcomm =
- strdup(cmdp->argv[argc]->bp)) == NULL) {
+ v_wstrdup(sp, cmdp->argv[argc]->bp,
+ cmdp->argv[argc]->len)) == NULL) {
msgq(sp, M_SYSERR, NULL);
return (1);
}
@@ -132,7 +132,7 @@ ex_read(sp, cmdp)
} else {
if (F_ISSET(cmdp, E_MODIFY))
(void)ex_printf(sp,
- "!%s\n", cmdp->argv[argc]->bp);
+ "!"WS"\n", cmdp->argv[argc]->bp);
else
(void)ex_puts(sp, "!\n");
(void)ex_fflush(sp);
@@ -157,7 +157,7 @@ ex_read(sp, cmdp)
*/
if (F_ISSET(sp, SC_VI)) {
if (gp->scr_screen(sp, SC_EX)) {
- ex_emsg(sp, cmdp->cmd->name, EXM_NOCANON_F);
+ ex_wemsg(sp, cmdp->cmd->name, EXM_NOCANON_F);
return (1);
}
/*
@@ -207,7 +207,8 @@ ex_read(sp, cmdp)
abort();
/* NOTREACHED */
case 2:
- name = cmdp->argv[1]->bp;
+ INT2CHAR(sp, cmdp->argv[1]->bp, cmdp->argv[1]->len + 1,
+ name, nlen);
/*
* !!!
* Historically, the read and write commands renamed
@@ -216,8 +217,7 @@ ex_read(sp, cmdp)
*/
if (F_ISSET(sp->frp, FR_TMPFILE) &&
!F_ISSET(sp->frp, FR_EXNAMED)) {
- if ((p = v_strdup(sp, cmdp->argv[1]->bp,
- cmdp->argv[1]->len)) != NULL) {
+ if ((p = strdup(name)) != NULL) {
free(sp->frp->name);
sp->frp->name = p;
}
@@ -230,11 +230,14 @@ ex_read(sp, cmdp)
/* Notify the screen. */
(void)sp->gp->scr_rename(sp, sp->frp->name, 1);
- } else
+ name = sp->frp->name;
+ } else {
set_alt_name(sp, name);
+ name = sp->alt_name;
+ }
break;
default:
- ex_emsg(sp, cmdp->argv[0]->bp, EXM_FILECOUNT);
+ ex_wemsg(sp, cmdp->argv[0]->bp, EXM_FILECOUNT);
return (1);
}
@@ -261,7 +264,7 @@ ex_read(sp, cmdp)
}
/* Try and get a lock. */
- if (file_lock(sp, NULL, NULL, fileno(fp), 0) == LOCK_UNAVAIL)
+ if (file_lock(sp, NULL, fileno(fp), 0) == LOCK_UNAVAIL)
msgq(sp, M_ERR, "146|%s: read lock was unavailable", name);
rval = ex_readfp(sp, name, fp, &cmdp->addr1, &nlines, 0);
@@ -291,13 +294,7 @@ ex_read(sp, cmdp)
* PUBLIC: int ex_readfp __P((SCR *, char *, FILE *, MARK *, recno_t *, int));
*/
int
-ex_readfp(sp, name, fp, fm, nlinesp, silent)
- SCR *sp;
- char *name;
- FILE *fp;
- MARK *fm;
- recno_t *nlinesp;
- int silent;
+ex_readfp(SCR *sp, char *name, FILE *fp, MARK *fm, recno_t *nlinesp, int silent)
{
EX_PRIVATE *exp;
GS *gp;
@@ -306,6 +303,8 @@ ex_readfp(sp, name, fp, fm, nlinesp, silent)
u_long ccnt; /* XXX: can't print off_t portably. */
int nf, rval;
char *p;
+ size_t wlen;
+ CHAR_T *wp;
gp = sp->gp;
exp = EXP(sp);
@@ -327,7 +326,8 @@ ex_readfp(sp, name, fp, fm, nlinesp, silent)
p = NULL;
}
}
- if (db_append(sp, 1, lno, exp->ibp, len))
+ FILE2INT5(sp, exp->ibcw, exp->ibp, len, wp, wlen);
+ if (db_append(sp, 1, lno, wp, wlen))
goto err;
ccnt += len;
}
@@ -342,7 +342,8 @@ ex_readfp(sp, name, fp, fm, nlinesp, silent)
if (!silent) {
p = msg_print(sp, name, &nf);
msgq(sp, M_INFO,
- "148|%s: %lu lines, %lu characters", p, lcnt, ccnt);
+ "148|%s: %lu lines, %lu characters", p,
+ (u_long)lcnt, ccnt);
if (nf)
FREE_SPACE(sp, p, 0);
}
diff --git a/ex/ex_screen.c b/ex/ex_screen.c
index 9bc5bf04b06a..9cb108f976a7 100644
--- a/ex/ex_screen.c
+++ b/ex/ex_screen.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_screen.c 10.11 (Berkeley) 6/29/96";
+static const char sccsid[] = "$Id: ex_screen.c,v 10.12 2001/06/25 15:19:19 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -33,9 +33,7 @@ static const char sccsid[] = "@(#)ex_screen.c 10.11 (Berkeley) 6/29/96";
* PUBLIC: int ex_bg __P((SCR *, EXCMD *));
*/
int
-ex_bg(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_bg(SCR *sp, EXCMD *cmdp)
{
return (vs_bg(sp));
}
@@ -47,9 +45,7 @@ ex_bg(sp, cmdp)
* PUBLIC: int ex_fg __P((SCR *, EXCMD *));
*/
int
-ex_fg(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_fg(SCR *sp, EXCMD *cmdp)
{
SCR *nsp;
int newscreen;
@@ -73,9 +69,7 @@ ex_fg(sp, cmdp)
* PUBLIC: int ex_resize __P((SCR *, EXCMD *));
*/
int
-ex_resize(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_resize(SCR *sp, EXCMD *cmdp)
{
adj_t adj;
@@ -104,22 +98,21 @@ ex_resize(sp, cmdp)
* PUBLIC: int ex_sdisplay __P((SCR *));
*/
int
-ex_sdisplay(sp)
- SCR *sp;
+ex_sdisplay(SCR *sp)
{
GS *gp;
SCR *tsp;
int cnt, col, len, sep;
gp = sp->gp;
- if ((tsp = gp->hq.cqh_first) == (void *)&gp->hq) {
+ if ((tsp = TAILQ_FIRST(gp->hq)) == NULL) {
msgq(sp, M_INFO, "149|No background screens to display");
return (0);
}
col = len = sep = 0;
- for (cnt = 1; tsp != (void *)&gp->hq && !INTERRUPTED(sp);
- tsp = tsp->q.cqe_next) {
+ for (cnt = 1; tsp != NULL && !INTERRUPTED(sp);
+ tsp = TAILQ_NEXT(tsp, q)) {
col += len = strlen(tsp->frp->name) + sep;
if (col >= sp->cols - 1) {
col = len;
diff --git a/ex/ex_script.c b/ex/ex_script.c
index 9ca6d60060d9..5ba0acf2e2f2 100644
--- a/ex/ex_script.c
+++ b/ex/ex_script.c
@@ -13,32 +13,32 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_script.c 10.30 (Berkeley) 9/24/96";
+static const char sccsid[] = "$Id: ex_script.c,v 10.44 2012/10/05 10:17:47 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
-#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
-#endif
#include <sys/stat.h>
-#ifdef HAVE_SYS5_PTY
-#include <sys/stropts.h>
-#endif
-#include <sys/time.h>
#include <sys/wait.h>
#include <bitstring.h>
#include <errno.h>
#include <fcntl.h>
-#include <stdio.h> /* XXX: OSF/1 bug: include before <grp.h> */
#include <grp.h>
#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#else
+#include <util.h>
+#endif
#include "../common/common.h"
#include "../vi/vi.h"
@@ -50,7 +50,6 @@ static int sscr_getprompt __P((SCR *));
static int sscr_init __P((SCR *));
static int sscr_insert __P((SCR *));
static int sscr_matchprompt __P((SCR *, char *, size_t, size_t *));
-static int sscr_pty __P((int *, int *, char *, struct termios *, void *));
static int sscr_setprompt __P((SCR *, char *, size_t));
/*
@@ -60,9 +59,7 @@ static int sscr_setprompt __P((SCR *, char *, size_t));
* PUBLIC: int ex_script __P((SCR *, EXCMD *));
*/
int
-ex_script(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_script(SCR *sp, EXCMD *cmdp)
{
/* Vi only command. */
if (!F_ISSET(sp, SC_VI)) {
@@ -87,8 +84,7 @@ ex_script(sp, cmdp)
* Create a pty setup for a shell.
*/
static int
-sscr_init(sp)
- SCR *sp;
+sscr_init(SCR *sp)
{
SCRIPT *sc;
char *sh, *sh_path;
@@ -119,24 +115,16 @@ sscr_init(sp)
sc->sh_term.c_oflag &= ~OPOST;
sc->sh_term.c_cflag &= ~(ECHO|ECHOE|ECHONL|ECHOK);
-#ifdef TIOCGWINSZ
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &sc->sh_win) == -1) {
msgq(sp, M_SYSERR, "tcgetattr");
goto err;
}
- if (sscr_pty(&sc->sh_master,
+ if (openpty(&sc->sh_master,
&sc->sh_slave, sc->sh_name, &sc->sh_term, &sc->sh_win) == -1) {
- msgq(sp, M_SYSERR, "pty");
+ msgq(sp, M_SYSERR, "openpty");
goto err;
}
-#else
- if (sscr_pty(&sc->sh_master,
- &sc->sh_slave, sc->sh_name, &sc->sh_term, NULL) == -1) {
- msgq(sp, M_SYSERR, "pty");
- goto err;
- }
-#endif
/*
* __TK__ huh?
@@ -203,17 +191,20 @@ err: if (sc->sh_master != -1)
* carriage return comes; set the prompt from that line.
*/
static int
-sscr_getprompt(sp)
- SCR *sp;
+sscr_getprompt(SCR *sp)
{
+ EX_PRIVATE *exp;
struct timeval tv;
- CHAR_T *endp, *p, *t, buf[1024];
+ char *endp, *p, *t, buf[1024];
SCRIPT *sc;
fd_set fdset;
recno_t lline;
size_t llen, len;
- u_int value;
int nr;
+ CHAR_T *wp;
+ size_t wlen;
+
+ exp = EXP(sp);
FD_ZERO(&fdset);
endp = buf;
@@ -251,10 +242,11 @@ more: len = sizeof(buf) - (endp - buf);
/* If any complete lines, push them into the file. */
for (p = t = buf; p < endp; ++p) {
- value = KEY_VAL(sp, *p);
- if (value == K_CR || value == K_NL) {
+ if (*p == '\r' || *p == '\n') {
+ if (CHAR2INT5(sp, exp->ibcw, t, p - t, wp, wlen))
+ goto conv_err;
if (db_last(sp, &lline) ||
- db_append(sp, 0, lline, t, p - t))
+ db_append(sp, 0, lline, wp, wlen))
goto prompterr;
t = p + 1;
}
@@ -284,7 +276,11 @@ more: len = sizeof(buf) - (endp - buf);
endp = buf;
/* Append the line into the file. */
- if (db_last(sp, &lline) || db_append(sp, 0, lline, buf, llen)) {
+ if (CHAR2INT5(sp, exp->ibcw, buf, llen, wp, wlen))
+ goto conv_err;
+ if (db_last(sp, &lline) || db_append(sp, 0, lline, wp, wlen)) {
+ if (0)
+conv_err: msgq(sp, M_ERR, "323|Invalid input. Truncated.");
prompterr: sscr_end(sp);
return (1);
}
@@ -299,38 +295,40 @@ prompterr: sscr_end(sp);
* PUBLIC: int sscr_exec __P((SCR *, recno_t));
*/
int
-sscr_exec(sp, lno)
- SCR *sp;
- recno_t lno;
+sscr_exec(SCR *sp, recno_t lno)
{
SCRIPT *sc;
recno_t last_lno;
size_t blen, len, last_len, tlen;
int isempty, matchprompt, nw, rval;
- char *bp, *p;
+ char *bp = NULL, *p;
+ CHAR_T *wp;
+ size_t wlen;
/* If there's a prompt on the last line, append the command. */
if (db_last(sp, &last_lno))
return (1);
- if (db_get(sp, last_lno, DBG_FATAL, &p, &last_len))
+ if (db_get(sp, last_lno, DBG_FATAL, &wp, &wlen))
return (1);
+ INT2CHAR(sp, wp, wlen, p, last_len);
if (sscr_matchprompt(sp, p, last_len, &tlen) && tlen == 0) {
matchprompt = 1;
- GET_SPACE_RET(sp, bp, blen, last_len + 128);
+ GET_SPACE_RETC(sp, bp, blen, last_len + 128);
memmove(bp, p, last_len);
} else
matchprompt = 0;
/* Get something to execute. */
- if (db_eget(sp, lno, &p, &len, &isempty)) {
+ if (db_eget(sp, lno, &wp, &wlen, &isempty)) {
if (isempty)
goto empty;
goto err1;
}
/* Empty lines aren't interesting. */
- if (len == 0)
+ if (wlen == 0)
goto empty;
+ INT2CHAR(sp, wp, wlen, p, len);
/* Delete any prompt. */
if (sscr_matchprompt(sp, p, len, &tlen)) {
@@ -355,9 +353,10 @@ err2: if (nw == 0)
}
if (matchprompt) {
- ADD_SPACE_RET(sp, bp, blen, last_len + len);
+ ADD_SPACE_RETC(sp, bp, blen, last_len + len);
memmove(bp + last_len, p, len);
- if (db_set(sp, last_lno, bp, last_len + len))
+ CHAR2INT(sp, bp, last_len + len, wp, wlen);
+ if (db_set(sp, last_lno, wp, wlen))
err1: rval = 1;
}
if (matchprompt)
@@ -372,8 +371,7 @@ err1: rval = 1;
* PUBLIC: int sscr_input __P((SCR *));
*/
int
-sscr_input(sp)
- SCR *sp;
+sscr_input(SCR *sp)
{
GS *gp;
struct timeval poll;
@@ -388,7 +386,7 @@ loop: maxfd = 0;
poll.tv_usec = 0;
/* Set up the input mask. */
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ TAILQ_FOREACH(sp, gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
FD_SET(sp->script->sh_master, &rdfd);
if (sp->script->sh_master > maxfd)
@@ -407,9 +405,10 @@ loop: maxfd = 0;
}
/* Read the input. */
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ TAILQ_FOREACH(sp, gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT) &&
- FD_ISSET(sp->script->sh_master, &rdfd) && sscr_insert(sp))
+ FD_ISSET(sp->script->sh_master, &rdfd) &&
+ sscr_insert(sp))
return (1);
goto loop;
}
@@ -419,25 +418,29 @@ loop: maxfd = 0;
* Take a line from the shell and insert it into the file.
*/
static int
-sscr_insert(sp)
- SCR *sp;
+sscr_insert(SCR *sp)
{
+ EX_PRIVATE *exp;
struct timeval tv;
- CHAR_T *endp, *p, *t;
+ char *endp, *p, *t;
SCRIPT *sc;
fd_set rdfd;
recno_t lno;
size_t blen, len, tlen;
- u_int value;
int nr, rval;
char *bp;
+ CHAR_T *wp;
+ size_t wlen = 0;
+
+ exp = EXP(sp);
+
/* Find out where the end of the file is. */
if (db_last(sp, &lno))
return (1);
#define MINREAD 1024
- GET_SPACE_RET(sp, bp, blen, MINREAD);
+ GET_SPACE_RETC(sp, bp, blen, MINREAD);
endp = bp;
/* Read the characters. */
@@ -458,10 +461,11 @@ more: switch (nr = read(sc->sh_master, endp, MINREAD)) {
/* Append the lines into the file. */
for (p = t = bp; p < endp; ++p) {
- value = KEY_VAL(sp, *p);
- if (value == K_CR || value == K_NL) {
+ if (*p == '\r' || *p == '\n') {
len = p - t;
- if (db_append(sp, 1, lno++, t, len))
+ if (CHAR2INT5(sp, exp->ibcw, t, len, wp, wlen))
+ goto conv_err;
+ if (db_append(sp, 1, lno++, wp, wlen))
goto ret;
t = p + 1;
}
@@ -489,15 +493,20 @@ more: switch (nr = read(sc->sh_master, endp, MINREAD)) {
}
if (sscr_setprompt(sp, t, len))
return (1);
- if (db_append(sp, 1, lno++, t, len))
+ if (CHAR2INT5(sp, exp->ibcw, t, len, wp, wlen))
+ goto conv_err;
+ if (db_append(sp, 1, lno++, wp, wlen))
goto ret;
}
/* The cursor moves to EOF. */
sp->lno = lno;
- sp->cno = len ? len - 1 : 0;
+ sp->cno = wlen ? wlen - 1 : 0;
rval = vs_refresh(sp, 1);
+ if (0)
+conv_err: msgq(sp, M_ERR, "323|Invalid input. Truncated.");
+
ret: FREE_SPACE(sp, bp, blen);
return (rval);
}
@@ -509,10 +518,7 @@ ret: FREE_SPACE(sp, bp, blen);
*
*/
static int
-sscr_setprompt(sp, buf, len)
- SCR *sp;
- char *buf;
- size_t len;
+sscr_setprompt(SCR *sp, char *buf, size_t len)
{
SCRIPT *sc;
@@ -536,10 +542,7 @@ sscr_setprompt(sp, buf, len)
* parts that can change, in both content and size.
*/
static int
-sscr_matchprompt(sp, lp, line_len, lenp)
- SCR *sp;
- char *lp;
- size_t line_len, *lenp;
+sscr_matchprompt(SCR *sp, char *lp, size_t line_len, size_t *lenp)
{
SCRIPT *sc;
size_t prompt_len;
@@ -577,8 +580,7 @@ sscr_matchprompt(sp, lp, line_len, lenp)
* PUBLIC: int sscr_end __P((SCR *));
*/
int
-sscr_end(sp)
- SCR *sp;
+sscr_end(SCR *sp)
{
SCRIPT *sc;
@@ -611,188 +613,15 @@ sscr_end(sp)
* Set/clear the global scripting bit.
*/
static void
-sscr_check(sp)
- SCR *sp;
+sscr_check(SCR *sp)
{
GS *gp;
gp = sp->gp;
- for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
+ TAILQ_FOREACH(sp, gp->dq, q)
if (F_ISSET(sp, SC_SCRIPT)) {
F_SET(gp, G_SCRWIN);
return;
}
F_CLR(gp, G_SCRWIN);
}
-
-#ifdef HAVE_SYS5_PTY
-static int ptys_open __P((int, char *));
-static int ptym_open __P((char *));
-
-static int
-sscr_pty(amaster, aslave, name, termp, winp)
- int *amaster, *aslave;
- char *name;
- struct termios *termp;
- void *winp;
-{
- int master, slave, ttygid;
-
- /* open master terminal */
- if ((master = ptym_open(name)) < 0) {
- errno = ENOENT; /* out of ptys */
- return (-1);
- }
-
- /* open slave terminal */
- if ((slave = ptys_open(master, name)) >= 0) {
- *amaster = master;
- *aslave = slave;
- } else {
- errno = ENOENT; /* out of ptys */
- return (-1);
- }
-
- if (termp)
- (void) tcsetattr(slave, TCSAFLUSH, termp);
-#ifdef TIOCSWINSZ
- if (winp != NULL)
- (void) ioctl(slave, TIOCSWINSZ, (struct winsize *)winp);
-#endif
- return (0);
-}
-
-/*
- * ptym_open --
- * This function opens a master pty and returns the file descriptor
- * to it. pts_name is also returned which is the name of the slave.
- */
-static int
-ptym_open(pts_name)
- char *pts_name;
-{
- int fdm;
- char *ptr, *ptsname();
-
- strcpy(pts_name, _PATH_SYSV_PTY);
- if ((fdm = open(pts_name, O_RDWR)) < 0 )
- return (-1);
-
- if (grantpt(fdm) < 0) {
- close(fdm);
- return (-2);
- }
-
- if (unlockpt(fdm) < 0) {
- close(fdm);
- return (-3);
- }
-
- if (unlockpt(fdm) < 0) {
- close(fdm);
- return (-3);
- }
-
- /* get slave's name */
- if ((ptr = ptsname(fdm)) == NULL) {
- close(fdm);
- return (-3);
- }
- strcpy(pts_name, ptr);
- return (fdm);
-}
-
-/*
- * ptys_open --
- * This function opens the slave pty.
- */
-static int
-ptys_open(fdm, pts_name)
- int fdm;
- char *pts_name;
-{
- int fds;
-
- if ((fds = open(pts_name, O_RDWR)) < 0) {
- close(fdm);
- return (-5);
- }
-
- if (ioctl(fds, I_PUSH, "ptem") < 0) {
- close(fds);
- close(fdm);
- return (-6);
- }
-
- if (ioctl(fds, I_PUSH, "ldterm") < 0) {
- close(fds);
- close(fdm);
- return (-7);
- }
-
- if (ioctl(fds, I_PUSH, "ttcompat") < 0) {
- close(fds);
- close(fdm);
- return (-8);
- }
-
- return (fds);
-}
-
-#else /* !HAVE_SYS5_PTY */
-
-static int
-sscr_pty(amaster, aslave, name, termp, winp)
- int *amaster, *aslave;
- char *name;
- struct termios *termp;
- void *winp;
-{
- static char line[] = "/dev/ptyXX";
- register char *cp1, *cp2;
- register int master, slave, ttygid;
- struct group *gr;
-
- if ((gr = getgrnam("tty")) != NULL)
- ttygid = gr->gr_gid;
- else
- ttygid = -1;
-
- for (cp1 = "pqrs"; *cp1; cp1++) {
- line[8] = *cp1;
- for (cp2 = "0123456789abcdef"; *cp2; cp2++) {
- line[5] = 'p';
- line[9] = *cp2;
- if ((master = open(line, O_RDWR, 0)) == -1) {
- if (errno == ENOENT)
- return (-1); /* out of ptys */
- } else {
- line[5] = 't';
- (void) chown(line, getuid(), ttygid);
- (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
-#ifdef HAVE_REVOKE
- (void) revoke(line);
-#endif
- if ((slave = open(line, O_RDWR, 0)) != -1) {
- *amaster = master;
- *aslave = slave;
- if (name)
- strcpy(name, line);
- if (termp)
- (void) tcsetattr(slave,
- TCSAFLUSH, termp);
-#ifdef TIOCSWINSZ
- if (winp)
- (void) ioctl(slave, TIOCSWINSZ,
- (char *)winp);
-#endif
- return (0);
- }
- (void) close(master);
- }
- }
- }
- errno = ENOENT; /* out of ptys */
- return (-1);
-}
-#endif /* HAVE_SYS5_PTY */
diff --git a/ex/ex_set.c b/ex/ex_set.c
index 11e929764242..5134babff7f6 100644
--- a/ex/ex_set.c
+++ b/ex/ex_set.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_set.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_set.c,v 10.8 2001/06/25 15:19:19 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -29,9 +30,7 @@ static const char sccsid[] = "@(#)ex_set.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int ex_set __P((SCR *, EXCMD *));
*/
int
-ex_set(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_set(SCR *sp, EXCMD *cmdp)
{
switch(cmdp->argc) {
case 0:
diff --git a/ex/ex_shell.c b/ex/ex_shell.c
index 95168033a13f..d12730505968 100644
--- a/ex/ex_shell.c
+++ b/ex/ex_shell.c
@@ -10,14 +10,15 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_shell.c 10.38 (Berkeley) 8/19/96";
+static const char sccsid[] = "$Id: ex_shell.c,v 10.44 2012/07/06 06:51:26 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <sys/wait.h>
#include <bitstring.h>
+#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
@@ -38,12 +39,10 @@ static const char *sigmsg __P((int));
* PUBLIC: int ex_shell __P((SCR *, EXCMD *));
*/
int
-ex_shell(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_shell(SCR *sp, EXCMD *cmdp)
{
int rval;
- char buf[MAXPATHLEN];
+ char *buf;
/* We'll need a shell. */
if (opts_empty(sp, O_SHELL, 0))
@@ -53,13 +52,18 @@ ex_shell(sp, cmdp)
* XXX
* Assumes all shells use -i.
*/
- (void)snprintf(buf, sizeof(buf), "%s -i", O_STR(sp, O_SHELL));
+ (void)asprintf(&buf, "%s -i", O_STR(sp, O_SHELL));
+ if (buf == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return (1);
+ }
/* Restore the window name. */
(void)sp->gp->scr_rename(sp, NULL, 0);
/* If we're still in a vi screen, move out explicitly. */
rval = ex_exec_proc(sp, cmdp, buf, NULL, !F_ISSET(sp, SC_SCR_EXWROTE));
+ free(buf);
/* Set the window name. */
(void)sp->gp->scr_rename(sp, sp->frp->name, 1);
@@ -81,12 +85,7 @@ ex_shell(sp, cmdp)
* PUBLIC: int ex_exec_proc __P((SCR *, EXCMD *, char *, const char *, int));
*/
int
-ex_exec_proc(sp, cmdp, cmd, msg, need_newline)
- SCR *sp;
- EXCMD *cmdp;
- char *cmd;
- const char *msg;
- int need_newline;
+ex_exec_proc(SCR *sp, EXCMD *cmdp, char *cmd, const char *msg, int need_newline)
{
GS *gp;
const char *name;
@@ -101,7 +100,7 @@ ex_exec_proc(sp, cmdp, cmd, msg, need_newline)
/* Enter ex mode. */
if (F_ISSET(sp, SC_VI)) {
if (gp->scr_screen(sp, SC_EX)) {
- ex_emsg(sp, cmdp->cmd->name, EXM_NOCANON);
+ ex_wemsg(sp, cmdp->cmd->name, EXM_NOCANON);
return (1);
}
(void)gp->scr_attr(sp, SA_ALTERNATE, 0);
@@ -122,11 +121,13 @@ ex_exec_proc(sp, cmdp, cmd, msg, need_newline)
msgq(sp, M_SYSERR, "vfork");
return (1);
case 0: /* Utility. */
+ if (gp->scr_child)
+ gp->scr_child(sp);
if ((name = strrchr(O_STR(sp, O_SHELL), '/')) == NULL)
name = O_STR(sp, O_SHELL);
else
++name;
- execl(O_STR(sp, O_SHELL), name, "-c", cmd, NULL);
+ execl(O_STR(sp, O_SHELL), name, "-c", cmd, (char *)NULL);
msgq_str(sp, M_SYSERR, O_STR(sp, O_SHELL), "execl: %s");
_exit(127);
/* NOTREACHED */
@@ -149,11 +150,7 @@ ex_exec_proc(sp, cmdp, cmd, msg, need_newline)
* PUBLIC: int proc_wait __P((SCR *, long, const char *, int, int));
*/
int
-proc_wait(sp, pid, cmd, silent, okpipe)
- SCR *sp;
- long pid;
- const char *cmd;
- int silent, okpipe;
+proc_wait(SCR *sp, long int pid, const char *cmd, int silent, int okpipe)
{
size_t len;
int nf, pstat;
@@ -176,11 +173,11 @@ proc_wait(sp, pid, cmd, silent, okpipe)
* exit before reading all of its input.
*/
if (WIFSIGNALED(pstat) && (!okpipe || WTERMSIG(pstat) != SIGPIPE)) {
- for (; isblank(*cmd); ++cmd);
+ for (; cmdskip(*cmd); ++cmd);
p = msg_print(sp, cmd, &nf);
len = strlen(p);
msgq(sp, M_ERR, "%.*s%s: received signal: %s%s",
- MIN(len, 20), p, len > 20 ? " ..." : "",
+ (int)MIN(len, 20), p, len > 20 ? " ..." : "",
sigmsg(WTERMSIG(pstat)),
WCOREDUMP(pstat) ? "; core dumped" : "");
if (nf)
@@ -198,11 +195,11 @@ proc_wait(sp, pid, cmd, silent, okpipe)
* practice.
*/
if (!silent) {
- for (; isblank(*cmd); ++cmd);
+ for (; cmdskip(*cmd); ++cmd);
p = msg_print(sp, cmd, &nf);
len = strlen(p);
msgq(sp, M_ERR, "%.*s%s: exited with status %d",
- MIN(len, 20), p, len > 20 ? " ..." : "",
+ (int)MIN(len, 20), p, len > 20 ? " ..." : "",
WEXITSTATUS(pstat));
if (nf)
FREE_SPACE(sp, p, 0);
@@ -213,166 +210,18 @@ proc_wait(sp, pid, cmd, silent, okpipe)
}
/*
- * XXX
- * The sys_siglist[] table in the C library has this information, but there's
- * no portable way to get to it. (Believe me, I tried.)
- */
-typedef struct _sigs {
- int number; /* signal number */
- char *message; /* related message */
-} SIGS;
-
-SIGS const sigs[] = {
-#ifdef SIGABRT
- SIGABRT, "Abort trap",
-#endif
-#ifdef SIGALRM
- SIGALRM, "Alarm clock",
-#endif
-#ifdef SIGBUS
- SIGBUS, "Bus error",
-#endif
-#ifdef SIGCLD
- SIGCLD, "Child exited or stopped",
-#endif
-#ifdef SIGCHLD
- SIGCHLD, "Child exited",
-#endif
-#ifdef SIGCONT
- SIGCONT, "Continued",
-#endif
-#ifdef SIGDANGER
- SIGDANGER, "System crash imminent",
-#endif
-#ifdef SIGEMT
- SIGEMT, "EMT trap",
-#endif
-#ifdef SIGFPE
- SIGFPE, "Floating point exception",
-#endif
-#ifdef SIGGRANT
- SIGGRANT, "HFT monitor mode granted",
-#endif
-#ifdef SIGHUP
- SIGHUP, "Hangup",
-#endif
-#ifdef SIGILL
- SIGILL, "Illegal instruction",
-#endif
-#ifdef SIGINFO
- SIGINFO, "Information request",
-#endif
-#ifdef SIGINT
- SIGINT, "Interrupt",
-#endif
-#ifdef SIGIO
- SIGIO, "I/O possible",
-#endif
-#ifdef SIGIOT
- SIGIOT, "IOT trap",
-#endif
-#ifdef SIGKILL
- SIGKILL, "Killed",
-#endif
-#ifdef SIGLOST
- SIGLOST, "Record lock",
-#endif
-#ifdef SIGMIGRATE
- SIGMIGRATE, "Migrate process to another CPU",
-#endif
-#ifdef SIGMSG
- SIGMSG, "HFT input data pending",
-#endif
-#ifdef SIGPIPE
- SIGPIPE, "Broken pipe",
-#endif
-#ifdef SIGPOLL
- SIGPOLL, "I/O possible",
-#endif
-#ifdef SIGPRE
- SIGPRE, "Programming error",
-#endif
-#ifdef SIGPROF
- SIGPROF, "Profiling timer expired",
-#endif
-#ifdef SIGPWR
- SIGPWR, "Power failure imminent",
-#endif
-#ifdef SIGRETRACT
- SIGRETRACT, "HFT monitor mode retracted",
-#endif
-#ifdef SIGQUIT
- SIGQUIT, "Quit",
-#endif
-#ifdef SIGSAK
- SIGSAK, "Secure Attention Key",
-#endif
-#ifdef SIGSEGV
- SIGSEGV, "Segmentation fault",
-#endif
-#ifdef SIGSOUND
- SIGSOUND, "HFT sound sequence completed",
-#endif
-#ifdef SIGSTOP
- SIGSTOP, "Suspended (signal)",
-#endif
-#ifdef SIGSYS
- SIGSYS, "Bad system call",
-#endif
-#ifdef SIGTERM
- SIGTERM, "Terminated",
-#endif
-#ifdef SIGTRAP
- SIGTRAP, "Trace/BPT trap",
-#endif
-#ifdef SIGTSTP
- SIGTSTP, "Suspended",
-#endif
-#ifdef SIGTTIN
- SIGTTIN, "Stopped (tty input)",
-#endif
-#ifdef SIGTTOU
- SIGTTOU, "Stopped (tty output)",
-#endif
-#ifdef SIGURG
- SIGURG, "Urgent I/O condition",
-#endif
-#ifdef SIGUSR1
- SIGUSR1, "User defined signal 1",
-#endif
-#ifdef SIGUSR2
- SIGUSR2, "User defined signal 2",
-#endif
-#ifdef SIGVTALRM
- SIGVTALRM, "Virtual timer expired",
-#endif
-#ifdef SIGWINCH
- SIGWINCH, "Window size changes",
-#endif
-#ifdef SIGXCPU
- SIGXCPU, "Cputime limit exceeded",
-#endif
-#ifdef SIGXFSZ
- SIGXFSZ, "Filesize limit exceeded",
-#endif
-};
-
-/*
* sigmsg --
* Return a pointer to a message describing a signal.
*/
static const char *
-sigmsg(signo)
- int signo;
+sigmsg(int signo)
{
static char buf[40];
- const SIGS *sigp;
- int n;
+ char *message;
- for (n = 0,
- sigp = &sigs[0]; n < sizeof(sigs) / sizeof(sigs[0]); ++n, ++sigp)
- if (sigp->number == signo)
- return (sigp->message);
+ /* POSIX.1-2008 leaves strsignal(3)'s return value unspecified. */
+ if ((message = strsignal(signo)) != NULL)
+ return message;
(void)snprintf(buf, sizeof(buf), "Unknown signal: %d", signo);
return (buf);
}
diff --git a/ex/ex_shift.c b/ex/ex_shift.c
index 83bd36d12a7d..cc6e1aac4b4b 100644
--- a/ex/ex_shift.c
+++ b/ex/ex_shift.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_shift.c 10.11 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: ex_shift.c,v 10.17 2001/06/25 15:19:20 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -34,9 +35,7 @@ static int shift __P((SCR *, EXCMD *, enum which));
* PUBLIC: int ex_shiftl __P((SCR *, EXCMD *));
*/
int
-ex_shiftl(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_shiftl(SCR *sp, EXCMD *cmdp)
{
return (shift(sp, cmdp, LEFT));
}
@@ -47,9 +46,7 @@ ex_shiftl(sp, cmdp)
* PUBLIC: int ex_shiftr __P((SCR *, EXCMD *));
*/
int
-ex_shiftr(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_shiftr(SCR *sp, EXCMD *cmdp)
{
return (shift(sp, cmdp, RIGHT));
}
@@ -59,15 +56,13 @@ ex_shiftr(sp, cmdp)
* Ex shift support.
*/
static int
-shift(sp, cmdp, rl)
- SCR *sp;
- EXCMD *cmdp;
- enum which rl;
+shift(SCR *sp, EXCMD *cmdp, enum which rl)
{
recno_t from, to;
size_t blen, len, newcol, newidx, oldcol, oldidx, sw;
int curset;
- char *p, *bp, *tbp;
+ CHAR_T *p;
+ CHAR_T *bp, *tbp;
NEEDFILE(sp, cmdp);
@@ -93,7 +88,7 @@ shift(sp, cmdp, rl)
for (p = cmdp->argv[0]->bp, sw = 0; *p == '>' || *p == '<'; ++p)
sw += O_VAL(sp, O_SHIFTWIDTH);
- GET_SPACE_RET(sp, bp, blen, 256);
+ GET_SPACE_RETW(sp, bp, blen, 256);
curset = 0;
for (from = cmdp->addr1.lno, to = cmdp->addr2.lno; from <= to; ++from) {
@@ -131,7 +126,7 @@ shift(sp, cmdp, rl)
}
/* Get a buffer that will hold the new line. */
- ADD_SPACE_RET(sp, bp, blen, newcol + len);
+ ADD_SPACE_RETW(sp, bp, blen, newcol + len);
/*
* Build a new indent string and count the number of
@@ -146,11 +141,11 @@ shift(sp, cmdp, rl)
*tbp++ = ' ';
/* Add the original line. */
- memcpy(tbp, p + oldidx, len - oldidx);
+ MEMCPY(tbp, p + oldidx, len - oldidx);
/* Set the replacement line. */
if (db_set(sp, from, bp, (tbp + (len - oldidx)) - bp)) {
-err: FREE_SPACE(sp, bp, blen);
+err: FREE_SPACEW(sp, bp, blen);
return (1);
}
@@ -184,7 +179,7 @@ err: FREE_SPACE(sp, bp, blen);
(void)nonblank(sp, to, &sp->cno);
}
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
sp->rptlines[L_SHIFT] += cmdp->addr2.lno - cmdp->addr1.lno + 1;
return (0);
diff --git a/ex/ex_source.c b/ex/ex_source.c
index b52c527716fd..63375d2b7ee2 100644
--- a/ex/ex_source.c
+++ b/ex/ex_source.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_source.c 10.12 (Berkeley) 8/10/96";
+static const char sccsid[] = "$Id: ex_source.c,v 10.17 2011/12/19 16:17:06 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -35,15 +35,18 @@ static const char sccsid[] = "@(#)ex_source.c 10.12 (Berkeley) 8/10/96";
* PUBLIC: int ex_source __P((SCR *, EXCMD *));
*/
int
-ex_source(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_source(SCR *sp, EXCMD *cmdp)
{
struct stat sb;
int fd, len;
- char *bp, *name;
+ char *bp;
+ char *name, *np;
+ size_t nlen;
+ CHAR_T *wp;
+ size_t wlen;
+ int rc;
- name = cmdp->argv[0]->bp;
+ INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, name, nlen);
if ((fd = open(name, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
goto err;
@@ -80,6 +83,13 @@ err: msgq_str(sp, M_SYSERR, name, "%s");
return (1);
}
+ np = strdup(name);
+ if (CHAR2INT(sp, bp, (size_t)sb.st_size + 1, wp, wlen))
+ msgq(sp, M_ERR, "323|Invalid input. Truncated.");
/* Put it on the ex queue. */
- return (ex_run_str(sp, name, bp, (size_t)sb.st_size, 1, 1));
+ rc = ex_run_str(sp, np, wp, wlen - 1, 1, 0);
+ if (np != NULL)
+ free(np);
+ free(bp);
+ return (rc);
}
diff --git a/ex/ex_stop.c b/ex/ex_stop.c
index bc55fd24ccb7..79167896b1cf 100644
--- a/ex/ex_stop.c
+++ b/ex/ex_stop.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_stop.c 10.10 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_stop.c,v 10.11 2001/06/25 15:19:20 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <errno.h>
@@ -33,9 +34,7 @@ static const char sccsid[] = "@(#)ex_stop.c 10.10 (Berkeley) 3/6/96";
* PUBLIC: int ex_stop __P((SCR *, EXCMD *));
*/
int
-ex_stop(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_stop(SCR *sp, EXCMD *cmdp)
{
int allowed;
diff --git a/ex/ex_subst.c b/ex/ex_subst.c
index 0ebb81dd58e7..93398431ca70 100644
--- a/ex/ex_subst.c
+++ b/ex/ex_subst.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_subst.c 10.37 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: ex_subst.c,v 10.53 2011/12/21 20:40:35 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -32,12 +32,12 @@ static const char sccsid[] = "@(#)ex_subst.c 10.37 (Berkeley) 9/15/96";
#define SUB_FIRST 0x01 /* The 'r' flag isn't reasonable. */
#define SUB_MUSTSETR 0x02 /* The 'r' flag is required. */
-static int re_conv __P((SCR *, char **, size_t *, int *));
-static int re_cscope_conv __P((SCR *, char **, size_t *, int *));
+static int re_conv __P((SCR *, CHAR_T **, size_t *, int *));
+static int re_cscope_conv __P((SCR *, CHAR_T **, size_t *, int *));
static int re_sub __P((SCR *,
- char *, char **, size_t *, size_t *, regmatch_t [10]));
-static int re_tag_conv __P((SCR *, char **, size_t *, int *));
-static int s __P((SCR *, EXCMD *, char *, regex_t *, u_int));
+ CHAR_T *, CHAR_T **, size_t *, size_t *, regmatch_t [10]));
+static int re_tag_conv __P((SCR *, CHAR_T **, size_t *, int *));
+static int s __P((SCR *, EXCMD *, CHAR_T *, regex_t *, u_int));
/*
* ex_s --
@@ -48,15 +48,13 @@ static int s __P((SCR *, EXCMD *, char *, regex_t *, u_int));
* PUBLIC: int ex_s __P((SCR *, EXCMD *));
*/
int
-ex_s(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_s(SCR *sp, EXCMD *cmdp)
{
regex_t *re;
size_t blen, len;
u_int flags;
int delim;
- char *bp, *ptrn, *rep, *p, *t;
+ CHAR_T *bp, *p, *ptrn, *rep, *t;
/*
* Skip leading white space.
@@ -73,14 +71,14 @@ ex_s(sp, cmdp)
goto subagain;
for (p = cmdp->argv[0]->bp,
len = cmdp->argv[0]->len; len > 0; --len, ++p) {
- if (!isblank(*p))
+ if (!cmdskip(*p))
break;
}
if (len == 0)
subagain: return (ex_subagain(sp, cmdp));
delim = *p++;
- if (isalnum(delim) || delim == '\\')
+ if (!isascii(delim) || isalnum(delim) || delim == '\\')
return (s(sp, cmdp, p, &sp->subre_c, SUB_MUSTSETR));
/*
@@ -140,8 +138,9 @@ subagain: return (ex_subagain(sp, cmdp));
}
/* Re-compile the RE if necessary. */
- if (!F_ISSET(sp, SC_RE_SEARCH) && re_compile(sp,
- sp->re, sp->re_len, NULL, NULL, &sp->re_c, RE_C_SEARCH))
+ if (!F_ISSET(sp, SC_RE_SEARCH) &&
+ re_compile(sp, sp->re, sp->re_len,
+ NULL, NULL, &sp->re_c, RE_C_SEARCH))
return (1);
flags = 0;
} else {
@@ -152,11 +151,11 @@ subagain: return (ex_subagain(sp, cmdp));
* RE's. We compile the RE twice, as we don't want to bother
* ref counting the pattern string and (opaque) structure.
*/
- if (re_compile(sp, ptrn, t - ptrn,
- &sp->re, &sp->re_len, &sp->re_c, RE_C_SEARCH))
+ if (re_compile(sp, ptrn, t - ptrn, &sp->re,
+ &sp->re_len, &sp->re_c, RE_C_SEARCH))
return (1);
- if (re_compile(sp, ptrn, t - ptrn,
- &sp->subre, &sp->subre_len, &sp->subre_c, RE_C_SUBST))
+ if (re_compile(sp, ptrn, t - ptrn, &sp->subre,
+ &sp->subre_len, &sp->subre_c, RE_C_SUBST))
return (1);
flags = SUB_FIRST;
@@ -202,7 +201,7 @@ subagain: return (ex_subagain(sp, cmdp));
p[0] != '\0' && p[0] != delim; ++p, ++len)
if (p[0] == '~')
len += sp->repl_len;
- GET_SPACE_RET(sp, bp, blen, len);
+ GET_SPACE_RETW(sp, bp, blen, len);
for (t = bp, len = 0, p = rep;;) {
if (p[0] == '\0' || p[0] == delim) {
if (p[0] == delim)
@@ -222,7 +221,7 @@ subagain: return (ex_subagain(sp, cmdp));
}
} else if (p[0] == '~' && O_ISSET(sp, O_MAGIC)) {
tilde: ++p;
- memcpy(t, sp->repl, sp->repl_len);
+ MEMCPY(t, sp->repl, sp->repl_len);
t += sp->repl_len;
len += sp->repl_len;
continue;
@@ -233,14 +232,14 @@ tilde: ++p;
if ((sp->repl_len = len) != 0) {
if (sp->repl != NULL)
free(sp->repl);
- if ((sp->repl = malloc(len)) == NULL) {
- msgq(sp, M_SYSERR, NULL);
- FREE_SPACE(sp, bp, blen);
+ MALLOC(sp, sp->repl, CHAR_T *, len * sizeof(CHAR_T));
+ if (sp->repl == NULL) {
+ FREE_SPACEW(sp, bp, blen);
return (1);
}
- memcpy(sp->repl, bp, len);
+ MEMCPY(sp->repl, bp, len);
}
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
}
return (s(sp, cmdp, p, re, flags));
}
@@ -254,16 +253,15 @@ tilde: ++p;
* PUBLIC: int ex_subagain __P((SCR *, EXCMD *));
*/
int
-ex_subagain(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_subagain(SCR *sp, EXCMD *cmdp)
{
if (sp->subre == NULL) {
ex_emsg(sp, NULL, EXM_NOPREVRE);
return (1);
}
- if (!F_ISSET(sp, SC_RE_SUBST) && re_compile(sp,
- sp->subre, sp->subre_len, NULL, NULL, &sp->subre_c, RE_C_SUBST))
+ if (!F_ISSET(sp, SC_RE_SUBST) &&
+ re_compile(sp, sp->subre, sp->subre_len,
+ NULL, NULL, &sp->subre_c, RE_C_SUBST))
return (1);
return (s(sp,
cmdp, cmdp->argc ? cmdp->argv[0]->bp : NULL, &sp->subre_c, 0));
@@ -278,16 +276,14 @@ ex_subagain(sp, cmdp)
* PUBLIC: int ex_subtilde __P((SCR *, EXCMD *));
*/
int
-ex_subtilde(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_subtilde(SCR *sp, EXCMD *cmdp)
{
if (sp->re == NULL) {
ex_emsg(sp, NULL, EXM_NOPREVRE);
return (1);
}
- if (!F_ISSET(sp, SC_RE_SEARCH) && re_compile(sp,
- sp->re, sp->re_len, NULL, NULL, &sp->re_c, RE_C_SEARCH))
+ if (!F_ISSET(sp, SC_RE_SEARCH) && re_compile(sp, sp->re,
+ sp->re_len, NULL, NULL, &sp->re_c, RE_C_SEARCH))
return (1);
return (s(sp,
cmdp, cmdp->argc ? cmdp->argv[0]->bp : NULL, &sp->re_c, 0));
@@ -320,21 +316,21 @@ ex_subtilde(sp, cmdp)
#define BUILD(sp, l, len) { \
if (lbclen + (len) > lblen) { \
- lblen += MAX(lbclen + (len), 256); \
- REALLOC(sp, lb, char *, lblen); \
+ lblen = p2roundup(MAX(lbclen + (len), 256)); \
+ REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T)); \
if (lb == NULL) { \
lbclen = 0; \
return (1); \
} \
} \
- memcpy(lb + lbclen, l, len); \
+ MEMCPY(lb + lbclen, l, len); \
lbclen += len; \
}
#define NEEDSP(sp, len, pnt) { \
if (lbclen + (len) > lblen) { \
- lblen += MAX(lbclen + (len), 256); \
- REALLOC(sp, lb, char *, lblen); \
+ lblen = p2roundup(MAX(lbclen + (len), 256)); \
+ REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T)); \
if (lb == NULL) { \
lbclen = 0; \
return (1); \
@@ -344,24 +340,21 @@ ex_subtilde(sp, cmdp)
}
static int
-s(sp, cmdp, s, re, flags)
- SCR *sp;
- EXCMD *cmdp;
- char *s;
- regex_t *re;
- u_int flags;
+s(SCR *sp, EXCMD *cmdp, CHAR_T *s, regex_t *re, u_int flags)
{
EVENT ev;
MARK from, to;
- TEXTH tiq;
+ TEXTH tiq[] = {{ 0 }};
recno_t elno, lno, slno;
+ u_long ul;
regmatch_t match[10];
size_t blen, cnt, last, lbclen, lblen, len, llen;
size_t offset, saved_offset, scno;
int cflag, lflag, nflag, pflag, rflag;
int didsub, do_eol_match, eflags, empty_ok, eval;
int linechanged, matched, quit, rval;
- char *bp, *lb;
+ CHAR_T *bp, *lb;
+ enum nresult nret;
NEEDFILE(sp, cmdp);
@@ -414,13 +407,14 @@ s(sp, cmdp, s, re, flags)
if (lno != OOBLNO)
goto usage;
errno = 0;
- lno = strtoul(s, &s, 10);
+ nret = nget_uslong(&ul, s, &s, 10);
+ lno = ul;
if (*s == '\0') /* Loop increment correction. */
--s;
- if (errno == ERANGE) {
- if (lno == LONG_MAX)
+ if (nret != NUM_OK) {
+ if (nret == NUM_OVER)
msgq(sp, M_ERR, "153|Count overflow");
- else if (lno == LONG_MIN)
+ else if (nret == NUM_UNDER)
msgq(sp, M_ERR, "154|Count underflow");
else
msgq(sp, M_SYSERR, NULL);
@@ -443,10 +437,8 @@ s(sp, cmdp, s, re, flags)
sp->c_suffix = !sp->c_suffix;
/* Ex text structure initialization. */
- if (F_ISSET(sp, SC_EX)) {
- memset(&tiq, 0, sizeof(TEXTH));
- CIRCLEQ_INIT(&tiq);
- }
+ if (F_ISSET(sp, SC_EX))
+ TAILQ_INIT(tiq);
break;
case 'g':
sp->g_suffix = !sp->g_suffix;
@@ -474,7 +466,7 @@ s(sp, cmdp, s, re, flags)
goto usage;
}
- if (*s != '\0' || !rflag && LF_ISSET(SUB_MUSTSETR)) {
+ if (*s != '\0' || (!rflag && LF_ISSET(SUB_MUSTSETR))) {
usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
return (1);
}
@@ -496,7 +488,8 @@ noargs: if (F_ISSET(sp, SC_VI) && sp->c_suffix && (lflag || nflag || pflag)) {
blen = lbclen = lblen = 0;
/* For each line... */
- for (matched = quit = 0, lno = cmdp->addr1.lno,
+ lno = cmdp->addr1.lno == 0 ? 1 : cmdp->addr1.lno;
+ for (matched = quit = 0,
elno = cmdp->addr2.lno; !quit && lno <= elno; ++lno) {
/* Someone's unhappy, time to stop. */
@@ -513,10 +506,10 @@ noargs: if (F_ISSET(sp, SC_VI) && sp->c_suffix && (lflag || nflag || pflag)) {
*/
if (sp->c_suffix) {
if (bp == NULL) {
- GET_SPACE_RET(sp, bp, blen, llen);
+ GET_SPACE_RETW(sp, bp, blen, llen);
} else
- ADD_SPACE_RET(sp, bp, blen, llen);
- memcpy(bp, s, llen);
+ ADD_SPACE_RETW(sp, bp, blen, llen);
+ MEMCPY(bp, s, llen);
s = bp;
}
@@ -555,7 +548,7 @@ nextmatch: match[0].rm_so = 0;
match[0].rm_eo = len;
/* Get the next match. */
- eval = regexec(re, (char *)s + offset, 10, match, eflags);
+ eval = regexec(re, s + offset, 10, match, eflags);
/*
* There wasn't a match or if there was an error, deal with
@@ -658,9 +651,9 @@ nextmatch: match[0].rm_so = 0;
if (ex_print(sp, cmdp, &from, &to, 0) ||
ex_scprint(sp, &from, &to))
goto lquit;
- if (ex_txt(sp, &tiq, 0, TXT_CR))
+ if (ex_txt(sp, tiq, 0, TXT_CR))
goto err;
- ev.e_c = tiq.cqh_first->lb[0];
+ ev.e_c = TAILQ_FIRST(tiq)->lb[0];
}
switch (ev.e_c) {
@@ -749,8 +742,8 @@ skip: offset += match[0].rm_eo;
goto err;
if (db_get(sp, lno, DBG_FATAL, &s, &llen))
goto err;
- ADD_SPACE_RET(sp, bp, blen, llen)
- memcpy(bp, s, llen);
+ ADD_SPACE_RETW(sp, bp, blen, llen)
+ MEMCPY(bp, s, llen);
s = bp;
len = llen - offset;
@@ -876,7 +869,7 @@ err: rval = 1;
}
if (bp != NULL)
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
if (lb != NULL)
free(lb);
return (rval);
@@ -887,19 +880,14 @@ err: rval = 1;
* Compile the RE.
*
* PUBLIC: int re_compile __P((SCR *,
- * PUBLIC: char *, size_t, char **, size_t *, regex_t *, u_int));
+ * PUBLIC: CHAR_T *, size_t, CHAR_T **, size_t *, regex_t *, u_int));
*/
int
-re_compile(sp, ptrn, plen, ptrnp, lenp, rep, flags)
- SCR *sp;
- char *ptrn, **ptrnp;
- size_t plen, *lenp;
- regex_t *rep;
- u_int flags;
+re_compile(SCR *sp, CHAR_T *ptrn, size_t plen, CHAR_T **ptrnp, size_t *lenp, regex_t *rep, u_int flags)
{
size_t len;
int reflags, replaced, rval;
- char *p;
+ CHAR_T *p;
/* Set RE flags. */
reflags = 0;
@@ -910,7 +898,7 @@ re_compile(sp, ptrn, plen, ptrnp, lenp, rep, flags)
reflags |= REG_ICASE;
if (O_ISSET(sp, O_ICLOWER)) {
for (p = ptrn, len = plen; len > 0; ++p, --len)
- if (isupper(*p))
+ if (ISUPPER(*p))
break;
if (len == 0)
reflags |= REG_ICASE;
@@ -933,6 +921,7 @@ re_compile(sp, ptrn, plen, ptrnp, lenp, rep, flags)
* later recompilation. Free any previously saved value.
*/
if (ptrnp != NULL) {
+ replaced = 0;
if (LF_ISSET(RE_C_CSCOPE)) {
if (re_cscope_conv(sp, &ptrn, &plen, &replaced))
return (1);
@@ -965,15 +954,15 @@ re_compile(sp, ptrn, plen, ptrnp, lenp, rep, flags)
* Regcomp isn't 8-bit clean, so the pattern is nul-terminated
* for now. There's just no other solution.
*/
- MALLOC(sp, *ptrnp, char *, plen + 1);
+ MALLOC(sp, *ptrnp, CHAR_T *, (plen + 1) * sizeof(CHAR_T));
if (*ptrnp != NULL) {
- memcpy(*ptrnp, ptrn, plen);
+ MEMCPY(*ptrnp, ptrn, plen);
(*ptrnp)[plen] = '\0';
}
/* Free up conversion-routine-allocated memory. */
if (replaced)
- FREE_SPACE(sp, ptrn, 0);
+ FREE_SPACEW(sp, ptrn, 0);
if (*ptrnp == NULL)
return (1);
@@ -1023,15 +1012,11 @@ re_compile(sp, ptrn, plen, ptrnp, lenp, rep, flags)
* weren't historically. It's a bug.
*/
static int
-re_conv(sp, ptrnp, plenp, replacedp)
- SCR *sp;
- char **ptrnp;
- size_t *plenp;
- int *replacedp;
+re_conv(SCR *sp, CHAR_T **ptrnp, size_t *plenp, int *replacedp)
{
size_t blen, len, needlen;
int magic;
- char *bp, *p, *t;
+ CHAR_T *bp, *p, *t;
/*
* First pass through, we figure out how much space we'll need.
@@ -1048,11 +1033,11 @@ re_conv(sp, ptrnp, plenp, replacedp)
switch (*++p) {
case '<':
magic = 1;
- needlen += sizeof(RE_WSTART);
+ needlen += RE_WSTART_LEN + 1;
break;
case '>':
magic = 1;
- needlen += sizeof(RE_WSTOP);
+ needlen += RE_WSTOP_LEN + 1;
break;
case '~':
if (!O_ISSET(sp, O_MAGIC)) {
@@ -1100,7 +1085,7 @@ re_conv(sp, ptrnp, plenp, replacedp)
/* Get enough memory to hold the final pattern. */
*replacedp = 1;
- GET_SPACE_RET(sp, bp, blen, needlen);
+ GET_SPACE_RETW(sp, bp, blen, needlen);
for (p = *ptrnp, len = *plenp, t = bp; len > 0; ++p, --len)
switch (*p) {
@@ -1109,20 +1094,20 @@ re_conv(sp, ptrnp, plenp, replacedp)
--len;
switch (*++p) {
case '<':
- memcpy(t,
- RE_WSTART, sizeof(RE_WSTART) - 1);
- t += sizeof(RE_WSTART) - 1;
+ MEMCPY(t,
+ RE_WSTART, RE_WSTART_LEN);
+ t += RE_WSTART_LEN;
break;
case '>':
- memcpy(t,
- RE_WSTOP, sizeof(RE_WSTOP) - 1);
- t += sizeof(RE_WSTOP) - 1;
+ MEMCPY(t,
+ RE_WSTOP, RE_WSTOP_LEN);
+ t += RE_WSTOP_LEN;
break;
case '~':
if (O_ISSET(sp, O_MAGIC))
*t++ = '~';
else {
- memcpy(t,
+ MEMCPY(t,
sp->repl, sp->repl_len);
t += sp->repl_len;
}
@@ -1143,7 +1128,7 @@ re_conv(sp, ptrnp, plenp, replacedp)
break;
case '~':
if (O_ISSET(sp, O_MAGIC)) {
- memcpy(t, sp->repl, sp->repl_len);
+ MEMCPY(t, sp->repl, sp->repl_len);
t += sp->repl_len;
} else
*t++ = '~';
@@ -1171,21 +1156,17 @@ re_conv(sp, ptrnp, plenp, replacedp)
* 1003.2 RE functions can handle.
*/
static int
-re_tag_conv(sp, ptrnp, plenp, replacedp)
- SCR *sp;
- char **ptrnp;
- size_t *plenp;
- int *replacedp;
+re_tag_conv(SCR *sp, CHAR_T **ptrnp, size_t *plenp, int *replacedp)
{
size_t blen, len;
int lastdollar;
- char *bp, *p, *t;
+ CHAR_T *bp, *p, *t;
len = *plenp;
/* Max memory usage is 2 times the length of the string. */
*replacedp = 1;
- GET_SPACE_RET(sp, bp, blen, len * 2);
+ GET_SPACE_RETW(sp, bp, blen, len * 2);
p = *ptrnp;
t = bp;
@@ -1222,7 +1203,7 @@ re_tag_conv(sp, ptrnp, plenp, replacedp)
if (p[0] == '\\' && (p[1] == '/' || p[1] == '?')) {
++p;
--len;
- } else if (strchr("^.[]$*", p[0]))
+ } else if (STRCHR(L("^.[]$*"), p[0]))
*t++ = '\\';
*t++ = *p++;
}
@@ -1240,20 +1221,21 @@ re_tag_conv(sp, ptrnp, plenp, replacedp)
* 1003.2 RE functions can handle.
*/
static int
-re_cscope_conv(sp, ptrnp, plenp, replacedp)
- SCR *sp;
- char **ptrnp;
- size_t *plenp;
- int *replacedp;
+re_cscope_conv(SCR *sp, CHAR_T **ptrnp, size_t *plenp, int *replacedp)
{
size_t blen, len, nspaces;
- char *bp, *p, *t;
+ CHAR_T *bp, *t;
+ CHAR_T *p;
+ CHAR_T *wp;
+ size_t wlen;
/*
* Each space in the source line printed by cscope represents an
* arbitrary sequence of spaces, tabs, and comments.
*/
#define CSCOPE_RE_SPACE "([ \t]|/\\*([^*]|\\*/)*\\*/)*"
+#define CSCOPE_LEN sizeof(CSCOPE_RE_SPACE) - 1
+ CHAR2INT(sp, CSCOPE_RE_SPACE, CSCOPE_LEN, wp, wlen);
for (nspaces = 0, p = *ptrnp, len = *plenp; len > 0; ++p, --len)
if (*p == ' ')
++nspaces;
@@ -1266,27 +1248,27 @@ re_cscope_conv(sp, ptrnp, plenp, replacedp)
*/
*replacedp = 1;
len = (p - *ptrnp) * 2 + (nspaces + 2) * sizeof(CSCOPE_RE_SPACE) + 3;
- GET_SPACE_RET(sp, bp, blen, len);
+ GET_SPACE_RETW(sp, bp, blen, len);
p = *ptrnp;
t = bp;
*t++ = '^';
- memcpy(t, CSCOPE_RE_SPACE, sizeof(CSCOPE_RE_SPACE) - 1);
- t += sizeof(CSCOPE_RE_SPACE) - 1;
+ MEMCPY(t, wp, wlen);
+ t += wlen;
for (len = *plenp; len > 0; ++p, --len)
if (*p == ' ') {
- memcpy(t, CSCOPE_RE_SPACE, sizeof(CSCOPE_RE_SPACE) - 1);
- t += sizeof(CSCOPE_RE_SPACE) - 1;
+ MEMCPY(t, wp, wlen);
+ t += wlen;
} else {
- if (strchr("\\^.[]$*+?()|{}", *p))
+ if (STRCHR(L("\\^.[]$*+?()|{}"), *p))
*t++ = '\\';
*t++ = *p;
}
- memcpy(t, CSCOPE_RE_SPACE, sizeof(CSCOPE_RE_SPACE) - 1);
- t += sizeof(CSCOPE_RE_SPACE) - 1;
+ MEMCPY(t, wp, wlen);
+ t += wlen;
*t++ = '$';
*ptrnp = bp;
@@ -1301,18 +1283,14 @@ re_cscope_conv(sp, ptrnp, plenp, replacedp)
* PUBLIC: void re_error __P((SCR *, int, regex_t *));
*/
void
-re_error(sp, errcode, preg)
- SCR *sp;
- int errcode;
- regex_t *preg;
+re_error(SCR *sp, int errcode, regex_t *preg)
{
size_t s;
char *oe;
s = regerror(errcode, preg, "", 0);
- if ((oe = malloc(s)) == NULL)
- msgq(sp, M_SYSERR, NULL);
- else {
+ MALLOC(sp, oe, char *, s);
+ if (oe != NULL) {
(void)regerror(errcode, preg, oe, s);
msgq(sp, M_ERR, "RE error: %s", oe);
free(oe);
@@ -1324,22 +1302,23 @@ re_error(sp, errcode, preg)
* Do the substitution for a regular expression.
*/
static int
-re_sub(sp, ip, lbp, lbclenp, lblenp, match)
- SCR *sp;
- char *ip; /* Input line. */
- char **lbp;
- size_t *lbclenp, *lblenp;
- regmatch_t match[10];
+re_sub(
+ SCR *sp,
+ CHAR_T *ip, /* Input line. */
+ CHAR_T **lbp,
+ size_t *lbclenp,
+ size_t *lblenp,
+ regmatch_t match[10])
{
enum { C_NOTSET, C_LOWER, C_ONELOWER, C_ONEUPPER, C_UPPER } conv;
size_t lbclen, lblen; /* Local copies. */
size_t mlen; /* Match length. */
size_t rpl; /* Remaining replacement length. */
- char *rp; /* Replacement pointer. */
+ CHAR_T *rp; /* Replacement pointer. */
int ch;
int no; /* Match replacement offset. */
- char *p, *t; /* Buffer pointers. */
- char *lb; /* Local copies. */
+ CHAR_T *p, *t; /* Buffer pointers. */
+ CHAR_T *lb; /* Local copies. */
lb = *lbp; /* Get local copies. */
lbclen = *lbclenp;
@@ -1363,8 +1342,8 @@ re_sub(sp, ip, lbp, lbclenp, lblenp, match)
* all escaping characters. This (hopefully) matches historic practice.
*/
#define OUTCH(ch, nltrans) { \
- CHAR_T __ch = (ch); \
- u_int __value = KEY_VAL(sp, __ch); \
+ ARG_CHAR_T __ch = (ch); \
+ e_key_t __value = KEY_VAL(sp, __ch); \
if (nltrans && (__value == K_CR || __value == K_NL)) { \
NEEDNEWLINE(sp); \
sp->newl[sp->newl_cnt++] = lbclen; \
@@ -1374,15 +1353,15 @@ re_sub(sp, ip, lbp, lbclenp, lblenp, match)
conv = C_NOTSET; \
/* FALLTHROUGH */ \
case C_LOWER: \
- if (isupper(__ch)) \
- __ch = tolower(__ch); \
+ if (ISUPPER(__ch)) \
+ __ch = TOLOWER(__ch); \
break; \
case C_ONEUPPER: \
conv = C_NOTSET; \
/* FALLTHROUGH */ \
case C_UPPER: \
- if (islower(__ch)) \
- __ch = toupper(__ch); \
+ if (ISLOWER(__ch)) \
+ __ch = TOUPPER(__ch); \
break; \
default: \
abort(); \
@@ -1444,6 +1423,9 @@ subzero: if (match[no].rm_so == -1 ||
++rp;
conv = C_UPPER;
continue;
+ case '\r':
+ OUTCH(ch, 0);
+ continue;
default:
++rp;
break;
diff --git a/ex/ex_tag.c b/ex/ex_tag.c
index 461b1526ef00..4ef03fb37d35 100644
--- a/ex/ex_tag.c
+++ b/ex/ex_tag.c
@@ -13,19 +13,13 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_tag.c 10.36 (Berkeley) 9/15/96";
+static const char sccsid[] = "$Id: ex_tag.c,v 10.54 2012/04/12 07:17:30 zy Exp $";
#endif /* not lint */
-#include <sys/param.h>
-#include <sys/types.h> /* XXX: param.h may not have included types.h */
-
-#ifdef HAVE_SYS_MMAN_H
+#include <sys/types.h>
#include <sys/mman.h>
-#endif
-
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -45,10 +39,10 @@ static const char sccsid[] = "@(#)ex_tag.c 10.36 (Berkeley) 9/15/96";
static char *binary_search __P((char *, char *, char *));
static int compare __P((char *, char *, char *));
static void ctag_file __P((SCR *, TAGF *, char *, char **, size_t *));
-static int ctag_search __P((SCR *, char *, size_t, char *));
+static int ctag_search __P((SCR *, CHAR_T *, size_t, char *));
static int ctag_sfile __P((SCR *, TAGF *, TAGQ *, char *));
-static TAGQ *ctag_slist __P((SCR *, char *));
-static char *linear_search __P((char *, char *, char *));
+static TAGQ *ctag_slist __P((SCR *, CHAR_T *));
+static char *linear_search __P((char *, char *, char *, long));
static int tag_copy __P((SCR *, TAG *, TAG **));
static int tag_pop __P((SCR *, TAGQ *, int));
static int tagf_copy __P((SCR *, TAGF *, TAGF **));
@@ -59,19 +53,16 @@ static int tagq_copy __P((SCR *, TAGQ *, TAGQ **));
* ex_tag_first --
* The tag code can be entered from main, e.g., "vi -t tag".
*
- * PUBLIC: int ex_tag_first __P((SCR *, char *));
+ * PUBLIC: int ex_tag_first __P((SCR *, CHAR_T *));
*/
int
-ex_tag_first(sp, tagarg)
- SCR *sp;
- char *tagarg;
+ex_tag_first(SCR *sp, CHAR_T *tagarg)
{
- ARGS *ap[2], a;
EXCMD cmd;
/* Build an argument for the ex :tag command. */
- ex_cinit(&cmd, C_TAG, 0, OOBLNO, OOBLNO, 0, ap);
- ex_cadd(&cmd, &a, tagarg, strlen(tagarg));
+ ex_cinit(sp, &cmd, C_TAG, 0, OOBLNO, OOBLNO, 0);
+ argv_exp0(sp, &cmd, tagarg, STRLEN(tagarg));
/*
* XXX
@@ -98,18 +89,11 @@ ex_tag_first(sp, tagarg)
* PUBLIC: int ex_tag_push __P((SCR *, EXCMD *));
*/
int
-ex_tag_push(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_tag_push(SCR *sp, EXCMD *cmdp)
{
EX_PRIVATE *exp;
- FREF *frp;
- TAG *rtp;
- TAGQ *rtqp, *tqp;
- recno_t lno;
- size_t cno;
+ TAGQ *tqp;
long tl;
- int force, istmp;
exp = EXP(sp);
switch (cmdp->argc) {
@@ -117,14 +101,15 @@ ex_tag_push(sp, cmdp)
if (exp->tag_last != NULL)
free(exp->tag_last);
- if ((exp->tag_last = strdup(cmdp->argv[0]->bp)) == NULL) {
+ if ((exp->tag_last = v_wstrdup(sp, cmdp->argv[0]->bp,
+ cmdp->argv[0]->len)) == NULL) {
msgq(sp, M_SYSERR, NULL);
return (1);
}
/* Taglength may limit the number of characters. */
if ((tl =
- O_VAL(sp, O_TAGLENGTH)) != 0 && strlen(exp->tag_last) > tl)
+ O_VAL(sp, O_TAGLENGTH)) != 0 && STRLEN(exp->tag_last) > tl)
exp->tag_last[tl] = '\0';
break;
case 0:
@@ -141,91 +126,11 @@ ex_tag_push(sp, cmdp)
if ((tqp = ctag_slist(sp, exp->tag_last)) == NULL)
return (1);
- /*
- * Allocate all necessary memory before swapping screens. Initialize
- * flags so we know what to free.
- */
- rtp = NULL;
- rtqp = NULL;
- if (exp->tq.cqh_first == (void *)&exp->tq) {
- /* Initialize the `local context' tag queue structure. */
- CALLOC_GOTO(sp, rtqp, TAGQ *, 1, sizeof(TAGQ));
- CIRCLEQ_INIT(&rtqp->tagq);
-
- /* Initialize and link in its tag structure. */
- CALLOC_GOTO(sp, rtp, TAG *, 1, sizeof(TAG));
- CIRCLEQ_INSERT_HEAD(&rtqp->tagq, rtp, q);
- rtqp->current = rtp;
- }
-
- /*
- * Stick the current context information in a convenient place, we're
- * about to lose it. Note, if we're called on editor startup, there
- * will be no FREF structure.
- */
- frp = sp->frp;
- lno = sp->lno;
- cno = sp->cno;
- istmp = frp == NULL ||
- F_ISSET(frp, FR_TMPFILE) && !F_ISSET(cmdp, E_NEWSCREEN);
-
- /* Try to switch to the tag. */
- force = FL_ISSET(cmdp->iflags, E_C_FORCE);
- if (F_ISSET(cmdp, E_NEWSCREEN)) {
- if (ex_tag_Nswitch(sp, tqp->tagq.cqh_first, force))
- goto err;
-
- /* Everything else gets done in the new screen. */
- sp = sp->nextdisp;
- exp = EXP(sp);
- } else
- if (ex_tag_nswitch(sp, tqp->tagq.cqh_first, force))
- goto err;
-
- /*
- * If this is the first tag, put a `current location' queue entry
- * in place, so we can pop all the way back to the current mark.
- * Note, it doesn't point to much of anything, it's a placeholder.
- */
- if (exp->tq.cqh_first == (void *)&exp->tq) {
- CIRCLEQ_INSERT_HEAD(&exp->tq, rtqp, q);
- } else
- rtqp = exp->tq.cqh_first;
-
- /* Link the new TAGQ structure into place. */
- CIRCLEQ_INSERT_HEAD(&exp->tq, tqp, q);
+ if (tagq_push(sp, tqp, F_ISSET(cmdp, E_NEWSCREEN),
+ FL_ISSET(cmdp->iflags, E_C_FORCE)))
+ return 1;
- (void)ctag_search(sp,
- tqp->current->search, tqp->current->slen, tqp->tag);
-
- /*
- * Move the current context from the temporary save area into the
- * right structure.
- *
- * If we were in a temporary file, we don't have a context to which
- * we can return, so just make it be the same as what we're moving
- * to. It will be a little odd that ^T doesn't change anything, but
- * I don't think it's a big deal.
- */
- if (istmp) {
- rtqp->current->frp = sp->frp;
- rtqp->current->lno = sp->lno;
- rtqp->current->cno = sp->cno;
- } else {
- rtqp->current->frp = frp;
- rtqp->current->lno = lno;
- rtqp->current->cno = cno;
- }
- return (0);
-
-err:
-alloc_err:
- if (rtqp != NULL)
- free(rtqp);
- if (rtp != NULL)
- free(rtp);
- tagq_free(sp, tqp);
- return (1);
+ return 0;
}
/*
@@ -235,20 +140,20 @@ alloc_err:
* PUBLIC: int ex_tag_next __P((SCR *, EXCMD *));
*/
int
-ex_tag_next(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_tag_next(SCR *sp, EXCMD *cmdp)
{
EX_PRIVATE *exp;
TAG *tp;
TAGQ *tqp;
+ char *np;
+ size_t nlen;
exp = EXP(sp);
- if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) {
+ if ((tqp = TAILQ_FIRST(exp->tq)) == NULL) {
tag_msg(sp, TAG_EMPTY, NULL);
return (1);
}
- if ((tp = tqp->current->q.cqe_next) == (void *)&tqp->tagq) {
+ if ((tp = TAILQ_NEXT(tqp->current, q)) == NULL) {
msgq(sp, M_ERR, "282|Already at the last tag of this group");
return (1);
}
@@ -260,6 +165,11 @@ ex_tag_next(sp, cmdp)
(void)cscope_search(sp, tqp, tp);
else
(void)ctag_search(sp, tp->search, tp->slen, tqp->tag);
+ if (tqp->current->msg) {
+ INT2CHAR(sp, tqp->current->msg, tqp->current->mlen + 1,
+ np, nlen);
+ msgq(sp, M_INFO, "%s", np);
+ }
return (0);
}
@@ -270,20 +180,20 @@ ex_tag_next(sp, cmdp)
* PUBLIC: int ex_tag_prev __P((SCR *, EXCMD *));
*/
int
-ex_tag_prev(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_tag_prev(SCR *sp, EXCMD *cmdp)
{
EX_PRIVATE *exp;
TAG *tp;
TAGQ *tqp;
+ char *np;
+ size_t nlen;
exp = EXP(sp);
- if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) {
+ if ((tqp = TAILQ_FIRST(exp->tq)) == NULL) {
tag_msg(sp, TAG_EMPTY, NULL);
return (0);
}
- if ((tp = tqp->current->q.cqe_prev) == (void *)&tqp->tagq) {
+ if ((tp = TAILQ_PREV(tqp->current, _tagqh, q)) == NULL) {
msgq(sp, M_ERR, "255|Already at the first tag of this group");
return (1);
}
@@ -295,6 +205,11 @@ ex_tag_prev(sp, cmdp)
(void)cscope_search(sp, tqp, tp);
else
(void)ctag_search(sp, tp->search, tp->slen, tqp->tag);
+ if (tqp->current->msg) {
+ INT2CHAR(sp, tqp->current->msg, tqp->current->mlen + 1,
+ np, nlen);
+ msgq(sp, M_INFO, "%s", np);
+ }
return (0);
}
@@ -305,10 +220,7 @@ ex_tag_prev(sp, cmdp)
* PUBLIC: int ex_tag_nswitch __P((SCR *, TAG *, int));
*/
int
-ex_tag_nswitch(sp, tp, force)
- SCR *sp;
- TAG *tp;
- int force;
+ex_tag_nswitch(SCR *sp, TAG *tp, int force)
{
/* Get a file structure. */
if (tp->frp == NULL && (tp->frp = file_add(sp, tp->fname)) == NULL)
@@ -342,10 +254,7 @@ ex_tag_nswitch(sp, tp, force)
* PUBLIC: int ex_tag_Nswitch __P((SCR *, TAG *, int));
*/
int
-ex_tag_Nswitch(sp, tp, force)
- SCR *sp;
- TAG *tp;
- int force;
+ex_tag_Nswitch(SCR *sp, TAG *tp, int force)
{
SCR *new;
@@ -399,19 +308,18 @@ ex_tag_Nswitch(sp, tp, force)
* PUBLIC: int ex_tag_pop __P((SCR *, EXCMD *));
*/
int
-ex_tag_pop(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_tag_pop(SCR *sp, EXCMD *cmdp)
{
EX_PRIVATE *exp;
TAGQ *tqp, *dtqp;
size_t arglen;
long off;
char *arg, *p, *t;
+ size_t nlen;
/* Check for an empty stack. */
exp = EXP(sp);
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (TAILQ_EMPTY(exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (1);
}
@@ -419,10 +327,11 @@ ex_tag_pop(sp, cmdp)
/* Find the last TAG structure that we're going to DISCARD! */
switch (cmdp->argc) {
case 0: /* Pop one tag. */
- dtqp = exp->tq.cqh_first;
+ dtqp = TAILQ_FIRST(exp->tq);
break;
case 1: /* Name or number. */
- arg = cmdp->argv[0]->bp;
+ INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len+1,
+ arg, nlen);
off = strtol(arg, &p, 10);
if (*p != '\0')
goto filearg;
@@ -430,10 +339,9 @@ ex_tag_pop(sp, cmdp)
/* Number: pop that many queue entries. */
if (off < 1)
return (0);
- for (tqp = exp->tq.cqh_first;
- tqp != (void *)&exp->tq && --off > 1;
- tqp = tqp->q.cqe_next);
- if (tqp == (void *)&exp->tq) {
+ TAILQ_FOREACH(tqp, exp->tq, q)
+ if (--off <= 1) break;
+ if (tqp == NULL) {
msgq(sp, M_ERR,
"159|Less than %s entries on the tags stack; use :display t[ags]",
arg);
@@ -444,11 +352,10 @@ ex_tag_pop(sp, cmdp)
/* File argument: pop to that queue entry. */
filearg: arglen = strlen(arg);
- for (tqp = exp->tq.cqh_first;
- tqp != (void *)&exp->tq;
- dtqp = tqp, tqp = tqp->q.cqe_next) {
+ for (tqp = TAILQ_FIRST(exp->tq); tqp;
+ dtqp = tqp, tqp = TAILQ_NEXT(tqp, q)) {
/* Don't pop to the current file. */
- if (tqp == exp->tq.cqh_first)
+ if (tqp == TAILQ_FIRST(exp->tq))
continue;
p = tqp->current->frp->name;
if ((t = strrchr(p, '/')) == NULL)
@@ -458,12 +365,12 @@ filearg: arglen = strlen(arg);
if (!strncmp(arg, t, arglen))
break;
}
- if (tqp == (void *)&exp->tq) {
+ if (tqp == NULL) {
msgq_str(sp, M_ERR, arg,
"160|No file %s on the tags stack to return to; use :display t[ags]");
return (1);
}
- if (tqp == exp->tq.cqh_first)
+ if (tqp == TAILQ_FIRST(exp->tq))
return (0);
break;
default:
@@ -480,23 +387,21 @@ filearg: arglen = strlen(arg);
* PUBLIC: int ex_tag_top __P((SCR *, EXCMD *));
*/
int
-ex_tag_top(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_tag_top(SCR *sp, EXCMD *cmdp)
{
EX_PRIVATE *exp;
exp = EXP(sp);
/* Check for an empty stack. */
- if (exp->tq.cqh_first == (void *)&exp->tq) {
+ if (TAILQ_EMPTY(exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (1);
}
/* Return to the oldest information. */
- return (tag_pop(sp,
- exp->tq.cqh_last->q.cqe_prev, FL_ISSET(cmdp->iflags, E_C_FORCE)));
+ return (tag_pop(sp, TAILQ_PREV(TAILQ_LAST(exp->tq, _tqh), _tqh, q),
+ FL_ISSET(cmdp->iflags, E_C_FORCE)));
}
/*
@@ -504,10 +409,7 @@ ex_tag_top(sp, cmdp)
* Pop up to and including the specified TAGQ context.
*/
static int
-tag_pop(sp, dtqp, force)
- SCR *sp;
- TAGQ *dtqp;
- int force;
+tag_pop(SCR *sp, TAGQ *dtqp, int force)
{
EX_PRIVATE *exp;
TAG *tp;
@@ -519,7 +421,7 @@ tag_pop(sp, dtqp, force)
* Update the cursor from the saved TAG information of the TAG
* structure we're moving to.
*/
- tp = dtqp->q.cqe_next->current;
+ tp = TAILQ_NEXT(dtqp, q)->current;
if (tp->frp == sp->frp) {
sp->lno = tp->lno;
sp->cno = tp->cno;
@@ -538,7 +440,7 @@ tag_pop(sp, dtqp, force)
/* Pop entries off the queue up to and including dtqp. */
do {
- tqp = exp->tq.cqh_first;
+ tqp = TAILQ_FIRST(exp->tq);
if (tagq_free(sp, tqp))
return (0);
} while (tqp != dtqp);
@@ -547,8 +449,8 @@ tag_pop(sp, dtqp, force)
* If only a single tag left, we've returned to the first tag point,
* and the stack is now empty.
*/
- if (exp->tq.cqh_first->q.cqe_next == (void *)&exp->tq)
- tagq_free(sp, exp->tq.cqh_first);
+ if (TAILQ_NEXT(TAILQ_FIRST(exp->tq), q) == NULL)
+ tagq_free(sp, TAILQ_FIRST(exp->tq));
return (0);
}
@@ -560,18 +462,17 @@ tag_pop(sp, dtqp, force)
* PUBLIC: int ex_tag_display __P((SCR *));
*/
int
-ex_tag_display(sp)
- SCR *sp;
+ex_tag_display(SCR *sp)
{
EX_PRIVATE *exp;
TAG *tp;
TAGQ *tqp;
int cnt;
size_t len;
- char *p, *sep;
+ char *p;
exp = EXP(sp);
- if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) {
+ if (TAILQ_EMPTY(exp->tq)) {
tag_msg(sp, TAG_EMPTY, NULL);
return (0);
}
@@ -599,11 +500,10 @@ ex_tag_display(sp)
* Display the list of tags for each queue entry. The first entry
* is numbered, and the current tag entry has an asterisk appended.
*/
- for (cnt = 1, tqp = exp->tq.cqh_first; !INTERRUPTED(sp) &&
- tqp != (void *)&exp->tq; ++cnt, tqp = tqp->q.cqe_next)
- for (tp = tqp->tagq.cqh_first;
- tp != (void *)&tqp->tagq; tp = tp->q.cqe_next) {
- if (tp == tqp->tagq.cqh_first)
+ for (cnt = 1, tqp = TAILQ_FIRST(exp->tq); !INTERRUPTED(sp) &&
+ tqp != NULL; ++cnt, tqp = TAILQ_NEXT(tqp, q))
+ TAILQ_FOREACH(tp, tqp->tagq, q) {
+ if (tp == TAILQ_FIRST(tqp->tagq))
(void)ex_printf(sp, "%2d ", cnt);
else
(void)ex_printf(sp, " ");
@@ -618,7 +518,7 @@ ex_tag_display(sp)
if (tqp->current == tp)
(void)ex_printf(sp, "*");
- if (tp == tqp->tagq.cqh_first && tqp->tag != NULL &&
+ if (tp == TAILQ_FIRST(tqp->tagq) && tqp->tag != NULL &&
(sp->cols - L_NAME) >= L_TAG + L_SPACE) {
len = strlen(tqp->tag);
if (len > sp->cols - (L_NAME + L_SPACE))
@@ -639,8 +539,7 @@ ex_tag_display(sp)
* PUBLIC: int ex_tag_copy __P((SCR *, SCR *));
*/
int
-ex_tag_copy(orig, sp)
- SCR *orig, *sp;
+ex_tag_copy(SCR *orig, SCR *sp)
{
EX_PRIVATE *oexp, *nexp;
TAGQ *aqp, *tqp;
@@ -651,33 +550,31 @@ ex_tag_copy(orig, sp)
nexp = EXP(sp);
/* Copy tag queue and tags stack. */
- for (aqp = oexp->tq.cqh_first;
- aqp != (void *)&oexp->tq; aqp = aqp->q.cqe_next) {
+ TAILQ_FOREACH(aqp, oexp->tq, q) {
if (tagq_copy(sp, aqp, &tqp))
return (1);
- for (ap = aqp->tagq.cqh_first;
- ap != (void *)&aqp->tagq; ap = ap->q.cqe_next) {
+ TAILQ_FOREACH(ap, aqp->tagq, q) {
if (tag_copy(sp, ap, &tp))
return (1);
/* Set the current pointer. */
if (aqp->current == ap)
tqp->current = tp;
- CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q);
+ TAILQ_INSERT_TAIL(tqp->tagq, tp, q);
}
- CIRCLEQ_INSERT_TAIL(&nexp->tq, tqp, q);
+ TAILQ_INSERT_TAIL(nexp->tq, tqp, q);
}
/* Copy list of tag files. */
- for (atfp = oexp->tagfq.tqh_first;
- atfp != NULL; atfp = atfp->q.tqe_next) {
+ TAILQ_FOREACH(atfp, oexp->tagfq, q) {
if (tagf_copy(sp, atfp, &tfp))
return (1);
- TAILQ_INSERT_TAIL(&nexp->tagfq, tfp, q);
+ TAILQ_INSERT_TAIL(nexp->tagfq, tfp, q);
}
/* Copy the last tag. */
if (oexp->tag_last != NULL &&
- (nexp->tag_last = strdup(oexp->tag_last)) == NULL) {
+ (nexp->tag_last = v_wstrdup(sp, oexp->tag_last,
+ STRLEN(oexp->tag_last))) == NULL) {
msgq(sp, M_SYSERR, NULL);
return (1);
}
@@ -689,9 +586,7 @@ ex_tag_copy(orig, sp)
* Copy a TAGF structure and return it in new memory.
*/
static int
-tagf_copy(sp, otfp, tfpp)
- SCR *sp;
- TAGF *otfp, **tfpp;
+tagf_copy(SCR *sp, TAGF *otfp, TAGF **tfpp)
{
TAGF *tfp;
@@ -711,9 +606,7 @@ tagf_copy(sp, otfp, tfpp)
* Copy a TAGQ structure and return it in new memory.
*/
static int
-tagq_copy(sp, otqp, tqpp)
- SCR *sp;
- TAGQ *otqp, **tqpp;
+tagq_copy(SCR *sp, TAGQ *otqp, TAGQ **tqpp)
{
TAGQ *tqp;
size_t len;
@@ -724,7 +617,7 @@ tagq_copy(sp, otqp, tqpp)
MALLOC_RET(sp, tqp, TAGQ *, len);
memcpy(tqp, otqp, len);
- CIRCLEQ_INIT(&tqp->tagq);
+ TAILQ_INIT(tqp->tagq);
tqp->current = NULL;
if (otqp->tag != NULL)
tqp->tag = tqp->buf;
@@ -738,9 +631,7 @@ tagq_copy(sp, otqp, tqpp)
* Copy a TAG structure and return it in new memory.
*/
static int
-tag_copy(sp, otp, tpp)
- SCR *sp;
- TAG *otp, **tpp;
+tag_copy(SCR *sp, TAG *otp, TAG **tpp)
{
TAG *tp;
size_t len;
@@ -750,13 +641,17 @@ tag_copy(sp, otp, tpp)
len += otp->fnlen + 1;
if (otp->search != NULL)
len += otp->slen + 1;
+ if (otp->msg != NULL)
+ len += otp->mlen + 1;
MALLOC_RET(sp, tp, TAG *, len);
memcpy(tp, otp, len);
if (otp->fname != NULL)
- tp->fname = tp->buf;
+ tp->fname = (char *)tp->buf;
if (otp->search != NULL)
- tp->search = tp->fname + otp->fnlen + 1;
+ tp->search = tp->buf + (otp->search - otp->buf);
+ if (otp->msg != NULL)
+ tp->msg = tp->buf + (otp->msg - otp->buf);
*tpp = tp;
return (0);
@@ -767,14 +662,12 @@ tag_copy(sp, otp, tpp)
* Free a TAGF structure.
*/
static int
-tagf_free(sp, tfp)
- SCR *sp;
- TAGF *tfp;
+tagf_free(SCR *sp, TAGF *tfp)
{
EX_PRIVATE *exp;
exp = EXP(sp);
- TAILQ_REMOVE(&exp->tagfq, tfp, q);
+ TAILQ_REMOVE(exp->tagfq, tfp, q);
free(tfp->name);
free(tfp);
return (0);
@@ -787,16 +680,14 @@ tagf_free(sp, tfp)
* PUBLIC: int tagq_free __P((SCR *, TAGQ *));
*/
int
-tagq_free(sp, tqp)
- SCR *sp;
- TAGQ *tqp;
+tagq_free(SCR *sp, TAGQ *tqp)
{
EX_PRIVATE *exp;
TAG *tp;
exp = EXP(sp);
- while ((tp = tqp->tagq.cqh_first) != (void *)&tqp->tagq) {
- CIRCLEQ_REMOVE(&tqp->tagq, tp, q);
+ while ((tp = TAILQ_FIRST(tqp->tagq)) != NULL) {
+ TAILQ_REMOVE(tqp->tagq, tp, q);
free(tp);
}
/*
@@ -804,23 +695,129 @@ tagq_free(sp, tqp)
* If allocated and then the user failed to switch files, the TAGQ
* structure was never attached to any list.
*/
- if (tqp->q.cqe_next != NULL)
- CIRCLEQ_REMOVE(&exp->tq, tqp, q);
+ if (TAILQ_ENTRY_ISVALID(tqp, q))
+ TAILQ_REMOVE(exp->tq, tqp, q);
free(tqp);
return (0);
}
/*
+ * PUBLIC: int tagq_push __P((SCR*, TAGQ*, int, int ));
+ */
+int
+tagq_push(SCR *sp, TAGQ *tqp, int new_screen, int force)
+{
+ EX_PRIVATE *exp;
+ FREF *frp;
+ TAG *rtp;
+ TAGQ *rtqp;
+ recno_t lno;
+ size_t cno;
+ int istmp;
+ char *np;
+ size_t nlen;
+
+ exp = EXP(sp);
+
+ /*
+ * Allocate all necessary memory before swapping screens. Initialize
+ * flags so we know what to free.
+ */
+ rtp = NULL;
+ rtqp = NULL;
+ if (TAILQ_EMPTY(exp->tq)) {
+ /* Initialize the `local context' tag queue structure. */
+ CALLOC_GOTO(sp, rtqp, TAGQ *, 1, sizeof(TAGQ));
+ TAILQ_INIT(rtqp->tagq);
+
+ /* Initialize and link in its tag structure. */
+ CALLOC_GOTO(sp, rtp, TAG *, 1, sizeof(TAG));
+ TAILQ_INSERT_HEAD(rtqp->tagq, rtp, q);
+ rtqp->current = rtp;
+ }
+
+ /*
+ * Stick the current context information in a convenient place, we're
+ * about to lose it. Note, if we're called on editor startup, there
+ * will be no FREF structure.
+ */
+ frp = sp->frp;
+ lno = sp->lno;
+ cno = sp->cno;
+ istmp = frp == NULL ||
+ (F_ISSET(frp, FR_TMPFILE) && !new_screen);
+
+ /* Try to switch to the preset tag. */
+ if (new_screen) {
+ if (ex_tag_Nswitch(sp, tqp->current, force))
+ goto err;
+
+ /* Everything else gets done in the new screen. */
+ sp = sp->nextdisp;
+ exp = EXP(sp);
+ } else
+ if (ex_tag_nswitch(sp, tqp->current, force))
+ goto err;
+
+ /*
+ * If this is the first tag, put a `current location' queue entry
+ * in place, so we can pop all the way back to the current mark.
+ * Note, it doesn't point to much of anything, it's a placeholder.
+ */
+ if (TAILQ_EMPTY(exp->tq)) {
+ TAILQ_INSERT_HEAD(exp->tq, rtqp, q);
+ } else
+ rtqp = TAILQ_FIRST(exp->tq);
+
+ /* Link the new TAGQ structure into place. */
+ TAILQ_INSERT_HEAD(exp->tq, tqp, q);
+
+ (void)ctag_search(sp,
+ tqp->current->search, tqp->current->slen, tqp->tag);
+ if (tqp->current->msg) {
+ INT2CHAR(sp, tqp->current->msg, tqp->current->mlen + 1,
+ np, nlen);
+ msgq(sp, M_INFO, "%s", np);
+ }
+
+ /*
+ * Move the current context from the temporary save area into the
+ * right structure.
+ *
+ * If we were in a temporary file, we don't have a context to which
+ * we can return, so just make it be the same as what we're moving
+ * to. It will be a little odd that ^T doesn't change anything, but
+ * I don't think it's a big deal.
+ */
+ if (istmp) {
+ rtqp->current->frp = sp->frp;
+ rtqp->current->lno = sp->lno;
+ rtqp->current->cno = sp->cno;
+ } else {
+ rtqp->current->frp = frp;
+ rtqp->current->lno = lno;
+ rtqp->current->cno = cno;
+ }
+ return (0);
+
+err:
+alloc_err:
+ if (rtqp != NULL)
+ free(rtqp);
+ if (rtp != NULL)
+ free(rtp);
+ tagq_free(sp, tqp);
+ return (1);
+}
+
+/*
* tag_msg
* A few common messages.
*
* PUBLIC: void tag_msg __P((SCR *, tagmsg_t, char *));
*/
void
-tag_msg(sp, msg, tag)
- SCR *sp;
- tagmsg_t msg;
- char *tag;
+tag_msg(SCR *sp, tagmsg_t msg, char *tag)
{
switch (msg) {
case TAG_BADLNO:
@@ -845,9 +842,7 @@ tag_msg(sp, msg, tag)
* PUBLIC: int ex_tagf_alloc __P((SCR *, char *));
*/
int
-ex_tagf_alloc(sp, str)
- SCR *sp;
- char *str;
+ex_tagf_alloc(SCR *sp, char *str)
{
EX_PRIVATE *exp;
TAGF *tfp;
@@ -856,13 +851,13 @@ ex_tagf_alloc(sp, str)
/* Free current queue. */
exp = EXP(sp);
- while ((tfp = exp->tagfq.tqh_first) != NULL)
+ while ((tfp = TAILQ_FIRST(exp->tagfq)) != NULL)
tagf_free(sp, tfp);
/* Create new queue. */
for (p = t = str;; ++p) {
- if (*p == '\0' || isblank(*p)) {
- if ((len = p - t) > 1) {
+ if (*p == '\0' || cmdskip(*p)) {
+ if ((len = p - t)) {
MALLOC_RET(sp, tfp, TAGF *, sizeof(TAGF));
MALLOC(sp, tfp->name, char *, len + 1);
if (tfp->name == NULL) {
@@ -872,7 +867,7 @@ ex_tagf_alloc(sp, str)
memcpy(tfp->name, t, len);
tfp->name[len] = '\0';
tfp->flags = 0;
- TAILQ_INSERT_TAIL(&exp->tagfq, tfp, q);
+ TAILQ_INSERT_TAIL(exp->tagfq, tfp, q);
}
t = p + 1;
}
@@ -889,8 +884,7 @@ ex_tagf_alloc(sp, str)
* PUBLIC: int ex_tag_free __P((SCR *));
*/
int
-ex_tag_free(sp)
- SCR *sp;
+ex_tag_free(SCR *sp)
{
EX_PRIVATE *exp;
TAGF *tfp;
@@ -898,9 +892,9 @@ ex_tag_free(sp)
/* Free up tag information. */
exp = EXP(sp);
- while ((tqp = exp->tq.cqh_first) != (void *)&exp->tq)
+ while ((tqp = TAILQ_FIRST(exp->tq)) != NULL)
tagq_free(sp, tqp);
- while ((tfp = exp->tagfq.tqh_first) != NULL)
+ while ((tfp = TAILQ_FIRST(exp->tagfq)) != NULL)
tagf_free(sp, tfp);
if (exp->tag_last != NULL)
free(exp->tag_last);
@@ -912,13 +906,12 @@ ex_tag_free(sp)
* Search a file for a tag.
*/
static int
-ctag_search(sp, search, slen, tag)
- SCR *sp;
- char *search, *tag;
- size_t slen;
+ctag_search(SCR *sp, CHAR_T *search, size_t slen, char *tag)
{
MARK m;
char *p;
+ char *np;
+ size_t nlen;
/*
* !!!
@@ -926,8 +919,9 @@ ctag_search(sp, search, slen, tag)
* used a line number, not a search string. I got complaints, so
* people are still using the format. POSIX 1003.2 permits it.
*/
- if (isdigit(search[0])) {
- m.lno = atoi(search);
+ if (ISDIGIT(search[0])) {
+ INT2CHAR(sp, search, slen+1, np, nlen);
+ m.lno = atoi(np);
if (!db_exist(sp, m.lno)) {
tag_msg(sp, TAG_BADLNO, tag);
return (1);
@@ -940,9 +934,10 @@ ctag_search(sp, search, slen, tag)
m.lno = 1;
m.cno = 0;
if (f_search(sp, &m, &m,
- search, slen, NULL, SEARCH_FILE | SEARCH_TAG))
- if ((p = strrchr(search, '(')) != NULL) {
- slen = p - search;
+ search, slen, NULL, SEARCH_FILE | SEARCH_TAG)) {
+ INT2CHAR(sp, search, slen, np, nlen);
+ if ((p = strrchr(np, '(')) != NULL) {
+ slen = p - np;
if (f_search(sp, &m, &m, search, slen,
NULL, SEARCH_FILE | SEARCH_TAG))
goto notfound;
@@ -950,6 +945,7 @@ ctag_search(sp, search, slen, tag)
notfound: tag_msg(sp, TAG_SEARCH, tag);
return (1);
}
+ }
/*
* !!!
* Historically, tags set the search direction if it wasn't
@@ -974,43 +970,42 @@ notfound: tag_msg(sp, TAG_SEARCH, tag);
* Search the list of tags files for a tag, and return tag queue.
*/
static TAGQ *
-ctag_slist(sp, tag)
- SCR *sp;
- char *tag;
+ctag_slist(SCR *sp, CHAR_T *tag)
{
EX_PRIVATE *exp;
TAGF *tfp;
TAGQ *tqp;
size_t len;
- int echk;
+ int echk = 0;
+ char *np;
+ size_t nlen;
exp = EXP(sp);
/* Allocate and initialize the tag queue structure. */
- len = strlen(tag);
+ INT2CHAR(sp, tag, STRLEN(tag) + 1, np, nlen);
+ len = nlen - 1;
CALLOC_GOTO(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + len + 1);
- CIRCLEQ_INIT(&tqp->tagq);
+ TAILQ_INIT(tqp->tagq);
tqp->tag = tqp->buf;
- memcpy(tqp->tag, tag, (tqp->tlen = len) + 1);
+ memcpy(tqp->tag, np, (tqp->tlen = len) + 1);
/*
* Find the tag, only display missing file messages once, and
* then only if we didn't find the tag.
*/
- for (echk = 0,
- tfp = exp->tagfq.tqh_first; tfp != NULL; tfp = tfp->q.tqe_next)
- if (ctag_sfile(sp, tfp, tqp, tag)) {
+ TAILQ_FOREACH(tfp, exp->tagfq, q)
+ if (ctag_sfile(sp, tfp, tqp, tqp->tag)) {
echk = 1;
F_SET(tfp, TAGF_ERR);
} else
F_CLR(tfp, TAGF_ERR | TAGF_ERR_WARN);
/* Check to see if we found anything. */
- if (tqp->tagq.cqh_first == (void *)&tqp->tagq) {
- msgq_str(sp, M_ERR, tag, "162|%s: tag not found");
+ if (TAILQ_EMPTY(tqp->tagq)) {
+ msgq_str(sp, M_ERR, tqp->tag, "162|%s: tag not found");
if (echk)
- for (tfp = exp->tagfq.tqh_first;
- tfp != NULL; tfp = tfp->q.tqe_next)
+ TAILQ_FOREACH(tfp, exp->tagfq, q)
if (F_ISSET(tfp, TAGF_ERR) &&
!F_ISSET(tfp, TAGF_ERR_WARN)) {
errno = tfp->errnum;
@@ -1021,7 +1016,6 @@ ctag_slist(sp, tag)
return (NULL);
}
- tqp->current = tqp->tagq.cqh_first;
return (tqp);
alloc_err:
@@ -1033,51 +1027,36 @@ alloc_err:
* Search a tags file for a tag, adding any found to the tag queue.
*/
static int
-ctag_sfile(sp, tfp, tqp, tname)
- SCR *sp;
- TAGF *tfp;
- TAGQ *tqp;
- char *tname;
+ctag_sfile(SCR *sp, TAGF *tfp, TAGQ *tqp, char *tname)
{
struct stat sb;
TAG *tp;
- size_t dlen, nlen, slen;
+ size_t dlen, nlen = 0, slen;
int fd, i, nf1, nf2;
- char *back, *cname, *dname, *front, *map, *name, *p, *search, *t;
+ char *back, *front, *map, *p, *search, *t;
+ char *cname = NULL, *dname = NULL, *name = NULL;
+ CHAR_T *wp;
+ size_t wlen;
+ long tl;
if ((fd = open(tfp->name, O_RDONLY, 0)) < 0) {
tfp->errnum = errno;
return (1);
}
- /*
- * XXX
- * Some old BSD systems require MAP_FILE as an argument when mapping
- * regular files.
- */
-#ifndef MAP_FILE
-#define MAP_FILE 0
-#endif
- /*
- * XXX
- * We'd like to test if the file is too big to mmap. Since we don't
- * know what size or type off_t's or size_t's are, what the largest
- * unsigned integral type is, or what random insanity the local C
- * compiler will perpetrate, doing the comparison in a portable way
- * is flatly impossible. Hope mmap fails if the file is too large.
- */
if (fstat(fd, &sb) != 0 ||
- (map = mmap(NULL, (size_t)sb.st_size, PROT_READ | PROT_WRITE,
- MAP_FILE | MAP_PRIVATE, fd, (off_t)0)) == (caddr_t)-1) {
+ (map = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
tfp->errnum = errno;
(void)close(fd);
return (1);
}
+ tl = O_VAL(sp, O_TAGLENGTH);
front = map;
back = front + sb.st_size;
front = binary_search(tname, front, back);
- front = linear_search(tname, front, back);
+ front = linear_search(tname, front, back, tl);
if (front == NULL)
goto done;
@@ -1140,29 +1119,41 @@ corrupt: p = msg_print(sp, tname, &nf1);
}
/* Check for passing the last entry. */
- if (strcmp(tname, cname))
+ if (tl ? strncmp(tname, cname, tl) : strcmp(tname, cname))
break;
/* Resolve the file name. */
ctag_file(sp, tfp, name, &dname, &dlen);
CALLOC_GOTO(sp, tp,
- TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 + slen + 1);
- tp->fname = tp->buf;
- if (dlen != 0) {
+ TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 +
+ (slen + 1) * sizeof(CHAR_T));
+ tp->fname = (char *)tp->buf;
+ if (dlen == 1 && *dname == '.')
+ --dlen;
+ else if (dlen != 0) {
memcpy(tp->fname, dname, dlen);
tp->fname[dlen] = '/';
++dlen;
}
memcpy(tp->fname + dlen, name, nlen + 1);
tp->fnlen = dlen + nlen;
- tp->search = tp->fname + tp->fnlen + 1;
- memcpy(tp->search, search, (tp->slen = slen) + 1);
- CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q);
+ tp->search = (CHAR_T*)(tp->fname + tp->fnlen + 1);
+ CHAR2INT(sp, search, slen + 1, wp, wlen);
+ MEMCPY(tp->search, wp, (tp->slen = slen) + 1);
+ TAILQ_INSERT_TAIL(tqp->tagq, tp, q);
+
+ /* Try to preset the tag within the current file. */
+ if (sp->frp != NULL && sp->frp->name != NULL &&
+ tqp->current == NULL && !strcmp(tp->fname, sp->frp->name))
+ tqp->current = tp;
}
+ if (tqp->current == NULL)
+ tqp->current = TAILQ_FIRST(tqp->tagq);
+
alloc_err:
-done: if (munmap(map, (size_t)sb.st_size))
+done: if (munmap(map, sb.st_size))
msgq(sp, M_SYSERR, "munmap");
if (close(fd))
msgq(sp, M_SYSERR, "close");
@@ -1174,15 +1165,10 @@ done: if (munmap(map, (size_t)sb.st_size))
* Search for the right path to this file.
*/
static void
-ctag_file(sp, tfp, name, dirp, dlenp)
- SCR *sp;
- TAGF *tfp;
- char *name, **dirp;
- size_t *dlenp;
+ctag_file(SCR *sp, TAGF *tfp, char *name, char **dirp, size_t *dlenp)
{
struct stat sb;
- size_t len;
- char *p, buf[MAXPATHLEN];
+ char *p, *buf;
/*
* !!!
@@ -1196,12 +1182,16 @@ ctag_file(sp, tfp, name, dirp, dlenp)
if (name[0] != '/' &&
stat(name, &sb) && (p = strrchr(tfp->name, '/')) != NULL) {
*p = '\0';
- len = snprintf(buf, sizeof(buf), "%s/%s", tfp->name, name);
- *p = '/';
+ if ((buf = join(tfp->name, name)) == NULL) {
+ msgq(sp, M_SYSERR, NULL);
+ return;
+ }
if (stat(buf, &sb) == 0) {
*dirp = tfp->name;
*dlenp = strlen(*dirp);
}
+ free(buf);
+ *p = '/';
}
}
@@ -1247,11 +1237,11 @@ ctag_file(sp, tfp, name, dirp, dlenp)
#define GREATER 1
#define LESS (-1)
-#define SKIP_PAST_NEWLINE(p, back) while (p < back && *p++ != '\n');
+#define SKIP_PAST_NEWLINE(p, back) \
+ while (p < back && *p++ != '\n') continue;
static char *
-binary_search(string, front, back)
- register char *string, *front, *back;
+binary_search(register char *string, register char *front, register char *back)
{
register char *p;
@@ -1281,11 +1271,12 @@ binary_search(string, front, back)
* o front is before or at the first line to be printed.
*/
static char *
-linear_search(string, front, back)
- char *string, *front, *back;
+linear_search(char *string, char *front, char *back, long tl)
{
+ char *end;
while (front < back) {
- switch (compare(string, front, back)) {
+ end = tl && back-front > tl ? front+tl : back;
+ switch (compare(string, front, end)) {
case EQUAL: /* Found it. */
return (front);
case LESS: /* No such string. */
@@ -1313,8 +1304,7 @@ linear_search(string, front, back)
* However, historic programs did use spaces, and, I got complaints.
*/
static int
-compare(s1, s2, back)
- register char *s1, *s2, *back;
+compare(register char *s1, register char *s2, register char *back)
{
for (; *s1 && s2 < back && (*s2 != '\t' && *s2 != ' '); ++s1, ++s2)
if (*s1 != *s2)
diff --git a/ex/ex_tcl.c b/ex/ex_tcl.c
deleted file mode 100644
index 06736a781006..000000000000
--- a/ex/ex_tcl.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- * Copyright (c) 1995
- * George V. Neville-Neil. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ex_tcl.c 8.10 (Berkeley) 9/15/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-#ifdef HAVE_TCL_INTERP
-#include <tcl.h>
-#endif
-
-/*
- * ex_tcl -- :[line [,line]] tcl [command]
- * Run a command through the tcl interpreter.
- *
- * PUBLIC: int ex_tcl __P((SCR*, EXCMD *));
- */
-int
-ex_tcl(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
-{
-#ifdef HAVE_TCL_INTERP
- CHAR_T *p;
- GS *gp;
- size_t len;
- char buf[128];
-
- /* Initialize the interpreter. */
- gp = sp->gp;
- if (gp->tcl_interp == NULL && tcl_init(gp))
- return (1);
-
- /* Skip leading white space. */
- if (cmdp->argc != 0)
- for (p = cmdp->argv[0]->bp,
- len = cmdp->argv[0]->len; len > 0; --len, ++p)
- if (!isblank(*p))
- break;
- if (cmdp->argc == 0 || len == 0) {
- ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
- return (1);
- }
-
- (void)snprintf(buf, sizeof(buf),
- "set viScreenId %d\nset viStartLine %lu\nset viStopLine %lu",
- sp->id, cmdp->addr1.lno, cmdp->addr2.lno);
- if (Tcl_Eval(gp->tcl_interp, buf) == TCL_OK &&
- Tcl_Eval(gp->tcl_interp, cmdp->argv[0]->bp) == TCL_OK)
- return (0);
-
- msgq(sp, M_ERR, "Tcl: %s", ((Tcl_Interp *)gp->tcl_interp)->result);
- return (1);
-#else
- msgq(sp, M_ERR, "302|Vi was not loaded with a Tcl interpreter");
- return (1);
-#endif /* HAVE_TCL_INTERP */
-}
diff --git a/ex/ex_txt.c b/ex/ex_txt.c
index 2f62ff51a47c..21d9f4412654 100644
--- a/ex/ex_txt.c
+++ b/ex/ex_txt.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_txt.c 10.17 (Berkeley) 10/10/96";
+static const char sccsid[] = "$Id: ex_txt.c,v 10.23 2001/06/25 15:19:21 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -24,6 +25,7 @@ static const char sccsid[] = "@(#)ex_txt.c 10.17 (Berkeley) 10/10/96";
#include <string.h>
#include "../common/common.h"
+#include "../vi/vi.h"
/*
* !!!
@@ -52,11 +54,7 @@ static void txt_prompt __P((SCR *, TEXT *, ARG_CHAR_T, u_int32_t));
* PUBLIC: int ex_txt __P((SCR *, TEXTH *, ARG_CHAR_T, u_int32_t));
*/
int
-ex_txt(sp, tiqh, prompt, flags)
- SCR *sp;
- TEXTH *tiqh;
- ARG_CHAR_T prompt;
- u_int32_t flags;
+ex_txt(SCR *sp, TEXTH *tiqh, ARG_CHAR_T prompt, u_int32_t flags)
{
EVENT ev;
GS *gp;
@@ -64,6 +62,7 @@ ex_txt(sp, tiqh, prompt, flags)
carat_t carat_st;
size_t cnt;
int rval;
+ int nochange;
rval = 0;
@@ -72,9 +71,9 @@ ex_txt(sp, tiqh, prompt, flags)
* last one if it's big enough. (All TEXT bookkeeping fields default
* to 0 -- text_init() handles this.)
*/
- if (tiqh->cqh_first != (void *)tiqh) {
- tp = tiqh->cqh_first;
- if (tp->q.cqe_next != (void *)tiqh || tp->lb_len < 32) {
+ if (!TAILQ_EMPTY(tiqh)) {
+ tp = TAILQ_FIRST(tiqh);
+ if (TAILQ_NEXT(tp, q) != NULL || tp->lb_len < 32) {
text_lfree(tiqh);
goto newtp;
}
@@ -82,7 +81,7 @@ ex_txt(sp, tiqh, prompt, flags)
} else {
newtp: if ((tp = text_init(sp, NULL, 0, 32)) == NULL)
goto err;
- CIRCLEQ_INSERT_HEAD(tiqh, tp, q);
+ TAILQ_INSERT_HEAD(tiqh, tp, q);
}
/* Set the starting line number. */
@@ -112,7 +111,7 @@ newtp: if ((tp = text_init(sp, NULL, 0, 32)) == NULL)
txt_prompt(sp, tp, prompt, flags);
}
- for (carat_st = C_NOTSET;;) {
+ for (carat_st = C_NOTSET, nochange = 0;;) {
if (v_event_get(sp, &ev, 0, 0))
goto err;
@@ -146,7 +145,7 @@ newtp: if ((tp = text_init(sp, NULL, 0, 32)) == NULL)
* Check to see if the character fits into the input buffer.
* (Use tp->len, ignore overwrite and non-printable chars.)
*/
- BINC_GOTO(sp, tp->lb, tp->lb_len, tp->len + 1);
+ BINC_GOTOW(sp, tp->lb, tp->lb_len, tp->len + 1);
switch (ev.e_value) {
case K_CR:
@@ -189,7 +188,7 @@ newtp: if ((tp = text_init(sp, NULL, 0, 32)) == NULL)
*/
if (LF_ISSET(TXT_DOTTERM) && tp->len == tp->ai + 1 &&
tp->lb[tp->len - 1] == '.') {
-notlast: CIRCLEQ_REMOVE(tiqh, tp, q);
+notlast: TAILQ_REMOVE(tiqh, tp, q);
text_free(tp);
goto done;
}
@@ -208,7 +207,8 @@ notlast: CIRCLEQ_REMOVE(tiqh, tp, q);
* erased.
*/
if (LF_ISSET(TXT_AUTOINDENT)) {
- if (carat_st == C_NOCHANGE) {
+ if (nochange) {
+ nochange = 0;
if (v_txt_auto(sp,
OOBLNO, &ait, ait.ai, ntp))
goto err;
@@ -226,7 +226,7 @@ notlast: CIRCLEQ_REMOVE(tiqh, tp, q);
* into the queue.
*/
tp = ntp;
- CIRCLEQ_INSERT_TAIL(tiqh, tp, q);
+ TAILQ_INSERT_TAIL(tiqh, tp, q);
break;
case K_CARAT: /* Delete autoindent chars. */
if (tp->len <= tp->ai && LF_ISSET(TXT_AUTOINDENT))
@@ -291,11 +291,12 @@ notlast: CIRCLEQ_REMOVE(tiqh, tp, q);
/* Save the ai string for later. */
ait.lb = NULL;
ait.lb_len = 0;
- BINC_GOTO(sp, ait.lb, ait.lb_len, tp->ai);
- memcpy(ait.lb, tp->lb, tp->ai);
+ BINC_GOTOW(sp, ait.lb, ait.lb_len, tp->ai);
+ MEMCPY(ait.lb, tp->lb, tp->ai);
ait.ai = ait.len = tp->ai;
- carat_st = C_NOCHANGE;
+ carat_st = C_NOTSET;
+ nochange = 1;
goto leftmargin;
case C_ZEROSET: /* 0^D */
if (tp->len > tp->ai + 1)
@@ -328,7 +329,7 @@ leftmargin: (void)gp->scr_ex_adjust(sp, EX_TERM_CE);
* not already handled specially, except for <tab> and
* <ff>.
*/
-ins_ch: if (LF_ISSET(TXT_BEAUTIFY) && iscntrl(ev.e_c) &&
+ins_ch: if (LF_ISSET(TXT_BEAUTIFY) && ISCNTRL(ev.e_c) &&
ev.e_value != K_FORMFEED && ev.e_value != K_TAB)
break;
@@ -352,24 +353,20 @@ alloc_err:
* not ours.
*/
static void
-txt_prompt(sp, tp, prompt, flags)
- SCR *sp;
- TEXT *tp;
- ARG_CHAR_T prompt;
- u_int32_t flags;
+txt_prompt(SCR *sp, TEXT *tp, ARG_CHAR_T prompt, u_int32_t flags)
{
/* Display the prompt. */
if (LF_ISSET(TXT_PROMPT))
- (void)printf("%c", prompt);
+ (void)ex_printf(sp, "%c", prompt);
/* Display the line number. */
if (LF_ISSET(TXT_NUMBER) && O_ISSET(sp, O_NUMBER))
- (void)printf("%6lu ", (u_long)tp->lno);
+ (void)ex_printf(sp, "%6lu ", (u_long)tp->lno);
/* Print out autoindent string. */
if (LF_ISSET(TXT_AUTOINDENT))
- (void)printf("%.*s", (int)tp->ai, tp->lb);
- (void)fflush(stdout);
+ (void)ex_printf(sp, WVS, (int)tp->ai, tp->lb);
+ (void)ex_fflush(sp);
}
/*
@@ -380,9 +377,7 @@ txt_prompt(sp, tp, prompt, flags)
* ranting and raving. This is a fair bit simpler as ^T isn't special.
*/
static int
-txt_dent(sp, tp)
- SCR *sp;
- TEXT *tp;
+txt_dent(SCR *sp, TEXT *tp)
{
u_long sw, ts;
size_t cno, off, scno, spaces, tabs;
@@ -398,8 +393,8 @@ txt_dent(sp, tp)
++scno;
/* Get the previous shiftwidth column. */
- cno = scno;
- scno -= --scno % sw;
+ cno = scno--;
+ scno -= scno % sw;
/*
* Since we don't know what comes before the character(s) being
@@ -416,7 +411,7 @@ txt_dent(sp, tp)
spaces = scno - cno;
/* Make sure there's enough room. */
- BINC_RET(sp, tp->lb, tp->lb_len, tabs + spaces + 1);
+ BINC_RETW(sp, tp->lb, tp->lb_len, tabs + spaces + 1);
/* Adjust the final ai character count. */
tp->ai = tabs + spaces;
diff --git a/ex/ex_undo.c b/ex/ex_undo.c
index 0b0b5b26be18..9e4cd7977559 100644
--- a/ex/ex_undo.c
+++ b/ex/ex_undo.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_undo.c 10.6 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_undo.c,v 10.7 2001/06/25 15:19:21 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -30,9 +31,7 @@ static const char sccsid[] = "@(#)ex_undo.c 10.6 (Berkeley) 3/6/96";
* PUBLIC: int ex_undo __P((SCR *, EXCMD *));
*/
int
-ex_undo(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_undo(SCR *sp, EXCMD *cmdp)
{
EXF *ep;
MARK m;
diff --git a/ex/ex_usage.c b/ex/ex_usage.c
index cddf7a6643c7..9a20ce18903d 100644
--- a/ex/ex_usage.c
+++ b/ex/ex_usage.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_usage.c 10.13 (Berkeley) 5/3/96";
+static const char sccsid[] = "$Id: ex_usage.c,v 10.16 2011/12/21 19:26:48 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -34,9 +34,7 @@ static const char sccsid[] = "@(#)ex_usage.c 10.13 (Berkeley) 5/3/96";
* PUBLIC: int ex_help __P((SCR *, EXCMD *));
*/
int
-ex_help(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_help(SCR *sp, EXCMD *cmdp)
{
(void)ex_puts(sp,
"To see the list of vi commands, enter \":viusage<CR>\"\n");
@@ -57,30 +55,28 @@ ex_help(sp, cmdp)
* PUBLIC: int ex_usage __P((SCR *, EXCMD *));
*/
int
-ex_usage(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_usage(SCR *sp, EXCMD *cmdp)
{
ARGS *ap;
EXCMDLIST const *cp;
int newscreen;
- char *name, *p, nb[MAXCMDNAMELEN + 5];
+ CHAR_T *name, *p, nb[MAXCMDNAMELEN + 5];
switch (cmdp->argc) {
case 1:
ap = cmdp->argv[0];
- if (isupper(ap->bp[0])) {
+ if (ISUPPER(ap->bp[0])) {
newscreen = 1;
- ap->bp[0] = tolower(ap->bp[0]);
+ ap->bp[0] = TOLOWER(ap->bp[0]);
} else
newscreen = 0;
for (cp = cmds; cp->name != NULL &&
- memcmp(ap->bp, cp->name, ap->len); ++cp);
+ MEMCMP(ap->bp, cp->name, ap->len); ++cp);
if (cp->name == NULL ||
- newscreen && !F_ISSET(cp, E_NEWSCREEN)) {
+ (newscreen && !F_ISSET(cp, E_NEWSCREEN))) {
if (newscreen)
- ap->bp[0] = toupper(ap->bp[0]);
- (void)ex_printf(sp, "The %.*s command is unknown\n",
+ ap->bp[0] = TOUPPER(ap->bp[0]);
+ (void)ex_printf(sp, "The "WVS" command is unknown\n",
(int)ap->len, ap->bp);
} else {
(void)ex_printf(sp,
@@ -112,10 +108,10 @@ ex_usage(sp, cmdp)
* room, they're all short names.
*/
if (cp == &cmds[C_SCROLL])
- name = "^D";
+ name = L("^D");
else if (F_ISSET(cp, E_NEWSCREEN)) {
nb[0] = '[';
- nb[1] = toupper(cp->name[0]);
+ nb[1] = TOUPPER(cp->name[0]);
nb[2] = cp->name[0];
nb[3] = ']';
for (name = cp->name + 1,
@@ -124,7 +120,7 @@ ex_usage(sp, cmdp)
} else
name = cp->name;
(void)ex_printf(sp,
- "%*s: %s\n", MAXCMDNAMELEN, name, cp->help);
+ WVS": %s\n", MAXCMDNAMELEN, name, cp->help);
}
break;
default:
@@ -140,9 +136,7 @@ ex_usage(sp, cmdp)
* PUBLIC: int ex_viusage __P((SCR *, EXCMD *));
*/
int
-ex_viusage(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_viusage(SCR *sp, EXCMD *cmdp)
{
GS *gp;
VIKEYS const *kp;
diff --git a/ex/ex_util.c b/ex/ex_util.c
index 6c4772e61540..2e56a068d8ff 100644
--- a/ex/ex_util.c
+++ b/ex/ex_util.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_util.c 10.23 (Berkeley) 6/19/96";
+static const char sccsid[] = "$Id: ex_util.c,v 10.32 2001/06/25 15:19:21 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -31,15 +31,10 @@ static const char sccsid[] = "@(#)ex_util.c 10.23 (Berkeley) 6/19/96";
* ex_cinit --
* Create an EX command structure.
*
- * PUBLIC: void ex_cinit __P((EXCMD *,
- * PUBLIC: int, int, recno_t, recno_t, int, ARGS **));
+ * PUBLIC: void ex_cinit __P((SCR *, EXCMD *, int, int, recno_t, recno_t, int));
*/
void
-ex_cinit(cmdp, cmd_id, naddr, lno1, lno2, force, ap)
- EXCMD *cmdp;
- int cmd_id, force, naddr;
- recno_t lno1, lno2;
- ARGS **ap;
+ex_cinit(SCR *sp, EXCMD *cmdp, int cmd_id, int naddr, recno_t lno1, recno_t lno2, int force)
{
memset(cmdp, 0, sizeof(EXCMD));
cmdp->cmd = &cmds[cmd_id];
@@ -49,28 +44,7 @@ ex_cinit(cmdp, cmd_id, naddr, lno1, lno2, force, ap)
cmdp->addr1.cno = cmdp->addr2.cno = 1;
if (force)
cmdp->iflags |= E_C_FORCE;
- cmdp->argc = 0;
- if ((cmdp->argv = ap) != NULL)
- cmdp->argv[0] = NULL;
-}
-
-/*
- * ex_cadd --
- * Add an argument to an EX command structure.
- *
- * PUBLIC: void ex_cadd __P((EXCMD *, ARGS *, char *, size_t));
- */
-void
-ex_cadd(cmdp, ap, arg, len)
- EXCMD *cmdp;
- ARGS *ap;
- char *arg;
- size_t len;
-{
- cmdp->argv[cmdp->argc] = ap;
- ap->bp = arg;
- ap->len = len;
- cmdp->argv[++cmdp->argc] = NULL;
+ (void)argv_init(sp, cmdp);
}
/*
@@ -80,10 +54,7 @@ ex_cadd(cmdp, ap, arg, len)
* PUBLIC: int ex_getline __P((SCR *, FILE *, size_t *));
*/
int
-ex_getline(sp, fp, lenp)
- SCR *sp;
- FILE *fp;
- size_t *lenp;
+ex_getline(SCR *sp, FILE *fp, size_t *lenp)
{
EX_PRIVATE *exp;
size_t off;
@@ -93,7 +64,7 @@ ex_getline(sp, fp, lenp)
exp = EXP(sp);
for (errno = 0, off = 0, p = exp->ibp;;) {
if (off >= exp->ibp_len) {
- BINC_RET(sp, exp->ibp, exp->ibp_len, off + 1);
+ BINC_RETC(sp, exp->ibp, exp->ibp_len, off + 1);
p = exp->ibp + off;
}
if ((ch = getc(fp)) == EOF && !feof(fp)) {
@@ -123,9 +94,7 @@ ex_getline(sp, fp, lenp)
* PUBLIC: int ex_ncheck __P((SCR *, int));
*/
int
-ex_ncheck(sp, force)
- SCR *sp;
- int force;
+ex_ncheck(SCR *sp, int force)
{
char **ap;
@@ -140,7 +109,7 @@ ex_ncheck(sp, force)
for (ap = sp->cargv + 1; *ap != NULL; ++ap);
msgq(sp, M_ERR,
- "167|%d more files to edit", (ap - sp->cargv) - 1);
+ "167|%d more files to edit", (int)(ap - sp->cargv) - 1);
return (1);
}
@@ -154,8 +123,7 @@ ex_ncheck(sp, force)
* PUBLIC: int ex_init __P((SCR *));
*/
int
-ex_init(sp)
- SCR *sp;
+ex_init(SCR *sp)
{
GS *gp;
@@ -177,13 +145,27 @@ ex_init(sp)
* ex_emsg --
* Display a few common ex and vi error messages.
*
+ * PUBLIC: void ex_wemsg __P((SCR *, CHAR_T *, exm_t));
+ */
+void
+ex_wemsg(SCR* sp, CHAR_T *p, exm_t which)
+{
+ char *np;
+ size_t nlen;
+
+ if (p) INT2CHAR(sp, p, STRLEN(p), np, nlen);
+ else np = NULL;
+ ex_emsg(sp, np, which);
+}
+
+/*
+ * ex_emsg --
+ * Display a few common ex and vi error messages.
+ *
* PUBLIC: void ex_emsg __P((SCR *, char *, exm_t));
*/
void
-ex_emsg(sp, p, which)
- SCR *sp;
- char *p;
- exm_t which;
+ex_emsg(SCR *sp, char *p, exm_t which)
{
switch (which) {
case EXM_EMPTYBUF:
diff --git a/ex/ex_version.c b/ex/ex_version.c
index d7363c8bd1ac..4f0a17d714f8 100644
--- a/ex/ex_version.c
+++ b/ex/ex_version.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_version.c 10.31 (Berkeley) 8/22/96";
+static const char sccsid[] = "$Id: ex_version.c,v 10.32 2001/06/25 15:19:22 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -30,10 +31,9 @@ static const char sccsid[] = "@(#)ex_version.c 10.31 (Berkeley) 8/22/96";
* PUBLIC: int ex_version __P((SCR *, EXCMD *));
*/
int
-ex_version(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_version(SCR *sp, EXCMD *cmdp)
{
- msgq(sp, M_INFO, VI_VERSION);
+ msgq(sp, M_INFO, "Version "VI_VERSION
+ " The CSRG, University of California, Berkeley.");
return (0);
}
diff --git a/ex/ex_visual.c b/ex/ex_visual.c
index 82e503d44658..f913c71d81fc 100644
--- a/ex/ex_visual.c
+++ b/ex/ex_visual.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_visual.c 10.13 (Berkeley) 6/28/96";
+static const char sccsid[] = "$Id: ex_visual.c,v 10.16 2001/08/29 11:04:13 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -34,14 +34,14 @@ static const char sccsid[] = "@(#)ex_visual.c 10.13 (Berkeley) 6/28/96";
* PUBLIC: int ex_visual __P((SCR *, EXCMD *));
*/
int
-ex_visual(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_visual(SCR *sp, EXCMD *cmdp)
{
SCR *tsp;
size_t len;
int pos;
char buf[256];
+ size_t wlen;
+ CHAR_T *wp;
/* If open option off, disallow visual command. */
if (!O_ISSET(sp, O_OPEN)) {
@@ -81,10 +81,11 @@ ex_visual(sp, cmdp)
if (FL_ISSET(cmdp->iflags, E_C_COUNT))
len = snprintf(buf, sizeof(buf),
- "%luz%c%lu", sp->lno, pos, cmdp->count);
+ "%luz%c%lu", (u_long)sp->lno, pos, cmdp->count);
else
- len = snprintf(buf, sizeof(buf), "%luz%c", sp->lno, pos);
- (void)v_event_push(sp, NULL, buf, len, CH_NOMAP | CH_QUOTED);
+ len = snprintf(buf, sizeof(buf), "%luz%c", (u_long)sp->lno, pos);
+ CHAR2INT(sp, buf, len, wp, wlen);
+ (void)v_event_push(sp, NULL, wp, wlen, CH_NOMAP | CH_QUOTED);
/*
* !!!
@@ -129,6 +130,7 @@ nopush: /*
*/
++sp->refcnt;
++sp->ep->refcnt;
+ /* XXXX where is this decremented ? */
/*
* Fake up a screen pointer -- vi doesn't get to change our
diff --git a/ex/ex_write.c b/ex/ex_write.c
index b3122e353563..1f94a632ed5b 100644
--- a/ex/ex_write.c
+++ b/ex/ex_write.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_write.c 10.30 (Berkeley) 7/12/96";
+static const char sccsid[] = "$Id: ex_write.c,v 10.41 2011/12/02 01:07:06 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -25,6 +25,7 @@ static const char sccsid[] = "@(#)ex_write.c 10.30 (Berkeley) 7/12/96";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include "../common/common.h"
@@ -39,9 +40,7 @@ static int exwr __P((SCR *, EXCMD *, enum which));
* PUBLIC: int ex_wn __P((SCR *, EXCMD *));
*/
int
-ex_wn(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_wn(SCR *sp, EXCMD *cmdp)
{
if (exwr(sp, cmdp, WN))
return (1);
@@ -61,9 +60,7 @@ ex_wn(sp, cmdp)
* PUBLIC: int ex_wq __P((SCR *, EXCMD *));
*/
int
-ex_wq(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_wq(SCR *sp, EXCMD *cmdp)
{
int force;
@@ -89,9 +86,7 @@ ex_wq(sp, cmdp)
* PUBLIC: int ex_write __P((SCR *, EXCMD *));
*/
int
-ex_write(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_write(SCR *sp, EXCMD *cmdp)
{
return (exwr(sp, cmdp, WRITE));
}
@@ -104,9 +99,7 @@ ex_write(sp, cmdp)
* PUBLIC: int ex_xit __P((SCR *, EXCMD *));
*/
int
-ex_xit(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_xit(SCR *sp, EXCMD *cmdp)
{
int force;
@@ -131,14 +124,16 @@ ex_xit(sp, cmdp)
* The guts of the ex write commands.
*/
static int
-exwr(sp, cmdp, cmd)
- SCR *sp;
- EXCMD *cmdp;
- enum which cmd;
+exwr(SCR *sp, EXCMD *cmdp, enum which cmd)
{
MARK rm;
int flags;
- char *name, *p;
+ char *name;
+ CHAR_T *p = NULL;
+ size_t nlen;
+ char *n;
+ int rc;
+ EX_PRIVATE *exp;
NEEDFILE(sp, cmdp);
@@ -149,25 +144,31 @@ exwr(sp, cmdp, cmd)
/* Skip any leading whitespace. */
if (cmdp->argc != 0)
- for (p = cmdp->argv[0]->bp; *p != '\0' && isblank(*p); ++p);
+ for (p = cmdp->argv[0]->bp; *p != '\0' && cmdskip(*p); ++p);
/* If "write !" it's a pipe to a utility. */
if (cmdp->argc != 0 && cmd == WRITE && *p == '!') {
/* Secure means no shell access. */
if (O_ISSET(sp, O_SECURE)) {
- ex_emsg(sp, cmdp->cmd->name, EXM_SECURE_F);
+ ex_wemsg(sp, cmdp->cmd->name, EXM_SECURE_F);
return (1);
}
/* Expand the argument. */
- for (++p; *p && isblank(*p); ++p);
+ for (++p; *p && cmdskip(*p); ++p);
if (*p == '\0') {
ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
return (1);
}
- if (argv_exp1(sp, cmdp, p, strlen(p), 1))
+ if (argv_exp1(sp, cmdp, p, STRLEN(p), 1))
return (1);
+ /* Set the last bang command */
+ exp = EXP(sp);
+ free(exp->lastbcomm);
+ exp->lastbcomm = v_wstrdup(sp, cmdp->argv[1]->bp,
+ cmdp->argv[1]->len);
+
/*
* Historically, vi waited after a write filter even if there
* wasn't any output from the command. People complained when
@@ -201,7 +202,7 @@ exwr(sp, cmdp, cmd)
LF_SET(FS_APPEND);
/* Skip ">>" and whitespace. */
- for (p += 2; *p && isblank(*p); ++p);
+ for (p += 2; *p && cmdskip(*p); ++p);
}
/* If no other arguments, just write the file back. */
@@ -210,7 +211,7 @@ exwr(sp, cmdp, cmd)
&cmdp->addr1, &cmdp->addr2, NULL, flags));
/* Build an argv so we get an argument count and file expansion. */
- if (argv_exp2(sp, cmdp, p, strlen(p)))
+ if (argv_exp2(sp, cmdp, p, STRLEN(p)))
return (1);
/*
@@ -228,7 +229,9 @@ exwr(sp, cmdp, cmd)
abort();
/* NOTREACHED */
case 2:
- name = cmdp->argv[1]->bp;
+ INT2CHAR(sp, cmdp->argv[1]->bp, cmdp->argv[1]->len+1,
+ n, nlen);
+ name = v_strdup(sp, n, nlen - 1);
/*
* !!!
@@ -238,10 +241,9 @@ exwr(sp, cmdp, cmd)
*/
if (F_ISSET(sp->frp, FR_TMPFILE) &&
!F_ISSET(sp->frp, FR_EXNAMED)) {
- if ((p = v_strdup(sp,
- cmdp->argv[1]->bp, cmdp->argv[1]->len)) != NULL) {
+ if ((n = v_strdup(sp, name, nlen - 1)) != NULL) {
free(sp->frp->name);
- sp->frp->name = p;
+ sp->frp->name = n;
}
/*
* The file has a real name, it's no longer a
@@ -261,11 +263,16 @@ exwr(sp, cmdp, cmd)
set_alt_name(sp, name);
break;
default:
- ex_emsg(sp, p, EXM_FILECOUNT);
+ INT2CHAR(sp, p, STRLEN(p) + 1, n, nlen);
+ ex_emsg(sp, n, EXM_FILECOUNT);
return (1);
}
- return (file_write(sp, &cmdp->addr1, &cmdp->addr2, name, flags));
+ rc = file_write(sp, &cmdp->addr1, &cmdp->addr2, name, flags);
+
+ free(name);
+
+ return rc;
}
/*
@@ -276,13 +283,7 @@ exwr(sp, cmdp, cmd)
* PUBLIC: char *, FILE *, MARK *, MARK *, u_long *, u_long *, int));
*/
int
-ex_writefp(sp, name, fp, fm, tm, nlno, nch, silent)
- SCR *sp;
- char *name;
- FILE *fp;
- MARK *fm, *tm;
- u_long *nlno, *nch;
- int silent;
+ex_writefp(SCR *sp, char *name, FILE *fp, MARK *fm, MARK *tm, u_long *nlno, u_long *nch, int silent)
{
struct stat sb;
GS *gp;
@@ -290,7 +291,11 @@ ex_writefp(sp, name, fp, fm, tm, nlno, nch, silent)
recno_t fline, tline, lcnt;
size_t len;
int rval;
- char *msg, *p;
+ char *msg;
+ CHAR_T *p;
+ char *f;
+ size_t flen;
+ int isutf16;
gp = sp->gp;
fline = fm->lno;
@@ -319,7 +324,17 @@ ex_writefp(sp, name, fp, fm, tm, nlno, nch, silent)
ccnt = 0;
lcnt = 0;
msg = "253|Writing...";
- if (tline != 0)
+
+ if (O_ISSET(sp, O_FILEENCODING)) {
+ isutf16 = !strncasecmp(O_STR(sp, O_FILEENCODING), "utf-16", 6);
+ isutf16 += !strncasecmp(O_STR(sp, O_FILEENCODING), "utf-16le", 8);
+ } else isutf16 = 0;
+
+ if (tline != 0) {
+ if (isutf16 == 1 && fwrite("\xfe\xff", 1, 2, fp) != 2)
+ goto err;
+ if (isutf16 == 2 && fwrite("\xff\xfe", 1, 2, fp) != 2)
+ goto err;
for (; fline <= tline; ++fline, ++lcnt) {
/* Caller has to provide any interrupt message. */
if ((lcnt + 1) % INTERRUPT_CHECK == 0) {
@@ -333,15 +348,29 @@ ex_writefp(sp, name, fp, fm, tm, nlno, nch, silent)
}
if (db_get(sp, fline, DBG_FATAL, &p, &len))
goto err;
- if (fwrite(p, 1, len, fp) != len)
+ INT2FILE(sp, p, len, f, flen);
+ if (fwrite(f, 1, flen, fp) != flen)
goto err;
ccnt += len;
- if (putc('\n', fp) != '\n')
+ /* UTF-16 w/o BOM is big-endian */
+ switch (isutf16) {
+ case 1: /* UTF-16BE */
+ if (fwrite("\0\x0a", 1, 2, fp) != 2)
+ goto done;
+ break;
+ case 2: /* UTF-16LE */
+ if (fwrite("\x0a\0", 1, 2, fp) != 2)
+ goto done;
break;
+ default:
+ if (putc('\n', fp) != '\n')
+ goto done;
+ }
++ccnt;
}
+ }
- if (fflush(fp))
+done: if (fflush(fp))
goto err;
/*
* XXX
diff --git a/ex/ex_yank.c b/ex/ex_yank.c
index 778dc7dee62c..262c78f978bc 100644
--- a/ex/ex_yank.c
+++ b/ex/ex_yank.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_yank.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_yank.c,v 10.8 2001/06/25 15:19:22 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -29,9 +30,7 @@ static const char sccsid[] = "@(#)ex_yank.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int ex_yank __P((SCR *, EXCMD *));
*/
int
-ex_yank(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_yank(SCR *sp, EXCMD *cmdp)
{
NEEDFILE(sp, cmdp);
diff --git a/ex/ex_z.c b/ex/ex_z.c
index 41b72ad1fd42..18a78590ded5 100644
--- a/ex/ex_z.c
+++ b/ex/ex_z.c
@@ -10,11 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_z.c 10.10 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: ex_z.c,v 10.12 2001/06/25 15:19:22 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -31,9 +32,7 @@ static const char sccsid[] = "@(#)ex_z.c 10.10 (Berkeley) 3/6/96";
* PUBLIC: int ex_z __P((SCR *, EXCMD *));
*/
int
-ex_z(sp, cmdp)
- SCR *sp;
- EXCMD *cmdp;
+ex_z(SCR *sp, EXCMD *cmdp)
{
MARK abs;
recno_t cnt, equals, lno;
@@ -55,7 +54,7 @@ ex_z(sp, cmdp)
if (FL_ISSET(cmdp->iflags, E_C_COUNT))
cnt = cmdp->count;
else
-#ifdef HISTORIC_PRACTICE
+#ifdef HISTORICAL_PRACTICE
cnt = O_VAL(sp, O_SCROLL) * 2;
#else
cnt = O_VAL(sp, O_WINDOW) - 1;
diff --git a/include/ex_extern.h b/ex/extern.h
index ed01701f1185..f54548b4cf09 100644
--- a/include/ex_extern.h
+++ b/ex/extern.h
@@ -1,8 +1,8 @@
int ex __P((SCR **));
int ex_cmd __P((SCR *));
int ex_range __P((SCR *, EXCMD *, int *));
-int ex_is_abbrev __P((char *, size_t));
-int ex_is_unmap __P((char *, size_t));
+int ex_is_abbrev __P((CHAR_T *, size_t));
+int ex_is_unmap __P((CHAR_T *, size_t));
void ex_badaddr
__P((SCR *, EXCMDLIST const *, enum badaddr, enum nresult));
int ex_abbr __P((SCR *, EXCMD *));
@@ -16,15 +16,20 @@ int ex_rew __P((SCR *, EXCMD *));
int ex_args __P((SCR *, EXCMD *));
char **ex_buildargv __P((SCR *, EXCMD *, char *));
int argv_init __P((SCR *, EXCMD *));
-int argv_exp0 __P((SCR *, EXCMD *, char *, size_t));
-int argv_exp1 __P((SCR *, EXCMD *, char *, size_t, int));
-int argv_exp2 __P((SCR *, EXCMD *, char *, size_t));
-int argv_exp3 __P((SCR *, EXCMD *, char *, size_t));
+int argv_exp0 __P((SCR *, EXCMD *, CHAR_T *, size_t));
+int argv_exp1 __P((SCR *, EXCMD *, CHAR_T *, size_t, int));
+int argv_exp2 __P((SCR *, EXCMD *, CHAR_T *, size_t));
+int argv_exp3 __P((SCR *, EXCMD *, CHAR_T *, size_t));
+int argv_flt_ex __P((SCR *, EXCMD *, CHAR_T *, size_t));
int argv_free __P((SCR *));
+int argv_flt_path __P((SCR *, EXCMD *, CHAR_T *, size_t));
+CHAR_T *argv_esc __P((SCR *, EXCMD *, CHAR_T *, size_t));
+CHAR_T *argv_uesc __P((SCR *, EXCMD *, CHAR_T *, size_t));
int ex_at __P((SCR *, EXCMD *));
int ex_bang __P((SCR *, EXCMD *));
int ex_cd __P((SCR *, EXCMD *));
int ex_cscope __P((SCR *, EXCMD *));
+int cscope_end __P((SCR *));
int cscope_display __P((SCR *));
int cscope_search __P((SCR *, TAGQ *, TAG *));
int ex_delete __P((SCR *, EXCMD *));
@@ -33,7 +38,7 @@ int ex_edit __P((SCR *, EXCMD *));
int ex_equal __P((SCR *, EXCMD *));
int ex_file __P((SCR *, EXCMD *));
int ex_filter __P((SCR *,
- EXCMD *, MARK *, MARK *, MARK *, char *, enum filtertype));
+ EXCMD *, MARK *, MARK *, MARK *, CHAR_T *, enum filtertype));
int ex_global __P((SCR *, EXCMD *));
int ex_v __P((SCR *, EXCMD *));
int ex_g_insdel __P((SCR *, lnop_t, recno_t));
@@ -41,7 +46,7 @@ int ex_screen_copy __P((SCR *, SCR *));
int ex_screen_end __P((SCR *));
int ex_optchange __P((SCR *, int, char *, u_long *));
int ex_exrc __P((SCR *));
-int ex_run_str __P((SCR *, char *, char *, size_t, int, int));
+int ex_run_str __P((SCR *, char *, CHAR_T *, size_t, int, int));
int ex_join __P((SCR *, EXCMD *));
int ex_map __P((SCR *, EXCMD *));
int ex_unmap __P((SCR *, EXCMD *));
@@ -50,14 +55,13 @@ int ex_mkexrc __P((SCR *, EXCMD *));
int ex_copy __P((SCR *, EXCMD *));
int ex_move __P((SCR *, EXCMD *));
int ex_open __P((SCR *, EXCMD *));
-int ex_perl __P((SCR*, EXCMD *));
int ex_preserve __P((SCR *, EXCMD *));
int ex_recover __P((SCR *, EXCMD *));
int ex_list __P((SCR *, EXCMD *));
int ex_number __P((SCR *, EXCMD *));
int ex_pr __P((SCR *, EXCMD *));
int ex_print __P((SCR *, EXCMD *, MARK *, MARK *, u_int32_t));
-int ex_ldisplay __P((SCR *, const char *, size_t, size_t, u_int));
+int ex_ldisplay __P((SCR *, const CHAR_T *, size_t, size_t, u_int));
int ex_scprint __P((SCR *, MARK *, MARK *));
int ex_printf __P((SCR *, const char *, ...));
int ex_puts __P((SCR *, const char *));
@@ -86,9 +90,9 @@ int ex_s __P((SCR *, EXCMD *));
int ex_subagain __P((SCR *, EXCMD *));
int ex_subtilde __P((SCR *, EXCMD *));
int re_compile __P((SCR *,
- char *, size_t, char **, size_t *, regex_t *, u_int));
+ CHAR_T *, size_t, CHAR_T **, size_t *, regex_t *, u_int));
void re_error __P((SCR *, int, regex_t *));
-int ex_tag_first __P((SCR *, char *));
+int ex_tag_first __P((SCR *, CHAR_T *));
int ex_tag_push __P((SCR *, EXCMD *));
int ex_tag_next __P((SCR *, EXCMD *));
int ex_tag_prev __P((SCR *, EXCMD *));
@@ -99,21 +103,20 @@ int ex_tag_top __P((SCR *, EXCMD *));
int ex_tag_display __P((SCR *));
int ex_tag_copy __P((SCR *, SCR *));
int tagq_free __P((SCR *, TAGQ *));
+int tagq_push __P((SCR*, TAGQ*, int, int ));
void tag_msg __P((SCR *, tagmsg_t, char *));
int ex_tagf_alloc __P((SCR *, char *));
int ex_tag_free __P((SCR *));
-int ex_tcl __P((SCR*, EXCMD *));
int ex_txt __P((SCR *, TEXTH *, ARG_CHAR_T, u_int32_t));
int ex_undo __P((SCR *, EXCMD *));
int ex_help __P((SCR *, EXCMD *));
int ex_usage __P((SCR *, EXCMD *));
int ex_viusage __P((SCR *, EXCMD *));
-void ex_cinit __P((EXCMD *,
- int, int, recno_t, recno_t, int, ARGS **));
-void ex_cadd __P((EXCMD *, ARGS *, char *, size_t));
+void ex_cinit __P((SCR *, EXCMD *, int, int, recno_t, recno_t, int));
int ex_getline __P((SCR *, FILE *, size_t *));
int ex_ncheck __P((SCR *, int));
int ex_init __P((SCR *));
+void ex_wemsg __P((SCR *, CHAR_T *, exm_t));
void ex_emsg __P((SCR *, char *, exm_t));
int ex_version __P((SCR *, EXCMD *));
int ex_visual __P((SCR *, EXCMD *));
diff --git a/ex/script.h b/ex/script.h
index e29f63347961..3952e96aea1e 100644
--- a/ex/script.h
+++ b/ex/script.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)script.h 10.2 (Berkeley) 3/6/96
+ * $Id: script.h,v 10.3 2012/04/21 23:51:46 zy Exp $
*/
struct _script {
@@ -16,8 +16,6 @@ struct _script {
char *sh_prompt; /* Prompt. */
size_t sh_prompt_len; /* Prompt length. */
char sh_name[64]; /* Pty name */
-#ifdef TIOCGWINSZ
struct winsize sh_win; /* Window size. */
-#endif
struct termios sh_term; /* Terminal information. */
};
diff --git a/ex/tag.h b/ex/tag.h
index aee3dd27471d..7d3b2476575b 100644
--- a/ex/tag.h
+++ b/ex/tag.h
@@ -8,7 +8,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)tag.h 10.5 (Berkeley) 5/15/96
+ * $Id: tag.h,v 10.9 2012/07/06 16:38:36 zy Exp $
*/
/*
@@ -16,12 +16,12 @@
* connection, linked from the EX_PRIVATE structure.
*/
struct _csc {
- LIST_ENTRY(_csc) q; /* Linked list of cscope connections. */
+ SLIST_ENTRY(_csc) q; /* Linked list of cscope connections. */
- char *dname; /* Base directory of this cscope connection. */
- size_t dlen; /* Length of base directory. */
- pid_t pid; /* PID of the connected cscope process. */
- time_t mtime; /* Last modification time of cscope database. */
+ char *dname; /* Base directory of this cscope connection. */
+ size_t dlen; /* Length of base directory. */
+ pid_t pid; /* PID of the connected cscope process. */
+ struct timespec mtim; /* Last modification time of cscope database. */
FILE *from_fp; /* from cscope: FILE. */
int from_fd; /* from cscope: file descriptor. */
@@ -74,7 +74,7 @@ struct _tagf { /* Tag files. */
* tagtop: discard all Q
*/
struct _tag { /* Tag list. */
- CIRCLEQ_ENTRY(_tag) q; /* Linked list of tags. */
+ TAILQ_ENTRY(_tag) q; /* Linked list of tags. */
/* Tag pop/return information. */
FREF *frp; /* Saved file. */
@@ -84,16 +84,18 @@ struct _tag { /* Tag list. */
char *fname; /* Filename. */
size_t fnlen; /* Filename length. */
recno_t slno; /* Search line number. */
- char *search; /* Search string. */
+ CHAR_T *search; /* Search string. */
size_t slen; /* Search string length. */
+ CHAR_T *msg; /* Message string. */
+ size_t mlen; /* Message string length. */
- char buf[1]; /* Variable length buffer. */
+ CHAR_T buf[1]; /* Variable length buffer. */
};
struct _tagq { /* Tag queue. */
- CIRCLEQ_ENTRY(_tagq) q; /* Linked list of tag queues. */
+ TAILQ_ENTRY(_tagq) q; /* Linked list of tag queues. */
/* This queue's tag list. */
- CIRCLEQ_HEAD(_tagqh, _tag) tagq;
+ TAILQ_HEAD(_tagqh, _tag) tagq[1];
TAG *current; /* Current TAG within the queue. */
diff --git a/ex/version.h b/ex/version.h
index 7d657b635fc2..295dd8e68b62 100644
--- a/ex/version.h
+++ b/ex/version.h
@@ -1,2 +1 @@
-#define VI_VERSION \
- "Version 1.79 (10/23/96) The CSRG, University of California, Berkeley."
+#define VI_VERSION "2.1.1 (2012-10-07)"
diff --git a/include/bitstring.h b/include/bitstring.h
deleted file mode 100644
index 88437e7fb9f7..000000000000
--- a/include/bitstring.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Vixie.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)bitstring.h 8.1 (Berkeley) 7/19/93
- */
-
-#ifndef _BITSTRING_H_
-#define _BITSTRING_H_
-
-typedef unsigned char bitstr_t;
-
-/* internal macros */
- /* byte of the bitstring bit is in */
-#define _bit_byte(bit) \
- ((bit) >> 3)
-
- /* mask for the bit within its byte */
-#define _bit_mask(bit) \
- (1 << ((bit)&0x7))
-
-/* external macros */
- /* bytes in a bitstring of nbits bits */
-#define bitstr_size(nbits) \
- ((((nbits) - 1) >> 3) + 1)
-
- /* allocate a bitstring */
-#define bit_alloc(nbits) \
- (bitstr_t *)calloc(1, \
- (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
-
- /* allocate a bitstring on the stack */
-#define bit_decl(name, nbits) \
- (name)[bitstr_size(nbits)]
-
- /* is bit N of bitstring name set? */
-#define bit_test(name, bit) \
- ((name)[_bit_byte(bit)] & _bit_mask(bit))
-
- /* set bit N of bitstring name */
-#define bit_set(name, bit) \
- (name)[_bit_byte(bit)] |= _bit_mask(bit)
-
- /* clear bit N of bitstring name */
-#define bit_clear(name, bit) \
- (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
-
- /* clear bits start ... stop in bitstring */
-#define bit_nclear(name, start, stop) { \
- register bitstr_t *_name = name; \
- register int _start = start, _stop = stop; \
- register int _startbyte = _bit_byte(_start); \
- register int _stopbyte = _bit_byte(_stop); \
- if (_startbyte == _stopbyte) { \
- _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
- (0xff << ((_stop&0x7) + 1))); \
- } else { \
- _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
- while (++_startbyte < _stopbyte) \
- _name[_startbyte] = 0; \
- _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
- } \
-}
-
- /* set bits start ... stop in bitstring */
-#define bit_nset(name, start, stop) { \
- register bitstr_t *_name = name; \
- register int _start = start, _stop = stop; \
- register int _startbyte = _bit_byte(_start); \
- register int _stopbyte = _bit_byte(_stop); \
- if (_startbyte == _stopbyte) { \
- _name[_startbyte] |= ((0xff << (_start&0x7)) & \
- (0xff >> (7 - (_stop&0x7)))); \
- } else { \
- _name[_startbyte] |= 0xff << ((_start)&0x7); \
- while (++_startbyte < _stopbyte) \
- _name[_startbyte] = 0xff; \
- _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
- } \
-}
-
- /* find first bit clear in name */
-#define bit_ffc(name, nbits, value) { \
- register bitstr_t *_name = name; \
- register int _byte, _nbits = nbits; \
- register int _stopbyte = _bit_byte(_nbits), _value = -1; \
- for (_byte = 0; _byte <= _stopbyte; ++_byte) \
- if (_name[_byte] != 0xff) { \
- _value = _byte << 3; \
- for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
- ++_value, _stopbyte >>= 1); \
- break; \
- } \
- *(value) = _value; \
-}
-
- /* find first bit set in name */
-#define bit_ffs(name, nbits, value) { \
- register bitstr_t *_name = name; \
- register int _byte, _nbits = nbits; \
- register int _stopbyte = _bit_byte(_nbits), _value = -1; \
- for (_byte = 0; _byte <= _stopbyte; ++_byte) \
- if (_name[_byte]) { \
- _value = _byte << 3; \
- for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
- ++_value, _stopbyte >>= 1); \
- break; \
- } \
- *(value) = _value; \
-}
-
-#endif /* !_BITSTRING_H_ */
diff --git a/include/ex_def.h b/include/ex_def.h
deleted file mode 100644
index 2e69b4872f59..000000000000
--- a/include/ex_def.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#define C_SCROLL 0
-#define C_BANG 1
-#define C_HASH 2
-#define C_SUBAGAIN 3
-#define C_STAR 4
-#define C_SHIFTL 5
-#define C_EQUAL 6
-#define C_SHIFTR 7
-#define C_AT 8
-#define C_APPEND 9
-#define C_ABBR 10
-#define C_ARGS 11
-#define C_BG 12
-#define C_CHANGE 13
-#define C_CD 14
-#define C_CHDIR 15
-#define C_COPY 16
-#define C_CSCOPE 17
-#define C_DELETE 18
-#define C_DISPLAY 19
-#define C_EDIT 20
-#define C_EX 21
-#define C_EXUSAGE 22
-#define C_FILE 23
-#define C_FG 24
-#define C_GLOBAL 25
-#define C_HELP 26
-#define C_INSERT 27
-#define C_JOIN 28
-#define C_K 29
-#define C_LIST 30
-#define C_MOVE 31
-#define C_MARK 32
-#define C_MAP 33
-#define C_MKEXRC 34
-#define C_NEXT 35
-#define C_NUMBER 36
-#define C_OPEN 37
-#define C_PRINT 38
-#define C_PERLCMD 39
-#define C_PERLDOCMD 40
-#define C_PRESERVE 41
-#define C_PREVIOUS 42
-#define C_PUT 43
-#define C_QUIT 44
-#define C_READ 45
-#define C_RECOVER 46
-#define C_RESIZE 47
-#define C_REWIND 48
-#define C_SUBSTITUTE 49
-#define C_SCRIPT 50
-#define C_SET 51
-#define C_SHELL 52
-#define C_SOURCE 53
-#define C_STOP 54
-#define C_SUSPEND 55
-#define C_T 56
-#define C_TAG 57
-#define C_TAGNEXT 58
-#define C_TAGPOP 59
-#define C_TAGPREV 60
-#define C_TAGTOP 61
-#define C_TCLCMD 62
-#define C_UNDO 63
-#define C_UNABBREVIATE 64
-#define C_UNMAP 65
-#define C_V 66
-#define C_VERSION 67
-#define C_VISUAL_EX 68
-#define C_VISUAL_VI 69
-#define C_VIUSAGE 70
-#define C_WRITE 71
-#define C_WN 72
-#define C_WQ 73
-#define C_XIT 74
-#define C_YANK 75
-#define C_Z 76
-#define C_SUBTILDE 77
diff --git a/include/ip_extern.h b/include/ip_extern.h
deleted file mode 100644
index b805343a8e81..000000000000
--- a/include/ip_extern.h
+++ /dev/null
@@ -1,23 +0,0 @@
-int ip_addstr __P((SCR *, const char *, size_t));
-int ip_attr __P((SCR *, scr_attr_t, int));
-int ip_baud __P((SCR *, u_long *));
-int ip_bell __P((SCR *));
-void ip_busy __P((SCR *, const char *, busy_t));
-int ip_clrtoeol __P((SCR *));
-int ip_cursor __P((SCR *, size_t *, size_t *));
-int ip_deleteln __P((SCR *));
-int ip_ex_adjust __P((SCR *, exadj_t));
-int ip_insertln __P((SCR *));
-int ip_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
-int ip_move __P((SCR *, size_t, size_t));
-int ip_refresh __P((SCR *, int));
-int ip_rename __P((SCR *));
-int ip_suspend __P((SCR *, int *));
-void ip_usage __P((void));
-int ip_event __P((SCR *, EVENT *, u_int32_t, int));
-int ip_screen __P((SCR *, u_int32_t));
-int ip_quit __P((GS *));
-int ip_term_init __P((SCR *));
-int ip_term_end __P((GS *));
-int ip_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
-int ip_optchange __P((SCR *, int, char *, u_long *));
diff --git a/include/options_def.h b/include/options_def.h
deleted file mode 100644
index 089fa7f4ea4c..000000000000
--- a/include/options_def.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#define O_ALTWERASE 0
-#define O_AUTOINDENT 1
-#define O_AUTOPRINT 2
-#define O_AUTOWRITE 3
-#define O_BACKUP 4
-#define O_BEAUTIFY 5
-#define O_CDPATH 6
-#define O_CEDIT 7
-#define O_COLUMNS 8
-#define O_COMMENT 9
-#define O_DIRECTORY 10
-#define O_EDCOMPATIBLE 11
-#define O_ESCAPETIME 12
-#define O_ERRORBELLS 13
-#define O_EXRC 14
-#define O_EXTENDED 15
-#define O_FILEC 16
-#define O_FLASH 17
-#define O_HARDTABS 18
-#define O_ICLOWER 19
-#define O_IGNORECASE 20
-#define O_KEYTIME 21
-#define O_LEFTRIGHT 22
-#define O_LINES 23
-#define O_LISP 24
-#define O_LIST 25
-#define O_LOCKFILES 26
-#define O_MAGIC 27
-#define O_MATCHTIME 28
-#define O_MESG 29
-#define O_MODELINE 30
-#define O_MSGCAT 31
-#define O_NOPRINT 32
-#define O_NUMBER 33
-#define O_OCTAL 34
-#define O_OPEN 35
-#define O_OPTIMIZE 36
-#define O_PARAGRAPHS 37
-#define O_PATH 38
-#define O_PRINT 39
-#define O_PROMPT 40
-#define O_READONLY 41
-#define O_RECDIR 42
-#define O_REDRAW 43
-#define O_REMAP 44
-#define O_REPORT 45
-#define O_RULER 46
-#define O_SCROLL 47
-#define O_SEARCHINCR 48
-#define O_SECTIONS 49
-#define O_SECURE 50
-#define O_SHELL 51
-#define O_SHELLMETA 52
-#define O_SHIFTWIDTH 53
-#define O_SHOWMATCH 54
-#define O_SHOWMODE 55
-#define O_SIDESCROLL 56
-#define O_SLOWOPEN 57
-#define O_SOURCEANY 58
-#define O_TABSTOP 59
-#define O_TAGLENGTH 60
-#define O_TAGS 61
-#define O_TERM 62
-#define O_TERSE 63
-#define O_TILDEOP 64
-#define O_TIMEOUT 65
-#define O_TTYWERASE 66
-#define O_VERBOSE 67
-#define O_W1200 68
-#define O_W300 69
-#define O_W9600 70
-#define O_WARN 71
-#define O_WINDOW 72
-#define O_WINDOWNAME 73
-#define O_WRAPLEN 74
-#define O_WRAPMARGIN 75
-#define O_WRAPSCAN 76
-#define O_WRITEANY 77
-#define O_OPTIONCOUNT 78
diff --git a/include/perl_extern.h b/include/perl_extern.h
deleted file mode 100644
index 5d6dd0d33bb6..000000000000
--- a/include/perl_extern.h
+++ /dev/null
@@ -1,8 +0,0 @@
-int perl_end __P((GS *));
-int perl_init __P((SCR *));
-int perl_screen_end __P((SCR*));
-int perl_ex_perl __P((SCR*, CHAR_T *, size_t, recno_t, recno_t));
-int perl_ex_perldo __P((SCR*, CHAR_T *, size_t, recno_t, recno_t));
-#ifdef USE_SFIO
-Sfdisc_t* sfdcnewnvi __P((SCR*));
-#endif
diff --git a/include/sys/queue.h b/include/sys/queue.h
deleted file mode 100644
index cbd75864ecda..000000000000
--- a/include/sys/queue.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)queue.h 8.5 (Berkeley) 8/20/94
- */
-
-#ifndef _SYS_QUEUE_H_
-#define _SYS_QUEUE_H_
-
-/*
- * This file defines three types of data structures: lists, tail queues,
- * and circular queues.
- *
- * A list is headed by a single forward pointer (or an array of forward
- * pointers for a hash table header). The elements are doubly linked
- * so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before
- * or after an existing element or at the head of the list. A list
- * may only be traversed in the forward direction.
- *
- * A tail queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or
- * after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may only be traversed in the forward direction.
- *
- * A circle queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or after
- * an existing element, at the head of the list, or at the end of the list.
- * A circle queue may be traversed in either direction, but has a more
- * complex end of list detection.
- *
- * For details on the use of these macros, see the queue(3) manual page.
- */
-
-/*
- * List definitions.
- */
-#define LIST_HEAD(name, type) \
-struct name { \
- struct type *lh_first; /* first element */ \
-}
-
-#define LIST_ENTRY(type) \
-struct { \
- struct type *le_next; /* next element */ \
- struct type **le_prev; /* address of previous next element */ \
-}
-
-/*
- * List functions.
- */
-#define LIST_INIT(head) { \
- (head)->lh_first = NULL; \
-}
-
-#define LIST_INSERT_AFTER(listelm, elm, field) { \
- if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
- (listelm)->field.le_next->field.le_prev = \
- &(elm)->field.le_next; \
- (listelm)->field.le_next = (elm); \
- (elm)->field.le_prev = &(listelm)->field.le_next; \
-}
-
-#define LIST_INSERT_BEFORE(listelm, elm, field) { \
- (elm)->field.le_prev = (listelm)->field.le_prev; \
- (elm)->field.le_next = (listelm); \
- *(listelm)->field.le_prev = (elm); \
- (listelm)->field.le_prev = &(elm)->field.le_next; \
-}
-
-#define LIST_INSERT_HEAD(head, elm, field) { \
- if (((elm)->field.le_next = (head)->lh_first) != NULL) \
- (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
- (head)->lh_first = (elm); \
- (elm)->field.le_prev = &(head)->lh_first; \
-}
-
-#define LIST_REMOVE(elm, field) { \
- if ((elm)->field.le_next != NULL) \
- (elm)->field.le_next->field.le_prev = \
- (elm)->field.le_prev; \
- *(elm)->field.le_prev = (elm)->field.le_next; \
-}
-
-/*
- * Tail queue definitions.
- */
-#define TAILQ_HEAD(name, type) \
-struct name { \
- struct type *tqh_first; /* first element */ \
- struct type **tqh_last; /* addr of last next element */ \
-}
-
-#define TAILQ_ENTRY(type) \
-struct { \
- struct type *tqe_next; /* next element */ \
- struct type **tqe_prev; /* address of previous next element */ \
-}
-
-/*
- * Tail queue functions.
- */
-#define TAILQ_INIT(head) { \
- (head)->tqh_first = NULL; \
- (head)->tqh_last = &(head)->tqh_first; \
-}
-
-#define TAILQ_INSERT_HEAD(head, elm, field) { \
- if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
- (head)->tqh_first->field.tqe_prev = \
- &(elm)->field.tqe_next; \
- else \
- (head)->tqh_last = &(elm)->field.tqe_next; \
- (head)->tqh_first = (elm); \
- (elm)->field.tqe_prev = &(head)->tqh_first; \
-}
-
-#define TAILQ_INSERT_TAIL(head, elm, field) { \
- (elm)->field.tqe_next = NULL; \
- (elm)->field.tqe_prev = (head)->tqh_last; \
- *(head)->tqh_last = (elm); \
- (head)->tqh_last = &(elm)->field.tqe_next; \
-}
-
-#define TAILQ_INSERT_AFTER(head, listelm, elm, field) { \
- if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
- (elm)->field.tqe_next->field.tqe_prev = \
- &(elm)->field.tqe_next; \
- else \
- (head)->tqh_last = &(elm)->field.tqe_next; \
- (listelm)->field.tqe_next = (elm); \
- (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
-}
-
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) { \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- (elm)->field.tqe_next = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
-}
-
-#define TAILQ_REMOVE(head, elm, field) { \
- if (((elm)->field.tqe_next) != NULL) \
- (elm)->field.tqe_next->field.tqe_prev = \
- (elm)->field.tqe_prev; \
- else \
- (head)->tqh_last = (elm)->field.tqe_prev; \
- *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
-}
-
-/*
- * Circular queue definitions.
- */
-#define CIRCLEQ_HEAD(name, type) \
-struct name { \
- struct type *cqh_first; /* first element */ \
- struct type *cqh_last; /* last element */ \
-}
-
-#define CIRCLEQ_ENTRY(type) \
-struct { \
- struct type *cqe_next; /* next element */ \
- struct type *cqe_prev; /* previous element */ \
-}
-
-/*
- * Circular queue functions.
- */
-#define CIRCLEQ_INIT(head) { \
- (head)->cqh_first = (void *)(head); \
- (head)->cqh_last = (void *)(head); \
-}
-
-#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) { \
- (elm)->field.cqe_next = (listelm)->field.cqe_next; \
- (elm)->field.cqe_prev = (listelm); \
- if ((listelm)->field.cqe_next == (void *)(head)) \
- (head)->cqh_last = (elm); \
- else \
- (listelm)->field.cqe_next->field.cqe_prev = (elm); \
- (listelm)->field.cqe_next = (elm); \
-}
-
-#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) { \
- (elm)->field.cqe_next = (listelm); \
- (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
- if ((listelm)->field.cqe_prev == (void *)(head)) \
- (head)->cqh_first = (elm); \
- else \
- (listelm)->field.cqe_prev->field.cqe_next = (elm); \
- (listelm)->field.cqe_prev = (elm); \
-}
-
-#define CIRCLEQ_INSERT_HEAD(head, elm, field) { \
- (elm)->field.cqe_next = (head)->cqh_first; \
- (elm)->field.cqe_prev = (void *)(head); \
- if ((head)->cqh_last == (void *)(head)) \
- (head)->cqh_last = (elm); \
- else \
- (head)->cqh_first->field.cqe_prev = (elm); \
- (head)->cqh_first = (elm); \
-}
-
-#define CIRCLEQ_INSERT_TAIL(head, elm, field) { \
- (elm)->field.cqe_next = (void *)(head); \
- (elm)->field.cqe_prev = (head)->cqh_last; \
- if ((head)->cqh_first == (void *)(head)) \
- (head)->cqh_first = (elm); \
- else \
- (head)->cqh_last->field.cqe_next = (elm); \
- (head)->cqh_last = (elm); \
-}
-
-#define CIRCLEQ_REMOVE(head, elm, field) { \
- if ((elm)->field.cqe_next == (void *)(head)) \
- (head)->cqh_last = (elm)->field.cqe_prev; \
- else \
- (elm)->field.cqe_next->field.cqe_prev = \
- (elm)->field.cqe_prev; \
- if ((elm)->field.cqe_prev == (void *)(head)) \
- (head)->cqh_first = (elm)->field.cqe_next; \
- else \
- (elm)->field.cqe_prev->field.cqe_next = \
- (elm)->field.cqe_next; \
-}
-#endif /* !_SYS_QUEUE_H_ */
diff --git a/include/tcl_extern.h b/include/tcl_extern.h
deleted file mode 100644
index ac68ae4119fd..000000000000
--- a/include/tcl_extern.h
+++ /dev/null
@@ -1 +0,0 @@
-int tcl_init __P((GS *));
diff --git a/include/tk_extern.h b/include/tk_extern.h
deleted file mode 100644
index 20a4de459f5e..000000000000
--- a/include/tk_extern.h
+++ /dev/null
@@ -1,29 +0,0 @@
-int tk_addstr __P((SCR *, const char *, size_t));
-int tk_attr __P((SCR *, scr_attr_t, int));
-int tk_baud __P((SCR *, u_long *));
-int tk_bell __P((SCR *));
-int tk_clrtoeol __P((SCR *));
-int tk_cursor __P((SCR *, size_t *, size_t *));
-int tk_deleteln __P((SCR *));
-int tk_ex_adjust __P((SCR *, exadj_t));
-int tk_insertln __P((SCR *));
-int tk_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
-int tk_move __P((SCR *, size_t, size_t));
-int tk_refresh __P((SCR *, int));
-int tk_rename __P((SCR *));
-int tk_suspend __P((SCR *, int *));
-void tk_usage __P((void));
-int tk_event __P((SCR *, EVENT *, u_int32_t, int));
-int tk_key __P((ClientData, Tcl_Interp *, int, char *[]));
-int tk_screen __P((SCR *, u_int32_t));
-int tk_quit __P((GS *));
-int tk_term_init __P((SCR *));
-int tk_term_end __P((GS *));
-int tk_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
-int tk_optchange __P((SCR *, int, char *, u_long *));
-int tk_ssize __P((SCR *, int, size_t *, size_t *, int *));
-int tk_op __P((ClientData, Tcl_Interp *, int, char *[]));
-int tk_opt_init __P((ClientData, Tcl_Interp *, int, char *[]));
-int tk_opt_set __P((ClientData, Tcl_Interp *, int, char *[]));
-int tk_version __P((ClientData, Tcl_Interp *, int, char *[]));
-void tk_msg __P((SCR *, mtype_t, char *, size_t));
diff --git a/ip/IP_INSTRUCTIONS b/ip/IP_INSTRUCTIONS
deleted file mode 100644
index 7745c8858d6f..000000000000
--- a/ip/IP_INSTRUCTIONS
+++ /dev/null
@@ -1,41 +0,0 @@
-1: Add:
- -DRUNNING_IP
-
- to the Makefile CFLAGS line and rebuild cl_main.o if it's already
- been compiled.
-
-2: Add:
-
- IPOBJS= ip_funcs.o ip_main.o ip_read.o ip_screen.o ip_term.o
-
- after the other object lists in the Makefile.
-
-3: Add
- $(IPOBJS)
-
- to the end of the NVIALL= line in the Makefile.
-
-4: Add:
-
- # Vi IP sources.
- ip_funcs.o: $(srcdir)/ip/ip_funcs.c
- $(CC) $(CFLAGS) $?
- ip_main.o: $(srcdir)/ip/ip_main.c
- $(CC) $(CFLAGS) $?
- ip_read.o: $(srcdir)/ip/ip_read.c
- $(CC) $(CFLAGS) $?
- ip_screen.o: $(srcdir)/ip/ip_screen.c
- $(CC) $(CFLAGS) $?
- ip_term.o: $(srcdir)/ip/ip_term.c
- $(CC) $(CFLAGS) $?
-
- at the end of the Makefile.
-
-5: Remove cl_main.o if it exists, and make nvi.
-
-6: Go to ip_cl and change the entries in the Makefile to reflect
- where the nvi binary was just built.
-
-7: Build ip_cl.
-
-8: Enter ip_cl and you should be running vi over a pipe.
diff --git a/ip/ip.h b/ip/ip.h
deleted file mode 100644
index f7798c3121b4..000000000000
--- a/ip/ip.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- *
- * @(#)ip.h 8.3 (Berkeley) 10/13/96
- */
-
-typedef struct _ip_private {
- int i_fd; /* Input file descriptor. */
- int o_fd; /* Output file descriptor. */
-
- size_t row; /* Current row. */
- size_t col; /* Current column. */
-
- size_t iblen; /* Input buffer length. */
- size_t iskip; /* Returned input buffer. */
- char ibuf[256]; /* Input buffer. */
-
-#define IP_SCR_VI_INIT 0x0001 /* Vi screen initialized. */
- u_int32_t flags;
-} IP_PRIVATE;
-
-#define IPP(sp) ((IP_PRIVATE *)((sp)->gp->ip_private))
-#define GIPP(gp) ((IP_PRIVATE *)((gp)->ip_private))
-
-/* The screen line relative to a specific window. */
-#define RLNO(sp, lno) (sp)->woff + (lno)
-
-/*
- * The IP protocol consists of frames, each containing:
- *
- * <IPO_><object>
- *
- * XXX
- * We should have a marking byte, 0xaa to delimit frames.
- *
- */
-#define IPO_CODE 1 /* An event specification. */
-#define IPO_INT 2 /* 4-byte, network order integer. */
-#define IPO_STR 3 /* IPO_INT: followed by N bytes. */
-
-#define IPO_CODE_LEN 1
-#define IPO_INT_LEN 4
-
-/* A structure that can hold the information for any frame. */
-typedef struct _ip_buf {
- int code; /* Event code. */
- const char *str; /* String. */
- size_t len; /* String length. */
- u_int32_t val1; /* First value. */
- u_int32_t val2; /* Second value. */
-} IP_BUF;
-
-/*
- * Screen/editor IP_CODE's.
- *
- * The program structure depends on the event loop being able to return
- * IPO_EOF/IPOE_ERR multiple times -- eventually enough things will end
- * due to the events that vi will reach the command level for the screen,
- * at which point the exit flags will be set and vi will exit.
- *
- * IP events sent from the screen to vi.
- */
-#define IPO_EOF 1 /* End of input (NOT ^D). */
-#define IPO_ERR 2 /* Input error. */
-#define IPO_INTERRUPT 3 /* Interrupt. */
-#define IPO_QUIT 4 /* Quit. */
-#define IPO_RESIZE 5 /* Screen resize: IPO_INT, IPO_INT. */
-#define IPO_SIGHUP 6 /* SIGHUP. */
-#define IPO_SIGTERM 7 /* SIGTERM. */
-#define IPO_STRING 8 /* Input string: IPO_STR. */
-#define IPO_WRITE 9 /* Write. */
-
-/*
- * IP events sent from vi to the screen.
- */
-#define IPO_ADDSTR 1 /* Add a string: IPO_STR. */
-#define IPO_ATTRIBUTE 2 /* Set screen attribute: IPO_INT, IPO_INT. */
-#define IPO_BELL 3 /* Beep/bell/flash the terminal. */
-#define IPO_BUSY 4 /* Display a busy message: IPO_STR. */
-#define IPO_CLRTOEOL 5 /* Clear to the end of the line. */
-#define IPO_DELETELN 6 /* Delete a line. */
-#define IPO_INSERTLN 7 /* Insert a line. */
-#define IPO_MOVE 8 /* Move the cursor: IPO_INT, IPO_INT. */
-#define IPO_REDRAW 9 /* Redraw the screen. */
-#define IPO_REFRESH 10 /* Refresh the screen. */
-#define IPO_RENAME 11 /* Rename the screen: IPO_STR. */
-#define IPO_REWRITE 12 /* Rewrite a line: IPO_INT. */
-
-#include "ip_extern.h"
diff --git a/ip/ip_funcs.c b/ip/ip_funcs.c
deleted file mode 100644
index c92f1eda2439..000000000000
--- a/ip/ip_funcs.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ip_funcs.c 8.4 (Berkeley) 10/13/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <stdio.h>
-
-#include "../common/common.h"
-#include "../vi/vi.h"
-#include "ip.h"
-
-static int ip_send __P((SCR *, char *, IP_BUF *));
-
-/*
- * ip_addstr --
- * Add len bytes from the string at the cursor, advancing the cursor.
- *
- * PUBLIC: int ip_addstr __P((SCR *, const char *, size_t));
- */
-int
-ip_addstr(sp, str, len)
- SCR *sp;
- const char *str;
- size_t len;
-{
- IP_BUF ipb;
- IP_PRIVATE *ipp;
- int iv, rval;
-
- ipp = IPP(sp);
-
- /*
- * If ex isn't in control, it's the last line of the screen and
- * it's a split screen, use inverse video.
- */
- iv = 0;
- if (!F_ISSET(sp, SC_SCR_EXWROTE) &&
- ipp->row == LASTLINE(sp) && IS_SPLIT(sp)) {
- iv = 1;
- ip_attr(sp, SA_INVERSE, 1);
- }
- ipb.code = IPO_ADDSTR;
- ipb.len = len;
- ipb.str = str;
- rval = ip_send(sp, "s", &ipb);
-
- if (iv)
- ip_attr(sp, SA_INVERSE, 0);
- return (rval);
-}
-
-/*
- * ip_attr --
- * Toggle a screen attribute on/off.
- *
- * PUBLIC: int ip_attr __P((SCR *, scr_attr_t, int));
- */
-int
-ip_attr(sp, attribute, on)
- SCR *sp;
- scr_attr_t attribute;
- int on;
-{
- IP_BUF ipb;
-
- ipb.code = IPO_ATTRIBUTE;
- ipb.val1 = attribute;
- ipb.val2 = on;
-
- return (ip_send(sp, "12", &ipb));
-}
-
-/*
- * ip_baud --
- * Return the baud rate.
- *
- * PUBLIC: int ip_baud __P((SCR *, u_long *));
- */
-int
-ip_baud(sp, ratep)
- SCR *sp;
- u_long *ratep;
-{
- *ratep = 9600; /* XXX: Translation: fast. */
- return (0);
-}
-
-/*
- * ip_bell --
- * Ring the bell/flash the screen.
- *
- * PUBLIC: int ip_bell __P((SCR *));
- */
-int
-ip_bell(sp)
- SCR *sp;
-{
- IP_BUF ipb;
-
- ipb.code = IPO_BELL;
-
- return (ip_send(sp, NULL, &ipb));
-}
-
-/*
- * ip_busy --
- * Display a busy message.
- *
- * PUBLIC: void ip_busy __P((SCR *, const char *, busy_t));
- */
-void
-ip_busy(sp, str, bval)
- SCR *sp;
- const char *str;
- busy_t bval;
-{
- IP_BUF ipb;
-
- ipb.code = IPO_BUSY;
- if (str == NULL) {
- ipb.len = 0;
- ipb.str = "";
- } else {
- ipb.len = strlen(str);
- ipb.str = str;
- }
- ipb.val1 = bval;
-
- (void)ip_send(sp, "s1", &ipb);
-}
-
-/*
- * ip_clrtoeol --
- * Clear from the current cursor to the end of the line.
- *
- * PUBLIC: int ip_clrtoeol __P((SCR *));
- */
-int
-ip_clrtoeol(sp)
- SCR *sp;
-{
- IP_BUF ipb;
-
- ipb.code = IPO_CLRTOEOL;
-
- return (ip_send(sp, NULL, &ipb));
-}
-
-/*
- * ip_cursor --
- * Return the current cursor position.
- *
- * PUBLIC: int ip_cursor __P((SCR *, size_t *, size_t *));
- */
-int
-ip_cursor(sp, yp, xp)
- SCR *sp;
- size_t *yp, *xp;
-{
- IP_PRIVATE *ipp;
-
- ipp = IPP(sp);
- *yp = ipp->row;
- *xp = ipp->col;
- return (0);
-}
-
-/*
- * ip_deleteln --
- * Delete the current line, scrolling all lines below it.
- *
- * PUBLIC: int ip_deleteln __P((SCR *));
- */
-int
-ip_deleteln(sp)
- SCR *sp;
-{
- IP_BUF ipb;
-
- /*
- * This clause is required because the curses screen uses reverse
- * video to delimit split screens. If the screen does not do this,
- * this code won't be necessary.
- *
- * If the bottom line was in reverse video, rewrite it in normal
- * video before it's scrolled.
- */
- if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
- ipb.code = IPO_REWRITE;
- ipb.val1 = RLNO(sp, LASTLINE(sp));
- if (ip_send(sp, "1", &ipb))
- return (1);
- }
-
- /*
- * The bottom line is expected to be blank after this operation,
- * and other screens must support that semantic.
- */
- ipb.code = IPO_DELETELN;
- return (ip_send(sp, NULL, &ipb));
-}
-
-/*
- * ip_ex_adjust --
- * Adjust the screen for ex.
- *
- * PUBLIC: int ip_ex_adjust __P((SCR *, exadj_t));
- */
-int
-ip_ex_adjust(sp, action)
- SCR *sp;
- exadj_t action;
-{
- abort();
- /* NOTREACHED */
-}
-
-/*
- * ip_insertln --
- * Push down the current line, discarding the bottom line.
- *
- * PUBLIC: int ip_insertln __P((SCR *));
- */
-int
-ip_insertln(sp)
- SCR *sp;
-{
- IP_BUF ipb;
-
- ipb.code = IPO_INSERTLN;
-
- return (ip_send(sp, NULL, &ipb));
-}
-
-/*
- * ip_keyval --
- * Return the value for a special key.
- *
- * PUBLIC: int ip_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
- */
-int
-ip_keyval(sp, val, chp, dnep)
- SCR *sp;
- scr_keyval_t val;
- CHAR_T *chp;
- int *dnep;
-{
- /*
- * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
- * VWERASE is a 4BSD extension.
- */
- switch (val) {
- case KEY_VEOF:
- *dnep = '\004'; /* ^D */
- break;
- case KEY_VERASE:
- *dnep = '\b'; /* ^H */
- break;
- case KEY_VKILL:
- *dnep = '\025'; /* ^U */
- break;
-#ifdef VWERASE
- case KEY_VWERASE:
- *dnep = '\027'; /* ^W */
- break;
-#endif
- default:
- *dnep = 1;
- break;
- }
- return (0);
-}
-
-/*
- * ip_move --
- * Move the cursor.
- *
- * PUBLIC: int ip_move __P((SCR *, size_t, size_t));
- */
-int
-ip_move(sp, lno, cno)
- SCR *sp;
- size_t lno, cno;
-{
- IP_PRIVATE *ipp;
- IP_BUF ipb;
-
- ipp = IPP(sp);
- ipp->row = lno;
- ipp->col = cno;
-
- ipb.code = IPO_MOVE;
- ipb.val1 = RLNO(sp, lno);
- ipb.val2 = cno;
- return (ip_send(sp, "12", &ipb));
-}
-
-/*
- * ip_refresh --
- * Refresh the screen.
- *
- * PUBLIC: int ip_refresh __P((SCR *, int));
- */
-int
-ip_refresh(sp, repaint)
- SCR *sp;
- int repaint;
-{
- IP_BUF ipb;
-
- ipb.code = repaint ? IPO_REDRAW : IPO_REFRESH;
-
- return (ip_send(sp, NULL, &ipb));
-}
-
-/*
- * ip_rename --
- * Rename the file.
- *
- * PUBLIC: int ip_rename __P((SCR *));
- */
-int
-ip_rename(sp)
- SCR *sp;
-{
- IP_BUF ipb;
-
- ipb.code = IPO_RENAME;
- ipb.len = strlen(sp->frp->name);
- ipb.str = sp->frp->name;
-
- return (ip_send(sp, "s", &ipb));
-}
-
-/*
- * ip_suspend --
- * Suspend a screen.
- *
- * PUBLIC: int ip_suspend __P((SCR *, int *));
- */
-int
-ip_suspend(sp, allowedp)
- SCR *sp;
- int *allowedp;
-{
- *allowedp = 0;
- return (0);
-}
-
-/*
- * ip_usage --
- * Print out the ip usage messages.
- *
- * PUBLIC: void ip_usage __P((void));
- */
-void
-ip_usage()
-{
-#define USAGE "\
-usage: vi [-eFlRrSv] [-c command] [-I ifd.ofd] [-t tag] [-w size] [file ...]\n"
- (void)fprintf(stderr, "%s", USAGE);
-#undef USAGE
-}
-
-/*
- * ip_send --
- * Construct and send an IP buffer.
- */
-static int
-ip_send(sp, fmt, ipbp)
- SCR *sp;
- char *fmt;
- IP_BUF *ipbp;
-{
- IP_PRIVATE *ipp;
- size_t blen, off;
- u_int32_t ilen;
- int nlen, n, nw, rval;
- char *bp, *p;
-
- ipp = IPP(sp);
-
- GET_SPACE_RET(sp, bp, blen, 128);
-
- p = bp;
- nlen = 0;
- *p++ = ipbp->code;
- nlen += IPO_CODE_LEN;
-
- if (fmt != NULL)
- for (; *fmt != '\0'; ++fmt)
- switch (*fmt) {
- case '1': /* Value 1. */
- ilen = htonl(ipbp->val1);
- goto value;
- case '2': /* Value 2. */
- ilen = htonl(ipbp->val2);
-value: nlen += IPO_INT_LEN;
- off = p - bp;
- ADD_SPACE_RET(sp, bp, blen, nlen);
- p = bp + off;
- memmove(p, &ilen, IPO_INT_LEN);
- p += IPO_INT_LEN;
- break;
- case 's': /* String. */
- ilen = ipbp->len; /* XXX: conversion. */
- ilen = htonl(ilen);
- nlen += IPO_INT_LEN + ipbp->len;
- off = p - bp;
- ADD_SPACE_RET(sp, bp, blen, nlen);
- p = bp + off;
- memmove(p, &ilen, IPO_INT_LEN);
- p += IPO_INT_LEN;
- memmove(p, ipbp->str, ipbp->len);
- p += ipbp->len;
- break;
- }
-
-
- rval = 0;
- for (n = p - bp, p = bp; n > 0; n -= nw, p += nw)
- if ((nw = write(ipp->o_fd, p, n)) < 0) {
- rval = 1;
- break;
- }
-
- FREE_SPACE(sp, bp, blen);
-
- return (rval);
-}
diff --git a/ip/ip_main.c b/ip/ip_main.c
deleted file mode 100644
index 7ca9f55024fd..000000000000
--- a/ip/ip_main.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ip_main.c 8.3 (Berkeley) 10/13/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include "../common/common.h"
-#include "ip.h"
-
-static void ip_func_std __P((GS *));
-static IP_PRIVATE *ip_init __P((GS *, char *));
-static void perr __P((char *, char *));
-
-/*
- * main --
- * This is the main loop for the vi-as-library editor.
- */
-int
-ip_main(argc, argv, gp, ip_arg)
- int argc;
- char *argv[], *ip_arg;
- GS *gp;
-{
- EVENT ev;
- IP_PRIVATE *ipp;
- IP_BUF ipb;
- int rval;
-
- /* Create and partially initialize the IP structure. */
- if ((ipp = ip_init(gp, ip_arg)) == NULL)
- return (1);
-
- /* Add the terminal type to the global structure. */
- if ((OG_D_STR(gp, GO_TERM) =
- OG_STR(gp, GO_TERM) = strdup("ip_curses")) == NULL)
- perr(gp->progname, NULL);
-
- /*
- * Figure out how big the screen is -- read events until we get
- * the rows and columns.
- */
- do {
- if (ip_event(NULL, &ev, 0, 0))
- return (1);
- } while (ev.e_event != E_EOF && ev.e_event != E_ERR &&
- ev.e_event != E_QUIT && ev.e_event != E_WRESIZE &&
- ev.e_event != E_SIGHUP && ev.e_event != E_SIGTERM);
- if (ev.e_event != E_WRESIZE)
- return (1);
-
- /* Run ex/vi. */
- rval = editor(gp, argc, argv);
-
- /* Clean up the screen. */
- (void)ip_quit(gp);
-
- /* Free the global and IP private areas. */
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
- free(ipp);
- free(gp);
-#endif
-
- return (rval);
-}
-
-/*
- * ip_init --
- * Create and partially initialize the GS structure.
- */
-static IP_PRIVATE *
-ip_init(gp, ip_arg)
- GS *gp;
- char *ip_arg;
-{
- IP_PRIVATE *ipp;
- char *ep;
-
- /* Allocate the IP private structure. */
- CALLOC_NOMSG(NULL, ipp, IP_PRIVATE *, 1, sizeof(IP_PRIVATE));
- if (ipp == NULL)
- perr(gp->progname, NULL);
- gp->ip_private = ipp;
-
- /*
- * Crack ip_arg -- it's of the form #.#, where the first number is the
- * file descriptor from the screen, the second is the file descriptor
- * to the screen.
- */
- if (!isdigit(ip_arg[0]))
- goto usage;
- ipp->i_fd = strtol(ip_arg, &ep, 10);
- if (ep[0] != '.' || !isdigit(ep[1]))
- goto usage;
- ipp->o_fd = strtol(++ep, &ep, 10);
- if (ep[0] != '\0') {
-usage: ip_usage();
- return (NULL);
- }
-
- /* Initialize the list of ip functions. */
- ip_func_std(gp);
-
- return (ipp);
-}
-
-/*
- * ip_func_std --
- * Initialize the standard ip functions.
- */
-static void
-ip_func_std(gp)
- GS *gp;
-{
- gp->scr_addstr = ip_addstr;
- gp->scr_attr = ip_attr;
- gp->scr_baud = ip_baud;
- gp->scr_bell = ip_bell;
- gp->scr_busy = ip_busy;
- gp->scr_clrtoeol = ip_clrtoeol;
- gp->scr_cursor = ip_cursor;
- gp->scr_deleteln = ip_deleteln;
- gp->scr_event = ip_event;
- gp->scr_ex_adjust = ip_ex_adjust;
- gp->scr_fmap = ip_fmap;
- gp->scr_insertln = ip_insertln;
- gp->scr_keyval = ip_keyval;
- gp->scr_move = ip_move;
- gp->scr_msg = NULL;
- gp->scr_optchange = ip_optchange;
- gp->scr_refresh = ip_refresh;
- gp->scr_rename = ip_rename;
- gp->scr_screen = ip_screen;
- gp->scr_suspend = ip_suspend;
- gp->scr_usage = ip_usage;
-}
-
-/*
- * perr --
- * Print system error.
- */
-static void
-perr(name, msg)
- char *name, *msg;
-{
- (void)fprintf(stderr, "%s:", name);
- if (msg != NULL)
- (void)fprintf(stderr, "%s:", msg);
- (void)fprintf(stderr, "%s\n", strerror(errno));
- exit(1);
-}
diff --git a/ip/ip_read.c b/ip/ip_read.c
deleted file mode 100644
index 9fd977774173..000000000000
--- a/ip/ip_read.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ip_read.c 8.3 (Berkeley) 9/24/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <stdio.h>
-#include <termios.h>
-#include <time.h>
-
-#include "../common/common.h"
-#include "../ex/script.h"
-#include "ip.h"
-
-extern GS *__global_list;
-
-typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_TIMEOUT } input_t;
-
-static input_t ip_read __P((SCR *, IP_PRIVATE *, struct timeval *));
-static int ip_resize __P((SCR *, size_t, size_t));
-static int ip_trans __P((SCR *, IP_PRIVATE *, EVENT *));
-
-/*
- * ip_event --
- * Return a single event.
- *
- * PUBLIC: int ip_event __P((SCR *, EVENT *, u_int32_t, int));
- */
-int
-ip_event(sp, evp, flags, ms)
- SCR *sp;
- EVENT *evp;
- u_int32_t flags;
- int ms;
-{
- IP_PRIVATE *ipp;
- struct timeval t, *tp;
-
- if (LF_ISSET(EC_INTERRUPT)) { /* XXX */
- evp->e_event = E_TIMEOUT;
- return (0);
- }
-
- ipp = sp == NULL ? GIPP(__global_list) : IPP(sp);
-
- /* Discard the last command. */
- if (ipp->iskip != 0) {
- ipp->iblen -= ipp->iskip;
- memmove(ipp->ibuf, ipp->ibuf + ipp->iskip, ipp->iblen);
- ipp->iskip = 0;
- }
-
- /* Set timer. */
- if (ms == 0)
- tp = NULL;
- else {
- t.tv_sec = ms / 1000;
- t.tv_usec = (ms % 1000) * 1000;
- tp = &t;
- }
-
- /* Read input events. */
- for (;;) {
- switch (ip_read(sp, ipp, tp)) {
- case INP_OK:
- if (!ip_trans(sp, ipp, evp))
- continue;
- break;
- case INP_EOF:
- evp->e_event = E_EOF;
- break;
- case INP_ERR:
- evp->e_event = E_ERR;
- break;
- case INP_TIMEOUT:
- evp->e_event = E_TIMEOUT;
- break;
- default:
- abort();
- }
- break;
- }
- return (0);
-}
-
-/*
- * ip_read --
- * Read characters from the input.
- */
-static input_t
-ip_read(sp, ipp, tp)
- SCR *sp;
- IP_PRIVATE *ipp;
- struct timeval *tp;
-{
- struct timeval poll;
- GS *gp;
- SCR *tsp;
- fd_set rdfd;
- input_t rval;
- size_t blen;
- int maxfd, nr;
- char *bp;
-
- gp = sp == NULL ? __global_list : sp->gp;
- bp = ipp->ibuf + ipp->iblen;
- blen = sizeof(ipp->ibuf) - ipp->iblen;
-
- /*
- * 1: A read with an associated timeout, e.g., trying to complete
- * a map sequence. If input exists, we fall into #2.
- */
- FD_ZERO(&rdfd);
- poll.tv_sec = 0;
- poll.tv_usec = 0;
- if (tp != NULL) {
- FD_SET(ipp->i_fd, &rdfd);
- switch (select(ipp->i_fd + 1,
- &rdfd, NULL, NULL, tp == NULL ? &poll : tp)) {
- case 0:
- return (INP_TIMEOUT);
- case -1:
- goto err;
- default:
- break;
- }
- }
-
- /*
- * 2: Wait for input.
- *
- * Select on the command input and scripting window file descriptors.
- * It's ugly that we wait on scripting file descriptors here, but it's
- * the only way to keep from locking out scripting windows.
- */
- if (sp != NULL && F_ISSET(gp, G_SCRWIN)) {
-loop: FD_ZERO(&rdfd);
- FD_SET(ipp->i_fd, &rdfd);
- maxfd = ipp->i_fd;
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
- if (F_ISSET(sp, SC_SCRIPT)) {
- FD_SET(sp->script->sh_master, &rdfd);
- if (sp->script->sh_master > maxfd)
- maxfd = sp->script->sh_master;
- }
- switch (select(maxfd + 1, &rdfd, NULL, NULL, NULL)) {
- case 0:
- abort();
- case -1:
- goto err;
- default:
- break;
- }
- if (!FD_ISSET(ipp->i_fd, &rdfd)) {
- if (sscr_input(sp))
- return (INP_ERR);
- goto loop;
- }
- }
-
- /*
- * 3: Read the input.
- */
- switch (nr = read(ipp->i_fd, bp, blen)) {
- case 0: /* EOF. */
- rval = INP_EOF;
- break;
- case -1: /* Error or interrupt. */
-err: rval = INP_ERR;
- msgq(sp, M_SYSERR, "input");
- break;
- default: /* Input characters. */
- ipp->iblen += nr;
- rval = INP_OK;
- break;
- }
- return (rval);
-}
-
-/*
- * ip_trans --
- * Translate messages into events.
- */
-static int
-ip_trans(sp, ipp, evp)
- SCR *sp;
- IP_PRIVATE *ipp;
- EVENT *evp;
-{
- u_int32_t val1, val2;
-
- switch (ipp->ibuf[0]) {
- case IPO_EOF:
- evp->e_event = E_EOF;
- ipp->iskip = IPO_CODE_LEN;
- return (1);
- case IPO_ERR:
- evp->e_event = E_ERR;
- ipp->iskip = IPO_CODE_LEN;
- return (1);
- case IPO_INTERRUPT:
- evp->e_event = E_INTERRUPT;
- ipp->iskip = IPO_CODE_LEN;
- return (1);
- case IPO_QUIT:
- evp->e_event = E_QUIT;
- ipp->iskip = IPO_CODE_LEN;
- return (1);
- case IPO_RESIZE:
- if (ipp->iblen < IPO_CODE_LEN + IPO_INT_LEN * 2)
- return (0);
- evp->e_event = E_WRESIZE;
- memcpy(&val1, ipp->ibuf + IPO_CODE_LEN, IPO_INT_LEN);
- val1 = ntohl(val1);
- memcpy(&val2,
- ipp->ibuf + IPO_CODE_LEN + IPO_INT_LEN, IPO_INT_LEN);
- val2 = ntohl(val2);
- ip_resize(sp, val1, val2);
- ipp->iskip = IPO_CODE_LEN + IPO_INT_LEN * 2;
- return (1);
- case IPO_SIGHUP:
- evp->e_event = E_SIGHUP;
- ipp->iskip = IPO_CODE_LEN;
- return (1);
- case IPO_SIGTERM:
- evp->e_event = E_SIGTERM;
- ipp->iskip = IPO_CODE_LEN;
- return (1);
- case IPO_STRING:
- evp->e_event = E_STRING;
-string: if (ipp->iblen < IPO_CODE_LEN + IPO_INT_LEN)
- return (0);
- memcpy(&val1, ipp->ibuf + IPO_CODE_LEN, IPO_INT_LEN);
- val1 = ntohl(val1);
- if (ipp->iblen < IPO_CODE_LEN + IPO_INT_LEN + val1)
- return (0);
- ipp->iskip = IPO_CODE_LEN + IPO_INT_LEN + val1;
- evp->e_csp = ipp->ibuf + IPO_CODE_LEN + IPO_INT_LEN;
- evp->e_len = val1;
- return (1);
- case IPO_WRITE:
- evp->e_event = E_WRITE;
- ipp->iskip = IPO_CODE_LEN;
- return (1);
- default:
- /*
- * XXX: Protocol is out of sync?
- */
- abort();
- }
- /* NOTREACHED */
-}
-
-/*
- * ip_resize --
- * Reset the options for a resize event.
- */
-static int
-ip_resize(sp, lines, columns)
- SCR *sp;
- size_t lines, columns;
-{
- GS *gp;
- ARGS *argv[2], a, b;
- char b1[1024];
-
- /*
- * XXX
- * The IP screen has to know the lines and columns before anything
- * else happens. So, we may not have a valid SCR pointer, and we
- * have to deal with that.
- */
- if (sp == NULL) {
- gp = __global_list;
- OG_VAL(gp, GO_LINES) = OG_D_VAL(gp, GO_LINES) = lines;
- OG_VAL(gp, GO_COLUMNS) = OG_D_VAL(gp, GO_COLUMNS) = columns;
- return (0);
- }
-
- a.bp = b1;
- b.bp = NULL;
- a.len = b.len = 0;
- argv[0] = &a;
- argv[1] = &b;
-
- (void)snprintf(b1, sizeof(b1), "lines=%lu", (u_long)lines);
- a.len = strlen(b1);
- if (opts_set(sp, argv, NULL))
- return (1);
- (void)snprintf(b1, sizeof(b1), "columns=%lu", (u_long)columns);
- a.len = strlen(b1);
- if (opts_set(sp, argv, NULL))
- return (1);
- return (0);
-}
diff --git a/ip/ip_screen.c b/ip/ip_screen.c
deleted file mode 100644
index 71578e0d1b39..000000000000
--- a/ip/ip_screen.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ip_screen.c 8.2 (Berkeley) 10/13/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <stdio.h>
-
-#include "../common/common.h"
-#include "ip.h"
-
-/*
- * ip_screen --
- * Initialize/shutdown the IP screen.
- *
- * PUBLIC: int ip_screen __P((SCR *, u_int32_t));
- */
-int
-ip_screen(sp, flags)
- SCR *sp;
- u_int32_t flags;
-{
- GS *gp;
- IP_PRIVATE *ipp;
-
- gp = sp->gp;
- ipp = IPP(sp);
-
- /* See if the current information is incorrect. */
- if (F_ISSET(gp, G_SRESTART)) {
- if (ip_quit(gp))
- return (1);
- F_CLR(gp, G_SRESTART);
- }
-
- /* See if we're already in the right mode. */
- if (LF_ISSET(SC_VI) && F_ISSET(ipp, IP_SCR_VI_INIT))
- return (0);
-
- /* Ex isn't possible. */
- if (LF_ISSET(SC_EX))
- return (1);
-
- /* Initialize terminal based information. */
- if (ip_term_init(sp))
- return (1);
-
- /* Put up the first file name. */
- if (ip_rename(sp))
- return (1);
-
- F_SET(ipp, IP_SCR_VI_INIT);
- return (0);
-}
-
-/*
- * ip_quit --
- * Shutdown the screens.
- *
- * PUBLIC: int ip_quit __P((GS *));
- */
-int
-ip_quit(gp)
- GS *gp;
-{
- IP_PRIVATE *ipp;
- int rval;
-
- /* Clean up the terminal mappings. */
- rval = ip_term_end(gp);
-
- ipp = GIPP(gp);
- F_CLR(ipp, IP_SCR_VI_INIT);
-
- return (rval);
-}
diff --git a/ip/ip_term.c b/ip/ip_term.c
deleted file mode 100644
index 28e686dddd28..000000000000
--- a/ip/ip_term.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ip_term.c 8.2 (Berkeley) 10/13/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <stdio.h>
-
-#include "../common/common.h"
-#include "ip.h"
-
-/*
- * ip_term_init --
- * Initialize the terminal special keys.
- *
- * PUBLIC: int ip_term_init __P((SCR *));
- */
-int
-ip_term_init(sp)
- SCR *sp;
-{
- SEQ *qp;
-
- /*
- * Rework any function key mappings that were set before the
- * screen was initialized.
- */
- for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next)
- if (F_ISSET(qp, SEQ_FUNCMAP))
- (void)ip_fmap(sp, qp->stype,
- qp->input, qp->ilen, qp->output, qp->olen);
- return (0);
-}
-
-/*
- * ip_term_end --
- * End the special keys defined by the termcap/terminfo entry.
- *
- * PUBLIC: int ip_term_end __P((GS *));
- */
-int
-ip_term_end(gp)
- GS *gp;
-{
- SEQ *qp, *nqp;
-
- /* Delete screen specific mappings. */
- for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
- nqp = qp->q.le_next;
- if (F_ISSET(qp, SEQ_SCREEN))
- (void)seq_mdel(qp);
- }
- return (0);
-}
-
-/*
- * ip_fmap --
- * Map a function key.
- *
- * PUBLIC: int ip_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
- */
-int
-ip_fmap(sp, stype, from, flen, to, tlen)
- SCR *sp;
- seq_t stype;
- CHAR_T *from, *to;
- size_t flen, tlen;
-{
- /* Bind a function key to a string sequence. */
- return (1);
-}
-
-/*
- * ip_optchange --
- * IP screen specific "option changed" routine.
- *
- * PUBLIC: int ip_optchange __P((SCR *, int, char *, u_long *));
- */
-int
-ip_optchange(sp, opt, str, valp)
- SCR *sp;
- int opt;
- char *str;
- u_long *valp;
-{
- switch (opt) {
- case O_COLUMNS:
- case O_LINES:
- F_SET(sp->gp, G_SRESTART);
- F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
- break;
- case O_TERM:
- msgq(sp, M_ERR, "The screen type may not be changed");
- return (1);
- }
- return (0);
-}
diff --git a/ip_cl/Makefile b/ip_cl/Makefile
deleted file mode 100644
index 9503c4dac501..000000000000
--- a/ip_cl/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# TR turns on tracing, to the specified file.
-TR= -DTR=\"/dev/ttypa\"
-#TR= -DTR=\"__log\"
-
-# VI is the binary that ip_cl runs.
-VI= -DVI=\"../build.local/nvi\"
-
-DEBUG= -DDEBUG -g
-INC= -I. -I../build.local -I../include
-CFLAGS= $(DEBUG) $(TR) $(VI) $(INC)
-
-OBJS= ip_cl.o
-
-LIBS= -lcurses -ltermcap
-
-ip_cl: ${OBJS}
- ${CC} ${OBJS} -o $@ ${LIBS}
-
-clean:
- rm -f ip_cl ${OBJS}
diff --git a/ip_cl/ip_cl.c b/ip_cl/ip_cl.c
deleted file mode 100644
index 5137b3f56abc..000000000000
--- a/ip_cl/ip_cl.c
+++ /dev/null
@@ -1,742 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)ip_cl.c 8.4 (Berkeley) 10/13/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/queue.h>
-#include <sys/select.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <curses.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "../ip/ip.h"
-#include "pathnames.h"
-
-size_t cols, rows; /* Screen columns, rows. */
-int die; /* Child died. */
-int i_fd, o_fd; /* Input/output fd's. */
-int resize; /* Window resized. */
-
-void arg_format __P((int *, char **[], int, int));
-void attach __P((void));
-void ip_cur_end __P((void));
-void ip_cur_init __P((void));
-void ip_read __P((void));
-void ip_resize __P((void));
-int ip_send __P((char *, IP_BUF *));
-void ip_siginit __P((void));
-int ip_trans __P((char *, size_t, size_t *));
-void nomem __P((void));
-void onchld __P((int));
-void onintr __P((int));
-void onwinch __P((int));
-void trace __P((const char *, ...));
-void usage __P((void));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- fd_set fdset;
- pid_t pid;
- size_t blen, len, skip;
- int ch, nr, rpipe[2], wpipe[2];
- char *bp;
-
- while ((ch = getopt(argc, argv, "D")) != EOF)
- switch (ch) {
- case 'D':
- attach();
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- /*
- * Open the communications pipes. The pipes are named from our
- * viewpoint, so we read from rpipe[0] and write to wpipe[1].
- * Vi reads from wpipe[0], and writes to rpipe[1].
- */
- if (pipe(rpipe) == -1 || pipe(wpipe) == -1) {
- perror("ip_cl: pipe");
- exit (1);
- }
- i_fd = rpipe[0];
- o_fd = wpipe[1];
-
- /*
- * Format our arguments, adding a -I to the list. The first file
- * descriptor to the -I argument is vi's input, and the second is
- * vi's output.
- */
- arg_format(&argc, &argv, wpipe[0], rpipe[1]);
-
- /* Run vi. */
- switch (pid = fork()) {
- case -1: /* Error. */
- perror("ip_cl: fork");
- exit (1);
- case 0: /* Vi. */
- execv(VI, argv);
- perror("ip_cl: execv ../build/nvi");
- exit (1);
- default: /* Ip_cl. */
- break;
- }
-
- /*
- * Allocate initial input buffer.
- * XXX
- * We don't dynamically resize, so there better not be any individual
- * messages larger than this buffer.
- */
- blen = 4 * 1024;
- if ((bp = malloc(blen)) == NULL)
- nomem();
-
- /* Clear the file descriptor mask. */
- FD_ZERO(&fdset);
-
- /* Initialize signals. */
- ip_siginit();
-
- /* Initialize the curses screen. */
- ip_cur_init();
-
- /* The first thing vi wants is the screen size. */
- ip_resize();
-
- /* Main loop. */
- for (len = 0;;) {
- if (die)
- break;
- /*
- * XXX
- * Race #1: if there's an event coming from vi that requires
- * that we know what size the screen is, and we take a resize
- * signal, we'll differ from vi in the size of the screen for
- * that event. Fixing this will requires information attached
- * to message as to what set of state was in place when the
- * message was sent. Not hard, but not worth doing now.
- *
- * Race #2: we cycle, handling resize events until there aren't
- * any waiting. We then do a select. If the resize signal
- * arrives after we exit the loop but before we enter select,
- * we'll wait on the user to enter a keystroke, handle it and
- * then handle the resize.
- */
- while (resize) {
- resize = 0;
- ip_resize();
- ip_cur_end();
- ip_cur_init();
- }
-
- /* Wait until vi or the screen wants to talk. */
- FD_SET(i_fd, &fdset);
- FD_SET(STDIN_FILENO, &fdset);
- errno = 0;
- switch (select(i_fd + 1, &fdset, NULL, NULL, NULL)) {
- case 0:
- abort(); /* Timeout. */
- /* NOTREACHED */
- case -1:
- if (errno == EINTR)
- continue;
- perror("ip_cl: select");
- exit (1);
- default:
- break;
- }
-
- /* Read waiting tty characters and send them to vi. */
- if (FD_ISSET(STDIN_FILENO, &fdset)) {
- ip_read();
- continue;
- }
-
- /* Read waiting vi messages and translate to curses calls. */
- switch (nr = read(i_fd, bp + len, blen - len)) {
- case 0:
- continue;
- case -1:
- perror("ip_cl: read");
- exit (1);
- default:
- break;
- }
-
- /* Parse to data end or partial message. */
- for (len += nr, skip = 0; len > skip &&
- ip_trans(bp + skip, len - skip, &skip) == 1;);
-
- /* Copy any partial messages down in the buffer. */
- len -= skip;
- if (len > 0)
- memmove(bp, bp + skip, len);
- }
-
- /* End the screen. */
- ip_cur_end();
-
- exit (0);
-}
-
-/*
- * ip_read --
- * Read characters from the screen and send them to vi.
- */
-void
-ip_read()
-{
- IP_BUF ipb;
- int nr;
- char bp[1024];
-
- /* Read waiting tty characters. */
- switch (nr = read(STDIN_FILENO, bp, sizeof(bp))) {
- case 0:
- return;
- case -1:
- perror("ip_cl: read");
- exit (1);
- default:
- break;
- }
-
- ipb.code = IPO_STRING;
- ipb.len = nr;
- ipb.str = bp;
- ip_send("s", &ipb);
-}
-
-/*
- * ip_trans --
- * Translate vi messages into curses calls.
- */
-int
-ip_trans(bp, len, skipp)
- char *bp;
- size_t len, *skipp;
-{
- IP_BUF ipb;
- size_t cno, lno, nlen, oldy, oldx, spcnt;
- int ch;
- char *fmt, *p;
-
- switch (bp[0]) {
- case IPO_ADDSTR:
- case IPO_RENAME:
- fmt = "s";
- break;
- case IPO_BUSY:
- fmt = "s1";
- break;
- case IPO_ATTRIBUTE:
- case IPO_MOVE:
- fmt = "12";
- break;
- case IPO_REWRITE:
- fmt = "1";
- break;
- default:
- fmt = "";
- }
-
- nlen = IPO_CODE_LEN;
- p = bp + IPO_CODE_LEN;
- for (; *fmt != '\0'; ++fmt)
- switch (*fmt) {
- case '1':
- nlen += IPO_INT_LEN;
- if (len < nlen)
- return (0);
- memcpy(&ipb.val1, p, IPO_INT_LEN);
- ipb.val1 = ntohl(ipb.val1);
- p += IPO_INT_LEN;
- break;
- case '2':
- nlen += IPO_INT_LEN;
- if (len < nlen)
- return (0);
- memcpy(&ipb.val2, p, IPO_INT_LEN);
- ipb.val2 = ntohl(ipb.val2);
- p += IPO_INT_LEN;
- break;
- case 's':
- nlen += IPO_INT_LEN;
- if (len < nlen)
- return (0);
- memcpy(&ipb.len, p, IPO_INT_LEN);
- ipb.len = ntohl(ipb.len);
- p += IPO_INT_LEN;
- nlen += ipb.len;
- if (len < nlen)
- return (0);
- ipb.str = p;
- p += ipb.len;
- break;
- }
- *skipp += nlen;
-
- switch (bp[0]) {
- case IPO_ADDSTR:
-#ifdef TR
- trace("addnstr {%.*s}\n", (int)ipb.len, ipb.str);
-#endif
- (void)addnstr(ipb.str, ipb.len);
- break;
- case IPO_ATTRIBUTE:
- switch (ipb.val1) {
- case SA_ALTERNATE:
-#ifdef TR
- trace("attr: alternate\n");
-#endif
- /*
- * XXX
- * Nothing.
- */
- break;
- case SA_INVERSE:
-#ifdef TR
- trace("attr: inverse\n");
-#endif
- if (ipb.val2)
- (void)standout();
- else
- (void)standend();
- break;
- default:
- abort();
- /* NOTREACHED */
- }
- break;
- case IPO_BELL:
-#ifdef TR
- trace("bell\n");
-#endif
- (void)write(1, "\007", 1); /* '\a' */
- break;
- case IPO_BUSY:
-#ifdef TR
- trace("busy {%.*s}\n", (int)ipb.len, ipb.str);
-#endif
- /*
- * XXX
- * Nothing...
- * ip_busy(ipb.str, ipb.len);
- */
- break;
- case IPO_CLRTOEOL:
-#ifdef TR
- trace("clrtoeol\n");
-#endif
- clrtoeol();
- break;
- case IPO_DELETELN:
-#ifdef TR
- trace("deleteln\n");
-#endif
- deleteln();
- break;
- case IPO_INSERTLN:
-#ifdef TR
- trace("insertln\n");
-#endif
- insertln();
- break;
- case IPO_MOVE:
-#ifdef TR
- trace("move: %lu %lu\n", (u_long)ipb.val1, (u_long)ipb.val2);
-#endif
- (void)move(ipb.val1, ipb.val2);
- break;
- case IPO_REDRAW:
-#ifdef TR
- trace("redraw\n");
-#endif
- clearok(curscr, 1);
- refresh();
- break;
- case IPO_REFRESH:
-#ifdef TR
- trace("refresh\n");
-#endif
- refresh();
- break;
- case IPO_RENAME:
-#ifdef TR
- trace("rename {%.*s}\n", (int)ipb.len, ipb.str);
-#endif
- /*
- * XXX
- * Nothing...
- * ip_rename(ipb.str, ipb.len);
- */
- break;
- case IPO_REWRITE:
-#ifdef TR
- trace("rewrite {%lu}\n", (u_long)ipb.val1);
-#endif
- getyx(stdscr, oldy, oldx);
- for (lno = ipb.val1, cno = spcnt = 0;;) {
- (void)move(lno, cno);
- ch = winch(stdscr);
- if (isblank(ch))
- ++spcnt;
- else {
- (void)move(lno, cno - spcnt);
- for (; spcnt > 0; --spcnt)
- (void)addch(' ');
- (void)addch(ch);
- }
- if (++cno >= cols)
- break;
- }
- (void)move(oldy, oldx);
- break;
- default:
- /*
- * XXX: Protocol is out of sync?
- */
- abort();
- }
-
- return (1);
-}
-
-/*
- * arg_format
- */
-void
-arg_format(argcp, argvp, i_fd, o_fd)
- int *argcp, i_fd, o_fd;
- char **argvp[];
-{
- char **largv, *iarg, *p;
-
- /* Get space for the argument array and the -I argument. */
- if ((iarg = malloc(64)) == NULL ||
- (largv = malloc((*argcp + 3) * sizeof(char *))) == NULL) {
- perror("ip_cl");
- exit (1);
- }
- memcpy(largv + 2, *argvp, *argcp * sizeof(char *) + 1);
-
- /* Reset argv[0] to be the exec'd program. */
- if ((p = strrchr(VI, '/')) == NULL)
- largv[0] = VI;
- else
- largv[0] = p + 1;
-
- /* Create the -I argument. */
- (void)sprintf(iarg, "-I%d%s%d", i_fd, ".", o_fd);
- largv[1] = iarg;
-
- /* Reset the argument array. */
- *argvp = largv;
-}
-
-/*
- * ip_cur_init --
- * Initialize the curses screen.
- */
-void
-ip_cur_init()
-{
- /*
- * XXX
- * This is 4BSD curses' specific -- if this is to be a real program
- * we'll have to do all the stuff that we do in the cl directory to
- * run with different curses variants.
- */
- if (initscr() == ERR) {
- perror("ip_cl: initscr");
- exit (1);
- }
- noecho();
- nonl();
- raw();
- idlok(stdscr, 1);
-}
-
-/*
- * ip_cur_end --
- * End the curses screen.
- */
-void
-ip_cur_end()
-{
- (void)move(0, 0);
- (void)deleteln();
- (void)move(rows - 1, 0);
- (void)refresh();
- (void)endwin();
-}
-
-/*
- * ip_siginit --
- * Initialize the signals.
- */
-void
-ip_siginit()
-{
- /* We need to know if vi dies horribly. */
- (void)signal(SIGCHLD, onchld);
-
- /* We want to allow interruption at least for now. */
- (void)signal(SIGINT, onintr);
-
-#ifdef SIGWINCH
- /* We need to know if the screen is resized. */
- (void)signal(SIGWINCH, onwinch);
-#endif
-}
-
-/*
- * ip_resize --
- * Send the window size.
- */
-void
-ip_resize()
-{
- struct winsize win;
- IP_BUF ipb;
-
- if (ioctl(STDERR_FILENO, TIOCGWINSZ, &win) == -1) {
- perror("ip_cl: TIOCGWINSZ");
- exit(1);
- }
-
- if (rows == win.ws_row && cols == win.ws_col)
- return;
-
- ipb.val1 = rows = win.ws_row;
- ipb.val2 = cols = win.ws_col;
- ipb.code = IPO_RESIZE;
- ip_send("12", &ipb);
-}
-
-/*
- * ip_send --
- * Construct and send an IP buffer.
- */
-int
-ip_send(fmt, ipbp)
- char *fmt;
- IP_BUF *ipbp;
-{
- static char *bp;
- static size_t blen;
- size_t off;
- u_int32_t ilen;
- int nlen, n, nw;
- char *p;
-
- if (blen == 0 && (bp = malloc(blen = 512)) == NULL)
- nomem();
-
- p = bp;
- nlen = 0;
- *p++ = ipbp->code;
- nlen += IPO_CODE_LEN;
-
- if (fmt != NULL)
- for (; *fmt != '\0'; ++fmt)
- switch (*fmt) {
- case '1': /* Value 1. */
- ilen = htonl(ipbp->val1);
- goto value;
- case '2': /* Value 2. */
- ilen = htonl(ipbp->val2);
-value: nlen += IPO_INT_LEN;
- if (nlen >= blen) {
- blen = blen * 2 + nlen;
- off = p - bp;
- if ((bp = realloc(bp, blen)) == NULL)
- nomem();
- p = bp + off;
- }
- memmove(p, &ilen, IPO_INT_LEN);
- p += IPO_INT_LEN;
- break;
- case 's': /* String. */
- ilen = ipbp->len; /* XXX: conversion. */
- ilen = htonl(ilen);
- nlen += IPO_INT_LEN + ipbp->len;
- if (nlen >= blen) {
- blen = blen * 2 + nlen;
- off = p - bp;
- if ((bp = realloc(bp, blen)) == NULL)
- nomem();
- p = bp + off;
- }
- memmove(p, &ilen, IPO_INT_LEN);
- p += IPO_INT_LEN;
- memmove(p, ipbp->str, ipbp->len);
- p += ipbp->len;
- break;
- }
-#ifdef TR
- trace("WROTE: ");
- for (n = p - bp, p = bp; n > 0; --n, ++p)
- if (isprint(*p))
- (void)trace("%c", *p);
- else
- trace("<%x>", (u_char)*p);
- trace("\n");
-#endif
-
- for (n = p - bp, p = bp; n > 0; n -= nw, p += nw)
- if ((nw = write(o_fd, p, n)) < 0) {
- perror("ip_cl: write");
- exit(1);
- }
-
- return (0);
-}
-
-void
-nomem()
-{
- perror("ip_cl");
- exit (1);
-}
-
-/*
- * onchld --
- * Handle SIGCHLD.
- */
-void
-onchld(signo)
- int signo;
-{
- die = 1;
-
-#ifdef TR
- trace("SIGCHLD\n");
-#endif
-
- /* Interrupt select if it's running. */
- (void)kill(getpid(), SIGINT);
-}
-
-/*
- * onintr --
- * Handle SIGINT.
- */
-void
-onintr(signo)
- int signo;
-{
- /*
- * If we receive an interrupt, we may have sent it ourselves.
- * If not, die from the signal.
- */
- if (die)
- return;
- (void)signal(SIGINT, SIG_DFL);
- kill(getpid(), SIGINT);
-}
-
-/*
- * onwinch --
- * Handle SIGWINCH.
- */
-void
-onwinch(signo)
- int signo;
-{
- resize = 1;
-}
-
-void
-attach()
-{
- int fd;
- char ch;
-
- (void)printf("process %lu waiting, enter <CR> to continue: ",
- (u_long)getpid());
- (void)fflush(stdout);
-
- if ((fd = open(_PATH_TTY, O_RDONLY, 0)) < 0) {
- perror(_PATH_TTY);
- exit (1);;
- }
- do {
- if (read(fd, &ch, 1) != 1) {
- (void)close(fd);
- return;
- }
- } while (ch != '\n' && ch != '\r');
- (void)close(fd);
-}
-
-#ifdef TR
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-/*
- * TR --
- * debugging trace routine.
- */
-void
-#ifdef __STDC__
-trace(const char *fmt, ...)
-#else
-trace(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- static FILE *tfp;
- va_list ap;
-
- if (tfp == NULL && (tfp = fopen(TR, "w")) == NULL)
- tfp = stderr;
-
-#ifdef __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- (void)vfprintf(tfp, fmt, ap);
- va_end(ap);
-
- (void)fflush(tfp);
-}
-#endif
-
-void
-usage()
-{
- (void)fprintf(stderr, "usage: ip_cl [-D]\n");
- exit(1);
-}
diff --git a/perl_api/VI.pod b/perl_api/VI.pod
deleted file mode 100644
index a87e24d911d8..000000000000
--- a/perl_api/VI.pod
+++ /dev/null
@@ -1,218 +0,0 @@
-=head1 NAME
-
-VI - VI module within perl embedded nvi
-
-=head1 SYNOPSIS
-
- sub wc {
- my $words;
- $i = $VI::StartLine;
- while ($i <= $VI::StopLine) {
- $_ = VI::GetLine($VI::ScreenId, $i++);
- $words+=split;
- }
- VI::Msg($VI::ScreenId,"$words words");
- }
-
-=head1 DESCRIPTION
-
-This pseudo module is available to perl programs run from within nvi and
-provides access to the files being edited and some internal data.
-
-Beware that you should not use this module from within a C<perldo> or
-from within an C<END> block or a C<DESTROY> method.
-
-=head2 Variables
-
-These are set by nvi before starting each perl command.
-
-=over 8
-
-=item * $ScreenId
-
-Screen id of the current screen.
-
-=item * $StartLine
-
-Line number of the first line of the selected range or of the file if no
-range was specified.
-
-=item * $StopLine
-
-Line number of the last line of the selected range or of the file if no
-range was specified.
-
-=back
-
-=head2 Functions
-
-=over 8
-
-=item * AppendLine
-
- VI::AppendLine(screenId,lineNumber,text);
-
-Append the string text after the line in lineNumber.
-
-=item * DelLine
-
- VI::DelLine(screenId,lineNum);
-
-Delete lineNum.
-
-=item * EndScreen
-
-VI::EndScreen(screenId);
-
-End a screen.
-
-=item * FindScreen
-
- VI::FindScreen(file);
-
-Return the screen id associated with file name.
-
-=item * GetCursor
-
- ($line, $column) = VI::GetCursor(screenId);
-
-Return the current cursor position as a list with two elements.
-
-=item * GetLine
-
- VI::GetLine(screenId,lineNumber);
-
-Return lineNumber.
-
-=item * GetMark
-
- ($line, $column) = VI::GetMark(screenId,mark);
-
-Return the mark's cursor position as a list with two elements.
-
-=item * GetOpt
-
- VI::GetOpt(screenId,option);
-
-Return the value of an option.
-
-=item * InsertLine
-
- VI::InsertLine(screenId,lineNumber,text);
-
-Insert the string text before the line in lineNumber.
-
-=item * LastLine
-
- VI::LastLine(screenId);
-
-Return the last line in the screen.
-
-=item * MapKey
-
- VI::MapKey(screenId,key,perlproc);
-
-Associate a key with a perl procedure.
-
-=item * Msg
-
- VI::Msg(screenId,text);
-
-Set the message line to text.
-
-=item * NewScreen
-
- VI::NewScreen(screenId);
- VI::NewScreen(screenId,file);
-
-Create a new screen. If a filename is specified then the screen is
-opened with that file.
-
-=item * Run
-
- VI::Run(screenId,cmd);
-
-Run the ex command cmd.
-
-=item * SetCursor
-
- VI::SetCursor(screenId,line,column);
-
-Set the cursor to the line and column numbers supplied.
-
-=item * SetLine
-
- VI::SetLine(screenId,lineNumber,text);
-
-Set lineNumber to the text supplied.
-
-=item * SetMark
-
- VI::SetMark(screenId,mark,line,column);
-
-Set the mark to the line and column numbers supplied.
-
-=item * SetOpt
-
- VI::SetOpt(screenId,command);
-
-Set an option.
-
-=item * SwitchScreen
-
- VI::SwitchScreen(screenId,screenId);
-
-Change the current focus to screen.
-
-=item * UnmapKey
-
- VI::UnmmapKey(screenId,key);
-
-Unmap a key.
-
-=item * Warn
-
-This is the default warning handler.
-It adds any warnings to the error string.
-
-=back
-
-=head1 EXAMPLES
-
- sub showmarks {
- my ($mark, $all);
- for $mark ('a' .. 'z') {
- eval {VI::GetMark($VI::ScreenId, $mark)};
- $all .= $mark unless ($@);
- }
- VI::Msg($VI::ScreenId,"Set marks: $all");
- }
-
- sub forall {
- my ($code) = shift;
- my ($i) = $VI::StartLine-1;
- while (++$i <= $VI::StopLine) {
- $_ = VI::GetLine($VI::ScreenId, $i);
- VI::SetLine($VI::ScreenId, $i, $_) if(&$code);
- }
- }
-
-Now you can do
-
- :perl forall sub{s/perlre/substitution/}
-
-Although you'll probably use
-
- :perldo s/perlre/substitution/
-
-instead.
-
-See L<perlre> for perl regular expressions.
-
-=head1 SEE ALSO
-
-L<nviperl>
-
-=head1 AUTHOR
-
-Sven Verdoolaege <skimo@dns.ufsia.ac.be>
diff --git a/perl_api/nviperl.pod b/perl_api/nviperl.pod
deleted file mode 100644
index 43850d8b6363..000000000000
--- a/perl_api/nviperl.pod
+++ /dev/null
@@ -1,43 +0,0 @@
-=head1 NAME
-
-nviperl - nvi with embedded perl
-
-=head1 SYNOPSIS
-
- :perl require 'wc.pl'
- :perl wc
- :,$perldo $_=reverse($_)
-
-=head1 DESCRIPTION
-
-nvi with embedded perl allows you to run perl commands from within nvi.
-Two additional commands are made available when you enable the perl
-interpreter:
-
-=over 8
-
-=item * perl cmd
-
-The perl command passes the specified commands to the perl interpreter.
-The C<$VI::ScreenId>, C<$VI::StartLine> and C<$VI::StopLine> are set.
-To find out how to maniplulate the nvi screens, see L<VI>.
-
-=item * perldo cmd
-
-The perldo command runs the specified commands on each line of the range
-(every line of the file if no range specified). Before running the
-command the line is copied into $_. If the command returns a true value
-the line is replaced by the new value of $_.
-
-The perldo commando does B<not> set the C<VI> variables. (If you think
-this is a bad idea, tell me.)
-
-=back
-
-=head1 SEE ALSO
-
-L<VI>
-
-=head1 AUTHOR
-
-Sven Verdoolaege <skimo@dns.ufsia.ac.be>
diff --git a/perl_api/perl.xs b/perl_api/perl.xs
deleted file mode 100644
index 0b48cded5bfc..000000000000
--- a/perl_api/perl.xs
+++ /dev/null
@@ -1,1115 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- * Copyright (c) 1995
- * George V. Neville-Neil. All rights reserved.
- * Copyright (c) 1996
- * Sven Verdoolaege. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)perl.xs 8.27 (Berkeley) 10/16/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-
-#include "perl_extern.h"
-
-static void msghandler __P((SCR *, mtype_t, char *, size_t));
-
-extern GS *__global_list; /* XXX */
-
-static char *errmsg = 0;
-
-/*
- * INITMESSAGE --
- * Macros to point messages at the Perl message handler.
- */
-#define INITMESSAGE \
- scr_msg = __global_list->scr_msg; \
- __global_list->scr_msg = msghandler;
-#define ENDMESSAGE \
- __global_list->scr_msg = scr_msg; \
- if (rval) croak(errmsg);
-
-static void xs_init __P((void));
-
-/*
- * perl_end --
- * Clean up perl interpreter
- *
- * PUBLIC: int perl_end __P((GS *));
- */
-int
-perl_end(gp)
- GS *gp;
-{
- /*
- * Call perl_run and perl_destuct to call END blocks and DESTROY
- * methods.
- */
- if (gp->perl_interp) {
- /*Irestartop = 0; / * XXX */
- perl_run(gp->perl_interp);
- perl_destruct(gp->perl_interp);
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
- perl_free(gp->perl_interp);
-#endif
- }
-}
-
-/*
- * perl_eval
- * Evaluate a string
- * We don't use mortal SVs because no one will clean up after us
- */
-static void
-perl_eval(string)
- char *string;
-{
-#ifdef HAVE_PERL_5_003_01
- SV* sv = newSVpv(string, 0);
-
- perl_eval_sv(sv, G_DISCARD | G_NOARGS);
- SvREFCNT_dec(sv);
-#else
- char *argv[2];
-
- argv[0] = string;
- argv[1] = NULL;
- perl_call_argv("_eval_", G_EVAL | G_DISCARD | G_KEEPERR, argv);
-#endif
-}
-
-/*
- * perl_init --
- * Create the perl commands used by nvi.
- *
- * PUBLIC: int perl_init __P((SCR *));
- */
-int
-perl_init(scrp)
- SCR *scrp;
-{
- AV * av;
- GS *gp;
- char *bootargs[] = { "VI", NULL };
-#ifndef USE_SFIO
- SV *svcurscr;
-#endif
-
-#ifndef HAVE_PERL_5_003_01
- static char *args[] = { "", "-e", "sub _eval_ { eval $_[0] }" };
-#else
- static char *args[] = { "", "-e", "" };
-#endif
- STRLEN length;
- char *file = __FILE__;
-
- gp = scrp->gp;
- gp->perl_interp = perl_alloc();
- perl_construct(gp->perl_interp);
- if (perl_parse(gp->perl_interp, xs_init, 3, args, 0)) {
- perl_destruct(gp->perl_interp);
- perl_free(gp->perl_interp);
- gp->perl_interp = NULL;
- return 1;
- }
- perl_call_argv("VI::bootstrap", G_DISCARD, bootargs);
- perl_eval("$SIG{__WARN__}='VI::Warn'");
-
- av_unshift(av = GvAVn(incgv), 1);
- av_store(av, 0, newSVpv(_PATH_PERLSCRIPTS,
- sizeof(_PATH_PERLSCRIPTS)-1));
-
-#ifdef USE_SFIO
- sfdisc(PerlIO_stdout(), sfdcnewnvi(scrp));
- sfdisc(PerlIO_stderr(), sfdcnewnvi(scrp));
-#else
- svcurscr = perl_get_sv("curscr", TRUE);
- sv_magic((SV *)gv_fetchpv("STDOUT",TRUE, SVt_PVIO), svcurscr,
- 'q', Nullch, 0);
- sv_magic((SV *)gv_fetchpv("STDERR",TRUE, SVt_PVIO), svcurscr,
- 'q', Nullch, 0);
-#endif /* USE_SFIO */
- return (0);
-}
-
-/*
- * perl_screen_end
- * Remove all refences to the screen to be destroyed
- *
- * PUBLIC: int perl_screen_end __P((SCR*));
- */
-int
-perl_screen_end(scrp)
- SCR *scrp;
-{
- if (scrp->perl_private) {
- sv_setiv((SV*) scrp->perl_private, 0);
- }
- return 0;
-}
-
-static void
-my_sighandler(i)
- int i;
-{
- croak("Perl command interrupted by SIGINT");
-}
-
-/* Create a new reference to an SV pointing to the SCR structure
- * The perl_private part of the SCR structure points to the SV,
- * so there can only be one such SV for a particular SCR structure.
- * When the last reference has gone (DESTROY is called),
- * perl_private is reset; When the screen goes away before
- * all references are gone, the value of the SV is reset;
- * any subsequent use of any of those reference will produce
- * a warning. (see typemap)
- */
-static SV *
-newVIrv(rv, screen)
- SV *rv;
- SCR *screen;
-{
- sv_upgrade(rv, SVt_RV);
- if (!screen->perl_private) {
- screen->perl_private = newSV(0);
- sv_setiv(screen->perl_private, (IV) screen);
- }
- else SvREFCNT_inc(screen->perl_private);
- SvRV(rv) = screen->perl_private;
- SvROK_on(rv);
- return sv_bless(rv, gv_stashpv("VI", TRUE));
-}
-
-
-/*
- * perl_ex_perl -- :[line [,line]] perl [command]
- * Run a command through the perl interpreter.
- *
- * PUBLIC: int perl_ex_perl __P((SCR*, CHAR_T *, size_t, recno_t, recno_t));
- */
-int
-perl_ex_perl(scrp, cmdp, cmdlen, f_lno, t_lno)
- SCR *scrp;
- CHAR_T *cmdp;
- size_t cmdlen;
- recno_t f_lno, t_lno;
-{
- static SV *svcurscr = 0, *svstart, *svstop, *svid;
- GS *gp;
- STRLEN length;
- size_t len;
- char *err;
- Signal_t (*istat)();
-
- /* Initialize the interpreter. */
- gp = scrp->gp;
- if (!svcurscr) {
- if (gp->perl_interp == NULL && perl_init(scrp))
- return (1);
- SvREADONLY_on(svcurscr = perl_get_sv("curscr", TRUE));
- SvREADONLY_on(svstart = perl_get_sv("VI::StartLine", TRUE));
- SvREADONLY_on(svstop = perl_get_sv("VI::StopLine", TRUE));
- SvREADONLY_on(svid = perl_get_sv("VI::ScreenId", TRUE));
- }
-
- sv_setiv(svstart, f_lno);
- sv_setiv(svstop, t_lno);
- newVIrv(svcurscr, scrp);
- /* Backwards compatibility. */
- newVIrv(svid, scrp);
-
- istat = signal(SIGINT, my_sighandler);
- perl_eval(cmdp);
- signal(SIGINT, istat);
-
- SvREFCNT_dec(SvRV(svcurscr));
- SvROK_off(svcurscr);
- SvREFCNT_dec(SvRV(svid));
- SvROK_off(svid);
-
- err = SvPV(GvSV(errgv), length);
- if (!length)
- return (0);
-
- err[length - 1] = '\0';
- msgq(scrp, M_ERR, "perl: %s", err);
- return (1);
-}
-
-/*
- * replace_line
- * replace a line with the contents of the perl variable $_
- * lines are split at '\n's
- * if $_ is undef, the line is deleted
- * returns possibly adjusted linenumber
- */
-static int
-replace_line(scrp, line, t_lno)
- SCR *scrp;
- recno_t line, *t_lno;
-{
- char *str, *next;
- size_t len;
-
- if (SvOK(GvSV(defgv))) {
- str = SvPV(GvSV(defgv),len);
- next = memchr(str, '\n', len);
- api_sline(scrp, line, str, next ? (next - str) : len);
- while (next++) {
- len -= next - str;
- next = memchr(str = next, '\n', len);
- api_iline(scrp, ++line, str, next ? (next - str) : len);
- (*t_lno)++;
- }
- } else {
- api_dline(scrp, line--);
- (*t_lno)--;
- }
- return line;
-}
-
-/*
- * perl_ex_perldo -- :[line [,line]] perl [command]
- * Run a set of lines through the perl interpreter.
- *
- * PUBLIC: int perl_ex_perldo __P((SCR*, CHAR_T *, size_t, recno_t, recno_t));
- */
-int
-perl_ex_perldo(scrp, cmdp, cmdlen, f_lno, t_lno)
- SCR *scrp;
- CHAR_T *cmdp;
- size_t cmdlen;
- recno_t f_lno, t_lno;
-{
- static SV *svcurscr = 0, *svstart, *svstop, *svid;
- CHAR_T *p;
- GS *gp;
- STRLEN length;
- size_t len;
- recno_t i;
- char *str;
-#ifndef HAVE_PERL_5_003_01
- char *argv[2];
-#else
- SV* sv;
-#endif
- dSP;
-
- /* Initialize the interpreter. */
- gp = scrp->gp;
- if (!svcurscr) {
- if (gp->perl_interp == NULL && perl_init(scrp))
- return (1);
- SPAGAIN;
- SvREADONLY_on(svcurscr = perl_get_sv("curscr", TRUE));
- SvREADONLY_on(svstart = perl_get_sv("VI::StartLine", TRUE));
- SvREADONLY_on(svstop = perl_get_sv("VI::StopLine", TRUE));
- SvREADONLY_on(svid = perl_get_sv("VI::ScreenId", TRUE));
- }
-
-#ifndef HAVE_PERL_5_003_01
- argv[0] = cmdp;
- argv[1] = NULL;
-#else
- length = strlen(cmdp);
- sv = newSV(length + sizeof("sub VI::perldo {")-1 + 1 /* } */);
- sv_setpvn(sv, "sub VI::perldo {", sizeof("sub VI::perldo {")-1);
- sv_catpvn(sv, cmdp, length);
- sv_catpvn(sv, "}", 1);
- perl_eval_sv(sv, G_DISCARD | G_NOARGS);
- SvREFCNT_dec(sv);
- str = SvPV(GvSV(errgv),length);
- if (length)
- goto err;
-#endif
-
- newVIrv(svcurscr, scrp);
- /* Backwards compatibility. */
- newVIrv(svid, scrp);
-
- ENTER;
- SAVETMPS;
- for (i = f_lno; i <= t_lno && !api_gline(scrp, i, &str, &len); i++) {
- sv_setpvn(GvSV(defgv),str,len);
- sv_setiv(svstart, i);
- sv_setiv(svstop, i);
-#ifndef HAVE_PERL_5_003_01
- perl_call_argv("_eval_", G_SCALAR | G_EVAL | G_KEEPERR, argv);
-#else
- PUSHMARK(sp);
- perl_call_pv("VI::perldo", G_SCALAR | G_EVAL);
-#endif
- str = SvPV(GvSV(errgv), length);
- if (length) break;
- SPAGAIN;
- if(SvTRUEx(POPs))
- i = replace_line(scrp, i, &t_lno);
- PUTBACK;
- }
- FREETMPS;
- LEAVE;
-
- SvREFCNT_dec(SvRV(svcurscr));
- SvROK_off(svcurscr);
- SvREFCNT_dec(SvRV(svid));
- SvROK_off(svid);
-
- if (!length)
- return (0);
-
-err: str[length - 1] = '\0';
- msgq(scrp, M_ERR, "perl: %s", str);
- return (1);
-}
-
-/*
- * msghandler --
- * Perl message routine so that error messages are processed in
- * Perl, not in nvi.
- */
-static void
-msghandler(sp, mtype, msg, len)
- SCR *sp;
- mtype_t mtype;
- char *msg;
- size_t len;
-{
- /* Replace the trailing <newline> with an EOS. */
- /* Let's do that later instead */
- if (errmsg) free (errmsg);
- errmsg = malloc(len + 1);
- memcpy(errmsg, msg, len);
- errmsg[len] = '\0';
-}
-
-/* Register any extra external extensions */
-
-extern void boot_DynaLoader _((CV* cv));
-extern void boot_VI _((CV* cv));
-
-static void
-xs_init()
-{
-#ifdef HAVE_PERL_5_003_01
- dXSUB_SYS;
-#endif
- char *file = __FILE__;
-
- newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
- newXS("VI::bootstrap", boot_VI, file);
-}
-
-typedef SCR * VI;
-typedef SCR * VI__OPT;
-typedef SCR * VI__MAP;
-typedef SCR * VI__MARK;
-typedef AV * AVREF;
-
-MODULE = VI PACKAGE = VI
-
-# msg --
-# Set the message line to text.
-#
-# Perl Command: VI::Msg
-# Usage: VI::Msg screenId text
-
-void
-Msg(screen, text)
- VI screen
- char * text
-
- ALIAS:
- PRINT = 1
-
- CODE:
- api_imessage(screen, text);
-
-# XS_VI_escreen --
-# End a screen.
-#
-# Perl Command: VI::EndScreen
-# Usage: VI::EndScreen screenId
-
-void
-EndScreen(screen)
- VI screen
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_escreen(screen);
- ENDMESSAGE;
-
-# XS_VI_iscreen --
-# Create a new screen. If a filename is specified then the screen
-# is opened with that file.
-#
-# Perl Command: VI::NewScreen
-# Usage: VI::NewScreen screenId [file]
-
-VI
-Edit(screen, ...)
- VI screen
-
- ALIAS:
- NewScreen = 1
-
- PROTOTYPE: $;$
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char *file;
- SCR *nsp;
-
- CODE:
- file = (items == 1) ? NULL : (char *)SvPV(ST(1),na);
- INITMESSAGE;
- rval = api_edit(screen, file, &nsp, ix);
- ENDMESSAGE;
-
- RETVAL = ix ? nsp : screen;
-
- OUTPUT:
- RETVAL
-
-# XS_VI_fscreen --
-# Return the screen id associated with file name.
-#
-# Perl Command: VI::FindScreen
-# Usage: VI::FindScreen file
-
-VI
-FindScreen(file)
- char *file
-
- PREINIT:
- SCR *fsp;
- CODE:
- RETVAL = api_fscreen(0, file);
-
-# XS_VI_aline --
-# -- Append the string text after the line in lineNumber.
-#
-# Perl Command: VI::AppendLine
-# Usage: VI::AppendLine screenId lineNumber text
-
-void
-AppendLine(screen, linenumber, text)
- VI screen
- int linenumber
- char *text
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- STRLEN length;
-
- CODE:
- SvPV(ST(2), length);
- INITMESSAGE;
- rval = api_aline(screen, linenumber, text, length);
- ENDMESSAGE;
-
-# XS_VI_dline --
-# Delete lineNum.
-#
-# Perl Command: VI::DelLine
-# Usage: VI::DelLine screenId lineNum
-
-void
-DelLine(screen, linenumber)
- VI screen
- int linenumber
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_dline(screen, (recno_t)linenumber);
- ENDMESSAGE;
-
-# XS_VI_gline --
-# Return lineNumber.
-#
-# Perl Command: VI::GetLine
-# Usage: VI::GetLine screenId lineNumber
-
-char *
-GetLine(screen, linenumber)
- VI screen
- int linenumber
-
- PREINIT:
- size_t len;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char *line, *p;
-
- PPCODE:
- INITMESSAGE;
- rval = api_gline(screen, (recno_t)linenumber, &p, &len);
- ENDMESSAGE;
-
- EXTEND(sp,1);
- PUSHs(sv_2mortal(newSVpv(p, len)));
-
-# XS_VI_sline --
-# Set lineNumber to the text supplied.
-#
-# Perl Command: VI::SetLine
-# Usage: VI::SetLine screenId lineNumber text
-
-void
-SetLine(screen, linenumber, text)
- VI screen
- int linenumber
- char *text
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- STRLEN length;
-
- CODE:
- SvPV(ST(2), length);
- INITMESSAGE;
- rval = api_sline(screen, linenumber, text, length);
- ENDMESSAGE;
-
-# XS_VI_iline --
-# Insert the string text before the line in lineNumber.
-#
-# Perl Command: VI::InsertLine
-# Usage: VI::InsertLine screenId lineNumber text
-
-void
-InsertLine(screen, linenumber, text)
- VI screen
- int linenumber
- char *text
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- STRLEN length;
-
- CODE:
- SvPV(ST(2), length);
- INITMESSAGE;
- rval = api_iline(screen, linenumber, text, length);
- ENDMESSAGE;
-
-# XS_VI_lline --
-# Return the last line in the screen.
-#
-# Perl Command: VI::LastLine
-# Usage: VI::LastLine screenId
-
-int
-LastLine(screen)
- VI screen
-
- PREINIT:
- recno_t last;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_lline(screen, &last);
- ENDMESSAGE;
- RETVAL=last;
-
- OUTPUT:
- RETVAL
-
-# XS_VI_getmark --
-# Return the mark's cursor position as a list with two elements.
-# {line, column}.
-#
-# Perl Command: VI::GetMark
-# Usage: VI::GetMark screenId mark
-
-void
-GetMark(screen, mark)
- VI screen
- char mark
-
- PREINIT:
- struct _mark cursor;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- PPCODE:
- INITMESSAGE;
- rval = api_getmark(screen, (int)mark, &cursor);
- ENDMESSAGE;
-
- EXTEND(sp,2);
- PUSHs(sv_2mortal(newSViv(cursor.lno)));
- PUSHs(sv_2mortal(newSViv(cursor.cno)));
-
-# XS_VI_setmark --
-# Set the mark to the line and column numbers supplied.
-#
-# Perl Command: VI::SetMark
-# Usage: VI::SetMark screenId mark line column
-
-void
-SetMark(screen, mark, line, column)
- VI screen
- char mark
- int line
- int column
-
- PREINIT:
- struct _mark cursor;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- cursor.lno = line;
- cursor.cno = column;
- rval = api_setmark(screen, (int)mark, &cursor);
- ENDMESSAGE;
-
-# XS_VI_getcursor --
-# Return the current cursor position as a list with two elements.
-# {line, column}.
-#
-# Perl Command: VI::GetCursor
-# Usage: VI::GetCursor screenId
-
-void
-GetCursor(screen)
- VI screen
-
- PREINIT:
- struct _mark cursor;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- PPCODE:
- INITMESSAGE;
- rval = api_getcursor(screen, &cursor);
- ENDMESSAGE;
-
- EXTEND(sp,2);
- PUSHs(sv_2mortal(newSViv(cursor.lno)));
- PUSHs(sv_2mortal(newSViv(cursor.cno)));
-
-# XS_VI_setcursor --
-# Set the cursor to the line and column numbers supplied.
-#
-# Perl Command: VI::SetCursor
-# Usage: VI::SetCursor screenId line column
-
-void
-SetCursor(screen, line, column)
- VI screen
- int line
- int column
-
- PREINIT:
- struct _mark cursor;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- cursor.lno = line;
- cursor.cno = column;
- rval = api_setcursor(screen, &cursor);
- ENDMESSAGE;
-
-# XS_VI_swscreen --
-# Change the current focus to screen.
-#
-# Perl Command: VI::SwitchScreen
-# Usage: VI::SwitchScreen screenId screenId
-
-void
-SwitchScreen(screenFrom, screenTo)
- VI screenFrom
- VI screenTo
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_swscreen(screenFrom, screenTo);
- ENDMESSAGE;
-
-# XS_VI_map --
-# Associate a key with a perl procedure.
-#
-# Perl Command: VI::MapKey
-# Usage: VI::MapKey screenId key perlproc
-
-void
-MapKey(screen, key, perlproc)
- VI screen
- char *key
- SV *perlproc
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- int length;
- char *command;
- SV *svc;
-
- CODE:
- INITMESSAGE;
- svc = sv_2mortal(newSVpv(":perl ", 6));
- sv_catsv(svc, perlproc);
- command = SvPV(svc, length);
- rval = api_map(screen, key, command, length);
- ENDMESSAGE;
-
-# XS_VI_unmap --
-# Unmap a key.
-#
-# Perl Command: VI::UnmapKey
-# Usage: VI::UnmmapKey screenId key
-
-void
-UnmapKey(screen, key)
- VI screen
- char *key
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_unmap(screen, key);
- ENDMESSAGE;
-
-# XS_VI_opts_set --
-# Set an option.
-#
-# Perl Command: VI::SetOpt
-# Usage: VI::SetOpt screenId setting
-
-void
-SetOpt(screen, setting)
- VI screen
- char *setting
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- SV *svc;
-
- CODE:
- INITMESSAGE;
- svc = sv_2mortal(newSVpv(":set ", 5));
- sv_catpv(svc, setting);
- rval = api_run_str(screen, SvPV(svc, na));
- ENDMESSAGE;
-
-# XS_VI_opts_get --
-# Return the value of an option.
-#
-# Perl Command: VI::GetOpt
-# Usage: VI::GetOpt screenId option
-
-void
-GetOpt(screen, option)
- VI screen
- char *option
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char *value;
-
- PPCODE:
- INITMESSAGE;
- rval = api_opts_get(screen, option, &value, NULL);
- ENDMESSAGE;
-
- EXTEND(SP,1);
- PUSHs(sv_2mortal(newSVpv(value, 0)));
- free(value);
-
-# XS_VI_run --
-# Run the ex command cmd.
-#
-# Perl Command: VI::Run
-# Usage: VI::Run screenId cmd
-
-void
-Run(screen, command)
- VI screen
- char *command;
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_run_str(screen, command);
- ENDMESSAGE;
-
-void
-DESTROY(screen)
- VI screen
-
- CODE:
- screen->perl_private = 0;
-
-void
-Warn(warning)
- char *warning;
-
- PREINIT:
- int i;
- CODE:
- sv_catpv(GvSV(errgv),warning);
-
-#define TIED(package) \
- sv_magic((SV *) (hv = \
- (HV *)sv_2mortal((SV *)newHV())), \
- sv_setref_pv(sv_newmortal(), package, \
- newVIrv(newSV(0), screen)),\
- 'P', Nullch, 0);\
- RETVAL = newRV((SV *)hv)
-
-SV *
-Opt(screen)
- VI screen;
- PREINIT:
- HV *hv;
- CODE:
- TIED("VI::OPT");
- OUTPUT:
- RETVAL
-
-SV *
-Map(screen)
- VI screen;
- PREINIT:
- HV *hv;
- CODE:
- TIED("VI::MAP");
- OUTPUT:
- RETVAL
-
-SV *
-Mark(screen)
- VI screen
- PREINIT:
- HV *hv;
- CODE:
- TIED("VI::MARK");
- OUTPUT:
- RETVAL
-
-MODULE = VI PACKAGE = VI::OPT
-
-void
-DESTROY(screen)
- VI::OPT screen
-
- CODE:
- # typemap did all the checking
- SvREFCNT_dec((SV*)SvIV((SV*)SvRV(ST(0))));
-
-void
-FETCH(screen, key)
- VI::OPT screen
- char *key
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char *value;
- int boolvalue;
-
- PPCODE:
- INITMESSAGE;
- rval = api_opts_get(screen, key, &value, &boolvalue);
- if (!rval) {
- EXTEND(SP,1);
- PUSHs(sv_2mortal((boolvalue == -1) ? newSVpv(value, 0)
- : newSViv(boolvalue)));
- free(value);
- } else ST(0) = &sv_undef;
- rval = 0;
- ENDMESSAGE;
-
-void
-STORE(screen, key, value)
- VI::OPT screen
- char *key
- SV *value
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_opts_set(screen, key, SvPV(value, na), SvIV(value),
- SvTRUEx(value));
- ENDMESSAGE;
-
-MODULE = VI PACKAGE = VI::MAP
-
-void
-DESTROY(screen)
- VI::MAP screen
-
- CODE:
- # typemap did all the checking
- SvREFCNT_dec((SV*)SvIV((SV*)SvRV(ST(0))));
-
-void
-STORE(screen, key, perlproc)
- VI::MAP screen
- char *key
- SV *perlproc
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- int length;
- char *command;
- SV *svc;
-
- CODE:
- INITMESSAGE;
- svc = sv_2mortal(newSVpv(":perl ", 6));
- sv_catsv(svc, perlproc);
- command = SvPV(svc, length);
- rval = api_map(screen, key, command, length);
- ENDMESSAGE;
-
-void
-DELETE(screen, key)
- VI::MAP screen
- char *key
-
- PREINIT:
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_unmap(screen, key);
- ENDMESSAGE;
-
-MODULE = VI PACKAGE = VI::MARK
-
-void
-DESTROY(screen)
- VI::MARK screen
-
- CODE:
- # typemap did all the checking
- SvREFCNT_dec((SV*)SvIV((SV*)SvRV(ST(0))));
-
-AV *
-FETCH(screen, mark)
- VI::MARK screen
- char mark
-
- PREINIT:
- struct _mark cursor;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- INITMESSAGE;
- rval = api_getmark(screen, (int)mark, &cursor);
- ENDMESSAGE;
- RETVAL = newAV();
- av_push(RETVAL, newSViv(cursor.lno));
- av_push(RETVAL, newSViv(cursor.cno));
-
- OUTPUT:
- RETVAL
-
-void
-STORE(screen, mark, pos)
- VI::MARK screen
- char mark
- AVREF pos
-
- PREINIT:
- struct _mark cursor;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- CODE:
- if (av_len(pos) < 1)
- croak("cursor position needs 2 elements");
- INITMESSAGE;
- cursor.lno = SvIV(*av_fetch(pos, 0, 0));
- cursor.cno = SvIV(*av_fetch(pos, 1, 0));
- rval = api_setmark(screen, (int)mark, &cursor);
- ENDMESSAGE;
-
-void
-FIRSTKEY(screen, ...)
- VI::MARK screen
-
- ALIAS:
- NEXTKEY = 1
-
- PROTOTYPE: $;$
-
- PREINIT:
- struct _mark cursor;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int next;
- char key[] = {0, 0};
-
- PPCODE:
- if (items == 2) {
- next = 1;
- *key = *(char *)SvPV(ST(1),na);
- } else next = 0;
- if (api_nextmark(screen, next, key) != 1) {
- EXTEND(sp, 1);
- PUSHs(sv_2mortal(newSVpv(key, 1)));
- } else ST(0) = &sv_undef;
diff --git a/perl_api/perlsfio.c b/perl_api/perlsfio.c
deleted file mode 100644
index 20ff4773495a..000000000000
--- a/perl_api/perlsfio.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * Copyright (c) 1996
- * Keith Bostic. All rights reserved.
- * Copyright (c) 1996
- * Sven Verdoolaege. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)perlsfio.c 8.1 (Berkeley) 9/24/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-
-#include "perl_extern.h"
-
-/*
- * PUBLIC: #ifdef USE_SFIO
- */
-#ifdef USE_SFIO
-
-#define NIL(type) ((type)0)
-
-static int
-sfnviwrite(f, buf, n, disc)
-Sfio_t* f; /* stream involved */
-char* buf; /* buffer to read into */
-int n; /* number of bytes to read */
-Sfdisc_t* disc; /* discipline */
-{
- SCR *scrp;
-
- scrp = (SCR *)SvIV((SV*)SvRV(perl_get_sv("curscr", FALSE)));
- msgq(scrp, M_INFO, "%.*s", n, buf);
- return n;
-}
-
-/*
- * sfdcnewnvi --
- * Create nvi discipline
- *
- * PUBLIC: Sfdisc_t* sfdcnewnvi __P((SCR*));
- */
-
-Sfdisc_t *
-sfdcnewnvi(scrp)
- SCR *scrp;
-{
- Sfdisc_t* disc;
-
- MALLOC(scrp, disc, Sfdisc_t*, sizeof(Sfdisc_t));
- if (!disc) return disc;
-
- disc->readf = (Sfread_f)NULL;
- disc->writef = sfnviwrite;
- disc->seekf = (Sfseek_f)NULL;
- disc->exceptf = (Sfexcept_f)NULL;
- return disc;
-}
-
-/*
- * PUBLIC: #endif
- */
-#endif /* USE_SFIO */
diff --git a/perl_api/typemap b/perl_api/typemap
deleted file mode 100644
index 0e38a9c07bc7..000000000000
--- a/perl_api/typemap
+++ /dev/null
@@ -1,42 +0,0 @@
-TYPEMAP
-# Grr can't let it end in OBJ 'cause xsubpp would
-# s/OBJ$/REF/ that for the DESTROY function
-VI T_VIOBJNOMUNGE
-VI::OPT T_VIOBJREF
-VI::MAP T_VIOBJREF
-VI::MARK T_VIOBJREF
-AVREF T_AVREFREF
-
-INPUT
-T_AVREFREF
- if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV)
- $var = (AV *)SvRV($arg);
- else
- croak(\"$var is not a reference to an array\")
-T_VIOBJNOMUNGE
- if (sv_isa($arg, \"VI\")) {
- IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type) tmp;
- if (!tmp)
- croak(\"screen no longer exists\");
- }
- else
- croak(\"$var is not of type ${ntype}\")
-T_VIOBJREF
- if (sv_isa($arg, \"${ntype}\")) {
- IV tmp = SvIV((SV*)SvRV($arg));
- if (sv_isa((SV *)tmp, \"VI\")) {
- IV tmp2 = SvIV((SV*)SvRV((SV *)tmp));
- $var = ($type) tmp2;
- if (!tmp2)
- croak(\"screen no longer exists\");
- }
- else
- croak(\"$var is not of type ${ntype}\");
- }
- else
- croak(\"$var is not of type ${ntype}\")
-
-OUTPUT
-T_VIOBJNOMUNGE
- newVIrv($arg, $var);
diff --git a/perl_scripts/forall.pl b/perl_scripts/forall.pl
deleted file mode 100644
index b9f85013b17d..000000000000
--- a/perl_scripts/forall.pl
+++ /dev/null
@@ -1,10 +0,0 @@
-sub forall {
- my ($code) = shift;
- my ($i) = $VI::StartLine-1;
- while (++$i <= $VI::StopLine) {
- $_ = $curscr->GetLine($i);
- VI::SetLine($VI::ScreenId, $i, $_) if(&$code);
- }
-}
-
-1;
diff --git a/perl_scripts/make.pl b/perl_scripts/make.pl
deleted file mode 100644
index 118dd99a424c..000000000000
--- a/perl_scripts/make.pl
+++ /dev/null
@@ -1,27 +0,0 @@
-sub make {
- open MAKE, "make 2>&1 1>/dev/null |";
- while(<MAKE>) {
- if (($file, $line, $msg) = /([^: ]*):(\d*):(.+)/) {
- if ($file == $prevfile && $line == $prevline) {
- $error[-1]->[2] .= "\n$msg";
- } else {
- push @error, [$file, $line, $msg];
- ($prevline, $prevfile) = ($line, $file);
- }
- }
- }
- close MAKE;
-}
-
-sub nexterror {
- if ($index <= $#error) {
- my $error = $error[$index++];
- $curscr->Edit($error->[0]);
- $curscr->SetCursor($error->[1],0);
- $curscr->Msg($error->[2]);
- }
-}
-
-# preverror is left as an exercise
-
-1;
diff --git a/perl_scripts/tk.pl b/perl_scripts/tk.pl
deleted file mode 100644
index f8d1bc068df3..000000000000
--- a/perl_scripts/tk.pl
+++ /dev/null
@@ -1,20 +0,0 @@
-# make sure every subprocess has it's exit and that the main one
-# hasn't
-sub fun {
- unless ($pid = fork) {
- unless (fork) {
- use Tk;
- $MW = MainWindow->new;
- $hello = $MW->Button(
- -text => 'Hello, world',
- -command => sub {exit;},
- );
- $hello->pack;
- MainLoop;
- }
- exit 0;
- }
- waitpid($pid, 0);
-}
-
-1;
diff --git a/perl_scripts/wc.pl b/perl_scripts/wc.pl
deleted file mode 100644
index 0a5015987d10..000000000000
--- a/perl_scripts/wc.pl
+++ /dev/null
@@ -1,11 +0,0 @@
-sub wc {
- my $words;
- $i = $VI::StartLine;
- while ($i <= $VI::StopLine) {
- $_ = $curscr->GetLine($i++);
- $words+=split;
- }
- $curscr->Msg("$words words");
-}
-
-1;
diff --git a/clib/strpbrk.c b/regex/COPYRIGHT
index 22abbb0da4b5..574f6bcec6c7 100644
--- a/clib/strpbrk.c
+++ b/regex/COPYRIGHT
@@ -1,5 +1,27 @@
-/*
- * Copyright (c) 1985, 1993
+Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
+This software is not subject to any license of the American Telephone
+and Telegraph Company or of the Regents of the University of California.
+
+Permission is granted to anyone to use this software for any purpose on
+any computer system, and to alter it and redistribute it, subject
+to the following restrictions:
+
+1. The author is not responsible for the consequences of use of this
+ software, no matter how awful, even if they arise from flaws in it.
+
+2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission. Since few users ever read sources,
+ credits must appear in the documentation.
+
+3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software. Since few users
+ ever read sources, credits must appear in the documentation.
+
+4. This notice may not be removed or altered.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+/*-
+ * Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,34 +51,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strpbrk.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <string.h>
-
-/*
- * Find the first occurrence in s1 of a character in s2 (excluding NUL).
*
- * PUBLIC: #ifndef HAVE_STRPBRK
- * PUBLIC: char *strpbrk __P((const char *, const char *));
- * PUBLIC: #endif
+ * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94
*/
-char *
-strpbrk(s1, s2)
- register const char *s1, *s2;
-{
- register const char *scanp;
- register int c, sc;
-
- while ((c = *s1++) != 0) {
- for (scanp = s2; (sc = *scanp++) != 0;)
- if (sc == c)
- return ((char *)(s1 - 1));
- }
- return (NULL);
-}
diff --git a/regex/WHATSNEW b/regex/WHATSNEW
new file mode 100644
index 000000000000..f4301d300dd3
--- /dev/null
+++ b/regex/WHATSNEW
@@ -0,0 +1,94 @@
+# @(#)WHATSNEW 8.3 (Berkeley) 3/18/94
+
+New in alpha3.4: The complex bug alluded to below has been fixed (in a
+slightly kludgey temporary way that may hurt efficiency a bit; this is
+another "get it out the door for 4.4" release). The tests at the end of
+the tests file have accordingly been uncommented. The primary sign of
+the bug was that something like a?b matching ab matched b rather than ab.
+(The bug was essentially specific to this exact situation, else it would
+have shown up earlier.)
+
+New in alpha3.3: The definition of word boundaries has been altered
+slightly, to more closely match the usual programming notion that "_"
+is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir,
+and the makefile no longer alludes to it in mysterious ways. The
+makefile has generally been cleaned up some. Fixes have been made
+(again!) so that the regression test will run without -DREDEBUG, at
+the cost of weaker checking. A workaround for a bug in some folks'
+<assert.h> has been added. And some more things have been added to
+tests, including a couple right at the end which are commented out
+because the code currently flunks them (complex bug; fix coming).
+Plus the usual minor cleanup.
+
+New in alpha3.2: Assorted bits of cleanup and portability improvement
+(the development base is now a BSDI system using GCC instead of an ancient
+Sun system, and the newer compiler exposed some glitches). Fix for a
+serious bug that affected REs using many [] (including REG_ICASE REs
+because of the way they are implemented), *sometimes*, depending on
+memory-allocation patterns. The header-file prototypes no longer name
+the parameters, avoiding possible name conflicts. The possibility that
+some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is
+now handled gracefully. "uchar" is no longer used as an internal type
+name (too many people have the same idea). Still the same old lousy
+performance, alas.
+
+New in alpha3.1: Basically nothing, this release is just a bookkeeping
+convenience. Stay tuned.
+
+New in alpha3.0: Performance is no better, alas, but some fixes have been
+made and some functionality has been added. (This is basically the "get
+it out the door in time for 4.4" release.) One bug fix: regfree() didn't
+free the main internal structure (how embarrassing). It is now possible
+to put NULs in either the RE or the target string, using (resp.) a new
+REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to
+regcomp() makes all characters ordinary, so you can match a literal
+string easily (this will become more useful when performance improves!).
+There are now primitives to match beginnings and ends of words, although
+the syntax is disgusting and so is the implementation. The REG_ATOI
+debugging interface has changed a bit. And there has been considerable
+internal cleanup of various kinds.
+
+New in alpha2.3: Split change list out of README, and moved flags notes
+into Makefile. Macro-ized the name of regex(7) in regex(3), since it has
+to change for 4.4BSD. Cleanup work in engine.c, and some new regression
+tests to catch tricky cases thereof.
+
+New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two
+small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges
+in my own test program and might be useful to others for similar purposes.
+The regression test will now compile (and run) without REDEBUG. The
+BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now.
+Char/uchar parameters are now written int/unsigned, to avoid possible
+portability problems with unpromoted parameters. Some unsigned casts have
+been introduced to minimize portability problems with shifting into sign
+bits.
+
+New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big
+thing is that regex.h is now generated, using mkh, rather than being
+supplied in the distribution; due to circularities in dependencies,
+you have to build regex.h explicitly by "make h". The two known bugs
+have been fixed (and the regression test now checks for them), as has a
+problem with assertions not being suppressed in the absence of REDEBUG.
+No performance work yet.
+
+New in alpha2: Backslash-anything is an ordinary character, not an
+error (except, of course, for the handful of backslashed metacharacters
+in BREs), which should reduce script breakage. The regression test
+checks *where* null strings are supposed to match, and has generally
+been tightened up somewhat. Small bug fixes in parameter passing (not
+harmful, but technically errors) and some other areas. Debugging
+invoked by defining REDEBUG rather than not defining NDEBUG.
+
+New in alpha+3: full prototyping for internal routines, using a little
+helper program, mkh, which extracts prototypes given in stylized comments.
+More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple
+pre-screening of input when a literal string is known to be part of the
+RE; this does wonders for performance.
+
+New in alpha+2: minor bits of cleanup. Notably, the number "32" for the
+word width isn't hardwired into regexec.c any more, the public header
+file prototypes the functions if __STDC__ is defined, and some small typos
+in the manpages have been fixed.
+
+New in alpha+1: improvements to the manual pages, and an important
+extension, the REG_STARTEND option to regexec().
diff --git a/clib/bsearch.c b/regex/cclass.h
index 6b41ab5fcef8..f28bccdfafcc 100644
--- a/clib/bsearch.c
+++ b/regex/cclass.h
@@ -1,7 +1,13 @@
-/*
- * Copyright (c) 1990, 1993
+/* $NetBSD: cclass.h,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -29,62 +35,51 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)bsearch.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stddef.h>
-#include <stdlib.h>
-
-#include "port.h"
-
-/*
- * Perform a binary search.
*
- * The code below is a bit sneaky. After a comparison fails, we
- * divide the work in half by moving either left or right. If lim
- * is odd, moving left simply involves halving lim: e.g., when lim
- * is 5 we look at item 2, so we change lim to 2 so that we will
- * look at items 0 & 1. If lim is even, the same applies. If lim
- * is odd, moving right again involes halving lim, this time moving
- * the base up one item past p: e.g., when lim is 5 we change base
- * to item 3 and make lim 2 so that we will look at items 3 and 4.
- * If lim is even, however, we have to shrink it by one before
- * halving: e.g., when lim is 4, we still looked at item 2, so we
- * have to make lim 3, then halve, obtaining 1, so that we will only
- * look at item 3.
- *
- * PUBLIC: #ifndef HAVE_BSEARCH
- * PUBLIC: void *bsearch __P((const void *, const void *, size_t,
- * PUBLIC: size_t, int (*)(const void *, const void *)));
- * PUBLIC: #endif
+ * @(#)cclass.h 8.2 (Berkeley) 3/16/94
*/
-void *
-bsearch(key, base0, nmemb, size, compar)
- register const void *key;
- const void *base0;
- size_t nmemb;
- register size_t size;
- register int (*compar) __P((const void *, const void *));
-{
- register const char *base = base0;
- register size_t lim;
- register int cmp;
- register const void *p;
- for (lim = nmemb; lim != 0; lim >>= 1) {
- p = base + (lim >> 1) * size;
- cmp = (*compar)(key, p);
- if (cmp == 0)
- return ((void *)p);
- if (cmp > 0) { /* key > p: move right */
- base = (char *)p + size;
- lim--;
- } /* else move left */
- }
- return (NULL);
-}
+RCHAR_T ALNUM[] = {'a','l','n','u','m',0};
+RCHAR_T ALPHA[] = {'a','l','p','h','a',0};
+RCHAR_T BLANK[] = {'b','l','a','n','k',0};
+RCHAR_T CNTRL[] = {'c','n','t','r','l',0};
+RCHAR_T DIGIT[] = {'d','i','g','i','t',0};
+RCHAR_T GRAPH[] = {'g','r','a','p','h',0};
+RCHAR_T LOWER[] = {'l','o','w','e','r',0};
+RCHAR_T PRINT[] = {'p','r','i','n','t',0};
+RCHAR_T PUNCT[] = {'p','u','n','c','t',0};
+RCHAR_T SPACE[] = {'s','p','a','c','e',0};
+RCHAR_T UPPER[] = {'u','p','p','e','r',0};
+RCHAR_T XDIGIT[] = {'x','d','i','g','i','t',0};
+
+/* character-class table */
+static struct cclass {
+ RCHAR_T *name;
+ const char *chars;
+ const char *multis;
+} cclasses[] = {
+ { ALNUM, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789", "" },
+ { ALPHA, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
+ "" },
+ { BLANK, " \t", "" },
+ { CNTRL, "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
+\25\26\27\30\31\32\33\34\35\36\37\177", "" },
+ { DIGIT, "0123456789", "" },
+ { GRAPH, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
+ "" },
+ { LOWER, "abcdefghijklmnopqrstuvwxyz",
+ "" },
+ { PRINT, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
+ "" },
+ { PUNCT, "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
+ "" },
+ { SPACE, "\t\n\v\f\r ", "" },
+ { UPPER, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ "" },
+ { XDIGIT, "0123456789ABCDEFabcdef",
+ "" },
+ { NULL, 0, "" },
+};
diff --git a/regex/cname.h b/regex/cname.h
new file mode 100644
index 000000000000..da69843df9de
--- /dev/null
+++ b/regex/cname.h
@@ -0,0 +1,143 @@
+/* $NetBSD: cname.h,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)cname.h 8.2 (Berkeley) 3/16/94
+ */
+
+/* character-name table */
+static struct cname {
+ const RCHAR_T *name;
+ char code;
+} cnames[] = {
+ { L("NUL"), '\0' },
+ { L("SOH"), '\001' },
+ { L("STX"), '\002' },
+ { L("ETX"), '\003' },
+ { L("EOT"), '\004' },
+ { L("ENQ"), '\005' },
+ { L("ACK"), '\006' },
+ { L("BEL"), '\007' },
+ { L("alert"), '\007' },
+ { L("BS"), '\010' },
+ { L("backspace"), '\b' },
+ { L("HT"), '\011' },
+ { L("tab"), '\t' },
+ { L("LF"), '\012' },
+ { L("newline"), '\n' },
+ { L("VT"), '\013' },
+ { L("vertical-tab"), '\v' },
+ { L("FF"), '\014' },
+ { L("form-feed"), '\f' },
+ { L("CR"), '\015' },
+ { L("carriage-return"), '\r' },
+ { L("SO"), '\016' },
+ { L("SI"), '\017' },
+ { L("DLE"), '\020' },
+ { L("DC1"), '\021' },
+ { L("DC2"), '\022' },
+ { L("DC3"), '\023' },
+ { L("DC4"), '\024' },
+ { L("NAK"), '\025' },
+ { L("SYN"), '\026' },
+ { L("ETB"), '\027' },
+ { L("CAN"), '\030' },
+ { L("EM"), '\031' },
+ { L("SUB"), '\032' },
+ { L("ESC"), '\033' },
+ { L("IS4"), '\034' },
+ { L("FS"), '\034' },
+ { L("IS3"), '\035' },
+ { L("GS"), '\035' },
+ { L("IS2"), '\036' },
+ { L("RS"), '\036' },
+ { L("IS1"), '\037' },
+ { L("US"), '\037' },
+ { L("space"), ' ' },
+ { L("exclamation-mark"),'!' },
+ { L("quotation-mark"), '"' },
+ { L("number-sign"), '#' },
+ { L("dollar-sign"), '$' },
+ { L("percent-sign"), '%' },
+ { L("ampersand"), '&' },
+ { L("apostrophe"), '\'' },
+ { L("left-parenthesis"),'(' },
+ { L("right-parenthesis"),')' },
+ { L("asterisk"), '*' },
+ { L("plus-sign"), '+' },
+ { L("comma"), ',' },
+ { L("hyphen"), '-' },
+ { L("hyphen-minus"), '-' },
+ { L("period"), '.' },
+ { L("full-stop"), '.' },
+ { L("slash"), '/' },
+ { L("solidus"), '/' },
+ { L("zero"), '0' },
+ { L("one"), '1' },
+ { L("two"), '2' },
+ { L("three"), '3' },
+ { L("four"), '4' },
+ { L("five"), '5' },
+ { L("six"), '6' },
+ { L("seven"), '7' },
+ { L("eight"), '8' },
+ { L("nine"), '9' },
+ { L("colon"), ':' },
+ { L("semicolon"), ';' },
+ { L("less-than-sign"), '<' },
+ { L("equals-sign"), '=' },
+ { L("greater-than-sign"),'>' },
+ { L("question-mark"), '?' },
+ { L("commercial-at"), '@' },
+ { L("left-square-bracket"),'[' },
+ { L("backslash"), '\\' },
+ { L("reverse-solidus"), '\\' },
+ { L("right-square-bracket"),']' },
+ { L("circumflex"), '^' },
+ { L("circumflex-accent"),'^' },
+ { L("underscore"), '_' },
+ { L("low-line"), '_' },
+ { L("grave-accent"), '`' },
+ { L("left-brace"), '{' },
+ { L("left-curly-bracket"),'{' },
+ { L("vertical-line"), '|' },
+ { L("right-brace"), '}' },
+ { L("right-curly-bracket"),'}' },
+ { L("tilde"), '~' },
+ { L("DEL"), '\177' },
+ { NULL, 0 },
+};
diff --git a/regex/engine.c b/regex/engine.c
new file mode 100644
index 000000000000..ad1c501067e3
--- /dev/null
+++ b/regex/engine.c
@@ -0,0 +1,1102 @@
+/* $NetBSD: engine.c,v 1.7 2011/11/19 17:45:11 tnozaki Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)engine.c 8.4 (Berkeley) 3/19/94
+ */
+
+/*
+ * The matching engine and friends. This file is #included by regexec.c
+ * after suitable #defines of a variety of macros used herein, so that
+ * different state representations can be used without duplicating masses
+ * of code.
+ */
+
+#ifdef SNAMES
+#define matcher smatcher
+#define fast sfast
+#define slow sslow
+#define dissect sdissect
+#define backref sbackref
+#define step sstep
+#define print sprint
+#define at sat
+#define match smat
+#endif
+#ifdef LNAMES
+#define matcher lmatcher
+#define fast lfast
+#define slow lslow
+#define dissect ldissect
+#define backref lbackref
+#define step lstep
+#define print lprint
+#define at lat
+#define match lmat
+#endif
+
+/* another structure passed up and down to avoid zillions of parameters */
+struct match {
+ struct re_guts *g;
+ int eflags;
+ regmatch_t *pmatch; /* [nsub+1] (0 element unused) */
+ const RCHAR_T *offp; /* offsets work from here */
+ const RCHAR_T *beginp; /* start of string -- virtual NUL precedes */
+ const RCHAR_T *endp; /* end of string -- virtual NUL here */
+ const RCHAR_T *coldp; /* can be no match starting before here */
+ const RCHAR_T **lastpos; /* [nplus+1] */
+ STATEVARS;
+ states st; /* current states */
+ states fresh; /* states for a fresh start */
+ states tmp; /* temporary */
+ states empty; /* empty set of states */
+};
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === engine.c === */
+static int matcher __P((struct re_guts *g, const RCHAR_T *string, size_t nmatch, regmatch_t pmatch[], int eflags));
+static const RCHAR_T *dissect __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst));
+static const RCHAR_T *backref __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst, sopno lev));
+static const RCHAR_T *fast __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst));
+static const RCHAR_T *slow __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst));
+static states step __P((struct re_guts *g, sopno start, sopno stop, states bef, int flag, RCHAR_T ch, states aft));
+#define BOL (1)
+#define EOL (BOL+1)
+#define BOLEOL (BOL+2)
+#define NOTHING (BOL+3)
+#define BOW (BOL+4)
+#define EOW (BOL+5)
+#ifdef REDEBUG
+static void print __P((struct match *m, char *caption, states st, int ch, FILE *d));
+#endif
+#ifdef REDEBUG
+static void at __P((struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst));
+#endif
+#ifdef REDEBUG
+static char *pchar __P((int ch));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+/* ========= end header generated by ./mkh ========= */
+
+#ifdef REDEBUG
+#define SP(t, s, c) print(m, t, s, c, stdout)
+#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
+#define NOTE(str) { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
+#else
+#define SP(t, s, c) /* nothing */
+#define AT(t, p1, p2, s1, s2) /* nothing */
+#define NOTE(s) /* nothing */
+#endif
+
+/*
+ - matcher - the actual matching engine
+ == static int matcher(register struct re_guts *g, const RCHAR_T *string, \
+ == size_t nmatch, regmatch_t pmatch[], int eflags);
+ */
+static int /* 0 success, REG_NOMATCH failure */
+matcher(g, string, nmatch, pmatch, eflags)
+register struct re_guts *g;
+const RCHAR_T *string;
+size_t nmatch;
+regmatch_t pmatch[];
+int eflags;
+{
+ register const RCHAR_T *endp;
+ register size_t i;
+ struct match mv;
+ register struct match *m = &mv;
+ register const RCHAR_T *dp;
+ register const sopno gf = g->firststate+1; /* +1 for OEND */
+ register const sopno gl = g->laststate;
+ const RCHAR_T *start;
+ const RCHAR_T *stop;
+
+ /* simplify the situation where possible */
+ if (g->cflags&REG_NOSUB)
+ nmatch = 0;
+ if (eflags&REG_STARTEND) {
+ start = string + pmatch[0].rm_so;
+ stop = string + pmatch[0].rm_eo;
+ } else {
+ start = string;
+ stop = start + STRLEN(start);
+ }
+ if (stop < start)
+ return(REG_INVARG);
+
+ /* prescreening; this does wonders for this rather slow code */
+ if (g->must != NULL) {
+ for (dp = start; dp < stop; dp++)
+ if (*dp == g->must[0] && (size_t)(stop - dp) >= g->mlen &&
+ MEMCMP(dp, g->must, g->mlen) == 0)
+ break;
+ if (dp == stop) /* we didn't find g->must */
+ return(REG_NOMATCH);
+ }
+
+ /* match struct setup */
+ m->g = g;
+ m->eflags = eflags;
+ m->pmatch = NULL;
+ m->lastpos = NULL;
+ m->offp = string;
+ m->beginp = start;
+ m->endp = stop;
+ STATESETUP(m, 4);
+ SETUP(m->st);
+ SETUP(m->fresh);
+ SETUP(m->tmp);
+ SETUP(m->empty);
+ CLEAR(m->empty);
+
+ /* this loop does only one repetition except for backrefs */
+ for (;;) {
+ endp = fast(m, start, stop, gf, gl);
+ if (endp == NULL) { /* a miss */
+ STATETEARDOWN(m);
+ return(REG_NOMATCH);
+ }
+ if (nmatch == 0 && !g->backrefs)
+ break; /* no further info needed */
+
+ /* where? */
+ assert(m->coldp != NULL);
+ for (;;) {
+ NOTE("finding start");
+ endp = slow(m, m->coldp, stop, gf, gl);
+ if (endp != NULL)
+ break;
+ assert(m->coldp < m->endp);
+ m->coldp++;
+ }
+ if (nmatch == 1 && !g->backrefs)
+ break; /* no further info needed */
+
+ /* oh my, he wants the subexpressions... */
+ if (m->pmatch == NULL)
+ m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) *
+ sizeof(regmatch_t));
+ if (m->pmatch == NULL) {
+ STATETEARDOWN(m);
+ return(REG_ESPACE);
+ }
+ for (i = 1; i <= m->g->nsub; i++)
+ m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
+ if (!g->backrefs && !(m->eflags&REG_BACKR)) {
+ NOTE("dissecting");
+ dp = dissect(m, m->coldp, endp, gf, gl);
+ } else {
+ if (g->nplus > 0 && m->lastpos == NULL)
+ m->lastpos = (const RCHAR_T **)malloc((g->nplus+1) *
+ sizeof(const RCHAR_T *));
+ if (g->nplus > 0 && m->lastpos == NULL) {
+ free(m->pmatch);
+ STATETEARDOWN(m);
+ return(REG_ESPACE);
+ }
+ NOTE("backref dissect");
+ dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
+ }
+ if (dp != NULL)
+ break;
+
+ /* uh-oh... we couldn't find a subexpression-level match */
+ assert(g->backrefs); /* must be back references doing it */
+ assert(g->nplus == 0 || m->lastpos != NULL);
+ for (;;) {
+ if (dp != NULL || endp <= m->coldp)
+ break; /* defeat */
+ NOTE("backoff");
+ endp = slow(m, m->coldp, endp-1, gf, gl);
+ if (endp == NULL)
+ break; /* defeat */
+ /* try it on a shorter possibility */
+#ifndef NDEBUG
+ for (i = 1; i <= m->g->nsub; i++) {
+ assert(m->pmatch[i].rm_so == -1);
+ assert(m->pmatch[i].rm_eo == -1);
+ }
+#endif
+ NOTE("backoff dissect");
+ dp = backref(m, m->coldp, endp, gf, gl, (sopno)0);
+ }
+ assert(dp == NULL || dp == endp);
+ if (dp != NULL) /* found a shorter one */
+ break;
+
+ /* despite initial appearances, there is no match here */
+ NOTE("false alarm");
+ start = m->coldp + 1; /* recycle starting later */
+ assert(start <= stop);
+ }
+
+ /* fill in the details if requested */
+ if (nmatch > 0) {
+ pmatch[0].rm_so = m->coldp - m->offp;
+ pmatch[0].rm_eo = endp - m->offp;
+ }
+ if (nmatch > 1) {
+ assert(m->pmatch != NULL);
+ for (i = 1; i < nmatch; i++)
+ if (i <= m->g->nsub)
+ pmatch[i] = m->pmatch[i];
+ else {
+ pmatch[i].rm_so = -1;
+ pmatch[i].rm_eo = -1;
+ }
+ }
+
+ if (m->pmatch != NULL)
+ free((char *)m->pmatch);
+ if (m->lastpos != NULL)
+ free((char *)m->lastpos);
+ STATETEARDOWN(m);
+ return(0);
+}
+
+/*
+ - dissect - figure out what matched what, no back references
+ == static const RCHAR_T *dissect(register struct match *m, const RCHAR_T *start, \
+ == const RCHAR_T *stop, sopno startst, sopno stopst);
+ */
+static const RCHAR_T * /* == stop (success) always */
+dissect(m, start, stop, startst, stopst)
+register struct match *m;
+const RCHAR_T *start;
+const RCHAR_T *stop;
+sopno startst;
+sopno stopst;
+{
+ register int i;
+ register sopno ss; /* start sop of current subRE */
+ register sopno es; /* end sop of current subRE */
+ register const RCHAR_T *sp; /* start of string matched by it */
+ register const RCHAR_T *stp; /* string matched by it cannot pass here */
+ register const RCHAR_T *rest; /* start of rest of string */
+ register const RCHAR_T *tail; /* string unmatched by rest of RE */
+ register sopno ssub; /* start sop of subsubRE */
+ register sopno esub; /* end sop of subsubRE */
+ register const RCHAR_T *ssp; /* start of string matched by subsubRE */
+ register const RCHAR_T *sep; /* end of string matched by subsubRE */
+ register const RCHAR_T *oldssp; /* previous ssp */
+ register const RCHAR_T *dp;
+
+ AT("diss", start, stop, startst, stopst);
+ sp = start;
+ for (ss = startst; ss < stopst; ss = es) {
+ /* identify end of subRE */
+ es = ss;
+ switch (m->g->strip[es]) {
+ case OPLUS_:
+ case OQUEST_:
+ es += m->g->stripdata[es];
+ break;
+ case OCH_:
+ while (m->g->strip[es] != O_CH)
+ es += m->g->stripdata[es];
+ break;
+ }
+ es++;
+
+ /* figure out what it matched */
+ switch (m->g->strip[ss]) {
+ case OEND:
+ assert(nope);
+ break;
+ case OCHAR:
+ sp++;
+ break;
+ case OBOL:
+ case OEOL:
+ case OBOW:
+ case OEOW:
+ break;
+ case OANY:
+ case OANYOF:
+ sp++;
+ break;
+ case OBACK_:
+ case O_BACK:
+ assert(nope);
+ break;
+ /* cases where length of match is hard to find */
+ case OQUEST_:
+ stp = stop;
+ for (;;) {
+ /* how long could this one be? */
+ rest = slow(m, sp, stp, ss, es);
+ assert(rest != NULL); /* it did match */
+ /* could the rest match the rest? */
+ tail = slow(m, rest, stop, es, stopst);
+ if (tail == stop)
+ break; /* yes! */
+ /* no -- try a shorter match for this one */
+ stp = rest - 1;
+ assert(stp >= sp); /* it did work */
+ }
+ ssub = ss + 1;
+ esub = es - 1;
+ /* did innards match? */
+ if (slow(m, sp, rest, ssub, esub) != NULL) {
+ dp = dissect(m, sp, rest, ssub, esub);
+ assert(dp == rest);
+ } else /* no */
+ assert(sp == rest);
+ sp = rest;
+ break;
+ case OPLUS_:
+ stp = stop;
+ for (;;) {
+ /* how long could this one be? */
+ rest = slow(m, sp, stp, ss, es);
+ assert(rest != NULL); /* it did match */
+ /* could the rest match the rest? */
+ tail = slow(m, rest, stop, es, stopst);
+ if (tail == stop)
+ break; /* yes! */
+ /* no -- try a shorter match for this one */
+ stp = rest - 1;
+ assert(stp >= sp); /* it did work */
+ }
+ ssub = ss + 1;
+ esub = es - 1;
+ ssp = sp;
+ oldssp = ssp;
+ for (;;) { /* find last match of innards */
+ sep = slow(m, ssp, rest, ssub, esub);
+ if (sep == NULL || sep == ssp)
+ break; /* failed or matched null */
+ oldssp = ssp; /* on to next try */
+ ssp = sep;
+ }
+ if (sep == NULL) {
+ /* last successful match */
+ sep = ssp;
+ ssp = oldssp;
+ }
+ assert(sep == rest); /* must exhaust substring */
+ assert(slow(m, ssp, sep, ssub, esub) == rest);
+ dp = dissect(m, ssp, sep, ssub, esub);
+ assert(dp == sep);
+ sp = rest;
+ break;
+ case OCH_:
+ stp = stop;
+ for (;;) {
+ /* how long could this one be? */
+ rest = slow(m, sp, stp, ss, es);
+ assert(rest != NULL); /* it did match */
+ /* could the rest match the rest? */
+ tail = slow(m, rest, stop, es, stopst);
+ if (tail == stop)
+ break; /* yes! */
+ /* no -- try a shorter match for this one */
+ stp = rest - 1;
+ assert(stp >= sp); /* it did work */
+ }
+ ssub = ss + 1;
+ esub = ss + m->g->stripdata[ss] - 1;
+ assert(m->g->strip[esub] == OOR1);
+ for (;;) { /* find first matching branch */
+ if (slow(m, sp, rest, ssub, esub) == rest)
+ break; /* it matched all of it */
+ /* that one missed, try next one */
+ assert(m->g->strip[esub] == OOR1);
+ esub++;
+ assert(m->g->strip[esub] == OOR2);
+ ssub = esub + 1;
+ esub += m->g->stripdata[esub];
+ if (m->g->strip[esub] == OOR2)
+ esub--;
+ else
+ assert(m->g->strip[esub] == O_CH);
+ }
+ dp = dissect(m, sp, rest, ssub, esub);
+ assert(dp == rest);
+ sp = rest;
+ break;
+ case O_PLUS:
+ case O_QUEST:
+ case OOR1:
+ case OOR2:
+ case O_CH:
+ assert(nope);
+ break;
+ case OLPAREN:
+ i = m->g->stripdata[ss];
+ assert(0 < i && i <= m->g->nsub);
+ m->pmatch[i].rm_so = sp - m->offp;
+ break;
+ case ORPAREN:
+ i = m->g->stripdata[ss];
+ assert(0 < i && i <= m->g->nsub);
+ m->pmatch[i].rm_eo = sp - m->offp;
+ break;
+ default: /* uh oh */
+ assert(nope);
+ break;
+ }
+ }
+
+ assert(sp == stop);
+ return(sp);
+}
+
+/*
+ - backref - figure out what matched what, figuring in back references
+ == static const RCHAR_T *backref(register struct match *m, const RCHAR_T *start, \
+ == const RCHAR_T *stop, sopno startst, sopno stopst, sopno lev);
+ */
+static const RCHAR_T * /* == stop (success) or NULL (failure) */
+backref(m, start, stop, startst, stopst, lev)
+register struct match *m;
+const RCHAR_T *start;
+const RCHAR_T *stop;
+sopno startst;
+sopno stopst;
+sopno lev; /* PLUS nesting level */
+{
+ register int i;
+ register sopno ss; /* start sop of current subRE */
+ register const RCHAR_T *sp; /* start of string matched by it */
+ register sopno ssub; /* start sop of subsubRE */
+ register sopno esub; /* end sop of subsubRE */
+ register const RCHAR_T *ssp; /* start of string matched by subsubRE */
+ register const RCHAR_T *dp;
+ register size_t len;
+ register int hard;
+ register sop s;
+ register RCHAR_T d;
+ register regoff_t offsave;
+ register cset *cs;
+
+ AT("back", start, stop, startst, stopst);
+ sp = start;
+
+ /* get as far as we can with easy stuff */
+ hard = 0;
+ for (ss = startst; !hard && ss < stopst; ss++) {
+ s = m->g->strip[ss];
+ d = m->g->stripdata[ss];
+ switch (s) {
+ case OCHAR:
+ if (sp == stop || *sp++ != d)
+ return(NULL);
+ break;
+ case OANY:
+ if (sp == stop)
+ return(NULL);
+ sp++;
+ break;
+ case OANYOF:
+ cs = &m->g->sets[d];
+ if (sp == stop || !CHIN(cs, *sp++))
+ return(NULL);
+ break;
+ case OBOL:
+ if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
+ (sp < m->endp && *(sp-1) == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case OEOL:
+ if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
+ (sp < m->endp && *sp == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case OBOW:
+ if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
+ (sp < m->endp && *(sp-1) == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) ||
+ (sp > m->beginp &&
+ !ISWORD(*(sp-1))) ) &&
+ (sp < m->endp && ISWORD(*sp)) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case OEOW:
+ if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
+ (sp < m->endp && *sp == '\n' &&
+ (m->g->cflags&REG_NEWLINE)) ||
+ (sp < m->endp && !ISWORD(*sp)) ) &&
+ (sp > m->beginp && ISWORD(*(sp-1))) )
+ { /* yes */ }
+ else
+ return(NULL);
+ break;
+ case O_QUEST:
+ break;
+ case OOR1: /* matches null but needs to skip */
+ ss++;
+ s = m->g->strip[ss];
+ d = m->g->stripdata[ss];
+ do {
+ assert(s == OOR2);
+ ss += d;
+ s = m->g->strip[ss];
+ d = m->g->stripdata[ss];
+ } while (s != O_CH);
+ /* note that the ss++ gets us past the O_CH */
+ break;
+ default: /* have to make a choice */
+ hard = 1;
+ break;
+ }
+ }
+ if (!hard) { /* that was it! */
+ if (sp != stop)
+ return(NULL);
+ return(sp);
+ }
+ ss--; /* adjust for the for's final increment */
+
+ /* the hard stuff */
+ AT("hard", sp, stop, ss, stopst);
+ s = m->g->strip[ss];
+ d = m->g->stripdata[ss];
+ switch (s) {
+ case OBACK_: /* the vilest depths */
+ i = d;
+ assert(0 < i && i <= m->g->nsub);
+ if (m->pmatch[i].rm_eo == -1)
+ return(NULL);
+ assert(m->pmatch[i].rm_so != -1);
+ len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
+ assert(stop - m->beginp >= len);
+ if (sp > stop - len)
+ return(NULL); /* not enough left to match */
+ ssp = m->offp + m->pmatch[i].rm_so;
+ if (memcmp(sp, ssp, len) != 0)
+ return(NULL);
+ while (m->g->strip[ss] != O_BACK || m->g->stripdata[ss] != i)
+ ss++;
+ return(backref(m, sp+len, stop, ss+1, stopst, lev));
+ break;
+ case OQUEST_: /* to null or not */
+ dp = backref(m, sp, stop, ss+1, stopst, lev);
+ if (dp != NULL)
+ return(dp); /* not */
+ return(backref(m, sp, stop, ss+d+1, stopst, lev));
+ break;
+ case OPLUS_:
+ assert(m->lastpos != NULL);
+ assert(lev+1 <= m->g->nplus);
+ m->lastpos[lev+1] = sp;
+ return(backref(m, sp, stop, ss+1, stopst, lev+1));
+ break;
+ case O_PLUS:
+ if (sp == m->lastpos[lev]) /* last pass matched null */
+ return(backref(m, sp, stop, ss+1, stopst, lev-1));
+ /* try another pass */
+ m->lastpos[lev] = sp;
+ dp = backref(m, sp, stop, ss-d+1, stopst, lev);
+ if (dp == NULL)
+ return(backref(m, sp, stop, ss+1, stopst, lev-1));
+ else
+ return(dp);
+ break;
+ case OCH_: /* find the right one, if any */
+ ssub = ss + 1;
+ esub = ss + d - 1;
+ assert(m->g->strip[esub] == OOR1);
+ for (;;) { /* find first matching branch */
+ dp = backref(m, sp, stop, ssub, esub, lev);
+ if (dp != NULL)
+ return(dp);
+ /* that one missed, try next one */
+ if (m->g->strip[esub] == O_CH)
+ return(NULL); /* there is none */
+ esub++;
+ assert(m->g->strip[esub] == OOR2);
+ ssub = esub + 1;
+ esub += m->g->stripdata[esub];
+ if (m->g->strip[esub] == OOR2)
+ esub--;
+ else
+ assert(m->g->strip[esub] == O_CH);
+ }
+ break;
+ case OLPAREN: /* must undo assignment if rest fails */
+ i = d;
+ assert(0 < i && i <= m->g->nsub);
+ offsave = m->pmatch[i].rm_so;
+ m->pmatch[i].rm_so = sp - m->offp;
+ dp = backref(m, sp, stop, ss+1, stopst, lev);
+ if (dp != NULL)
+ return(dp);
+ m->pmatch[i].rm_so = offsave;
+ return(NULL);
+ break;
+ case ORPAREN: /* must undo assignment if rest fails */
+ i = d;
+ assert(0 < i && i <= m->g->nsub);
+ offsave = m->pmatch[i].rm_eo;
+ m->pmatch[i].rm_eo = sp - m->offp;
+ dp = backref(m, sp, stop, ss+1, stopst, lev);
+ if (dp != NULL)
+ return(dp);
+ m->pmatch[i].rm_eo = offsave;
+ return(NULL);
+ break;
+ default: /* uh oh */
+ assert(nope);
+ break;
+ }
+
+ /* "can't happen" */
+ assert(nope);
+ /* NOTREACHED */
+ return NULL;
+}
+
+/*
+ - fast - step through the string at top speed
+ == static const RCHAR_T *fast(register struct match *m, const RCHAR_T *start, \
+ == const RCHAR_T *stop, sopno startst, sopno stopst);
+ */
+static const RCHAR_T * /* where tentative match ended, or NULL */
+fast(m, start, stop, startst, stopst)
+register struct match *m;
+const RCHAR_T *start;
+const RCHAR_T *stop;
+sopno startst;
+sopno stopst;
+{
+ register states st = m->st;
+ register states fresh = m->fresh;
+ register states tmp = m->tmp;
+ register const RCHAR_T *p = start;
+ register RCHAR_T c = (start == m->beginp) ? OUT : *(start-1);
+ register RCHAR_T lastc; /* previous c */
+ register int flag;
+ register int i;
+ register const RCHAR_T *coldp; /* last p after which no match was underway */
+
+ CLEAR(st);
+ SET1(st, startst);
+ st = step(m->g, startst, stopst, st, NOTHING, OUT, st);
+ ASSIGN(fresh, st);
+ SP("start", st, *p);
+ coldp = NULL;
+ for (;;) {
+ /* next character */
+ lastc = c;
+ c = (p == m->endp) ? OUT : *p;
+ if (EQ(st, fresh))
+ coldp = p;
+
+ /* is there an EOL and/or BOL between lastc and c? */
+ flag = 0;
+ i = 0;
+ if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
+ flag = BOL;
+ i = m->g->nbol;
+ }
+ if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
+ flag = (flag == BOL) ? BOLEOL : EOL;
+ i += m->g->neol;
+ }
+ if (i != 0) {
+ for (; i > 0; i--)
+ st = step(m->g, startst, stopst, st, flag, OUT, st);
+ SP("boleol", st, c);
+ }
+
+ /* how about a word boundary? */
+ if ( (flag == BOL || (lastc != OUT && !ISWORD(lastc))) &&
+ (c != OUT && ISWORD(c)) ) {
+ flag = BOW;
+ }
+ if ( (lastc != OUT && ISWORD(lastc)) &&
+ (flag == EOL || (c != OUT && !ISWORD(c))) ) {
+ flag = EOW;
+ }
+ if (flag == BOW || flag == EOW) {
+ st = step(m->g, startst, stopst, st, flag, OUT, st);
+ SP("boweow", st, c);
+ }
+
+ /* are we done? */
+ if (ISSET(st, stopst) || p == stop)
+ break; /* NOTE BREAK OUT */
+
+ /* no, we must deal with this character */
+ ASSIGN(tmp, st);
+ ASSIGN(st, fresh);
+ assert(c != OUT);
+ st = step(m->g, startst, stopst, tmp, 0, c, st);
+ SP("aft", st, c);
+ assert(EQ(step(m->g, startst, stopst, st, NOTHING, OUT, st), st));
+ p++;
+ }
+
+ assert(coldp != NULL);
+ m->coldp = coldp;
+ if (ISSET(st, stopst))
+ return(p+1);
+ else
+ return(NULL);
+}
+
+/*
+ - slow - step through the string more deliberately
+ == static const RCHAR_T *slow(register struct match *m, const RCHAR_T *start, \
+ == const RCHAR_T *stop, sopno startst, sopno stopst);
+ */
+static const RCHAR_T * /* where it ended */
+slow(m, start, stop, startst, stopst)
+register struct match *m;
+const RCHAR_T *start;
+const RCHAR_T *stop;
+sopno startst;
+sopno stopst;
+{
+ register states st = m->st;
+ register states empty = m->empty;
+ register states tmp = m->tmp;
+ register const RCHAR_T *p = start;
+ register RCHAR_T c = (start == m->beginp) ? OUT : *(start-1);
+ register RCHAR_T lastc; /* previous c */
+ register int flag;
+ register int i;
+ register const RCHAR_T *matchp; /* last p at which a match ended */
+
+ AT("slow", start, stop, startst, stopst);
+ CLEAR(st);
+ SET1(st, startst);
+ SP("sstart", st, *p);
+ st = step(m->g, startst, stopst, st, NOTHING, OUT, st);
+ matchp = NULL;
+ for (;;) {
+ /* next character */
+ lastc = c;
+ c = (p == m->endp) ? OUT : *p;
+
+ /* is there an EOL and/or BOL between lastc and c? */
+ flag = 0;
+ i = 0;
+ if ( (lastc == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (lastc == OUT && !(m->eflags&REG_NOTBOL)) ) {
+ flag = BOL;
+ i = m->g->nbol;
+ }
+ if ( (c == '\n' && m->g->cflags&REG_NEWLINE) ||
+ (c == OUT && !(m->eflags&REG_NOTEOL)) ) {
+ flag = (flag == BOL) ? BOLEOL : EOL;
+ i += m->g->neol;
+ }
+ if (i != 0) {
+ for (; i > 0; i--)
+ st = step(m->g, startst, stopst, st, flag, OUT, st);
+ SP("sboleol", st, c);
+ }
+
+ /* how about a word boundary? */
+ if ( (flag == BOL || (lastc != OUT && !ISWORD(lastc))) &&
+ (c != OUT && ISWORD(c)) ) {
+ flag = BOW;
+ }
+ if ( (lastc != OUT && ISWORD(lastc)) &&
+ (flag == EOL || (c != OUT && !ISWORD(c))) ) {
+ flag = EOW;
+ }
+ if (flag == BOW || flag == EOW) {
+ st = step(m->g, startst, stopst, st, flag, OUT, st);
+ SP("sboweow", st, c);
+ }
+
+ /* are we done? */
+ if (ISSET(st, stopst))
+ matchp = p;
+ if (EQ(st, empty) || p == stop)
+ break; /* NOTE BREAK OUT */
+
+ /* no, we must deal with this character */
+ ASSIGN(tmp, st);
+ ASSIGN(st, empty);
+ assert(c != OUT);
+ st = step(m->g, startst, stopst, tmp, 0, c, st);
+ SP("saft", st, c);
+ assert(EQ(step(m->g, startst, stopst, st, NOTHING, OUT, st), st));
+ p++;
+ }
+
+ return(matchp);
+}
+
+
+/*
+ - step - map set of states reachable before char to set reachable after
+ == static states step(register struct re_guts *g, sopno start, sopno stop, \
+ == register states bef, int flag, RCHAR_T ch, register states aft);
+ == #define BOL (1)
+ == #define EOL (BOL+1)
+ == #define BOLEOL (BOL+2)
+ == #define NOTHING (BOL+3)
+ == #define BOW (BOL+4)
+ == #define EOW (BOL+5)
+ */
+static states
+step(g, start, stop, bef, flag, ch, aft)
+register struct re_guts *g;
+sopno start; /* start state within strip */
+sopno stop; /* state after stop state within strip */
+register states bef; /* states reachable before */
+int flag; /* NONCHAR flag */
+RCHAR_T ch; /* character code */
+register states aft; /* states already known reachable after */
+{
+ register cset *cs;
+ register sop s;
+ register RCHAR_T d;
+ register sopno pc;
+ register onestate here; /* note, macros know this name */
+ register sopno look;
+ register int i;
+
+ for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) {
+ s = g->strip[pc];
+ d = g->stripdata[pc];
+ switch (s) {
+ case OEND:
+ assert(pc == stop-1);
+ break;
+ case OCHAR:
+ /* only characters can match */
+ assert(!flag || ch != d);
+ if (ch == d)
+ FWD(aft, bef, 1);
+ break;
+ case OBOL:
+ if (flag == BOL || flag == BOLEOL)
+ FWD(aft, bef, 1);
+ break;
+ case OEOL:
+ if (flag == EOL || flag == BOLEOL)
+ FWD(aft, bef, 1);
+ break;
+ case OBOW:
+ if (flag == BOW)
+ FWD(aft, bef, 1);
+ break;
+ case OEOW:
+ if (flag == EOW)
+ FWD(aft, bef, 1);
+ break;
+ case OANY:
+ if (!flag)
+ FWD(aft, bef, 1);
+ break;
+ case OANYOF:
+ cs = &g->sets[d];
+ if (!flag && CHIN(cs, ch))
+ FWD(aft, bef, 1);
+ break;
+ case OBACK_: /* ignored here */
+ case O_BACK:
+ FWD(aft, aft, 1);
+ break;
+ case OPLUS_: /* forward, this is just an empty */
+ FWD(aft, aft, 1);
+ break;
+ case O_PLUS: /* both forward and back */
+ FWD(aft, aft, 1);
+ i = ISSETBACK(aft, d);
+ BACK(aft, aft, d);
+ if (!i && ISSETBACK(aft, d)) {
+ /* oho, must reconsider loop body */
+ pc -= d + 1;
+ INIT(here, pc);
+ }
+ break;
+ case OQUEST_: /* two branches, both forward */
+ FWD(aft, aft, 1);
+ FWD(aft, aft, d);
+ break;
+ case O_QUEST: /* just an empty */
+ FWD(aft, aft, 1);
+ break;
+ case OLPAREN: /* not significant here */
+ case ORPAREN:
+ FWD(aft, aft, 1);
+ break;
+ case OCH_: /* mark the first two branches */
+ FWD(aft, aft, 1);
+ assert(OP(g->strip[pc+d]) == OOR2);
+ FWD(aft, aft, d);
+ break;
+ case OOR1: /* done a branch, find the O_CH */
+ if (ISSTATEIN(aft, here)) {
+ for (look = 1; /**/; look += d) {
+ s = g->strip[pc+look];
+ d = g->stripdata[pc+look];
+ if (s == O_CH)
+ break;
+ assert(s == OOR2);
+ }
+ FWD(aft, aft, look);
+ }
+ break;
+ case OOR2: /* propagate OCH_'s marking */
+ FWD(aft, aft, 1);
+ if (g->strip[pc+d] != O_CH) {
+ assert(g->strip[pc+d] == OOR2);
+ FWD(aft, aft, d);
+ }
+ break;
+ case O_CH: /* just empty */
+ FWD(aft, aft, 1);
+ break;
+ default: /* ooooops... */
+ assert(nope);
+ break;
+ }
+ }
+
+ return(aft);
+}
+
+#ifdef REDEBUG
+/*
+ - print - print a set of states
+ == #ifdef REDEBUG
+ == static void print(struct match *m, char *caption, states st, \
+ == int ch, FILE *d);
+ == #endif
+ */
+static void
+print(m, caption, st, ch, d)
+struct match *m;
+char *caption;
+states st;
+int ch;
+FILE *d;
+{
+ register struct re_guts *g = m->g;
+ register int i;
+ register int first = 1;
+
+ if (!(m->eflags&REG_TRACE))
+ return;
+
+ fprintf(d, "%s", caption);
+ if (ch != '\0')
+ fprintf(d, " %s", pchar(ch));
+ for (i = 0; i < g->nstates; i++)
+ if (ISSET(st, i)) {
+ fprintf(d, "%s%d", (first) ? "\t" : ", ", i);
+ first = 0;
+ }
+ fprintf(d, "\n");
+}
+
+/*
+ - at - print current situation
+ == #ifdef REDEBUG
+ == static void at(struct match *m, char *title, char *start, char *stop, \
+ == sopno startst, sopno stopst);
+ == #endif
+ */
+static void
+at(m, title, start, stop, startst, stopst)
+struct match *m;
+char *title;
+char *start;
+char *stop;
+sopno startst;
+sopno stopst;
+{
+ if (!(m->eflags&REG_TRACE))
+ return;
+
+ printf("%s %s-", title, pchar(*start));
+ printf("%s ", pchar(*stop));
+ printf("%ld-%ld\n", (long)startst, (long)stopst);
+}
+
+#ifndef PCHARDONE
+#define PCHARDONE /* never again */
+/*
+ - pchar - make a character printable
+ == #ifdef REDEBUG
+ == static char *pchar(int ch);
+ == #endif
+ *
+ * Is this identical to regchar() over in debug.c? Well, yes. But a
+ * duplicate here avoids having a debugging-capable regexec.o tied to
+ * a matching debug.o, and this is convenient. It all disappears in
+ * the non-debug compilation anyway, so it doesn't matter much.
+ */
+static char * /* -> representation */
+pchar(ch)
+int ch;
+{
+ static char pbuf[10];
+
+ if (isprint(ch) || ch == ' ')
+ snprintf(pbuf, sizeof(pbuf), "%c", ch);
+ else
+ snprintf(pbuf, sizeof(pbuf), "\\%o", ch);
+ return(pbuf);
+}
+#endif
+#endif
+
+#undef matcher
+#undef fast
+#undef slow
+#undef dissect
+#undef backref
+#undef step
+#undef print
+#undef at
+#undef match
diff --git a/regex/re_format.7 b/regex/re_format.7
new file mode 100644
index 000000000000..61d1aeaa85f4
--- /dev/null
+++ b/regex/re_format.7
@@ -0,0 +1,271 @@
+.\" $NetBSD: re_format.7,v 1.1.1.2 2008/05/18 14:31:37 aymeric Exp $
+.\"
+.\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
+.\" Copyright (c) 1992, 1993, 1994
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Henry Spencer of the University of Toronto.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)re_format.7 8.2 (Berkeley) 3/16/94
+.\"
+.TH RE_FORMAT 7 "March 16, 1994"
+.SH NAME
+re_format \- POSIX 1003.2 regular expressions
+.SH DESCRIPTION
+Regular expressions (``RE''s),
+as defined in POSIX 1003.2, come in two forms:
+modern REs (roughly those of
+.IR egrep ;
+1003.2 calls these ``extended'' REs)
+and obsolete REs (roughly those of
+.IR ed ;
+1003.2 ``basic'' REs).
+Obsolete REs mostly exist for backward compatibility in some old programs;
+they will be discussed at the end.
+1003.2 leaves some aspects of RE syntax and semantics open;
+`\(dg' marks decisions on these aspects that
+may not be fully portable to other 1003.2 implementations.
+.PP
+A (modern) RE is one\(dg or more non-empty\(dg \fIbranches\fR,
+separated by `|'.
+It matches anything that matches one of the branches.
+.PP
+A branch is one\(dg or more \fIpieces\fR, concatenated.
+It matches a match for the first, followed by a match for the second, etc.
+.PP
+A piece is an \fIatom\fR possibly followed
+by a single\(dg `*', `+', `?', or \fIbound\fR.
+An atom followed by `*' matches a sequence of 0 or more matches of the atom.
+An atom followed by `+' matches a sequence of 1 or more matches of the atom.
+An atom followed by `?' matches a sequence of 0 or 1 matches of the atom.
+.PP
+A \fIbound\fR is `{' followed by an unsigned decimal integer,
+possibly followed by `,'
+possibly followed by another unsigned decimal integer,
+always followed by `}'.
+The integers must lie between 0 and RE_DUP_MAX (255\(dg) inclusive,
+and if there are two of them, the first may not exceed the second.
+An atom followed by a bound containing one integer \fIi\fR
+and no comma matches
+a sequence of exactly \fIi\fR matches of the atom.
+An atom followed by a bound
+containing one integer \fIi\fR and a comma matches
+a sequence of \fIi\fR or more matches of the atom.
+An atom followed by a bound
+containing two integers \fIi\fR and \fIj\fR matches
+a sequence of \fIi\fR through \fIj\fR (inclusive) matches of the atom.
+.PP
+An atom is a regular expression enclosed in `()' (matching a match for the
+regular expression),
+an empty set of `()' (matching the null string)\(dg,
+a \fIbracket expression\fR (see below), `.'
+(matching any single character), `^' (matching the null string at the
+beginning of a line), `$' (matching the null string at the
+end of a line), a `\e' followed by one of the characters
+`^.[$()|*+?{\e'
+(matching that character taken as an ordinary character),
+a `\e' followed by any other character\(dg
+(matching that character taken as an ordinary character,
+as if the `\e' had not been present\(dg),
+or a single character with no other significance (matching that character).
+A `{' followed by a character other than a digit is an ordinary
+character, not the beginning of a bound\(dg.
+It is illegal to end an RE with `\e'.
+.PP
+A \fIbracket expression\fR is a list of characters enclosed in `[]'.
+It normally matches any single character from the list (but see below).
+If the list begins with `^',
+it matches any single character
+(but see below) \fInot\fR from the rest of the list.
+If two characters in the list are separated by `\-', this is shorthand
+for the full \fIrange\fR of characters between those two (inclusive) in the
+collating sequence,
+e.g. `[0-9]' in ASCII matches any decimal digit.
+It is illegal\(dg for two ranges to share an
+endpoint, e.g. `a-c-e'.
+Ranges are very collating-sequence-dependent,
+and portable programs should avoid relying on them.
+.PP
+To include a literal `]' in the list, make it the first character
+(following a possible `^').
+To include a literal `\-', make it the first or last character,
+or the second endpoint of a range.
+To use a literal `\-' as the first endpoint of a range,
+enclose it in `[.' and `.]' to make it a collating element (see below).
+With the exception of these and some combinations using `[' (see next
+paragraphs), all other special characters, including `\e', lose their
+special significance within a bracket expression.
+.PP
+Within a bracket expression, a collating element (a character,
+a multi-character sequence that collates as if it were a single character,
+or a collating-sequence name for either)
+enclosed in `[.' and `.]' stands for the
+sequence of characters of that collating element.
+The sequence is a single element of the bracket expression's list.
+A bracket expression containing a multi-character collating element
+can thus match more than one character,
+e.g. if the collating sequence includes a `ch' collating element,
+then the RE `[[.ch.]]*c' matches the first five characters
+of `chchcc'.
+.PP
+Within a bracket expression, a collating element enclosed in `[=' and
+`=]' is an equivalence class, standing for the sequences of characters
+of all collating elements equivalent to that one, including itself.
+(If there are no other equivalent collating elements,
+the treatment is as if the enclosing delimiters were `[.' and `.]'.)
+For example, if o and \o'o^' are the members of an equivalence class,
+then `[[=o=]]', `[[=\o'o^'=]]', and `[o\o'o^']' are all synonymous.
+An equivalence class may not\(dg be an endpoint
+of a range.
+.PP
+Within a bracket expression, the name of a \fIcharacter class\fR enclosed
+in `[:' and `:]' stands for the list of all characters belonging to that
+class.
+Standard character class names are:
+.PP
+.RS
+.nf
+.ta 3c 6c 9c
+alnum digit punct
+alpha graph space
+blank lower upper
+cntrl print xdigit
+.fi
+.RE
+.PP
+These stand for the character classes defined in
+.IR ctype (3).
+A locale may provide others.
+A character class may not be used as an endpoint of a range.
+.PP
+There are two special cases\(dg of bracket expressions:
+the bracket expressions `[[:<:]]' and `[[:>:]]' match the null string at
+the beginning and end of a word respectively.
+A word is defined as a sequence of
+word characters
+which is neither preceded nor followed by
+word characters.
+A word character is an
+.I alnum
+character (as defined by
+.IR ctype (3))
+or an underscore.
+This is an extension,
+compatible with but not specified by POSIX 1003.2,
+and should be used with
+caution in software intended to be portable to other systems.
+.PP
+In the event that an RE could match more than one substring of a given
+string,
+the RE matches the one starting earliest in the string.
+If the RE could match more than one substring starting at that point,
+it matches the longest.
+Subexpressions also match the longest possible substrings, subject to
+the constraint that the whole match be as long as possible,
+with subexpressions starting earlier in the RE taking priority over
+ones starting later.
+Note that higher-level subexpressions thus take priority over
+their lower-level component subexpressions.
+.PP
+Match lengths are measured in characters, not collating elements.
+A null string is considered longer than no match at all.
+For example,
+`bb*' matches the three middle characters of `abbbc',
+`(wee|week)(knights|nights)' matches all ten characters of `weeknights',
+when `(.*).*' is matched against `abc' the parenthesized subexpression
+matches all three characters, and
+when `(a*)*' is matched against `bc' both the whole RE and the parenthesized
+subexpression match the null string.
+.PP
+If case-independent matching is specified,
+the effect is much as if all case distinctions had vanished from the
+alphabet.
+When an alphabetic that exists in multiple cases appears as an
+ordinary character outside a bracket expression, it is effectively
+transformed into a bracket expression containing both cases,
+e.g. `x' becomes `[xX]'.
+When it appears inside a bracket expression, all case counterparts
+of it are added to the bracket expression, so that (e.g.) `[x]'
+becomes `[xX]' and `[^x]' becomes `[^xX]'.
+.PP
+No particular limit is imposed on the length of REs\(dg.
+Programs intended to be portable should not employ REs longer
+than 256 bytes,
+as an implementation can refuse to accept such REs and remain
+POSIX-compliant.
+.PP
+Obsolete (``basic'') regular expressions differ in several respects.
+`|', `+', and `?' are ordinary characters and there is no equivalent
+for their functionality.
+The delimiters for bounds are `\e{' and `\e}',
+with `{' and `}' by themselves ordinary characters.
+The parentheses for nested subexpressions are `\e(' and `\e)',
+with `(' and `)' by themselves ordinary characters.
+`^' is an ordinary character except at the beginning of the
+RE or\(dg the beginning of a parenthesized subexpression,
+`$' is an ordinary character except at the end of the
+RE or\(dg the end of a parenthesized subexpression,
+and `*' is an ordinary character if it appears at the beginning of the
+RE or the beginning of a parenthesized subexpression
+(after a possible leading `^').
+Finally, there is one new type of atom, a \fIback reference\fR:
+`\e' followed by a non-zero decimal digit \fId\fR
+matches the same sequence of characters
+matched by the \fId\fRth parenthesized subexpression
+(numbering subexpressions by the positions of their opening parentheses,
+left to right),
+so that (e.g.) `\e([bc]\e)\e1' matches `bb' or `cc' but not `bc'.
+.SH SEE ALSO
+regex(3)
+.PP
+POSIX 1003.2, section 2.8 (Regular Expression Notation).
+.SH BUGS
+Having two kinds of REs is a botch.
+.PP
+The current 1003.2 spec says that `)' is an ordinary character in
+the absence of an unmatched `(';
+this was an unintentional result of a wording error,
+and change is likely.
+Avoid relying on it.
+.PP
+Back references are a dreadful botch,
+posing major problems for efficient implementations.
+They are also somewhat vaguely defined
+(does
+`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?).
+Avoid using them.
+.PP
+1003.2's specification of case-independent matching is vague.
+The ``one case implies all cases'' definition given above
+is current consensus among implementors as to the right interpretation.
+.PP
+The syntax for word boundaries is incredibly ugly.
diff --git a/regex/regcomp.c b/regex/regcomp.c
new file mode 100644
index 000000000000..8f7438f28d8a
--- /dev/null
+++ b/regex/regcomp.c
@@ -0,0 +1,1737 @@
+/* $NetBSD: regcomp.c,v 1.7 2011/11/19 17:45:11 tnozaki Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)regcomp.c 8.4 (Berkeley) 3/19/94
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regcomp.c 8.4 (Berkeley) 3/19/94";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <regex.h>
+
+#include "utils.h"
+#include "regex2.h"
+
+#include "cclass.h"
+#include "cname.h"
+
+/*
+ * parse structure, passed up and down to avoid global variables and
+ * other clumsinesses
+ */
+struct parse {
+ RCHAR_T *next; /* next character in RE */
+ RCHAR_T *end; /* end of string (-> NUL normally) */
+ int error; /* has an error been seen? */
+ sop *strip; /* malloced strip */
+ RCHAR_T *stripdata; /* malloced stripdata */
+ sopno ssize; /* malloced strip size (allocated) */
+ sopno slen; /* malloced strip length (used) */
+ int ncsalloc; /* number of csets allocated */
+ struct re_guts *g;
+# define NPAREN 10 /* we need to remember () 1-9 for back refs */
+ sopno pbegin[NPAREN]; /* -> ( ([0] unused) */
+ sopno pend[NPAREN]; /* -> ) ([0] unused) */
+};
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === regcomp.c === */
+static void p_ere __P((struct parse *p, int stop, size_t reclimit));
+static void p_ere_exp __P((struct parse *p, size_t reclimit));
+static void p_str __P((struct parse *p));
+static void p_bre __P((struct parse *p, int end1, int end2, size_t reclimit));
+static int p_simp_re __P((struct parse *p, int starordinary, size_t reclimit));
+static int p_count __P((struct parse *p));
+static void p_bracket __P((struct parse *p));
+static void p_b_term __P((struct parse *p, cset *cs));
+static void p_b_cclass __P((struct parse *p, cset *cs));
+static void p_b_eclass __P((struct parse *p, cset *cs));
+static char p_b_symbol __P((struct parse *p));
+static char p_b_coll_elem __P((struct parse *p, int endc));
+static char othercase __P((int ch));
+static void bothcases __P((struct parse *p, int ch));
+static void ordinary __P((struct parse *p, int ch));
+static void nonnewline __P((struct parse *p));
+static void repeat __P((struct parse *p, sopno start, int from, int to, size_t reclimit));
+static int seterr __P((struct parse *p, int e));
+static cset *allocset __P((struct parse *p));
+static void freeset __P((struct parse *p, cset *cs));
+static int freezeset __P((struct parse *p, cset *cs));
+static int firstch __P((struct parse *p, cset *cs));
+static int nch __P((struct parse *p, cset *cs));
+static void mcadd __P((struct parse *p, cset *cs, const char *cp));
+#ifdef notdef
+static void mcsub __P((cset *cs, char *cp));
+static int mcin __P((cset *cs, char *cp));
+static char *mcfind __P((cset *cs, char *cp));
+#endif
+static void mcinvert __P((struct parse *p, cset *cs));
+static void mccase __P((struct parse *p, cset *cs));
+#ifdef notdef
+static int isinsets __P((struct re_guts *g, int c));
+static int samesets __P((struct re_guts *g, int c1, int c2));
+#endif
+static void categorize __P((struct parse *p, struct re_guts *g));
+static sopno dupl __P((struct parse *p, sopno start, sopno finish));
+static void doemit __P((struct parse *p, sop op, size_t opnd));
+static void doinsert __P((struct parse *p, sop op, size_t opnd, sopno pos));
+static void dofwd __P((struct parse *p, sopno pos, sop value));
+static int enlarge __P((struct parse *p, sopno size));
+static void stripsnug __P((struct parse *p, struct re_guts *g));
+static void findmust __P((struct parse *p, struct re_guts *g));
+static sopno pluscount __P((struct parse *p, struct re_guts *g));
+
+#ifdef __cplusplus
+}
+#endif
+/* ========= end header generated by ./mkh ========= */
+
+static RCHAR_T nuls[10]; /* place to point scanner in event of error */
+
+/*
+ * macros for use with parse structure
+ * BEWARE: these know that the parse structure is named `p' !!!
+ */
+#define PEEK() (*p->next)
+#define PEEK2() (*(p->next+1))
+#define MORE() (p->next < p->end)
+#define MORE2() (p->next+1 < p->end)
+#define SEE(c) (MORE() && PEEK() == (c))
+#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
+#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0)
+#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
+#define NEXT() (p->next++)
+#define NEXT2() (p->next += 2)
+#define NEXTn(n) (p->next += (n))
+#define GETNEXT() (*p->next++)
+#define SETERROR(e) seterr(p, (e))
+#define REQUIRE(co, e) ((co) || SETERROR(e))
+#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e))
+#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e))
+#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e))
+#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
+#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
+#define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
+#define ASTERN(sop, pos) EMIT(sop, HERE()-pos)
+#define HERE() (p->slen)
+#define THERE() (p->slen - 1)
+#define THERETHERE() (p->slen - 2)
+#define DROP(n) (p->slen -= (n))
+
+#ifndef NDEBUG
+static int never = 0; /* for use in asserts; shuts lint up */
+#else
+#define never 0 /* some <assert.h>s have bugs too */
+#endif
+
+#define MEMLIMIT 0x8000000
+#define MEMSIZE(p) \
+ ((p)->ncsalloc / CHAR_BIT * (p)->g->csetsize + \
+ (p)->ncsalloc * sizeof(cset) + \
+ (p)->ssize * sizeof(sop))
+#define RECLIMIT 256
+
+/*
+ - regcomp - interface for parser and compilation
+ = extern int regcomp(regex_t *, const RCHAR_T *, int);
+ = #define REG_BASIC 0000
+ = #define REG_EXTENDED 0001
+ = #define REG_ICASE 0002
+ = #define REG_NOSUB 0004
+ = #define REG_NEWLINE 0010
+ = #define REG_NOSPEC 0020
+ = #define REG_PEND 0040
+ = #define REG_DUMP 0200
+ */
+int /* 0 success, otherwise REG_something */
+regcomp(regex_t *preg, const RCHAR_T *pattern, int cflags)
+{
+ struct parse pa;
+ register struct re_guts *g;
+ register struct parse *p = &pa;
+ register int i;
+ register size_t len;
+#ifdef REDEBUG
+# define GOODFLAGS(f) (f)
+#else
+# define GOODFLAGS(f) ((f)&~REG_DUMP)
+#endif
+
+ cflags = GOODFLAGS(cflags);
+ if ((cflags&REG_EXTENDED) && (cflags&REG_NOSPEC))
+ return(REG_INVARG);
+
+ if (cflags&REG_PEND) {
+ if (preg->re_endp < pattern)
+ return(REG_INVARG);
+ len = preg->re_endp - pattern;
+ } else
+ len = STRLEN(pattern);
+
+ /* do the mallocs early so failure handling is easy */
+ g = (struct re_guts *)malloc(sizeof(struct re_guts) +
+ (NC-1)*sizeof(cat_t));
+ if (g == NULL)
+ return(REG_ESPACE);
+ p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
+ p->strip = (sop *)malloc(p->ssize * sizeof(sop));
+ if (p->strip == NULL) {
+ free((char *)g);
+ return(REG_ESPACE);
+ }
+ p->stripdata = (RCHAR_T *)malloc(p->ssize * sizeof(RCHAR_T));
+ if (p->stripdata == NULL) {
+ free((char *)p->strip);
+ free((char *)g);
+ return(REG_ESPACE);
+ }
+ p->slen = 0;
+
+ /* set things up */
+ p->g = g;
+ p->next = (RCHAR_T *)pattern; /* convenience; we do not modify it */
+ p->end = p->next + len;
+ p->error = 0;
+ p->ncsalloc = 0;
+ for (i = 0; i < NPAREN; i++) {
+ p->pbegin[i] = 0;
+ p->pend[i] = 0;
+ }
+ g->csetsize = NC;
+ g->sets = NULL;
+ g->setbits = NULL;
+ g->ncsets = 0;
+ g->cflags = cflags;
+ g->iflags = 0;
+ g->nbol = 0;
+ g->neol = 0;
+ g->must = NULL;
+ g->mlen = 0;
+ g->nsub = 0;
+#if 0
+ g->ncategories = 1; /* category 0 is "everything else" */
+ g->categories = &g->catspace[-(CHAR_MIN)];
+ (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t));
+#endif
+ g->backrefs = 0;
+
+ /* do it */
+ EMIT(OEND, 0);
+ g->firststate = THERE();
+ if (cflags&REG_EXTENDED)
+ p_ere(p, OUT, 0);
+ else if (cflags&REG_NOSPEC)
+ p_str(p);
+ else
+ p_bre(p, OUT, OUT, 0);
+ EMIT(OEND, 0);
+ g->laststate = THERE();
+
+ /* tidy up loose ends and fill things in */
+ categorize(p, g);
+ stripsnug(p, g);
+ findmust(p, g);
+ g->nplus = pluscount(p, g);
+ g->magic = MAGIC2;
+ preg->re_nsub = g->nsub;
+ preg->re_g = g;
+ preg->re_magic = MAGIC1;
+#ifndef REDEBUG
+ /* not debugging, so can't rely on the assert() in regexec() */
+ if (g->iflags&BAD)
+ SETERROR(REG_ASSERT);
+#endif
+
+ /* win or lose, we're done */
+ if (p->error != 0) /* lose */
+ regfree(preg);
+ return(p->error);
+}
+
+/*
+ - p_ere - ERE parser top level, concatenation and alternation
+ == static void p_ere(register struct parse *p, int stop, size_t reclimit);
+ */
+static void
+p_ere(register struct parse *p, int stop, size_t reclimit)
+
+ /* character this ERE should end at */
+{
+ register char c;
+ register sopno prevback = 0;
+ register sopno prevfwd = 0;
+ register sopno conc;
+ register int first = 1; /* is this the first alternative? */
+
+ if (reclimit++ > RECLIMIT || p->error == REG_ESPACE) {
+ p->error = REG_ESPACE;
+ return;
+ }
+
+ for (;;) {
+ /* do a bunch of concatenated expressions */
+ conc = HERE();
+ while (MORE() && (c = PEEK()) != '|' && c != stop)
+ p_ere_exp(p, reclimit);
+ (void)REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */
+
+ if (!EAT('|'))
+ break; /* NOTE BREAK OUT */
+
+ if (first) {
+ INSERT(OCH_, conc); /* offset is wrong */
+ prevfwd = conc;
+ prevback = conc;
+ first = 0;
+ }
+ ASTERN(OOR1, prevback);
+ prevback = THERE();
+ AHEAD(prevfwd); /* fix previous offset */
+ prevfwd = HERE();
+ EMIT(OOR2, 0); /* offset is very wrong */
+ }
+
+ if (!first) { /* tail-end fixups */
+ AHEAD(prevfwd);
+ ASTERN(O_CH, prevback);
+ }
+
+ assert(!MORE() || SEE(stop));
+}
+
+/*
+ - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
+ == static void p_ere_exp(register struct parse *p);
+ */
+static void
+p_ere_exp(register struct parse *p, size_t reclimit)
+{
+ register char c;
+ register sopno pos;
+ register int count;
+ register int count2;
+ register sopno subno;
+ int wascaret = 0;
+
+ assert(MORE()); /* caller should have ensured this */
+ c = GETNEXT();
+
+ pos = HERE();
+ switch (c) {
+ case '(':
+ (void)REQUIRE(MORE(), REG_EPAREN);
+ p->g->nsub++;
+ subno = p->g->nsub;
+ if (subno < NPAREN)
+ p->pbegin[subno] = HERE();
+ EMIT(OLPAREN, subno);
+ if (!SEE(')'))
+ p_ere(p, ')', reclimit);
+ if (subno < NPAREN) {
+ p->pend[subno] = HERE();
+ assert(p->pend[subno] != 0);
+ }
+ EMIT(ORPAREN, subno);
+ (void)MUSTEAT(')', REG_EPAREN);
+ break;
+#ifndef POSIX_MISTAKE
+ case ')': /* happens only if no current unmatched ( */
+ /*
+ * You may ask, why the ifndef? Because I didn't notice
+ * this until slightly too late for 1003.2, and none of the
+ * other 1003.2 regular-expression reviewers noticed it at
+ * all. So an unmatched ) is legal POSIX, at least until
+ * we can get it fixed.
+ */
+ SETERROR(REG_EPAREN);
+ break;
+#endif
+ case '^':
+ EMIT(OBOL, 0);
+ p->g->iflags |= USEBOL;
+ p->g->nbol++;
+ wascaret = 1;
+ break;
+ case '$':
+ EMIT(OEOL, 0);
+ p->g->iflags |= USEEOL;
+ p->g->neol++;
+ break;
+ case '|':
+ SETERROR(REG_EMPTY);
+ break;
+ case '*':
+ case '+':
+ case '?':
+ SETERROR(REG_BADRPT);
+ break;
+ case '.':
+ if (p->g->cflags&REG_NEWLINE)
+ nonnewline(p);
+ else
+ EMIT(OANY, 0);
+ break;
+ case '[':
+ p_bracket(p);
+ break;
+ case '\\':
+ (void)REQUIRE(MORE(), REG_EESCAPE);
+ c = GETNEXT();
+ ordinary(p, c);
+ break;
+ case '{': /* okay as ordinary except if digit follows */
+ (void)REQUIRE(!MORE() || !ISDIGIT((UCHAR_T)PEEK()), REG_BADRPT);
+ /* FALLTHROUGH */
+ default:
+ ordinary(p, c);
+ break;
+ }
+
+ if (!MORE())
+ return;
+ c = PEEK();
+ /* we call { a repetition if followed by a digit */
+ if (!( c == '*' || c == '+' || c == '?' ||
+ (c == '{' && MORE2() && ISDIGIT((UCHAR_T)PEEK2())) ))
+ return; /* no repetition, we're done */
+ NEXT();
+
+ (void)REQUIRE(!wascaret, REG_BADRPT);
+ switch (c) {
+ case '*': /* implemented as +? */
+ /* this case does not require the (y|) trick, noKLUDGE */
+ INSERT(OPLUS_, pos);
+ ASTERN(O_PLUS, pos);
+ INSERT(OQUEST_, pos);
+ ASTERN(O_QUEST, pos);
+ break;
+ case '+':
+ INSERT(OPLUS_, pos);
+ ASTERN(O_PLUS, pos);
+ break;
+ case '?':
+ /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
+ INSERT(OCH_, pos); /* offset slightly wrong */
+ ASTERN(OOR1, pos); /* this one's right */
+ AHEAD(pos); /* fix the OCH_ */
+ EMIT(OOR2, 0); /* offset very wrong... */
+ AHEAD(THERE()); /* ...so fix it */
+ ASTERN(O_CH, THERETHERE());
+ break;
+ case '{':
+ count = p_count(p);
+ if (EAT(',')) {
+ if (ISDIGIT((UCHAR_T)PEEK())) {
+ count2 = p_count(p);
+ (void)REQUIRE(count <= count2, REG_BADBR);
+ } else /* single number with comma */
+ count2 = INFINITY;
+ } else /* just a single number */
+ count2 = count;
+ repeat(p, pos, count, count2, 0);
+ if (!EAT('}')) { /* error heuristics */
+ while (MORE() && PEEK() != '}')
+ NEXT();
+ (void)REQUIRE(MORE(), REG_EBRACE);
+ SETERROR(REG_BADBR);
+ }
+ break;
+ }
+
+ if (!MORE())
+ return;
+ c = PEEK();
+ if (!( c == '*' || c == '+' || c == '?' ||
+ (c == '{' && MORE2() && ISDIGIT((UCHAR_T)PEEK2())) ) )
+ return;
+ SETERROR(REG_BADRPT);
+}
+
+/*
+ - p_str - string (no metacharacters) "parser"
+ == static void p_str(register struct parse *p);
+ */
+static void
+p_str(register struct parse *p)
+{
+ (void)REQUIRE(MORE(), REG_EMPTY);
+ while (MORE())
+ ordinary(p, GETNEXT());
+}
+
+/*
+ - p_bre - BRE parser top level, anchoring and concatenation
+ == static void p_bre(register struct parse *p, register int end1, \
+ == register int end2, size_t reclimit);
+ * Giving end1 as OUT essentially eliminates the end1/end2 check.
+ *
+ * This implementation is a bit of a kludge, in that a trailing $ is first
+ * taken as an ordinary character and then revised to be an anchor. The
+ * only undesirable side effect is that '$' gets included as a character
+ * category in such cases. This is fairly harmless; not worth fixing.
+ * The amount of lookahead needed to avoid this kludge is excessive.
+ */
+static void
+p_bre(register struct parse *p, register int end1, register int end2, size_t reclimit)
+
+ /* first terminating character */
+ /* second terminating character */
+{
+ register sopno start;
+ register int first = 1; /* first subexpression? */
+ register int wasdollar = 0;
+
+ if (reclimit++ > RECLIMIT || p->error == REG_ESPACE) {
+ p->error = REG_ESPACE;
+ return;
+ }
+
+ start = HERE();
+
+ if (EAT('^')) {
+ EMIT(OBOL, 0);
+ p->g->iflags |= USEBOL;
+ p->g->nbol++;
+ }
+ while (MORE() && !SEETWO(end1, end2)) {
+ wasdollar = p_simp_re(p, first, reclimit);
+ first = 0;
+ }
+ if (wasdollar) { /* oops, that was a trailing anchor */
+ DROP(1);
+ EMIT(OEOL, 0);
+ p->g->iflags |= USEEOL;
+ p->g->neol++;
+ }
+
+ (void)REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */
+}
+
+/*
+ - p_simp_re - parse a simple RE, an atom possibly followed by a repetition
+ == static int p_simp_re(register struct parse *p, int starordinary, size_t reclimit);
+ */
+static int /* was the simple RE an unbackslashed $? */
+p_simp_re(register struct parse *p, int starordinary, size_t reclimit)
+
+ /* is a leading * an ordinary character? */
+{
+ register int c;
+ register int count;
+ register int count2;
+ register sopno pos;
+ register int i;
+ register sopno subno;
+ int backsl;
+
+ pos = HERE(); /* repetion op, if any, covers from here */
+
+ assert(MORE()); /* caller should have ensured this */
+ c = GETNEXT();
+ backsl = c == '\\';
+ if (backsl) {
+ (void)REQUIRE(MORE(), REG_EESCAPE);
+ c = (unsigned char)GETNEXT();
+ switch (c) {
+ case '{':
+ SETERROR(REG_BADRPT);
+ break;
+ case '(':
+ p->g->nsub++;
+ subno = p->g->nsub;
+ if (subno < NPAREN)
+ p->pbegin[subno] = HERE();
+ EMIT(OLPAREN, subno);
+ /* the MORE here is an error heuristic */
+ if (MORE() && !SEETWO('\\', ')'))
+ p_bre(p, '\\', ')', reclimit);
+ if (subno < NPAREN) {
+ p->pend[subno] = HERE();
+ assert(p->pend[subno] != 0);
+ }
+ EMIT(ORPAREN, subno);
+ (void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN);
+ break;
+ case ')': /* should not get here -- must be user */
+ case '}':
+ SETERROR(REG_EPAREN);
+ break;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ i = c - '0';
+ assert(i < NPAREN);
+ if (p->pend[i] != 0) {
+ assert(i <= p->g->nsub);
+ EMIT(OBACK_, i);
+ assert(p->pbegin[i] != 0);
+ assert(p->strip[p->pbegin[i]] == OLPAREN);
+ assert(p->strip[p->pend[i]] == ORPAREN);
+ (void) dupl(p, p->pbegin[i]+1, p->pend[i]);
+ EMIT(O_BACK, i);
+ } else
+ SETERROR(REG_ESUBREG);
+ p->g->backrefs = 1;
+ break;
+ default:
+ ordinary(p, c);
+ break;
+ }
+ } else {
+ switch (c) {
+ case '.':
+ if (p->g->cflags&REG_NEWLINE)
+ nonnewline(p);
+ else
+ EMIT(OANY, 0);
+ break;
+ case '[':
+ p_bracket(p);
+ break;
+ case '*':
+ (void)REQUIRE(starordinary, REG_BADRPT);
+ /* FALLTHROUGH */
+ default:
+ ordinary(p, c);
+ break;
+ }
+ }
+
+ if (EAT('*')) { /* implemented as +? */
+ /* this case does not require the (y|) trick, noKLUDGE */
+ INSERT(OPLUS_, pos);
+ ASTERN(O_PLUS, pos);
+ INSERT(OQUEST_, pos);
+ ASTERN(O_QUEST, pos);
+ } else if (EATTWO('\\', '{')) {
+ count = p_count(p);
+ if (EAT(',')) {
+ if (MORE() && ISDIGIT((UCHAR_T)PEEK())) {
+ count2 = p_count(p);
+ (void)REQUIRE(count <= count2, REG_BADBR);
+ } else /* single number with comma */
+ count2 = INFINITY;
+ } else /* just a single number */
+ count2 = count;
+ repeat(p, pos, count, count2, reclimit);
+ if (!EATTWO('\\', '}')) { /* error heuristics */
+ while (MORE() && !SEETWO('\\', '}'))
+ NEXT();
+ (void)REQUIRE(MORE(), REG_EBRACE);
+ SETERROR(REG_BADBR);
+ }
+ } else if (!backsl && c == (unsigned char)'$') /* $ (but not \$) ends it */
+ return(1);
+
+ return(0);
+}
+
+/*
+ - p_count - parse a repetition count
+ == static int p_count(register struct parse *p);
+ */
+static int /* the value */
+p_count(register struct parse *p)
+{
+ register int count = 0;
+ register int ndigits = 0;
+
+ while (MORE() && ISDIGIT((UCHAR_T)PEEK()) && count <= DUPMAX) {
+ count = count*10 + (GETNEXT() - '0');
+ ndigits++;
+ }
+
+ (void)REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR);
+ return(count);
+}
+
+/*
+ - p_bracket - parse a bracketed character list
+ == static void p_bracket(register struct parse *p);
+ *
+ * Note a significant property of this code: if the allocset() did SETERROR,
+ * no set operations are done.
+ */
+static void
+p_bracket(register struct parse *p)
+{
+ register cset *cs;
+ register int invert = 0;
+ static RCHAR_T bow[] = { '[', ':', '<', ':', ']', ']' };
+ static RCHAR_T eow[] = { '[', ':', '>', ':', ']', ']' };
+
+ cs = allocset(p);
+ if (cs == NULL)
+ return;
+
+ /* Dept of Truly Sickening Special-Case Kludges */
+ if (p->next + 5 < p->end && MEMCMP(p->next, bow, 6) == 0) {
+ EMIT(OBOW, 0);
+ NEXTn(6);
+ return;
+ }
+ if (p->next + 5 < p->end && MEMCMP(p->next, eow, 6) == 0) {
+ EMIT(OEOW, 0);
+ NEXTn(6);
+ return;
+ }
+
+ if (EAT('^'))
+ invert++; /* make note to invert set at end */
+ if (EAT(']'))
+ CHadd(cs, ']');
+ else if (EAT('-'))
+ CHadd(cs, '-');
+ while (MORE() && PEEK() != ']' && !SEETWO('-', ']'))
+ p_b_term(p, cs);
+ if (EAT('-'))
+ CHadd(cs, '-');
+ (void)MUSTEAT(']', REG_EBRACK);
+
+ if (p->error != 0) /* don't mess things up further */
+ return;
+
+ if (p->g->cflags&REG_ICASE) {
+ register int i;
+ register int ci;
+
+ for (i = p->g->csetsize - 1; i >= 0; i--)
+ if (CHIN(cs, i) && isalpha(i)) {
+ ci = othercase(i);
+ if (ci != i)
+ CHadd(cs, ci);
+ }
+ if (cs->multis != NULL)
+ mccase(p, cs);
+ }
+ if (invert) {
+ register int i;
+
+ for (i = p->g->csetsize - 1; i >= 0; i--)
+ if (CHIN(cs, i))
+ CHsub(cs, i);
+ else
+ CHadd(cs, i);
+ if (p->g->cflags&REG_NEWLINE)
+ CHsub(cs, '\n');
+ if (cs->multis != NULL)
+ mcinvert(p, cs);
+ }
+
+ assert(cs->multis == NULL); /* xxx */
+
+ if (nch(p, cs) == 1) { /* optimize singleton sets */
+ ordinary(p, firstch(p, cs));
+ freeset(p, cs);
+ } else
+ EMIT(OANYOF, freezeset(p, cs));
+}
+
+/*
+ - p_b_term - parse one term of a bracketed character list
+ == static void p_b_term(register struct parse *p, register cset *cs);
+ */
+static void
+p_b_term(register struct parse *p, register cset *cs)
+{
+ register char c;
+ register char start, finish;
+ register int i;
+
+ /* classify what we've got */
+ switch ((MORE()) ? PEEK() : '\0') {
+ case '[':
+ c = (MORE2()) ? PEEK2() : '\0';
+ break;
+ case '-':
+ SETERROR(REG_ERANGE);
+ return; /* NOTE RETURN */
+ break;
+ default:
+ c = '\0';
+ break;
+ }
+
+ switch (c) {
+ case ':': /* character class */
+ NEXT2();
+ (void)REQUIRE(MORE(), REG_EBRACK);
+ c = PEEK();
+ (void)REQUIRE(c != '-' && c != ']', REG_ECTYPE);
+ p_b_cclass(p, cs);
+ (void)REQUIRE(MORE(), REG_EBRACK);
+ (void)REQUIRE(EATTWO(':', ']'), REG_ECTYPE);
+ break;
+ case '=': /* equivalence class */
+ NEXT2();
+ (void)REQUIRE(MORE(), REG_EBRACK);
+ c = PEEK();
+ (void)REQUIRE(c != '-' && c != ']', REG_ECOLLATE);
+ p_b_eclass(p, cs);
+ (void)REQUIRE(MORE(), REG_EBRACK);
+ (void)REQUIRE(EATTWO('=', ']'), REG_ECOLLATE);
+ break;
+ default: /* symbol, ordinary character, or range */
+/* xxx revision needed for multichar stuff */
+ start = p_b_symbol(p);
+ if (SEE('-') && MORE2() && PEEK2() != ']') {
+ /* range */
+ NEXT();
+ if (EAT('-'))
+ finish = '-';
+ else
+ finish = p_b_symbol(p);
+ } else
+ finish = start;
+/* xxx what about signed chars here... */
+ (void)REQUIRE(start <= finish, REG_ERANGE);
+ for (i = start; i <= finish; i++)
+ CHadd(cs, i);
+ break;
+ }
+}
+
+/*
+ - p_b_cclass - parse a character-class name and deal with it
+ == static void p_b_cclass(register struct parse *p, register cset *cs);
+ */
+static void
+p_b_cclass(register struct parse *p, register cset *cs)
+{
+ register RCHAR_T *sp = p->next;
+ register struct cclass *cp;
+ register size_t len;
+ register const char *u;
+ register char c;
+
+ while (MORE() && isalpha(PEEK()))
+ NEXT();
+ len = p->next - sp;
+ for (cp = cclasses; cp->name != NULL; cp++)
+ if (STRLEN(cp->name) == len && !MEMCMP(cp->name, sp, len))
+ break;
+ if (cp->name == NULL) {
+ /* oops, didn't find it */
+ SETERROR(REG_ECTYPE);
+ return;
+ }
+
+ u = cp->chars;
+ while ((c = *u++) != '\0')
+ CHadd(cs, c);
+ for (u = cp->multis; *u != '\0'; u += strlen(u) + 1)
+ MCadd(p, cs, u);
+}
+
+/*
+ - p_b_eclass - parse an equivalence-class name and deal with it
+ == static void p_b_eclass(register struct parse *p, register cset *cs);
+ *
+ * This implementation is incomplete. xxx
+ */
+static void
+p_b_eclass(register struct parse *p, register cset *cs)
+{
+ register char c;
+
+ c = p_b_coll_elem(p, '=');
+ CHadd(cs, c);
+}
+
+/*
+ - p_b_symbol - parse a character or [..]ed multicharacter collating symbol
+ == static char p_b_symbol(register struct parse *p);
+ */
+static char /* value of symbol */
+p_b_symbol(register struct parse *p)
+{
+ register char value;
+
+ (void)REQUIRE(MORE(), REG_EBRACK);
+ if (!EATTWO('[', '.'))
+ return(GETNEXT());
+
+ /* collating symbol */
+ value = p_b_coll_elem(p, '.');
+ (void)REQUIRE(EATTWO('.', ']'), REG_ECOLLATE);
+ return(value);
+}
+
+/*
+ - p_b_coll_elem - parse a collating-element name and look it up
+ == static char p_b_coll_elem(register struct parse *p, int endc);
+ */
+static char /* value of collating element */
+p_b_coll_elem(register struct parse *p, int endc)
+
+ /* name ended by endc,']' */
+{
+ register RCHAR_T *sp = p->next;
+ register struct cname *cp;
+ register size_t len;
+
+ while (MORE() && !SEETWO(endc, ']'))
+ NEXT();
+ if (!MORE()) {
+ SETERROR(REG_EBRACK);
+ return(0);
+ }
+ len = p->next - sp;
+ for (cp = cnames; cp->name != NULL; cp++)
+ if (STRLEN(cp->name) == len && MEMCMP(cp->name, sp, len))
+ return(cp->code); /* known name */
+ if (len == 1)
+ return(*sp); /* single character */
+ SETERROR(REG_ECOLLATE); /* neither */
+ return(0);
+}
+
+/*
+ - othercase - return the case counterpart of an alphabetic
+ == static char othercase(int ch);
+ */
+static char /* if no counterpart, return ch */
+othercase(int ch)
+{
+ assert(isalpha(ch));
+ if (isupper(ch))
+ return(tolower(ch));
+ else if (islower(ch))
+ return(toupper(ch));
+ else /* peculiar, but could happen */
+ return(ch);
+}
+
+/*
+ - bothcases - emit a dualcase version of a two-case character
+ == static void bothcases(register struct parse *p, int ch);
+ *
+ * Boy, is this implementation ever a kludge...
+ */
+static void
+bothcases(register struct parse *p, int ch)
+{
+ register RCHAR_T *oldnext = p->next;
+ register RCHAR_T *oldend = p->end;
+ RCHAR_T bracket[3];
+
+ assert(othercase(ch) != ch); /* p_bracket() would recurse */
+ p->next = bracket;
+ p->end = bracket+2;
+ bracket[0] = ch;
+ bracket[1] = ']';
+ bracket[2] = '\0';
+ p_bracket(p);
+ assert(p->next == bracket+2);
+ p->next = oldnext;
+ p->end = oldend;
+}
+
+/*
+ - ordinary - emit an ordinary character
+ == static void ordinary(register struct parse *p, register int ch);
+ */
+static void
+ordinary(register struct parse *p, register int ch)
+{
+/*
+ register cat_t *cap = p->g->categories;
+*/
+
+ if ((p->g->cflags&REG_ICASE) && isalpha(ch) && othercase(ch) != ch)
+ bothcases(p, ch);
+ else {
+ EMIT(OCHAR, (UCHAR_T)ch);
+/*
+ if (cap[ch] == 0)
+ cap[ch] = p->g->ncategories++;
+*/
+ }
+}
+
+/*
+ - nonnewline - emit REG_NEWLINE version of OANY
+ == static void nonnewline(register struct parse *p);
+ *
+ * Boy, is this implementation ever a kludge...
+ */
+static void
+nonnewline(register struct parse *p)
+{
+ register RCHAR_T *oldnext = p->next;
+ register RCHAR_T *oldend = p->end;
+ RCHAR_T bracket[4];
+
+ p->next = bracket;
+ p->end = bracket+3;
+ bracket[0] = '^';
+ bracket[1] = '\n';
+ bracket[2] = ']';
+ bracket[3] = '\0';
+ p_bracket(p);
+ assert(p->next == bracket+3);
+ p->next = oldnext;
+ p->end = oldend;
+}
+
+/*
+ - repeat - generate code for a bounded repetition, recursively if needed
+ == static void repeat(register struct parse *p, sopno start, int from, int to, size_t reclimit);
+ */
+static void
+repeat(register struct parse *p, sopno start, int from, int to, size_t reclimit)
+
+ /* operand from here to end of strip */
+ /* repeated from this number */
+ /* to this number of times (maybe INFINITY) */
+{
+ register sopno finish;
+# define N 2
+# define INF 3
+# define REP(f, t) ((f)*8 + (t))
+# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)
+ register sopno copy;
+
+ if (reclimit++ > RECLIMIT)
+ p->error = REG_ESPACE;
+ if (p->error)
+ return;
+
+ finish = HERE();
+
+ assert(from <= to);
+
+ switch (REP(MAP(from), MAP(to))) {
+ case REP(0, 0): /* must be user doing this */
+ DROP(finish-start); /* drop the operand */
+ break;
+ case REP(0, 1): /* as x{1,1}? */
+ case REP(0, N): /* as x{1,n}? */
+ case REP(0, INF): /* as x{1,}? */
+ /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
+ INSERT(OCH_, start); /* offset is wrong... */
+ repeat(p, start+1, 1, to, reclimit);
+ ASTERN(OOR1, start);
+ AHEAD(start); /* ... fix it */
+ EMIT(OOR2, 0);
+ AHEAD(THERE());
+ ASTERN(O_CH, THERETHERE());
+ break;
+ case REP(1, 1): /* trivial case */
+ /* done */
+ break;
+ case REP(1, N): /* as x?x{1,n-1} */
+ /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */
+ INSERT(OCH_, start);
+ ASTERN(OOR1, start);
+ AHEAD(start);
+ EMIT(OOR2, 0); /* offset very wrong... */
+ AHEAD(THERE()); /* ...so fix it */
+ ASTERN(O_CH, THERETHERE());
+ copy = dupl(p, start+1, finish+1);
+ assert(copy == finish+4);
+ repeat(p, copy, 1, to-1, reclimit);
+ break;
+ case REP(1, INF): /* as x+ */
+ INSERT(OPLUS_, start);
+ ASTERN(O_PLUS, start);
+ break;
+ case REP(N, N): /* as xx{m-1,n-1} */
+ copy = dupl(p, start, finish);
+ repeat(p, copy, from-1, to-1, reclimit);
+ break;
+ case REP(N, INF): /* as xx{n-1,INF} */
+ copy = dupl(p, start, finish);
+ repeat(p, copy, from-1, to, reclimit);
+ break;
+ default: /* "can't happen" */
+ SETERROR(REG_ASSERT); /* just in case */
+ break;
+ }
+}
+
+/*
+ - seterr - set an error condition
+ == static int seterr(register struct parse *p, int e);
+ */
+static int /* useless but makes type checking happy */
+seterr(register struct parse *p, int e)
+{
+ if (p->error == 0) /* keep earliest error condition */
+ p->error = e;
+ p->next = nuls; /* try to bring things to a halt */
+ p->end = nuls;
+ return(0); /* make the return value well-defined */
+}
+
+/*
+ - allocset - allocate a set of characters for []
+ == static cset *allocset(register struct parse *p);
+ */
+static cset *
+allocset(register struct parse *p)
+{
+ register int no = p->g->ncsets++;
+ register size_t nc;
+ register size_t nbytes;
+ register cset *cs;
+ register size_t css = (size_t)p->g->csetsize;
+ register int i;
+
+ if (no >= p->ncsalloc) { /* need another column of space */
+ p->ncsalloc += CHAR_BIT;
+ nc = p->ncsalloc;
+ assert(nc % CHAR_BIT == 0);
+ nbytes = nc / CHAR_BIT * css;
+ if (MEMSIZE(p) > MEMLIMIT)
+ goto oomem;
+ if (p->g->sets == NULL)
+ p->g->sets = (cset *)malloc(nc * sizeof(cset));
+ else
+ p->g->sets = (cset *)realloc((char *)p->g->sets,
+ nc * sizeof(cset));
+ if (p->g->setbits == NULL)
+ p->g->setbits = (uch *)malloc(nbytes);
+ else {
+ p->g->setbits = (uch *)realloc((char *)p->g->setbits,
+ nbytes);
+ /* xxx this isn't right if setbits is now NULL */
+ for (i = 0; i < no; i++)
+ p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
+ }
+ if (p->g->sets != NULL && p->g->setbits != NULL)
+ (void) memset((char *)p->g->setbits + (nbytes - css),
+ 0, css);
+ else {
+oomem:
+ no = 0;
+ SETERROR(REG_ESPACE);
+ /* caller's responsibility not to do set ops */
+ return NULL;
+ }
+ }
+
+ cs = &p->g->sets[no];
+ cs->ptr = p->g->setbits + css*((no)/CHAR_BIT);
+ cs->mask = 1 << ((no) % CHAR_BIT);
+ cs->hash = 0;
+ cs->smultis = 0;
+ cs->multis = NULL;
+
+ return(cs);
+}
+
+/*
+ - freeset - free a now-unused set
+ == static void freeset(register struct parse *p, register cset *cs);
+ */
+static void
+freeset(register struct parse *p, register cset *cs)
+{
+ register size_t i;
+ register cset *top = &p->g->sets[p->g->ncsets];
+ register size_t css = (size_t)p->g->csetsize;
+
+ for (i = 0; i < css; i++)
+ CHsub(cs, i);
+ if (cs == top-1) /* recover only the easy case */
+ p->g->ncsets--;
+}
+
+/*
+ - freezeset - final processing on a set of characters
+ == static int freezeset(register struct parse *p, register cset *cs);
+ *
+ * The main task here is merging identical sets. This is usually a waste
+ * of time (although the hash code minimizes the overhead), but can win
+ * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash
+ * is done using addition rather than xor -- all ASCII [aA] sets xor to
+ * the same value!
+ */
+static int /* set number */
+freezeset(register struct parse *p, register cset *cs)
+{
+ register uch h = cs->hash;
+ register size_t i;
+ register cset *top = &p->g->sets[p->g->ncsets];
+ register cset *cs2;
+ register size_t css = (size_t)p->g->csetsize;
+
+ /* look for an earlier one which is the same */
+ for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
+ if (cs2->hash == h && cs2 != cs) {
+ /* maybe */
+ for (i = 0; i < css; i++)
+ if (!!CHIN(cs2, i) != !!CHIN(cs, i))
+ break; /* no */
+ if (i == css)
+ break; /* yes */
+ }
+
+ if (cs2 < top) { /* found one */
+ freeset(p, cs);
+ cs = cs2;
+ }
+
+ return((int)(cs - p->g->sets));
+}
+
+/*
+ - firstch - return first character in a set (which must have at least one)
+ == static int firstch(register struct parse *p, register cset *cs);
+ */
+static int /* character; there is no "none" value */
+firstch(register struct parse *p, register cset *cs)
+{
+ register size_t i;
+ register size_t css = (size_t)p->g->csetsize;
+
+ for (i = 0; i < css; i++)
+ if (CHIN(cs, i))
+ return((char)i);
+ assert(never);
+ return(0); /* arbitrary */
+}
+
+/*
+ - nch - number of characters in a set
+ == static int nch(register struct parse *p, register cset *cs);
+ */
+static int
+nch(register struct parse *p, register cset *cs)
+{
+ register size_t i;
+ register size_t css = (size_t)p->g->csetsize;
+ register int n = 0;
+
+ for (i = 0; i < css; i++)
+ if (CHIN(cs, i))
+ n++;
+ return(n);
+}
+
+/*
+ - mcadd - add a collating element to a cset
+ == static void mcadd(register struct parse *p, register cset *cs, \
+ == register char *cp);
+ */
+static void
+mcadd(register struct parse *p, register cset *cs, register const char *cp)
+{
+ register size_t oldend = cs->smultis;
+ void *np;
+
+ cs->smultis += strlen(cp) + 1;
+ np = realloc(cs->multis, cs->smultis);
+ if (np == NULL) {
+ if (cs->multis)
+ free(cs->multis);
+ cs->multis = NULL;
+ SETERROR(REG_ESPACE);
+ return;
+ }
+ cs->multis = np;
+
+ (void) strlcpy(cs->multis + oldend - 1, cp, cs->smultis - oldend + 1);
+}
+
+#ifdef notdef
+/*
+ - mcsub - subtract a collating element from a cset
+ == static void mcsub(register cset *cs, register char *cp);
+ */
+static void
+mcsub(register cset *cs, register char *cp)
+{
+ register char *fp = mcfind(cs, cp);
+ register size_t len = strlen(fp);
+
+ assert(fp != NULL);
+ (void) memmove(fp, fp + len + 1,
+ cs->smultis - (fp + len + 1 - cs->multis));
+ cs->smultis -= len;
+
+ if (cs->smultis == 0) {
+ free(cs->multis);
+ cs->multis = NULL;
+ return;
+ }
+
+ cs->multis = realloc(cs->multis, cs->smultis);
+ assert(cs->multis != NULL);
+}
+
+/*
+ - mcin - is a collating element in a cset?
+ == static int mcin(register cset *cs, register char *cp);
+ */
+static int
+mcin(register cset *cs, register char *cp)
+{
+ return(mcfind(cs, cp) != NULL);
+}
+
+/*
+ - mcfind - find a collating element in a cset
+ == static char *mcfind(register cset *cs, register char *cp);
+ */
+static char *
+mcfind(register cset *cs, register char *cp)
+{
+ register char *p;
+
+ if (cs->multis == NULL)
+ return(NULL);
+ for (p = cs->multis; *p != '\0'; p += strlen(p) + 1)
+ if (strcmp(cp, p) == 0)
+ return(p);
+ return(NULL);
+}
+#endif
+
+/*
+ - mcinvert - invert the list of collating elements in a cset
+ == static void mcinvert(register struct parse *p, register cset *cs);
+ *
+ * This would have to know the set of possibilities. Implementation
+ * is deferred.
+ */
+static void
+mcinvert(register struct parse *p, register cset *cs)
+{
+ assert(cs->multis == NULL); /* xxx */
+}
+
+/*
+ - mccase - add case counterparts of the list of collating elements in a cset
+ == static void mccase(register struct parse *p, register cset *cs);
+ *
+ * This would have to know the set of possibilities. Implementation
+ * is deferred.
+ */
+static void
+mccase(register struct parse *p, register cset *cs)
+{
+ assert(cs->multis == NULL); /* xxx */
+}
+
+#ifdef notdef
+/*
+ - isinsets - is this character in any sets?
+ == static int isinsets(register struct re_guts *g, int c);
+ */
+static int /* predicate */
+isinsets(register struct re_guts *g, int c)
+{
+ register uch *col;
+ register int i;
+ register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
+ register unsigned uc = (unsigned char)c;
+
+ for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
+ if (col[uc] != 0)
+ return(1);
+ return(0);
+}
+
+/*
+ - samesets - are these two characters in exactly the same sets?
+ == static int samesets(register struct re_guts *g, int c1, int c2);
+ */
+static int /* predicate */
+samesets(register struct re_guts *g, int c1, int c2)
+{
+ register uch *col;
+ register int i;
+ register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
+ register unsigned uc1 = (unsigned char)c1;
+ register unsigned uc2 = (unsigned char)c2;
+
+ for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize)
+ if (col[uc1] != col[uc2])
+ return(0);
+ return(1);
+}
+#endif
+
+/*
+ - categorize - sort out character categories
+ == static void categorize(struct parse *p, register struct re_guts *g);
+ */
+static void
+categorize(struct parse *p, register struct re_guts *g)
+{
+#ifdef notdef
+ register cat_t *cats = g->categories;
+ register int c;
+ register int c2;
+ register cat_t cat;
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ for (c = CHAR_MIN; c <= CHAR_MAX; c++)
+ if (cats[c] == 0 && isinsets(g, c)) {
+ cat = g->ncategories++;
+ cats[c] = cat;
+ for (c2 = c+1; c2 <= CHAR_MAX; c2++)
+ if (cats[c2] == 0 && samesets(g, c, c2))
+ cats[c2] = cat;
+ }
+#endif
+}
+
+/*
+ - dupl - emit a duplicate of a bunch of sops
+ == static sopno dupl(register struct parse *p, sopno start, sopno finish);
+ */
+static sopno /* start of duplicate */
+dupl(register struct parse *p, sopno start, sopno finish)
+
+ /* from here */
+ /* to this less one */
+{
+ register sopno ret = HERE();
+ register sopno len = finish - start;
+
+ assert(finish >= start);
+ if (len == 0)
+ return(ret);
+ if (!enlarge(p, p->ssize + len)) /* this many unexpected additions */
+ return ret;
+ assert(p->ssize >= p->slen + len);
+ (void) memcpy((char *)(p->strip + p->slen),
+ (char *)(p->strip + start), (size_t)len*sizeof(sop));
+ (void) memcpy((char *)(p->stripdata + p->slen),
+ (char *)(p->stripdata + start), (size_t)len*sizeof(RCHAR_T));
+ p->slen += len;
+ return(ret);
+}
+
+/*
+ - doemit - emit a strip operator
+ == static void doemit(register struct parse *p, sop op, size_t opnd);
+ *
+ * It might seem better to implement this as a macro with a function as
+ * hard-case backup, but it's just too big and messy unless there are
+ * some changes to the data structures. Maybe later.
+ */
+static void
+doemit(register struct parse *p, sop op, size_t opnd)
+{
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ /* deal with oversize operands ("can't happen", more or less) */
+ assert(opnd < 1);
+
+ /* deal with undersized strip */
+ if (p->slen >= p->ssize)
+ if (!enlarge(p, (p->ssize+1) / 2 * 3)) /* +50% */
+ return;
+
+ /* finally, it's all reduced to the easy case */
+ p->strip[p->slen] = op;
+ p->stripdata[p->slen] = opnd;
+ p->slen++;
+}
+
+/*
+ - doinsert - insert a sop into the strip
+ == static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos);
+ */
+static void
+doinsert(register struct parse *p, sop op, size_t opnd, sopno pos)
+{
+ register sopno sn;
+ register sop s;
+ register RCHAR_T d;
+ register int i;
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ sn = HERE();
+ EMIT(op, opnd); /* do checks, ensure space */
+ assert(HERE() == sn+1);
+ s = p->strip[sn];
+ d = p->stripdata[sn];
+
+ /* adjust paren pointers */
+ assert(pos > 0);
+ for (i = 1; i < NPAREN; i++) {
+ if (p->pbegin[i] >= pos) {
+ p->pbegin[i]++;
+ }
+ if (p->pend[i] >= pos) {
+ p->pend[i]++;
+ }
+ }
+
+ memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
+ (HERE()-pos-1)*sizeof(sop));
+ memmove((char *)&p->stripdata[pos+1], (char *)&p->stripdata[pos],
+ (HERE()-pos-1)*sizeof(RCHAR_T));
+ p->strip[pos] = s;
+ p->stripdata[pos] = d;
+}
+
+/*
+ - dofwd - complete a forward reference
+ == static void dofwd(register struct parse *p, sopno pos, sop value);
+ */
+static void
+dofwd(register struct parse *p, register sopno pos, sop value)
+{
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ assert(value < 1);
+ p->stripdata[pos] = value;
+}
+
+/*
+ - enlarge - enlarge the strip
+ == static int enlarge(register struct parse *p, sopno size);
+ */
+static int
+enlarge(register struct parse *p, register sopno size)
+{
+ register sop *sp;
+ register RCHAR_T *dp;
+ sopno osize;
+
+ if (p->ssize >= size)
+ return 1;
+
+ osize = p->ssize;
+ p->ssize = size;
+ if (MEMSIZE(p) > MEMLIMIT)
+ goto oomem;
+ sp = realloc(p->strip, p->ssize * sizeof(sop));
+ if (sp == NULL)
+ goto oomem;
+ p->strip = sp;
+ dp = realloc(p->stripdata, p->ssize * sizeof(RCHAR_T));
+ if (dp == NULL) {
+oomem:
+ p->ssize = osize;
+ SETERROR(REG_ESPACE);
+ return 0;
+ }
+ p->stripdata = dp;
+ return 1;
+}
+
+/*
+ - stripsnug - compact the strip
+ == static void stripsnug(register struct parse *p, register struct re_guts *g);
+ */
+static void
+stripsnug(register struct parse *p, register struct re_guts *g)
+{
+ g->nstates = p->slen;
+ g->strip = (sop *)realloc((char *)p->strip,
+ p->slen * sizeof(sop));
+ if (g->strip == NULL) {
+ SETERROR(REG_ESPACE);
+ g->strip = p->strip;
+ }
+ g->stripdata = (RCHAR_T *)realloc((char *)p->stripdata,
+ p->slen * sizeof(RCHAR_T));
+ if (g->stripdata == NULL) {
+ SETERROR(REG_ESPACE);
+ g->stripdata = p->stripdata;
+ }
+}
+
+/*
+ - findmust - fill in must and mlen with longest mandatory literal string
+ == static void findmust(register struct parse *p, register struct re_guts *g);
+ *
+ * This algorithm could do fancy things like analyzing the operands of |
+ * for common subsequences. Someday. This code is simple and finds most
+ * of the interesting cases.
+ *
+ * Note that must and mlen got initialized during setup.
+ */
+static void
+findmust(struct parse *p, register struct re_guts *g)
+{
+ register sop *scans;
+ register RCHAR_T *scand;
+ sop *starts = 0;
+ RCHAR_T *startd = NULL;
+ register sop *newstarts = 0;
+ register RCHAR_T *newstartd = NULL;
+ register sopno newlen;
+ register sop s;
+ register RCHAR_T d;
+ register RCHAR_T *cp;
+ register sopno i;
+
+ /* avoid making error situations worse */
+ if (p->error != 0)
+ return;
+
+ /* find the longest OCHAR sequence in strip */
+ newlen = 0;
+ scans = g->strip + 1;
+ scand = g->stripdata + 1;
+ do {
+ s = *scans++;
+ d = *scand++;
+ switch (s) {
+ case OCHAR: /* sequence member */
+ if (newlen == 0) { /* new sequence */
+ newstarts = scans - 1;
+ newstartd = scand - 1;
+ }
+ newlen++;
+ break;
+ case OPLUS_: /* things that don't break one */
+ case OLPAREN:
+ case ORPAREN:
+ break;
+ case OQUEST_: /* things that must be skipped */
+ case OCH_:
+ scans--;
+ scand--;
+ do {
+ scans += d;
+ scand += d;
+ s = *scans;
+ d = *scand;
+ /* assert() interferes w debug printouts */
+ if (s != O_QUEST && s != O_CH && s != OOR2) {
+ g->iflags |= BAD;
+ return;
+ }
+ } while (s != O_QUEST && s != O_CH);
+ /* fallthrough */
+ default: /* things that break a sequence */
+ if (newlen > g->mlen) { /* ends one */
+ starts = newstarts;
+ startd = newstartd;
+ g->mlen = newlen;
+ }
+ newlen = 0;
+ break;
+ }
+ } while (s != OEND);
+
+ if (g->mlen == 0) /* there isn't one */
+ return;
+
+ /* turn it into a character string */
+ g->must = malloc(((size_t)g->mlen + 1) * sizeof(RCHAR_T));
+ if (g->must == NULL) { /* argh; just forget it */
+ g->mlen = 0;
+ return;
+ }
+ cp = g->must;
+ scans = starts;
+ scand = startd;
+ for (i = g->mlen; i > 0; i--) {
+ for (;;) {
+ s = *scans++;
+ d = *scand++;
+ if (s == OCHAR)
+ break;
+ }
+ assert(cp < g->must + g->mlen);
+ *cp++ = d;
+ }
+ assert(cp == g->must + g->mlen);
+ *cp++ = '\0'; /* just on general principles */
+}
+
+/*
+ - pluscount - count + nesting
+ == static sopno pluscount(register struct parse *p, register struct re_guts *g);
+ */
+static sopno /* nesting depth */
+pluscount(struct parse *p, register struct re_guts *g)
+{
+ register sop *scan;
+ register sop s;
+ register sopno plusnest = 0;
+ register sopno maxnest = 0;
+
+ if (p->error != 0)
+ return(0); /* there may not be an OEND */
+
+ scan = g->strip + 1;
+ do {
+ s = *scan++;
+ switch (s) {
+ case OPLUS_:
+ plusnest++;
+ break;
+ case O_PLUS:
+ if (plusnest > maxnest)
+ maxnest = plusnest;
+ plusnest--;
+ break;
+ }
+ } while (s != OEND);
+ if (plusnest != 0)
+ g->iflags |= BAD;
+ return(maxnest);
+}
diff --git a/regex/regerror.c b/regex/regerror.c
new file mode 100644
index 000000000000..5ff1f6b67b21
--- /dev/null
+++ b/regex/regerror.c
@@ -0,0 +1,176 @@
+/* $NetBSD: regerror.c,v 1.2 2008/12/05 22:51:43 christos Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)regerror.c 8.3 (Berkeley) 3/19/94
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regerror.c 8.3 (Berkeley) 3/19/94";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <regex.h>
+
+#include "utils.h"
+
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* === regerror.c === */
+static char *regatoi __P((const regex_t *preg, char *localbuf));
+
+#ifdef __cplusplus
+}
+#endif
+/* ========= end header generated by ./mkh ========= */
+/*
+ = #define REG_NOMATCH 1
+ = #define REG_BADPAT 2
+ = #define REG_ECOLLATE 3
+ = #define REG_ECTYPE 4
+ = #define REG_EESCAPE 5
+ = #define REG_ESUBREG 6
+ = #define REG_EBRACK 7
+ = #define REG_EPAREN 8
+ = #define REG_EBRACE 9
+ = #define REG_BADBR 10
+ = #define REG_ERANGE 11
+ = #define REG_ESPACE 12
+ = #define REG_BADRPT 13
+ = #define REG_EMPTY 14
+ = #define REG_ASSERT 15
+ = #define REG_INVARG 16
+ = #define REG_ATOI 255 // convert name to number (!)
+ = #define REG_ITOA 0400 // convert number to name (!)
+ */
+static struct rerr {
+ int code;
+ const char *name;
+ const char *explain;
+} rerrs[] = {
+ { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" },
+ { REG_BADPAT, "REG_BADPAT", "invalid regular expression" },
+ { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" },
+ { REG_ECTYPE, "REG_ECTYPE", "invalid character class" },
+ { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" },
+ { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" },
+ { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" },
+ { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" },
+ { REG_EBRACE, "REG_EBRACE", "braces not balanced" },
+ { REG_BADBR, "REG_BADBR", "invalid repetition count(s)" },
+ { REG_ERANGE, "REG_ERANGE", "invalid character range" },
+ { REG_ESPACE, "REG_ESPACE", "out of memory" },
+ { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" },
+ { REG_EMPTY, "REG_EMPTY", "empty (sub)expression" },
+ { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" },
+ { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" },
+ { 0, "", "*** unknown regexp error code ***" },
+};
+
+/*
+ - regerror - the interface to error numbers
+ = extern size_t regerror(int, const regex_t *, char *, size_t);
+ */
+/* ARGSUSED */
+size_t
+regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
+{
+ register struct rerr *r;
+ register size_t len;
+ register int target = errcode &~ REG_ITOA;
+ register const char *s;
+ char convbuf[50];
+
+ if (errcode == REG_ATOI)
+ s = regatoi(preg, convbuf);
+ else {
+ for (r = rerrs; r->code != 0; r++)
+ if (r->code == target)
+ break;
+
+ if (errcode&REG_ITOA) {
+ if (r->code != 0) {
+ assert(strlen(r->name) < sizeof(convbuf));
+ (void) strlcpy(convbuf, r->name, sizeof(convbuf));
+ } else
+ (void) snprintf(convbuf, sizeof(convbuf),
+ "REG_0x%x", target);
+ s = convbuf;
+ } else
+ s = r->explain;
+ }
+
+ len = strlen(s) + 1;
+ if (errbuf_size > 0) {
+ (void) strlcpy(errbuf, s, errbuf_size);
+ }
+
+ return(len);
+}
+
+/*
+ - regatoi - internal routine to implement REG_ATOI
+ == static char *regatoi(const regex_t *preg, char *localbuf);
+ */
+static char *
+regatoi(const regex_t *preg, char *localbuf)
+{
+#if 0 /* we don't seem to use this and it gives a warning. */
+ register struct rerr *r;
+ register size_t siz;
+ register char *p;
+
+ for (r = rerrs; r->code != 0; r++)
+ if (strcmp(r->name, preg->re_endp) == 0)
+ break;
+ if (r->code == 0)
+ return("0");
+
+ sprintf(localbuf, "%d", r->code);
+#else
+ *localbuf = '\0';
+#endif
+ return(localbuf);
+}
diff --git a/regex/regex.3 b/regex/regex.3
new file mode 100644
index 000000000000..2c17254c1a16
--- /dev/null
+++ b/regex/regex.3
@@ -0,0 +1,540 @@
+.\" $NetBSD: regex.3,v 1.1.1.2 2008/05/18 14:31:38 aymeric Exp $
+.\"
+.\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
+.\" Copyright (c) 1992, 1993, 1994
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Henry Spencer of the University of Toronto.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)regex.3 8.2 (Berkeley) 3/16/94
+.\"
+.TH REGEX 3 "March 16, 1994"
+.de ZR
+.\" one other place knows this name: the SEE ALSO section
+.IR re_format (7) \\$1
+..
+.SH NAME
+regcomp, regexec, regerror, regfree \- regular-expression library
+.SH SYNOPSIS
+.ft B
+.\".na
+#include <sys/types.h>
+.br
+#include <regex.h>
+.HP 10
+int regcomp(regex_t\ *preg, const\ char\ *pattern, int\ cflags);
+.HP
+int\ regexec(const\ regex_t\ *preg, const\ char\ *string,
+size_t\ nmatch, regmatch_t\ pmatch[], int\ eflags);
+.HP
+size_t\ regerror(int\ errcode, const\ regex_t\ *preg,
+char\ *errbuf, size_t\ errbuf_size);
+.HP
+void\ regfree(regex_t\ *preg);
+.\".ad
+.ft
+.SH DESCRIPTION
+These routines implement POSIX 1003.2 regular expressions (``RE''s);
+see
+.ZR .
+.I Regcomp
+compiles an RE written as a string into an internal form,
+.I regexec
+matches that internal form against a string and reports results,
+.I regerror
+transforms error codes from either into human-readable messages,
+and
+.I regfree
+frees any dynamically-allocated storage used by the internal form
+of an RE.
+.PP
+The header
+.I <regex.h>
+declares two structure types,
+.I regex_t
+and
+.IR regmatch_t ,
+the former for compiled internal forms and the latter for match reporting.
+It also declares the four functions,
+a type
+.IR regoff_t ,
+and a number of constants with names starting with ``REG_''.
+.PP
+.I Regcomp
+compiles the regular expression contained in the
+.I pattern
+string,
+subject to the flags in
+.IR cflags ,
+and places the results in the
+.I regex_t
+structure pointed to by
+.IR preg .
+.I Cflags
+is the bitwise OR of zero or more of the following flags:
+.IP REG_EXTENDED \w'REG_EXTENDED'u+2n
+Compile modern (``extended'') REs,
+rather than the obsolete (``basic'') REs that
+are the default.
+.IP REG_BASIC
+This is a synonym for 0,
+provided as a counterpart to REG_EXTENDED to improve readability.
+.IP REG_NOSPEC
+Compile with recognition of all special characters turned off.
+All characters are thus considered ordinary,
+so the ``RE'' is a literal string.
+This is an extension,
+compatible with but not specified by POSIX 1003.2,
+and should be used with
+caution in software intended to be portable to other systems.
+REG_EXTENDED and REG_NOSPEC may not be used
+in the same call to
+.IR regcomp .
+.IP REG_ICASE
+Compile for matching that ignores upper/lower case distinctions.
+See
+.ZR .
+.IP REG_NOSUB
+Compile for matching that need only report success or failure,
+not what was matched.
+.IP REG_NEWLINE
+Compile for newline-sensitive matching.
+By default, newline is a completely ordinary character with no special
+meaning in either REs or strings.
+With this flag,
+`[^' bracket expressions and `.' never match newline,
+a `^' anchor matches the null string after any newline in the string
+in addition to its normal function,
+and the `$' anchor matches the null string before any newline in the
+string in addition to its normal function.
+.IP REG_PEND
+The regular expression ends,
+not at the first NUL,
+but just before the character pointed to by the
+.I re_endp
+member of the structure pointed to by
+.IR preg .
+The
+.I re_endp
+member is of type
+.IR const\ char\ * .
+This flag permits inclusion of NULs in the RE;
+they are considered ordinary characters.
+This is an extension,
+compatible with but not specified by POSIX 1003.2,
+and should be used with
+caution in software intended to be portable to other systems.
+.PP
+When successful,
+.I regcomp
+returns 0 and fills in the structure pointed to by
+.IR preg .
+One member of that structure
+(other than
+.IR re_endp )
+is publicized:
+.IR re_nsub ,
+of type
+.IR size_t ,
+contains the number of parenthesized subexpressions within the RE
+(except that the value of this member is undefined if the
+REG_NOSUB flag was used).
+If
+.I regcomp
+fails, it returns a non-zero error code;
+see DIAGNOSTICS.
+.PP
+.I Regexec
+matches the compiled RE pointed to by
+.I preg
+against the
+.IR string ,
+subject to the flags in
+.IR eflags ,
+and reports results using
+.IR nmatch ,
+.IR pmatch ,
+and the returned value.
+The RE must have been compiled by a previous invocation of
+.IR regcomp .
+The compiled form is not altered during execution of
+.IR regexec ,
+so a single compiled RE can be used simultaneously by multiple threads.
+.PP
+By default,
+the NUL-terminated string pointed to by
+.I string
+is considered to be the text of an entire line, minus any terminating
+newline.
+The
+.I eflags
+argument is the bitwise OR of zero or more of the following flags:
+.IP REG_NOTBOL \w'REG_STARTEND'u+2n
+The first character of
+the string
+is not the beginning of a line, so the `^' anchor should not match before it.
+This does not affect the behavior of newlines under REG_NEWLINE.
+.IP REG_NOTEOL
+The NUL terminating
+the string
+does not end a line, so the `$' anchor should not match before it.
+This does not affect the behavior of newlines under REG_NEWLINE.
+.IP REG_STARTEND
+The string is considered to start at
+\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_so\fR
+and to have a terminating NUL located at
+\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_eo\fR
+(there need not actually be a NUL at that location),
+regardless of the value of
+.IR nmatch .
+See below for the definition of
+.IR pmatch
+and
+.IR nmatch .
+This is an extension,
+compatible with but not specified by POSIX 1003.2,
+and should be used with
+caution in software intended to be portable to other systems.
+Note that a non-zero \fIrm_so\fR does not imply REG_NOTBOL;
+REG_STARTEND affects only the location of the string,
+not how it is matched.
+.PP
+See
+.ZR
+for a discussion of what is matched in situations where an RE or a
+portion thereof could match any of several substrings of
+.IR string .
+.PP
+Normally,
+.I regexec
+returns 0 for success and the non-zero code REG_NOMATCH for failure.
+Other non-zero error codes may be returned in exceptional situations;
+see DIAGNOSTICS.
+.PP
+If REG_NOSUB was specified in the compilation of the RE,
+or if
+.I nmatch
+is 0,
+.I regexec
+ignores the
+.I pmatch
+argument (but see below for the case where REG_STARTEND is specified).
+Otherwise,
+.I pmatch
+points to an array of
+.I nmatch
+structures of type
+.IR regmatch_t .
+Such a structure has at least the members
+.I rm_so
+and
+.IR rm_eo ,
+both of type
+.I regoff_t
+(a signed arithmetic type at least as large as an
+.I off_t
+and a
+.IR ssize_t ),
+containing respectively the offset of the first character of a substring
+and the offset of the first character after the end of the substring.
+Offsets are measured from the beginning of the
+.I string
+argument given to
+.IR regexec .
+An empty substring is denoted by equal offsets,
+both indicating the character following the empty substring.
+.PP
+The 0th member of the
+.I pmatch
+array is filled in to indicate what substring of
+.I string
+was matched by the entire RE.
+Remaining members report what substring was matched by parenthesized
+subexpressions within the RE;
+member
+.I i
+reports subexpression
+.IR i ,
+with subexpressions counted (starting at 1) by the order of their opening
+parentheses in the RE, left to right.
+Unused entries in the array\(emcorresponding either to subexpressions that
+did not participate in the match at all, or to subexpressions that do not
+exist in the RE (that is, \fIi\fR\ > \fIpreg\fR\->\fIre_nsub\fR)\(emhave both
+.I rm_so
+and
+.I rm_eo
+set to \-1.
+If a subexpression participated in the match several times,
+the reported substring is the last one it matched.
+(Note, as an example in particular, that when the RE `(b*)+' matches `bbb',
+the parenthesized subexpression matches each of the three `b's and then
+an infinite number of empty strings following the last `b',
+so the reported substring is one of the empties.)
+.PP
+If REG_STARTEND is specified,
+.I pmatch
+must point to at least one
+.I regmatch_t
+(even if
+.I nmatch
+is 0 or REG_NOSUB was specified),
+to hold the input offsets for REG_STARTEND.
+Use for output is still entirely controlled by
+.IR nmatch ;
+if
+.I nmatch
+is 0 or REG_NOSUB was specified,
+the value of
+.IR pmatch [0]
+will not be changed by a successful
+.IR regexec .
+.PP
+.I Regerror
+maps a non-zero
+.I errcode
+from either
+.I regcomp
+or
+.I regexec
+to a human-readable, printable message.
+If
+.I preg
+is non-NULL,
+the error code should have arisen from use of
+the
+.I regex_t
+pointed to by
+.IR preg ,
+and if the error code came from
+.IR regcomp ,
+it should have been the result from the most recent
+.I regcomp
+using that
+.IR regex_t .
+.RI ( Regerror
+may be able to supply a more detailed message using information
+from the
+.IR regex_t .)
+.I Regerror
+places the NUL-terminated message into the buffer pointed to by
+.IR errbuf ,
+limiting the length (including the NUL) to at most
+.I errbuf_size
+bytes.
+If the whole message won't fit,
+as much of it as will fit before the terminating NUL is supplied.
+In any case,
+the returned value is the size of buffer needed to hold the whole
+message (including terminating NUL).
+If
+.I errbuf_size
+is 0,
+.I errbuf
+is ignored but the return value is still correct.
+.PP
+If the
+.I errcode
+given to
+.I regerror
+is first ORed with REG_ITOA,
+the ``message'' that results is the printable name of the error code,
+e.g. ``REG_NOMATCH'',
+rather than an explanation thereof.
+If
+.I errcode
+is REG_ATOI,
+then
+.I preg
+shall be non-NULL and the
+.I re_endp
+member of the structure it points to
+must point to the printable name of an error code;
+in this case, the result in
+.I errbuf
+is the decimal digits of
+the numeric value of the error code
+(0 if the name is not recognized).
+REG_ITOA and REG_ATOI are intended primarily as debugging facilities;
+they are extensions,
+compatible with but not specified by POSIX 1003.2,
+and should be used with
+caution in software intended to be portable to other systems.
+Be warned also that they are considered experimental and changes are possible.
+.PP
+.I Regfree
+frees any dynamically-allocated storage associated with the compiled RE
+pointed to by
+.IR preg .
+The remaining
+.I regex_t
+is no longer a valid compiled RE
+and the effect of supplying it to
+.I regexec
+or
+.I regerror
+is undefined.
+.PP
+None of these functions references global variables except for tables
+of constants;
+all are safe for use from multiple threads if the arguments are safe.
+.SH IMPLEMENTATION CHOICES
+There are a number of decisions that 1003.2 leaves up to the implementor,
+either by explicitly saying ``undefined'' or by virtue of them being
+forbidden by the RE grammar.
+This implementation treats them as follows.
+.PP
+See
+.ZR
+for a discussion of the definition of case-independent matching.
+.PP
+There is no particular limit on the length of REs,
+except insofar as memory is limited.
+Memory usage is approximately linear in RE size, and largely insensitive
+to RE complexity, except for bounded repetitions.
+See BUGS for one short RE using them
+that will run almost any system out of memory.
+.PP
+A backslashed character other than one specifically given a magic meaning
+by 1003.2 (such magic meanings occur only in obsolete [``basic''] REs)
+is taken as an ordinary character.
+.PP
+Any unmatched [ is a REG_EBRACK error.
+.PP
+Equivalence classes cannot begin or end bracket-expression ranges.
+The endpoint of one range cannot begin another.
+.PP
+RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255.
+.PP
+A repetition operator (?, *, +, or bounds) cannot follow another
+repetition operator.
+A repetition operator cannot begin an expression or subexpression
+or follow `^' or `|'.
+.PP
+`|' cannot appear first or last in a (sub)expression or after another `|',
+i.e. an operand of `|' cannot be an empty subexpression.
+An empty parenthesized subexpression, `()', is legal and matches an
+empty (sub)string.
+An empty string is not a legal RE.
+.PP
+A `{' followed by a digit is considered the beginning of bounds for a
+bounded repetition, which must then follow the syntax for bounds.
+A `{' \fInot\fR followed by a digit is considered an ordinary character.
+.PP
+`^' and `$' beginning and ending subexpressions in obsolete (``basic'')
+REs are anchors, not ordinary characters.
+.SH SEE ALSO
+grep(1), re_format(7)
+.PP
+POSIX 1003.2, sections 2.8 (Regular Expression Notation)
+and
+B.5 (C Binding for Regular Expression Matching).
+.SH DIAGNOSTICS
+Non-zero error codes from
+.I regcomp
+and
+.I regexec
+include the following:
+.PP
+.nf
+.ta \w'REG_ECOLLATE'u+3n
+REG_NOMATCH regexec() failed to match
+REG_BADPAT invalid regular expression
+REG_ECOLLATE invalid collating element
+REG_ECTYPE invalid character class
+REG_EESCAPE \e applied to unescapable character
+REG_ESUBREG invalid backreference number
+REG_EBRACK brackets [ ] not balanced
+REG_EPAREN parentheses ( ) not balanced
+REG_EBRACE braces { } not balanced
+REG_BADBR invalid repetition count(s) in { }
+REG_ERANGE invalid character range in [ ]
+REG_ESPACE ran out of memory
+REG_BADRPT ?, *, or + operand invalid
+REG_EMPTY empty (sub)expression
+REG_ASSERT ``can't happen''\(emyou found a bug
+REG_INVARG invalid argument, e.g. negative-length string
+.fi
+.SH HISTORY
+Originally written by Henry Spencer at University of Toronto.
+Altered for inclusion in the 4.4BSD distribution.
+.SH BUGS
+This is an alpha release with known defects.
+Please report problems.
+.PP
+There is one known functionality bug.
+The implementation of internationalization is incomplete:
+the locale is always assumed to be the default one of 1003.2,
+and only the collating elements etc. of that locale are available.
+.PP
+The back-reference code is subtle and doubts linger about its correctness
+in complex cases.
+.PP
+.I Regexec
+performance is poor.
+This will improve with later releases.
+.I Nmatch
+exceeding 0 is expensive;
+.I nmatch
+exceeding 1 is worse.
+.I Regexec
+is largely insensitive to RE complexity \fIexcept\fR that back
+references are massively expensive.
+RE length does matter; in particular, there is a strong speed bonus
+for keeping RE length under about 30 characters,
+with most special characters counting roughly double.
+.PP
+.I Regcomp
+implements bounded repetitions by macro expansion,
+which is costly in time and space if counts are large
+or bounded repetitions are nested.
+An RE like, say,
+`((((a{1,100}){1,100}){1,100}){1,100}){1,100}'
+will (eventually) run almost any existing machine out of swap space.
+.PP
+There are suspected problems with response to obscure error conditions.
+Notably,
+certain kinds of internal overflow,
+produced only by truly enormous REs or by multiply nested bounded repetitions,
+are probably not handled well.
+.PP
+Due to a mistake in 1003.2, things like `a)b' are legal REs because `)' is
+a special character only in the presence of a previous unmatched `('.
+This can't be fixed until the spec is fixed.
+.PP
+The standard's definition of back references is vague.
+For example, does
+`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?
+Until the standard is clarified,
+behavior in such cases should not be relied on.
+.PP
+The implementation of word-boundary matching is a bit of a kludge,
+and bugs may lurk in combinations of word-boundary matching and anchoring.
diff --git a/regex/regex.h b/regex/regex.h
new file mode 100644
index 000000000000..cabd66b0528a
--- /dev/null
+++ b/regex/regex.h
@@ -0,0 +1,109 @@
+/* $NetBSD: regex.h,v 1.1.1.2 2008/05/18 14:31:38 aymeric Exp $ */
+
+/*-
+ * Copyright (c) 1992 Henry Spencer.
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)regex.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _REGEX_H_
+#define _REGEX_H_
+
+#ifdef __REGEX_PRIVATE
+#include "config.h"
+#include "../common/multibyte.h"
+#endif
+
+/* types */
+typedef off_t regoff_t;
+
+typedef struct {
+ int re_magic;
+ size_t re_nsub; /* number of parenthesized subexpressions */
+ const RCHAR_T *re_endp; /* end pointer for REG_PEND */
+ struct re_guts *re_g; /* none of your business :-) */
+} regex_t;
+
+typedef struct {
+ regoff_t rm_so; /* start of match */
+ regoff_t rm_eo; /* end of match */
+} regmatch_t;
+
+/* regcomp() flags */
+#define REG_BASIC 0000
+#define REG_EXTENDED 0001
+#define REG_ICASE 0002
+#define REG_NOSUB 0004
+#define REG_NEWLINE 0010
+#define REG_NOSPEC 0020
+#define REG_PEND 0040
+#define REG_DUMP 0200
+
+/* regerror() flags */
+#define REG_NOMATCH 1
+#define REG_BADPAT 2
+#define REG_ECOLLATE 3
+#define REG_ECTYPE 4
+#define REG_EESCAPE 5
+#define REG_ESUBREG 6
+#define REG_EBRACK 7
+#define REG_EPAREN 8
+#define REG_EBRACE 9
+#define REG_BADBR 10
+#define REG_ERANGE 11
+#define REG_ESPACE 12
+#define REG_BADRPT 13
+#define REG_EMPTY 14
+#define REG_ASSERT 15
+#define REG_INVARG 16
+#define REG_ATOI 255 /* convert name to number (!) */
+#define REG_ITOA 0400 /* convert number to name (!) */
+
+/* regexec() flags */
+#define REG_NOTBOL 00001
+#define REG_NOTEOL 00002
+#define REG_STARTEND 00004
+#define REG_TRACE 00400 /* tracing of execution */
+#define REG_LARGE 01000 /* force large representation */
+#define REG_BACKR 02000 /* force use of backref code */
+
+int regcomp __P((regex_t *, const RCHAR_T *, int));
+size_t regerror __P((int, const regex_t *, char *, size_t));
+int regexec __P((const regex_t *,
+ const RCHAR_T *, size_t, regmatch_t [], int));
+void regfree __P((regex_t *));
+
+#endif /* !_REGEX_H_ */
diff --git a/regex/regex2.h b/regex/regex2.h
new file mode 100644
index 000000000000..7c9352831c28
--- /dev/null
+++ b/regex/regex2.h
@@ -0,0 +1,174 @@
+/* $NetBSD: regex2.h,v 1.5 2011/11/23 15:43:39 tnozaki Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)regex2.h 8.3 (Berkeley) 3/16/94
+ */
+
+/*
+ * First, the stuff that ends up in the outside-world include file
+ = typedef off_t regoff_t;
+ = typedef struct {
+ = int re_magic;
+ = size_t re_nsub; // number of parenthesized subexpressions
+ = const char *re_endp; // end pointer for REG_PEND
+ = struct re_guts *re_g; // none of your business :-)
+ = } regex_t;
+ = typedef struct {
+ = regoff_t rm_so; // start of match
+ = regoff_t rm_eo; // end of match
+ = } regmatch_t;
+ */
+/*
+ * internals of regex_t
+ */
+#define MAGIC1 ((('r'^0200)<<8) | 'e')
+
+/*
+ * The internal representation is a *strip*, a sequence of
+ * operators ending with an endmarker. (Some terminology etc. is a
+ * historical relic of earlier versions which used multiple strips.)
+ * Certain oddities in the representation are there to permit running
+ * the machinery backwards; in particular, any deviation from sequential
+ * flow must be marked at both its source and its destination. Some
+ * fine points:
+ *
+ * - OPLUS_ and O_PLUS are *inside* the loop they create.
+ * - OQUEST_ and O_QUEST are *outside* the bypass they create.
+ * - OCH_ and O_CH are *outside* the multi-way branch they create, while
+ * OOR1 and OOR2 are respectively the end and the beginning of one of
+ * the branches. Note that there is an implicit OOR2 following OCH_
+ * and an implicit OOR1 preceding O_CH.
+ *
+ * In state representations, an operator's bit is on to signify a state
+ * immediately *preceding* "execution" of that operator.
+ */
+typedef char sop; /* strip operator */
+typedef size_t sopno;
+/* operators meaning operand */
+/* (back, fwd are offsets) */
+#define OEND (1) /* endmarker - */
+#define OCHAR (2) /* character unsigned char */
+#define OBOL (3) /* left anchor - */
+#define OEOL (4) /* right anchor - */
+#define OANY (5) /* . - */
+#define OANYOF (6) /* [...] set number */
+#define OBACK_ (7) /* begin \d paren number */
+#define O_BACK (8) /* end \d paren number */
+#define OPLUS_ (9) /* + prefix fwd to suffix */
+#define O_PLUS (10) /* + suffix back to prefix */
+#define OQUEST_ (11) /* ? prefix fwd to suffix */
+#define O_QUEST (12) /* ? suffix back to prefix */
+#define OLPAREN (13) /* ( fwd to ) */
+#define ORPAREN (14) /* ) back to ( */
+#define OCH_ (15) /* begin choice fwd to OOR2 */
+#define OOR1 (16) /* | pt. 1 back to OOR1 or OCH_ */
+#define OOR2 (17) /* | pt. 2 fwd to OOR2 or O_CH */
+#define O_CH (18) /* end choice back to OOR1 */
+#define OBOW (19) /* begin word - */
+#define OEOW (20) /* end word - */
+
+/*
+ * Structure for [] character-set representation. Character sets are
+ * done as bit vectors, grouped 8 to a byte vector for compactness.
+ * The individual set therefore has both a pointer to the byte vector
+ * and a mask to pick out the relevant bit of each byte. A hash code
+ * simplifies testing whether two sets could be identical.
+ *
+ * This will get trickier for multicharacter collating elements. As
+ * preliminary hooks for dealing with such things, we also carry along
+ * a string of multi-character elements, and decide the size of the
+ * vectors at run time.
+ */
+typedef struct {
+ uch *ptr; /* -> uch [csetsize] */
+ uch mask; /* bit within array */
+ uch hash; /* hash code */
+ size_t smultis;
+ char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
+} cset;
+/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
+#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
+#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
+#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
+#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
+#define MCsub(p, cs, cp) mcsub(p, cs, cp)
+#define MCin(p, cs, cp) mcin(p, cs, cp)
+
+/* stuff for character categories */
+typedef RCHAR_T cat_t;
+
+/*
+ * main compiled-expression structure
+ */
+struct re_guts {
+ int magic;
+# define MAGIC2 ((('R'^0200)<<8)|'E')
+ sop *strip; /* malloced area for strip */
+ RCHAR_T *stripdata; /* malloced area for stripdata */
+ size_t csetsize; /* number of bits in a cset vector */
+ size_t ncsets; /* number of csets in use */
+ cset *sets; /* -> cset [ncsets] */
+ uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */
+ int cflags; /* copy of regcomp() cflags argument */
+ sopno nstates; /* = number of sops */
+ sopno firststate; /* the initial OEND (normally 0) */
+ sopno laststate; /* the final OEND */
+ int iflags; /* internal flags */
+# define USEBOL 01 /* used ^ */
+# define USEEOL 02 /* used $ */
+# define BAD 04 /* something wrong */
+ size_t nbol; /* number of ^ used */
+ size_t neol; /* number of $ used */
+#if 0
+ size_t ncategories; /* how many character categories */
+ cat_t *categories; /* ->catspace[-CHAR_MIN] */
+#endif
+ RCHAR_T *must; /* match must contain this string */
+ size_t mlen; /* length of must */
+ size_t nsub; /* copy of re_nsub */
+ int backrefs; /* does it use back references? */
+ sopno nplus; /* how deep does it nest +s? */
+ /* catspace must be last */
+#if 0
+ cat_t catspace[1]; /* actually [NC] */
+#endif
+};
+
+/* misc utilities */
+#define OUT REOF /* a non-character value */
+#define ISWORD(c) ((c) == '_' || (ISGRAPH((UCHAR_T)c) && !ISPUNCT((UCHAR_T)c)))
diff --git a/regex/regexec.c b/regex/regexec.c
new file mode 100644
index 000000000000..89ab2ca9786d
--- /dev/null
+++ b/regex/regexec.c
@@ -0,0 +1,180 @@
+/* $NetBSD: regexec.c,v 1.4 2009/10/31 20:11:53 dsl Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)regexec.c 8.2 (Berkeley) 3/16/94
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regexec.c 8.2 (Berkeley) 3/16/94";
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * the outer shell of regexec()
+ *
+ * This file includes engine.c *twice*, after muchos fiddling with the
+ * macros that code uses. This lets the same code operate on two different
+ * representations for state sets.
+ */
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <ctype.h>
+#include <regex.h>
+
+#include "utils.h"
+#include "regex2.h"
+
+#ifdef notdef
+static int nope = 0; /* for use in asserts; shuts lint up */
+#endif
+
+/* macros for manipulating states, small version */
+#define states int
+#define states1 int /* for later use in regexec() decision */
+#define CLEAR(v) ((v) = 0)
+#define SET0(v, n) ((v) &= ~(1 << (n)))
+#define SET1(v, n) ((v) |= 1 << (n))
+#define ISSET(v, n) ((v) & (1 << (n)))
+#define ASSIGN(d, s) ((d) = (s))
+#define EQ(a, b) ((a) == (b))
+#define STATEVARS int dummy /* dummy version */
+#define STATESETUP(m, n) /* nothing */
+#define STATETEARDOWN(m) /* nothing */
+#define SETUP(v) ((v) = 0)
+#define onestate int
+#define INIT(o, n) ((o) = (unsigned)1 << (n))
+#define INC(o) ((o) <<= 1)
+#define ISSTATEIN(v, o) ((v) & (o))
+/* some abbreviations; note that some of these know variable names! */
+/* do "if I'm here, I can also be there" etc without branches */
+#define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n))
+#define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n))
+#define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n)))
+/* function names */
+#define SNAMES /* engine.c looks after details */
+
+#include "engine.c"
+
+/* now undo things */
+#undef states
+#undef CLEAR
+#undef SET0
+#undef SET1
+#undef ISSET
+#undef ASSIGN
+#undef EQ
+#undef STATEVARS
+#undef STATESETUP
+#undef STATETEARDOWN
+#undef SETUP
+#undef onestate
+#undef INIT
+#undef INC
+#undef ISSTATEIN
+#undef FWD
+#undef BACK
+#undef ISSETBACK
+#undef SNAMES
+
+/* macros for manipulating states, large version */
+#define states char *
+#define CLEAR(v) memset(v, 0, m->g->nstates)
+#define SET0(v, n) ((v)[n] = 0)
+#define SET1(v, n) ((v)[n] = 1)
+#define ISSET(v, n) ((v)[n])
+#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
+#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
+#define STATEVARS int vn; char *space
+#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
+ if ((m)->space == NULL) return(REG_ESPACE); \
+ (m)->vn = 0; }
+#define STATETEARDOWN(m) { free((m)->space); }
+#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
+#define onestate int
+#define INIT(o, n) ((o) = (n))
+#define INC(o) ((o)++)
+#define ISSTATEIN(v, o) ((v)[o])
+/* some abbreviations; note that some of these know variable names! */
+/* do "if I'm here, I can also be there" etc without branches */
+#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
+#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
+#define ISSETBACK(v, n) ((v)[here - (n)])
+/* function names */
+#define LNAMES /* flag */
+
+#include "engine.c"
+
+/*
+ - regexec - interface for matching
+ = extern int regexec(const regex_t *, const char *, size_t, \
+ = regmatch_t [], int);
+ = #define REG_NOTBOL 00001
+ = #define REG_NOTEOL 00002
+ = #define REG_STARTEND 00004
+ = #define REG_TRACE 00400 // tracing of execution
+ = #define REG_LARGE 01000 // force large representation
+ = #define REG_BACKR 02000 // force use of backref code
+ *
+ * We put this here so we can exploit knowledge of the state representation
+ * when choosing which matcher to call. Also, by this point the matchers
+ * have been prototyped.
+ */
+int /* 0 success, REG_NOMATCH failure */
+regexec(const regex_t *preg, const RCHAR_T *string, size_t nmatch, regmatch_t *pmatch, int eflags)
+{
+ register struct re_guts *g = preg->re_g;
+#ifdef REDEBUG
+# define GOODFLAGS(f) (f)
+#else
+# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
+#endif
+
+ if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
+ return(REG_BADPAT);
+ assert(!(g->iflags&BAD));
+ if (g->iflags&BAD) /* backstop for no-debug case */
+ return(REG_BADPAT);
+ eflags = GOODFLAGS(eflags);
+
+ if (g->nstates <= (int)(CHAR_BIT*sizeof(states1)) && !(eflags&REG_LARGE))
+ return(smatcher(g, string, nmatch, pmatch, eflags));
+ else
+ return(lmatcher(g, string, nmatch, pmatch, eflags));
+}
diff --git a/clib/strdup.c b/regex/regfree.c
index 4bc2303cee54..61df17cb6664 100644
--- a/clib/strdup.c
+++ b/regex/regfree.c
@@ -1,7 +1,13 @@
-/*
- * Copyright (c) 1988, 1993
+/* $NetBSD: regfree.c,v 1.2 2009/01/02 00:32:11 tnozaki Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
+ * This code is derived from software contributed to Berkeley by
+ * Henry Spencer of the University of Toronto.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -29,35 +35,49 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * @(#)regfree.c 8.2 (Berkeley) 3/16/94
*/
-#include "config.h"
-
#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)regfree.c 8.2 (Berkeley) 3/16/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
-
-#include <stddef.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
+#include <regex.h>
+
+#include "utils.h"
+#include "regex2.h"
/*
- * PUBLIC: #ifndef HAVE_STRDUP
- * PUBLIC: char *strdup __P((const char *));
- * PUBLIC: #endif
+ - regfree - free everything
+ = extern void regfree(regex_t *);
*/
-char *
-strdup(str)
- const char *str;
+void
+regfree(regex_t *preg)
{
- size_t len;
- char *copy;
-
- len = strlen(str) + 1;
- if (!(copy = malloc((u_int)len)))
- return (NULL);
- memcpy(copy, str, len);
- return (copy);
+ register struct re_guts *g;
+
+ if (preg->re_magic != MAGIC1) /* oops */
+ return; /* nice to complain, but hard */
+
+ g = preg->re_g;
+ if (g == NULL || g->magic != MAGIC2) /* oops again */
+ return;
+ preg->re_magic = 0; /* mark it invalid */
+ g->magic = 0; /* mark it invalid */
+
+ if (g->strip != NULL)
+ free((char *)g->strip);
+ if (g->stripdata != NULL)
+ free((char *)g->stripdata);
+ if (g->sets != NULL)
+ free((char *)g->sets);
+ if (g->setbits != NULL)
+ free((char *)g->setbits);
+ if (g->must != NULL)
+ free(g->must);
+ free((char *)g);
}
diff --git a/clib/memchr.c b/regex/utils.h
index b6d4c311bff6..4a6f57a3fe6c 100644
--- a/clib/memchr.c
+++ b/regex/utils.h
@@ -1,9 +1,12 @@
+/* $NetBSD: utils.h,v 1.1.1.2 2008/05/18 14:31:39 aymeric Exp $ */
+
/*-
- * Copyright (c) 1990, 1993
+ * Copyright (c) 1992, 1993, 1994 Henry Spencer.
+ * Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
- * Chris Torek.
+ * Henry Spencer of the University of Toronto.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,34 +35,25 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * @(#)utils.h 8.2 (Berkeley) 3/16/94
*/
-#include "config.h"
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)memchr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
+/* utility definitions */
+#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
+#define INFINITY (DUPMAX + 1)
+#define NC (CHAR_MAX - CHAR_MIN + 1)
+typedef unsigned char uch;
-#include <string.h>
-
-/*
- * PUBLIC: #ifndef HAVE_MEMCHR
- * PUBLIC: void *memchr __P((const void *, int, size_t));
- * PUBLIC: #endif
- */
-void *
-memchr(s, c, n)
- const void *s;
- register unsigned char c;
- register size_t n;
-{
- if (n != 0) {
- register const unsigned char *p = s;
+/* switch off assertions (if not already off) if no REDEBUG */
+#ifndef REDEBUG
+#ifndef NDEBUG
+#define NDEBUG /* no assertions please */
+#endif
+#endif
+#include <assert.h>
- do {
- if (*p++ == c)
- return ((void *)(p - 1));
- } while (--n != 0);
- }
- return (NULL);
-}
+/* for old systems with bcopy() but no memmove() */
+#ifdef USEBCOPY
+#define memmove(d, s, c) bcopy(s, d, c)
+#endif
diff --git a/tcl_api/tcl.c b/tcl_api/tcl.c
deleted file mode 100644
index 8f4a430bac4c..000000000000
--- a/tcl_api/tcl.c
+++ /dev/null
@@ -1,852 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1992, 1993, 1994, 1995
- * Keith Bostic. All rights reserved.
- * Copyright (c) 1995
- * George V. Neville-Neil. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)tcl.c 8.16 (Berkeley) 10/16/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <errno.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <tcl.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "tcl_extern.h"
-
-static int getint __P((Tcl_Interp *, char *, char *, int *));
-static int getscreenid __P((Tcl_Interp *, SCR **, char *, char *));
-static void msghandler __P((SCR *, mtype_t, char *, size_t));
-
-extern GS *__global_list; /* XXX */
-
-/*
- * INITMESSAGE --
- * Macros to point messages at the Tcl message handler.
- */
-#define INITMESSAGE \
- scr_msg = __global_list->scr_msg; \
- __global_list->scr_msg = msghandler;
-#define ENDMESSAGE \
- __global_list->scr_msg = scr_msg;
-
-/*
- * tcl_fscreen --
- * Return the screen id associated with file name.
- *
- * Tcl Command: viFindScreen
- * Usage: viFindScreen file
- */
-static int
-tcl_fscreen(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
-
- if (argc != 2) {
- Tcl_SetResult(interp, "Usage: viFindScreen file", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, NULL, argv[1]))
- return (TCL_ERROR);
-
- (void)sprintf(interp->result, "%d", sp->id);
- return (TCL_OK);
-}
-
-/*
- * tcl_aline --
- * -- Append the string text after the line in lineNumber.
- *
- * Tcl Command: viAppendLine
- * Usage: viAppendLine screenId lineNumber text
- */
-static int
-tcl_aline(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int lno, rval;
-
- if (argc != 4) {
- Tcl_SetResult(interp,
- "Usage: viAppendLine screenId lineNumber text", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL) ||
- getint(interp, "line number", argv[2], &lno))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_aline(sp, (recno_t)lno, argv[3], strlen(argv[3]));
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_dline --
- * Delete lineNum.
- *
- * Tcl Command: viDelLine
- * Usage: viDelLine screenId lineNum
- */
-static int
-tcl_dline(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int lno, rval;
-
- if (argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viDelLine screenId lineNumber", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL) ||
- getint(interp, "line number", argv[2], &lno))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_dline(sp, (recno_t)lno);
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_gline --
- * Return lineNumber.
- *
- * Tcl Command: viGetLine
- * Usage: viGetLine screenId lineNumber
- */
-static int
-tcl_gline(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- size_t len;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int lno, rval;
- char *line, *p;
-
- if (argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viGetLine screenId lineNumber", TCL_STATIC);
- return (TCL_ERROR);
- }
- if (getscreenid(interp, &sp, argv[1], NULL) ||
- getint(interp, "line number", argv[2], &lno))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_gline(sp, (recno_t)lno, &p, &len);
- ENDMESSAGE;
-
- if (rval)
- return (TCL_ERROR);
-
- if ((line = malloc(len + 1)) == NULL)
- exit(1); /* XXX */
- memmove(line, p, len);
- line[len] = '\0';
- Tcl_SetResult(interp, line, TCL_DYNAMIC);
- return (TCL_OK);
-}
-
-/*
- * tcl_iline --
- * Insert the string text after the line in lineNumber.
- *
- * Tcl Command: viInsertLine
- * Usage: viInsertLine screenId lineNumber text
- */
-static int
-tcl_iline(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int lno, rval;
-
- if (argc != 4) {
- Tcl_SetResult(interp,
- "Usage: viInsertLine screenId lineNumber text", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL) ||
- getint(interp, "line number", argv[2], &lno))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_iline(sp, (recno_t)lno, argv[3], strlen(argv[3]));
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_lline --
- * Return the last line in the screen.
- *
- * Tcl Command: viLastLine
- * Usage: viLastLine screenId
- */
-static int
-tcl_lline(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- recno_t last;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- if (argc != 2) {
- Tcl_SetResult(interp, "Usage: viLastLine screenId", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_lline(sp, &last);
- ENDMESSAGE;
- if (rval)
- return (TCL_ERROR);
-
- (void)sprintf(interp->result, "%lu", (unsigned long)last);
- return (TCL_OK);
-}
-
-/*
- * tcl_sline --
- * Set lineNumber to the text supplied.
- *
- * Tcl Command: viSetLine
- * Usage: viSetLine screenId lineNumber text
- */
-static int
-tcl_sline(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int lno, rval;
-
- if (argc != 4) {
- Tcl_SetResult(interp,
- "Usage: viSetLine screenId lineNumber text", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL) ||
- getint(interp, "line number", argv[2], &lno))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_sline(sp, (recno_t)lno, argv[3], strlen(argv[3]));
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_getmark --
- * Return the mark's cursor position as a list with two elements.
- * {line, column}.
- *
- * Tcl Command: viGetMark
- * Usage: viGetMark screenId mark
- */
-static int
-tcl_getmark(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- MARK cursor;
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char buf[20];
-
- if (argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viGetMark screenId mark", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_getmark(sp, (int)argv[2][0], &cursor);
- ENDMESSAGE;
-
- if (rval)
- return (TCL_ERROR);
-
- (void)snprintf(buf, sizeof(buf), "%lu", (u_long)cursor.lno);
- Tcl_AppendElement(interp, buf);
- (void)snprintf(buf, sizeof(buf), "%lu", (u_long)cursor.cno);
- Tcl_AppendElement(interp, buf);
- return (TCL_OK);
-}
-
-/*
- * tcl_setmark --
- * Set the mark to the line and column numbers supplied.
- *
- * Tcl Command: viSetMark
- * Usage: viSetMark screenId mark line column
- */
-static int
-tcl_setmark(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- MARK cursor;
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int i, rval;
-
- if (argc != 5) {
- Tcl_SetResult(interp,
- "Usage: viSetMark screenId mark line column", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- if (getint(interp, "line number", argv[3], &i))
- return (TCL_ERROR);
- cursor.lno = i;
- if (getint(interp, "column number", argv[4], &i))
- return (TCL_ERROR);
- cursor.cno = i;
- INITMESSAGE;
- rval = api_setmark(sp, (int)argv[2][0], &cursor);
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_getcursor --
- * Return the current cursor position as a list with two elements.
- * {line, column}.
- *
- * Tcl Command: viGetCursor
- * Usage: viGetCursor screenId
- */
-static int
-tcl_getcursor(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- MARK cursor;
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char buf[20];
-
- if (argc != 2) {
- Tcl_SetResult(interp,
- "Usage: viGetCursor screenId", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_getcursor(sp, &cursor);
- ENDMESSAGE;
-
- if (rval)
- return (TCL_ERROR);
-
- (void)snprintf(buf, sizeof(buf), "%lu", (u_long)cursor.lno);
- Tcl_AppendElement(interp, buf);
- (void)snprintf(buf, sizeof(buf), "%lu", (u_long)cursor.cno);
- Tcl_AppendElement(interp, buf);
- return (TCL_OK);
-}
-
-/*
- * tcl_setcursor --
- * Set the cursor to the line and column numbers supplied.
- *
- * Tcl Command: viSetCursor
- * Usage: viSetCursor screenId line column
- */
-static int
-tcl_setcursor(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- MARK cursor;
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int i, rval;
-
- if (argc != 4) {
- Tcl_SetResult(interp,
- "Usage: viSetCursor screenId line column", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- if (getint(interp, "screen id", argv[2], &i))
- return (TCL_ERROR);
- cursor.lno = i;
- if (getint(interp, "screen id", argv[3], &i))
- return (TCL_ERROR);
- cursor.cno = i;
- INITMESSAGE;
- rval = api_setcursor(sp, &cursor);
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_msg --
- * Set the message line to text.
- *
- * Tcl Command: viMsg
- * Usage: viMsg screenId text
- */
-static int
-tcl_msg(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
-
- if (argc != 3) {
- Tcl_SetResult(interp, "Usage: viMsg screenId text", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- api_imessage(sp, argv[2]);
-
- return (TCL_OK);
-}
-
-/*
- * tcl_iscreen --
- * Create a new screen. If a filename is specified then the screen
- * is opened with that file.
- *
- * Tcl Command: viNewScreen
- * Usage: viNewScreen screenId [file]
- */
-static int
-tcl_iscreen(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp, *nsp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- if (argc != 2 && argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viNewScreen screenId [file]", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_edit(sp, argv[2], &nsp, 1);
- ENDMESSAGE;
-
- if (rval)
- return (TCL_ERROR);
-
- (void)sprintf(interp->result, "%d", nsp->id);
- return (TCL_OK);
-}
-
-/*
- * tcl_escreen --
- * End a screen.
- *
- * Tcl Command: viEndScreen
- * Usage: viEndScreen screenId
- */
-static int
-tcl_escreen(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- if (argc != 2) {
- Tcl_SetResult(interp,
- "Usage: viEndScreen screenId", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_escreen(sp);
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_swscreen --
- * Change the current focus to screen.
- *
- * Tcl Command: viSwitchScreen
- * Usage: viSwitchScreen screenId screenId
- */
-static int
-tcl_swscreen(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp, *new;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- if (argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viSwitchScreen cur_screenId new_screenId",
- TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- if (getscreenid(interp, &new, argv[2], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_swscreen(sp, new);
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_map --
- * Associate a key with a tcl procedure.
- *
- * Tcl Command: viMapKey
- * Usage: viMapKey screenId key tclproc
- */
-static int
-tcl_map(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char command[256];
-
- if (argc != 4) {
- Tcl_SetResult(interp,
- "Usage: viMapKey screenId key tclproc", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- (void)snprintf(command, sizeof(command), ":tcl %s\n", argv[3]);
- rval = api_map(sp, argv[2], command, strlen(command));
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_unmap --
- * Unmap a key.
- *
- * Tcl Command: viUnmapKey
- * Usage: viUnmMapKey screenId key
- */
-static int
-tcl_unmap(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
-
- if (argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viUnmapKey screenId key", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_unmap(sp, argv[2]);
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_opts_set --
- * Set an option.
- *
- * Tcl Command: viSetOpt
- * Usage: viSetOpt screenId command
- */
-static int
-tcl_opts_set(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char *setting;
-
- if (argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viSetOpt screenId command", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- /*rval = api_opts_set(sp, argv[2]);*/
- MALLOC(sp, setting, char *, strlen(argv[2])+6);
- strcpy(setting, ":set ");
- strcpy(setting+5, argv[2]);
- rval=api_run_str(sp, setting);
- free(setting);
- ENDMESSAGE;
-
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tcl_opts_get --
- Return the value of an option.
- *
- * Tcl Command: viGetOpt
- * Usage: viGetOpt screenId option
- */
-static int
-tcl_opts_get(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
- SCR *sp;
- void (*scr_msg) __P((SCR *, mtype_t, char *, size_t));
- int rval;
- char *value;
-
- if (argc != 3) {
- Tcl_SetResult(interp,
- "Usage: viGetOpt screenId option", TCL_STATIC);
- return (TCL_ERROR);
- }
-
- if (getscreenid(interp, &sp, argv[1], NULL))
- return (TCL_ERROR);
- INITMESSAGE;
- rval = api_opts_get(sp, argv[2], &value, NULL);
- ENDMESSAGE;
- if (rval)
- return (TCL_ERROR);
-
- Tcl_SetResult(interp, value, TCL_DYNAMIC);
- return (TCL_OK);
-}
-
-/*
- * tcl_init --
- * Create the TCL commands used by nvi.
- *
- * PUBLIC: int tcl_init __P((GS *));
- */
-int
-tcl_init(gp)
- GS *gp;
-{
- gp->tcl_interp = Tcl_CreateInterp();
- if (Tcl_Init(gp->tcl_interp) == TCL_ERROR)
- return (1);
-
-#define TCC(name, function) { \
- Tcl_CreateCommand(gp->tcl_interp, name, function, \
- (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); \
-}
- TCC("viAppendLine", tcl_aline);
- TCC("viDelLine", tcl_dline);
- TCC("viEndScreen", tcl_escreen);
- TCC("viFindScreen", tcl_fscreen);
- TCC("viGetCursor", tcl_getcursor);
- TCC("viGetLine", tcl_gline);
- TCC("viGetMark", tcl_getmark);
- TCC("viGetOpt", tcl_opts_get);
- TCC("viInsertLine", tcl_iline);
- TCC("viLastLine", tcl_lline);
- TCC("viMapKey", tcl_map);
- TCC("viMsg", tcl_msg);
- TCC("viNewScreen", tcl_iscreen);
- TCC("viSetCursor", tcl_setcursor);
- TCC("viSetLine", tcl_sline);
- TCC("viSetMark", tcl_setmark);
- TCC("viSetOpt", tcl_opts_set);
- TCC("viSwitchScreen", tcl_swscreen);
- TCC("viUnmapKey", tcl_unmap);
-
- return (0);
-}
-
-/*
- * getscreenid --
- * Get the specified screen pointer.
- *
- * XXX
- * This is fatal. We can't post a message into vi that we're unable to find
- * the screen without first finding the screen... So, this must be the first
- * thing a Tcl routine does, and, if it fails, the last as well.
- */
-static int
-getscreenid(interp, spp, id, name)
- Tcl_Interp *interp;
- SCR **spp;
- char *id, *name;
-{
- int scr_no;
- char buf[64];
-
- if (id != NULL && getint(interp, "screen id", id, &scr_no))
- return (1);
- if ((*spp = api_fscreen(scr_no, name)) == NULL) {
- (void)snprintf(buf, sizeof(buf),
- "unknown screen id: %s", name == NULL ? id : name);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return (1);
- }
- return (0);
-}
-
-/*
- * getint --
- * Get a Tcl integer.
- *
- * XXX
- * This code assumes that both recno_t and size_t are larger than ints.
- */
-static int
-getint(interp, msg, s, intp)
- Tcl_Interp *interp;
- char *msg, *s;
- int *intp;
-{
- char buf[64];
-
- if (Tcl_GetInt(interp, s, intp) == TCL_ERROR)
- return (1);
- if (*intp < 0) {
- (void)snprintf(buf, sizeof(buf),
- "illegal %s %s: may not be negative", msg, s);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- return (1);
- }
- return (0);
-}
-
-/*
- * msghandler --
- * Tcl message routine so that error messages are processed in
- * Tcl, not in nvi.
- */
-static void
-msghandler(sp, mtype, msg, len)
- SCR *sp;
- mtype_t mtype;
- char *msg;
- size_t len;
-{
- /* Replace the trailing <newline> with an EOS. */
- msg[len - 1] = '\0';
-
- Tcl_SetResult(sp->gp->tcl_interp, msg, TCL_VOLATILE);
-}
diff --git a/tcl_scripts/errors.tcl b/tcl_scripts/errors.tcl
deleted file mode 100644
index 94a1e6a8c3c9..000000000000
--- a/tcl_scripts/errors.tcl
+++ /dev/null
@@ -1,44 +0,0 @@
-# @(#)errors.tcl 8.2 (Berkeley) 11/18/95
-#
-# File: errors.tcl
-#
-# Author: George V. Neville-Neil
-#
-# Purpose: This file contains vi/tcl code that allows a vi user to parse
-# compiler errors and warnings from a make.out file.
-
-proc findErr {} {
- global errScreen
- global currFile
- global fileScreen
- set errLine [lindex [viGetCursor $errScreen] 0]
- set currLine [split [viGetLine $errScreen $errLine] :]
- set currFile [lindex $currLine 0]
- set fileScreen [viNewScreen $errScreen $currFile]
- viSetCursor $fileScreen [lindex $currLine 1] 1
- viMapKey $viScreenId  nextErr
-}
-
-proc nextErr {} {
- global errScreen
- global fileScreen
- global currFile
- set errLine [lindex [viGetCursor $errScreen] 0]
- set currLine [split [viGetLine $errScreen $errLine] :]
- if {[string match $currFile [lindex $currLine 0]]} {
- viSetCursor $fileScreen [lindex $currLine 1] 0
- viSwitchScreen $fileScreen
- } else {
- viEndScreen $fileScreen
- set currFile [lindex $currLine 0]
- set fileScreen[viNewScreen $errScreen $currFile]
- viSetCursor $fileScreen [lindex $currLine 1] 0
- }
-}
-
-proc initErr {} {
- global viScreenId
- global errScreen
- set errScreen [viNewScreen $viScreenId make.out]
- viMapKey $viScreenId  findErr
-}
diff --git a/tcl_scripts/gnats.tcl b/tcl_scripts/gnats.tcl
deleted file mode 100644
index 61ecb6e2cda0..000000000000
--- a/tcl_scripts/gnats.tcl
+++ /dev/null
@@ -1,95 +0,0 @@
-# @(#)gnats.tcl 8.2 (Berkeley) 11/18/95
-#
-proc init {catFile} {
- global viScreenId
- global categories
- set categories {}
- set categoriesFile [open $catFile r]
- while {[gets $categoriesFile line] >= 0} {
- lappend categories $line
- }
- close $categoriesFile
- viMsg $viScreenId $categories
- viMapKey $viScreenId  next
-}
-
-proc next {} {
- global viScreenId
- set cursor [viGetCursor $viScreenId]
- set lineNum [lindex $cursor 0]
- set line [viGetLine $viScreenId $lineNum]
- viMsg $viScreenId [lindex $line 0]
- if {[lindex $line 0] == ">Confidential:"} {
- confNext $lineNum $line
- } elseif {[lindex $line 0] == ">Severity:"} {
- sevNext $lineNum $line
- } elseif {[lindex $line 0] == ">Priority:"} {
- priNext $lineNum $line
- } elseif {[lindex $line 0] == ">Class:"} {
- classNext $lineNum $line
- } elseif {[lindex $line 0] == ">Category:"} {
- catNext $lineNum $line
- }
-}
-
-proc confNext {lineNum line} {
- global viScreenId
- viMsg $viScreenId [lindex $line 1]
- if {[lindex $line 1] == "yes"} {
- viSetLine $viScreenId $lineNum ">Confidential: no"
- } else {
- viSetLine $viScreenId $lineNum ">Confidential: yes"
- }
-}
-
-proc sevNext {lineNum line} {
- global viScreenId
- viMsg $viScreenId [lindex $line 1]
- if {[lindex $line 1] == "non-critical"} {
- viSetLine $viScreenId $lineNum ">Severity: serious"
- } elseif {[lindex $line 1] == "serious"} {
- viSetLine $viScreenId $lineNum ">Severity: critical"
- } elseif {[lindex $line 1] == "critical"} {
- viSetLine $viScreenId $lineNum ">Severity: non-critical"
- }
-}
-
-proc priNext {lineNum line} {
- global viScreenId
- viMsg $viScreenId [lindex $line 1]
- if {[lindex $line 1] == "low"} {
- viSetLine $viScreenId $lineNum ">Priority: medium"
- } elseif {[lindex $line 1] == "medium"} {
- viSetLine $viScreenId $lineNum ">Priority: high"
- } elseif {[lindex $line 1] == "high"} {
- viSetLine $viScreenId $lineNum ">Priority: low"
- }
-}
-
-proc classNext {lineNum line} {
- global viScreenId
- viMsg $viScreenId [lindex $line 1]
- if {[lindex $line 1] == "sw-bug"} {
- viSetLine $viScreenId $lineNum ">Class: doc-bug"
- } elseif {[lindex $line 1] == "doc-bug"} {
- viSetLine $viScreenId $lineNum ">Class: change-request"
- } elseif {[lindex $line 1] == "change-request"} {
- viSetLine $viScreenId $lineNum ">Class: support"
- } elseif {[lindex $line 1] == "support"} {
- viSetLine $viScreenId $lineNum ">Class: sw-bug"
- }
-}
-
-proc catNext {lineNum line} {
- global viScreenId
- global categories
- viMsg $viScreenId [lindex $line 1]
- set curr [lsearch -exact $categories [lindex $line 1]]
- if {$curr == -1} {
- set curr 0
- }
- viMsg $viScreenId $curr
- viSetLine $viScreenId $lineNum ">Class: [lindex $categories $curr]"
-}
-
-init abekas
diff --git a/tcl_scripts/mailprocs.tcl b/tcl_scripts/mailprocs.tcl
deleted file mode 100644
index eccb9cdfcf74..000000000000
--- a/tcl_scripts/mailprocs.tcl
+++ /dev/null
@@ -1,115 +0,0 @@
-# @(#)mailprocs.tcl 8.3 (Berkeley) 4/29/96
-#
-proc validLine {} {
- global viScreenId
- set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
- if {[string compare [lindex [split $line :] 0] "To"] == 0} {
- set addrs [lindex [split $line :] 1]
- foreach name [split $addrs ,] {
- isValid [string trim $name]
- }
- }
-}
-
-proc valid {target} {
- set found 0
- set aliasFile [open "~/Mail/aliases" r]
- while {[gets $aliasFile line] >= 0} {
- set name [lindex [split $line :] 0]
- set address [lindex [split $line :] 1]
- if {[string compare $target $name] == 0} {
- set found 1
- break
- }
- }
- close $aliasFile
- if {$found == 1} {
- return $address
- } else {
- return $found
- }
-}
-
-proc isValid {target} {
- global viScreenId
- set address [valid $target]
- if {$address != 0} {
- viMsg $viScreenId "$target is [string trim $address]"
- } else {
- viMsg $viScreenId "$target not found"
- }
-}
-
-proc isAliasedLine {} {
- global viScreenId
- set line [viGetLine $viScreenId [lindex [viGetCursor $viScreenId] 0]]
- if {[string match [lindex [split $line :] 0] "*To"] == 0} {
- set addrs [lindex [split $line :] 1]
- foreach name [split $addrs ,] {
- isAliased [string trim $name]
- }
- }
-}
-
-proc aliased {target} {
- set found 0
- set aliasFile [open "~/Mail/aliases" r]
- while {[gets $aliasFile line] >= 0} {
- set name [lindex [split $line :] 0]
- set address [lindex [split $line :] 1]
- if {[string compare $target [string trim $address]] == 0} {
- set found 1
- break
- }
- }
- close $aliasFile
-
- return $found
-}
-
-proc isAliased {target} {
- global viScreenId
- set found [aliased $target]
-
- if {$found} {
- viMsg $viScreenId "$target is aliased to [string trim $name]"
- } else {
- viMsg $viScreenId "$target not aliased"
- }
-}
-
-proc appendAlias {target address} {
- if {![aliased $target]} {
- set aliasFile [open "~/Mail/aliases" a]
- puts $aliasFile "$target: $address"
- }
- close $aliasFile
-}
-
-proc expand {} {
- global viScreenId
- set row [lindex [viGetCursor $viScreenId] 0]]
- set column [lindex [viGetCursor $viScreenId] 1]]
- set line [viGetLine $viScreenId $row]
- while {$column < [string length $line] && \
- [string index $line $column] != ' '} {
- append $target [string index $line $column]
- incr $column
- }
- set found [isValid $target]
-}
-
-proc cite {} {
- global viScreenId
- global viStartLine
- global viStopLine
- for {set i $viStartLine} {$i <= $viStopLine} {incr i} {
- set newLine "> "
- append newLine [viGetLine $viScreenId $i]
- viSetLine $viScreenId $i $newLine
- }
-}
-
-global viScreenId
-viMapKey $viScreenId  isAliasedLine
-viMapKey $viScreenId  validLine
diff --git a/tcl_scripts/wc.tcl b/tcl_scripts/wc.tcl
deleted file mode 100644
index 25d0f6254391..000000000000
--- a/tcl_scripts/wc.tcl
+++ /dev/null
@@ -1,16 +0,0 @@
-# @(#)wc.tcl 8.2 (Berkeley) 11/18/95
-#
-proc wc {} {
- global viScreenId
- global viStartLine
- global viStopLine
-
- set lines [viLastLine $viScreenId]
- set output ""
- set words 0
- for {set i $viStartLine} {$i <= $viStopLine} {incr i} {
- set outLine [split [string trim [viGetLine $viScreenId $i]]]
- set words [expr $words + [llength $outLine]]
- }
- viMsg $viScreenId "$words words"
-}
diff --git a/tk/init.tcl b/tk/init.tcl
deleted file mode 100644
index 78c5a115c0a7..000000000000
--- a/tk/init.tcl
+++ /dev/null
@@ -1,1096 +0,0 @@
-# @(#)init.tcl 8.10 (Berkeley) 7/19/96
-proc screen {} {
- global tk_ssize_row
- global tk_ssize_col
-
- # Build menubar with File, Options and Help entries.
- frame .menu -relief raised -borderwidth 1
- pack append . .menu {top fillx}
-
- # File pull-down menu
- menubutton .menu.file -text "File" \
- -menu .menu.file.fileops -underline 0
- menu .menu.file.fileops
- .menu.file.fileops add command -label "Edit ..." \
- -command "tk_edit" -underline 0
- .menu.file.fileops add command -label "Save File" \
- -command "tk_write" -underline 0
- .menu.file.fileops add command -label "Save File as ..." \
- -command "tk_writeas" -underline 1
- .menu.file.fileops add command -label "Save and Quit" \
- -command "tk_writequit" -underline 7
- .menu.file.fileops add command -label "Quit" \
- -command "tk_quit" -underline 0
-
- # Options pull-down menu
- menubutton .menu.option -text "Options" \
- -menu .menu.option.optionops -underline 0
- menu .menu.option.optionops
- .menu.option.optionops add command -label "Set all" \
- -command tk_options -underline 0
-
- # Help pull-down menu
- menubutton .menu.help -text "Help" \
- -menu .menu.help.helpops -underline 0
- menu .menu.help.helpops
- .menu.help.helpops add command -label "On Help" -underline 3 \
- -command tk_help
- .menu.help.helpops add command -label "On Version" -underline 3 \
- -command tk_version
-
- pack append .menu \
- .menu.file {left} .menu.option {left} .menu.help {right}
-
- # Set up for keyboard-based menu traversal
- tk_bindForTraversal .
- bind . <Any-Enter> {focus .}
- focus .
- tk_menuBar .menu .menu.file .menu.help
-
- # Create text window
- text .t -relief raised -bd 1 -setgrid true -yscrollcommand ".s set"
- scrollbar .s -relief flat -command ".t yview"
- pack append . .s {right filly} .t {expand fill}
-
- # Use tags to build a cursor for the text window.
- set bg [lindex [.t config -background] 4]
- set fg [lindex [.t config -foreground] 4]
- .t tag configure tk_cursor -background $fg -foreground $bg
- .t mark set tk_cursor_indx insert
- .t tag add tk_cursor tk_cursor_indx
-
- # Bind the keys.
- bind .t <Any-KeyPress> {tk_flash; break}
- bind .t 0 {tk_key_enter "0"; break}
- bind .t 1 {tk_key_enter "1"; break}
- bind .t 2 {tk_key_enter "2"; break}
- bind .t 3 {tk_key_enter "3"; break}
- bind .t 4 {tk_key_enter "4"; break}
- bind .t 5 {tk_key_enter "5"; break}
- bind .t 6 {tk_key_enter "6"; break}
- bind .t 7 {tk_key_enter "7"; break}
- bind .t 8 {tk_key_enter "8"; break}
- bind .t 9 {tk_key_enter "9"; break}
- bind .t <BackSpace> {tk_key_enter "\010"; break}
- bind .t <Control-a> {tk_key_enter "\001"; break}
- bind .t <Control-b> {tk_key_enter "\002"; break}
- bind .t <Control-c> {tk_key_enter "\003"; break}
- bind .t <Control-d> {tk_key_enter "\004"; break}
- bind .t <Control-e> {tk_key_enter "\005"; break}
- bind .t <Control-f> {tk_key_enter "\006"; break}
- bind .t <Control-g> {tk_key_enter "\007"; break}
- bind .t <Control-h> {tk_key_enter "\010"; break}
- bind .t <Control-i> {tk_key_enter "\011"; break}
- bind .t <Control-j> {tk_key_enter "\012"; break}
- bind .t <Control-k> {tk_key_enter "\013"; break}
- bind .t <Control-l> {tk_key_enter "\014"; break}
- bind .t <Control-m> {tk_key_enter "\015"; break}
- bind .t <Control-n> {tk_key_enter "\016"; break}
- bind .t <Control-o> {tk_key_enter "\017"; break}
- bind .t <Control-p> {tk_key_enter "\020"; break}
- bind .t <Control-q> {tk_key_enter "\021"; break}
- bind .t <Control-r> {tk_key_enter "\022"; break}
- bind .t <Control-s> {tk_key_enter "\023"; break}
- bind .t <Control-t> {tk_key_enter "\024"; break}
- bind .t <Control-u> {tk_key_enter "\025"; break}
- bind .t <Control-v> {tk_key_enter "\026"; break}
- bind .t <Control-w> {tk_key_enter "\027"; break}
- bind .t <Control-x> {tk_key_enter "\030"; break}
- bind .t <Control-y> {tk_key_enter "\031"; break}
- bind .t <Control-z> {tk_key_enter "\032"; break}
- bind .t <Control_L> {tk_noop; break}
- bind .t <Control_R> {tk_noop; break}
- bind .t <Delete> {tk_key_enter "x"; break}
- bind .t <Down> {tk_key_enter "j"; break}
- bind .t <End> {tk_key_enter "G"; break}
- bind .t <Escape> {tk_key_enter "\033"; break}
- bind .t <Home> {tk_key_enter "1G"; break}
- bind .t <Insert> {tk_key_enter "i"; break}
- bind .t <Left> {tk_key_enter "h"; break}
- bind .t <Next> {tk_key_enter "\006"; break}
- bind .t <Prior> {tk_key_enter "\002"; break}
- bind .t <Return> {tk_key_enter "\015"; break}
- bind .t <Right> {tk_key_enter "l"; break}
- bind .t <Shift_L> {tk_noop; break}
- bind .t <Shift_Lock> {tk_noop; break}
- bind .t <Shift_R> {tk_noop; break}
- bind .t <Tab> {tk_key_enter "\011"; break}
- bind .t <Up> {tk_key_enter "k"; break}
- bind .t <ampersand> {tk_key_enter "&"; break}
- bind .t <asciicircum> {tk_key_enter "^"; break}
- bind .t <asciitilde> {tk_key_enter "~"; break}
- bind .t <asterisk> {tk_key_enter "*"; break}
- bind .t <at> {tk_key_enter "@"; break}
- bind .t <backslash> {tk_key_enter "\\"; break}
- bind .t <bar> {tk_key_enter "|"; break}
- bind .t <braceleft> {tk_key_enter "{"; break}
- bind .t <braceright> {tk_key_enter "; break}"}
- bind .t <bracketleft> {tk_key_enter "\["; break}
- bind .t <bracketright> {tk_key_enter "]"; break}
- bind .t <colon> {tk_key_enter ":"; break}
- bind .t <comma> {tk_key_enter ","; break}
- bind .t <dollar> {tk_key_enter "$"; break}
- bind .t <equal> {tk_key_enter "="; break}
- bind .t <exclam> {tk_key_enter "!"; break}
- bind .t <greater> {tk_key_enter ">"; break}
- bind .t <less> {tk_key_enter "<"; break}
- bind .t <minus> {tk_key_enter "-"; break}
- bind .t <numbersign> {tk_key_enter "#"; break}
- bind .t <parenleft> {tk_key_enter "("; break}
- bind .t <parenright> {tk_key_enter ")"; break}
- bind .t <percent> {tk_key_enter "%"; break}
- bind .t <period> {tk_key_enter "."; break}
- bind .t <plus> {tk_key_enter "+"; break}
- bind .t <question> {tk_key_enter "?"; break}
- bind .t <quotedbl> {tk_key_enter "\""; break}
- bind .t <quoteright> {tk_key_enter "'"; break}
- bind .t <semicolon> {tk_key_enter ";"; break}
- bind .t <slash> {tk_key_enter "/"; break}
- bind .t <space> {tk_key_enter " "; break}
- bind .t <underscore> {tk_key_enter "_"; break}
- bind .t A {tk_key_enter "A"; break}
- bind .t B {tk_key_enter "B"; break}
- bind .t C {tk_key_enter "C"; break}
- bind .t D {tk_key_enter "D"; break}
- bind .t E {tk_key_enter "E"; break}
- bind .t F {tk_key_enter "F"; break}
- bind .t G {tk_key_enter "G"; break}
- bind .t H {tk_key_enter "H"; break}
- bind .t I {tk_key_enter "I"; break}
- bind .t J {tk_key_enter "J"; break}
- bind .t K {tk_key_enter "K"; break}
- bind .t L {tk_key_enter "L"; break}
- bind .t M {tk_key_enter "M"; break}
- bind .t N {tk_key_enter "N"; break}
- bind .t O {tk_key_enter "O"; break}
- bind .t P {tk_key_enter "P"; break}
- bind .t Q {tk_key_enter "Q"; break}
- bind .t R {tk_key_enter "R"; break}
- bind .t S {tk_key_enter "S"; break}
- bind .t T {tk_key_enter "T"; break}
- bind .t U {tk_key_enter "U"; break}
- bind .t V {tk_key_enter "V"; break}
- bind .t W {tk_key_enter "W"; break}
- bind .t X {tk_key_enter "X"; break}
- bind .t Y {tk_key_enter "Y"; break}
- bind .t Z {tk_key_enter "Z"; break}
- bind .t a {tk_key_enter "a"; break}
- bind .t b {tk_key_enter "b"; break}
- bind .t c {tk_key_enter "c"; break}
- bind .t d {tk_key_enter "d"; break}
- bind .t e {tk_key_enter "e"; break}
- bind .t f {tk_key_enter "f"; break}
- bind .t g {tk_key_enter "g"; break}
- bind .t h {tk_key_enter "h"; break}
- bind .t i {tk_key_enter "i"; break}
- bind .t j {tk_key_enter "j"; break}
- bind .t k {tk_key_enter "k"; break}
- bind .t l {tk_key_enter "l"; break}
- bind .t m {tk_key_enter "m"; break}
- bind .t n {tk_key_enter "n"; break}
- bind .t o {tk_key_enter "o"; break}
- bind .t p {tk_key_enter "p"; break}
- bind .t q {tk_key_enter "q"; break}
- bind .t r {tk_key_enter "r"; break}
- bind .t s {tk_key_enter "s"; break}
- bind .t t {tk_key_enter "t"; break}
- bind .t u {tk_key_enter "u"; break}
- bind .t v {tk_key_enter "v"; break}
- bind .t w {tk_key_enter "w"; break}
- bind .t x {tk_key_enter "x"; break}
- bind .t y {tk_key_enter "y"; break}
- bind .t z {tk_key_enter "z"; break}
-
- # XXX
- # I haven't been able to make Tcl/Tk write uninitialized portions
- # of the text window. Fill in the screen.
- tk_ssize
- .t mark set insert 1.0
- for {set i 1} {$i <= $tk_ssize_row} {incr i} {
- for {set j 1} {$j <= $tk_ssize_col} {incr j} {
- .t insert insert " "
- }
- .t insert insert "\n"
- }
-}
-
-# tk_noop --
-# Do nothing.
-#
-# XXX
-# I can't figure out how to get a binding that does nothing without
-# calling a function, so this stub does it for me.
-proc tk_noop {} {
-}
-
-# tk_key_enter --
-# Enter a key.
-proc tk_key_enter {val} {
- global newkey
- global waiting
-
- set waiting 0
- tk_key $val
- set newkey 1
-}
-
-# tk_key_wait --
-# Wait for a key.
-proc tk_key_wait {timeout} {
- global newkey
- global waiting
-
- if { $timeout != 0 } {
- after $timeout "set newkey 1"
- }
- set waiting 1
- tkwait variable newkey
-}
-
-# Callback functions for the File menu.
-# tk_edit
-# Edit another file.
-proc tk_edit {} {
-}
-
-# tk_quit
-# Quit.
-proc tk_quit {} {
- global newkey
- global waiting
-
- tk_op quit
- if { $waiting != 0 } {
- set newkey 1
- }
-}
-
-# tk_write
-# Write the edit buffer.
-proc tk_write {} {
- global newkey
- global waiting
-
- tk_op write
- if { $waiting != 0 } {
- set newkey 1
- }
-}
-
-# tk_writeas
-# Write the edit buffer to a named file.
-proc tk_writeas {} {
-}
-
-# tk_writequit
-# Write and quit.
-proc tk_writequit {} {
- global newkey
- global waiting
-
- tk_op writequit
- if { $waiting != 0 } {
- set newkey 1
- }
-}
-
-# Callback functions for the Help menu.
-#
-# tk_help --
-# Present a help screen.
-proc tk_help {} {
- tk_dialog .d {} "No help screen currently available." {} 0 Continue
-}
-
-# tk_options
-# Contains the option selector box. It is divided into three parts, the
-# checkbuttons for the boolean options, the entry fields for the string
-# numeric options, and a control area containing buttons. There is only
-# one function.
-proc tk_options {} {
-
- # Build option selector box with three subframes for boolean,
- # numeric, and string options. Make it a toplevel window.
- toplevel .os
- wm title .os options
-
- # Option variables.
- global tko_altwerase
- global tko_autoindent
- global tko_autoprint
- global tko_autowrite
- global tko_backup
- global tko_beautify
- global tko_cdpath
- global tko_cedit
- global tko_columns
- global tko_comment
- global tko_directory
- global tko_edcompatible
- global tko_escapetime
- global tko_errorbells
- global tko_exrc
- global tko_extended
- global tko_filec
- global tko_flash
- global tko_hardtabs
- global tko_iclower
- global tko_ignorecase
- global tko_keytime
- global tko_leftright
- global tko_lines
- global tko_lisp
- global tko_list
- global tko_lock
- global tko_magic
- global tko_matchtime
- global tko_mesg
- global tko_modeline
- global tko_msgcat
- global tko_noprint
- global tko_number
- global tko_octal
- global tko_open
- global tko_optimize
- global tko_paragraphs
- global tko_print
- global tko_prompt
- global tko_readonly
- global tko_recdir
- global tko_redraw
- global tko_remap
- global tko_report
- global tko_ruler
- global tko_scroll
- global tko_searchincr
- global tko_sections
- global tko_secure
- global tko_shell
- global tko_shellmeta
- global tko_shiftwidth
- global tko_showmatch
- global tko_showmode
- global tko_sidescroll
- global tko_slowopen
- global tko_sourceany
- global tko_tabstop
- global tko_taglength
- global tko_tags
- global tko_term
- global tko_terse
- global tko_tildeop
- global tko_timeout
- global tko_ttywerase
- global tko_verbose
- global tko_warn
- global tko_window
- global tko_windowname
- global tko_wraplen
- global tko_wrapmargin
- global tko_wrapscan
- global tko_writeany
-
- # Initialize option values.
- tk_opt_init
-
- # Build subframe for boolean options.
- frame .os.bopts
-
- # This is the width of the edcompatible button.
- set buttonwidth 13
-
- # Pack the boolean os, 5 to a frame.
- frame .os.bopts.f1
- pack append .os.bopts .os.bopts.f1 {top}
- checkbutton .os.bopts.f1.b1 \
- -variable tko_altwerase -text "altwerase" \
- -command "tk_opt_set altwerase $tko_altwerase" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f1.b2 \
- -variable tko_autoindent -text "autoindent" \
- -command "tk_opt_set autoindent $tko_autoindent" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f1.b3 \
- -variable tko_autoprint -text "autoprint" \
- -command "tk_opt_set autoprint $tko_autoprint" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f1.b4 \
- -variable tko_autowrite -text "autowrite" \
- -command "tk_opt_set autowrite $tko_autowrite" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f1.b5 \
- -variable tko_beautify -text "beautify" \
- -command "tk_opt_set beautify $tko_beautify" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f1 \
- .os.bopts.f1.b1 {left frame w} \
- .os.bopts.f1.b2 {left frame w} \
- .os.bopts.f1.b3 {left frame w} \
- .os.bopts.f1.b4 {left frame w} \
- .os.bopts.f1.b5 {left frame w}
-
- frame .os.bopts.f2
- pack append .os.bopts .os.bopts.f2 {top}
- checkbutton .os.bopts.f2.b1 \
- -variable tko_comment -text "comment" \
- -command "tk_opt_set comment $tko_comment" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f2.b2 \
- -variable tko_edcompatible -text "edcompatible" \
- -command "tk_opt_set edcompatible $tko_edcompatible" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f2.b3 \
- -variable tko_errorbells -text "errorbells" \
- -command "tk_opt_set errorbells $tko_errorbells" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f2.b4 \
- -variable tko_exrc -text "exrc" \
- -command "tk_opt_set exrc $tko_exrc" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f2.b5 \
- -variable tko_extended -text "extended" \
- -command "tk_opt_set extended $tko_extended" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f2 \
- .os.bopts.f2.b1 {left frame w} \
- .os.bopts.f2.b2 {left frame w} \
- .os.bopts.f2.b3 {left frame w} \
- .os.bopts.f2.b4 {left frame w} \
- .os.bopts.f2.b5 {left frame w}
-
- frame .os.bopts.f3
- pack append .os.bopts .os.bopts.f3 {top}
- checkbutton .os.bopts.f3.b1 \
- -variable tko_flash -text "flash" \
- -command "tk_opt_set flash $tko_flash" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f3.b2 \
- -variable tko_iclower -text "iclower" \
- -command "tk_opt_set iclower $tko_iclower" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f3.b3 \
- -variable tko_ignorecase -text "ignorecase" \
- -command "tk_opt_set ignorecase $tko_ignorecase" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f3.b4 \
- -variable tko_leftright -text "leftright" \
- -command "tk_opt_set leftright $tko_leftright" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f3.b5 \
- -variable tko_lisp -text "lisp" \
- -command "tk_opt_set lisp $tko_lisp" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f3 \
- .os.bopts.f3.b1 {left frame w} \
- .os.bopts.f3.b2 {left frame w} \
- .os.bopts.f3.b3 {left frame w} \
- .os.bopts.f3.b4 {left frame w} \
- .os.bopts.f3.b5 {left frame w}
-
- frame .os.bopts.f4
- pack append .os.bopts .os.bopts.f4 {top}
- checkbutton .os.bopts.f4.b1 \
- -variable tko_list -text "list" \
- -command "tk_opt_set list $tko_list" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f4.b2 \
- -variable tko_lock -text "lock" \
- -command "tk_opt_set lock $tko_lock" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f4.b3 \
- -variable tko_magic -text "magic" \
- -command "tk_opt_set magic $tko_magic" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f4.b4 \
- -variable tko_mesg -text "mesg" \
- -command "tk_opt_set mesg $tko_mesg" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f4.b5\
- -variable tko_number -text "number" \
- -command "tk_opt_set number $tko_number" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f4 \
- .os.bopts.f4.b1 {left frame w} \
- .os.bopts.f4.b2 {left frame w} \
- .os.bopts.f4.b3 {left frame w} \
- .os.bopts.f4.b4 {left frame w} \
- .os.bopts.f4.b5 {left frame w}
-
- frame .os.bopts.f5
- pack append .os.bopts .os.bopts.f5 {top}
- checkbutton .os.bopts.f5.b1 \
- -variable tko_octal -text "octal" \
- -command "tk_opt_set octal $tko_octal" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f5.b2 \
- -variable tko_open -text "open" \
- -command "tk_opt_set open $tko_open" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f5.b3 \
- -variable tko_optimize -text "optimize" \
- -command "tk_opt_set optimize $tko_optimize" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f5.b4 \
- -variable tko_prompt -text "prompt" \
- -command "tk_opt_set prompt $tko_prompt" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f5.b5 \
- -variable tko_readonly -text "readonly" \
- -command "tk_opt_set readonly $tko_readonly" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f5 \
- .os.bopts.f5.b1 {left frame w} \
- .os.bopts.f5.b2 {left frame w} \
- .os.bopts.f5.b3 {left frame w} \
- .os.bopts.f5.b4 {left frame w} \
- .os.bopts.f5.b5 {left frame w}
-
- frame .os.bopts.f6
- pack append .os.bopts .os.bopts.f6 {top}
- checkbutton .os.bopts.f6.b1 \
- -variable tko_remap -text "remap" \
- -command "tk_opt_set remap $tko_remap" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f6.b2 \
- -variable tko_ruler -text "ruler" \
- -command "tk_opt_set ruler $tko_ruler" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f6.b3 \
- -variable tko_searchincr -text "searchincr" \
- -command "tk_opt_set searchincr $tko_searchincr" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f6.b4 \
- -variable tko_secure -text "secure" \
- -command "tk_opt_set secure $tko_secure" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f6.b5 \
- -variable tko_showmatch -text "showmatch" \
- -command "tk_opt_set showmatch $tko_showmatch" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f6 \
- .os.bopts.f6.b1 {left frame w} \
- .os.bopts.f6.b2 {left frame w} \
- .os.bopts.f6.b3 {left frame w} \
- .os.bopts.f6.b4 {left frame w} \
- .os.bopts.f6.b5 {left frame w}
-
- frame .os.bopts.f7
- pack append .os.bopts .os.bopts.f7 {top}
- checkbutton .os.bopts.f7.b1 \
- -variable tko_showmode -text "showmode" \
- -command "tk_opt_set showmode $tko_showmode" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f7.b2 \
- -variable tko_slowopen -text "slowopen" \
- -command "tk_opt_set slowopen $tko_slowopen" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f7.b3 \
- -variable tko_sourceany -text "sourceany" \
- -command "tk_opt_set sourceany $tko_sourceany" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f7.b4 \
- -variable tko_terse -text "terse" \
- -command "tk_opt_set terse $tko_terse" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f7.b5 \
- -variable tko_tildeop -text "tildeop" \
- -command "tk_opt_set tildeope $tko_tildeop" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f7 \
- .os.bopts.f7.b1 {left frame w} \
- .os.bopts.f7.b2 {left frame w} \
- .os.bopts.f7.b3 {left frame w} \
- .os.bopts.f7.b4 {left frame w} \
- .os.bopts.f7.b5 {left frame w}
-
- frame .os.bopts.f8
- pack append .os.bopts .os.bopts.f8 {top fillx}
- checkbutton .os.bopts.f8.b1 \
- -variable tko_timeout -text "timeout" \
- -command "tk_opt_set timeout $tko_timeout" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f8.b2 \
- -variable tko_ttywerase -text "ttywerase" \
- -command "tk_opt_set ttywerase $tko_ttywerase" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f8.b3 \
- -variable tko_verbose -text "verbose" \
- -command "tk_opt_set verbose $tko_verbose" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f8.b4 \
- -variable tko_warn -text "warn" \
- -command "tk_opt_set warn $tko_warn" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f8.b5 \
- -variable tko_windowname -text "windowname" \
- -command "tk_opt_set windowname $tko_windowname" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f8 \
- .os.bopts.f8.b1 {left frame w} \
- .os.bopts.f8.b2 {left frame w} \
- .os.bopts.f8.b3 {left frame w} \
- .os.bopts.f8.b4 {left frame w} \
- .os.bopts.f8.b5 {left frame w}
-
- frame .os.bopts.f9
- pack append .os.bopts .os.bopts.f9 {top fillx}
- checkbutton .os.bopts.f9.b1 \
- -variable tko_wrapscan -text "wrapscan" \
- -command "tk_opt_set wrapscan $tko_wrapscan" \
- -width $buttonwidth -anchor w
- checkbutton .os.bopts.f9.b2 \
- -variable tko_writeany -text "writeany" \
- -command "tk_opt_set writeany $tko_writeany" \
- -width $buttonwidth -anchor w
- pack append .os.bopts.f9 \
- .os.bopts.f9.b1 {left frame w} \
- .os.bopts.f9.b2 {left frame w}
-
- # Build frame for number options:
- frame .os.nopts
-
- # Label and entry widths.
- set lwidth 12
- set ewidth 3
-
- frame .os.nopts.n1
- label .os.nopts.n1.l -text "column:" -width $lwidth -anchor w
- entry .os.nopts.n1.e -width $ewidth -relief raised \
- -textvariable tko_columns
- trace variable tko_columns w tk_opt_ew
- pack append .os.nopts.n1 \
- .os.nopts.n1.l {left} .os.nopts.n1.e {left frame w}
-
- frame .os.nopts.n2
- label .os.nopts.n2.l -text "escapetime:" -width $lwidth -anchor w
- entry .os.nopts.n2.e -width $ewidth -textvariable tko_escapetime \
- -relief raised
- trace variable tko_escapetime w tk_opt_ew
- pack append .os.nopts.n2 \
- .os.nopts.n2.l {left} .os.nopts.n2.e {left frame w}
-
- frame .os.nopts.n3
- label .os.nopts.n3.l -text "hardtabs:" -width $lwidth -anchor w
- entry .os.nopts.n3.e -width $ewidth -textvariable tko_hardtabs \
- -relief raised
- trace variable tko_hardtabs w tk_opt_ew
- pack append .os.nopts.n3 \
- .os.nopts.n3.l {left} .os.nopts.n3.e {left frame w}
-
- frame .os.nopts.n4
- label .os.nopts.n4.l -text "keytime:" -width $lwidth -anchor w
- entry .os.nopts.n4.e -width $ewidth -textvariable tko_keytime \
- -relief raised
- trace variable tko_keytime w tk_opt_ew
- pack append .os.nopts.n4 \
- .os.nopts.n4.l {left} .os.nopts.n4.e {left frame w}
-
- frame .os.nopts.n5
- label .os.nopts.n5.l -text "lines:" -width $lwidth -anchor w
- entry .os.nopts.n5.e -width $ewidth -textvariable tko_lines \
- -relief raised
- trace variable tko_lines w tk_opt_ew
- pack append .os.nopts.n5 \
- .os.nopts.n5.l {left} .os.nopts.n5.e {left frame w}
-
- frame .os.nopts.n6
- label .os.nopts.n6.l -text "matchtime:" -width $lwidth -anchor w
- entry .os.nopts.n6.e -width $ewidth -textvariable tko_matchtime \
- -relief raised
- trace variable tko_matchtime w tk_opt_ew
- pack append .os.nopts.n6 \
- .os.nopts.n6.l {left} .os.nopts.n6.e {left frame w}
-
- frame .os.nopts.n7
- label .os.nopts.n7.l -text "report:" -width $lwidth -anchor w
- entry .os.nopts.n7.e -width $ewidth -textvariable tko_report \
- -relief raised
- trace variable tko_report w tk_opt_ew
- pack append .os.nopts.n7 \
- .os.nopts.n7.l {left} .os.nopts.n7.e {left frame w}
-
- frame .os.nopts.n8
- label .os.nopts.n8.l -text "scroll:" -width $lwidth -anchor w
- entry .os.nopts.n8.e -width $ewidth -textvariable tko_scroll \
- -relief raised
- trace variable tko_scroll w tk_opt_ew
- pack append .os.nopts.n8 \
- .os.nopts.n8.l {left} .os.nopts.n8.e {left frame w}
-
- frame .os.nopts.n9
- label .os.nopts.n9.l -text "shiftwidth:" -width $lwidth -anchor w
- entry .os.nopts.n9.e -width $ewidth -textvariable tko_shiftwidth \
- -relief raised
- trace variable tko_shiftwidth w tk_opt_ew
- pack append .os.nopts.n9 \
- .os.nopts.n9.l {left} .os.nopts.n9.e {left frame w}
-
- frame .os.nopts.n10
- label .os.nopts.n10.l -text "sidescroll:" -width $lwidth -anchor w
- entry .os.nopts.n10.e -width $ewidth -textvariable tko_sidescroll \
- -relief raised
- trace variable tko_sidescroll w tk_opt_ew
- pack append .os.nopts.n10 \
- .os.nopts.n10.l {left} .os.nopts.n10.e {left frame w}
-
- frame .os.nopts.n11
- label .os.nopts.n11.l -text "tabstop:" -width $lwidth -anchor w
- entry .os.nopts.n11.e -width $ewidth -textvariable tko_tabstop \
- -relief raised
- trace variable tko_tabstop w tk_opt_ew
- pack append .os.nopts.n11 \
- .os.nopts.n11.l {left} .os.nopts.n11.e {left frame w}
-
- frame .os.nopts.n12
- label .os.nopts.n12.l -text "taglength:" -width $lwidth -anchor w
- entry .os.nopts.n12.e -width $ewidth -textvariable tko_taglength \
- -relief raised
- trace variable tko_taglength w tk_opt_ew
- pack append .os.nopts.n12 \
- .os.nopts.n12.l {left} .os.nopts.n12.e {left frame w}
-
- frame .os.nopts.n13
- label .os.nopts.n13.l -text "window:" -width $lwidth -anchor w
- entry .os.nopts.n13.e -width $ewidth -textvariable tko_window \
- -relief raised
- trace variable tko_window w tk_opt_ew
- pack append .os.nopts.n13 \
- .os.nopts.n13.l {left} .os.nopts.n13.e {left frame w}
-
- frame .os.nopts.n14
- label .os.nopts.n14.l -text "wraplen:" -width $lwidth -anchor w
- entry .os.nopts.n14.e -width $ewidth -textvariable tko_wraplen \
- -relief raised
- trace variable tko_wraplen w tk_opt_ew
- pack append .os.nopts.n14 \
- .os.nopts.n14.l {left} .os.nopts.n14.e {left frame w}
-
- frame .os.nopts.n15
- label .os.nopts.n15.l -text "wrapmargin:" -width $lwidth -anchor w
- entry .os.nopts.n15.e -width $ewidth -textvariable tko_wrapmargin \
- -relief raised
- trace variable tko_wrapmargin w tk_opt_ew
- pack append .os.nopts.n15 \
- .os.nopts.n15.l {left} .os.nopts.n15.e {left frame w}
-
- pack append .os.nopts \
- .os.nopts.n1 {top fillx} \
- .os.nopts.n3 {top expand fillx} \
- .os.nopts.n4 {top expand fillx} \
- .os.nopts.n5 {top expand fillx} \
- .os.nopts.n6 {top expand fillx} \
- .os.nopts.n7 {top expand fillx} \
- .os.nopts.n8 {top expand fillx} \
- .os.nopts.n9 {top expand fillx} \
- .os.nopts.n10 {top expand fillx} \
- .os.nopts.n11 {top expand fillx} \
- .os.nopts.n12 {top expand fillx} \
- .os.nopts.n13 {top expand fillx} \
- .os.nopts.n14 {top expand fillx} \
- .os.nopts.n15 {top expand fillx}
-
- # Build frame for string options
- frame .os.sopts
-
- # Entry width.
- set ewidth 40
-
- frame .os.sopts.s1
- label .os.sopts.s1.l -text "backup:" -width $lwidth -anchor w
- entry .os.sopts.s1.e -width $ewidth -textvariable tko_backup \
- -relief raised
- pack append .os.sopts.s1 \
- .os.sopts.s1.l {left} .os.sopts.s1.e {left frame w}
-
- frame .os.sopts.s2
- label .os.sopts.s2.l -text "cdpath:" -width $lwidth -anchor w
- entry .os.sopts.s2.e -width $ewidth -textvariable tko_cdpath \
- -relief raised
- pack append .os.sopts.s2 \
- .os.sopts.s2.l {left} .os.sopts.s2.e {left frame w}
-
- frame .os.sopts.s3
- label .os.sopts.s3.l -text "directory:" -width $lwidth -anchor w
- entry .os.sopts.s3.e -width $ewidth -textvariable tko_directory \
- -relief raised
- pack append .os.sopts.s3 \
- .os.sopts.s3.l {left} .os.sopts.s3.e {left frame w}
-
- frame .os.sopts.s4
- label .os.sopts.s4.l -text "cedit:" -width $lwidth -anchor w
- entry .os.sopts.s4.e -width $ewidth -textvariable tko_cedit \
- -relief raised
- pack append .os.sopts.s4 \
- .os.sopts.s4.l {left} .os.sopts.s4.e {left frame w}
-
- frame .os.sopts.s5
- label .os.sopts.s5.l -text "filec:" -width $lwidth -anchor w
- entry .os.sopts.s5.e -width $ewidth -textvariable tko_filec \
- -relief raised
- pack append .os.sopts.s5 \
- .os.sopts.s5.l {left} .os.sopts.s5.e {left frame w}
-
- frame .os.sopts.s6
- label .os.sopts.s6.l -text "msgcat:" -width $lwidth -anchor w
- entry .os.sopts.s6.e -width $ewidth -textvariable tko_msgcat \
- -relief raised
- pack append .os.sopts.s6 \
- .os.sopts.s6.l {left} .os.sopts.s6.e {left frame w}
-
- frame .os.sopts.s7
- label .os.sopts.s7.l -text "noprint:" -width $lwidth -anchor w
- entry .os.sopts.s7.e -width $ewidth -textvariable tko_noprint \
- -relief raised
- pack append .os.sopts.s7 \
- .os.sopts.s7.l {left} .os.sopts.s7.e {left frame w}
-
- frame .os.sopts.s8
- label .os.sopts.s8.l -text "paragraphs:" -width $lwidth -anchor w
- entry .os.sopts.s8.e -width $ewidth -textvariable tko_paragraphs \
- -relief raised
- pack append .os.sopts.s8 \
- .os.sopts.s8.l {left} .os.sopts.s8.e {left frame w}
-
- frame .os.sopts.s9
- label .os.sopts.s9.l -text "print:" -width $lwidth -anchor w
- entry .os.sopts.s9.e -width $ewidth -textvariable tko_print \
- -relief raised
- pack append .os.sopts.s9 \
- .os.sopts.s9.l {left} .os.sopts.s9.e {left frame w}
-
- frame .os.sopts.s10
- label .os.sopts.s10.l -text "recdir:" -width $lwidth -anchor w
- entry .os.sopts.s10.e -width $ewidth -textvariable tko_recdir \
- -relief raised
- pack append .os.sopts.s10 \
- .os.sopts.s10.l {left} .os.sopts.s10.e {left frame w}
-
- frame .os.sopts.s11
- label .os.sopts.s11.l -text "sections:" -width $lwidth -anchor w
- entry .os.sopts.s11.e -width $ewidth -textvariable tko_sections \
- -relief raised
- pack append .os.sopts.s11 \
- .os.sopts.s11.l {left} .os.sopts.s11.e {left frame w}
-
- frame .os.sopts.s12
- label .os.sopts.s12.l -text "shell:" -width $lwidth -anchor w
- entry .os.sopts.s12.e -width $ewidth -textvariable tko_shell \
- -relief raised
- pack append .os.sopts.s12 \
- .os.sopts.s12.l {left} .os.sopts.s12.e {left frame w}
-
- frame .os.sopts.s13
- label .os.sopts.s13.l -text "shellmeta:" -width $lwidth -anchor w
- entry .os.sopts.s13.e -width $ewidth -textvariable tko_shellmeta \
- -relief raised
- pack append .os.sopts.s13 \
- .os.sopts.s13.l {left} .os.sopts.s13.e {left frame w}
-
- frame .os.sopts.s14
- label .os.sopts.s14.l -text "tags:" -width $lwidth -anchor w
- entry .os.sopts.s14.e -width $ewidth -textvariable tko_tags \
- -relief raised
- pack append .os.sopts.s14 \
- .os.sopts.s14.l {left} .os.sopts.s14.e {left frame w}
-
- frame .os.sopts.s15
- label .os.sopts.s15.l -text "term:" -width $lwidth -anchor w
- entry .os.sopts.s15.e -width $ewidth -textvariable tko_term \
- -relief raised
- pack append .os.sopts.s15 \
- .os.sopts.s15.l {left} .os.sopts.s15.e {left frame w}
-
- pack append .os.sopts \
- .os.sopts.s1 {top expand fillx} \
- .os.sopts.s2 {top expand fillx} \
- .os.sopts.s3 {top expand fillx} \
- .os.sopts.s4 {top expand fillx} \
- .os.sopts.s5 {top expand fillx} \
- .os.sopts.s6 {top expand fillx} \
- .os.sopts.s7 {top expand fillx} \
- .os.sopts.s8 {top expand fillx} \
- .os.sopts.s9 {top expand fillx} \
- .os.sopts.s10 {top expand fillx} \
- .os.sopts.s11 {top expand fillx} \
- .os.sopts.s12 {top expand fillx} \
- .os.sopts.s13 {top expand fillx} \
- .os.sopts.s14 {top expand fillx} \
- .os.sopts.s15 {top expand fillx}
-
- # Build frame for continue button.
- frame .os.control -bd 4
- button .os.control.quit -text "Continue" -command "destroy .os"
- bind .os <Return> ".os.control.quit flash; destroy .os"
- pack append .os.control .os.control.quit {left}
-
- # Pack everything together.
- pack append .os \
- .os.bopts {top} \
- .os.control {bottom fillx} \
- .os.nopts {left fillx padx 4m pady 4m} \
- .os.sopts {left fillx pady 4m}
-
- grab .os
- focus .os
-}
-
-# tk_opt_ew --
-# Handle a change to an option entry widget.
-proc tk_opt_ew {name element op} {
- upvar $name x
- tk_opt_set "$name=$x"
-}
-
-# tk_err --
-# Display a Tcl/Tk error message.
-proc tk_err {msg} {
- tk_dialog .d {} "$msg" {} 0 Continue
-
- #puts "msg: $msg"
-}
-
-# tk_addstr --
-# Add a string to the screen.
-proc tk_addstr {len str} {
- global tk_cursor_row
- global tk_cursor_col
-
- # Delete the current characters, then insert the new ones.
- .t mark set insert $tk_cursor_row.$tk_cursor_col
- .t delete insert "insert + $len chars"
- .t insert insert "$str"
- incr tk_cursor_col $len
-
- #puts "tk_addstr: row $tk_cursor_row col $tk_cursor_col: insert $str"
-}
-
-# tk_clrtoeol --
-# Clear to the end of the line.
-proc tk_clrtoeol {} {
- global tk_cursor_row
- global tk_cursor_col
- global tk_ssize_col
-
- # Overwrite to the end of the line with spaces.
- .t mark set insert $tk_cursor_row.$tk_cursor_col
- .t delete insert "insert lineend"
- for {set j $tk_cursor_col} {$j < $tk_ssize_col} {incr j} {
- .t insert insert " "
- }
-
- #puts "tk_clrtoel: row $tk_cursor_row col $tk_cursor_col"
-}
-
-# tk_deleteln --
-# Delete the line.
-proc tk_deleteln {} {
- global tk_cursor_row
- global tk_cursor_col
- global tk_ssize_col
-
- # Delete the line.
- .t mark set insert $tk_cursor_row.$tk_cursor_col
- .t delete insert "insert lineend + 1 chars"
-
- # Append a new, blank line at the end of the screen.
- .t mark set insert end
- for {set j 1} {$j <= $tk_ssize_col} {incr j} {
- .t insert insert " "
- }
- .t insert insert "\n"
-
- #puts "tk_deleteln: row $tk_cursor_row"
-}
-
-# tk_flash --
-# Flash the screen.
-proc tk_flash {} {
- set bg [lindex [.t config -background] 4]
- set fg [lindex [.t config -foreground] 4]
- .t configure -background $fg -foreground $bg
- update idletasks
- .t configure -background $bg -foreground $fg
- update idletasks
-}
-
-# tk_insertln --
-# Insert the line.
-proc tk_insertln {} {
- global tk_cursor_row
- global tk_cursor_col
- global tk_ssize_row
- global tk_ssize_col
-
- # Delete the last line on the screen.
- .t mark set insert $tk_ssize_row.0
- .t delete insert "insert lineend + 1 chars"
-
- # Insert a new, blank line.
- .t mark set insert $tk_cursor_row.$tk_cursor_col
- for {set j 1} {$j <= $tk_ssize_col} {incr j} {
- .t insert insert " "
- }
- .t insert insert "\n"
-
- #puts "tk_insertln: row $tk_cursor_row"
-}
-
-# tk_move --
-# Move the cursor.
-proc tk_move {row col} {
- global tk_cursor_row
- global tk_cursor_col
-
- # Convert to Tcl/Tk coordinates, update the insert cursor.
- set tk_cursor_row [ expr $row + 1 ]
- set tk_cursor_col $col
- .t mark set insert $tk_cursor_row.$tk_cursor_col
-
- # Update the screen cursor.
- .t tag remove tk_cursor tk_cursor_indx
- .t mark set tk_cursor_indx insert
- .t tag add tk_cursor tk_cursor_indx
-
- #puts "tk_move: row $tk_cursor_row col $tk_cursor_col"
-}
-
-# tk_rename --
-# Rename the screen.
-proc tk_rename {name} {
- wm title . "$name"
-}
-
-# tk_ssize --
-# Return the window size.
-proc tk_ssize {} {
- global tk_ssize_col
- global tk_ssize_row
-
- set s [ .t configure -width ]
- set tk_ssize_col [ lindex $s [ expr [ llength $s ] -1 ] ]
- set s [ .t configure -height ]
- set tk_ssize_row [ lindex $s [ expr [ llength $s ] -1 ] ]
-
- #puts "tk_ssize: rows $tk_ssize_row, cols $tk_ssize_col"
-}
-
-# tk_standout --
-# Change into standout mode.
-proc tk_standout {} {
-}
-
-# tk_standend --
-# Change out of standout mode.
-proc tk_standend {} {
-}
-
-# Cursor
-set tk_cursor_row 1
-set tk_cursor_col 0
-
-# Screen size
-set tk_ssize_row 0
-set tk_ssize_col 0
-
-screen
-#tkwait window .
diff --git a/tk/tk_funcs.c b/tk/tk_funcs.c
deleted file mode 100644
index be2b0d96ea09..000000000000
--- a/tk/tk_funcs.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)tk_funcs.c 8.11 (Berkeley) 9/23/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "../vi/vi.h"
-#include "tki.h"
-
-/*
- * tk_addstr --
- * Add len bytes from the string at the cursor, advancing the cursor.
- *
- * PUBLIC: int tk_addstr __P((SCR *, const char *, size_t));
- */
-int
-tk_addstr(sp, str, len)
- SCR *sp;
- const char *str;
- size_t len;
-{
- TK_PRIVATE *tkp;
- int iv;
- char buf[20];
-
- iv = 0;
-
- tkp = TKP(sp);
- if (iv)
- (void)Tcl_Eval(tkp->interp, "tk_standout");
-
- (void)snprintf(buf, sizeof(buf), "%d ", (int)len);
- if ((Tcl_VarEval(tkp->interp,
- "tk_addstr ", buf, "{", str, "}", NULL) != TCL_OK))
- return (1);
-
- if (iv)
- (void)Tcl_Eval(tkp->interp, "tk_standend");
- return (0);
-}
-
-/*
- * tk_attr --
- * Toggle a screen attribute on/off.
- *
- * PUBLIC: int tk_attr __P((SCR *, scr_attr_t, int));
- */
-int
-tk_attr(sp, attribute, on)
- SCR *sp;
- scr_attr_t attribute;
- int on;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
- switch (attribute) {
- case SA_ALTERNATE: /* No alternate screen. */
- break;
- case SA_INVERSE:
- if (on)
- (void)Tcl_Eval(tkp->interp, "tk_standout");
- else
- (void)Tcl_Eval(tkp->interp, "tk_standend");
- break;
- default:
- abort();
- }
- return (0);
-}
-
-/*
- * tk_baud --
- * Return the baud rate.
- *
- * PUBLIC: int tk_baud __P((SCR *, u_long *));
- */
-int
-tk_baud(sp, ratep)
- SCR *sp;
- u_long *ratep;
-{
- *ratep = 9600;
- return (0);
-}
-
-/*
- * tk_bell --
- * Ring the bell/flash the screen.
- *
- * PUBLIC: int tk_bell __P((SCR *));
- */
-int
-tk_bell(sp)
- SCR *sp;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
- return (Tcl_Eval(tkp->interp, "tk_flash") != TCL_OK);
-}
-
-/*
- * tk_clrtoeol --
- * Clear from the current cursor to the end of the line.
- *
- * PUBLIC: int tk_clrtoeol __P((SCR *));
- */
-int
-tk_clrtoeol(sp)
- SCR *sp;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
- return (Tcl_Eval(tkp->interp, "tk_clrtoeol") != TCL_OK);
-}
-
-/*
- * tk_cursor --
- * Return the current cursor position.
- *
- * PUBLIC: int tk_cursor __P((SCR *, size_t *, size_t *));
- */
-int
-tk_cursor(sp, yp, xp)
- SCR *sp;
- size_t *yp, *xp;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
- *yp = (tkp->tk_cursor_row - 1) - sp->woff;
- *xp = tkp->tk_cursor_col;
- return (0);
-}
-
-/*
- * tk_deleteln --
- * Delete the current line, scrolling all lines below it.
- *
- * PUBLIC: int tk_deleteln __P((SCR *));
- */
-int
-tk_deleteln(sp)
- SCR *sp;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
- return (Tcl_Eval(tkp->interp, "tk_deleteln") != TCL_OK);
-}
-
-/*
- * tk_ex_adjust --
- * Adjust the screen for ex.
- *
- * PUBLIC: int tk_ex_adjust __P((SCR *, exadj_t));
- */
-int
-tk_ex_adjust(sp, action)
- SCR *sp;
- exadj_t action;
-{
- abort();
- /* NOTREACHED */
-}
-
-/*
- * tk_insertln --
- * Push down the current line, discarding the bottom line.
- *
- * PUBLIC: int tk_insertln __P((SCR *));
- */
-int
-tk_insertln(sp)
- SCR *sp;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
- return (Tcl_Eval(tkp->interp, "tk_insertln") != TCL_OK);
-}
-
-/*
- * tk_keyval --
- * Return the value for a special key.
- *
- * PUBLIC: int tk_keyval __P((SCR *, scr_keyval_t, CHAR_T *, int *));
- */
-int
-tk_keyval(sp, val, chp, dnep)
- SCR *sp;
- scr_keyval_t val;
- CHAR_T *chp;
- int *dnep;
-{
- TK_PRIVATE *tkp;
-
- /*
- * VEOF, VERASE and VKILL are required by POSIX 1003.1-1990,
- * VWERASE is a 4BSD extension.
- */
- tkp = TKP(sp);
- switch (val) {
- case KEY_VEOF:
- *dnep = (*chp = tkp->orig.c_cc[VEOF]) == _POSIX_VDISABLE;
- break;
- case KEY_VERASE:
- *dnep = (*chp = tkp->orig.c_cc[VERASE]) == _POSIX_VDISABLE;
- break;
- case KEY_VKILL:
- *dnep = (*chp = tkp->orig.c_cc[VKILL]) == _POSIX_VDISABLE;
- break;
-#ifdef VWERASE
- case KEY_VWERASE:
- *dnep = (*chp = tkp->orig.c_cc[VWERASE]) == _POSIX_VDISABLE;
- break;
-#endif
- default:
- *dnep = 1;
- break;
- }
- return (0);
-}
-
-/*
- * tk_move --
- * Move the cursor.
- *
- * PUBLIC: int tk_move __P((SCR *, size_t, size_t));
- */
-int
-tk_move(sp, lno, cno)
- SCR *sp;
- size_t lno, cno;
-{
- TK_PRIVATE *tkp;
- char buf[40];
-
- (void)snprintf(buf, sizeof(buf), "%d %d", RLNO(sp, lno), cno);
-
- tkp = TKP(sp);
- return (Tcl_VarEval(tkp->interp, "tk_move ", buf, NULL) != TCL_OK);
-}
-
-/*
- * tk_refresh --
- * Refresh the screen.
- *
- * PUBLIC: int tk_refresh __P((SCR *, int));
- */
-int
-tk_refresh(sp, repaint)
- SCR *sp;
- int repaint;
-{
- TK_PRIVATE *tkp;
-
- /*
- * If repaint is set, the editor is telling us that we don't know
- * what's on the screen, so we have to repaint from scratch.
- *
- * XXX
- * I have no idea how to do this in Tk. My guess is that we have
- * to delete all of the text and call the editor with an E_REPAINT
- * event.
- */
- if (repaint) {
- }
-
- tkp = TKP(sp);
- return (Tcl_Eval(tkp->interp, "update idletasks") != TCL_OK);
-}
-
-/*
- * tk_rename --
- * Rename the file.
- *
- * PUBLIC: int tk_rename __P((SCR *));
- */
-int
-tk_rename(sp)
- SCR *sp;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
- return (Tcl_VarEval(tkp->interp,
- "tk_rename ", sp->frp->name, NULL) != TCL_OK);
-}
-
-/*
- * tk_suspend --
- * Suspend a screen.
- *
- * PUBLIC: int tk_suspend __P((SCR *, int *));
- */
-int
-tk_suspend(sp, allowedp)
- SCR *sp;
- int *allowedp;
-{
- *allowedp = 0;
- return (0);
-}
-
-/*
- * tk_usage --
- * Print out the Tk/Tcl usage messages.
- *
- * PUBLIC: void tk_usage __P((void));
- */
-void
-tk_usage()
-{
-#define USAGE "\
-usage: tkvi [-eFlRrSv] [-c command] [-bg color] [-fg color]\n\
- [-geometry widthxheight+x+y] [-i script] [-t tag] [-w size]\n\
- [file ...]\n"
- (void)fprintf(stderr, "%s", USAGE);
-#undef USAGE
-}
diff --git a/tk/tk_main.c b/tk/tk_main.c
deleted file mode 100644
index c2f34e7b2d9f..000000000000
--- a/tk/tk_main.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)tk_main.c 8.18 (Berkeley) 9/24/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "tki.h"
-#include "pathnames.h"
-
-GS *__global_list; /* GLOBAL: List of screens. */
-sigset_t __sigblockset; /* GLOBAL: Blocked signals. */
-
-static GS *gs_init __P((char *));
-static void killsig __P((SCR *));
-static void perr __P((char *, char *));
-static void sig_end __P((GS *));
-static int sig_init __P((GS *));
-static int tcl_init __P((GS *));
-static void tcl_err __P((TK_PRIVATE *));
-
-/*
- * main --
- * This is the main loop for the standalone Tcl/Tk editor.
- */
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- static int reenter;
- GS *gp;
- TK_PRIVATE *tkp;
- size_t rows, cols;
- int rval;
- char **p_av, **t_av, *script;
-
- /* If loaded at 0 and jumping through a NULL pointer, stop. */
- if (reenter++)
- abort();
-
- /* Create and initialize the global structure. */
- __global_list = gp = gs_init(argv[0]);
-
- /* Initialize Tk/Tcl. */
- if (tcl_init(gp))
- exit (1);
-
- /*
- * Strip out any arguments that the common editor doesn't understand
- * (i.e. the Tk/Tcl arguments). Search for -i first, it's the Tk/Tcl
- * startup script and needs to be run first.
- *
- * XXX
- * There's no way to portably call getopt twice.
- */
- script = "init.tcl";
- for (p_av = t_av = argv;;) {
- if (*t_av == NULL) {
- *p_av = NULL;
- break;
- }
- if (!strcmp(*t_av, "--")) {
- while ((*p_av++ = *t_av++) != NULL);
- break;
- }
- if (!memcmp(*t_av, "-i", sizeof("-i") - 1)) {
- if (t_av[0][2] != '\0') {
- script = t_av[0] + 2;
- ++t_av;
- --argc;
- continue;
- }
- if (t_av[1] != NULL) {
- script = t_av[1];
- t_av += 2;
- argc -= 2;
- continue;
- }
- }
- *p_av++ = *t_av++;
- }
- for (p_av = t_av = argv;;) {
- if (*t_av == NULL) {
- *p_av = NULL;
- break;
- }
- if (!strcmp(*t_av, "--")) {
- while ((*p_av++ = *t_av++) != NULL);
- break;
- }
- if (t_av[1] != NULL &&
- (!memcmp(*t_av, "-background", sizeof("-background") - 1) ||
- !memcmp(*t_av, "-bg", sizeof("-bg") - 1) ||
- !memcmp(*t_av, "-borderwidth", sizeof("-borderwidth") - 1)||
- !memcmp(*t_av, "-bd", sizeof("-bd") - 1) ||
- !memcmp(*t_av, "-foreground", sizeof("-foreground") - 1) ||
- !memcmp(*t_av, "-fg", sizeof("-fg") - 1) ||
- !memcmp(*t_av, "-font", sizeof("-font") - 1))) {
- if (Tcl_VarEval(tkp->interp, ".t configure ",
- t_av[0], " ", t_av[1], NULL) == TCL_ERROR)
- tcl_err(tkp);
- t_av += 2;
- argc -= 2;
- continue;
- }
- if (!memcmp(*t_av, "-geometry", sizeof("-geometry") - 1)) {
- if (Tcl_VarEval(tkp->interp, "wm geometry . ",
- *t_av + sizeof("-geometry") - 1, NULL) == TCL_ERROR)
- tcl_err(tkp);
- ++t_av;
- --argc;
- continue;
- }
- *p_av++ = *t_av++;
- }
-
- /* Load the initial Tcl/Tk script. */
- tkp = GTKP(gp);
- if (Tcl_EvalFile(tkp->interp, script) == TCL_ERROR)
- tcl_err(tkp);
-
- /* Add the terminal type to the global structure. */
- if ((OG_D_STR(gp, GO_TERM) =
- OG_STR(gp, GO_TERM) = strdup("tkterm")) == NULL)
- perr(gp->progname, NULL);
-
- /* Figure out how big the screen is. */
- if (tk_ssize(NULL, 0, &rows, &cols, NULL))
- exit (1);
-
- /* Add the rows and columns to the global structure. */
- OG_VAL(gp, GO_LINES) = OG_D_VAL(gp, GO_LINES) = rows;
- OG_VAL(gp, GO_COLUMNS) = OG_D_VAL(gp, GO_COLUMNS) = cols;
-
- /* Start catching signals. */
- if (sig_init(gp))
- exit (1);
-
- /* Run ex/vi. */
- rval = editor(gp, argc, argv);
-
- /* Clean up signals. */
- sig_end(gp);
-
- /* Clean up the terminal. */
- (void)tk_quit(gp);
-
- /* If a killer signal arrived, pretend we just got it. */
- if (tkp->killersig) {
- (void)signal(tkp->killersig, SIG_DFL);
- (void)kill(getpid(), tkp->killersig);
- /* NOTREACHED */
- }
-
- /* Free the global and TK private areas. */
-#if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY)
- free(tkp);
- free(gp);
-#endif
-
- exit (rval);
-}
-
-/*
- * gs_init --
- * Create and partially initialize the GS structure.
- */
-static GS *
-gs_init(name)
- char *name;
-{
- TK_PRIVATE *tkp;
- GS *gp;
- int fd;
- char *p;
-
- /* Figure out what our name is. */
- if ((p = strrchr(name, '/')) != NULL)
- name = p + 1;
-
- /* Allocate the global structure. */
- CALLOC_NOMSG(NULL, gp, GS *, 1, sizeof(GS));
-
- /* Allocate the CL private structure. */
- if (gp != NULL)
- CALLOC_NOMSG(NULL, tkp, TK_PRIVATE *, 1, sizeof(TK_PRIVATE));
- if (gp == NULL || tkp == NULL)
- perr(name, NULL);
- gp->tk_private = tkp;
- TAILQ_INIT(&tkp->evq);
-
- /* Initialize the list of curses functions. */
- gp->scr_addstr = tk_addstr;
- gp->scr_attr = tk_attr;
- gp->scr_baud = tk_baud;
- gp->scr_bell = tk_bell;
- gp->scr_busy = NULL;
- gp->scr_clrtoeol = tk_clrtoeol;
- gp->scr_cursor = tk_cursor;
- gp->scr_deleteln = tk_deleteln;
- gp->scr_event = tk_event;
- gp->scr_ex_adjust = tk_ex_adjust;
- gp->scr_fmap = tk_fmap;
- gp->scr_insertln = tk_insertln;
- gp->scr_keyval = tk_keyval;
- gp->scr_move = tk_move;
- gp->scr_msg = NULL;
- gp->scr_optchange = tk_optchange;
- gp->scr_refresh = tk_refresh;
- gp->scr_rename = tk_rename;
- gp->scr_screen = tk_screen;
- gp->scr_suspend = tk_suspend;
- gp->scr_usage = tk_usage;
-
- /*
- * We expect that if we've lost our controlling terminal that the
- * open() (but not the tcgetattr()) will fail.
- */
- if (isatty(STDIN_FILENO)) {
- if (tcgetattr(STDIN_FILENO, &tkp->orig) == -1)
- goto tcfail;
- } else if ((fd = open(_PATH_TTY, O_RDONLY, 0)) != -1) {
- if (tcgetattr(fd, &tkp->orig) == -1)
-tcfail: perr(name, "tcgetattr");
- (void)close(fd);
- }
-
- gp->progname = name;
- return (gp);
-}
-
-/*
- * tcl_init --
- * Get Tcl/Tk up and running.
- */
-static int
-tcl_init(gp)
- GS *gp;
-{
- TK_PRIVATE *tkp;
-
- tkp = GTKP(gp);
- if ((tkp->interp = Tcl_CreateInterp()) == NULL)
- tcl_err(tkp);
- /* XXX: Tk 4.1 has an incompatible change. */
-#if (TK_MAJOR_VERSION == 4) && (TK_MINOR_VERSION == 0)
- if (Tk_CreateMainWindow(tkp->interp, NULL, "vi", "Vi") == NULL)
- tcl_err(tkp);
-#endif
- if (Tcl_Init(tkp->interp) == TCL_ERROR)
- tcl_err(tkp);
- if (Tk_Init(tkp->interp) == TCL_ERROR)
- tcl_err(tkp);
-
- /* Shared variables. */
- (void)Tcl_LinkVar(tkp->interp,
- "tk_cursor_row", (char *)&tkp->tk_cursor_row, TCL_LINK_INT);
- (void)Tcl_LinkVar(tkp->interp,
- "tk_cursor_col", (char *)&tkp->tk_cursor_col, TCL_LINK_INT);
- (void)Tcl_LinkVar(tkp->interp,
- "tk_ssize_row", (char *)&tkp->tk_ssize_row, TCL_LINK_INT);
- (void)Tcl_LinkVar(tkp->interp,
- "tk_ssize_col", (char *)&tkp->tk_ssize_col, TCL_LINK_INT);
-
- /* Functions called by Tcl script. */
- Tcl_CreateCommand(tkp->interp, "tk_key", tk_key, tkp, NULL);
- Tcl_CreateCommand(tkp->interp, "tk_op", tk_op, tkp, NULL);
- Tcl_CreateCommand(tkp->interp, "tk_opt_init", tk_opt_init, tkp, NULL);
- Tcl_CreateCommand(tkp->interp, "tk_opt_set", tk_opt_set, tkp, NULL);
- Tcl_CreateCommand(tkp->interp, "tk_version", tk_version, tkp, NULL);
-
- /* Other initialization. */
- if (Tcl_Eval(tkp->interp, "wm geometry . =80x28+0+0") == TCL_ERROR)
- tcl_err(tkp);
- return (0);
-}
-
-/*
- * tcl_err --
- * Tcl/Tk error message during initialization.
- */
-static void
-tcl_err(tkp)
- TK_PRIVATE *tkp;
-{
- (void)fprintf(stderr, "%s\n", tkp->interp->result != NULL ?
- tkp->interp->result : "Tcl/Tk: initialization error");
- (void)tk_usage();
- exit (1);
-}
-
-#define GLOBAL_TKP \
- TK_PRIVATE *tkp = GTKP(__global_list);
-static void
-h_hup(signo)
- int signo;
-{
- GLOBAL_TKP;
-
- F_SET(tkp, TK_SIGHUP);
- tkp->killersig = SIGHUP;
-}
-
-static void
-h_int(signo)
- int signo;
-{
- GLOBAL_TKP;
-
- F_SET(tkp, TK_SIGINT);
-}
-
-static void
-h_term(signo)
- int signo;
-{
- GLOBAL_TKP;
-
- F_SET(tkp, TK_SIGTERM);
- tkp->killersig = SIGTERM;
-}
-
-static void
-h_winch(signo)
- int signo;
-{
- GLOBAL_TKP;
-
- F_SET(tkp, TK_SIGWINCH);
-}
-#undef GLOBAL_TKP
-
-/*
- * sig_init --
- * Initialize signals.
- */
-static int
-sig_init(gp)
- GS *gp;
-{
- TK_PRIVATE *tkp;
- struct sigaction act;
-
- tkp = GTKP(gp);
-
- (void)sigemptyset(&__sigblockset);
-
- /*
- * Use sigaction(2), not signal(3), since we don't always want to
- * restart system calls. The example is when waiting for a command
- * mode keystroke and SIGWINCH arrives. Besides, you can't portably
- * restart system calls (thanks, POSIX!).
- */
-#define SETSIG(signal, handler, off) { \
- if (sigaddset(&__sigblockset, signal)) \
- goto err; \
- act.sa_handler = handler; \
- sigemptyset(&act.sa_mask); \
- act.sa_flags = 0; \
- if (sigaction(signal, &act, &tkp->oact[off])) \
- goto err; \
-}
-#undef SETSIG
- return (0);
-
-err: perr(gp->progname, NULL);
- return (1);
-}
-
-/*
- * sig_end --
- * End signal setup.
- */
-static void
-sig_end(gp)
- GS *gp;
-{
- TK_PRIVATE *tkp;
-
- tkp = GTKP(gp);
- (void)sigaction(SIGHUP, NULL, &tkp->oact[INDX_HUP]);
- (void)sigaction(SIGINT, NULL, &tkp->oact[INDX_INT]);
- (void)sigaction(SIGTERM, NULL, &tkp->oact[INDX_TERM]);
- (void)sigaction(SIGWINCH, NULL, &tkp->oact[INDX_WINCH]);
-}
-
-/*
- * perr --
- * Print system error.
- */
-static void
-perr(name, msg)
- char *name, *msg;
-{
- (void)fprintf(stderr, "%s:", name);
- if (msg != NULL)
- (void)fprintf(stderr, "%s:", msg);
- (void)fprintf(stderr, "%s\n", strerror(errno));
- exit(1);
-}
diff --git a/tk/tk_read.c b/tk/tk_read.c
deleted file mode 100644
index b5cfab71c7e2..000000000000
--- a/tk/tk_read.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)tk_read.c 8.12 (Berkeley) 9/24/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "../ex/script.h"
-#include "tki.h"
-
-static input_t tk_read __P((SCR *, int));
-static int tk_resize __P((SCR *, size_t, size_t));
-
-
-/*
- * tk_event --
- * Return a single event.
- *
- * PUBLIC: int tk_event __P((SCR *, EVENT *, u_int32_t, int));
- */
-int
-tk_event(sp, evp, flags, timeout)
- SCR *sp;
- EVENT *evp;
- u_int32_t flags;
- int timeout;
-{
- EVENT *tevp;
- TK_PRIVATE *tkp;
- size_t lines, columns;
- int changed;
-
- /*
- * Queue signal based events. We never clear SIGHUP or SIGTERM events,
- * so that we just keep returning them until the editor dies.
- */
- tkp = TKP(sp);
-sig: if (LF_ISSET(EC_INTERRUPT) || F_ISSET(tkp, TK_SIGINT)) {
- if (F_ISSET(tkp, TK_SIGINT)) {
- F_CLR(tkp, TK_SIGINT);
- evp->e_event = E_INTERRUPT;
- } else
- evp->e_event = E_TIMEOUT;
- return (0);
- }
- if (F_ISSET(tkp, TK_SIGHUP | TK_SIGTERM | TK_SIGWINCH)) {
- if (F_ISSET(tkp, TK_SIGHUP)) {
- evp->e_event = E_SIGHUP;
- return (0);
- }
- if (F_ISSET(tkp, TK_SIGTERM)) {
- evp->e_event = E_SIGTERM;
- return (0);
- }
- if (F_ISSET(tkp, TK_SIGWINCH)) {
- F_CLR(tkp, TK_SIGWINCH);
- (void)tk_ssize(sp, 1, &lines, &columns, &changed);
- if (changed) {
- (void)tk_resize(sp, lines, columns);
- evp->e_event = E_WRESIZE;
- return (0);
- }
- /* No change, so ignore the signal. */
- }
- }
-
- /* Queue special ops. */
-ops: if ((tevp = tkp->evq.tqh_first) != NULL) {
- *evp = *tevp;
- TAILQ_REMOVE(&tkp->evq, tevp, q);
- free(tevp);
- return (0);
- }
-
- /* Read input characters. */
- switch (tk_read(sp, timeout)) {
- case INP_OK:
- evp->e_csp = tkp->ibuf;
- evp->e_len = tkp->ibuf_cnt;
- evp->e_event = E_STRING;
- tkp->ibuf_cnt = 0;
- break;
- case INP_EOF:
- evp->e_event = E_EOF;
- break;
- case INP_ERR:
- evp->e_event = E_ERR;
- break;
- case INP_INTR:
- goto sig;
- break;
- case INP_TIMEOUT:
- /* May have returned because queued a special op. */
- if (tkp->evq.tqh_first != NULL)
- goto ops;
-
- /* Otherwise, we timed out. */
- evp->e_event = E_TIMEOUT;
- break;
- default:
- abort();
- }
- return (0);
-}
-
-/*
- * tk_read --
- * Read characters from the input.
- */
-static input_t
-tk_read(sp, timeout)
- SCR *sp;
- int timeout;
-{
- TK_PRIVATE *tkp;
- char buf[20];
-
- /*
- * Check scripting window file descriptors. It's ugly that we wait
- * on scripting file descriptors here, but it's the only way to keep
- * from locking out scripting windows.
- */
- if (F_ISSET(sp->gp, G_SCRWIN) && sscr_input(sp))
- return (INP_ERR);
-
- /* Read characters. */
- tkp = TKP(sp);
- (void)snprintf(buf, sizeof(buf), "%d", timeout);
- (void)Tcl_VarEval(tkp->interp, "tk_key_wait ", buf, NULL);
-
- return (tkp->ibuf_cnt == 0 ? INP_TIMEOUT : INP_OK);
-}
-
-/*
- * tk_key --
- * Receive an input key.
- *
- * PUBLIC: int tk_key __P((ClientData, Tcl_Interp *, int, char *[]));
- */
-int
-tk_key(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char *argv[];
-{
- TK_PRIVATE *tkp;
- u_int8_t *p, *t;
-
- tkp = (TK_PRIVATE *)clientData;
- for (p =
- tkp->ibuf + tkp->ibuf_cnt, t = argv[1]; (*p++ = *t++) != '\0';
- ++tkp->ibuf_cnt);
- return (TCL_OK);
-}
-
-/*
- * tk_resize --
- * Reset the options for a resize event.
- */
-static int
-tk_resize(sp, lines, columns)
- SCR *sp;
- size_t lines, columns;
-{
- ARGS *argv[2], a, b;
- int rval;
- char b1[1024];
-
- a.bp = b1;
- b.bp = NULL;
- a.len = b.len = 0;
- argv[0] = &a;
- argv[1] = &b;
-
- (void)snprintf(b1, sizeof(b1), "lines=%lu", (u_long)lines);
- a.len = strlen(b1);
- if (opts_set(sp, argv, NULL))
- return (1);
- (void)snprintf(b1, sizeof(b1), "columns=%lu", (u_long)columns);
- a.len = strlen(b1);
- if (opts_set(sp, argv, NULL))
- return (1);
- return (0);
-}
diff --git a/tk/tk_screen.c b/tk/tk_screen.c
deleted file mode 100644
index e1090930ba23..000000000000
--- a/tk/tk_screen.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)tk_screen.c 8.9 (Berkeley) 5/24/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "tki.h"
-
-/*
- * tk_screen --
- * Initialize/shutdown the Tcl/Tk screen.
- *
- * PUBLIC: int tk_screen __P((SCR *, u_int32_t));
- */
-int
-tk_screen(sp, flags)
- SCR *sp;
- u_int32_t flags;
-{
- TK_PRIVATE *tkp;
-
- tkp = TKP(sp);
-
- /* See if we're already in the right mode. */
- if (LF_ISSET(SC_VI) && F_ISSET(sp, SC_SCR_VI))
- return (0);
-
- /* Ex isn't possible. */
- if (LF_ISSET(SC_EX))
- return (1);
-
- /* Initialize terminal based information. */
- if (tk_term_init(sp))
- return (1);
-
- /* Put up the first file name. */
- if (tk_rename(sp))
- return (1);
-
- F_SET(tkp, TK_SCR_VI_INIT);
- return (0);
-}
-
-/*
- * tk_quit --
- * Shutdown the screens.
- *
- * PUBLIC: int tk_quit __P((GS *));
- */
-int
-tk_quit(gp)
- GS *gp;
-{
- TK_PRIVATE *tkp;
- int rval;
-
- /* Clean up the terminal mappings. */
- rval = tk_term_end(gp);
-
- tkp = GTKP(gp);
- F_CLR(tkp, TK_SCR_VI_INIT);
-
- return (rval);
-}
diff --git a/tk/tk_term.c b/tk/tk_term.c
deleted file mode 100644
index 18299a28ae77..000000000000
--- a/tk/tk_term.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)tk_term.c 8.12 (Berkeley) 10/13/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <errno.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "tki.h"
-
-/*
- * tk_term_init --
- * Initialize the terminal special keys.
- *
- * PUBLIC: int tk_term_init __P((SCR *));
- */
-int
-tk_term_init(sp)
- SCR *sp;
-{
- SEQ *qp;
-
- /*
- * Rework any function key mappings that were set before the
- * screen was initialized.
- */
- for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next)
- if (F_ISSET(qp, SEQ_FUNCMAP))
- (void)tk_fmap(sp, qp->stype,
- qp->input, qp->ilen, qp->output, qp->olen);
- return (0);
-}
-
-/*
- * tk_term_end --
- * End the special keys defined by the termcap/terminfo entry.
- *
- * PUBLIC: int tk_term_end __P((GS *));
- */
-int
-tk_term_end(gp)
- GS *gp;
-{
- SEQ *qp, *nqp;
-
- /* Delete screen specific mappings. */
- for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
- nqp = qp->q.le_next;
- if (F_ISSET(qp, SEQ_SCREEN))
- (void)seq_mdel(qp);
- }
- return (0);
-}
-
-/*
- * tk_fmap --
- * Map a function key.
- *
- * PUBLIC: int tk_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
- */
-int
-tk_fmap(sp, stype, from, flen, to, tlen)
- SCR *sp;
- seq_t stype;
- CHAR_T *from, *to;
- size_t flen, tlen;
-{
- VI_INIT_IGNORE(sp);
-
- /* Bind a Tk/Tcl function key to a string sequence. */
- return (0);
-}
-
-/*
- * tk_optchange --
- * Curses screen specific "option changed" routine.
- *
- * PUBLIC: int tk_optchange __P((SCR *, int, char *, u_long *));
- */
-int
-tk_optchange(sp, opt, str, valp)
- SCR *sp;
- int opt;
- char *str;
- u_long *valp;
-{
- switch (opt) {
- case O_COLUMNS:
- case O_LINES:
- /*
- * Changing the columns or lines require that we restart
- * the screen.
- */
- F_SET(sp->gp, G_SRESTART);
- F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
- break;
- case O_TERM:
- msgq(sp, M_ERR, "The screen type may not be changed");
- return (1);
- }
- return (0);
-}
-
-/*
- * tk_ssize --
- * Return the window size.
- *
- * PUBLIC: int tk_ssize __P((SCR *, int, size_t *, size_t *, int *));
- */
-int
-tk_ssize(sp, sigwinch, rowp, colp, changedp)
- SCR *sp;
- int sigwinch;
- size_t *rowp, *colp;
- int *changedp;
-{
- TK_PRIVATE *tkp;
-
- tkp = GTKP(__global_list);
- (void)Tcl_Eval(tkp->interp, "tk_ssize");
-
- /*
- * SunOS systems deliver SIGWINCH when windows are uncovered
- * as well as when they change size. In addition, we call
- * here when continuing after being suspended since the window
- * may have changed size. Since we don't want to background
- * all of the screens just because the window was uncovered,
- * ignore the signal if there's no change.
- *
- * !!!
- * sp may be NULL.
- */
- if (sigwinch && sp != NULL &&
- tkp->tk_ssize_row == O_VAL(sp, O_LINES) &&
- tkp->tk_ssize_col == O_VAL(sp, O_COLUMNS)) {
- if (changedp != NULL)
- *changedp = 0;
- return (0);
- }
-
- if (rowp != NULL)
- *rowp = tkp->tk_ssize_row;
- if (colp != NULL)
- *colp = tkp->tk_ssize_col;
- if (changedp != NULL)
- *changedp = 1;
- return (0);
-}
diff --git a/tk/tk_util.c b/tk/tk_util.c
deleted file mode 100644
index 096fa7bb3eba..000000000000
--- a/tk/tk_util.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#ifndef lint
-static const char sccsid[] = "@(#)tk_util.c 8.14 (Berkeley) 7/19/96";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <bitstring.h>
-#include <errno.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "tki.h"
-
-static int tk_op_push __P((SCR *, TK_PRIVATE *, e_event_t));
-
-/*
- * tk_op --
- * Events provided directly from Tcl/Tk.
- *
- * PUBLIC: int tk_op __P((ClientData, Tcl_Interp *, int, char *[]));
- */
-int
-tk_op(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char *argv[];
-{
- SCR *sp;
- TK_PRIVATE *tkp;
-
- sp = __global_list->dq.cqh_first; /* XXX */
- tkp = (TK_PRIVATE *)clientData;
-
- switch (argv[1][0]) {
- case 'q':
- if (!strcmp(argv[1], "quit"))
- return (tk_op_push(sp, tkp, E_QUIT));
- break;
- case 'w':
- if (!strcmp(argv[1], "write"))
- return (tk_op_push(sp, tkp, E_WRITE));
- if (!strcmp(argv[1], "writequit")) {
- if (tk_op_push(sp, tkp, E_WRITE) != TCL_OK)
- return (TCL_ERROR);
- if (tk_op_push(sp, tkp, E_QUIT) != TCL_OK)
- return (TCL_ERROR);
- return (TCL_OK);
- }
- break;
- }
- (void)Tcl_VarEval(tkp->interp,
- "tk_err {", argv[1], ": unknown event", "}", NULL);
- return (TCL_OK);
-}
-
-/*
- * tk_op_push --
- * Push an event.
- */
-static int
-tk_op_push(sp, tkp, et)
- SCR *sp;
- TK_PRIVATE *tkp;
- e_event_t et;
-{
- EVENT *evp;
-
- CALLOC(sp, evp, EVENT *, 1, sizeof(EVENT));
- if (evp == NULL)
- return (TCL_ERROR);
-
- evp->e_event = et;
- TAILQ_INSERT_TAIL(&tkp->evq, evp, q);
- return (TCL_OK);
-}
-
-/*
- * tk_opt_init --
- * Initialize the values of the current options.
- *
- * PUBLIC: int tk_opt_init __P((ClientData, Tcl_Interp *, int, char *[]));
- */
-int
-tk_opt_init(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char *argv[];
-{
- OPTLIST const *op;
- SCR *sp;
- TK_PRIVATE *tkp;
- int off;
- char buf[20];
-
- sp = __global_list->dq.cqh_first; /* XXX */
-
- tkp = (TK_PRIVATE *)clientData;
- for (op = optlist, off = 0; op->name != NULL; ++op, ++off) {
- if (F_ISSET(op, OPT_NDISP))
- continue;
- switch (op->type) {
- case OPT_0BOOL:
- case OPT_1BOOL:
- (void)Tcl_VarEval(tkp->interp, "set tko_",
- op->name, O_ISSET(sp, off) ? " 1" : " 0", NULL);
- break;
- case OPT_NUM:
- (void)snprintf(buf,
- sizeof(buf), " %lu", O_VAL(sp, off));
- (void)Tcl_VarEval(tkp->interp,
- "set tko_", op->name, buf, NULL);
- break;
- case OPT_STR:
- (void)Tcl_VarEval(tkp->interp,
- "set tko_", op->name, " {",
- O_STR(sp, off) == NULL ? "" : O_STR(sp, off),
- "}", NULL);
- break;
- }
- }
- return (TCL_OK);
-}
-
-/*
- * tk_opt_set --
- * Set an options button.
- *
- * PUBLIC: int tk_opt_set __P((ClientData, Tcl_Interp *, int, char *[]));
- */
-int
-tk_opt_set(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char *argv[];
-{
- ARGS *ap[2], a, b;
- GS *gp;
- SCR *sp;
- int rval;
- void (*msg) __P((SCR *, mtype_t, char *, size_t));
- char buf[64];
-
- gp = __global_list;
- sp = gp->dq.cqh_first; /* XXX */
-
- switch (argc) {
- case 2:
- a.bp = argv[1] + (sizeof("tko_") - 1);
- a.len = strlen(a.bp);
- break;
- case 3:
- a.bp = buf;
- a.len = snprintf(buf, sizeof(buf),
- "%s%s", atoi(argv[2]) ? "no" : "", argv[1]);
- break;
- default:
- abort();
- }
- b.bp = NULL;
- b.len = 0;
- ap[0] = &a;
- ap[1] = &b;
-
- /* Use Tcl/Tk for error messages. */
- msg = gp->scr_msg;
- gp->scr_msg = tk_msg;
-
- rval = opts_set(sp, ap, NULL);
-
- gp->scr_msg = msg;
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tk_version --
- * Display the version in Tcl/Tk.
- *
- * PUBLIC: int tk_version __P((ClientData, Tcl_Interp *, int, char *[]));
- */
-int
-tk_version(clientData, interp, argc, argv)
- ClientData clientData;
- Tcl_Interp *interp;
- int argc;
- char *argv[];
-{
- EXCMD cmd;
- GS *gp;
- SCR *sp;
- int rval;
- void (*msg) __P((SCR *, mtype_t, char *, size_t));
-
- gp = __global_list;
- sp = gp->dq.cqh_first; /* XXX */
-
- msg = gp->scr_msg;
- gp->scr_msg = tk_msg;
-
- ex_cinit(&cmd, C_VERSION, 0, OOBLNO, OOBLNO, 0, NULL);
- rval = cmd.cmd->fn(sp, &cmd);
- (void)ex_fflush(sp);
-
- gp->scr_msg = msg;
- return (rval ? TCL_ERROR : TCL_OK);
-}
-
-/*
- * tk_msg --
- * Display an error message in Tcl/Tk.
- *
- * PUBLIC: void tk_msg __P((SCR *, mtype_t, char *, size_t));
- */
-void
-tk_msg(sp, mtype, line, rlen)
- SCR *sp;
- mtype_t mtype;
- char *line;
- size_t rlen;
-{
- TK_PRIVATE *tkp;
- char buf[2048];
-
- if (line == NULL)
- return;
-
- tkp = TKP(sp);
- (void)snprintf(buf, sizeof(buf), "%.*s", (int)rlen, line);
- (void)Tcl_VarEval(tkp->interp, "tk_err {", buf, "}", NULL);
-}
diff --git a/tk/tki.h b/tk/tki.h
deleted file mode 100644
index 206dacf5d73b..000000000000
--- a/tk/tki.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993, 1994, 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- *
- * @(#)tki.h 8.6 (Berkeley) 4/27/96
- */
-
-#include <tcl.h>
-#include <tk.h>
-
-typedef struct _tk_private {
- Tcl_Interp *interp;/* Tcl interpreter cookie. */
-
- /* Shared variables. */
- int tk_cursor_row; /* Current cursor row. */
- int tk_cursor_col; /* Current cursor col. */
- int tk_ssize_row; /* Screen rows. */
- int tk_ssize_col; /* Screen columns. */
-
- struct termios orig; /* Original terminal values. */
-
- CHAR_T ibuf[64]; /* Input keys. */
- int ibuf_cnt; /* Number of input keys. */
-
- /* Event queue. */
- TAILQ_HEAD(_eventh, _event) evq;
-
- int killersig; /* Killer signal. */
-#define INDX_HUP 0
-#define INDX_INT 1
-#define INDX_TERM 2
-#define INDX_WINCH 3
-#define INDX_MAX 4 /* Original signal information. */
- struct sigaction oact[INDX_MAX];
-
-#define TK_LLINE_IV 0x0001 /* Last line is in inverse video. */
-#define TK_SCR_VI_INIT 0x0002 /* Vi screen initialized. */
-#define TK_SIGHUP 0x0004 /* SIGHUP arrived. */
-#define TK_SIGINT 0x0008 /* SIGINT arrived. */
-#define TK_SIGTERM 0x0010 /* SIGTERM arrived. */
-#define TK_SIGWINCH 0x0020 /* SIGWINCH arrived. */
- u_int16_t flags;
-} TK_PRIVATE;
-
-extern GS *__global_list;
-#define TKP(sp) ((TK_PRIVATE *)((sp)->gp->tk_private))
-#define GTKP(gp) ((TK_PRIVATE *)gp->tk_private)
-
-/* Return possibilities from the keyboard read routine. */
-typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t;
-
-/* The screen line relative to a specific window. */
-#define RLNO(sp, lno) (sp)->woff + (lno)
-
-/* Some functions can be safely ignored until the screen is running. */
-#define VI_INIT_IGNORE(sp) \
- if (F_ISSET(sp, SC_VI) && !F_ISSET(TKP(sp), TK_SCR_VI_INIT)) \
- return (0);
-
-#include "tk_extern.h"
diff --git a/include/vi_extern.h b/vi/extern.h
index b3c335e6c580..600caa673c95 100644
--- a/include/vi_extern.h
+++ b/vi/extern.h
@@ -22,7 +22,6 @@ int v_switch __P((SCR *, VICMD *));
int v_tagpush __P((SCR *, VICMD *));
int v_tagpop __P((SCR *, VICMD *));
int v_filter __P((SCR *, VICMD *));
-int v_event_exec __P((SCR *, VICMD *));
int v_ex __P((SCR *, VICMD *));
int v_ecl_exec __P((SCR *));
int v_increment __P((SCR *, VICMD *));
@@ -46,7 +45,9 @@ int v_zero __P((SCR *, VICMD *));
int v_mark __P((SCR *, VICMD *));
int v_bmark __P((SCR *, VICMD *));
int v_fmark __P((SCR *, VICMD *));
+int v_emark __P((SCR *, VICMD *));
int v_match __P((SCR *, VICMD *));
+int v_buildmcs __P((SCR *, char *));
int v_paragraphf __P((SCR *, VICMD *));
int v_paragraphb __P((SCR *, VICMD *));
int v_buildps __P((SCR *, char *, char *));
@@ -83,7 +84,7 @@ int v_sentenceb __P((SCR *, VICMD *));
int v_status __P((SCR *, VICMD *));
int v_tcmd __P((SCR *, VICMD *, ARG_CHAR_T, u_int));
int v_txt __P((SCR *, VICMD *, MARK *,
- const char *, size_t, ARG_CHAR_T, recno_t, u_long, u_int32_t));
+ const CHAR_T *, size_t, ARG_CHAR_T, recno_t, u_long, u_int32_t));
int v_txt_auto __P((SCR *, recno_t, TEXT *, size_t, TEXT *));
int v_ulcase __P((SCR *, VICMD *));
int v_mulcase __P((SCR *, VICMD *));
@@ -94,7 +95,7 @@ void v_eol __P((SCR *, MARK *));
void v_nomove __P((SCR *));
void v_sof __P((SCR *, MARK *));
void v_sol __P((SCR *));
-int v_isempty __P((char *, size_t));
+int v_isempty __P((CHAR_T *, size_t));
void v_emsg __P((SCR *, char *, vim_t));
int v_wordW __P((SCR *, VICMD *));
int v_wordw __P((SCR *, VICMD *));
@@ -109,11 +110,12 @@ int v_z __P((SCR *, VICMD *));
int vs_crel __P((SCR *, long));
int v_zexit __P((SCR *, VICMD *));
int vi __P((SCR **));
+int v_curword __P((SCR *));
int vs_line __P((SCR *, SMAP *, size_t *, size_t *));
int vs_number __P((SCR *));
void vs_busy __P((SCR *, const char *, busy_t));
void vs_home __P((SCR *));
-void vs_update __P((SCR *, const char *, const char *));
+void vs_update __P((SCR *, const char *, const CHAR_T *));
void vs_msg __P((SCR *, mtype_t, char *, size_t));
int vs_ex_resolve __P((SCR *, int *));
int vs_resolve __P((SCR *, SCR *, int));
@@ -121,7 +123,7 @@ int vs_repaint __P((SCR *, EVENT *));
int vs_refresh __P((SCR *, int));
int vs_column __P((SCR *, size_t *));
size_t vs_screens __P((SCR *, recno_t, size_t *));
-size_t vs_columns __P((SCR *, char *, recno_t, size_t *, size_t *));
+size_t vs_columns __P((SCR *, CHAR_T *, recno_t, size_t *, size_t *));
size_t vs_rcm __P((SCR *, recno_t, int));
size_t vs_colpos __P((SCR *, recno_t, size_t));
int vs_change __P((SCR *, recno_t, lnop_t));
@@ -135,6 +137,7 @@ int vs_sm_cursor __P((SCR *, SMAP **));
int vs_sm_position __P((SCR *, MARK *, u_long, pos_t));
recno_t vs_sm_nlines __P((SCR *, SMAP *, recno_t, size_t));
int vs_split __P((SCR *, SCR *, int));
+int vs_vsplit __P((SCR *, SCR *));
int vs_discard __P((SCR *, SCR **));
int vs_fg __P((SCR *, SCR **, CHAR_T *, int));
int vs_bg __P((SCR *));
diff --git a/vi/getc.c b/vi/getc.c
index 5e60adee96d7..deb3554a0abc 100644
--- a/vi/getc.c
+++ b/vi/getc.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)getc.c 10.10 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: getc.c,v 10.13 2011/12/27 00:49:31 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -43,9 +43,7 @@ static const char sccsid[] = "@(#)getc.c 10.10 (Berkeley) 3/6/96";
* PUBLIC: int cs_init __P((SCR *, VCS *));
*/
int
-cs_init(sp, csp)
- SCR *sp;
- VCS *csp;
+cs_init(SCR *sp, VCS *csp)
{
int isempty;
@@ -71,11 +69,9 @@ cs_init(sp, csp)
* PUBLIC: int cs_next __P((SCR *, VCS *));
*/
int
-cs_next(sp, csp)
- SCR *sp;
- VCS *csp;
+cs_next(SCR *sp, VCS *csp)
{
- char *p;
+ CHAR_T *p;
switch (csp->cs_flags) {
case CS_EMP: /* EMP; get next line. */
@@ -123,16 +119,14 @@ cs_next(sp, csp)
* PUBLIC: int cs_fspace __P((SCR *, VCS *));
*/
int
-cs_fspace(sp, csp)
- SCR *sp;
- VCS *csp;
+cs_fspace(SCR *sp, VCS *csp)
{
- if (csp->cs_flags != 0 || !isblank(csp->cs_ch))
+ if (csp->cs_flags != 0 || !ISBLANK(csp->cs_ch))
return (0);
for (;;) {
if (cs_next(sp, csp))
return (1);
- if (csp->cs_flags != 0 || !isblank(csp->cs_ch))
+ if (csp->cs_flags != 0 || !ISBLANK(csp->cs_ch))
break;
}
return (0);
@@ -145,15 +139,13 @@ cs_fspace(sp, csp)
* PUBLIC: int cs_fblank __P((SCR *, VCS *));
*/
int
-cs_fblank(sp, csp)
- SCR *sp;
- VCS *csp;
+cs_fblank(SCR *sp, VCS *csp)
{
for (;;) {
if (cs_next(sp, csp))
return (1);
if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
- csp->cs_flags == 0 && isblank(csp->cs_ch))
+ (csp->cs_flags == 0 && ISBLANK(csp->cs_ch)))
continue;
break;
}
@@ -167,9 +159,7 @@ cs_fblank(sp, csp)
* PUBLIC: int cs_prev __P((SCR *, VCS *));
*/
int
-cs_prev(sp, csp)
- SCR *sp;
- VCS *csp;
+cs_prev(SCR *sp, VCS *csp)
{
switch (csp->cs_flags) {
case CS_EMP: /* EMP; get previous line. */
@@ -218,15 +208,13 @@ cs_prev(sp, csp)
* PUBLIC: int cs_bblank __P((SCR *, VCS *));
*/
int
-cs_bblank(sp, csp)
- SCR *sp;
- VCS *csp;
+cs_bblank(SCR *sp, VCS *csp)
{
for (;;) {
if (cs_prev(sp, csp))
return (1);
if (csp->cs_flags == CS_EOL || csp->cs_flags == CS_EMP ||
- csp->cs_flags == 0 && isblank(csp->cs_ch))
+ (csp->cs_flags == 0 && ISBLANK(csp->cs_ch)))
continue;
break;
}
diff --git a/vi/v_at.c b/vi/v_at.c
index d266f275d983..45757d4b4733 100644
--- a/vi/v_at.c
+++ b/vi/v_at.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_at.c 10.8 (Berkeley) 4/27/96";
+static const char sccsid[] = "$Id: v_at.c,v 10.11 2001/06/25 15:19:30 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -21,6 +21,7 @@ static const char sccsid[] = "@(#)v_at.c 10.8 (Berkeley) 4/27/96";
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
+#include <string.h>
#include "../common/common.h"
#include "vi.h"
@@ -32,15 +33,16 @@ static const char sccsid[] = "@(#)v_at.c 10.8 (Berkeley) 4/27/96";
* PUBLIC: int v_at __P((SCR *, VICMD *));
*/
int
-v_at(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_at(SCR *sp, VICMD *vp)
{
CB *cbp;
CHAR_T name;
TEXT *tp;
size_t len;
char nbuf[20];
+ CHAR_T wbuf[20];
+ CHAR_T *wp;
+ size_t wlen;
/*
* !!!
@@ -87,13 +89,13 @@ v_at(sp, vp)
* together. We don't get this right; I'm waiting for the new DB
* logging code to be available.
*/
- for (tp = cbp->textq.cqh_last;
- tp != (void *)&cbp->textq; tp = tp->q.cqe_prev)
- if ((F_ISSET(cbp, CB_LMODE) ||
- tp->q.cqe_next != (void *)&cbp->textq) &&
- v_event_push(sp, NULL, "\n", 1, 0) ||
+ TAILQ_FOREACH_REVERSE(tp, cbp->textq, _texth, q) {
+ if (((F_ISSET(cbp, CB_LMODE) ||
+ TAILQ_NEXT(tp, q) != NULL) &&
+ v_event_push(sp, NULL, L("\n"), 1, 0)) ||
v_event_push(sp, NULL, tp->lb, tp->len, 0))
return (1);
+ }
/*
* !!!
@@ -102,7 +104,9 @@ v_at(sp, vp)
*/
if (F_ISSET(vp, VC_C1SET)) {
len = snprintf(nbuf, sizeof(nbuf), "%lu", vp->count);
- if (v_event_push(sp, NULL, nbuf, len, 0))
+ CHAR2INT(sp, nbuf, len, wp, wlen);
+ MEMCPY(wbuf, wp, wlen);
+ if (v_event_push(sp, NULL, wp, wlen, 0))
return (1);
}
return (0);
diff --git a/vi/v_ch.c b/vi/v_ch.c
index 6a1b61182680..04fb6af65272 100644
--- a/vi/v_ch.c
+++ b/vi/v_ch.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_ch.c 10.8 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_ch.c,v 10.11 2011/12/02 19:49:50 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -35,9 +35,7 @@ static void noprev __P((SCR *));
* PUBLIC: int v_chrepeat __P((SCR *, VICMD *));
*/
int
-v_chrepeat(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_chrepeat(SCR *sp, VICMD *vp)
{
vp->character = VIP(sp)->lastckey;
@@ -66,9 +64,7 @@ v_chrepeat(sp, vp)
* PUBLIC: int v_chrrepeat __P((SCR *, VICMD *));
*/
int
-v_chrrepeat(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_chrrepeat(SCR *sp, VICMD *vp)
{
cdir_t savedir;
int rval;
@@ -107,9 +103,7 @@ v_chrrepeat(sp, vp)
* PUBLIC: int v_cht __P((SCR *, VICMD *));
*/
int
-v_cht(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_cht(SCR *sp, VICMD *vp)
{
if (v_chf(sp, vp))
return (1);
@@ -140,14 +134,13 @@ v_cht(sp, vp)
* PUBLIC: int v_chf __P((SCR *, VICMD *));
*/
int
-v_chf(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_chf(SCR *sp, VICMD *vp)
{
size_t len;
u_long cnt;
- int isempty, key;
- char *endp, *p, *startp;
+ int isempty;
+ ARG_CHAR_T key;
+ CHAR_T *endp, *p, *startp;
/*
* !!!
@@ -198,9 +191,7 @@ empty: notfound(sp, key);
* PUBLIC: int v_chT __P((SCR *, VICMD *));
*/
int
-v_chT(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_chT(SCR *sp, VICMD *vp)
{
if (v_chF(sp, vp))
return (1);
@@ -225,14 +216,13 @@ v_chT(sp, vp)
* PUBLIC: int v_chF __P((SCR *, VICMD *));
*/
int
-v_chF(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_chF(SCR *sp, VICMD *vp)
{
size_t len;
u_long cnt;
- int isempty, key;
- char *endp, *p;
+ int isempty;
+ ARG_CHAR_T key;
+ CHAR_T *endp, *p;
/*
* !!!
@@ -280,16 +270,13 @@ empty: notfound(sp, key);
}
static void
-noprev(sp)
- SCR *sp;
+noprev(SCR *sp)
{
msgq(sp, M_BERR, "178|No previous F, f, T or t search");
}
static void
-notfound(sp, ch)
- SCR *sp;
- ARG_CHAR_T ch;
+notfound(SCR *sp, ARG_CHAR_T ch)
{
msgq(sp, M_BERR, "179|%s not found", KEY_NAME(sp, ch));
}
diff --git a/vi/v_cmd.c b/vi/v_cmd.c
index cc9e30f79ae4..f77cd273cf08 100644
--- a/vi/v_cmd.c
+++ b/vi/v_cmd.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_cmd.c 10.9 (Berkeley) 3/28/96";
+static const char sccsid[] = "$Id: v_cmd.c,v 10.9 1996/03/28 15:18:39 bostic Exp $";
#endif /* not lint */
#include <sys/types.h>
diff --git a/vi/v_delete.c b/vi/v_delete.c
index 70df78b22e2c..b3b879e93dd3 100644
--- a/vi/v_delete.c
+++ b/vi/v_delete.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_delete.c 10.9 (Berkeley) 10/23/96";
+static const char sccsid[] = "$Id: v_delete.c,v 10.11 2001/06/25 15:19:31 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -32,9 +32,7 @@ static const char sccsid[] = "@(#)v_delete.c 10.9 (Berkeley) 10/23/96";
* PUBLIC: int v_delete __P((SCR *, VICMD *));
*/
int
-v_delete(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_delete(SCR *sp, VICMD *vp)
{
recno_t nlines;
size_t len;
diff --git a/vi/v_ex.c b/vi/v_ex.c
index 359080c656e3..e5ac5731d074 100644
--- a/vi/v_ex.c
+++ b/vi/v_ex.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_ex.c 10.42 (Berkeley) 6/28/96";
+static const char sccsid[] = "$Id: v_ex.c,v 10.61 2011/12/22 18:41:53 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -40,16 +40,12 @@ static int v_exec_ex __P((SCR *, VICMD *, EXCMD *));
* PUBLIC: int v_again __P((SCR *, VICMD *));
*/
int
-v_again(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_again(SCR *sp, VICMD *vp)
{
- ARGS *ap[2], a;
EXCMD cmd;
- ex_cinit(&cmd, C_SUBAGAIN, 2, vp->m_start.lno, vp->m_start.lno, 1, ap);
- ex_cadd(&cmd, &a, "", 1);
-
+ ex_cinit(sp, &cmd, C_SUBAGAIN, 2, vp->m_start.lno, vp->m_start.lno, 1);
+ argv_exp0(sp, &cmd, L(""), 1);
return (v_exec_ex(sp, vp, &cmd));
}
@@ -60,9 +56,7 @@ v_again(sp, vp)
* PUBLIC: int v_exmode __P((SCR *, VICMD *));
*/
int
-v_exmode(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_exmode(SCR *sp, VICMD *vp)
{
GS *gp;
@@ -98,9 +92,7 @@ v_exmode(sp, vp)
* PUBLIC: int v_join __P((SCR *, VICMD *));
*/
int
-v_join(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_join(SCR *sp, VICMD *vp)
{
EXCMD cmd;
int lno;
@@ -118,7 +110,7 @@ v_join(sp, vp)
if (F_ISSET(vp, VC_C1SET) && vp->count > 2)
lno = vp->m_start.lno + (vp->count - 1);
- ex_cinit(&cmd, C_JOIN, 2, vp->m_start.lno, lno, 0, NULL);
+ ex_cinit(sp, &cmd, C_JOIN, 2, vp->m_start.lno, lno, 0);
return (v_exec_ex(sp, vp, &cmd));
}
@@ -129,15 +121,12 @@ v_join(sp, vp)
* PUBLIC: int v_shiftl __P((SCR *, VICMD *));
*/
int
-v_shiftl(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_shiftl(SCR *sp, VICMD *vp)
{
- ARGS *ap[2], a;
EXCMD cmd;
- ex_cinit(&cmd, C_SHIFTL, 2, vp->m_start.lno, vp->m_stop.lno, 0, ap);
- ex_cadd(&cmd, &a, "<", 1);
+ ex_cinit(sp, &cmd, C_SHIFTL, 2, vp->m_start.lno, vp->m_stop.lno, 0);
+ argv_exp0(sp, &cmd, L("<"), 2);
return (v_exec_ex(sp, vp, &cmd));
}
@@ -148,15 +137,12 @@ v_shiftl(sp, vp)
* PUBLIC: int v_shiftr __P((SCR *, VICMD *));
*/
int
-v_shiftr(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_shiftr(SCR *sp, VICMD *vp)
{
- ARGS *ap[2], a;
EXCMD cmd;
- ex_cinit(&cmd, C_SHIFTR, 2, vp->m_start.lno, vp->m_stop.lno, 0, ap);
- ex_cadd(&cmd, &a, ">", 1);
+ ex_cinit(sp, &cmd, C_SHIFTR, 2, vp->m_start.lno, vp->m_stop.lno, 0);
+ argv_exp0(sp, &cmd, L(">"), 2);
return (v_exec_ex(sp, vp, &cmd));
}
@@ -167,15 +153,12 @@ v_shiftr(sp, vp)
* PUBLIC: int v_suspend __P((SCR *, VICMD *));
*/
int
-v_suspend(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_suspend(SCR *sp, VICMD *vp)
{
- ARGS *ap[2], a;
EXCMD cmd;
- ex_cinit(&cmd, C_STOP, 0, OOBLNO, OOBLNO, 0, ap);
- ex_cadd(&cmd, &a, "suspend", sizeof("suspend") - 1);
+ ex_cinit(sp, &cmd, C_STOP, 0, OOBLNO, OOBLNO, 0);
+ argv_exp0(sp, &cmd, L("suspend"), SIZE(L("suspend")));
return (v_exec_ex(sp, vp, &cmd));
}
@@ -186,13 +169,12 @@ v_suspend(sp, vp)
* PUBLIC: int v_switch __P((SCR *, VICMD *));
*/
int
-v_switch(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_switch(SCR *sp, VICMD *vp)
{
- ARGS *ap[2], a;
EXCMD cmd;
char *name;
+ CHAR_T *wp;
+ size_t wlen;
/*
* Try the alternate file name, then the previous file
@@ -207,8 +189,9 @@ v_switch(sp, vp)
if (file_m1(sp, 0, FS_ALL))
return (1);
- ex_cinit(&cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0, ap);
- ex_cadd(&cmd, &a, name, strlen(name));
+ ex_cinit(sp, &cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0);
+ CHAR2INT(sp, name, strlen(name) + 1, wp, wlen);
+ argv_exp0(sp, &cmd, wp, wlen);
return (v_exec_ex(sp, vp, &cmd));
}
@@ -219,15 +202,12 @@ v_switch(sp, vp)
* PUBLIC: int v_tagpush __P((SCR *, VICMD *));
*/
int
-v_tagpush(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_tagpush(SCR *sp, VICMD *vp)
{
- ARGS *ap[2], a;
EXCMD cmd;
- ex_cinit(&cmd, C_TAG, 0, OOBLNO, 0, 0, ap);
- ex_cadd(&cmd, &a, VIP(sp)->keyw, strlen(VIP(sp)->keyw));
+ ex_cinit(sp, &cmd, C_TAG, 0, OOBLNO, 0, 0);
+ argv_exp0(sp, &cmd, VIP(sp)->keyw, STRLEN(VIP(sp)->keyw) + 1);
return (v_exec_ex(sp, vp, &cmd));
}
@@ -238,13 +218,11 @@ v_tagpush(sp, vp)
* PUBLIC: int v_tagpop __P((SCR *, VICMD *));
*/
int
-v_tagpop(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_tagpop(SCR *sp, VICMD *vp)
{
EXCMD cmd;
- ex_cinit(&cmd, C_TAGPOP, 0, OOBLNO, 0, 0, NULL);
+ ex_cinit(sp, &cmd, C_TAGPOP, 0, OOBLNO, 0, 0);
return (v_exec_ex(sp, vp, &cmd));
}
@@ -255,9 +233,7 @@ v_tagpop(sp, vp)
* PUBLIC: int v_filter __P((SCR *, VICMD *));
*/
int
-v_filter(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_filter(SCR *sp, VICMD *vp)
{
EXCMD cmd;
TEXT *tp;
@@ -283,11 +259,11 @@ v_filter(sp, vp)
*/
if (F_ISSET(vp, VC_ISDOT) ||
ISCMD(vp->rkp, 'N') || ISCMD(vp->rkp, 'n')) {
- ex_cinit(&cmd, C_BANG,
- 2, vp->m_start.lno, vp->m_stop.lno, 0, NULL);
+ ex_cinit(sp,
+ &cmd, C_BANG, 2, vp->m_start.lno, vp->m_stop.lno, 0);
EXP(sp)->argsoff = 0; /* XXX */
- if (argv_exp1(sp, &cmd, "!", 1, 1))
+ if (argv_exp1(sp, &cmd, L("!"), 1, 1))
return (1);
cmd.argc = EXP(sp)->argsoff; /* XXX */
cmd.argv = EXP(sp)->args; /* XXX */
@@ -306,7 +282,7 @@ v_filter(sp, vp)
* Entering <escape> on an empty line was historically an error,
* this implementation doesn't bother.
*/
- tp = sp->tiq.cqh_first;
+ tp = TAILQ_FIRST(sp->tiq);
if (tp->term != TERM_OK) {
vp->m_final.lno = sp->lno;
vp->m_final.cno = sp->cno;
@@ -316,7 +292,7 @@ v_filter(sp, vp)
/* Home the cursor. */
vs_home(sp);
- ex_cinit(&cmd, C_BANG, 2, vp->m_start.lno, vp->m_stop.lno, 0, NULL);
+ ex_cinit(sp, &cmd, C_BANG, 2, vp->m_start.lno, vp->m_stop.lno, 0);
EXP(sp)->argsoff = 0; /* XXX */
if (argv_exp1(sp, &cmd, tp->lb + 1, tp->len - 1, 1))
@@ -327,40 +303,11 @@ v_filter(sp, vp)
}
/*
- * v_event_exec --
- * Execute some command(s) based on an event.
- *
- * PUBLIC: int v_event_exec __P((SCR *, VICMD *));
- */
-int
-v_event_exec(sp, vp)
- SCR *sp;
- VICMD *vp;
-{
- EXCMD cmd;
-
- switch (vp->ev.e_event) {
- case E_QUIT:
- ex_cinit(&cmd, C_QUIT, 0, OOBLNO, OOBLNO, 0, NULL);
- break;
- case E_WRITE:
- ex_cinit(&cmd, C_WRITE, 0, OOBLNO, OOBLNO, 0, NULL);
- break;
- default:
- abort();
- }
- return (v_exec_ex(sp, vp, &cmd));
-}
-
-/*
* v_exec_ex --
* Execute an ex command.
*/
static int
-v_exec_ex(sp, vp, exp)
- SCR *sp;
- VICMD *vp;
- EXCMD *exp;
+v_exec_ex(SCR *sp, VICMD *vp, EXCMD *exp)
{
int rval;
@@ -375,9 +322,7 @@ v_exec_ex(sp, vp, exp)
* PUBLIC: int v_ex __P((SCR *, VICMD *));
*/
int
-v_ex(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_ex(SCR *sp, VICMD *vp)
{
GS *gp;
TEXT *tp;
@@ -405,7 +350,7 @@ v_ex(sp, vp)
if (v_tcmd(sp, vp, ':',
TXT_BS | TXT_CEDIT | TXT_FILEC | TXT_PROMPT))
return (1);
- tp = sp->tiq.cqh_first;
+ tp = TAILQ_FIRST(sp->tiq);
/*
* If the user entered a single <esc>, they want to
@@ -423,6 +368,10 @@ v_ex(sp, vp)
if (tp->term == TERM_BS)
break;
+ /* If the user changed their mind, return. */
+ if (tp->term != TERM_OK)
+ break;
+
/* Log the command. */
if (O_STR(sp, O_CEDIT) != NULL && v_ecl_log(sp, tp))
return (1);
@@ -501,9 +450,7 @@ v_ex(sp, vp)
* Cleanup from an ex command.
*/
static int
-v_ex_done(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_ex_done(SCR *sp, VICMD *vp)
{
size_t len;
@@ -545,8 +492,7 @@ v_ex_done(sp, vp)
* Start an edit window on the colon command-line commands.
*/
static int
-v_ecl(sp)
- SCR *sp;
+v_ecl(SCR *sp)
{
GS *gp;
SCR *new;
@@ -582,6 +528,11 @@ v_ecl(sp)
/* It's a special window. */
F_SET(new, SC_COMEDIT);
+#if defined(USE_WIDECHAR) && defined(USE_ICONV)
+ /* Bypass iconv on writing to DB. */
+ o_set(new, O_FILEENCODING, OS_STRDUP, codeset(), 0);
+#endif
+
/* Set up the switch. */
sp->nextdisp = new;
F_SET(sp, SC_SSWITCH);
@@ -595,11 +546,10 @@ v_ecl(sp)
* PUBLIC: int v_ecl_exec __P((SCR *));
*/
int
-v_ecl_exec(sp)
- SCR *sp;
+v_ecl_exec(SCR *sp)
{
size_t len;
- char *p;
+ CHAR_T *p;
if (db_get(sp, sp->lno, 0, &p, &len) && sp->lno == 1) {
v_emsg(sp, NULL, VIM_EMPTY);
@@ -625,39 +575,43 @@ v_ecl_exec(sp)
* Log a command into the colon command-line log file.
*/
static int
-v_ecl_log(sp, tp)
- SCR *sp;
- TEXT *tp;
+v_ecl_log(SCR *sp, TEXT *tp)
{
- EXF *save_ep;
recno_t lno;
int rval;
+ CHAR_T *p;
+ size_t len;
+ SCR *ccl_sp;
/* Initialize the screen, if necessary. */
if (sp->gp->ccl_sp == NULL && v_ecl_init(sp))
return (1);
+ ccl_sp = sp->gp->ccl_sp;
+
/*
* Don't log colon command window commands into the colon command
* window...
*/
- if (sp->ep == sp->gp->ccl_sp->ep)
+ if (sp->ep == ccl_sp->ep)
return (0);
- /*
- * XXX
- * Swap the current EXF with the colon command file EXF. This
- * isn't pretty, but too many routines "know" that sp->ep points
- * to the current EXF.
- */
- save_ep = sp->ep;
- sp->ep = sp->gp->ccl_sp->ep;
- if (db_last(sp, &lno)) {
- sp->ep = save_ep;
+ if (db_last(ccl_sp, &lno)) {
return (1);
}
- rval = db_append(sp, 0, lno, tp->lb, tp->len);
- sp->ep = save_ep;
+ /* Don't log line that is identical to previous one */
+ if (lno > 0 &&
+ !db_get(ccl_sp, lno, 0, &p, &len) &&
+ len == tp->len &&
+ !MEMCMP(tp->lb, p, len))
+ rval = 0;
+ else {
+ rval = db_append(ccl_sp, 0, lno, tp->lb, tp->len);
+ /* XXXX end "transaction" on ccl */
+ /* Is this still necessary now that we no longer hijack sp ? */
+ log_cursor(ccl_sp);
+ }
+
return (rval);
}
@@ -666,8 +620,7 @@ v_ecl_log(sp, tp)
* Initialize the colon command-line log file.
*/
static int
-v_ecl_init(sp)
- SCR *sp;
+v_ecl_init(SCR *sp)
{
FREF *frp;
GS *gp;
@@ -686,6 +639,7 @@ v_ecl_init(sp)
return (1);
if (file_init(gp->ccl_sp, frp, NULL, 0)) {
(void)screen_end(gp->ccl_sp);
+ gp->ccl_sp = NULL;
return (1);
}
diff --git a/vi/v_increment.c b/vi/v_increment.c
index 45e763fa5bd5..0a121a914c96 100644
--- a/vi/v_increment.c
+++ b/vi/v_increment.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_increment.c 10.12 (Berkeley) 3/19/96";
+static const char sccsid[] = "$Id: v_increment.c,v 10.17 2011/12/02 01:17:53 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -28,17 +28,17 @@ static const char sccsid[] = "@(#)v_increment.c 10.12 (Berkeley) 3/19/96";
#include "../common/common.h"
#include "vi.h"
-static char * const fmt[] = {
+static CHAR_T * const fmt[] = {
#define DEC 0
- "%ld",
+ L("%ld"),
#define SDEC 1
- "%+ld",
+ L("%+ld"),
#define HEXC 2
- "0X%0*lX",
+ L("0X%0*lX"),
#define HEXL 3
- "0x%0*lx",
+ L("0x%0*lx"),
#define OCTAL 4
- "%#0*lo",
+ L("%#0*lo"),
};
static void inc_err __P((SCR *, enum nresult));
@@ -50,16 +50,15 @@ static void inc_err __P((SCR *, enum nresult));
* PUBLIC: int v_increment __P((SCR *, VICMD *));
*/
int
-v_increment(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_increment(SCR *sp, VICMD *vp)
{
enum nresult nret;
u_long ulval;
long change, ltmp, lval;
size_t beg, blen, end, len, nlen, wlen;
int base, isempty, rval;
- char *bp, *ntype, *p, *t, nbuf[100];
+ CHAR_T *ntype, nbuf[100];
+ CHAR_T *bp, *p, *t;
/* Validate the operator. */
if (vp->character == '#')
@@ -91,7 +90,7 @@ v_increment(sp, vp)
* implies moving the cursor to its beginning, if we moved, refresh
* now.
*/
- for (beg = vp->m_start.cno; beg < len && isspace(p[beg]); ++beg);
+ for (beg = vp->m_start.cno; beg < len && ISSPACE(p[beg]); ++beg);
if (beg >= len)
goto nonum;
if (beg != vp->m_start.cno) {
@@ -100,9 +99,9 @@ v_increment(sp, vp)
}
#undef ishex
-#define ishex(c) (isdigit(c) || strchr("abcdefABCDEF", c))
+#define ishex(c) (ISXDIGIT(c))
#undef isoctal
-#define isoctal(c) (isdigit(c) && (c) != '8' && (c) != '9')
+#define isoctal(c) ((c) >= '0' && (c) <= '7')
/*
* Look for 0[Xx], or leading + or - signs, guess at the base.
@@ -175,9 +174,9 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
* buffer big enough to fit the line changes as well, and only
* allocate once.
*/
- GET_SPACE_RET(sp, bp, blen, len + 50);
+ GET_SPACE_RETW(sp, bp, blen, len + 50);
if (end == len) {
- memmove(bp, &p[beg], wlen);
+ MEMMOVE(bp, &p[beg], wlen);
bp[wlen] = '\0';
t = bp;
} else
@@ -203,7 +202,7 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
/* If we cross 0, signed numbers lose their sign. */
if (lval == 0 && ntype == fmt[SDEC])
ntype = fmt[DEC];
- nlen = snprintf(nbuf, sizeof(nbuf), ntype, lval);
+ nlen = SPRINTF(nbuf, sizeof(nbuf), ntype, lval);
} else {
if ((nret = nget_uslong(&ulval, t, NULL, base)) != NUM_OK)
goto err;
@@ -225,13 +224,13 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number");
if (base == 16)
wlen -= 2;
- nlen = snprintf(nbuf, sizeof(nbuf), ntype, wlen, ulval);
+ nlen = SPRINTF(nbuf, sizeof(nbuf), ntype, wlen, ulval);
}
/* Build the new line. */
- memmove(bp, p, beg);
- memmove(bp + beg, nbuf, nlen);
- memmove(bp + beg + nlen, p + end, len - beg - (end - beg));
+ MEMMOVE(bp, p, beg);
+ MEMMOVE(bp + beg, nbuf, nlen);
+ MEMMOVE(bp + beg + nlen, p + end, len - beg - (end - beg));
len = beg + nlen + (len - beg - (end - beg));
nret = NUM_OK;
@@ -242,14 +241,12 @@ err: rval = 1;
inc_err(sp, nret);
}
if (bp != NULL)
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
return (rval);
}
static void
-inc_err(sp, nret)
- SCR *sp;
- enum nresult nret;
+inc_err(SCR *sp, enum nresult nret)
{
switch (nret) {
case NUM_ERR:
diff --git a/vi/v_init.c b/vi/v_init.c
index ee58de377ada..e47a821df9c4 100644
--- a/vi/v_init.c
+++ b/vi/v_init.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_init.c 10.8 (Berkeley) 3/30/96";
+static const char sccsid[] = "$Id: v_init.c,v 10.10 2012/02/11 00:33:46 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -34,8 +34,7 @@ static const char sccsid[] = "@(#)v_init.c 10.8 (Berkeley) 3/30/96";
* PUBLIC: int v_screen_copy __P((SCR *, SCR *));
*/
int
-v_screen_copy(orig, sp)
- SCR *orig, *sp;
+v_screen_copy(SCR *orig, SCR *sp)
{
VI_PRIVATE *ovip, *nvip;
@@ -58,6 +57,11 @@ v_screen_copy(orig, sp)
nvip->rep_len = ovip->rep_len;
}
+ /* Copy the match characters information. */
+ if (ovip->mcs != NULL && (nvip->mcs =
+ v_wstrdup(sp, ovip->mcs, STRLEN(ovip->mcs))) == NULL)
+ return (1);
+
/* Copy the paragraph/section information. */
if (ovip->ps != NULL && (nvip->ps =
v_strdup(sp, ovip->ps, strlen(ovip->ps))) == NULL)
@@ -78,8 +82,7 @@ v_screen_copy(orig, sp)
* PUBLIC: int v_screen_end __P((SCR *));
*/
int
-v_screen_end(sp)
- SCR *sp;
+v_screen_end(SCR *sp)
{
VI_PRIVATE *vip;
@@ -89,6 +92,8 @@ v_screen_end(sp)
free(vip->keyw);
if (vip->rep != NULL)
free(vip->rep);
+ if (vip->mcs != NULL)
+ free(vip->mcs);
if (vip->ps != NULL)
free(vip->ps);
@@ -108,13 +113,11 @@ v_screen_end(sp)
* PUBLIC: int v_optchange __P((SCR *, int, char *, u_long *));
*/
int
-v_optchange(sp, offset, str, valp)
- SCR *sp;
- int offset;
- char *str;
- u_long *valp;
+v_optchange(SCR *sp, int offset, char *str, u_long *valp)
{
switch (offset) {
+ case O_MATCHCHARS:
+ return (v_buildmcs(sp, str));
case O_PARAGRAPHS:
return (v_buildps(sp, str, O_STR(sp, O_SECTIONS)));
case O_SECTIONS:
diff --git a/vi/v_itxt.c b/vi/v_itxt.c
index 6cf93773ac3d..8b263297aeb0 100644
--- a/vi/v_itxt.c
+++ b/vi/v_itxt.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_itxt.c 10.16 (Berkeley) 10/23/96";
+static const char sccsid[] = "$Id: v_itxt.c,v 10.21 2001/06/25 15:19:32 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -66,9 +66,7 @@ static u_int32_t set_txt_std __P((SCR *, VICMD *, u_int32_t));
* PUBLIC: int v_iA __P((SCR *, VICMD *));
*/
int
-v_iA(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_iA(SCR *sp, VICMD *vp)
{
size_t len;
@@ -88,14 +86,12 @@ v_iA(sp, vp)
* PUBLIC: int v_ia __P((SCR *, VICMD *));
*/
int
-v_ia(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_ia(SCR *sp, VICMD *vp)
{
size_t len;
u_int32_t flags;
int isempty;
- char *p;
+ CHAR_T *p;
flags = set_txt_std(sp, vp, 0);
sp->showmode = SM_APPEND;
@@ -127,9 +123,7 @@ v_ia(sp, vp)
* PUBLIC: int v_iI __P((SCR *, VICMD *));
*/
int
-v_iI(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_iI(SCR *sp, VICMD *vp)
{
sp->cno = 0;
if (nonblank(sp, vp->m_start.lno, &sp->cno))
@@ -148,14 +142,12 @@ v_iI(sp, vp)
* PUBLIC: int v_ii __P((SCR *, VICMD *));
*/
int
-v_ii(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_ii(SCR *sp, VICMD *vp)
{
size_t len;
u_int32_t flags;
int isempty;
- char *p;
+ CHAR_T *p;
flags = set_txt_std(sp, vp, 0);
sp->showmode = SM_INSERT;
@@ -183,9 +175,7 @@ static int io __P((SCR *, VICMD *, enum which));
* PUBLIC: int v_iO __P((SCR *, VICMD *));
*/
int
-v_iO(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_iO(SCR *sp, VICMD *vp)
{
return (io(sp, vp, O_cmd));
}
@@ -197,23 +187,18 @@ v_iO(sp, vp)
* PUBLIC: int v_io __P((SCR *, VICMD *));
*/
int
-v_io(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_io(SCR *sp, VICMD *vp)
{
return (io(sp, vp, o_cmd));
}
static int
-io(sp, vp, cmd)
- SCR *sp;
- VICMD *vp;
- enum which cmd;
+io(SCR *sp, VICMD *vp, enum which cmd)
{
recno_t ai_line, lno;
size_t len;
u_int32_t flags;
- char *p;
+ CHAR_T *p;
flags = set_txt_std(sp, vp, TXT_ADDNEWLINE | TXT_APPENDEOL);
sp->showmode = SM_INSERT;
@@ -227,7 +212,7 @@ io(sp, vp, cmd)
len = 0;
ai_line = OOBLNO;
} else {
-insert: p = "";
+insert: p = L("");
sp->cno = 0;
LOG_CORRECT;
@@ -258,14 +243,13 @@ insert: p = "";
* PUBLIC: int v_change __P((SCR *, VICMD *));
*/
int
-v_change(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_change(SCR *sp, VICMD *vp)
{
size_t blen, len;
u_int32_t flags;
int isempty, lmode, rval;
- char *bp, *p;
+ CHAR_T *bp;
+ CHAR_T *p;
/*
* 'c' can be combined with motion commands that set the resulting
@@ -356,8 +340,8 @@ v_change(sp, vp)
*/
if (db_get(sp, vp->m_start.lno, DBG_FATAL, &p, &len))
return (1);
- GET_SPACE_RET(sp, bp, blen, vp->m_start.cno);
- memmove(bp, p, vp->m_start.cno);
+ GET_SPACE_RETW(sp, bp, blen, vp->m_start.cno);
+ MEMMOVE(bp, p, vp->m_start.cno);
} else
bp = NULL;
@@ -388,7 +372,7 @@ v_change(sp, vp)
0, OOBLNO, F_ISSET(vp, VC_C1SET) ? vp->count : 1, flags);
if (bp != NULL)
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
return (rval);
}
@@ -399,14 +383,12 @@ v_change(sp, vp)
* PUBLIC: int v_Replace __P((SCR *, VICMD *));
*/
int
-v_Replace(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_Replace(SCR *sp, VICMD *vp)
{
size_t len;
u_int32_t flags;
int isempty;
- char *p;
+ CHAR_T *p;
flags = set_txt_std(sp, vp, 0);
sp->showmode = SM_REPLACE;
@@ -435,14 +417,12 @@ v_Replace(sp, vp)
* PUBLIC: int v_subst __P((SCR *, VICMD *));
*/
int
-v_subst(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_subst(SCR *sp, VICMD *vp)
{
size_t len;
u_int32_t flags;
int isempty;
- char *p;
+ CHAR_T *p;
flags = set_txt_std(sp, vp, 0);
sp->showmode = SM_CHANGE;
@@ -477,10 +457,7 @@ v_subst(sp, vp)
* Initialize text processing flags.
*/
static u_int32_t
-set_txt_std(sp, vp, flags)
- SCR *sp;
- VICMD *vp;
- u_int32_t flags;
+set_txt_std(SCR *sp, VICMD *vp, u_int32_t flags)
{
LF_SET(TXT_CNTRLT |
TXT_ESCAPE | TXT_MAPINPUT | TXT_RECORD | TXT_RESOLVE);
diff --git a/vi/v_left.c b/vi/v_left.c
index cfed80c74bf4..2a8f6e61b83a 100644
--- a/vi/v_left.c
+++ b/vi/v_left.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_left.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_left.c,v 10.9 2001/06/25 15:19:32 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -31,9 +31,7 @@ static const char sccsid[] = "@(#)v_left.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int v_left __P((SCR *, VICMD *));
*/
int
-v_left(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_left(SCR *sp, VICMD *vp)
{
recno_t cnt;
@@ -71,9 +69,7 @@ v_left(sp, vp)
* PUBLIC: int v_cfirst __P((SCR *, VICMD *));
*/
int
-v_cfirst(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_cfirst(SCR *sp, VICMD *vp)
{
recno_t cnt, lno;
@@ -140,9 +136,7 @@ v_cfirst(sp, vp)
* PUBLIC: int v_first __P((SCR *, VICMD *));
*/
int
-v_first(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_first(SCR *sp, VICMD *vp)
{
/*
* !!!
@@ -204,9 +198,7 @@ v_first(sp, vp)
* PUBLIC: int v_ncol __P((SCR *, VICMD *));
*/
int
-v_ncol(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_ncol(SCR *sp, VICMD *vp)
{
if (F_ISSET(vp, VC_C1SET) && vp->count > 1) {
--vp->count;
@@ -266,9 +258,7 @@ v_ncol(sp, vp)
* PUBLIC: int v_zero __P((SCR *, VICMD *));
*/
int
-v_zero(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_zero(SCR *sp, VICMD *vp)
{
/*
* !!!
diff --git a/vi/v_mark.c b/vi/v_mark.c
index 447430efabe8..39ed0aaae3be 100644
--- a/vi/v_mark.c
+++ b/vi/v_mark.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_mark.c 10.8 (Berkeley) 9/20/96";
+static const char sccsid[] = "$Id: v_mark.c,v 10.12 2001/06/25 15:19:32 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -25,6 +25,9 @@ static const char sccsid[] = "@(#)v_mark.c 10.8 (Berkeley) 9/20/96";
#include "../common/common.h"
#include "vi.h"
+enum which {BQMARK, FQMARK};
+static int mark __P((SCR *, VICMD *, int, enum which));
+
/*
* v_mark -- m[a-z]
* Set a mark.
@@ -32,17 +35,11 @@ static const char sccsid[] = "@(#)v_mark.c 10.8 (Berkeley) 9/20/96";
* PUBLIC: int v_mark __P((SCR *, VICMD *));
*/
int
-v_mark(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_mark(SCR *sp, VICMD *vp)
{
return (mark_set(sp, vp->character, &vp->m_start, 1));
}
-enum which {BQMARK, FQMARK};
-static int mark __P((SCR *, VICMD *, enum which));
-
-
/*
* v_bmark -- `['`a-z]
* Move to a mark.
@@ -59,11 +56,9 @@ static int mark __P((SCR *, VICMD *, enum which));
* PUBLIC: int v_bmark __P((SCR *, VICMD *));
*/
int
-v_bmark(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_bmark(SCR *sp, VICMD *vp)
{
- return (mark(sp, vp, BQMARK));
+ return (mark(sp, vp, 1, BQMARK));
}
/*
@@ -75,11 +70,31 @@ v_bmark(sp, vp)
* PUBLIC: int v_fmark __P((SCR *, VICMD *));
*/
int
-v_fmark(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_fmark(SCR *sp, VICMD *vp)
{
- return (mark(sp, vp, FQMARK));
+ return (mark(sp, vp, 1, FQMARK));
+}
+
+/*
+ * v_emark -- <mouse click>
+ * Mouse mark.
+ *
+ * PUBLIC: int v_emark __P((SCR *, VICMD *));
+ */
+int
+v_emark(SCR *sp, VICMD *vp)
+{
+ SMAP *smp;
+
+ smp = HMAP + vp->ev.e_lno;
+ if (smp > TMAP) {
+ msgq(sp, M_BERR, "320|Unknown cursor position.");
+ return (1);
+ }
+ vp->m_stop.lno = smp->lno;
+ vp->m_stop.cno =
+ vs_colpos(sp, smp->lno, vp->ev.e_cno + (smp->soff - 1) * sp->cols);
+ return (mark(sp, vp, 0, BQMARK));
}
/*
@@ -87,16 +102,13 @@ v_fmark(sp, vp)
* Mark commands.
*/
static int
-mark(sp, vp, cmd)
- SCR *sp;
- VICMD *vp;
- enum which cmd;
+mark(SCR *sp, VICMD *vp, int getmark, enum which cmd)
{
dir_t dir;
MARK m;
size_t len;
- if (mark_get(sp, vp->character, &vp->m_stop, M_BERR))
+ if (getmark && mark_get(sp, vp->character, &vp->m_stop, M_BERR))
return (1);
/*
@@ -111,7 +123,7 @@ mark(sp, vp, cmd)
if (db_get(sp, vp->m_stop.lno, DBG_FATAL, NULL, &len))
return (1);
if (vp->m_stop.cno < len ||
- vp->m_stop.cno == len && len == 0)
+ (vp->m_stop.cno == len && len == 0))
break;
if (ISMOTION(vp))
@@ -152,8 +164,8 @@ mark(sp, vp, cmd)
* and backward motions can happen for any kind of search command.
*/
if (vp->m_start.lno > vp->m_stop.lno ||
- vp->m_start.lno == vp->m_stop.lno &&
- vp->m_start.cno > vp->m_stop.cno) {
+ (vp->m_start.lno == vp->m_stop.lno &&
+ vp->m_start.cno > vp->m_stop.cno)) {
m = vp->m_start;
vp->m_start = vp->m_stop;
vp->m_stop = m;
@@ -187,15 +199,15 @@ mark(sp, vp, cmd)
#ifdef HISTORICAL_PRACTICE
if (ISCMD(vp->rkp, 'y')) {
if ((cmd == BQMARK ||
- cmd == FQMARK && vp->m_start.lno != vp->m_stop.lno) &&
+ (cmd == FQMARK && vp->m_start.lno != vp->m_stop.lno)) &&
(vp->m_start.lno > vp->m_stop.lno ||
- vp->m_start.lno == vp->m_stop.lno &&
- vp->m_start.cno > vp->m_stop.cno))
+ (vp->m_start.lno == vp->m_stop.lno &&
+ vp->m_start.cno > vp->m_stop.cno)))
vp->m_final = vp->m_stop;
} else if (ISCMD(vp->rkp, 'd'))
if (vp->m_start.lno > vp->m_stop.lno ||
- vp->m_start.lno == vp->m_stop.lno &&
- vp->m_start.cno > vp->m_stop.cno)
+ (vp->m_start.lno == vp->m_stop.lno &&
+ vp->m_start.cno > vp->m_stop.cno))
vp->m_final = vp->m_stop;
#else
vp->m_final = vp->m_start;
diff --git a/vi/v_match.c b/vi/v_match.c
index 3996560aaa73..2fae58e3a8e1 100644
--- a/vi/v_match.c
+++ b/vi/v_match.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_match.c 10.8 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_match.c,v 10.11 2012/02/11 00:33:46 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -18,8 +18,10 @@ static const char sccsid[] = "@(#)v_match.c 10.8 (Berkeley) 3/6/96";
#include <sys/time.h>
#include <bitstring.h>
+#include <ctype.h>
#include <limits.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "../common/common.h"
@@ -32,15 +34,23 @@ static const char sccsid[] = "@(#)v_match.c 10.8 (Berkeley) 3/6/96";
* PUBLIC: int v_match __P((SCR *, VICMD *));
*/
int
-v_match(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_match(SCR *sp, VICMD *vp)
{
VCS cs;
MARK *mp;
size_t cno, len, off;
int cnt, isempty, matchc, startc, (*gc)__P((SCR *, VCS *));
- char *p;
+ CHAR_T *p;
+ CHAR_T *cp;
+ const CHAR_T *match_chars;
+
+ /*
+ * Historically vi would match (), {} and [] however
+ * an update included <>. This is ok for editing HTML
+ * but a pain in the butt for C source.
+ * Making it an option lets the user decide what is 'right'.
+ */
+ match_chars = VIP(sp)->mcs;
/*
* !!!
@@ -60,43 +70,14 @@ v_match(sp, vp)
nomatch: msgq(sp, M_BERR, "184|No match character on this line");
return (1);
}
- switch (startc = p[off]) {
- case '(':
- matchc = ')';
- gc = cs_next;
- break;
- case ')':
- matchc = '(';
- gc = cs_prev;
- break;
- case '[':
- matchc = ']';
- gc = cs_next;
- break;
- case ']':
- matchc = '[';
- gc = cs_prev;
+ startc = p[off];
+ cp = STRCHR(match_chars, startc);
+ if (cp != NULL) {
+ cnt = cp - match_chars;
+ matchc = match_chars[cnt ^ 1];
+ gc = cnt & 1 ? cs_prev : cs_next;
break;
- case '{':
- matchc = '}';
- gc = cs_next;
- break;
- case '}':
- matchc = '{';
- gc = cs_prev;
- break;
- case '<':
- matchc = '>';
- gc = cs_next;
- break;
- case '>':
- matchc = '<';
- gc = cs_prev;
- break;
- default:
- continue;
}
- break;
}
cs.cs_lno = vp->m_start.lno;
@@ -135,8 +116,8 @@ nomatch: msgq(sp, M_BERR, "184|No match character on this line");
* starting cursor position when deleting to a match.
*/
if (vp->m_start.lno < vp->m_stop.lno ||
- vp->m_start.lno == vp->m_stop.lno &&
- vp->m_start.cno < vp->m_stop.cno)
+ (vp->m_start.lno == vp->m_stop.lno &&
+ vp->m_start.cno < vp->m_stop.cno))
vp->m_final = ISMOTION(vp) ? vp->m_start : vp->m_stop;
else
vp->m_final = vp->m_stop;
@@ -168,3 +149,29 @@ nomatch: msgq(sp, M_BERR, "184|No match character on this line");
F_SET(vp, VM_LMODE);
return (0);
}
+
+/*
+ * v_buildmcs --
+ * Build the match character list.
+ *
+ * PUBLIC: int v_buildmcs __P((SCR *, char *));
+ */
+int
+v_buildmcs(SCR *sp, char *str)
+{
+ CHAR_T **mp = &VIP(sp)->mcs;
+ size_t len = strlen(str) + 1;
+
+ if (*mp != NULL)
+ free(*mp);
+ MALLOC(sp, *mp, CHAR_T *, len * sizeof(CHAR_T));
+ if (*mp == NULL)
+ return (1);
+#ifdef USE_WIDECHAR
+ if (mbstowcs(*mp, str, len) == (size_t)-1)
+ return (1);
+#else
+ memcpy(*mp, str, len);
+#endif
+ return (0);
+}
diff --git a/vi/v_paragraph.c b/vi/v_paragraph.c
index 762e38e01671..4ff4b15ec0d5 100644
--- a/vi/v_paragraph.c
+++ b/vi/v_paragraph.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_paragraph.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_paragraph.c,v 10.10 2001/06/25 15:19:32 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -64,15 +64,14 @@ static const char sccsid[] = "@(#)v_paragraph.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int v_paragraphf __P((SCR *, VICMD *));
*/
int
-v_paragraphf(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_paragraphf(SCR *sp, VICMD *vp)
{
enum { P_INTEXT, P_INBLANK } pstate;
size_t lastlen, len;
recno_t cnt, lastlno, lno;
int isempty;
- char *p, *lp;
+ CHAR_T *p;
+ char *lp;
/*
* !!!
@@ -203,14 +202,13 @@ eof: if (vp->m_start.lno == lno || vp->m_start.lno == lno - 1) {
* PUBLIC: int v_paragraphb __P((SCR *, VICMD *));
*/
int
-v_paragraphb(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_paragraphb(SCR *sp, VICMD *vp)
{
enum { P_INTEXT, P_INBLANK } pstate;
size_t len;
recno_t cnt, lno;
- char *p, *lp;
+ CHAR_T *p;
+ char *lp;
/*
* !!!
@@ -311,9 +309,7 @@ found: vp->m_stop.lno = lno;
* PUBLIC: int v_buildps __P((SCR *, char *, char *));
*/
int
-v_buildps(sp, p_p, s_p)
- SCR *sp;
- char *p_p, *s_p;
+v_buildps(SCR *sp, char *p_p, char *s_p)
{
VI_PRIVATE *vip;
size_t p_len, s_len;
diff --git a/vi/v_put.c b/vi/v_put.c
index 77220ea14ff9..a739bd1a80e3 100644
--- a/vi/v_put.c
+++ b/vi/v_put.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_put.c 10.5 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_put.c,v 10.6 2001/06/25 15:19:34 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -33,9 +33,7 @@ static void inc_buf __P((SCR *, VICMD *));
* PUBLIC: int v_Put __P((SCR *, VICMD *));
*/
int
-v_Put(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_Put(SCR *sp, VICMD *vp)
{
u_long cnt;
@@ -66,9 +64,7 @@ v_Put(sp, vp)
* PUBLIC: int v_put __P((SCR *, VICMD *));
*/
int
-v_put(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_put(SCR *sp, VICMD *vp)
{
u_long cnt;
@@ -108,9 +104,7 @@ v_put(sp, vp)
* the buffer increment gets done regardless of the success of the put.
*/
static void
-inc_buf(sp, vp)
- SCR *sp;
- VICMD *vp;
+inc_buf(SCR *sp, VICMD *vp)
{
CHAR_T v;
diff --git a/vi/v_redraw.c b/vi/v_redraw.c
index 4c965c713913..979f37c70ecc 100644
--- a/vi/v_redraw.c
+++ b/vi/v_redraw.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_redraw.c 10.6 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_redraw.c,v 10.7 2001/06/25 15:19:34 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -31,9 +31,7 @@ static const char sccsid[] = "@(#)v_redraw.c 10.6 (Berkeley) 3/6/96";
* PUBLIC: int v_redraw __P((SCR *, VICMD *));
*/
int
-v_redraw(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_redraw(SCR *sp, VICMD *vp)
{
return (sp->gp->scr_refresh(sp, 1));
}
diff --git a/vi/v_replace.c b/vi/v_replace.c
index a4712b683a91..2a7ea979e86f 100644
--- a/vi/v_replace.c
+++ b/vi/v_replace.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_replace.c 10.17 (Berkeley) 6/30/96";
+static const char sccsid[] = "$Id: v_replace.c,v 10.24 2001/06/25 15:19:34 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -43,9 +43,7 @@ static const char sccsid[] = "@(#)v_replace.c 10.17 (Berkeley) 6/30/96";
* PUBLIC: int v_replace __P((SCR *, VICMD *));
*/
int
-v_replace(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_replace(SCR *sp, VICMD *vp)
{
EVENT ev;
VI_PRIVATE *vip;
@@ -53,7 +51,8 @@ v_replace(sp, vp)
size_t blen, len;
u_long cnt;
int quote, rval;
- char *bp, *p;
+ CHAR_T *bp;
+ CHAR_T *p;
vip = VIP(sp);
@@ -144,8 +143,8 @@ next: if (v_event_get(sp, &ev, 0, 0))
}
/* Copy the line. */
- GET_SPACE_RET(sp, bp, blen, len);
- memmove(bp, p, len);
+ GET_SPACE_RETW(sp, bp, blen, len);
+ MEMMOVE(bp, p, len);
p = bp;
/*
@@ -154,7 +153,7 @@ next: if (v_event_get(sp, &ev, 0, 0))
* is different from the historic vi, which replaced N characters with
* a single new line. Users complained, so we match historic practice.
*/
- if (!quote && vip->rvalue == K_CR || vip->rvalue == K_NL) {
+ if ((!quote && vip->rvalue == K_CR) || vip->rvalue == K_NL) {
/* Set return line. */
vp->m_stop.lno = vp->m_start.lno + 1;
vp->m_stop.cno = 0;
@@ -193,10 +192,10 @@ err_ret: rval = 1;
rval = 0;
}
} else {
- memset(bp + vp->m_start.cno, vip->rlast, cnt);
+ STRSET(bp + vp->m_start.cno, vip->rlast, cnt);
rval = db_set(sp, vp->m_start.lno, bp, len);
}
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
vp->m_final = vp->m_stop;
return (rval);
diff --git a/vi/v_right.c b/vi/v_right.c
index c2f349eb2328..566f952716af 100644
--- a/vi/v_right.c
+++ b/vi/v_right.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_right.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_right.c,v 10.8 2001/06/25 15:19:34 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -31,9 +31,7 @@ static const char sccsid[] = "@(#)v_right.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int v_right __P((SCR *, VICMD *));
*/
int
-v_right(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_right(SCR *sp, VICMD *vp)
{
size_t len;
int isempty;
@@ -83,9 +81,7 @@ eol: v_eol(sp, NULL);
* PUBLIC: int v_dollar __P((SCR *, VICMD *));
*/
int
-v_dollar(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_dollar(SCR *sp, VICMD *vp)
{
size_t len;
int isempty;
diff --git a/vi/v_screen.c b/vi/v_screen.c
index 85cd1e32bca0..d7932a4e7b1a 100644
--- a/vi/v_screen.c
+++ b/vi/v_screen.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_screen.c 10.10 (Berkeley) 4/27/96";
+static const char sccsid[] = "$Id: v_screen.c,v 10.12 2001/06/25 15:19:34 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -31,9 +31,7 @@ static const char sccsid[] = "@(#)v_screen.c 10.10 (Berkeley) 4/27/96";
* PUBLIC: int v_screen __P((SCR *, VICMD *));
*/
int
-v_screen(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_screen(SCR *sp, VICMD *vp)
{
/*
* You can't leave a colon command-line edit window -- it's not that
@@ -51,13 +49,13 @@ v_screen(sp, vp)
* Try for the next lower screen, or, go back to the first
* screen on the stack.
*/
- if (sp->q.cqe_next != (void *)&sp->gp->dq)
- sp->nextdisp = sp->q.cqe_next;
- else if (sp->gp->dq.cqh_first == sp) {
+ if (TAILQ_NEXT(sp, q) != NULL)
+ sp->nextdisp = TAILQ_NEXT(sp, q);
+ else if (TAILQ_FIRST(sp->gp->dq) == sp) {
msgq(sp, M_ERR, "187|No other screen to switch to");
return (1);
} else
- sp->nextdisp = sp->gp->dq.cqh_first;
+ sp->nextdisp = TAILQ_FIRST(sp->gp->dq);
F_SET(sp->nextdisp, SC_STATUS);
F_SET(sp, SC_SSWITCH | SC_STATUS);
diff --git a/vi/v_scroll.c b/vi/v_scroll.c
index 92def4b3e48d..71528a02b220 100644
--- a/vi/v_scroll.c
+++ b/vi/v_scroll.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_scroll.c 10.9 (Berkeley) 4/27/96";
+static const char sccsid[] = "$Id: v_scroll.c,v 10.12 2001/06/25 15:19:34 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -67,9 +67,7 @@ static void goto_adjust __P((VICMD *));
* PUBLIC: int v_lgoto __P((SCR *, VICMD *));
*/
int
-v_lgoto(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_lgoto(SCR *sp, VICMD *vp)
{
recno_t nlines;
@@ -106,9 +104,7 @@ v_lgoto(sp, vp)
* PUBLIC: int v_home __P((SCR *, VICMD *));
*/
int
-v_home(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_home(SCR *sp, VICMD *vp)
{
if (vs_sm_position(sp, &vp->m_stop,
F_ISSET(vp, VC_C1SET) ? vp->count - 1 : 0, P_TOP))
@@ -125,9 +121,7 @@ v_home(sp, vp)
* PUBLIC: int v_middle __P((SCR *, VICMD *));
*/
int
-v_middle(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_middle(SCR *sp, VICMD *vp)
{
/*
* Yielding to none in our quest for compatibility with every
@@ -148,9 +142,7 @@ v_middle(sp, vp)
* PUBLIC: int v_bottom __P((SCR *, VICMD *));
*/
int
-v_bottom(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_bottom(SCR *sp, VICMD *vp)
{
if (vs_sm_position(sp, &vp->m_stop,
F_ISSET(vp, VC_C1SET) ? vp->count - 1 : 0, P_BOTTOM))
@@ -160,8 +152,7 @@ v_bottom(sp, vp)
}
static void
-goto_adjust(vp)
- VICMD *vp;
+goto_adjust(VICMD *vp)
{
/* Guess that it's the end of the range. */
vp->m_final = vp->m_stop;
@@ -199,8 +190,8 @@ goto_adjust(vp)
* stay at the start of the range. Ignore others.
*/
if (vp->m_stop.lno < vp->m_start.lno ||
- vp->m_stop.lno == vp->m_start.lno &&
- vp->m_stop.cno < vp->m_start.cno) {
+ (vp->m_stop.lno == vp->m_start.lno &&
+ vp->m_stop.cno < vp->m_start.cno)) {
if (ISCMD(vp->rkp, 'y') && vp->m_stop.lno == vp->m_start.lno)
vp->m_final = vp->m_start;
} else
@@ -214,9 +205,7 @@ goto_adjust(vp)
* PUBLIC: int v_up __P((SCR *, VICMD *));
*/
int
-v_up(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_up(SCR *sp, VICMD *vp)
{
recno_t lno;
@@ -238,9 +227,7 @@ v_up(sp, vp)
* PUBLIC: int v_cr __P((SCR *, VICMD *));
*/
int
-v_cr(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_cr(SCR *sp, VICMD *vp)
{
/* If it's a colon command-line edit window, it's an ex command. */
if (F_ISSET(sp, SC_COMEDIT))
@@ -261,9 +248,7 @@ v_cr(sp, vp)
* PUBLIC: int v_down __P((SCR *, VICMD *));
*/
int
-v_down(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_down(SCR *sp, VICMD *vp)
{
recno_t lno;
@@ -284,9 +269,7 @@ v_down(sp, vp)
* PUBLIC: int v_hpageup __P((SCR *, VICMD *));
*/
int
-v_hpageup(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_hpageup(SCR *sp, VICMD *vp)
{
/*
* Half screens always succeed unless already at SOF.
@@ -310,9 +293,7 @@ v_hpageup(sp, vp)
* PUBLIC: int v_hpagedown __P((SCR *, VICMD *));
*/
int
-v_hpagedown(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_hpagedown(SCR *sp, VICMD *vp)
{
/*
* Half screens always succeed unless already at EOF.
@@ -340,9 +321,7 @@ v_hpagedown(sp, vp)
* PUBLIC: int v_pagedown __P((SCR *, VICMD *));
*/
int
-v_pagedown(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_pagedown(SCR *sp, VICMD *vp)
{
recno_t offset;
@@ -361,8 +340,8 @@ v_pagedown(sp, vp)
* any screen but the "next" one anyway. We do it the historical
* way as there's no good reason to change it.
*
- * If the screen has been split, use the smaller of the current
- * window size and the window option value.
+ * If the screen has been split horizontally, use the smaller of
+ * the current window size and the window option value.
*
* It possible for this calculation to be less than 1; move at
* least one line.
@@ -388,9 +367,7 @@ v_pagedown(sp, vp)
* PUBLIC: int v_pageup __P((SCR *, VICMD *));
*/
int
-v_pageup(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_pageup(SCR *sp, VICMD *vp)
{
recno_t offset;
@@ -414,8 +391,8 @@ v_pageup(sp, vp)
* but the first screen. We do it the historical way as there's
* no good reason to change it.
*
- * If the screen has been split, use the smaller of the current
- * window size and the window option value.
+ * If the screen has been split horizontally, use the smaller of
+ * the current window size and the window option value.
*
* It possible for this calculation to be less than 1; move at
* least one line.
@@ -436,9 +413,7 @@ v_pageup(sp, vp)
* PUBLIC: int v_lineup __P((SCR *, VICMD *));
*/
int
-v_lineup(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_lineup(SCR *sp, VICMD *vp)
{
/*
* The cursor moves down, staying with its original line, unless it
@@ -458,9 +433,7 @@ v_lineup(sp, vp)
* PUBLIC: int v_linedown __P((SCR *, VICMD *));
*/
int
-v_linedown(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_linedown(SCR *sp, VICMD *vp)
{
/*
* The cursor moves up, staying with its original line, unless it
diff --git a/vi/v_search.c b/vi/v_search.c
index 4f7a2671ab8e..1d6b26030118 100644
--- a/vi/v_search.c
+++ b/vi/v_search.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_search.c 10.18 (Berkeley) 9/19/96";
+static const char sccsid[] = "$Id: v_search.c,v 10.31 2012/02/08 07:26:59 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -29,7 +29,7 @@ static const char sccsid[] = "@(#)v_search.c 10.18 (Berkeley) 9/19/96";
#include "vi.h"
static int v_exaddr __P((SCR *, VICMD *, dir_t));
-static int v_search __P((SCR *, VICMD *, char *, size_t, u_int, dir_t));
+static int v_search __P((SCR *, VICMD *, CHAR_T *, size_t, u_int, dir_t));
/*
* v_srch -- [count]?RE[? offset]
@@ -38,9 +38,7 @@ static int v_search __P((SCR *, VICMD *, char *, size_t, u_int, dir_t));
* PUBLIC: int v_searchb __P((SCR *, VICMD *));
*/
int
-v_searchb(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_searchb(SCR *sp, VICMD *vp)
{
return (v_exaddr(sp, vp, BACKWARD));
}
@@ -52,9 +50,7 @@ v_searchb(sp, vp)
* PUBLIC: int v_searchf __P((SCR *, VICMD *));
*/
int
-v_searchf(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_searchf(SCR *sp, VICMD *vp)
{
return (v_exaddr(sp, vp, FORWARD));
}
@@ -64,19 +60,19 @@ v_searchf(sp, vp)
* Do a vi search (which is really an ex address).
*/
static int
-v_exaddr(sp, vp, dir)
- SCR *sp;
- VICMD *vp;
- dir_t dir;
+v_exaddr(SCR *sp, VICMD *vp, dir_t dir)
{
- static EXCMDLIST fake = { "search" };
+ static EXCMDLIST fake = { L("search") };
EXCMD *cmdp;
GS *gp;
TEXT *tp;
recno_t s_lno;
size_t len, s_cno, tlen;
int err, nb, type;
- char *cmd, *t, buf[20];
+ char buf[20];
+ CHAR_T *cmd, *t;
+ CHAR_T *w;
+ size_t wlen;
/*
* !!!
@@ -93,7 +89,7 @@ v_exaddr(sp, vp, dir)
(O_ISSET(sp, O_SEARCHINCR) ? TXT_SEARCHINCR : 0)))
return (1);
- tp = sp->tiq.cqh_first;
+ tp = TAILQ_FIRST(sp->tiq);
/* If the user backspaced over the prompt, do nothing. */
if (tp->term == TERM_BS)
@@ -245,7 +241,7 @@ v_exaddr(sp, vp, dir)
/* Default to z+. */
if (!type &&
- v_event_push(sp, NULL, "+", 1, CH_NOMAP | CH_QUOTED))
+ v_event_push(sp, NULL, L("+"), 1, CH_NOMAP | CH_QUOTED))
return (1);
/* Push the user's command. */
@@ -255,7 +251,8 @@ v_exaddr(sp, vp, dir)
/* Push line number so get correct z display. */
tlen = snprintf(buf,
sizeof(buf), "%lu", (u_long)vp->m_stop.lno);
- if (v_event_push(sp, NULL, buf, tlen, CH_NOMAP | CH_QUOTED))
+ CHAR2INT(sp, buf, tlen, w, wlen);
+ if (v_event_push(sp, NULL, w, wlen, CH_NOMAP | CH_QUOTED))
return (1);
/* Don't refresh until after 'z' happens. */
@@ -284,9 +281,7 @@ err2: vp->m_final.lno = s_lno;
* PUBLIC: int v_searchN __P((SCR *, VICMD *));
*/
int
-v_searchN(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_searchN(SCR *sp, VICMD *vp)
{
dir_t dir;
@@ -311,35 +306,82 @@ v_searchN(sp, vp)
* PUBLIC: int v_searchn __P((SCR *, VICMD *));
*/
int
-v_searchn(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_searchn(SCR *sp, VICMD *vp)
{
return (v_search(sp, vp, NULL, 0, SEARCH_PARSE, sp->searchdir));
}
/*
+ * is_special --
+ * Test if the character is special in a basic RE.
+ */
+static int
+is_special(CHAR_T c)
+{
+ /*
+ * !!!
+ * `*' and `$' are ordinary when appear at the beginning of a RE,
+ * but it's safe to distinguish them from the ordinary characters.
+ * The tilde is vi-specific, of course.
+ */
+ return (STRCHR(L(".[*\\^$~"), c) && c);
+}
+
+/*
+ * Rear delimiter for word search when the keyword ends in
+ * (i.e., consists of) a non-word character. See v_searchw below.
+ */
+#define RE_NWSTOP L("([^[:alnum:]_]|$)")
+#define RE_NWSTOP_LEN (SIZE(RE_NWSTOP) - 1)
+
+/*
* v_searchw -- [count]^A
* Search for the word under the cursor.
*
* PUBLIC: int v_searchw __P((SCR *, VICMD *));
*/
int
-v_searchw(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_searchw(SCR *sp, VICMD *vp)
{
size_t blen, len;
int rval;
- char *bp;
+ CHAR_T *bp, *p;
+
+ /* An upper bound for the SIZE of the RE under construction. */
+ len = VIP(sp)->klen + MAX(RE_WSTART_LEN, 1)
+ + MAX(RE_WSTOP_LEN, RE_NWSTOP_LEN);
+ GET_SPACE_RETW(sp, bp, blen, len);
+ p = bp;
+
+ /* Only the first character can be non-word, see v_curword. */
+ if (inword(VIP(sp)->keyw[0])) {
+ MEMCPY(p, RE_WSTART, RE_WSTART_LEN);
+ p += RE_WSTART_LEN;
+ } else if (is_special(VIP(sp)->keyw[0])) {
+ MEMCPY(p, L("\\"), 1);
+ p += 1;
+ }
- len = VIP(sp)->klen + sizeof(RE_WSTART) + sizeof(RE_WSTOP);
- GET_SPACE_RET(sp, bp, blen, len);
- len = snprintf(bp, blen, "%s%s%s", RE_WSTART, VIP(sp)->keyw, RE_WSTOP);
+ MEMCPY(p, VIP(sp)->keyw, VIP(sp)->klen);
+ p += VIP(sp)->klen;
+
+ if (inword(p[-1])) {
+ MEMCPY(p, RE_WSTOP, RE_WSTOP_LEN);
+ p += RE_WSTOP_LEN;
+ } else {
+ /*
+ * The keyword is a single non-word character.
+ * We want it to stay the same when typing ^A several times
+ * in a row, just the way the other cases behave.
+ */
+ MEMCPY(p, RE_NWSTOP, RE_NWSTOP_LEN);
+ p += RE_NWSTOP_LEN;
+ }
+ len = p - bp;
rval = v_search(sp, vp, bp, len, SEARCH_SET, FORWARD);
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
return (rval);
}
@@ -348,13 +390,7 @@ v_searchw(sp, vp)
* The search commands.
*/
static int
-v_search(sp, vp, ptrn, plen, flags, dir)
- SCR *sp;
- VICMD *vp;
- u_int flags;
- char *ptrn;
- size_t plen;
- dir_t dir;
+v_search(SCR *sp, VICMD *vp, CHAR_T *ptrn, size_t plen, u_int flags, dir_t dir)
{
/* Display messages. */
LF_SET(SEARCH_MSG);
@@ -417,10 +453,7 @@ v_search(sp, vp, ptrn, plen, flags, dir)
* PUBLIC: int v_correct __P((SCR *, VICMD *, int));
*/
int
-v_correct(sp, vp, isdelta)
- SCR *sp;
- VICMD *vp;
- int isdelta;
+v_correct(SCR *sp, VICMD *vp, int isdelta)
{
dir_t dir;
MARK m;
@@ -462,8 +495,8 @@ v_correct(sp, vp, isdelta)
* because of the wrapscan option.
*/
if (vp->m_start.lno > vp->m_stop.lno ||
- vp->m_start.lno == vp->m_stop.lno &&
- vp->m_start.cno > vp->m_stop.cno) {
+ (vp->m_start.lno == vp->m_stop.lno &&
+ vp->m_start.cno > vp->m_stop.cno)) {
m = vp->m_start;
vp->m_start = vp->m_stop;
vp->m_stop = m;
diff --git a/vi/v_section.c b/vi/v_section.c
index 20e8ff2808fd..e769cdad3289 100644
--- a/vi/v_section.c
+++ b/vi/v_section.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_section.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_section.c,v 10.10 2001/06/25 15:19:35 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -62,13 +62,12 @@ static const char sccsid[] = "@(#)v_section.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int v_sectionf __P((SCR *, VICMD *));
*/
int
-v_sectionf(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_sectionf(SCR *sp, VICMD *vp)
{
recno_t cnt, lno;
size_t len;
- char *p, *list, *lp;
+ CHAR_T *p;
+ char *list, *lp;
/* Get the macro list. */
if ((list = O_STR(sp, O_SECTIONS)) == NULL)
@@ -98,7 +97,7 @@ v_sectionf(sp, vp)
for (lno = vp->m_start.lno; !db_get(sp, ++lno, 0, &p, &len);) {
if (len == 0)
continue;
- if (p[0] == '{' || ISMOTION(vp) && p[0] == '}') {
+ if (p[0] == '{' || (ISMOTION(vp) && p[0] == '}')) {
if (!--cnt) {
if (p[0] == '{')
goto adjust1;
@@ -122,7 +121,7 @@ v_sectionf(sp, vp)
continue;
for (lp = list; *lp != '\0'; lp += 2 * sizeof(*lp))
if (lp[0] == p[1] &&
- (lp[1] == ' ' && len == 2 || lp[1] == p[2]) &&
+ ((lp[1] == ' ' && len == 2) || lp[1] == p[2]) &&
!--cnt) {
/*
* !!!
@@ -170,13 +169,12 @@ ret2: if (ISMOTION(vp)) {
* PUBLIC: int v_sectionb __P((SCR *, VICMD *));
*/
int
-v_sectionb(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_sectionb(SCR *sp, VICMD *vp)
{
size_t len;
recno_t cnt, lno;
- char *p, *list, *lp;
+ CHAR_T *p;
+ char *list, *lp;
/* An empty file or starting from line 1 is always illegal. */
if (vp->m_start.lno <= 1) {
@@ -213,7 +211,7 @@ v_sectionb(sp, vp)
continue;
for (lp = list; *lp != '\0'; lp += 2 * sizeof(*lp))
if (lp[0] == p[1] &&
- (lp[1] == ' ' && len == 2 || lp[1] == p[2]) &&
+ ((lp[1] == ' ' && len == 2) || lp[1] == p[2]) &&
!--cnt) {
adjust1: vp->m_stop.lno = lno;
vp->m_stop.cno = 0;
diff --git a/vi/v_sentence.c b/vi/v_sentence.c
index a3d9376be403..ddbc6c707aad 100644
--- a/vi/v_sentence.c
+++ b/vi/v_sentence.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_sentence.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_sentence.c,v 10.9 2001/06/25 15:19:35 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -52,9 +52,7 @@ static const char sccsid[] = "@(#)v_sentence.c 10.7 (Berkeley) 3/6/96";
* PUBLIC: int v_sentencef __P((SCR *, VICMD *));
*/
int
-v_sentencef(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_sentencef(SCR *sp, VICMD *vp)
{
enum { BLANK, NONE, PERIOD } state;
VCS cs;
@@ -74,7 +72,7 @@ v_sentencef(sp, vp)
* This may not handle " . " correctly, but it's real unclear
* what correctly means in that case.
*/
- if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && isblank(cs.cs_ch)) {
+ if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && isblank(cs.cs_ch))) {
if (cs_fblank(sp, &cs))
return (1);
if (--cnt == 0) {
@@ -193,9 +191,7 @@ okret: vp->m_stop.lno = cs.cs_lno;
* PUBLIC: int v_sentenceb __P((SCR *, VICMD *));
*/
int
-v_sentenceb(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_sentenceb(SCR *sp, VICMD *vp)
{
VCS cs;
recno_t slno;
diff --git a/vi/v_status.c b/vi/v_status.c
index 7095d782c60a..82fe74b601b6 100644
--- a/vi/v_status.c
+++ b/vi/v_status.c
@@ -10,13 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_status.c 10.9 (Berkeley) 5/15/96";
+static const char sccsid[] = "$Id: v_status.c,v 10.10 2001/06/25 15:19:35 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <limits.h>
@@ -32,9 +31,7 @@ static const char sccsid[] = "@(#)v_status.c 10.9 (Berkeley) 5/15/96";
* PUBLIC: int v_status __P((SCR *, VICMD *));
*/
int
-v_status(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_status(SCR *sp, VICMD *vp)
{
(void)msgq_status(sp, vp->m_start.lno, MSTAT_SHOWLAST);
return (0);
diff --git a/vi/v_txt.c b/vi/v_txt.c
index c47a485686fb..e81e34880e2b 100644
--- a/vi/v_txt.c
+++ b/vi/v_txt.c
@@ -10,13 +10,12 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_txt.c 10.87 (Berkeley) 10/13/96";
+static const char sccsid[] = "$Id: v_txt.c,v 11.5 2013/05/19 20:37:45 bentley Exp $";
#endif /* not lint */
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -63,11 +62,7 @@ static void txt_unmap __P((SCR *, TEXT *, u_int32_t *));
* PUBLIC: int v_tcmd __P((SCR *, VICMD *, ARG_CHAR_T, u_int));
*/
int
-v_tcmd(sp, vp, prompt, flags)
- SCR *sp;
- VICMD *vp;
- ARG_CHAR_T prompt;
- u_int flags;
+v_tcmd(SCR *sp, VICMD *vp, ARG_CHAR_T prompt, u_int flags)
{
/* Normally, we end up where we started. */
vp->m_final.lno = sp->lno;
@@ -118,8 +113,7 @@ v_tcmd(sp, vp, prompt, flags)
* Initialize the screen map for colon command-line input.
*/
static int
-txt_map_init(sp)
- SCR *sp;
+txt_map_init(SCR *sp)
{
SMAP *esmp;
VI_PRIVATE *vip;
@@ -171,8 +165,7 @@ txt_map_init(sp)
* Reset the screen map for colon command-line input.
*/
static int
-txt_map_end(sp)
- SCR *sp;
+txt_map_end(SCR *sp)
{
VI_PRIVATE *vip;
size_t cnt;
@@ -242,26 +235,26 @@ txt_map_end(sp)
* Vi text input.
*
* PUBLIC: int v_txt __P((SCR *, VICMD *, MARK *,
- * PUBLIC: const char *, size_t, ARG_CHAR_T, recno_t, u_long, u_int32_t));
+ * PUBLIC: const CHAR_T *, size_t, ARG_CHAR_T, recno_t, u_long, u_int32_t));
*/
int
-v_txt(sp, vp, tm, lp, len, prompt, ai_line, rcount, flags)
- SCR *sp;
- VICMD *vp;
- MARK *tm; /* To MARK. */
- const char *lp; /* Input line. */
- size_t len; /* Input line length. */
- ARG_CHAR_T prompt; /* Prompt to display. */
- recno_t ai_line; /* Line number to use for autoindent count. */
- u_long rcount; /* Replay count. */
- u_int32_t flags; /* TXT_* flags. */
+v_txt(
+ SCR *sp,
+ VICMD *vp,
+ MARK *tm, /* To MARK. */
+ const CHAR_T *lp, /* Input line. */
+ size_t len, /* Input line length. */
+ ARG_CHAR_T prompt, /* Prompt to display. */
+ recno_t ai_line, /* Line number to use for autoindent count. */
+ u_long rcount, /* Replay count. */
+ u_int32_t flags) /* TXT_* flags. */
{
- EVENT ev, *evp; /* Current event. */
+ EVENT ev, *evp = NULL; /* Current event. */
EVENT fc; /* File name completion event. */
GS *gp;
TEXT *ntp, *tp; /* Input text structures. */
TEXT ait; /* Autoindent text structure. */
- TEXT wmt; /* Wrapmargin text structure. */
+ TEXT wmt = {{ 0 }}; /* Wrapmargin text structure. */
TEXTH *tiqh;
VI_PRIVATE *vip;
abb_t abb; /* State of abbreviation checks. */
@@ -281,7 +274,8 @@ v_txt(sp, vp, tm, lp, len, prompt, ai_line, rcount, flags)
int showmatch; /* Showmatch set on this character. */
int wm_set, wm_skip; /* Wrapmargin happened, blank skip flags. */
int max, tmp;
- char *p;
+ int nochange;
+ CHAR_T *p;
gp = sp->gp;
vip = VIP(sp);
@@ -298,23 +292,24 @@ v_txt(sp, vp, tm, lp, len, prompt, ai_line, rcount, flags)
* default to 0 -- text_init() handles this.) If changing a line,
* copy it into the TEXT buffer.
*/
- tiqh = &sp->tiq;
- if (tiqh->cqh_first != (void *)tiqh) {
- tp = tiqh->cqh_first;
- if (tp->q.cqe_next != (void *)tiqh || tp->lb_len < len + 32) {
+ tiqh = sp->tiq;
+ if (!TAILQ_EMPTY(tiqh)) {
+ tp = TAILQ_FIRST(tiqh);
+ if (TAILQ_NEXT(tp, q) != NULL || tp->lb_len < len + 32) {
text_lfree(tiqh);
goto newtp;
}
tp->ai = tp->insert = tp->offset = tp->owrite = 0;
if (lp != NULL) {
tp->len = len;
- memmove(tp->lb, lp, len);
+ BINC_RETW(sp, tp->lb, tp->lb_len, len);
+ MEMMOVE(tp->lb, lp, len);
} else
tp->len = 0;
} else {
newtp: if ((tp = text_init(sp, lp, len, len + 32)) == NULL)
return (1);
- CIRCLEQ_INSERT_HEAD(tiqh, tp, q);
+ TAILQ_INSERT_HEAD(tiqh, tp, q);
}
/* Set default termination condition. */
@@ -463,6 +458,7 @@ newtp: if ((tp = text_init(sp, lp, len, len + 32)) == NULL)
/* Other text input mode setup. */
quote = Q_NOTSET;
carat = C_NOTSET;
+ nochange = 0;
FL_INIT(is_flags,
LF_ISSET(TXT_SEARCHINCR) ? IS_RESTART | IS_RUNNING : 0);
filec_redraw = hexcnt = showmatch = 0;
@@ -539,7 +535,7 @@ next: if (v_event_get(sp, evp, 0, ec_flags))
* This was not documented as far as I know, and is a great test of vi
* clones.
*/
- if (rcol == 0 && !LF_ISSET(TXT_REPLAY) && evp->e_c == '\0') {
+ if (LF_ISSET(TXT_RECORD) && rcol == 0 && evp->e_c == '\0') {
if (vip->rep == NULL)
goto done;
@@ -594,13 +590,16 @@ next: if (v_event_get(sp, evp, 0, ec_flags))
/* Check to see if the character fits into the replay buffers. */
if (LF_ISSET(TXT_RECORD)) {
- BINC_GOTO(sp, vip->rep,
+ BINC_GOTO(sp, EVENT, vip->rep,
vip->rep_len, (rcol + 1) * sizeof(EVENT));
vip->rep[rcol++] = *evp;
}
-replay: if (LF_ISSET(TXT_REPLAY))
+replay: if (LF_ISSET(TXT_REPLAY)) {
+ if (rcol == vip->rep_cnt)
+ goto k_escape;
evp = vip->rep + rcol++;
+ }
/* Wrapmargin check for leading space. */
if (wm_skip) {
@@ -651,7 +650,7 @@ replay: if (LF_ISSET(TXT_REPLAY))
* this test delimits the value by any non-hex character. Offset by
* one, we use 0 to mean that we've found <CH_HEX>.
*/
- if (hexcnt > 1 && !isxdigit(evp->e_c)) {
+ if (hexcnt > 1 && !ISXDIGIT(evp->e_c)) {
hexcnt = 0;
if (txt_hex(sp, tp))
goto err;
@@ -673,7 +672,7 @@ k_cr: if (LF_ISSET(TXT_CR)) {
if (vs_change(sp, tp->lno, LINE_RESET))
goto err;
} else if (F_ISSET(sp, SC_SCRIPT))
- (void)v_event_push(sp, NULL, "\r", 1, CH_NOMAP);
+ (void)v_event_push(sp, NULL, L("\r"), 1, CH_NOMAP);
/* Set term condition: if empty. */
if (tp->cno <= tp->offset)
@@ -771,7 +770,7 @@ k_cr: if (LF_ISSET(TXT_CR)) {
if ((ntp = text_init(sp, p,
insert + owrite, insert + owrite + 32)) == NULL)
goto err;
- CIRCLEQ_INSERT_TAIL(&sp->tiq, ntp, q);
+ TAILQ_INSERT_TAIL(sp->tiq, ntp, q);
/* Set up bookkeeping for the new line. */
ntp->insert = insert;
@@ -786,10 +785,11 @@ k_cr: if (LF_ISSET(TXT_CR)) {
* characters may have been erased.
*/
if (LF_ISSET(TXT_AUTOINDENT)) {
- if (carat == C_NOCHANGE) {
+ if (nochange) {
+ nochange = 0;
if (v_txt_auto(sp, OOBLNO, &ait, ait.ai, ntp))
goto err;
- FREE_SPACE(sp, ait.lb, ait.lb_len);
+ FREE_SPACEW(sp, ait.lb, ait.lb_len);
} else
if (v_txt_auto(sp, OOBLNO, tp, tp->cno, ntp))
goto err;
@@ -808,9 +808,9 @@ k_cr: if (LF_ISSET(TXT_CR)) {
if (wmt.offset != 0 ||
wmt.owrite != 0 || wmt.insert != 0) {
#define WMTSPACE wmt.offset + wmt.owrite + wmt.insert
- BINC_GOTO(sp, ntp->lb,
+ BINC_GOTOW(sp, ntp->lb,
ntp->lb_len, ntp->len + WMTSPACE + 32);
- memmove(ntp->lb + ntp->cno, wmt.lb, WMTSPACE);
+ MEMMOVE(ntp->lb + ntp->cno, wmt.lb, WMTSPACE);
ntp->len += WMTSPACE;
ntp->cno += wmt.offset;
ntp->owrite = wmt.owrite;
@@ -821,7 +821,7 @@ k_cr: if (LF_ISSET(TXT_CR)) {
/* New lines are TXT_APPENDEOL. */
if (ntp->owrite == 0 && ntp->insert == 0) {
- BINC_GOTO(sp, ntp->lb, ntp->lb_len, ntp->len + 1);
+ BINC_GOTOW(sp, ntp->lb, ntp->lb_len, ntp->len + 1);
LF_SET(TXT_APPENDEOL);
ntp->lb[ntp->cno] = CH_CURSOR;
++ntp->insert;
@@ -842,6 +842,7 @@ k_cr: if (LF_ISSET(TXT_CR)) {
if (rcount > 1) {
--rcount;
+ vip->rep_cnt = rcol;
rcol = 0;
abb = AB_NOTSET;
LF_CLR(TXT_RECORD);
@@ -884,7 +885,7 @@ k_escape: LINE_RESOLVE;
* characters, and making them into insert characters.
*/
if (LF_ISSET(TXT_REPLACE))
- txt_Rresolve(sp, &sp->tiq, tp, len);
+ txt_Rresolve(sp, sp->tiq, tp, len);
/*
* If there are any overwrite characters, copy down
@@ -892,7 +893,7 @@ k_escape: LINE_RESOLVE;
*/
if (tp->owrite) {
if (tp->insert)
- memmove(tp->lb + tp->cno,
+ MEMMOVE(tp->lb + tp->cno,
tp->lb + tp->cno + tp->owrite, tp->insert);
tp->len -= tp->owrite;
}
@@ -907,10 +908,10 @@ k_escape: LINE_RESOLVE;
* This is wrong, should pass back a length.
*/
if (LF_ISSET(TXT_RESOLVE)) {
- if (txt_resolve(sp, &sp->tiq, flags))
+ if (txt_resolve(sp, sp->tiq, flags))
goto err;
} else {
- BINC_GOTO(sp, tp->lb, tp->lb_len, tp->len + 1);
+ BINC_GOTOW(sp, tp->lb, tp->lb_len, tp->len + 1);
tp->lb[tp->len] = '\0';
}
@@ -954,11 +955,12 @@ k_escape: LINE_RESOLVE;
/* Save the ai string for later. */
ait.lb = NULL;
ait.lb_len = 0;
- BINC_GOTO(sp, ait.lb, ait.lb_len, tp->ai);
- memmove(ait.lb, tp->lb, tp->ai);
+ BINC_GOTOW(sp, ait.lb, ait.lb_len, tp->ai);
+ MEMMOVE(ait.lb, tp->lb, tp->ai);
ait.ai = ait.len = tp->ai;
- carat = C_NOCHANGE;
+ carat = C_NOTSET;
+ nochange = 1;
goto leftmargin;
case C_ZEROSET: /* 0^D */
if (tp->ai == 0 || tp->cno > tp->ai + tp->offset + 1)
@@ -993,7 +995,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
*/
if (tp->cno == 0) {
if ((ntp =
- txt_backup(sp, &sp->tiq, tp, &flags)) == NULL)
+ txt_backup(sp, sp->tiq, tp, &flags)) == NULL)
goto err;
tp = ntp;
break;
@@ -1045,7 +1047,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
*/
if (tp->cno == 0) {
if ((ntp =
- txt_backup(sp, &sp->tiq, tp, &flags)) == NULL)
+ txt_backup(sp, sp->tiq, tp, &flags)) == NULL)
goto err;
tp = ntp;
}
@@ -1075,7 +1077,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
}
/* Skip over trailing space characters. */
- while (tp->cno > max && isblank(tp->lb[tp->cno - 1])) {
+ while (tp->cno > max && ISBLANK(tp->lb[tp->cno - 1])) {
--tp->cno;
++tp->owrite;
}
@@ -1104,12 +1106,12 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
*/
if (LF_ISSET(TXT_TTYWERASE))
while (tp->cno > max) {
+ if (ISBLANK(tp->lb[tp->cno - 1]))
+ break;
--tp->cno;
++tp->owrite;
if (FL_ISSET(is_flags, IS_RUNNING))
tp->lb[tp->cno] = ' ';
- if (isblank(tp->lb[tp->cno - 1]))
- break;
}
else {
if (LF_ISSET(TXT_ALTWERASE)) {
@@ -1117,19 +1119,17 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
++tp->owrite;
if (FL_ISSET(is_flags, IS_RUNNING))
tp->lb[tp->cno] = ' ';
- if (isblank(tp->lb[tp->cno - 1]))
- break;
}
if (tp->cno > max)
tmp = inword(tp->lb[tp->cno - 1]);
while (tp->cno > max) {
+ if (tmp != inword(tp->lb[tp->cno - 1])
+ || ISBLANK(tp->lb[tp->cno - 1]))
+ break;
--tp->cno;
++tp->owrite;
if (FL_ISSET(is_flags, IS_RUNNING))
tp->lb[tp->cno] = ' ';
- if (tmp != inword(tp->lb[tp->cno - 1])
- || isblank(tp->lb[tp->cno - 1]))
- break;
}
}
@@ -1146,7 +1146,7 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
*/
if (tp->cno == 0) {
if ((ntp =
- txt_backup(sp, &sp->tiq, tp, &flags)) == NULL)
+ txt_backup(sp, sp->tiq, tp, &flags)) == NULL)
goto err;
tp = ntp;
}
@@ -1195,11 +1195,6 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
if (txt_dent(sp, tp, 1))
goto err;
goto ebuf_chk;
- case K_RIGHTBRACE:
- case K_RIGHTPAREN:
- if (LF_ISSET(TXT_SHOWMATCH))
- showmatch = 1;
- goto ins_ch;
case K_BACKSLASH: /* Quote next erase/kill. */
/*
* !!!
@@ -1247,6 +1242,14 @@ leftmargin: tp->lb[tp->cno - 1] = ' ';
hexcnt = 1;
goto insq_ch;
default: /* Insert the character. */
+ if (LF_ISSET(TXT_SHOWMATCH)) {
+ CHAR_T *match_chars, *cp;
+
+ match_chars = VIP(sp)->mcs;
+ cp = STRCHR(match_chars, evp->e_c);
+ if (cp != NULL && (cp - match_chars) & 1)
+ showmatch = 1;
+ }
ins_ch: /*
* Historically, vi eliminated nul's out of hand. If the
* beautify option was set, it also deleted any unknown
@@ -1260,7 +1263,7 @@ ins_ch: /*
* wasn't a replay and wasn't handled specially, except
* <tab> or <ff>.
*/
- if (LF_ISSET(TXT_BEAUTIFY) && iscntrl(evp->e_c) &&
+ if (LF_ISSET(TXT_BEAUTIFY) && ISCNTRL(evp->e_c) &&
evp->e_value != K_FORMFEED && evp->e_value != K_TAB) {
msgq(sp, M_BERR,
"192|Illegal character; quote to enter");
@@ -1313,7 +1316,7 @@ insl_ch: if (txt_insch(sp, tp, &evp->e_c, flags))
* number of hex bytes. Offset by one, we use 0 to mean
* that we've found <CH_HEX>.
*/
- if (hexcnt != 0 && hexcnt++ == sizeof(CHAR_T) * 2 + 1) {
+ if (hexcnt != 0 && hexcnt++ == 3) {
hexcnt = 0;
if (txt_hex(sp, tp))
goto err;
@@ -1352,7 +1355,7 @@ insl_ch: if (txt_insch(sp, tp, &evp->e_c, flags))
* the length of the motion.
*/
ebuf_chk: if (tp->cno >= tp->len) {
- BINC_GOTO(sp, tp->lb, tp->lb_len, tp->len + 1);
+ BINC_GOTOW(sp, tp->lb, tp->lb_len, tp->len + 1);
LF_SET(TXT_APPENDEOL);
tp->lb[tp->cno] = CH_CURSOR;
@@ -1373,7 +1376,7 @@ ebuf_chk: if (tp->cno >= tp->len) {
#ifdef DEBUG
if (tp->cno + tp->insert + tp->owrite != tp->len) {
msgq(sp, M_ERR,
- "len %u != cno: %u ai: %u insert %u overwrite %u",
+ "len %zu != cno: %zu ai: %zu insert %zu overwrite %zu",
tp->len, tp->cno, tp->ai, tp->insert, tp->owrite);
if (LF_ISSET(TXT_REPLAY))
goto done;
@@ -1456,7 +1459,8 @@ done: /* Leave input mode. */
err:
alloc_err:
- txt_err(sp, &sp->tiq);
+ F_CLR(sp, SC_TINPUT);
+ txt_err(sp, sp->tiq);
return (1);
}
@@ -1465,11 +1469,7 @@ alloc_err:
* Handle abbreviations.
*/
static int
-txt_abbrev(sp, tp, pushcp, isinfoline, didsubp, turnoffp)
- SCR *sp;
- TEXT *tp;
- CHAR_T *pushcp;
- int isinfoline, *didsubp, *turnoffp;
+txt_abbrev(SCR *sp, TEXT *tp, CHAR_T *pushcp, int isinfoline, int *didsubp, int *turnoffp)
{
VI_PRIVATE *vip;
CHAR_T ch, *p;
@@ -1613,7 +1613,7 @@ search: if (isinfoline)
tp->owrite += len;
else {
if (tp->insert)
- memmove(tp->lb + tp->cno + qp->olen,
+ MEMMOVE(tp->lb + tp->cno + qp->olen,
tp->lb + tp->cno + tp->owrite + len, tp->insert);
tp->owrite += qp->olen;
tp->len -= len - qp->olen;
@@ -1635,13 +1635,10 @@ search: if (isinfoline)
* Handle the unmap command.
*/
static void
-txt_unmap(sp, tp, ec_flagsp)
- SCR *sp;
- TEXT *tp;
- u_int32_t *ec_flagsp;
+txt_unmap(SCR *sp, TEXT *tp, u_int32_t *ec_flagsp)
{
size_t len, off;
- char *p;
+ CHAR_T *p;
/* Find the beginning of this "word". */
for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --p, --off) {
@@ -1678,15 +1675,12 @@ txt_unmap(sp, tp, ec_flagsp)
* When a line is resolved by <esc>, review autoindent characters.
*/
static void
-txt_ai_resolve(sp, tp, changedp)
- SCR *sp;
- TEXT *tp;
- int *changedp;
+txt_ai_resolve(SCR *sp, TEXT *tp, int *changedp)
{
u_long ts;
int del;
size_t cno, len, new, old, scno, spaces, tab_after_sp, tabs;
- char *p;
+ CHAR_T *p;
*changedp = 0;
@@ -1729,7 +1723,7 @@ txt_ai_resolve(sp, tp, changedp)
* If there are no spaces, or no tabs after spaces and less than
* ts spaces, it's already minimal.
*/
- if (!spaces || !tab_after_sp && spaces < ts)
+ if (!spaces || (!tab_after_sp && spaces < ts))
return;
/* Count up spaces/tabs needed to get to the target. */
@@ -1748,7 +1742,7 @@ txt_ai_resolve(sp, tp, changedp)
/* Shift the rest of the characters down, adjust the counts. */
del = old - new;
- memmove(p - del, p, tp->len - old);
+ MEMMOVE(p - del, p, tp->len - old);
tp->len -= del;
tp->cno -= del;
@@ -1768,14 +1762,10 @@ txt_ai_resolve(sp, tp, changedp)
* PUBLIC: int v_txt_auto __P((SCR *, recno_t, TEXT *, size_t, TEXT *));
*/
int
-v_txt_auto(sp, lno, aitp, len, tp)
- SCR *sp;
- recno_t lno;
- TEXT *aitp, *tp;
- size_t len;
+v_txt_auto(SCR *sp, recno_t lno, TEXT *aitp, size_t len, TEXT *tp)
{
size_t nlen;
- char *p, *t;
+ CHAR_T *p, *t;
if (aitp == NULL) {
/*
@@ -1802,15 +1792,15 @@ v_txt_auto(sp, lno, aitp, len, tp)
return (0);
/* Make sure the buffer's big enough. */
- BINC_RET(sp, tp->lb, tp->lb_len, tp->len + nlen);
+ BINC_RETW(sp, tp->lb, tp->lb_len, tp->len + nlen);
/* Copy the buffer's current contents up. */
if (tp->len != 0)
- memmove(tp->lb + nlen, tp->lb, tp->len);
+ MEMMOVE(tp->lb + nlen, tp->lb, tp->len);
tp->len += nlen;
/* Copy the indentation into the new buffer. */
- memmove(tp->lb, t, nlen);
+ MEMMOVE(tp->lb, t, nlen);
/* Set the autoindent count. */
tp->ai = nlen;
@@ -1822,17 +1812,13 @@ v_txt_auto(sp, lno, aitp, len, tp)
* Back up to the previously edited line.
*/
static TEXT *
-txt_backup(sp, tiqh, tp, flagsp)
- SCR *sp;
- TEXTH *tiqh;
- TEXT *tp;
- u_int32_t *flagsp;
+txt_backup(SCR *sp, TEXTH *tiqh, TEXT *tp, u_int32_t *flagsp)
{
VI_PRIVATE *vip;
TEXT *ntp;
/* Get a handle on the previous TEXT structure. */
- if ((ntp = tp->q.cqe_prev) == (void *)tiqh) {
+ if ((ntp = TAILQ_PREV(tp, _texth, q)) == NULL) {
if (!FL_ISSET(*flagsp, TXT_REPLAY))
msgq(sp, M_BERR,
"193|Already at the beginning of the insert");
@@ -1853,7 +1839,7 @@ txt_backup(sp, tiqh, tp, flagsp)
FL_CLR(*flagsp, TXT_APPENDEOL);
/* Release the current TEXT. */
- CIRCLEQ_REMOVE(tiqh, tp, q);
+ TAILQ_REMOVE(tiqh, tp, q);
text_free(tp);
/* Update the old line on the screen. */
@@ -1891,7 +1877,7 @@ txt_backup(sp, tiqh, tp, flagsp)
* Technically, txt_dent should be part of the screen interface, as it requires
* knowledge of character sizes, including <space>s, on the screen. It's here
* because it's a complicated little beast, and I didn't want to shove it down
- * into the screen. It's probable that KEY_LEN will call into the screen once
+ * into the screen. It's probable that KEY_COL will call into the screen once
* there are screens with different character representations.
*
* txt_dent --
@@ -1901,14 +1887,11 @@ txt_backup(sp, tiqh, tp, flagsp)
* changes.
*/
static int
-txt_dent(sp, tp, isindent)
- SCR *sp;
- TEXT *tp;
- int isindent;
+txt_dent(SCR *sp, TEXT *tp, int isindent)
{
CHAR_T ch;
u_long sw, ts;
- size_t cno, current, spaces, target, tabs, off;
+ size_t cno, current, spaces, target, tabs;
int ai_reset;
ts = O_VAL(sp, O_TABSTOP);
@@ -1932,13 +1915,15 @@ txt_dent(sp, tp, isindent)
*/
for (current = cno = 0; cno < tp->cno; ++cno)
current += tp->lb[cno] == '\t' ?
- COL_OFF(current, ts) : KEY_LEN(sp, tp->lb[cno]);
+ COL_OFF(current, ts) : KEY_COL(sp, tp->lb[cno]);
target = current;
if (isindent)
target += COL_OFF(target, sw);
- else
- target -= --target % sw;
+ else {
+ --target;
+ target -= target % sw;
+ }
/*
* The AI characters will be turned into overwrite characters if the
@@ -1960,7 +1945,7 @@ txt_dent(sp, tp, isindent)
--tp->cno, ++tp->owrite);
for (current = cno = 0; cno < tp->cno; ++cno)
current += tp->lb[cno] == '\t' ?
- COL_OFF(current, ts) : KEY_LEN(sp, tp->lb[cno]);
+ COL_OFF(current, ts) : KEY_COL(sp, tp->lb[cno]);
/*
* If we didn't move up to or past the target, it's because there
@@ -2000,24 +1985,23 @@ txt_dent(sp, tp, isindent)
/*
* txt_fc --
- * File name completion.
+ * File name and ex command completion.
*/
static int
-txt_fc(sp, tp, redrawp)
- SCR *sp;
- TEXT *tp;
- int *redrawp;
+txt_fc(SCR *sp, TEXT *tp, int *redrawp)
{
struct stat sb;
ARGS **argv;
- CHAR_T s_ch;
EXCMD cmd;
size_t indx, len, nlen, off;
- int argc, trydir;
- char *p, *t;
+ int argc;
+ CHAR_T *p, *t, *bp;
+ char *np, *epd = NULL;
+ size_t nplen;
+ int fstwd = 1;
- trydir = 0;
*redrawp = 0;
+ ex_cinit(sp, &cmd, 0, 0, OOBLNO, OOBLNO, 0);
/*
* Find the beginning of this "word" -- if we're at the beginning
@@ -2026,67 +2010,53 @@ txt_fc(sp, tp, redrawp)
if (tp->cno == 1) {
len = 0;
p = tp->lb;
- } else
-retry: for (len = 0,
- off = tp->cno - 1, p = tp->lb + off;; --off, --p) {
- if (isblank(*p)) {
- ++p;
- break;
- }
- ++len;
- if (off == tp->ai || off == tp->offset)
- break;
+ } else {
+ CHAR_T *ap;
+
+ for (len = 0,
+ off = MAX(tp->ai, tp->offset), ap = tp->lb + off, p = ap;
+ off < tp->cno; ++off, ++ap) {
+ if (IS_ESCAPE(sp, &cmd, *ap)) {
+ if (++off == tp->cno)
+ break;
+ ++ap;
+ len += 2;
+ } else if (cmdskip(*ap)) {
+ p = ap + 1;
+ if (len > 0)
+ fstwd = 0;
+ len = 0;
+ } else
+ ++len;
}
+ }
/*
- * Get enough space for a wildcard character.
- *
- * XXX
- * This won't work for "foo\", since the \ will escape the expansion
- * character. I'm not sure if that's a bug or not...
+ * If we are at the first word, do ex command completion instead of
+ * file name completion.
*/
- off = p - tp->lb;
- BINC_RET(sp, tp->lb, tp->lb_len, tp->len + 1);
- p = tp->lb + off;
-
- s_ch = p[len];
- p[len] = '*';
-
- /* Build an ex command, and call the ex expansion routines. */
- ex_cinit(&cmd, 0, 0, OOBLNO, OOBLNO, 0, NULL);
- if (argv_init(sp, &cmd))
- return (1);
- if (argv_exp2(sp, &cmd, p, len + 1)) {
- p[len] = s_ch;
- return (0);
+ if (fstwd)
+ (void)argv_flt_ex(sp, &cmd, p, len);
+ else {
+ if ((bp = argv_uesc(sp, &cmd, p, len)) == NULL)
+ return (1);
+ if (argv_flt_path(sp, &cmd, bp, STRLEN(bp))) {
+ FREE_SPACEW(sp, bp, 0);
+ return (0);
+ }
+ FREE_SPACEW(sp, bp, 0);
}
argc = cmd.argc;
argv = cmd.argv;
- p[len] = s_ch;
-
switch (argc) {
case 0: /* No matches. */
- if (!trydir)
- (void)sp->gp->scr_bell(sp);
+ (void)sp->gp->scr_bell(sp);
return (0);
case 1: /* One match. */
- /* If something changed, do the exchange. */
- nlen = strlen(cmd.argv[0]->bp);
- if (len != nlen || memcmp(cmd.argv[0]->bp, p, len))
- break;
-
- /* If haven't done a directory test, do it now. */
- if (!trydir &&
- !stat(cmd.argv[0]->bp, &sb) && S_ISDIR(sb.st_mode)) {
- p += len;
- goto isdir;
- }
-
- /* If nothing changed, period, ring the bell. */
- if (!trydir)
- (void)sp->gp->scr_bell(sp);
- return (0);
+ /* Always overwrite the old text. */
+ nlen = STRLEN(cmd.argv[0]->bp);
+ break;
default: /* Multiple matches. */
*redrawp = 1;
if (txt_fc_col(sp, argc, argv))
@@ -2104,8 +2074,17 @@ retry: for (len = 0,
break;
}
+ /* Escape the matched part of the path. */
+ if (fstwd)
+ bp = cmd.argv[0]->bp;
+ else {
+ if ((bp = argv_esc(sp, &cmd, cmd.argv[0]->bp, nlen)) == NULL)
+ return (1);
+ nlen = STRLEN(bp);
+ }
+
/* Overwrite the expanded text first. */
- for (t = cmd.argv[0]->bp; len > 0 && nlen > 0; --len, --nlen)
+ for (t = bp; len > 0 && nlen > 0; --len, --nlen)
*p++ = *t++;
/* If lost text, make the remaining old text overwrite characters. */
@@ -2121,36 +2100,44 @@ retry: for (len = 0,
/* Shift remaining text up, and move the cursor to the end. */
if (nlen) {
off = p - tp->lb;
- BINC_RET(sp, tp->lb, tp->lb_len, tp->len + nlen);
+ BINC_RETW(sp, tp->lb, tp->lb_len, tp->len + nlen);
p = tp->lb + off;
tp->cno += nlen;
tp->len += nlen;
if (tp->insert != 0)
- (void)memmove(p + nlen, p, tp->insert);
+ (void)MEMMOVE(p + nlen, p, tp->insert);
while (nlen--)
*p++ = *t++;
}
- /* If a single match and it's a directory, retry it. */
- if (argc == 1 && !stat(cmd.argv[0]->bp, &sb) && S_ISDIR(sb.st_mode)) {
-isdir: if (tp->owrite == 0) {
+ if (!fstwd)
+ FREE_SPACEW(sp, bp, 0);
+
+ /* If not a single match of path, we've done. */
+ if (argc != 1 || fstwd)
+ return (0);
+
+ /* If a single match and it's a directory, append a '/'. */
+ INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1, np, nplen);
+ if ((epd = expanduser(np)) != NULL)
+ np = epd;
+ if (!stat(np, &sb) && S_ISDIR(sb.st_mode)) {
+ if (tp->owrite == 0) {
off = p - tp->lb;
- BINC_RET(sp, tp->lb, tp->lb_len, tp->len + 1);
+ BINC_RETW(sp, tp->lb, tp->lb_len, tp->len + 1);
p = tp->lb + off;
if (tp->insert != 0)
- (void)memmove(p + 1, p, tp->insert);
+ (void)MEMMOVE(p + 1, p, tp->insert);
++tp->len;
} else
--tp->owrite;
++tp->cno;
*p++ = '/';
-
- trydir = 1;
- goto retry;
}
+ free(epd);
return (0);
}
@@ -2159,27 +2146,28 @@ isdir: if (tp->owrite == 0) {
* Display file names for file name completion.
*/
static int
-txt_fc_col(sp, argc, argv)
- SCR *sp;
- int argc;
- ARGS **argv;
+txt_fc_col(SCR *sp, int argc, ARGS **argv)
{
ARGS **av;
CHAR_T *p;
GS *gp;
size_t base, cnt, col, colwidth, numrows, numcols, prefix, row;
int ac, nf, reset;
+ char *np, *pp;
+ size_t nlen;
gp = sp->gp;
/* Trim any directory prefix common to all of the files. */
- if ((p = strrchr(argv[0]->bp, '/')) == NULL)
+ INT2CHAR(sp, argv[0]->bp, argv[0]->len + 1, np, nlen);
+ if ((pp = strrchr(np, '/')) == NULL)
prefix = 0;
else {
- prefix = (p - argv[0]->bp) + 1;
+ prefix = (pp - np) + 1;
for (ac = argc - 1, av = argv + 1; ac > 0; --ac, ++av)
if (av[0]->len < prefix ||
- memcmp(av[0]->bp, argv[0]->bp, prefix)) {
+ MEMCMP(av[0]->bp, argv[0]->bp,
+ prefix)) {
prefix = 0;
break;
}
@@ -2194,7 +2182,7 @@ txt_fc_col(sp, argc, argv)
*/
for (ac = argc, av = argv, colwidth = 0; ac > 0; --ac, ++av) {
for (col = 0, p = av[0]->bp + prefix; *p != '\0'; ++p)
- col += KEY_LEN(sp, *p);
+ col += KEY_COL(sp, *p);
if (col > colwidth)
colwidth = col;
}
@@ -2215,15 +2203,17 @@ txt_fc_col(sp, argc, argv)
goto intr;
/* If the largest file name is too large, just print them. */
- if (colwidth > sp->cols) {
- p = msg_print(sp, av[0]->bp + prefix, &nf);
+ if (colwidth >= sp->cols) {
for (ac = argc, av = argv; ac > 0; --ac, ++av) {
- (void)ex_printf(sp, "%s\n", p);
+ INT2CHAR(sp, av[0]->bp+prefix, av[0]->len+1-prefix,
+ np, nlen);
+ pp = msg_print(sp, np, &nf);
+ (void)ex_printf(sp, "%s\n", pp);
+ if (nf)
+ FREE_SPACE(sp, pp, 0);
if (F_ISSET(gp, G_INTERRUPTED))
break;
}
- if (nf)
- FREE_SPACE(sp, p, 0);
CHK_INTR;
} else {
/* Figure out the number of columns. */
@@ -2238,10 +2228,12 @@ txt_fc_col(sp, argc, argv)
/* Display the files in sorted order. */
for (row = 0; row < numrows; ++row) {
for (base = row, col = 0; col < numcols; ++col) {
- p = msg_print(sp, argv[base]->bp + prefix, &nf);
- cnt = ex_printf(sp, "%s", p);
+ INT2CHAR(sp, argv[base]->bp+prefix,
+ argv[base]->len+1-prefix, np, nlen);
+ pp = msg_print(sp, np, &nf);
+ cnt = ex_printf(sp, "%s", pp);
if (nf)
- FREE_SPACE(sp, p, 0);
+ FREE_SPACE(sp, pp, 0);
CHK_INTR;
if ((base += numrows) >= argc)
break;
@@ -2271,14 +2263,12 @@ intr: F_CLR(gp, G_INTERRUPTED);
* Set the end mark on the line.
*/
static int
-txt_emark(sp, tp, cno)
- SCR *sp;
- TEXT *tp;
- size_t cno;
+txt_emark(SCR *sp, TEXT *tp, size_t cno)
{
- CHAR_T ch, *kp;
+ CHAR_T ch;
+ u_char *kp;
size_t chlen, nlen, olen;
- char *p;
+ CHAR_T *p;
ch = CH_ENDMARK;
@@ -2286,11 +2276,11 @@ txt_emark(sp, tp, cno)
* The end mark may not be the same size as the current character.
* Don't let the line shift.
*/
- nlen = KEY_LEN(sp, ch);
+ nlen = KEY_COL(sp, ch);
if (tp->lb[cno] == '\t')
(void)vs_columns(sp, tp->lb, tp->lno, &cno, &olen);
else
- olen = KEY_LEN(sp, tp->lb[cno]);
+ olen = KEY_COL(sp, tp->lb[cno]);
/*
* If the line got longer, well, it's weird, but it's easy. If
@@ -2298,20 +2288,22 @@ txt_emark(sp, tp, cno)
* to fix it up.
*/
if (olen > nlen) {
- BINC_RET(sp, tp->lb, tp->lb_len, tp->len + olen);
+ BINC_RETW(sp, tp->lb, tp->lb_len, tp->len + olen);
chlen = olen - nlen;
if (tp->insert != 0)
- memmove(tp->lb + cno + 1 + chlen,
+ MEMMOVE(tp->lb + cno + 1 + chlen,
tp->lb + cno + 1, tp->insert);
tp->len += chlen;
tp->owrite += chlen;
p = tp->lb + cno;
- if (tp->lb[cno] == '\t')
+ if (tp->lb[cno] == '\t' ||
+ KEY_NEEDSWIDE(sp, tp->lb[cno]))
for (cno += chlen; chlen--;)
*p++ = ' ';
else
- for (kp = KEY_NAME(sp, tp->lb[cno]),
+ for (kp = (u_char *)
+ KEY_NAME(sp, tp->lb[cno]),
cno += chlen; chlen--;)
*p++ = *kp++;
}
@@ -2324,9 +2316,7 @@ txt_emark(sp, tp, cno)
* Handle an error during input processing.
*/
static void
-txt_err(sp, tiqh)
- SCR *sp;
- TEXTH *tiqh;
+txt_err(SCR *sp, TEXTH *tiqh)
{
recno_t lno;
@@ -2339,7 +2329,7 @@ txt_err(sp, tiqh)
* We depend on at least one line number being set in the text
* chain.
*/
- for (lno = tiqh->cqh_first->lno;
+ for (lno = TAILQ_FIRST(tiqh)->lno;
!db_exist(sp, lno) && lno > 0; --lno);
sp->lno = lno == 0 ? 1 : lno;
@@ -2359,14 +2349,12 @@ txt_err(sp, tiqh)
* may not be able to enter.
*/
static int
-txt_hex(sp, tp)
- SCR *sp;
- TEXT *tp;
+txt_hex(SCR *sp, TEXT *tp)
{
CHAR_T savec;
size_t len, off;
u_long value;
- char *p, *wp;
+ CHAR_T *p, *wp;
/*
* Null-terminate the string. Since nul isn't a legal hex value,
@@ -2393,8 +2381,8 @@ txt_hex(sp, tp)
/* Get the value. */
errno = 0;
- value = strtol(wp, NULL, 16);
- if (errno || value > MAX_CHAR_T) {
+ value = STRTOL(wp, NULL, 16);
+ if (errno || value > UCHAR_MAX) {
nothex: tp->lb[tp->cno] = savec;
return (0);
}
@@ -2409,12 +2397,14 @@ nothex: tp->lb[tp->cno] = savec;
/* Copy down any overwrite characters. */
if (tp->owrite)
- memmove(tp->lb + tp->cno, tp->lb + tp->cno + len, tp->owrite);
+ MEMMOVE(tp->lb + tp->cno, tp->lb + tp->cno + len,
+ tp->owrite);
/* Copy down any insert characters. */
if (tp->insert)
- memmove(tp->lb + tp->cno + tp->owrite,
- tp->lb + tp->cno + tp->owrite + len, tp->insert);
+ MEMMOVE(tp->lb + tp->cno + tp->owrite,
+ tp->lb + tp->cno + tp->owrite + len,
+ tp->insert);
return (0);
}
@@ -2439,15 +2429,12 @@ nothex: tp->lb[tp->cno] = savec;
* of the screen space they require, but that it not overwrite other characters.
*/
static int
-txt_insch(sp, tp, chp, flags)
- SCR *sp;
- TEXT *tp;
- CHAR_T *chp;
- u_int flags;
+txt_insch(SCR *sp, TEXT *tp, CHAR_T *chp, u_int flags)
{
- CHAR_T *kp, savech;
+ u_char *kp;
+ CHAR_T savech;
size_t chlen, cno, copydown, olen, nlen;
- char *p;
+ CHAR_T *p;
/*
* The 'R' command does one-for-one replacement, because there's
@@ -2473,7 +2460,7 @@ txt_insch(sp, tp, chp, flags)
(void)vs_columns(sp, tp->lb, tp->lno, &cno, &nlen);
tp->lb[cno] = savech;
} else
- nlen = KEY_LEN(sp, *chp);
+ nlen = KEY_COL(sp, *chp);
/*
* Eat overwrite characters until we run out of them or we've
@@ -2488,7 +2475,7 @@ txt_insch(sp, tp, chp, flags)
(void)vs_columns(sp,
tp->lb, tp->lno, &cno, &olen);
else
- olen = KEY_LEN(sp, tp->lb[cno]);
+ olen = KEY_COL(sp, tp->lb[cno]);
if (olen == nlen) {
nlen = 0;
@@ -2498,19 +2485,21 @@ txt_insch(sp, tp, chp, flags)
++copydown;
nlen -= olen;
} else {
- BINC_RET(sp,
+ BINC_RETW(sp,
tp->lb, tp->lb_len, tp->len + olen);
chlen = olen - nlen;
- memmove(tp->lb + cno + 1 + chlen,
- tp->lb + cno + 1, tp->owrite + tp->insert);
+ MEMMOVE(tp->lb + cno + 1 + chlen,
+ tp->lb + cno + 1,
+ tp->owrite + tp->insert);
tp->len += chlen;
tp->owrite += chlen;
- if (tp->lb[cno] == '\t')
+ if (tp->lb[cno] == '\t' ||
+ KEY_NEEDSWIDE(sp, tp->lb[cno]))
for (p = tp->lb + cno + 1; chlen--;)
*p++ = ' ';
else
- for (kp =
+ for (kp = (u_char *)
KEY_NAME(sp, tp->lb[cno]) + nlen,
p = tp->lb + cno + 1; chlen--;)
*p++ = *kp++;
@@ -2525,7 +2514,7 @@ txt_insch(sp, tp, chp, flags)
* into position.
*/
if (copydown != 0 && (tp->len -= copydown) != 0)
- memmove(tp->lb + cno, tp->lb + cno + copydown,
+ MEMMOVE(tp->lb + cno, tp->lb + cno + copydown,
tp->owrite + tp->insert + copydown);
/* If we had enough overwrite characters, we're done. */
@@ -2536,14 +2525,14 @@ txt_insch(sp, tp, chp, flags)
}
/* Check to see if the character fits into the input buffer. */
- BINC_RET(sp, tp->lb, tp->lb_len, tp->len + 1);
+ BINC_RETW(sp, tp->lb, tp->lb_len, tp->len + 1);
++tp->len;
if (tp->insert) { /* Insert a character. */
if (tp->insert == 1)
tp->lb[tp->cno + 1] = tp->lb[tp->cno];
else
- memmove(tp->lb + tp->cno + 1,
+ MEMMOVE(tp->lb + tp->cno + 1,
tp->lb + tp->cno, tp->owrite + tp->insert);
}
tp->lb[tp->cno++] = *chp;
@@ -2555,11 +2544,7 @@ txt_insch(sp, tp, chp, flags)
* Do an incremental search.
*/
static int
-txt_isrch(sp, vp, tp, is_flagsp)
- SCR *sp;
- VICMD *vp;
- TEXT *tp;
- u_int8_t *is_flagsp;
+txt_isrch(SCR *sp, VICMD *vp, TEXT *tp, u_int8_t *is_flagsp)
{
MARK start;
recno_t lno;
@@ -2592,7 +2577,7 @@ txt_isrch(sp, vp, tp, is_flagsp)
* If it's a magic shell character, and not quoted, reset the cursor
* to the starting point.
*/
- if (strchr(O_STR(sp, O_SHELLMETA), tp->lb[tp->cno - 1]) != NULL &&
+ if (IS_SHELLMETA(sp, tp->lb[tp->cno - 1]) &&
(tp->cno == 2 || tp->lb[tp->cno - 2] != '\\'))
vp->m_final = vp->m_start;
@@ -2679,10 +2664,7 @@ txt_isrch(sp, vp, tp, is_flagsp)
* Resolve the input text chain into the file.
*/
static int
-txt_resolve(sp, tiqh, flags)
- SCR *sp;
- TEXTH *tiqh;
- u_int32_t flags;
+txt_resolve(SCR *sp, TEXTH *tiqh, u_int32_t flags)
{
VI_PRIVATE *vip;
TEXT *tp;
@@ -2697,23 +2679,23 @@ txt_resolve(sp, tiqh, flags)
* about the line will be wrong.
*/
vip = VIP(sp);
- tp = tiqh->cqh_first;
+ tp = TAILQ_FIRST(tiqh);
if (LF_ISSET(TXT_AUTOINDENT))
txt_ai_resolve(sp, tp, &changed);
else
changed = 0;
if (db_set(sp, tp->lno, tp->lb, tp->len) ||
- changed && vs_change(sp, tp->lno, LINE_RESET))
+ (changed && vs_change(sp, tp->lno, LINE_RESET)))
return (1);
- for (lno = tp->lno; (tp = tp->q.cqe_next) != (void *)&sp->tiq; ++lno) {
+ for (lno = tp->lno; (tp = TAILQ_NEXT(tp, q)) != NULL; ++lno) {
if (LF_ISSET(TXT_AUTOINDENT))
txt_ai_resolve(sp, tp, &changed);
else
changed = 0;
if (db_append(sp, 0, lno, tp->lb, tp->len) ||
- changed && vs_change(sp, tp->lno, LINE_RESET))
+ (changed && vs_change(sp, tp->lno, LINE_RESET)))
return (1);
}
@@ -2736,9 +2718,7 @@ txt_resolve(sp, tiqh, flags)
* I think not.
*/
static int
-txt_showmatch(sp, tp)
- SCR *sp;
- TEXT *tp;
+txt_showmatch(SCR *sp, TEXT *tp)
{
GS *gp;
VCS cs;
@@ -2767,7 +2747,7 @@ txt_showmatch(sp, tp)
cs.cs_cno = tp->cno - 1;
if (cs_init(sp, &cs))
return (1);
- startc = (endc = cs.cs_ch) == ')' ? '(' : '{';
+ startc = STRCHR(VIP(sp)->mcs, endc = cs.cs_ch)[-1];
/* Search for the match. */
for (cnt = 1;;) {
@@ -2788,7 +2768,7 @@ txt_showmatch(sp, tp)
}
/* If the match is on the screen, move to it. */
- if (cs.cs_lno < m.lno || cs.cs_lno == m.lno && cs.cs_cno < m.cno)
+ if (cs.cs_lno < m.lno || (cs.cs_lno == m.lno && cs.cs_cno < m.cno))
return (0);
sp->lno = cs.cs_lno;
sp->cno = cs.cs_cno;
@@ -2805,15 +2785,11 @@ txt_showmatch(sp, tp)
* Handle margin wrap.
*/
static int
-txt_margin(sp, tp, wmtp, didbreak, flags)
- SCR *sp;
- TEXT *tp, *wmtp;
- int *didbreak;
- u_int32_t flags;
+txt_margin(SCR *sp, TEXT *tp, TEXT *wmtp, int *didbreak, u_int32_t flags)
{
VI_PRIVATE *vip;
size_t len, off;
- char *p, *wp;
+ CHAR_T *p, *wp;
/* Find the nearest previous blank. */
for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --off, --p, ++len) {
@@ -2885,15 +2861,11 @@ txt_margin(sp, tp, wmtp, didbreak, flags)
* Resolve the input line for the 'R' command.
*/
static void
-txt_Rresolve(sp, tiqh, tp, orig_len)
- SCR *sp;
- TEXTH *tiqh;
- TEXT *tp;
- const size_t orig_len;
+txt_Rresolve(SCR *sp, TEXTH *tiqh, TEXT *tp, const size_t orig_len)
{
TEXT *ttp;
size_t input_len, retain;
- char *p;
+ CHAR_T *p;
/*
* Check to make sure that the cursor hasn't moved beyond
@@ -2906,9 +2878,9 @@ txt_Rresolve(sp, tiqh, tp, orig_len)
* Calculate how many characters the user has entered,
* plus the blanks erased by <carriage-return>/<newline>s.
*/
- for (ttp = tiqh->cqh_first, input_len = 0;;) {
+ for (ttp = TAILQ_FIRST(tiqh), input_len = 0;;) {
input_len += ttp == tp ? tp->cno : ttp->len + ttp->R_erase;
- if ((ttp = ttp->q.cqe_next) == (void *)&sp->tiq)
+ if ((ttp = TAILQ_NEXT(ttp, q)) == NULL)
break;
}
@@ -2929,9 +2901,9 @@ txt_Rresolve(sp, tiqh, tp, orig_len)
if (input_len < orig_len) {
retain = MIN(tp->owrite, orig_len - input_len);
if (db_get(sp,
- tiqh->cqh_first->lno, DBG_FATAL | DBG_NOCACHE, &p, NULL))
+ TAILQ_FIRST(tiqh)->lno, DBG_FATAL | DBG_NOCACHE, &p, NULL))
return;
- memcpy(tp->lb + tp->cno, p + input_len, retain);
+ MEMCPY(tp->lb + tp->cno, p + input_len, retain);
tp->len -= tp->owrite - retain;
tp->owrite = 0;
tp->insert += retain;
@@ -2943,8 +2915,7 @@ txt_Rresolve(sp, tiqh, tp, orig_len)
* No more characters message.
*/
static void
-txt_nomorech(sp)
- SCR *sp;
+txt_nomorech(SCR *sp)
{
msgq(sp, M_BERR, "194|No more characters to erase");
}
diff --git a/vi/v_ulcase.c b/vi/v_ulcase.c
index 179bebabcc11..10d3d359619d 100644
--- a/vi/v_ulcase.c
+++ b/vi/v_ulcase.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_ulcase.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_ulcase.c,v 10.12 2011/12/02 19:58:32 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -47,14 +47,12 @@ static int ulcase __P((SCR *, recno_t, CHAR_T *, size_t, size_t, size_t));
* PUBLIC: int v_ulcase __P((SCR *, VICMD *));
*/
int
-v_ulcase(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_ulcase(SCR *sp, VICMD *vp)
{
recno_t lno;
size_t cno, lcnt, len;
u_long cnt;
- char *p;
+ CHAR_T *p;
lno = vp->m_start.lno;
cno = vp->m_start.cno;
@@ -107,9 +105,7 @@ v_ulcase(sp, vp)
* PUBLIC: int v_mulcase __P((SCR *, VICMD *));
*/
int
-v_mulcase(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_mulcase(SCR *sp, VICMD *vp)
{
CHAR_T *p;
size_t len;
@@ -145,28 +141,24 @@ v_mulcase(sp, vp)
* Change part of a line's case.
*/
static int
-ulcase(sp, lno, lp, len, scno, ecno)
- SCR *sp;
- recno_t lno;
- CHAR_T *lp;
- size_t len, scno, ecno;
+ulcase(SCR *sp, recno_t lno, CHAR_T *lp, size_t len, size_t scno, size_t ecno)
{
size_t blen;
int change, rval;
- CHAR_T ch, *p, *t;
- char *bp;
+ ARG_CHAR_T ch;
+ CHAR_T *p, *t, *bp;
- GET_SPACE_RET(sp, bp, blen, len);
- memmove(bp, lp, len);
+ GET_SPACE_RETW(sp, bp, blen, len);
+ MEMMOVE(bp, lp, len);
change = rval = 0;
for (p = bp + scno, t = bp + ecno + 1; p < t; ++p) {
- ch = *(u_char *)p;
- if (islower(ch)) {
- *p = toupper(ch);
+ ch = (UCHAR_T)*p;
+ if (ISLOWER(ch)) {
+ *p = TOUPPER(ch);
change = 1;
- } else if (isupper(ch)) {
- *p = tolower(ch);
+ } else if (ISUPPER(ch)) {
+ *p = TOLOWER(ch);
change = 1;
}
}
@@ -174,6 +166,6 @@ ulcase(sp, lno, lp, len, scno, ecno)
if (change && db_set(sp, lno, bp, len))
rval = 1;
- FREE_SPACE(sp, bp, blen);
+ FREE_SPACEW(sp, bp, blen);
return (rval);
}
diff --git a/vi/v_undo.c b/vi/v_undo.c
index d04a8a18810b..2bbd9208643c 100644
--- a/vi/v_undo.c
+++ b/vi/v_undo.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_undo.c 10.5 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_undo.c,v 10.6 2001/06/25 15:19:36 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -34,9 +34,7 @@ static const char sccsid[] = "@(#)v_undo.c 10.5 (Berkeley) 3/6/96";
* PUBLIC: int v_Undo __P((SCR *, VICMD *));
*/
int
-v_Undo(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_Undo(SCR *sp, VICMD *vp)
{
/*
* Historically, U reset the cursor to the first column in the line
@@ -70,9 +68,7 @@ v_Undo(sp, vp)
* PUBLIC: int v_undo __P((SCR *, VICMD *));
*/
int
-v_undo(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_undo(SCR *sp, VICMD *vp)
{
EXF *ep;
diff --git a/vi/v_util.c b/vi/v_util.c
index c4c0daa901fd..6348ca73ec85 100644
--- a/vi/v_util.c
+++ b/vi/v_util.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_util.c 10.11 (Berkeley) 6/30/96";
+static const char sccsid[] = "$Id: v_util.c,v 10.14 2001/06/25 15:19:36 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -35,9 +35,7 @@ static const char sccsid[] = "@(#)v_util.c 10.11 (Berkeley) 6/30/96";
* PUBLIC: void v_eof __P((SCR *, MARK *));
*/
void
-v_eof(sp, mp)
- SCR *sp;
- MARK *mp;
+v_eof(SCR *sp, MARK *mp)
{
recno_t lno;
@@ -60,9 +58,7 @@ v_eof(sp, mp)
* PUBLIC: void v_eol __P((SCR *, MARK *));
*/
void
-v_eol(sp, mp)
- SCR *sp;
- MARK *mp;
+v_eol(SCR *sp, MARK *mp)
{
size_t len;
@@ -85,8 +81,7 @@ v_eol(sp, mp)
* PUBLIC: void v_nomove __P((SCR *));
*/
void
-v_nomove(sp)
- SCR *sp;
+v_nomove(SCR *sp)
{
msgq(sp, M_BERR, "197|No cursor movement made");
}
@@ -98,9 +93,7 @@ v_nomove(sp)
* PUBLIC: void v_sof __P((SCR *, MARK *));
*/
void
-v_sof(sp, mp)
- SCR *sp;
- MARK *mp;
+v_sof(SCR *sp, MARK *mp)
{
if (mp == NULL || mp->lno == 1)
msgq(sp, M_BERR, "198|Already at the beginning of the file");
@@ -115,8 +108,7 @@ v_sof(sp, mp)
* PUBLIC: void v_sol __P((SCR *));
*/
void
-v_sol(sp)
- SCR *sp;
+v_sol(SCR *sp)
{
msgq(sp, M_BERR, "200|Already in the first column");
}
@@ -125,12 +117,10 @@ v_sol(sp)
* v_isempty --
* Return if the line contains nothing but white-space characters.
*
- * PUBLIC: int v_isempty __P((char *, size_t));
+ * PUBLIC: int v_isempty __P((CHAR_T *, size_t));
*/
int
-v_isempty(p, len)
- char *p;
- size_t len;
+v_isempty(CHAR_T *p, size_t len)
{
for (; len--; ++p)
if (!isblank(*p))
@@ -145,10 +135,7 @@ v_isempty(p, len)
* PUBLIC: void v_emsg __P((SCR *, char *, vim_t));
*/
void
-v_emsg(sp, p, which)
- SCR *sp;
- char *p;
- vim_t which;
+v_emsg(SCR *sp, char *p, vim_t which)
{
switch (which) {
case VIM_COMBUF:
diff --git a/vi/v_word.c b/vi/v_word.c
index e6e4a63c57e7..6336e2d97ce8 100644
--- a/vi/v_word.c
+++ b/vi/v_word.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_word.c 10.5 (Berkeley) 3/6/96";
+static const char sccsid[] = "$Id: v_word.c,v 10.7 2011/12/27 00:49:31 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -77,9 +77,7 @@ static int fword __P((SCR *, VICMD *, enum which));
* PUBLIC: int v_wordW __P((SCR *, VICMD *));
*/
int
-v_wordW(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_wordW(SCR *sp, VICMD *vp)
{
return (fword(sp, vp, BIGWORD));
}
@@ -91,9 +89,7 @@ v_wordW(sp, vp)
* PUBLIC: int v_wordw __P((SCR *, VICMD *));
*/
int
-v_wordw(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_wordw(SCR *sp, VICMD *vp)
{
return (fword(sp, vp, LITTLEWORD));
}
@@ -103,10 +99,7 @@ v_wordw(sp, vp)
* Move forward by words.
*/
static int
-fword(sp, vp, type)
- SCR *sp;
- VICMD *vp;
- enum which type;
+fword(SCR *sp, VICMD *vp, enum which type)
{
enum { INWORD, NOTWORD } state;
VCS cs;
@@ -125,7 +118,7 @@ fword(sp, vp, type)
* counts as a single word move. If it's a motion command,
* don't move off the end of the line.
*/
- if (cs.cs_flags == CS_EMP || cs.cs_flags == 0 && isblank(cs.cs_ch)) {
+ if (cs.cs_flags == CS_EMP || (cs.cs_flags == 0 && ISBLANK(cs.cs_ch))) {
if (ISMOTION(vp) && cs.cs_flags != CS_EMP && cnt == 1) {
if (ISCMD(vp->rkp, 'c'))
return (0);
@@ -153,7 +146,7 @@ fword(sp, vp, type)
return (1);
if (cs.cs_flags == CS_EOF)
goto ret;
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
break;
}
/*
@@ -185,7 +178,7 @@ fword(sp, vp, type)
return (1);
if (cs.cs_flags == CS_EOF)
goto ret;
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
break;
if (state == INWORD) {
if (!inword(cs.cs_ch))
@@ -204,7 +197,7 @@ fword(sp, vp, type)
}
/* Eat whitespace characters. */
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
if (cs_fblank(sp, &cs))
return (1);
if (cs.cs_flags == CS_EOF)
@@ -244,9 +237,7 @@ ret: if (!ISMOTION(vp) &&
* PUBLIC: int v_wordE __P((SCR *, VICMD *));
*/
int
-v_wordE(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_wordE(SCR *sp, VICMD *vp)
{
return (eword(sp, vp, BIGWORD));
}
@@ -258,9 +249,7 @@ v_wordE(sp, vp)
* PUBLIC: int v_worde __P((SCR *, VICMD *));
*/
int
-v_worde(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_worde(SCR *sp, VICMD *vp)
{
return (eword(sp, vp, LITTLEWORD));
}
@@ -270,10 +259,7 @@ v_worde(sp, vp)
* Move forward to the end of the word.
*/
static int
-eword(sp, vp, type)
- SCR *sp;
- VICMD *vp;
- enum which type;
+eword(SCR *sp, VICMD *vp, enum which type)
{
enum { INWORD, NOTWORD } state;
VCS cs;
@@ -291,10 +277,10 @@ eword(sp, vp, type)
* it. (This doesn't count as a word move.) Stay at the character
* past the current one, it sets word "state" for the 'e' command.
*/
- if (cs.cs_flags == 0 && !isblank(cs.cs_ch)) {
+ if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch)) {
if (cs_next(sp, &cs))
return (1);
- if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
+ if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch))
goto start;
}
if (cs_fblank(sp, &cs))
@@ -313,7 +299,7 @@ start: if (type == BIGWORD)
return (1);
if (cs.cs_flags == CS_EOF)
goto ret;
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
break;
}
/*
@@ -342,7 +328,7 @@ start: if (type == BIGWORD)
return (1);
if (cs.cs_flags == CS_EOF)
goto ret;
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
break;
if (state == INWORD) {
if (!inword(cs.cs_ch))
@@ -359,7 +345,7 @@ start: if (type == BIGWORD)
}
/* Eat whitespace characters. */
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
if (cs_fblank(sp, &cs))
return (1);
if (cs.cs_flags == CS_EOF)
@@ -397,9 +383,7 @@ ret: if (!ISMOTION(vp) &&
* PUBLIC: int v_wordB __P((SCR *, VICMD *));
*/
int
-v_wordB(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_wordB(SCR *sp, VICMD *vp)
{
return (bword(sp, vp, BIGWORD));
}
@@ -411,9 +395,7 @@ v_wordB(sp, vp)
* PUBLIC: int v_wordb __P((SCR *, VICMD *));
*/
int
-v_wordb(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_wordb(SCR *sp, VICMD *vp)
{
return (bword(sp, vp, LITTLEWORD));
}
@@ -423,10 +405,7 @@ v_wordb(sp, vp)
* Move backward by words.
*/
static int
-bword(sp, vp, type)
- SCR *sp;
- VICMD *vp;
- enum which type;
+bword(SCR *sp, VICMD *vp, enum which type)
{
enum { INWORD, NOTWORD } state;
VCS cs;
@@ -445,10 +424,10 @@ bword(sp, vp, type)
* character before the current one, it sets word "state" for the
* 'b' command.
*/
- if (cs.cs_flags == 0 && !isblank(cs.cs_ch)) {
+ if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch)) {
if (cs_prev(sp, &cs))
return (1);
- if (cs.cs_flags == 0 && !isblank(cs.cs_ch))
+ if (cs.cs_flags == 0 && !ISBLANK(cs.cs_ch))
goto start;
}
if (cs_bblank(sp, &cs))
@@ -467,7 +446,7 @@ start: if (type == BIGWORD)
return (1);
if (cs.cs_flags == CS_SOF)
goto ret;
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
break;
}
/*
@@ -496,7 +475,7 @@ start: if (type == BIGWORD)
return (1);
if (cs.cs_flags == CS_SOF)
goto ret;
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
break;
if (state == INWORD) {
if (!inword(cs.cs_ch))
@@ -513,7 +492,7 @@ start: if (type == BIGWORD)
}
/* Eat whitespace characters. */
- if (cs.cs_flags != 0 || isblank(cs.cs_ch))
+ if (cs.cs_flags != 0 || ISBLANK(cs.cs_ch))
if (cs_bblank(sp, &cs))
return (1);
if (cs.cs_flags == CS_SOF)
diff --git a/vi/v_xchar.c b/vi/v_xchar.c
index 15f155ffed33..a0c1a692be90 100644
--- a/vi/v_xchar.c
+++ b/vi/v_xchar.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_xchar.c 10.9 (Berkeley) 10/23/96";
+static const char sccsid[] = "$Id: v_xchar.c,v 10.10 2001/06/25 15:19:36 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -31,9 +31,7 @@ static const char sccsid[] = "@(#)v_xchar.c 10.9 (Berkeley) 10/23/96";
* PUBLIC: int v_xchar __P((SCR *, VICMD *));
*/
int
-v_xchar(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_xchar(SCR *sp, VICMD *vp)
{
size_t len;
int isempty;
@@ -80,9 +78,7 @@ nodel: msgq(sp, M_BERR, "206|No characters to delete");
* PUBLIC: int v_Xchar __P((SCR *, VICMD *));
*/
int
-v_Xchar(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_Xchar(SCR *sp, VICMD *vp)
{
u_long cnt;
diff --git a/vi/v_yank.c b/vi/v_yank.c
index 4708f1996774..7b02cce04adb 100644
--- a/vi/v_yank.c
+++ b/vi/v_yank.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_yank.c 10.9 (Berkeley) 5/19/96";
+static const char sccsid[] = "$Id: v_yank.c,v 10.10 2001/06/25 15:19:36 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -42,9 +42,7 @@ static const char sccsid[] = "@(#)v_yank.c 10.9 (Berkeley) 5/19/96";
* PUBLIC: int v_yank __P((SCR *, VICMD *));
*/
int
-v_yank(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_yank(SCR *sp, VICMD *vp)
{
size_t len;
diff --git a/vi/v_z.c b/vi/v_z.c
index 5f02ddf5a10b..9d4ef64f73f7 100644
--- a/vi/v_z.c
+++ b/vi/v_z.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_z.c 10.10 (Berkeley) 5/16/96";
+static const char sccsid[] = "$Id: v_z.c,v 10.13 2011/12/02 17:26:59 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -31,12 +31,10 @@ static const char sccsid[] = "@(#)v_z.c 10.10 (Berkeley) 5/16/96";
* PUBLIC: int v_z __P((SCR *, VICMD *));
*/
int
-v_z(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_z(SCR *sp, VICMD *vp)
{
recno_t lno;
- u_int value;
+ e_key_t value;
/*
* The first count is the line to use. If the value doesn't
@@ -136,9 +134,7 @@ v_z(sp, vp)
* PUBLIC: int vs_crel __P((SCR *, long));
*/
int
-vs_crel(sp, count)
- SCR *sp;
- long count;
+vs_crel(SCR *sp, long int count)
{
sp->t_minrows = sp->t_rows = count;
if (sp->t_rows > sp->rows - 1)
diff --git a/vi/v_zexit.c b/vi/v_zexit.c
index 3e454caa5bea..a2decd662882 100644
--- a/vi/v_zexit.c
+++ b/vi/v_zexit.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_zexit.c 10.6 (Berkeley) 4/27/96";
+static const char sccsid[] = "$Id: v_zexit.c,v 10.7 2001/06/25 15:19:37 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -32,9 +32,7 @@ static const char sccsid[] = "@(#)v_zexit.c 10.6 (Berkeley) 4/27/96";
* PUBLIC: int v_zexit __P((SCR *, VICMD *));
*/
int
-v_zexit(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_zexit(SCR *sp, VICMD *vp)
{
/* Write back any modifications. */
if (F_ISSET(sp->ep, F_MODIFIED) &&
diff --git a/vi/vi.c b/vi/vi.c
index d20f7f284e39..aafdbd139c5f 100644
--- a/vi/vi.c
+++ b/vi/vi.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vi.c 10.57 (Berkeley) 10/13/96";
+static const char sccsid[] = "$Id: vi.c,v 10.61 2011/12/21 13:08:30 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -40,7 +40,6 @@ static int v_count __P((SCR *, ARG_CHAR_T, u_long *));
static void v_dtoh __P((SCR *));
static int v_init __P((SCR *));
static gcret_t v_key __P((SCR *, int, EVENT *, u_int32_t));
-static int v_keyword __P((SCR *));
static int v_motion __P((SCR *, VICMD *, VICMD *, int *));
#if defined(DEBUG) && defined(COMLOG)
@@ -62,13 +61,12 @@ static void v_comlog __P((SCR *, VICMD *));
* PUBLIC: int vi __P((SCR **));
*/
int
-vi(spp)
- SCR **spp;
+vi(SCR **spp)
{
GS *gp;
MARK abs;
SCR *next, *sp;
- VICMD cmd, *vp;
+ VICMD cmd = { 0 }, *vp;
VI_PRIVATE *vip;
int comcount, mapped, rval;
@@ -76,9 +74,8 @@ vi(spp)
sp = *spp;
gp = sp->gp;
- /* Initialize the command structure. */
+ /* Point to the command structure. */
vp = &cmd;
- memset(vp, 0, sizeof(VICMD));
/* Reset strange attraction. */
F_SET(vp, VM_RCM_SET);
@@ -158,8 +155,6 @@ vi(spp)
case GC_ERR_NOFLUSH:
goto gc_err_noflush;
case GC_EVENT:
- if (v_event_exec(sp, vp))
- goto err;
goto gc_event;
case GC_FATAL:
goto ret;
@@ -347,9 +342,9 @@ gc_event:
* command, since the tag may be moving to the same file.
*/
if ((F_ISSET(vp, V_ABS) ||
- F_ISSET(vp, V_ABS_L) && sp->lno != abs.lno ||
- F_ISSET(vp, V_ABS_C) &&
- (sp->lno != abs.lno || sp->cno != abs.cno)) &&
+ (F_ISSET(vp, V_ABS_L) && sp->lno != abs.lno) ||
+ (F_ISSET(vp, V_ABS_C) &&
+ (sp->lno != abs.lno || sp->cno != abs.cno))) &&
mark_set(sp, ABSMARK1, &abs, 1))
goto err;
@@ -405,6 +400,7 @@ intr: CLR_INTERRUPT(sp);
if (F_ISSET(gp, G_SRESTART) || F_ISSET(sp, SC_EX)) {
*spp = sp;
v_dtoh(sp);
+ gp->scr_discard(sp, NULL);
break;
}
}
@@ -452,11 +448,13 @@ VIKEYS const tmotion = {
* [count] key [character]
*/
static gcret_t
-v_cmd(sp, dp, vp, ismotion, comcountp, mappedp)
- SCR *sp;
- VICMD *dp, *vp;
- VICMD *ismotion; /* Previous key if getting motion component. */
- int *comcountp, *mappedp;
+v_cmd(
+ SCR *sp,
+ VICMD *dp,
+ VICMD *vp,
+ VICMD *ismotion, /* Previous key if getting motion component. */
+ int *comcountp,
+ int *mappedp)
{
enum { COMMANDMODE, ISPARTIAL, NOTPARTIAL } cpart;
EVENT ev;
@@ -494,7 +492,7 @@ v_cmd(sp, dp, vp, ismotion, comcountp, mappedp)
if (ismotion == NULL)
cpart = NOTPARTIAL;
- /* Pick up optional buffer. */
+ /* Pick up an optional buffer. */
if (key == '"') {
cpart = ISPARTIAL;
if (ismotion != NULL) {
@@ -508,10 +506,10 @@ v_cmd(sp, dp, vp, ismotion, comcountp, mappedp)
}
/*
- * Pick up optional count, where a leading 0 is not a count,
+ * Pick up an optional count, where a leading 0 is not a count,
* it's a command.
*/
- if (isdigit(key) && key != '0') {
+ if (ISDIGIT(key) && key != '0') {
if (v_count(sp, key, &vp->count))
return (GC_ERR);
F_SET(vp, VC_C1SET);
@@ -650,7 +648,7 @@ v_cmd(sp, dp, vp, ismotion, comcountp, mappedp)
* Don't set the EC_MAPCOMMAND flag, apparently ] is a popular
* vi meta-character, and we don't want the user to wait while
* we time out a possible mapping. This *appears* to match
- * historic vi practice, but with mapping characters, you Just
+ * historic vi practice, but with mapping characters, You Just
* Never Know.
*/
KEY(key, 0);
@@ -669,7 +667,7 @@ usage: if (ismotion == NULL)
/* Special case: 'z' command. */
if (vp->key == 'z') {
KEY(vp->character, 0);
- if (isdigit(vp->character)) {
+ if (ISDIGIT(vp->character)) {
if (v_count(sp, vp->character, &vp->count2))
return (GC_ERR);
F_SET(vp, VC_C2SET);
@@ -678,8 +676,8 @@ usage: if (ismotion == NULL)
}
/*
- * Commands that have motion components can be doubled to
- * imply the current line.
+ * Commands that have motion components can be doubled to imply the
+ * current line.
*/
if (ismotion != NULL && ismotion->key != key && !LF_ISSET(V_MOVE)) {
msgq(sp, M_ERR, "210|%s may not be used as a motion command",
@@ -687,12 +685,12 @@ usage: if (ismotion == NULL)
return (GC_ERR);
}
- /* Required character. */
+ /* Pick up required trailing character. */
if (LF_ISSET(V_CHAR))
KEY(vp->character, 0);
/* Get any associated cursor word. */
- if (F_ISSET(kp, V_KEYW) && v_keyword(sp))
+ if (F_ISSET(kp, V_KEYW) && v_curword(sp))
return (GC_ERR);
return (GC_OK);
@@ -716,10 +714,11 @@ esc: switch (cpart) {
* Get resulting motion mark.
*/
static int
-v_motion(sp, dm, vp, mappedp)
- SCR *sp;
- VICMD *dm, *vp;
- int *mappedp;
+v_motion(
+ SCR *sp,
+ VICMD *dm,
+ VICMD *vp,
+ int *mappedp)
{
VICMD motion;
size_t len;
@@ -785,7 +784,7 @@ v_motion(sp, dm, vp, mappedp)
vp->m_stop.lno = sp->lno + motion.count - 1;
if (db_get(sp, vp->m_stop.lno, 0, NULL, &len)) {
if (vp->m_stop.lno != 1 ||
- vp->key != 'c' && vp->key != '!') {
+ (vp->key != 'c' && vp->key != '!')) {
v_emsg(sp, NULL, VIM_EMPTY);
return (1);
}
@@ -857,7 +856,7 @@ v_motion(sp, dm, vp, mappedp)
*/
if (!db_exist(sp, vp->m_stop.lno)) {
if (vp->m_stop.lno != 1 ||
- vp->key != 'c' && vp->key != '!') {
+ (vp->key != 'c' && vp->key != '!')) {
v_emsg(sp, NULL, VIM_EMPTY);
return (1);
}
@@ -901,8 +900,8 @@ v_motion(sp, dm, vp, mappedp)
* Motions are from the from MARK to the to MARK (inclusive).
*/
if (motion.m_start.lno > motion.m_stop.lno ||
- motion.m_start.lno == motion.m_stop.lno &&
- motion.m_start.cno > motion.m_stop.cno) {
+ (motion.m_start.lno == motion.m_stop.lno &&
+ motion.m_start.cno > motion.m_stop.cno)) {
vp->m_start = motion.m_stop;
vp->m_stop = motion.m_start;
} else {
@@ -929,8 +928,7 @@ v_motion(sp, dm, vp, mappedp)
* Initialize the vi screen.
*/
static int
-v_init(sp)
- SCR *sp;
+v_init(SCR *sp)
{
GS *gp;
VI_PRIVATE *vip;
@@ -964,12 +962,12 @@ v_init(sp)
sp->t_minrows = sp->t_rows = sp->rows - 1;
msgq(sp, M_INFO,
"214|Windows option value is too large, max is %u",
- sp->t_rows);
+ (u_int)sp->t_rows);
}
sp->t_maxrows = sp->rows - 1;
} else
sp->t_maxrows = 1;
- sp->woff = 0;
+ sp->roff = sp->coff = 0;
/* Create a screen map. */
CALLOC_RET(sp, HMAP, SMAP *, SIZE_HMAP(sp), sizeof(SMAP));
@@ -1000,8 +998,7 @@ v_init(sp)
* Move all but the current screen to the hidden queue.
*/
static void
-v_dtoh(sp)
- SCR *sp;
+v_dtoh(SCR *sp)
{
GS *gp;
SCR *tsp;
@@ -1009,42 +1006,40 @@ v_dtoh(sp)
/* Move all screens to the hidden queue, tossing screen maps. */
for (hidden = 0, gp = sp->gp;
- (tsp = gp->dq.cqh_first) != (void *)&gp->dq; ++hidden) {
+ (tsp = TAILQ_FIRST(gp->dq)) != NULL; ++hidden) {
if (_HMAP(tsp) != NULL) {
free(_HMAP(tsp));
_HMAP(tsp) = NULL;
}
- CIRCLEQ_REMOVE(&gp->dq, tsp, q);
- CIRCLEQ_INSERT_TAIL(&gp->hq, tsp, q);
+ TAILQ_REMOVE(gp->dq, tsp, q);
+ TAILQ_INSERT_TAIL(gp->hq, tsp, q);
+ /* XXXX Change if hidden screens per window */
+ gp->scr_discard(tsp, NULL);
}
/* Move current screen back to the display queue. */
- CIRCLEQ_REMOVE(&gp->hq, sp, q);
- CIRCLEQ_INSERT_TAIL(&gp->dq, sp, q);
+ TAILQ_REMOVE(gp->hq, sp, q);
+ TAILQ_INSERT_TAIL(gp->dq, sp, q);
- /*
- * XXX
- * Don't bother internationalizing this message, it's going to
- * go away as soon as we have one-line screens. --TK
- */
if (hidden > 1)
msgq(sp, M_INFO,
- "%d screens backgrounded; use :display to list them",
+ "319|%d screens backgrounded; use :display to list them",
hidden - 1);
}
/*
- * v_keyword --
- * Get the word (or non-word) the cursor is on.
+ * v_curword --
+ * Get the word (tagstring, actually) the cursor is on.
+ *
+ * PUBLIC: int v_curword __P((SCR *));
*/
-static int
-v_keyword(sp)
- SCR *sp;
+int
+v_curword(SCR *sp)
{
VI_PRIVATE *vip;
size_t beg, end, len;
- int moved, state;
- char *p;
+ int moved;
+ CHAR_T *p;
if (db_get(sp, sp->lno, DBG_FATAL, &p, &len))
return (1);
@@ -1065,7 +1060,7 @@ v_keyword(sp)
* follow the same rule.
*/
for (moved = 0,
- beg = sp->cno; beg < len && isspace(p[beg]); moved = 1, ++beg);
+ beg = sp->cno; beg < len && ISSPACE(p[beg]); moved = 1, ++beg);
if (beg >= len) {
msgq(sp, M_BERR, "212|Cursor not in a word");
return (1);
@@ -1075,14 +1070,19 @@ v_keyword(sp)
(void)vs_refresh(sp, 0);
}
- /* Find the end of the word. */
- for (state = inword(p[beg]),
- end = beg; ++end < len && state == inword(p[end]););
+ /*
+ * Find the end of the word.
+ *
+ * !!!
+ * Historically, vi accepted any non-blank as initial character
+ * when building up a tagstring. Required by IEEE 1003.1-2001.
+ */
+ for (end = beg; ++end < len && inword(p[end]););
vip = VIP(sp);
- len = (end - beg);
- BINC_RET(sp, vip->keyw, vip->klen, len);
- memmove(vip->keyw, p + beg, len);
+ vip->klen = len = (end - beg);
+ BINC_RETW(sp, vip->keyw, vip->keywlen, len+1);
+ MEMMOVE(vip->keyw, p + beg, len);
vip->keyw[len] = '\0'; /* XXX */
return (0);
}
@@ -1092,10 +1092,10 @@ v_keyword(sp)
* Check for a command alias.
*/
static VIKEYS const *
-v_alias(sp, vp, kp)
- SCR *sp;
- VICMD *vp;
- VIKEYS const *kp;
+v_alias(
+ SCR *sp,
+ VICMD *vp,
+ VIKEYS const *kp)
{
CHAR_T push;
@@ -1128,10 +1128,10 @@ v_alias(sp, vp, kp)
* Return the next count.
*/
static int
-v_count(sp, fkey, countp)
- SCR *sp;
- ARG_CHAR_T fkey;
- u_long *countp;
+v_count(
+ SCR *sp,
+ ARG_CHAR_T fkey,
+ u_long *countp)
{
EVENT ev;
u_long count, tc;
@@ -1150,7 +1150,7 @@ v_count(sp, fkey, countp)
if (v_key(sp, 0, &ev,
EC_MAPCOMMAND | EC_MAPNODIGIT) != GC_OK)
return (1);
- } while (isdigit(ev.e_c));
+ } while (ISDIGIT(ev.e_c));
msgq(sp, M_ERR,
"235|Number larger than %lu", ULONG_MAX);
return (1);
@@ -1158,7 +1158,7 @@ v_count(sp, fkey, countp)
count = tc;
if (v_key(sp, 0, &ev, EC_MAPCOMMAND | EC_MAPNODIGIT) != GC_OK)
return (1);
- } while (isdigit(ev.e_c));
+ } while (ISDIGIT(ev.e_c));
*countp = count;
return (0);
}
@@ -1168,11 +1168,11 @@ v_count(sp, fkey, countp)
* Return the next event.
*/
static gcret_t
-v_key(sp, command_events, evp, ec_flags)
- SCR *sp;
- int command_events;
- EVENT *evp;
- u_int32_t ec_flags;
+v_key(
+ SCR *sp,
+ int command_events,
+ EVENT *evp,
+ u_int32_t ec_flags)
{
u_int32_t quote;
@@ -1216,10 +1216,6 @@ v_key(sp, command_events, evp, ec_flags)
break;
case E_WRESIZE:
return (GC_ERR);
- case E_QUIT:
- case E_WRITE:
- if (command_events)
- return (GC_EVENT);
/* FALLTHROUGH */
default:
v_event_err(sp, evp);
@@ -1235,13 +1231,13 @@ v_key(sp, command_events, evp, ec_flags)
* Log the contents of the command structure.
*/
static void
-v_comlog(sp, vp)
- SCR *sp;
- VICMD *vp;
+v_comlog(
+ SCR *sp,
+ VICMD *vp)
{
- TRACE(sp, "vcmd: %c", vp->key);
+ TRACE(sp, "vcmd: "WC, vp->key);
if (F_ISSET(vp, VC_BUFFER))
- TRACE(sp, " buffer: %c", vp->buffer);
+ TRACE(sp, " buffer: "WC, vp->buffer);
if (F_ISSET(vp, VC_C1SET))
TRACE(sp, " c1: %lu", vp->count);
if (F_ISSET(vp, VC_C2SET))
diff --git a/vi/vi.h b/vi/vi.h
index bede3a651817..2cfbb999ab93 100644
--- a/vi/vi.h
+++ b/vi/vi.h
@@ -6,11 +6,11 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)vi.h 10.19 (Berkeley) 6/30/96
+ * $Id: vi.h,v 10.29 2012/02/11 00:33:46 zy Exp $
*/
/* Definition of a vi "word". */
-#define inword(ch) (isalnum(ch) || (ch) == '_')
+#define inword(ch) ((ch) == '_' || (ISGRAPH(ch) && !ISPUNCT(ch)))
typedef struct _vikeys VIKEYS;
@@ -188,23 +188,24 @@ int cs_prev __P((SCR *, VCS *));
* slot for the colon command line, so there is room to add any screen into
* another one at screen exit.
*
- * Lno is the line number. If doing the historic vi long line folding, off
+ * Lno is the line number. If doing the historic vi long line folding, soff
* is the screen offset into the line. For example, the pair 2:1 would be
* the first screen of line 2, and 2:2 would be the second. In the case of
* long lines, the screen map will tend to be staggered, e.g., 1:1, 1:2, 1:3,
- * 2:1, 3:1, etc. If doing left-right scrolling, the off field is the screen
+ * 2:1, 3:1, etc. If doing left-right scrolling, the coff field is the screen
* column offset into the lines, and can take on any value, as it's adjusted
* by the user set value O_SIDESCROLL.
*/
typedef struct _smap {
- recno_t lno; /* 1-N: Physical file line number. */
+ recno_t lno; /* 1-N: Physical file line number. */
size_t coff; /* 0-N: Column offset in the line. */
size_t soff; /* 1-N: Screen offset in the line. */
/* vs_line() cache information. */
- size_t c_sboff; /* 0-N: offset of first character byte. */
- size_t c_eboff; /* 0-N: offset of last character byte. */
+ size_t c_sboff; /* 0-N: offset of first character on screen. */
+ size_t c_eboff; /* 0-N: offset of last character on screen. */
u_int8_t c_scoff; /* 0-N: offset into the first character. */
+ /* 255: no character of line visible. */
u_int8_t c_eclen; /* 1-N: columns from the last character. */
u_int8_t c_ecsize; /* 1-N: size of the last character. */
} SMAP;
@@ -253,8 +254,11 @@ typedef struct _vi_private {
size_t busy_fx; /* Busy character x coordinate. */
size_t busy_oldy; /* Saved y coordinate. */
size_t busy_oldx; /* Saved x coordinate. */
- struct timeval busy_tv; /* Busy timer. */
+ struct timespec busy_ts;/* Busy timer. */
+ MARK sel; /* Select start position. */
+
+ CHAR_T *mcs; /* Match character list. */
char *ps; /* Paragraph plus section list. */
u_long u_ccnt; /* Undo command count. */
@@ -351,10 +355,15 @@ typedef struct _vi_private {
*/
#define TAB_OFF(c) COL_OFF((c), O_VAL(sp, O_TABSTOP))
+/* If more than one horizontal screen being shown. */
+#define IS_HSPLIT(sp) \
+ ((sp)->rows != O_VAL(sp, O_LINES))
+/* If more than one vertical screen being shown. */
+#define IS_VSPLIT(sp) \
+ ((sp)->cols != O_VAL(sp, O_COLUMNS))
/* If more than one screen being shown. */
#define IS_SPLIT(sp) \
- ((sp)->q.cqe_next != (void *)&(sp)->gp->dq || \
- (sp)->q.cqe_prev != (void *)&(sp)->gp->dq)
+ (IS_HSPLIT(sp) || IS_VSPLIT(sp))
/* Screen adjustment operations. */
typedef enum { A_DECREASE, A_INCREASE, A_SET } adj_t;
@@ -374,4 +383,4 @@ typedef enum {
VIM_NOCOM, VIM_NOCOM_B, VIM_USAGE, VIM_WRESIZE
} vim_t;
-#include "vi_extern.h"
+#include "extern.h"
diff --git a/vi/vs_line.c b/vi/vs_line.c
index 2e5166227b35..dc12a3ad11fd 100644
--- a/vi/vs_line.c
+++ b/vi/vs_line.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_line.c 10.19 (Berkeley) 9/26/96";
+static const char sccsid[] = "$Id: vs_line.c,v 10.40 2012/02/13 19:22:25 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -38,20 +38,19 @@ static const char sccsid[] = "@(#)vs_line.c 10.19 (Berkeley) 9/26/96";
* PUBLIC: int vs_line __P((SCR *, SMAP *, size_t *, size_t *));
*/
int
-vs_line(sp, smp, yp, xp)
- SCR *sp;
- SMAP *smp;
- size_t *xp, *yp;
+vs_line(SCR *sp, SMAP *smp, size_t *yp, size_t *xp)
{
- CHAR_T *kp;
+ u_char *kp;
GS *gp;
SMAP *tsmp;
- size_t chlen, cno_cnt, cols_per_screen, len, nlen;
+ size_t chlen = 0, cno_cnt, cols_per_screen, len, nlen;
size_t offset_in_char, offset_in_line, oldx, oldy;
size_t scno, skip_cols, skip_screens;
- int ch, dne, is_cached, is_partial, is_tab, no_draw;
+ int dne, is_cached, is_partial, is_tab, no_draw;
int list_tab, list_dollar;
- char *p, *cbp, *ecbp, cbuf[128];
+ CHAR_T *p;
+ CHAR_T *cbp, *ecbp, cbuf[128];
+ ARG_CHAR_T ch = '\0';
#if defined(DEBUG) && 0
TRACE(sp, "vs_line: row %u: line: %u off: %u\n",
@@ -139,9 +138,9 @@ vs_line(sp, smp, yp, xp)
if (O_ISSET(sp, O_NUMBER)) {
cols_per_screen -= O_NUMBER_LENGTH;
if ((!dne || smp->lno == 1) && skip_cols == 0) {
- nlen = snprintf(cbuf,
- sizeof(cbuf), O_NUMBER_FMT, smp->lno);
- (void)gp->scr_addstr(sp, cbuf, nlen);
+ nlen = snprintf((char*)cbuf,
+ sizeof(cbuf), O_NUMBER_FMT, (u_long)smp->lno);
+ (void)gp->scr_addstr(sp, (char*)cbuf, nlen);
}
}
}
@@ -193,6 +192,12 @@ empty: (void)gp->scr_addstr(sp,
return (0);
}
+ /* If we shortened this line in another screen, the cursor
+ * position may have fallen off.
+ */
+ if (sp->lno == smp->lno && sp->cno >= len)
+ sp->cno = len - 1;
+
/*
* If we just wrote this or a previous line, we cached the starting
* and ending positions of that line. The way it works is we keep
@@ -258,8 +263,8 @@ empty: (void)gp->scr_addstr(sp,
/* Do it the hard way, for leftright scrolling screens. */
if (O_ISSET(sp, O_LEFTRIGHT)) {
for (; offset_in_line < len; ++offset_in_line) {
- chlen = (ch = *(u_char *)p++) == '\t' && !list_tab ?
- TAB_OFF(scno) : KEY_LEN(sp, ch);
+ chlen = (ch = *p++) == '\t' && !list_tab ?
+ TAB_OFF(scno) : KEY_COL(sp, ch);
if ((scno += chlen) >= skip_cols)
break;
}
@@ -285,8 +290,8 @@ empty: (void)gp->scr_addstr(sp,
/* Do it the hard way, for historic line-folding screens. */
else {
for (; offset_in_line < len; ++offset_in_line) {
- chlen = (ch = *(u_char *)p++) == '\t' && !list_tab ?
- TAB_OFF(scno) : KEY_LEN(sp, ch);
+ chlen = (ch = *p++) == '\t' && !list_tab ?
+ TAB_OFF(scno) : KEY_COL(sp, ch);
if ((scno += chlen) < cols_per_screen)
continue;
scno -= cols_per_screen;
@@ -332,14 +337,14 @@ display:
cno_cnt = (sp->cno - offset_in_line) + 1;
/* This is the loop that actually displays characters. */
- ecbp = (cbp = cbuf) + sizeof(cbuf) - 1;
+ ecbp = (cbp = cbuf) + SIZE(cbuf) - 1;
for (is_partial = 0, scno = 0;
offset_in_line < len; ++offset_in_line, offset_in_char = 0) {
- if ((ch = *(u_char *)p++) == '\t' && !list_tab) {
+ if ((ch = *p++) == '\t' && !list_tab) {
scno += chlen = TAB_OFF(scno) - offset_in_char;
is_tab = 1;
} else {
- scno += chlen = KEY_LEN(sp, ch) - offset_in_char;
+ scno += chlen = KEY_COL(sp, ch) - offset_in_char;
is_tab = 0;
}
@@ -382,7 +387,10 @@ display:
--cno_cnt == 0 && (F_ISSET(sp, SC_TINPUT) || !is_partial)) {
*yp = smp - HMAP;
if (F_ISSET(sp, SC_TINPUT))
- *xp = scno - chlen;
+ if (is_partial)
+ *xp = scno - smp->c_ecsize;
+ else
+ *xp = scno - chlen;
else
*xp = scno - 1;
if (O_ISSET(sp, O_NUMBER) &&
@@ -400,7 +408,7 @@ display:
#define FLUSH { \
*cbp = '\0'; \
- (void)gp->scr_addstr(sp, cbuf, cbp - cbuf); \
+ (void)gp->scr_waddstr(sp, cbuf, cbp - cbuf); \
cbp = cbuf; \
}
/*
@@ -419,14 +427,26 @@ display:
else {
if (cbp + chlen >= ecbp)
FLUSH;
- for (kp = KEY_NAME(sp, ch) + offset_in_char; chlen--;)
- *cbp++ = *kp++;
+
+ /* don't display half a wide character */
+ if (is_partial && CHAR_WIDTH(sp, ch) > 1) {
+ *cbp++ = ' ';
+ break;
+ }
+
+ if (KEY_NEEDSWIDE(sp, ch))
+ *cbp++ = ch;
+ else
+ for (kp = (u_char *)
+ KEY_NAME(sp, ch) + offset_in_char;
+ chlen--;)
+ *cbp++ = *kp++;
}
}
if (scno < cols_per_screen) {
/* If didn't paint the whole line, update the cache. */
- smp->c_ecsize = smp->c_eclen = KEY_LEN(sp, ch);
+ smp->c_ecsize = smp->c_eclen = KEY_COL(sp, ch);
smp->c_eboff = len - 1;
/*
@@ -440,7 +460,8 @@ display:
chlen = KEY_LEN(sp, '$');
if (cbp + chlen >= ecbp)
FLUSH;
- for (kp = KEY_NAME(sp, '$'); chlen--;)
+ for (kp = (u_char *)
+ KEY_NAME(sp, '$'); chlen--;)
*cbp++ = *kp++;
}
@@ -464,8 +485,7 @@ ret1: (void)gp->scr_move(sp, oldy, oldx);
* PUBLIC: int vs_number __P((SCR *));
*/
int
-vs_number(sp)
- SCR *sp;
+vs_number(SCR *sp)
{
GS *gp;
SMAP *smp;
@@ -510,7 +530,7 @@ vs_number(sp)
break;
(void)gp->scr_move(sp, smp - HMAP, 0);
- len = snprintf(nbuf, sizeof(nbuf), O_NUMBER_FMT, smp->lno);
+ len = snprintf(nbuf, sizeof(nbuf), O_NUMBER_FMT, (u_long)smp->lno);
(void)gp->scr_addstr(sp, nbuf, len);
}
(void)gp->scr_move(sp, oldy, oldx);
diff --git a/vi/vs_msg.c b/vi/vs_msg.c
index 7ef8f5343c15..32b2755c1722 100644
--- a/vi/vs_msg.c
+++ b/vi/vs_msg.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_msg.c 10.77 (Berkeley) 10/13/96";
+static const char sccsid[] = "$Id: vs_msg.c,v 10.88 2013/03/19 09:59:03 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -56,15 +56,13 @@ static void vs_wait __P((SCR *, int *, sw_t));
* PUBLIC: void vs_busy __P((SCR *, const char *, busy_t));
*/
void
-vs_busy(sp, msg, btype)
- SCR *sp;
- const char *msg;
- busy_t btype;
+vs_busy(SCR *sp, const char *msg, busy_t btype)
{
GS *gp;
VI_PRIVATE *vip;
static const char flagc[] = "|/-\\";
- struct timeval tv;
+ struct timespec ts, ts_diff;
+ const struct timespec ts_min = { 0, 125000000 };
size_t len, notused;
const char *p;
@@ -89,7 +87,7 @@ vs_busy(sp, msg, btype)
/* Initialize state for updates. */
vip->busy_ch = 0;
- (void)gettimeofday(&vip->busy_tv, NULL);
+ timepoint_steady(&vip->busy_ts);
/* Save the current cursor. */
(void)gp->scr_cursor(sp, &vip->busy_oldy, &vip->busy_oldx);
@@ -122,11 +120,12 @@ vs_busy(sp, msg, btype)
break;
/* Update no more than every 1/8 of a second. */
- (void)gettimeofday(&tv, NULL);
- if (((tv.tv_sec - vip->busy_tv.tv_sec) * 1000000 +
- (tv.tv_usec - vip->busy_tv.tv_usec)) < 125000)
+ timepoint_steady(&ts);
+ ts_diff = ts;
+ timespecsub(&ts_diff, &vip->busy_ts);
+ if (timespeccmp(&ts_diff, &ts_min, <))
return;
- vip->busy_tv = tv;
+ vip->busy_ts = ts;
/* Display the update. */
if (vip->busy_ch == sizeof(flagc) - 1)
@@ -146,8 +145,7 @@ vs_busy(sp, msg, btype)
* PUBLIC: void vs_home __P((SCR *));
*/
void
-vs_home(sp)
- SCR *sp;
+vs_home(SCR *sp)
{
(void)sp->gp->scr_move(sp, LASTLINE(sp), 0);
(void)sp->gp->scr_refresh(sp, 0);
@@ -157,15 +155,15 @@ vs_home(sp)
* vs_update --
* Update a command.
*
- * PUBLIC: void vs_update __P((SCR *, const char *, const char *));
+ * PUBLIC: void vs_update __P((SCR *, const char *, const CHAR_T *));
*/
void
-vs_update(sp, m1, m2)
- SCR *sp;
- const char *m1, *m2;
+vs_update(SCR *sp, const char *m1, const CHAR_T *m2)
{
GS *gp;
size_t len, mlen, oldx, oldy;
+ CONST char *np;
+ size_t nlen;
gp = sp->gp;
@@ -178,8 +176,10 @@ vs_update(sp, m1, m2)
* expanded, and by the ex substitution confirmation prompt.
*/
if (F_ISSET(sp, SC_SCR_EXWROTE)) {
+ if (m2 != NULL)
+ INT2CHAR(sp, m2, STRLEN(m2) + 1, np, nlen);
(void)ex_printf(sp,
- "%s\n", m1 == NULL? "" : m1, m2 == NULL ? "" : m2);
+ "%s\n", m1 == NULL? "" : m1, m2 == NULL ? "" : np);
(void)ex_fflush(sp);
}
@@ -205,10 +205,10 @@ vs_update(sp, m1, m2)
} else
len = 0;
if (m2 != NULL) {
- mlen = strlen(m2);
+ mlen = STRLEN(m2);
if (len + mlen > sp->cols - 2)
mlen = (sp->cols - 2) - len;
- (void)gp->scr_addstr(sp, m2, mlen);
+ (void)gp->scr_waddstr(sp, m2, mlen);
}
(void)gp->scr_move(sp, oldy, oldx);
@@ -228,11 +228,7 @@ vs_update(sp, m1, m2)
* PUBLIC: void vs_msg __P((SCR *, mtype_t, char *, size_t));
*/
void
-vs_msg(sp, mtype, line, len)
- SCR *sp;
- mtype_t mtype;
- char *line;
- size_t len;
+vs_msg(SCR *sp, mtype_t mtype, char *line, size_t len)
{
GS *gp;
VI_PRIVATE *vip;
@@ -394,17 +390,12 @@ ret: (void)gp->scr_move(sp, oldy, oldx);
* Output the text to the screen.
*/
static void
-vs_output(sp, mtype, line, llen)
- SCR *sp;
- mtype_t mtype;
- const char *line;
- int llen;
+vs_output(SCR *sp, mtype_t mtype, const char *line, int llen)
{
- CHAR_T *kp;
GS *gp;
VI_PRIVATE *vip;
- size_t chlen, notused;
- int ch, len, rlen, tlen;
+ size_t notused;
+ int len, rlen, tlen;
const char *p, *t;
char *cbp, *ecbp, cbuf[128];
@@ -472,7 +463,6 @@ vs_output(sp, mtype, line, llen)
}
ecbp = (cbp = cbuf) + sizeof(cbuf) - 1;
for (t = line, tlen = len; tlen--; ++t) {
- ch = *t;
/*
* Replace tabs with spaces, there are places in
* ex that do column calculations without looking
@@ -480,13 +470,9 @@ vs_output(sp, mtype, line, llen)
* <tabs> do their own expansions. This catches
* <tabs> in things like tag search strings.
*/
- if (ch == '\t')
- ch = ' ';
- chlen = KEY_LEN(sp, ch);
- if (cbp + chlen >= ecbp)
+ if (cbp + 1 >= ecbp)
FLUSH;
- for (kp = KEY_NAME(sp, ch); chlen--;)
- *cbp++ = *kp++;
+ *cbp++ = *t == '\t' ? ' ' : *t;
}
if (cbp > cbuf)
FLUSH;
@@ -523,9 +509,7 @@ vs_output(sp, mtype, line, llen)
* PUBLIC: int vs_ex_resolve __P((SCR *, int *));
*/
int
-vs_ex_resolve(sp, continuep)
- SCR *sp;
- int *continuep;
+vs_ex_resolve(SCR *sp, int *continuep)
{
EVENT ev;
GS *gp;
@@ -598,7 +582,7 @@ vs_ex_resolve(sp, continuep)
* If we're not the bottom of the split screen stack, the screen
* image itself is wrong, so redraw everything.
*/
- if (sp->q.cqe_next != (void *)&sp->gp->dq)
+ if (TAILQ_NEXT(sp, q) != NULL)
F_SET(sp, SC_SCR_REDRAW);
/* If ex changed the underlying file, the map itself is wrong. */
@@ -649,9 +633,7 @@ vs_ex_resolve(sp, continuep)
* PUBLIC: int vs_resolve __P((SCR *, SCR *, int));
*/
int
-vs_resolve(sp, csp, forcewait)
- SCR *sp, *csp;
- int forcewait;
+vs_resolve(SCR *sp, SCR *csp, int forcewait)
{
EVENT ev;
GS *gp;
@@ -696,12 +678,12 @@ vs_resolve(sp, csp, forcewait)
* messages.) Once this is done, don't trust the cursor. That
* extra refresh screwed the pooch.
*/
- if (gp->msgq.lh_first != NULL) {
+ if (!SLIST_EMPTY(gp->msgq)) {
if (!F_ISSET(sp, SC_SCR_VI) && vs_refresh(sp, 1))
return (1);
- while ((mp = gp->msgq.lh_first) != NULL) {
+ while ((mp = SLIST_FIRST(gp->msgq)) != NULL) {
gp->scr_msg(sp, mp->mtype, mp->buf, mp->len);
- LIST_REMOVE(mp, q);
+ SLIST_REMOVE_HEAD(gp->msgq, q);
free(mp->buf);
free(mp);
}
@@ -758,10 +740,7 @@ vs_resolve(sp, csp, forcewait)
* Scroll the screen for output.
*/
static void
-vs_scroll(sp, continuep, wtype)
- SCR *sp;
- int *continuep;
- sw_t wtype;
+vs_scroll(SCR *sp, int *continuep, sw_t wtype)
{
GS *gp;
VI_PRIVATE *vip;
@@ -779,7 +758,7 @@ vs_scroll(sp, continuep, wtype)
(void)gp->scr_deleteln(sp);
/* If there are screens below us, push them back into place. */
- if (sp->q.cqe_next != (void *)&sp->gp->dq) {
+ if (TAILQ_NEXT(sp, q) != NULL) {
(void)gp->scr_move(sp, LASTLINE(sp), 0);
(void)gp->scr_insertln(sp);
}
@@ -794,10 +773,7 @@ vs_scroll(sp, continuep, wtype)
* Prompt the user to continue.
*/
static void
-vs_wait(sp, continuep, wtype)
- SCR *sp;
- int *continuep;
- sw_t wtype;
+vs_wait(SCR *sp, int *continuep, sw_t wtype)
{
EVENT ev;
VI_PRIVATE *vip;
@@ -868,8 +844,7 @@ vs_wait(sp, continuep, wtype)
* Draw a dividing line between the screen and the output.
*/
static void
-vs_divider(sp)
- SCR *sp;
+vs_divider(SCR *sp)
{
GS *gp;
size_t len;
@@ -888,11 +863,7 @@ vs_divider(sp)
* Save a message for later display.
*/
static void
-vs_msgsave(sp, mt, p, len)
- SCR *sp;
- mtype_t mt;
- char *p;
- size_t len;
+vs_msgsave(SCR *sp, mtype_t mt, char *p, size_t len)
{
GS *gp;
MSGS *mp_c, *mp_n;
@@ -912,11 +883,13 @@ vs_msgsave(sp, mt, p, len)
mp_n->mtype = mt;
gp = sp->gp;
- if ((mp_c = gp->msgq.lh_first) == NULL) {
- LIST_INSERT_HEAD(&gp->msgq, mp_n, q);
+ if (SLIST_EMPTY(gp->msgq)) {
+ SLIST_INSERT_HEAD(gp->msgq, mp_n, q);
} else {
- for (; mp_c->q.le_next != NULL; mp_c = mp_c->q.le_next);
- LIST_INSERT_AFTER(mp_c, mp_n, q);
+ SLIST_FOREACH(mp_c, gp->msgq, q)
+ if (SLIST_NEXT(mp_c, q) == NULL)
+ break;
+ SLIST_INSERT_AFTER(mp_c, mp_n, q);
}
return;
diff --git a/vi/vs_refresh.c b/vi/vs_refresh.c
index 81587608c1a2..98b66c492d1f 100644
--- a/vi/vs_refresh.c
+++ b/vi/vs_refresh.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_refresh.c 10.44 (Berkeley) 10/13/96";
+static const char sccsid[] = "$Id: vs_refresh.c,v 10.52 2011/12/16 11:06:25 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -40,9 +40,9 @@ static int vs_paint __P((SCR *, u_int));
* PUBLIC: int vs_repaint __P((SCR *, EVENT *));
*/
int
-vs_repaint(sp, evp)
- SCR *sp;
- EVENT *evp;
+vs_repaint(
+ SCR *sp,
+ EVENT *evp)
{
SMAP *smp;
@@ -62,13 +62,13 @@ vs_repaint(sp, evp)
* PUBLIC: int vs_refresh __P((SCR *, int));
*/
int
-vs_refresh(sp, forcepaint)
- SCR *sp;
- int forcepaint;
+vs_refresh(
+ SCR *sp,
+ int forcepaint)
{
GS *gp;
SCR *tsp;
- int need_refresh;
+ int need_refresh = 0;
u_int priv_paint, pub_paint;
gp = sp->gp;
@@ -80,8 +80,7 @@ vs_refresh(sp, forcepaint)
* that we can find, including status lines.
*/
if (F_ISSET(sp, SC_SCR_REDRAW))
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ TAILQ_FOREACH(tsp, gp->dq, q)
if (tsp != sp)
F_SET(tsp, SC_SCR_REDRAW | SC_STATUS);
@@ -98,8 +97,7 @@ vs_refresh(sp, forcepaint)
priv_paint = VIP_CUR_INVALID | VIP_N_REFRESH;
if (O_ISSET(sp, O_NUMBER))
priv_paint |= VIP_N_RENUMBER;
- for (tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ TAILQ_FOREACH(tsp, gp->dq, q)
if (tsp != sp && !F_ISSET(tsp, SC_EXIT | SC_EXIT_FORCE) &&
(F_ISSET(tsp, pub_paint) ||
F_ISSET(VIP(tsp), priv_paint))) {
@@ -134,8 +132,7 @@ vs_refresh(sp, forcepaint)
* And, finally, if we updated any status lines, make sure the cursor
* gets back to where it belongs.
*/
- for (need_refresh = 0, tsp = gp->dq.cqh_first;
- tsp != (void *)&gp->dq; tsp = tsp->q.cqe_next)
+ TAILQ_FOREACH(tsp, gp->dq, q)
if (F_ISSET(tsp, SC_STATUS)) {
need_refresh = 1;
vs_resolve(tsp, sp, 0);
@@ -162,17 +159,17 @@ vs_refresh(sp, forcepaint)
* what you're doing. It's subtle and quick to anger.
*/
static int
-vs_paint(sp, flags)
- SCR *sp;
- u_int flags;
+vs_paint(
+ SCR *sp,
+ u_int flags)
{
GS *gp;
SMAP *smp, tmp;
VI_PRIVATE *vip;
recno_t lastline, lcnt;
size_t cwtotal, cnt, len, notused, off, y;
- int ch, didpaint, isempty, leftright_warp;
- char *p;
+ int ch = 0, didpaint, isempty, leftright_warp;
+ CHAR_T *p;
#define LNO sp->lno /* Current file line. */
#define OLNO vip->olno /* Remembered file line. */
@@ -470,7 +467,7 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
#ifdef DEBUG
/* Sanity checking. */
if (CNO >= len && len != 0) {
- msgq(sp, M_ERR, "Error: %s/%d: cno (%u) >= len (%u)",
+ msgq(sp, M_ERR, "Error: %s/%d: cno (%zu) >= len (%zu)",
tail(__FILE__), __LINE__, CNO, len);
return (1);
}
@@ -507,8 +504,8 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
* Count up the widths of the characters. If it's a tab
* character, go do it the the slow way.
*/
- for (cwtotal = 0; cnt--; cwtotal += KEY_LEN(sp, ch))
- if ((ch = *(u_char *)p--) == '\t')
+ for (cwtotal = 0; cnt--; cwtotal += KEY_COL(sp, ch))
+ if ((ch = *(UCHAR_T *)p--) == '\t')
goto slow;
/*
@@ -521,8 +518,8 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
* If we're moving left, and there's a wide character in the
* current position, go to the end of the character.
*/
- if (KEY_LEN(sp, ch) > 1)
- cwtotal -= KEY_LEN(sp, ch) - 1;
+ if (KEY_COL(sp, ch) > 1)
+ cwtotal -= KEY_COL(sp, ch) - 1;
/*
* If the new column moved us off of the current logical line,
@@ -547,9 +544,9 @@ adjust: if (!O_ISSET(sp, O_LEFTRIGHT) &&
* screen boundary, we can quit.
*/
for (cwtotal = SCNO; cnt--;) {
- if ((ch = *(u_char *)p++) == '\t')
+ if ((ch = *(UCHAR_T *)p++) == '\t')
goto slow;
- if ((cwtotal += KEY_LEN(sp, ch)) >= SCREEN_COLS(sp))
+ if ((cwtotal += KEY_COL(sp, ch)) >= SCREEN_COLS(sp))
break;
}
@@ -595,7 +592,7 @@ slow: for (smp = HMAP; smp->lno != LNO; ++smp);
* for the number option offset.
*/
cnt = vs_columns(sp, NULL, LNO, &CNO, NULL);
- if (O_ISSET(sp, O_NUMBER))
+ if (O_ISSET(sp, O_NUMBER) && cnt >= O_NUMBER_LENGTH)
cnt -= O_NUMBER_LENGTH;
/* Adjust the window towards the beginning of the line. */
@@ -613,8 +610,8 @@ slow: for (smp = HMAP; smp->lno != LNO; ++smp);
}
/* Adjust the window towards the end of the line. */
- if (off == 0 && off + SCREEN_COLS(sp) < cnt ||
- off != 0 && off + sp->cols < cnt) {
+ if ((off == 0 && off + SCREEN_COLS(sp) < cnt) ||
+ (off != 0 && off + sp->cols < cnt)) {
do {
off += O_VAL(sp, O_SIDESCROLL);
} while (off + sp->cols < cnt);
@@ -763,8 +760,7 @@ number: if (O_ISSET(sp, O_NUMBER) &&
* Update the mode line.
*/
static void
-vs_modeline(sp)
- SCR *sp;
+vs_modeline(SCR *sp)
{
static char * const modes[] = {
"215|Append", /* SM_APPEND */
@@ -775,9 +771,9 @@ vs_modeline(sp)
};
GS *gp;
size_t cols, curcol, curlen, endpoint, len, midpoint;
- const char *t;
+ const char *t = NULL;
int ellipsis;
- char *p, buf[20];
+ char buf[20];
gp = sp->gp;
@@ -799,19 +795,23 @@ vs_modeline(sp)
/* If more than one screen in the display, show the file name. */
curlen = 0;
if (IS_SPLIT(sp)) {
- for (p = sp->frp->name; *p != '\0'; ++p);
- for (ellipsis = 0, cols = sp->cols / 2; --p > sp->frp->name;) {
+ CHAR_T *wp, *p;
+ size_t l;
+
+ CHAR2INT(sp, sp->frp->name, strlen(sp->frp->name) + 1, wp, l);
+ p = wp + l;
+ for (ellipsis = 0, cols = sp->cols / 2; --p > wp;) {
if (*p == '/') {
++p;
break;
}
- if ((curlen += KEY_LEN(sp, *p)) > cols) {
+ if ((curlen += KEY_COL(sp, *p)) > cols) {
ellipsis = 3;
curlen +=
KEY_LEN(sp, '.') * 3 + KEY_LEN(sp, ' ');
while (curlen > cols) {
++p;
- curlen -= KEY_LEN(sp, *p);
+ curlen -= KEY_COL(sp, *p);
}
break;
}
@@ -825,7 +825,7 @@ vs_modeline(sp)
}
for (; *p != '\0'; ++p)
(void)gp->scr_addstr(sp,
- KEY_NAME(sp, *p), KEY_LEN(sp, *p));
+ KEY_NAME(sp, *p), KEY_COL(sp, *p));
}
/* Clear the rest of the line. */
@@ -845,8 +845,8 @@ vs_modeline(sp)
cols = sp->cols - 1;
if (O_ISSET(sp, O_RULER)) {
vs_column(sp, &curcol);
- len =
- snprintf(buf, sizeof(buf), "%lu,%lu", sp->lno, curcol + 1);
+ len = snprintf(buf, sizeof(buf), "%lu,%lu",
+ (u_long)sp->lno, (u_long)(curcol + 1));
midpoint = (cols - ((len + 1) / 2)) / 2;
if (curlen < midpoint) {
diff --git a/vi/vs_relative.c b/vi/vs_relative.c
index 878fc4f944ad..5f25b51d9342 100644
--- a/vi/vs_relative.c
+++ b/vi/vs_relative.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_relative.c 10.11 (Berkeley) 5/13/96";
+static const char sccsid[] = "$Id: vs_relative.c,v 10.19 2011/12/01 15:22:59 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -32,9 +32,7 @@ static const char sccsid[] = "@(#)vs_relative.c 10.11 (Berkeley) 5/13/96";
* PUBLIC: int vs_column __P((SCR *, size_t *));
*/
int
-vs_column(sp, colp)
- SCR *sp;
- size_t *colp;
+vs_column(SCR *sp, size_t *colp)
{
VI_PRIVATE *vip;
@@ -55,10 +53,7 @@ vs_column(sp, colp)
* PUBLIC: size_t vs_screens __P((SCR *, recno_t, size_t *));
*/
size_t
-vs_screens(sp, lno, cnop)
- SCR *sp;
- recno_t lno;
- size_t *cnop;
+vs_screens(SCR *sp, recno_t lno, size_t *cnop)
{
size_t cols, screens;
@@ -98,18 +93,14 @@ vs_screens(sp, lno, cnop)
* Return the screen columns necessary to display the line, or,
* if specified, the physical character column within the line.
*
- * PUBLIC: size_t vs_columns __P((SCR *, char *, recno_t, size_t *, size_t *));
+ * PUBLIC: size_t vs_columns __P((SCR *, CHAR_T *, recno_t, size_t *, size_t *));
*/
size_t
-vs_columns(sp, lp, lno, cnop, diffp)
- SCR *sp;
- char *lp;
- recno_t lno;
- size_t *cnop, *diffp;
+vs_columns(SCR *sp, CHAR_T *lp, recno_t lno, size_t *cnop, size_t *diffp)
{
- size_t chlen, cno, curoff, last, len, scno;
+ size_t chlen, cno, curoff, last = 0, len, scno;
int ch, leftright, listset;
- char *p;
+ CHAR_T *p;
/*
* Initialize the screen offset.
@@ -142,11 +133,11 @@ done: if (diffp != NULL) /* XXX */
* Initialize the pointer into the buffer and current offset.
*/
p = lp;
- curoff = 0;
+ curoff = scno;
/* Macro to return the display length of any signal character. */
-#define CHLEN(val) (ch = *(u_char *)p++) == '\t' && \
- !listset ? TAB_OFF(val) : KEY_LEN(sp, ch);
+#define CHLEN(val) (ch = *(UCHAR_T *)p++) == '\t' && \
+ !listset ? TAB_OFF(val) : KEY_COL(sp, ch);
/*
* If folding screens (the historic vi screen format), past the end
@@ -204,10 +195,7 @@ done: if (diffp != NULL) /* XXX */
* PUBLIC: size_t vs_rcm __P((SCR *, recno_t, int));
*/
size_t
-vs_rcm(sp, lno, islast)
- SCR *sp;
- recno_t lno;
- int islast;
+vs_rcm(SCR *sp, recno_t lno, int islast)
{
size_t len;
@@ -233,14 +221,11 @@ vs_rcm(sp, lno, islast)
* PUBLIC: size_t vs_colpos __P((SCR *, recno_t, size_t));
*/
size_t
-vs_colpos(sp, lno, cno)
- SCR *sp;
- recno_t lno;
- size_t cno;
+vs_colpos(SCR *sp, recno_t lno, size_t cno)
{
size_t chlen, curoff, len, llen, off, scno;
- int ch, leftright, listset;
- char *lp, *p;
+ int ch = 0, leftright, listset;
+ CHAR_T *lp, *p;
/* Need the line to go any further. */
(void)db_get(sp, lno, 0, &lp, &llen);
diff --git a/vi/vs_smap.c b/vi/vs_smap.c
index 18d7942b742a..0ab2df9e95bf 100644
--- a/vi/vs_smap.c
+++ b/vi/vs_smap.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_smap.c 10.25 (Berkeley) 7/12/96";
+static const char sccsid[] = "$Id: vs_smap.c,v 10.31 2011/02/26 13:56:21 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -42,10 +42,7 @@ static int vs_sm_up __P((SCR *, MARK *, recno_t, scroll_t, SMAP *));
* PUBLIC: int vs_change __P((SCR *, recno_t, lnop_t));
*/
int
-vs_change(sp, lno, op)
- SCR *sp;
- recno_t lno;
- lnop_t op;
+vs_change(SCR *sp, recno_t lno, lnop_t op)
{
VI_PRIVATE *vip;
SMAP *p;
@@ -64,7 +61,8 @@ vs_change(sp, lno, op)
*
* Check for line #2 before going to the end of the file.
*/
- if ((op == LINE_APPEND && lno == 0 || op == LINE_INSERT && lno == 1) &&
+ if (((op == LINE_APPEND && lno == 0) ||
+ (op == LINE_INSERT && lno == 1)) &&
!db_exist(sp, 2)) {
lno = 1;
op = LINE_RESET;
@@ -138,11 +136,15 @@ vs_change(sp, lno, op)
case LINE_DELETE:
if (vs_sm_delete(sp, lno))
return (1);
+ if (sp->lno > lno)
+ --sp->lno;
F_SET(vip, VIP_N_RENUMBER);
break;
case LINE_INSERT:
if (vs_sm_insert(sp, lno))
return (1);
+ if (sp->lno > lno)
+ ++sp->lno;
F_SET(vip, VIP_N_RENUMBER);
break;
case LINE_RESET:
@@ -172,10 +174,7 @@ vs_change(sp, lno, op)
* PUBLIC: int vs_sm_fill __P((SCR *, recno_t, pos_t));
*/
int
-vs_sm_fill(sp, lno, pos)
- SCR *sp;
- recno_t lno;
- pos_t pos;
+vs_sm_fill(SCR *sp, recno_t lno, pos_t pos)
{
SMAP *p, tmp;
size_t cnt;
@@ -225,6 +224,16 @@ vs_sm_fill(sp, lno, pos)
top: HMAP->lno = lno;
HMAP->coff = 0;
HMAP->soff = 1;
+ } else {
+ /*
+ * If number of lines HMAP->lno (top line) spans
+ * changed due to, say reformatting, and now is
+ * fewer than HMAP->soff, reset so the line is
+ * redrawn at the top of the screen.
+ */
+ cnt = vs_screens(sp, HMAP->lno, NULL);
+ if (cnt < HMAP->soff)
+ HMAP->soff = 1;
}
/* If we fail, just punt. */
for (p = HMAP, cnt = sp->t_rows; --cnt; ++p)
@@ -299,9 +308,7 @@ err: HMAP->lno = 1;
* Delete a line out of the SMAP.
*/
static int
-vs_sm_delete(sp, lno)
- SCR *sp;
- recno_t lno;
+vs_sm_delete(SCR *sp, recno_t lno)
{
SMAP *p, *t;
size_t cnt_orig;
@@ -349,9 +356,7 @@ vs_sm_delete(sp, lno)
* Insert a line into the SMAP.
*/
static int
-vs_sm_insert(sp, lno)
- SCR *sp;
- recno_t lno;
+vs_sm_insert(SCR *sp, recno_t lno)
{
SMAP *p, *t;
size_t cnt_orig, cnt, coff;
@@ -405,9 +410,7 @@ vs_sm_insert(sp, lno)
* Reset a line in the SMAP.
*/
static int
-vs_sm_reset(sp, lno)
- SCR *sp;
- recno_t lno;
+vs_sm_reset(SCR *sp, recno_t lno)
{
SMAP *p, *t;
size_t cnt_orig, cnt_new, cnt, diff;
@@ -512,11 +515,7 @@ vs_sm_reset(sp, lno)
* PUBLIC: int vs_sm_scroll __P((SCR *, MARK *, recno_t, scroll_t));
*/
int
-vs_sm_scroll(sp, rp, count, scmd)
- SCR *sp;
- MARK *rp;
- recno_t count;
- scroll_t scmd;
+vs_sm_scroll(SCR *sp, MARK *rp, recno_t count, scroll_t scmd)
{
SMAP *smp;
@@ -573,12 +572,7 @@ vs_sm_scroll(sp, rp, count, scmd)
* Scroll the SMAP up count logical lines.
*/
static int
-vs_sm_up(sp, rp, count, scmd, smp)
- SCR *sp;
- MARK *rp;
- scroll_t scmd;
- recno_t count;
- SMAP *smp;
+vs_sm_up(SCR *sp, MARK *rp, recno_t count, scroll_t scmd, SMAP *smp)
{
int cursor_set, echanged, zset;
SMAP *ssmp, s1, s2;
@@ -754,8 +748,7 @@ vs_sm_up(sp, rp, count, scmd, smp)
* PUBLIC: int vs_sm_1up __P((SCR *));
*/
int
-vs_sm_1up(sp)
- SCR *sp;
+vs_sm_1up(SCR *sp)
{
/*
* Delete the top line of the screen. Shift the screen map
@@ -784,14 +777,19 @@ vs_sm_1up(sp)
* line and other screens back.
*/
static int
-vs_deleteln(sp, cnt)
- SCR *sp;
- int cnt;
+vs_deleteln(SCR *sp, int cnt)
{
GS *gp;
size_t oldy, oldx;
gp = sp->gp;
+
+ /* If the screen is vertically split, we can't scroll it. */
+ if (IS_VSPLIT(sp)) {
+ F_SET(sp, SC_SCR_REDRAW);
+ return (0);
+ }
+
if (IS_ONELINE(sp))
(void)gp->scr_clrtoeol(sp);
else {
@@ -811,12 +809,7 @@ vs_deleteln(sp, cnt)
* Scroll the SMAP down count logical lines.
*/
static int
-vs_sm_down(sp, rp, count, scmd, smp)
- SCR *sp;
- MARK *rp;
- recno_t count;
- SMAP *smp;
- scroll_t scmd;
+vs_sm_down(SCR *sp, MARK *rp, recno_t count, scroll_t scmd, SMAP *smp)
{
SMAP *ssmp, s1, s2;
int cursor_set, ychanged, zset;
@@ -967,8 +960,7 @@ vs_sm_down(sp, rp, count, scmd, smp)
* Erase the small screen area for the scrolling functions.
*/
static int
-vs_sm_erase(sp)
- SCR *sp;
+vs_sm_erase(SCR *sp)
{
GS *gp;
@@ -989,8 +981,7 @@ vs_sm_erase(sp)
* PUBLIC: int vs_sm_1down __P((SCR *));
*/
int
-vs_sm_1down(sp)
- SCR *sp;
+vs_sm_1down(SCR *sp)
{
/*
* Insert a line at the top of the screen. Shift the screen map
@@ -1019,14 +1010,19 @@ vs_sm_1down(sp)
* line and other screens back.
*/
static int
-vs_insertln(sp, cnt)
- SCR *sp;
- int cnt;
+vs_insertln(SCR *sp, int cnt)
{
GS *gp;
size_t oldy, oldx;
gp = sp->gp;
+
+ /* If the screen is vertically split, we can't scroll it. */
+ if (IS_VSPLIT(sp)) {
+ F_SET(sp, SC_SCR_REDRAW);
+ return (0);
+ }
+
if (IS_ONELINE(sp)) {
(void)gp->scr_move(sp, LASTLINE(sp), 0);
(void)gp->scr_clrtoeol(sp);
@@ -1049,9 +1045,7 @@ vs_insertln(sp, cnt)
* PUBLIC: int vs_sm_next __P((SCR *, SMAP *, SMAP *));
*/
int
-vs_sm_next(sp, p, t)
- SCR *sp;
- SMAP *p, *t;
+vs_sm_next(SCR *sp, SMAP *p, SMAP *t)
{
size_t lcnt;
@@ -1079,9 +1073,7 @@ vs_sm_next(sp, p, t)
* PUBLIC: int vs_sm_prev __P((SCR *, SMAP *, SMAP *));
*/
int
-vs_sm_prev(sp, p, t)
- SCR *sp;
- SMAP *p, *t;
+vs_sm_prev(SCR *sp, SMAP *p, SMAP *t)
{
SMAP_FLUSH(t);
if (O_ISSET(sp, O_LEFTRIGHT)) {
@@ -1106,9 +1098,7 @@ vs_sm_prev(sp, p, t)
* PUBLIC: int vs_sm_cursor __P((SCR *, SMAP **));
*/
int
-vs_sm_cursor(sp, smpp)
- SCR *sp;
- SMAP **smpp;
+vs_sm_cursor(SCR *sp, SMAP **smpp)
{
SMAP *p;
@@ -1147,11 +1137,7 @@ vs_sm_cursor(sp, smpp)
* PUBLIC: int vs_sm_position __P((SCR *, MARK *, u_long, pos_t));
*/
int
-vs_sm_position(sp, rp, cnt, pos)
- SCR *sp;
- MARK *rp;
- u_long cnt;
- pos_t pos;
+vs_sm_position(SCR *sp, MARK *rp, u_long cnt, pos_t pos)
{
SMAP *smp;
recno_t last;
@@ -1231,11 +1217,7 @@ eof: msgq(sp, M_BERR,
* PUBLIC: recno_t vs_sm_nlines __P((SCR *, SMAP *, recno_t, size_t));
*/
recno_t
-vs_sm_nlines(sp, from_sp, to_lno, max)
- SCR *sp;
- SMAP *from_sp;
- recno_t to_lno;
- size_t max;
+vs_sm_nlines(SCR *sp, SMAP *from_sp, recno_t to_lno, size_t max)
{
recno_t lno, lcnt;
diff --git a/vi/vs_split.c b/vi/vs_split.c
index d01735490e69..07bc8e50e2b0 100644
--- a/vi/vs_split.c
+++ b/vi/vs_split.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_split.c 10.31 (Berkeley) 10/13/96";
+static const char sccsid[] = "$Id: vs_split.c,v 10.42 2001/06/25 15:19:38 skimo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -27,18 +27,23 @@ static const char sccsid[] = "@(#)vs_split.c 10.31 (Berkeley) 10/13/96";
#include "../common/common.h"
#include "vi.h"
-static SCR *vs_getbg __P((SCR *, char *));
+typedef enum { HORIZ_FOLLOW, HORIZ_PRECEDE, VERT_FOLLOW, VERT_PRECEDE } jdir_t;
+
+static SCR *vs_getbg __P((SCR *, char *));
+static void vs_insert __P((SCR *sp, GS *gp));
+static int vs_join __P((SCR *, SCR **, jdir_t *));
/*
* vs_split --
- * Create a new screen.
+ * Create a new screen, horizontally.
*
* PUBLIC: int vs_split __P((SCR *, SCR *, int));
*/
int
-vs_split(sp, new, ccl)
- SCR *sp, *new;
- int ccl; /* Colon-command line split. */
+vs_split(
+ SCR *sp,
+ SCR *new,
+ int ccl) /* Colon-command line split. */
{
GS *gp;
SMAP *smp;
@@ -58,10 +63,6 @@ vs_split(sp, new, ccl)
/* Wait for any messages in the screen. */
vs_resolve(sp, NULL, 1);
- half = sp->rows / 2;
- if (ccl && half > 6)
- half = 6;
-
/* Get a new screen map. */
CALLOC(sp, _HMAP(new), SMAP *, SIZE_HMAP(sp), sizeof(SMAP));
if (_HMAP(new) == NULL)
@@ -70,6 +71,11 @@ vs_split(sp, new, ccl)
_HMAP(new)->coff = 0;
_HMAP(new)->soff = 1;
+ /* Split the screen in half. */
+ half = sp->rows / 2;
+ if (ccl && half > 6)
+ half = 6;
+
/*
* Small screens: see vs_refresh.c section 6a. Set a flag so
* we know to fix the screen up later.
@@ -77,6 +83,7 @@ vs_split(sp, new, ccl)
issmallscreen = IS_SMALL(sp);
/* The columns in the screen don't change. */
+ new->coff = sp->coff;
new->cols = sp->cols;
/*
@@ -93,24 +100,20 @@ vs_split(sp, new, ccl)
!ccl && (vs_sm_cursor(sp, &smp) ? 0 : (smp - HMAP) + 1) >= half;
if (splitup) { /* Old is bottom half. */
new->rows = sp->rows - half; /* New. */
- new->woff = sp->woff;
+ new->roff = sp->roff;
sp->rows = half; /* Old. */
- sp->woff += new->rows;
- /* Link in before old. */
- CIRCLEQ_INSERT_BEFORE(&gp->dq, sp, new, q);
+ sp->roff += new->rows;
/*
* If the parent is the bottom half of the screen, shift
* the map down to match on-screen text.
*/
- memmove(_HMAP(sp), _HMAP(sp) + new->rows,
+ memcpy(_HMAP(sp), _HMAP(sp) + new->rows,
(sp->t_maxrows - new->rows) * sizeof(SMAP));
} else { /* Old is top half. */
new->rows = half; /* New. */
sp->rows -= half; /* Old. */
- new->woff = sp->woff + sp->rows;
- /* Link in after old. */
- CIRCLEQ_INSERT_AFTER(&gp->dq, sp, new, q);
+ new->roff = sp->roff + sp->rows;
}
/* Adjust maximum text count. */
@@ -168,6 +171,103 @@ vs_split(sp, new, ccl)
if ((new->defscroll = new->t_maxrows / 2) == 0)
new->defscroll = 1;
+ /* Fit the screen into the logical chain. */
+ vs_insert(new, sp->gp);
+
+ /* Tell the display that we're splitting. */
+ (void)gp->scr_split(sp, new);
+
+ /*
+ * Initialize the screen flags:
+ *
+ * If we're in vi mode in one screen, we don't have to reinitialize.
+ * This isn't just a cosmetic fix. The path goes like this:
+ *
+ * return into vi(), SC_SSWITCH set
+ * call vs_refresh() with SC_STATUS set
+ * call vs_resolve to display the status message
+ * call vs_refresh() because the SC_SCR_VI bit isn't set
+ *
+ * Things go downhill at this point.
+ *
+ * Draw the new screen from scratch, and add a status line.
+ */
+ F_SET(new,
+ SC_SCR_REFORMAT | SC_STATUS |
+ F_ISSET(sp, SC_EX | SC_VI | SC_SCR_VI | SC_SCR_EX));
+ return (0);
+}
+
+/*
+ * vs_vsplit --
+ * Create a new screen, vertically.
+ *
+ * PUBLIC: int vs_vsplit __P((SCR *, SCR *));
+ */
+int
+vs_vsplit(SCR *sp, SCR *new)
+{
+ GS *gp;
+ size_t cols;
+
+ gp = sp->gp;
+
+ /* Check to see if it's possible. */
+ if (sp->cols / 2 <= MINIMUM_SCREEN_COLS) {
+ msgq(sp, M_ERR,
+ "288|Screen must be larger than %d columns to split",
+ MINIMUM_SCREEN_COLS * 2);
+ return (1);
+ }
+
+ /* Wait for any messages in the screen. */
+ vs_resolve(sp, NULL, 1);
+
+ /* Get a new screen map. */
+ CALLOC(sp, _HMAP(new), SMAP *, SIZE_HMAP(sp), sizeof(SMAP));
+ if (_HMAP(new) == NULL)
+ return (1);
+ _HMAP(new)->lno = sp->lno;
+ _HMAP(new)->coff = 0;
+ _HMAP(new)->soff = 1;
+
+ /*
+ * Split the screen in half; we have to sacrifice a column to delimit
+ * the screens.
+ *
+ * XXX
+ * We always split to the right... that makes more sense to me, and
+ * I don't want to play the stupid games that I play when splitting
+ * horizontally.
+ *
+ * XXX
+ * We reserve a column for the screen, "knowing" that curses needs
+ * one. This should be worked out with the display interface.
+ */
+ cols = sp->cols / 2;
+ new->cols = sp->cols - cols - 1;
+ sp->cols = cols;
+ new->coff = sp->coff + cols + 1;
+ sp->cno = 0;
+
+ /* Nothing else changes. */
+ new->rows = sp->rows;
+ new->t_rows = sp->t_rows;
+ new->t_maxrows = sp->t_maxrows;
+ new->t_minrows = sp->t_minrows;
+ new->roff = sp->roff;
+ new->defscroll = sp->defscroll;
+ _TMAP(new) = _HMAP(new) + (new->t_rows - 1);
+
+ /* Fit the screen into the logical chain. */
+ vs_insert(new, sp->gp);
+
+ /* Tell the display that we're splitting. */
+ (void)gp->scr_split(sp, new);
+
+ /* Redraw the old screen from scratch. */
+ F_SET(sp, SC_SCR_REFORMAT | SC_STATUS);
+
/*
* Initialize the screen flags:
*
@@ -190,6 +290,43 @@ vs_split(sp, new, ccl)
}
/*
+ * vs_insert --
+ * Insert the new screen into the correct place in the logical
+ * chain.
+ */
+static void
+vs_insert(SCR *sp, GS *gp)
+{
+ SCR *tsp;
+
+ gp = sp->gp;
+
+ /* Move past all screens with lower row numbers. */
+ TAILQ_FOREACH(tsp, gp->dq, q)
+ if (tsp->roff >= sp->roff)
+ break;
+ /*
+ * Move past all screens with the same row number and lower
+ * column numbers.
+ */
+ for (; tsp != NULL; tsp = TAILQ_NEXT(tsp, q))
+ if (tsp->roff != sp->roff || tsp->coff > sp->coff)
+ break;
+
+ /*
+ * If we reached the end, this screen goes there. Otherwise,
+ * put it before or after the screen where we stopped.
+ */
+ if (tsp == NULL) {
+ TAILQ_INSERT_TAIL(gp->dq, sp, q);
+ } else if (tsp->roff < sp->roff ||
+ (tsp->roff == sp->roff && tsp->coff < sp->coff)) {
+ TAILQ_INSERT_AFTER(gp->dq, tsp, sp, q);
+ } else
+ TAILQ_INSERT_BEFORE(tsp, sp, q);
+}
+
+/*
* vs_discard --
* Discard the screen, folding the real-estate into a related screen,
* if one exists, and return that screen.
@@ -197,11 +334,13 @@ vs_split(sp, new, ccl)
* PUBLIC: int vs_discard __P((SCR *, SCR **));
*/
int
-vs_discard(sp, spp)
- SCR *sp, **spp;
+vs_discard(SCR *sp, SCR **spp)
{
- SCR *nsp;
- dir_t dir;
+ GS *gp;
+ SCR *tsp, **lp, *list[100];
+ jdir_t jdir;
+
+ gp = sp->gp;
/*
* Save the old screen's cursor information.
@@ -216,94 +355,285 @@ vs_discard(sp, spp)
F_SET(sp->frp, FR_CURSORSET);
}
- /*
- * Add into a previous screen and then into a subsequent screen, as
- * they're the closest to the current screen. If that doesn't work,
- * there was no screen to join.
- */
- if ((nsp = sp->q.cqe_prev) != (void *)&sp->gp->dq) {
- nsp->rows += sp->rows;
- sp = nsp;
- dir = FORWARD;
- } else if ((nsp = sp->q.cqe_next) != (void *)&sp->gp->dq) {
- nsp->woff = sp->woff;
- nsp->rows += sp->rows;
- sp = nsp;
- dir = BACKWARD;
- } else
- sp = NULL;
+ /* If no other screens to join, we're done. */
+ if (!IS_SPLIT(sp)) {
+ (void)gp->scr_discard(sp, NULL);
- if (spp != NULL)
- *spp = sp;
- if (sp == NULL)
+ if (spp != NULL)
+ *spp = NULL;
return (0);
-
+ }
+
/*
- * Make no effort to clean up the discarded screen's information. If
- * it's not exiting, we'll do the work when the user redisplays it.
- *
- * Small screens: see vs_refresh.c section 6a. Adjust text line info,
- * unless it's a small screen.
+ * Find a set of screens that cover one of the screen's borders.
+ * Check the vertical axis first, for no particular reason.
*
- * Reset the length of the default scroll.
+ * XXX
+ * It's possible (I think?), to create a screen that shares no full
+ * border with any other set of screens, so we can't discard it. We
+ * just complain at the user until they clean it up.
*/
- if (!IS_SMALL(sp))
- sp->t_rows = sp->t_minrows = sp->rows - 1;
- sp->t_maxrows = sp->rows - 1;
- sp->defscroll = sp->t_maxrows / 2;
- *(HMAP + (sp->t_rows - 1)) = *TMAP;
- TMAP = HMAP + (sp->t_rows - 1);
+ if (vs_join(sp, list, &jdir))
+ return (1);
/*
- * Draw the new screen from scratch, and add a status line.
+ * Modify the affected screens. Redraw the modified screen(s) from
+ * scratch, setting a status line. If this is ever a performance
+ * problem we could play games with the map, but I wrote that code
+ * before and it was never clean or easy.
*
- * XXX
- * We could play games with the map, if this were ever to be a
- * performance problem, but I wrote the code a few times and it
- * was never clean or easy.
+ * Don't clean up the discarded screen's information. If the screen
+ * isn't exiting, we'll do the work when the user redisplays it.
*/
- switch (dir) {
- case FORWARD:
- vs_sm_fill(sp, OOBLNO, P_TOP);
+ switch (jdir) {
+ case HORIZ_FOLLOW:
+ case HORIZ_PRECEDE:
+ for (lp = &list[0]; (tsp = *lp) != NULL; ++lp) {
+ /*
+ * Small screens: see vs_refresh.c section 6a. Adjust
+ * text line info, unless it's a small screen.
+ *
+ * Reset the length of the default scroll.
+ *
+ * Reset the map references.
+ */
+ tsp->rows += sp->rows;
+ if (!IS_SMALL(tsp))
+ tsp->t_rows = tsp->t_minrows = tsp->rows - 1;
+ tsp->t_maxrows = tsp->rows - 1;
+
+ tsp->defscroll = tsp->t_maxrows / 2;
+
+ *(_HMAP(tsp) + (tsp->t_rows - 1)) = *_TMAP(tsp);
+ _TMAP(tsp) = _HMAP(tsp) + (tsp->t_rows - 1);
+
+ switch (jdir) {
+ case HORIZ_FOLLOW:
+ tsp->roff = sp->roff;
+ vs_sm_fill(tsp, OOBLNO, P_TOP);
+ break;
+ case HORIZ_PRECEDE:
+ vs_sm_fill(tsp, OOBLNO, P_BOTTOM);
+ break;
+ default:
+ abort();
+ }
+ F_SET(tsp, SC_STATUS);
+ }
break;
- case BACKWARD:
- vs_sm_fill(sp, OOBLNO, P_BOTTOM);
+ case VERT_FOLLOW:
+ case VERT_PRECEDE:
+ for (lp = &list[0]; (tsp = *lp) != NULL; ++lp) {
+ if (jdir == VERT_FOLLOW)
+ tsp->coff = sp->coff;
+ tsp->cols += sp->cols + 1; /* XXX: DIVIDER */
+ vs_sm_fill(tsp, OOBLNO, P_TOP);
+ F_SET(tsp, SC_STATUS);
+ }
break;
default:
abort();
}
- F_SET(sp, SC_STATUS);
+ /* Find the closest screen that changed and move to it. */
+ tsp = list[0];
+ if (spp != NULL)
+ *spp = tsp;
+
+ /* Tell the display that we're discarding a screen. */
+ (void)gp->scr_discard(sp, list);
+
return (0);
}
/*
+ * vs_join --
+ * Find a set of screens that covers a screen's border.
+ */
+static int
+vs_join(SCR *sp, SCR **listp, jdir_t *jdirp)
+{
+ GS *gp;
+ SCR **lp, *tsp;
+ int first;
+ size_t tlen;
+
+ gp = sp->gp;
+
+ /* Check preceding vertical. */
+ for (lp = listp, tlen = sp->rows,
+ tsp = TAILQ_FIRST(gp->dq);
+ tsp != NULL; tsp = TAILQ_NEXT(tsp, q)) {
+ if (sp == tsp)
+ continue;
+ /* Test if precedes the screen vertically. */
+ if (tsp->coff + tsp->cols + 1 != sp->coff)
+ continue;
+ /*
+ * Test if a subset on the vertical axis. If overlaps the
+ * beginning or end, we can't join on this axis at all.
+ */
+ if (tsp->roff > sp->roff + sp->rows)
+ continue;
+ if (tsp->roff < sp->roff) {
+ if (tsp->roff + tsp->rows >= sp->roff)
+ break;
+ continue;
+ }
+ if (tsp->roff + tsp->rows > sp->roff + sp->rows)
+ break;
+#ifdef DEBUG
+ if (tlen < tsp->rows)
+ abort();
+#endif
+ tlen -= tsp->rows;
+ *lp++ = tsp;
+ }
+ if (tlen == 0) {
+ *lp = NULL;
+ *jdirp = VERT_PRECEDE;
+ return (0);
+ }
+
+ /* Check following vertical. */
+ for (lp = listp, tlen = sp->rows,
+ tsp = TAILQ_FIRST(gp->dq);
+ tsp != NULL; tsp = TAILQ_NEXT(tsp, q)) {
+ if (sp == tsp)
+ continue;
+ /* Test if follows the screen vertically. */
+ if (tsp->coff != sp->coff + sp->cols + 1)
+ continue;
+ /*
+ * Test if a subset on the vertical axis. If overlaps the
+ * beginning or end, we can't join on this axis at all.
+ */
+ if (tsp->roff > sp->roff + sp->rows)
+ continue;
+ if (tsp->roff < sp->roff) {
+ if (tsp->roff + tsp->rows >= sp->roff)
+ break;
+ continue;
+ }
+ if (tsp->roff + tsp->rows > sp->roff + sp->rows)
+ break;
+#ifdef DEBUG
+ if (tlen < tsp->rows)
+ abort();
+#endif
+ tlen -= tsp->rows;
+ *lp++ = tsp;
+ }
+ if (tlen == 0) {
+ *lp = NULL;
+ *jdirp = VERT_FOLLOW;
+ return (0);
+ }
+
+ /* Check preceding horizontal. */
+ for (first = 0, lp = listp, tlen = sp->cols,
+ tsp = TAILQ_FIRST(gp->dq);
+ tsp != NULL; tsp = TAILQ_NEXT(tsp, q)) {
+ if (sp == tsp)
+ continue;
+ /* Test if precedes the screen horizontally. */
+ if (tsp->roff + tsp->rows != sp->roff)
+ continue;
+ /*
+ * Test if a subset on the horizontal axis. If overlaps the
+ * beginning or end, we can't join on this axis at all.
+ */
+ if (tsp->coff > sp->coff + sp->cols)
+ continue;
+ if (tsp->coff < sp->coff) {
+ if (tsp->coff + tsp->cols >= sp->coff)
+ break;
+ continue;
+ }
+ if (tsp->coff + tsp->cols > sp->coff + sp->cols)
+ break;
+#ifdef DEBUG
+ if (tlen < tsp->cols)
+ abort();
+#endif
+ tlen -= tsp->cols + first;
+ first = 1;
+ *lp++ = tsp;
+ }
+ if (tlen == 0) {
+ *lp = NULL;
+ *jdirp = HORIZ_PRECEDE;
+ return (0);
+ }
+
+ /* Check following horizontal. */
+ for (first = 0, lp = listp, tlen = sp->cols,
+ tsp = TAILQ_FIRST(gp->dq);
+ tsp != NULL; tsp = TAILQ_NEXT(tsp, q)) {
+ if (sp == tsp)
+ continue;
+ /* Test if precedes the screen horizontally. */
+ if (tsp->roff != sp->roff + sp->rows)
+ continue;
+ /*
+ * Test if a subset on the horizontal axis. If overlaps the
+ * beginning or end, we can't join on this axis at all.
+ */
+ if (tsp->coff > sp->coff + sp->cols)
+ continue;
+ if (tsp->coff < sp->coff) {
+ if (tsp->coff + tsp->cols >= sp->coff)
+ break;
+ continue;
+ }
+ if (tsp->coff + tsp->cols > sp->coff + sp->cols)
+ break;
+#ifdef DEBUG
+ if (tlen < tsp->cols)
+ abort();
+#endif
+ tlen -= tsp->cols + first;
+ first = 1;
+ *lp++ = tsp;
+ }
+ if (tlen == 0) {
+ *lp = NULL;
+ *jdirp = HORIZ_FOLLOW;
+ return (0);
+ }
+ return (1);
+}
+
+/*
* vs_fg --
* Background the current screen, and foreground a new one.
*
* PUBLIC: int vs_fg __P((SCR *, SCR **, CHAR_T *, int));
*/
int
-vs_fg(sp, nspp, name, newscreen)
- SCR *sp, **nspp;
- CHAR_T *name;
- int newscreen;
+vs_fg(SCR *sp, SCR **nspp, CHAR_T *name, int newscreen)
{
GS *gp;
SCR *nsp;
+ char *np;
+ size_t nlen;
gp = sp->gp;
+ if (name)
+ INT2CHAR(sp, name, STRLEN(name) + 1, np, nlen);
+ else
+ np = NULL;
if (newscreen)
/* Get the specified background screen. */
- nsp = vs_getbg(sp, name);
+ nsp = vs_getbg(sp, np);
else
/* Swap screens. */
- if (vs_swap(sp, &nsp, name))
+ if (vs_swap(sp, &nsp, np))
return (1);
if ((*nspp = nsp) == NULL) {
- msgq_str(sp, M_ERR, name,
+ msgq_wstr(sp, M_ERR, name,
name == NULL ?
"223|There are no background screens" :
"224|There's no background screen editing a file named %s");
@@ -312,17 +642,17 @@ vs_fg(sp, nspp, name, newscreen)
if (newscreen) {
/* Remove the new screen from the background queue. */
- CIRCLEQ_REMOVE(&gp->hq, nsp, q);
+ TAILQ_REMOVE(gp->hq, nsp, q);
/* Split the screen; if we fail, hook the screen back in. */
if (vs_split(sp, nsp, 0)) {
- CIRCLEQ_INSERT_TAIL(&gp->hq, nsp, q);
+ TAILQ_INSERT_TAIL(gp->hq, nsp, q);
return (1);
}
} else {
/* Move the old screen to the background queue. */
- CIRCLEQ_REMOVE(&gp->dq, sp, q);
- CIRCLEQ_INSERT_TAIL(&gp->hq, sp, q);
+ TAILQ_REMOVE(gp->dq, sp, q);
+ TAILQ_INSERT_TAIL(gp->hq, sp, q);
}
return (0);
}
@@ -334,8 +664,7 @@ vs_fg(sp, nspp, name, newscreen)
* PUBLIC: int vs_bg __P((SCR *));
*/
int
-vs_bg(sp)
- SCR *sp;
+vs_bg(SCR *sp)
{
GS *gp;
SCR *nsp;
@@ -352,8 +681,8 @@ vs_bg(sp)
}
/* Move the old screen to the background queue. */
- CIRCLEQ_REMOVE(&gp->dq, sp, q);
- CIRCLEQ_INSERT_TAIL(&gp->hq, sp, q);
+ TAILQ_REMOVE(gp->dq, sp, q);
+ TAILQ_INSERT_TAIL(gp->hq, sp, q);
/* Toss the screen map. */
free(_HMAP(sp));
@@ -373,12 +702,10 @@ vs_bg(sp)
* PUBLIC: int vs_swap __P((SCR *, SCR **, char *));
*/
int
-vs_swap(sp, nspp, name)
- SCR *sp, **nspp;
- char *name;
+vs_swap(SCR *sp, SCR **nspp, char *name)
{
GS *gp;
- SCR *nsp;
+ SCR *nsp, *list[2];
gp = sp->gp;
@@ -409,7 +736,7 @@ vs_swap(sp, nspp, name)
/* Initialize screen information. */
nsp->cols = sp->cols;
nsp->rows = sp->rows; /* XXX: Only place in vi that sets rows. */
- nsp->woff = sp->woff;
+ nsp->roff = sp->roff;
/*
* Small screens: see vs_refresh.c, section 6a.
@@ -435,6 +762,7 @@ vs_swap(sp, nspp, name)
_TMAP(nsp) = _HMAP(nsp) + (nsp->t_rows - 1);
/* Fill the map. */
+ nsp->gp = sp->gp;
if (vs_sm_fill(nsp, nsp->lno, P_FILL))
return (1);
@@ -444,8 +772,8 @@ vs_swap(sp, nspp, name)
* the exit will delete the old one, if we're foregrounding, the fg
* code will move the old one to the background queue.
*/
- CIRCLEQ_REMOVE(&gp->hq, nsp, q);
- CIRCLEQ_INSERT_AFTER(&gp->dq, sp, nsp, q);
+ TAILQ_REMOVE(gp->hq, nsp, q);
+ TAILQ_INSERT_AFTER(gp->dq, sp, nsp, q);
/*
* Don't change the screen's cursor information other than to
@@ -455,6 +783,10 @@ vs_swap(sp, nspp, name)
/* Draw the new screen from scratch, and add a status line. */
F_SET(nsp, SC_SCR_REDRAW | SC_STATUS);
+
+ list[0] = nsp; list[1] = NULL;
+ (void)gp->scr_discard(sp, list);
+
return (0);
}
@@ -465,13 +797,10 @@ vs_swap(sp, nspp, name)
* PUBLIC: int vs_resize __P((SCR *, long, adj_t));
*/
int
-vs_resize(sp, count, adj)
- SCR *sp;
- long count;
- adj_t adj;
+vs_resize(SCR *sp, long int count, adj_t adj)
{
GS *gp;
- SCR *g, *s;
+ SCR *g, *s, *prev, *next, *list[3] = {NULL, NULL, NULL};
size_t g_off, s_off;
gp = sp->gp;
@@ -494,6 +823,23 @@ vs_resize(sp, count, adj)
}
}
+ /* Find first overlapping screen */
+ for (next = TAILQ_NEXT(sp, q); next != NULL &&
+ (next->coff >= sp->coff + sp->cols ||
+ next->coff + next->cols <= sp->coff);
+ next = TAILQ_NEXT(next, q));
+ /* See if we can use it */
+ if (next != NULL &&
+ (sp->coff != next->coff || sp->cols != next->cols))
+ next = NULL;
+ for (prev = TAILQ_PREV(sp, _dqh, q); prev != NULL &&
+ (prev->coff >= sp->coff + sp->cols ||
+ prev->coff + prev->cols <= sp->coff);
+ prev = TAILQ_PREV(prev, _dqh, q));
+ if (prev != NULL &&
+ (sp->coff != prev->coff || sp->cols != prev->cols))
+ prev = NULL;
+
g_off = s_off = 0;
if (adj == A_DECREASE) {
if (count < 0)
@@ -501,23 +847,21 @@ vs_resize(sp, count, adj)
s = sp;
if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)
goto toosmall;
- if ((g = sp->q.cqe_prev) == (void *)&gp->dq) {
- if ((g = sp->q.cqe_next) == (void *)&gp->dq)
+ if ((g = prev) == NULL) {
+ if ((g = next) == NULL)
goto toobig;
g_off = -count;
} else
s_off = count;
} else {
g = sp;
- if ((s = sp->q.cqe_next) != (void *)&gp->dq)
- if (s->t_maxrows < MINIMUM_SCREEN_ROWS + count)
- s = NULL;
- else
+ if ((s = next) != NULL &&
+ s->t_maxrows >= MINIMUM_SCREEN_ROWS + count)
s_off = count;
else
s = NULL;
if (s == NULL) {
- if ((s = sp->q.cqe_prev) == (void *)&gp->dq) {
+ if ((s = prev) == NULL) {
toobig: msgq(sp, M_BERR, adj == A_DECREASE ?
"227|The screen cannot shrink" :
"228|The screen cannot grow");
@@ -539,9 +883,9 @@ toosmall: msgq(sp, M_BERR,
* to make it worthwhile.
*/
s->rows += -count;
- s->woff += s_off;
+ s->roff += s_off;
g->rows += count;
- g->woff += g_off;
+ g->roff += g_off;
g->t_rows += count;
if (g->t_minrows == g->t_maxrows)
@@ -557,6 +901,10 @@ toosmall: msgq(sp, M_BERR,
_TMAP(s) -= count;
F_SET(s, SC_SCR_REFORMAT | SC_STATUS);
+ /* XXXX */
+ list[0] = g; list[1] = s;
+ gp->scr_discard(0, list);
+
return (0);
}
@@ -566,9 +914,7 @@ toosmall: msgq(sp, M_BERR,
* background screen.
*/
static SCR *
-vs_getbg(sp, name)
- SCR *sp;
- char *name;
+vs_getbg(SCR *sp, char *name)
{
GS *gp;
SCR *nsp;
@@ -577,22 +923,18 @@ vs_getbg(sp, name)
gp = sp->gp;
/* If name is NULL, return the first background screen on the list. */
- if (name == NULL) {
- nsp = gp->hq.cqh_first;
- return (nsp == (void *)&gp->hq ? NULL : nsp);
- }
+ if (name == NULL)
+ return (TAILQ_FIRST(gp->hq));
/* Search for a full match. */
- for (nsp = gp->hq.cqh_first;
- nsp != (void *)&gp->hq; nsp = nsp->q.cqe_next)
+ TAILQ_FOREACH(nsp, gp->hq, q)
if (!strcmp(nsp->frp->name, name))
break;
- if (nsp != (void *)&gp->hq)
+ if (nsp != NULL)
return (nsp);
/* Search for a last-component match. */
- for (nsp = gp->hq.cqh_first;
- nsp != (void *)&gp->hq; nsp = nsp->q.cqe_next) {
+ TAILQ_FOREACH(nsp, gp->hq, q) {
if ((p = strrchr(nsp->frp->name, '/')) == NULL)
p = nsp->frp->name;
else
@@ -600,7 +942,7 @@ vs_getbg(sp, name)
if (!strcmp(p, name))
break;
}
- if (nsp != (void *)&gp->hq)
+ if (nsp != NULL)
return (nsp);
return (NULL);