summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-02-22 08:56:13 +0000
committerBram Moolenaar <Bram@vim.org>2005-02-22 08:56:13 +0000
commit5313dcb75ac76501f23d21ac94efdbeeabc860bc (patch)
treeb6c5ac114addb67fdee375a0c1baf75e609d4dff
parent26a60b45245080771bc2452b2634cb1f5acd60ed (diff)
updated for version 7.0051v7.0051
-rw-r--r--runtime/doc/syntax.txt10
-rw-r--r--runtime/doc/tagsrch.txt6
-rw-r--r--runtime/doc/todo.txt95
-rw-r--r--runtime/doc/various.txt45
-rw-r--r--runtime/doc/version7.txt61
-rw-r--r--src/eval.c542
-rw-r--r--src/ex_cmds.c355
-rw-r--r--src/ex_cmds.h39
-rw-r--r--src/main.c32
-rw-r--r--src/memline.c31
-rw-r--r--src/misc1.c8
-rw-r--r--src/po/ga.po7170
-rw-r--r--src/proto/ex_cmds.pro4
-rw-r--r--src/testdir/Makefile11
-rw-r--r--src/ui.c4
15 files changed, 8066 insertions, 347 deletions
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index c421a22982..bc7bcae45c 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1,4 +1,4 @@
-*syntax.txt* For Vim version 7.0aa. Last change: 2005 Jan 26
+*syntax.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -184,6 +184,11 @@ add a few items or change the highlighting, follow these steps:
That's it. The next time you edit a C file the Comment color will be
different. You don't even have to restart Vim.
+If you have multiple files, you can use the filetype as the directory name.
+All the "*.vim" files in this directory will be used, for example:
+ ~/.vim/after/syntax/c/one.vim
+ ~/.vim/after/syntax/c/two.vim
+
REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
@@ -2577,7 +2582,7 @@ DEFINING KEYWORDS *:syn-keyword*
:syntax keyword Type contained int long char
:syntax keyword Type int long contained char
:syntax keyword Type int long char contained
-<
+< *E747*
When you have a keyword with an optional tail, like Ex commands in
Vim, you can put the optional characters inside [], to define all the
variations at once: >
@@ -3504,6 +3509,7 @@ faster.]
Without a "groupthere" argument. Define a region or match that is
skipped while searching for a sync point.
+ *syn-sync-linecont*
:syntax sync linecont {pattern}
When {pattern} matches in a line, it is considered to continue in
diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt
index 326ec3edcb..467a9a1750 100644
--- a/runtime/doc/tagsrch.txt
+++ b/runtime/doc/tagsrch.txt
@@ -1,4 +1,4 @@
-*tagsrch.txt* For Vim version 7.0aa. Last change: 2005 Jan 02
+*tagsrch.txt* For Vim version 7.0aa. Last change: 2005 Feb 14
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -744,11 +744,13 @@ CTRL-W i Open a new window, with the cursor on the first line
]D like "[D", but start at the current cursor position.
{not in Vi}
- *:dl* *:dlist*
+ *:dli* *:dlist*
:[range]dl[ist][!] [/]string[/]
Like "[D" and "]D", but search in [range] lines
(default: whole file).
See |:search-args| for [/] and [!]. {not in Vi}
+ Note that ":dl" works like ":delete" with the "l"
+ flag.
*[_CTRL-D*
[ CTRL-D Jump to the first macro definition that contains the
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 85f2de6625..023194289b 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt* For Vim version 7.0aa. Last change: 2005 Feb 12
+*todo.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -30,53 +30,38 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
*known-bugs*
-------------------- Known bugs and current work -----------------------
-"norm! gQ" hangs. Fixes in ex_getln.c and ex_docmd.c also in Vim 6.3?
+Mac unicode patch (Da Woon Jung):
+- default font is ugly
+- typing doesn't work
+- selecting proportional font breaks display
autoload:
-- Rename directory to from "autoload" to "library"?
-- Also autoload when reading a variable with a long:name that doesn't exist.
-- Example using short script with user command that triggers loading script
- with functionality.
-- Remark about one script depending on another, recursively.
-- Catch recursive autoloading.
-- Add note in docs about HelpExtractor wrapper script. Think about a good way
- that the user doesn't need to run ":helptags" manually.
-
-POSIX compliance:
-- vi test 310 fails; exit code non-zero when any error occurred?
-- vi test 33 fails for unknown reasons
-- ex test 24 fails because test is wrong?
-- ex test 29 fails because exit value is always 0.
-- ex tests 47, 48, 49 fail because .exrc file isn't read in silent mode and
- $EXINIT isn't used.
-- ex test 57 fails, need to look into this.
-- check ex test output
-- report use of $LINES and $COLUMNS to austin maillist.
-
-Make list of user functions a hashtable.
-
-Docs for using "syntax/{filetype}/*.vim" syntax files.
-
-Include Mac unicode patch (Da Woon Jung).
-
-New Motif toolbar button from Marcin Dalecki:
-- When the mouse pointer is over an Agide button the red becomes black.
- Something with the way colors are specified in the .xpm file.
-- The pixmap is two pixels smaller than it should be. The gap is filled
- with grey instead of the current toolbar background color.
+- Add docs in user manual: one for using one script and FuncUndefined and one
+ for using autoload with two scripts.
+- Add a Vim script in $VIMRUNTIME/tools that takes a file with a list of
+ script names and a help file and produces a script that can be sourced to
+ install the scripts in the user's directories.
+ Use findfile(), so that only file names need to be given:
+ script plugin/myscript.vim
+ script autoload/mylib.vim
+ script autoload/yourlib.vim
+ helpfile doc/myscript.txt
+ For the "helpfile" item ":helptags" is run.
Awaiting response:
- Patch for mch_FullName() also in Vim 6.3? os_mswin.c
- Win32: tearoff menu window should have a scrollbar when it's taller than
the screen.
-Patch from Yegappan Lakshmanan for redirecting of Ex commands (Feb 9 10:58):
-Look into how lval struct is kept for a long time.
- :redir => variable
- :redir =>> variable (append)
-
Improvements for Python indent script: Peter Wilson.
+Win32: when 'encoding' is "utf-8" getenv() should convert from the active
+codepage to utf-8, putenv() the other way around. Or use _wgetenv() (but that
+duplicates the environment).
+
+Russian helpfile doesn't show up correctly when 'encoding' is koi8-r.
+(Vassily Ragosin 2005 Feb 16)
+
PLANNED FOR VERSION 7.0:
@@ -165,6 +150,7 @@ PLANNED FOR VERSION 7.0:
- Add DEBUGGER INTERFACE. Implementation for gdb by Xavier de Gaye,
assisted by Mikolaj Machowski. Should work like an IDE. Try to keep it
generic. Also found here: http://skawina.eu.org/mikolaj/vimgdb
+ And the idevim plugin/script.
To be able to start the debugger from inside Vim: For GUI run a program
with a netbeans connection; for console: start a program that splits the
terminal, runs the debugger in one window and reconnect Vim I/O to the
@@ -248,6 +234,10 @@ Also place vimtutor.bat in %windir%?
Add gui_mch_browsedir() for Motif, KDE and Mac OS/X.
+7 Add a ":cstring" command. Works like ":cfile" but reads from a string
+ variable. Also accept a list variable? Patch from Yegappan Lakshmanan.
+ 2005 Feb 17 Now it's ":cexpr".
+
HTML indenting can be slow, find out why. Any way to do some kind of
profiling for Vim script? At least add a function to get the current time in
usec. reltime([start, [end]])
@@ -370,7 +360,6 @@ quote. (Nieko Maatjes, 2005 Jan 4)
Vi incompatibility:
9 In Ex mode, "u" undoes all changes, not just the last one. (John Cowan)
8 In Ex mode, an empty file doesn't have a first line, "1p" should fail.
-8 In Ex mode, "1,3" should print three lines.
8 With undo/redo only marks in the changed lines should be changed. Other
marks should be kept. Vi keeps each mark at the same text, even when it
is deleted or restored. (Webb)
@@ -554,6 +543,11 @@ Win32 GUI known bugs:
Athena and Motif:
+6 New Motif toolbar button from Marcin Dalecki:
+ - When the mouse pointer is over an Agide button the red becomes black.
+ Something with the way colors are specified in the .xpm file.
+ - The pixmap is two pixels smaller than it should be. The gap is filled
+ with grey instead of the current toolbar background color.
9 Can configure be changed to disable netbeans if the Xpm library is
required and it's missing?
8 When using the resource "Vim*borderwidth 2" the widgets are positioned
@@ -632,6 +626,14 @@ GUI:
use that code? Or use console dialog.
8 When selecting a font with the font dialog and the font is invalid, the
error message disappears too quick.
+7 More features in the find/replace dialog:
+ - regexp on/off
+ - search in selection/buffer/all buffers/directory
+ when all buffers/directory is used:
+ - filter for file name
+ when directory is used:
+ - subdirectory on/off
+ - top directory browser
8 gui_check_colors() is not called at the right moment. Do it much later,
to avoid problems.
8 gui_update_cursor() is called for a cursor shape change, even when there
@@ -1594,7 +1596,6 @@ Built-in script language:
Return a list instead.
sprintf(format, arg, ..) How to prevent a crash???
attributes() return file protection flags "drwxrwxrwx"
- mkdir(dir) Create directory
copy(from, to) Copy a file
perl(cmd) call Perl and return string
shorten(fname) shorten a file name, like home_replace()
@@ -2238,13 +2239,10 @@ Command line completion:
them with the optional part inside [].
7 Completion of ":map x ": fill in the current mapping, so that it can be
edited. (Sven Guckes)
-7 Add completion for when entering an expression after CTRL-R= and "=.
- (Servatius Brandt)
- For 'wildmenu': Simplify "../bar" when possible.
- When using <Up> in wildmenu mode for a submenu, should go back to the
current menu, not the first one. E.g., ":emenu File.Save<Up>".
8 For ":find" and ":sfind" expand files found in 'path'.
-8 Add cmdline completion for the ":debug" command.
8 When using backtick expansion, the external command may write a greeting
message. Add an option or commands to remove lines that match a regexp?
7 When listing matches of files, display the common path separately from the
@@ -2260,7 +2258,6 @@ Command line completion:
- Add 'wildlongest' option: Key to use to find longest common match for
command line completion (default CTRL-L), like 'wildchar'. (Cregut)
Also: when there are several matches, show them line a CTRL-D.
-- Add completion for Environment variables: ":echo $SH<Tab>" -> "$SHELL".
Command line history:
@@ -2441,6 +2438,10 @@ Text objects:
8 Add test script for text object commands "aw", "iW", etc.
8 Add text object for part of a CamelHumedWord and under_scored_word.
(Scott Graham) "ac" and "au"?
+8 Add a text object for any kind of quoting, also with multi-byte
+ characters. Option to specify what quotes are recognized (default: all)
+ use "aq" and "iq".
+8 Add text object for any kind of parens, also multi-byte ones.
7 Add text object for current search pattern: "a/" and "i/". Makes it
possible to turn text highlighted for 'hlsearch' into a Visual area.
8 Add "gp" and "gP" commands: insert text and make sure there is a single
@@ -3092,8 +3093,6 @@ Various improvements:
Govindachar)
6 In the quickfix window statusline add the command used to get the list of
errors, e.g. ":make foo", ":grep something *.c".
-7 Add a ":cstring" command. Works like ":cfile" but reads from a string
- variable. Also accept a list variable?
6 Python interface: add vim.message() function. (Michal Vitecek, 2002 Nov 5)
7 Support using ":vert" with User commands. Add expandable items <vert>.
Do the same for ":browse" and ":confirm"?
@@ -3230,6 +3229,7 @@ Various improvements:
regexp which triggers auto-formatting (for one line).
":set autoformat=\\s$".
- Be able to redefine where a sentence stops. Use a regexp pattern?
+- Support multi-byte characters for sentences. Example from Ben Peterson.
7 Add command "g)" to go to the end of a sentence, "g(" to go back to the
end of a sentence. (Servatius Brandt)
- Be able to redefine where a paragraph starts. For "[[" where the '{' is
@@ -3241,7 +3241,6 @@ Various improvements:
8 findmatchlimit() should be able to skip comments. Solves problem of
matching the '{' in /* if (foo) { */ (Fiveash)
- Add more redirecting of Ex commands:
- :redir @r> register (append)
:redir #> bufname
:redir #>> bufname (append)
- Give error message when starting :redir: twice or using END when no
@@ -3402,8 +3401,6 @@ Various improvements:
- Implement 'redraw' option.
- Add special code to 'sections' option to define something else but '{' or
'}' as the start of a section (e.g. one shiftwidth to the right).
-- Use pipes for filtering on Unix. Requires using fork() to be able to read
- and write at the same time, or some select() mechanism.
7 Allow using Vim in a pipe: "ls | vim -u xxx.vim - | yyy". Only needs
implementing ":w" to stdout in the buffer that was read from stdin.
8 Allow opening an unnamed buffer with ":e !cmd" and ":sp !cmd". Vile can
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index b9408025a1..31aa8af34d 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -1,4 +1,4 @@
-*various.txt* For Vim version 7.0aa. Last change: 2005 Feb 11
+*various.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -66,33 +66,39 @@ g8 Print the hex values of the bytes used in the
{not in Vi}
*:p* *:pr* *:print*
-:[range]p[rint] Print [range] lines (default current line).
+:[range]p[rint] [flags]
+ Print [range] lines (default current line).
Note: If you are looking for a way to print your text
- file, you need an external program for that. In the
- GUI you can use the File.Print menu entry.
- (For printing on paper see |:hardcopy|)
+ on paper see |:hardcopy|. In the GUI you can use the
+ File.Print menu entry.
+ See |ex-flags| for [flags].
-:[range]p[rint] {count}
+:[range]p[rint] {count} [flags]
Print {count} lines, starting with [range] (default
current line |cmdline-ranges|).
+ See |ex-flags| for [flags].
*:P* *:Print*
-:[range]P[rint] [count]
+:[range]P[rint] [count] [flags]
Just as ":print". Was apparently added to Vi for
people that keep the shift key pressed too long...
+ See |ex-flags| for [flags].
*:l* *:list*
-:[range]l[ist] [count]
+:[range]l[ist] [count] [flags]
Same as :print, but display unprintable characters
- with '^'.
+ with '^' and put $ after the line.
+ See |ex-flags| for [flags].
*:nu* *:number*
-:[range]nu[mber] [count]
+:[range]nu[mber] [count] [flags]
Same as :print, but precede each line with its line
number. (See also 'highlight' option).
+ See |ex-flags| for [flags].
*:#*
-:[range]# [count] synonym for :number.
+:[range]# [count] [flags]
+ synonym for :number.
*:z* *E144*
:{range}z[+-^.=]{count} Display several lines of text surrounding the line
@@ -123,11 +129,13 @@ g8 Print the hex values of the bytes used in the
{not in all versions of Vi, not with these arguments}
*:=*
-:= Print the last line number.
+:= [flags] Print the last line number.
+ See |ex-flags| for [flags].
-:{range}= Prints the last line number in {range}. For example,
+:{range}= [flags] Prints the last line number in {range}. For example,
this prints the current line number: >
:.=
+< See |ex-flags| for [flags].
:norm[al][!] {commands} *:norm* *:normal*
Execute Normal mode commands {commands}. This makes
@@ -397,6 +405,17 @@ N *+X11* Unix only: can restore window title |X11|
:redi[r] @" Redirect messages to the unnamed register. {not in Vi}
:redi[r] @"> Append messages to the unnamed register. {not in Vi}
+:redi[r] => {var} Redirect messages to a variable. If the variable
+ doesn't exist, then it is created. If the variable
+ exists, then it is initialized to an empty string.
+ Only string variables can be used. After the
+ redirection starts, if the variable is removed or
+ locked or the variable type is changed, then further
+ command output messages will cause errors. {not in Vi}
+
+:redi[r] =>> {var} Append messages to an existing variable. Only string
+ variables can be used. {not in Vi}
+
:redi[r] END End redirecting messages. {not in Vi}
*:sil* *:silent*
diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt
index 203204e9fb..38133641f8 100644
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt* For Vim version 7.0aa. Last change: 2005 Feb 11
+*version7.txt* For Vim version 7.0aa. Last change: 2005 Feb 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -184,7 +184,28 @@ Items that were fixed for both Vi and POSIX compatibilty:
- Allow "-c{command}" argument, no space between "-c" and {command}.
- When writing a file with ":w!" don't reset 'readonly' when 'Z' is present in
'cpoptions'.
-
+- Allow 'l' and '#' flags for ":list", ":print" and ":number".
+- Added the '.' flag to 'cpoptions': ":cd" fails when the buffer is modified.
+- In Ex mode with an empty buffer ":read file" doesn't keep an empty line
+ above or below the new lines.
+- Remove a backslash before a NL for the ":global" command.
+- When ":append", ":insert" or ":change" is used with ":global", get the
+ inserted lines from the command. Can use backslash-NL to separate lines.
+- Can use ":global /pat/ visual" to execute Normal mode commands at each
+ matched line. Use "Q" to continue and go to the next line.
+- The |:open| command has been partially implemented. It stops Ex mode, but
+ redraws the whole screen, not just one line as open mode is supposed to do.
+- Support using a pipe to read the output from and write input to an external
+ command. Added the 'shelltemp' option and has("filterpipe").
+- In ex silent mode the ":set" command output is displayed.
+- The ":@@" and ":**" give an error message when no register was used before.
+- The search pattern "[]-`]" matches ']', '^', '_' and '`'.
+- Autoindent for ":insert" is using the line below the insert.
+- Autoindent for ":change" is using the first changed line.
+- Editing Ex command lines is not done in cooked mode, because CTRL-D and
+ CTRL-T cannot be handled then.
+- In Ex mode, "1,3" prints three lines.
+- Implemented the 'prompt' option.
Various new items *new-items-7*
@@ -273,6 +294,7 @@ New functions: ~
|matchlist()| list with match and submatches of a pattern in a string
|max()| maximum value in a List or Dictionary
|min()| minimum value in a List or Dictionary
+|mkdir()| create a directory
|readfile()| read a file into a list of lines
|remove()| remove one or more items from a List or Dictionary
|repeat()| Repeat "expr" "count" times. (Christophe Poucet)
@@ -312,6 +334,13 @@ New items in search patterns: ~
|/\%U| \%U1234abcd search for character with 8 pos. hex number
|/\]| [\U1234abcd] idem, in a colletion
(The above partly by Ciaran McCreesh)
+|/[=| [[=a=]] an equivalence class (only for latin1 characters)
+|/[.| [[.a.]] a collation element (only works with single char)
+
+Nesting |/multi| items no longer is an error when an empty match is possible.
+
+It is now possible to use \{0}, it matches the preceding atom zero times. Not
+useful, just for compatibility.
New Syntax/Indent/FTplugin files: ~
@@ -336,6 +365,8 @@ New message translations: ~
The Ukranian messages are now also available in cp1251.
+Irish message translations. (Kevin Patrick Scannell)
+
Others: ~
@@ -346,6 +377,8 @@ Also fixes the problem that setting 'clipboard' to "unnamed" breaks using
Mac: GUI font selector. (Peter "Rain Dog" Cucka)
+Mac: support for multi-byte characters. (Da Woon Jung)
+
GUI font selector for Motif. (Marcin Dalecki)
Nicer toolbar buttons for Motif. (Marcin Dalecki)
@@ -462,7 +495,10 @@ When a register is empty it is not stored in the viminfo file.
Removed the tcltags script, it's obsolete.
":redir @*>" and ":redir @+>" append to the clipboard. Better check for
-invalid characters after the register name.
+invalid characters after the register name. |:redir|
+
+":redir => variable" and ":redir =>> variable" write or append to a variable.
+(Yegappan Lakshmanan) |:redir|
":let g:" lists global variables.
":let b:" lists buffer-local variables.
@@ -475,6 +511,15 @@ searching. (Yegappan Lakshmanan)
g CTRL-G also shows the number of characters if it differs from the number of
bytes.
+Completion for ":debug" and entering an expression for the '=' register. Skip
+":" between range and command name. (Peter winters)
+
+CTRL-Q in Insert mode now works like CTRL-V by default. Previously it was
+ignored.
+
+When "beep" is included in 'debug' a function or script that causes a beep
+will result in a message with the source of the error.
+
==============================================================================
COMPILE TIME CHANGES *compile-changes-7*
@@ -489,6 +534,9 @@ Mac: Made it possible to compile with Motif, Athena or GTK without tricks and
still being able to use the MacRoman conversion. Added the os_mac_conv.c
file.
+When running the tests and one of them fails to produce "test.out" the
+following tests are still executed. This helps when running out of memory.
+
==============================================================================
BUG FIXES *bug-fixes-7*
@@ -813,4 +861,11 @@ When reading commands from a file and stdout goes to a terminal, would still
request the xterm version. Vim can't read it, thus the output went to the
shell and caused trouble there.
+When redirecting to a register with an invalid name the redirection would
+still be done (after an error message). Now reset "redir_reg". (Yegappan
+Lakshmanan)
+
+It was not possible to use a NL after a backslash in Ex mode. This is
+sometimes used to feed multiple lines to a shell command.
+
vim:tw=78:ts=8:ft=help:norl:
diff --git a/src/eval.c b/src/eval.c
index c6ec0da0e1..1aa4dc307c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -148,17 +148,17 @@ typedef struct ufunc ufunc_T;
struct ufunc
{
- ufunc_T *next; /* next function in list */
- char_u *name; /* name of function; can start with <SNR>123_
- (<SNR> is K_SPECIAL KS_EXTRA KE_SNR) */
- int varargs; /* variable nr of arguments */
- int flags;
- int calls; /* nr of active calls */
- garray_T args; /* arguments */
- garray_T lines; /* function lines */
- scid_T script_ID; /* ID of script where function was defined,
+ int uf_varargs; /* variable nr of arguments */
+ int uf_flags;
+ int uf_calls; /* nr of active calls */
+ garray_T uf_args; /* arguments */
+ garray_T uf_lines; /* function lines */
+ scid_T uf_script_ID; /* ID of script where function was defined,
used for s: variables */
- int refcount; /* for numbered function: reference count */
+ int uf_refcount; /* for numbered function: reference count */
+ char_u uf_name[1]; /* name of function (actually longer); can
+ start with <SNR>123_ (<SNR> is K_SPECIAL
+ KS_EXTRA KE_SNR) */
};
/* function flags */
@@ -167,13 +167,18 @@ struct ufunc
#define FC_DICT 4 /* Dict function, uses "self" */
/*
- * All user-defined functions are found in the forward-linked function list.
- * The first function is pointed at by firstfunc.
+ * All user-defined functions are found in this hash table.
*/
-ufunc_T *firstfunc = NULL;
+hashtab_T func_hashtab;
+
+/* From user function to hashitem and back. */
+static ufunc_T dumuf;
+#define UF2HIKEY(fp) ((fp)->uf_name)
+#define HIKEY2UF(p) ((ufunc_T *)(p - (dumuf.uf_name - (char_u *)&dumuf)))
+#define HI2UF(hi) HIKEY2UF((hi)->hi_key)
-#define FUNCARG(fp, j) ((char_u **)(fp->args.ga_data))[j]
-#define FUNCLINE(fp, j) ((char_u **)(fp->lines.ga_data))[j]
+#define FUNCARG(fp, j) ((char_u **)(fp->uf_args.ga_data))[j]
+#define FUNCLINE(fp, j) ((char_u **)(fp->uf_lines.ga_data))[j]
#define MAX_FUNC_ARGS 20 /* maximum number of function arguments */
#define VAR_SHORT_LEN 20 /* short variable name length */
@@ -475,6 +480,9 @@ static void f_matchlist __ARGS((typval_T *argvars, typval_T *rettv));
static void f_matchstr __ARGS((typval_T *argvars, typval_T *rettv));
static void f_max __ARGS((typval_T *argvars, typval_T *rettv));
static void f_min __ARGS((typval_T *argvars, typval_T *rettv));
+#ifdef vim_mkdir
+static void f_mkdir __ARGS((typval_T *argvars, typval_T *rettv));
+#endif
static void f_mode __ARGS((typval_T *argvars, typval_T *rettv));
static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv));
static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv));
@@ -554,7 +562,7 @@ static linenr_T get_tv_lnum __ARGS((typval_T *argvars));
static char_u *get_tv_string __ARGS((typval_T *varp));
static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf));
static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp));
-static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, char_u *varname));
+static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, char_u *varname, int writing));
static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
@@ -574,7 +582,8 @@ static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
static ufunc_T *find_func __ARGS((char_u *name));
static int function_exists __ARGS((char_u *name));
static int builtin_function __ARGS((char_u *name));
-static int func_autoload __ARGS((char_u *name));
+static int script_autoload __ARGS((char_u *name));
+static char_u *autoload_name __ARGS((char_u *name));
static void func_free __ARGS((ufunc_T *fp));
static void func_unref __ARGS((char_u *name));
static void func_ref __ARGS((char_u *name));
@@ -605,6 +614,7 @@ static void ex_unletlock __ARGS((exarg_T *eap, char_u *argstart, int deep));
static int do_unlet_var __ARGS((lval_T *lp, char_u *name_end, int forceit));
static int do_lock_var __ARGS((lval_T *lp, char_u *name_end, int deep, int lock));
static void item_lock __ARGS((typval_T *tv, int deep, int lock));
+static int tv_islocked __ARGS((typval_T *tv));
/*
* Initialize the global and v: variables.
@@ -618,6 +628,7 @@ eval_init()
init_var_dict(&globvardict, &globvars_var);
init_var_dict(&vimvardict, &vimvars_var);
hash_init(&compat_hashtab);
+ hash_init(&func_hashtab);
for (i = 0; i < VV_LEN; ++i)
{
@@ -646,7 +657,7 @@ eval_init()
func_name(cookie)
void *cookie;
{
- return ((funccall_T *)cookie)->func->name;
+ return ((funccall_T *)cookie)->func->uf_name;
}
/*
@@ -716,6 +727,136 @@ set_internal_string_var(name, value)
}
}
+static lval_T *redir_lval = NULL;
+static char_u *redir_endp = NULL;
+static char_u *redir_varname = NULL;
+
+/*
+ * Start recording command output to a variable
+ * Returns OK if successfully completed the setup. FAIL otherwise.
+ */
+ int
+var_redir_start(name, append)
+ char_u *name;
+ int append; /* append to an existing variable */
+{
+ int save_emsg;
+ int err;
+ typval_T tv;
+
+ /* Make sure a valid variable name is specified */
+ if (!eval_isnamec(*name) || VIM_ISDIGIT(*name))
+ {
+ EMSG(_(e_invarg));
+ return FAIL;
+ }
+
+ redir_varname = vim_strsave(name);
+ if (redir_varname == NULL)
+ return FAIL;
+
+ redir_lval = (lval_T *)alloc_clear((unsigned)sizeof(lval_T));
+ if (redir_lval == NULL)
+ {
+ var_redir_stop();
+ return FAIL;
+ }
+
+ /* Parse the variable name (can be a dict or list entry). */
+ redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE);
+ if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != NUL)
+ {
+ if (redir_endp != NULL && *redir_endp != NUL)
+ /* Trailing characters are present after the variable name */
+ EMSG(_(e_trailing));
+ else
+ EMSG(_(e_invarg));
+ var_redir_stop();
+ return FAIL;
+ }
+
+ /* check if we can write to the variable: set it to or append an empty
+ * string */
+ save_emsg = did_emsg;
+ did_emsg = FALSE;
+ tv.v_type = VAR_STRING;
+ tv.vval.v_string = (char_u *)"";
+ if (append)
+ set_var_lval(redir_lval, redir_endp, &tv, TRUE, (char_u *)".");
+ else
+ set_var_lval(redir_lval, redir_endp, &tv, TRUE, (char_u *)"=");
+ err = did_emsg;
+ did_emsg += save_emsg;
+ if (err)
+ {
+ var_redir_stop();
+ return FAIL;
+ }
+ if (redir_lval->ll_newkey != NULL)
+ {
+ /* Dictionary item was created, don't do it again. */
+ vim_free(redir_lval->ll_newkey);
+ redir_lval->ll_newkey = NULL;
+ }
+
+ return OK;
+}
+
+/*
+ * Append "value[len]" to the variable set by var_redir_start().
+ */
+ void
+var_redir_str(value, len)
+ char_u *value;
+ int len;
+{
+ char_u *val;
+ typval_T tv;
+ int save_emsg;
+ int err;
+
+ if (redir_lval == NULL)
+ return;
+
+ if (len == -1)
+ /* Append the entire string */
+ val = vim_strsave(value);
+ else
+ /* Append only the specified number of characters */
+ val = vim_strnsave(value, len);
+ if (val == NULL)
+ return;
+
+ tv.v_type = VAR_STRING;
+ tv.vval.v_string = val;
+
+ save_emsg = did_emsg;
+ did_emsg = FALSE;
+ set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
+ err = did_emsg;
+ did_emsg += save_emsg;
+ if (err)
+ var_redir_stop();
+
+ vim_free(tv.vval.v_string);
+}
+
+/*
+ * Stop redirecting command output to a variable.
+ */
+ void
+var_redir_stop()
+{
+ if (redir_lval != NULL)
+ {
+ clear_lval(redir_lval);
+ vim_free(redir_lval);
+ redir_lval = NULL;
+ }
+ vim_free(redir_varname);
+ redir_varname = NULL;
+}
+
# if defined(FEAT_MBYTE) || defined(PROTO)
int
eval_charconvert(enc_from, enc_to, fname_from, fname_to)
@@ -5866,12 +6007,15 @@ static struct fst
{"matchstr", 2, 4, f_matchstr},
{"max", 1, 1, f_max},
{"min", 1, 1, f_min},
+#ifdef vim_mkdir
+ {"mkdir", 1, 3, f_mkdir},
+#endif
{"mode", 0, 0, f_mode},
{"nextnonblank", 1, 1, f_nextnonblank},
{"nr2char", 1, 1, f_nr2char},
{"prevnonblank", 1, 1, f_prevnonblank},
{"range", 1, 3, f_range},
- {"readfile", 1, 2, f_readfile},
+ {"readfile", 1, 3, f_readfile},
{"remote_expr", 2, 3, f_remote_expr},
{"remote_foreground", 1, 1, f_remote_foreground},
{"remote_peek", 1, 2, f_remote_peek},
@@ -6218,7 +6362,7 @@ call_func(name, len, rettv, argcount, argvars, firstline, lastline,
}
#endif
/* Try loading a package. */
- if (fp == NULL && func_autoload(fname) && !aborting())
+ if (fp == NULL && script_autoload(fname) && !aborting())
{
/* loaded a package, search for the function again */
fp = find_func(fname);
@@ -6226,13 +6370,13 @@ call_func(name, len, rettv, argcount, argvars, firstline, lastline,
if (fp != NULL)
{
- if (fp->flags & FC_RANGE)
+ if (fp->uf_flags & FC_RANGE)
*doesrange = TRUE;
- if (argcount < fp->args.ga_len)
+ if (argcount < fp->uf_args.ga_len)
error = ERROR_TOOFEW;
- else if (!fp->varargs && argcount > fp->args.ga_len)
+ else if (!fp->uf_varargs && argcount > fp->uf_args.ga_len)
error = ERROR_TOOMANY;
- else if ((fp->flags & FC_DICT) && selfdict == NULL)
+ else if ((fp->uf_flags & FC_DICT) && selfdict == NULL)
error = ERROR_DICT;
else
{
@@ -6243,12 +6387,12 @@ call_func(name, len, rettv, argcount, argvars, firstline, lastline,
*/
save_search_patterns();
saveRedobuff();
- ++fp->calls;
+ ++fp->uf_calls;
call_user_func(fp, argcount, argvars, rettv,
firstline, lastline,
- (fp->flags & FC_DICT) ? selfdict : NULL);
- if (--fp->calls <= 0 && isdigit(*fp->name)
- && fp->refcount <= 0)
+ (fp->uf_flags & FC_DICT) ? selfdict : NULL);
+ if (--fp->uf_calls <= 0 && isdigit(*fp->uf_name)
+ && fp->uf_refcount <= 0)
/* Function was unreferenced while being used, free it
* now. */
func_free(fp);
@@ -8198,7 +8342,7 @@ f_getbufvar(argvars, rettv)
else
{
/* look up the variable */
- v = find_var_in_ht(&buf->b_vars.dv_hashtab, varname);
+ v = find_var_in_ht(&buf->b_vars.dv_hashtab, varname, FALSE);
if (v != NULL)
copy_tv(&v->di_tv, rettv);
}
@@ -8723,7 +8867,7 @@ f_getwinvar(argvars, rettv)
else
{
/* look up the variable */
- v = find_var_in_ht(&win->w_vars.dv_hashtab, varname);
+ v = find_var_in_ht(&win->w_vars.dv_hashtab, varname, FALSE);
if (v != NULL)
copy_tv(&v->di_tv, rettv);
}
@@ -8909,6 +9053,9 @@ f_has(argvars, rettv)
#ifdef FEAT_SEARCHPATH
"file_in_path",
#endif
+#if defined(UNIX) && !defined(USE_SYSTEM)
+ "filterpipe",
+#endif
#ifdef FEAT_FIND_ID
"find_in_path",
#endif
@@ -9772,8 +9919,6 @@ f_isdirectory(argvars, rettv)
rettv->vval.v_number = mch_isdir(get_tv_string(&argvars[0]));
}
-static int tv_islocked __ARGS((typval_T *tv));
-
/*
* Return TRUE if typeval "tv" is locked: Either tha value is locked itself or
* it refers to a List or Dictionary that is locked.
@@ -10569,6 +10714,68 @@ f_min(argvars, rettv)
max_min(argvars, rettv, FALSE);
}
+static int mkdir_recurse __ARGS((char_u *dir, int prot));
+
+/*
+ * Create the directory in which "dir" is located, and higher levels when
+ * needed.
+ */
+ static int
+mkdir_recurse(dir, prot)
+ char_u *dir;
+ int prot;
+{
+ char_u *p;
+ char_u *updir;