1
0
forked from aniani/vim

updated for version 7.0072

This commit is contained in:
Bram Moolenaar 2005-05-18 22:17:12 +00:00
parent 142695f3c5
commit a7fc0101b2
13 changed files with 223 additions and 168 deletions

View File

@ -1,4 +1,4 @@
*change.txt* For Vim version 7.0aa. Last change: 2005 Apr 03 *change.txt* For Vim version 7.0aa. Last change: 2005 Apr 26
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -748,8 +748,8 @@ either the first or second pattern in parentheses did not match, so either
< <
Substitute with an expression *sub-replace-expression* Substitute with an expression *sub-replace-expression*
*sub-replace-\=*
When the substitute string starts with "\=" the remainer is interpreted as an When the substitute string starts with "\=" the remainder is interpreted as an
expression. This does not work recursively: a substitute() function inside expression. This does not work recursively: a substitute() function inside
the expression cannot use "\=" for the substitute string. the expression cannot use "\=" for the substitute string.

View File

@ -1,4 +1,4 @@
*diff.txt* For Vim version 7.0aa. Last change: 2005 Mar 08 *diff.txt* For Vim version 7.0aa. Last change: 2005 Apr 26
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -161,6 +161,8 @@ buffer. If you don't want a buffer to remain used for the diff do ":set
nodiff" before hiding it. nodiff" before hiding it.
*:diffu* *:diffupdate* *:diffu* *:diffupdate*
:diffu[pdate] Update the diff highlighting and folds.
Vim attempts to keep the differences updated when you make changes to the Vim attempts to keep the differences updated when you make changes to the
text. This mostly takes care of inserted and deleted lines. Changes within a text. This mostly takes care of inserted and deleted lines. Changes within a
line and more complicated changes do not cause the differences to be updated. line and more complicated changes do not cause the differences to be updated.

View File

@ -1,4 +1,4 @@
*eval.txt* For Vim version 7.0aa. Last change: 2005 Apr 22 *eval.txt* For Vim version 7.0aa. Last change: 2005 May 18
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -194,6 +194,10 @@ is an empty list. If the second index is lower, this results in an error. >
:echo mylist[2:1] " result: [] :echo mylist[2:1] " result: []
:echo mylist[2:0] " error! :echo mylist[2:0] " error!
NOTE: mylist[s:e] means using the variable "s:e" as index. Watch out for
using a single letter variable before the ":". Insert a space when needed:
mylist[s : e].
List identity ~ List identity ~
*list-identity* *list-identity*
@ -4596,14 +4600,14 @@ Using a script in the "autoload" directory is simpler, but requires using
exactly the right file name. A function that can be autoloaded has a name exactly the right file name. A function that can be autoloaded has a name
like this: > like this: >
:call filename:funcname() :call filename#funcname()
When such a function is called, and it is not defined yet, Vim will search the When such a function is called, and it is not defined yet, Vim will search the
"autoload" directories in 'runtimepath' for a script file called "autoload" directories in 'runtimepath' for a script file called
"filename.vim". For example "~/.vim/autoload/filename.vim". That file should "filename.vim". For example "~/.vim/autoload/filename.vim". That file should
then define the function like this: > then define the function like this: >
function filename:funcname() function filename#funcname()
echo "Done!" echo "Done!"
endfunction endfunction
@ -4611,10 +4615,10 @@ The file name and the name used before the colon in the function must match
exactly, and the defined function must have the name exactly as it will be exactly, and the defined function must have the name exactly as it will be
called. called.
It is possible to use subdirectories. Every colon in the function name works It is possible to use subdirectories. Every # in the function name works like
like a path separator. Thus when calling a function: > a path separator. Thus when calling a function: >
:call foo:bar:func() :call foo#bar#func()
Vim will look for the file "autoload/foo/bar.vim" in 'runtimepath'. Vim will look for the file "autoload/foo/bar.vim" in 'runtimepath'.
@ -4623,13 +4627,13 @@ otherwise it looks like a scope, such as "s:".
This also works when reading a variable that has not been set yet: > This also works when reading a variable that has not been set yet: >
:let l = foo:bar:lvar :let l = foo#bar#lvar
When assigning a value to such a variable nothing special happens. This can When assigning a value to such a variable nothing special happens. This can
be used to pass settings to the autoload script before it's loaded: > be used to pass settings to the autoload script before it's loaded: >
:let foo:bar:toggle = 1 :let foo#bar#toggle = 1
:call foo:bar:func() :call foo#bar#func()
Note that when you make a mistake and call a function that is supposed to be Note that when you make a mistake and call a function that is supposed to be
defined in an autoload script, but the script doesn't actually define the defined in an autoload script, but the script doesn't actually define the

View File

@ -6292,6 +6292,7 @@ style-names develop.txt /*style-names*
style-spaces develop.txt /*style-spaces* style-spaces develop.txt /*style-spaces*
style-various develop.txt /*style-various* style-various develop.txt /*style-various*
sub-menu-priority gui.txt /*sub-menu-priority* sub-menu-priority gui.txt /*sub-menu-priority*
sub-replace-\= change.txt /*sub-replace-\\=*
sub-replace-expression change.txt /*sub-replace-expression* sub-replace-expression change.txt /*sub-replace-expression*
sub-replace-special change.txt /*sub-replace-special* sub-replace-special change.txt /*sub-replace-special*
submatch() eval.txt /*submatch()* submatch() eval.txt /*submatch()*

View File

@ -1,4 +1,4 @@
*usr_41.txt* For Vim version 7.0aa. Last change: 2005 Mar 25 *usr_41.txt* For Vim version 7.0aa. Last change: 2005 May 18
VIM USER MANUAL - by Bram Moolenaar VIM USER MANUAL - by Bram Moolenaar
@ -2229,11 +2229,11 @@ Here you need to know that MyLibFunction() is defined in a script
To make this a bit simpler Vim offers the autoload mechanism. Then the To make this a bit simpler Vim offers the autoload mechanism. Then the
example looks like this: > example looks like this: >
call mylib:myfunction(arg) call mylib#myfunction(arg)
That's a lot simpler, isn't it? Vim will recognize the function name and when That's a lot simpler, isn't it? Vim will recognize the function name and when
it's not defined search for the script "autoload/mylib.vim" in 'runtimepath'. it's not defined search for the script "autoload/mylib.vim" in 'runtimepath'.
That script must define the "mylib:myfunction()" function. That script must define the "mylib#myfunction()" function.
You can put many other functions in the mylib.vim script, you are free to You can put many other functions in the mylib.vim script, you are free to
organize your functions in library scripts. But you must use function names organize your functions in library scripts. But you must use function names
@ -2243,7 +2243,7 @@ would not know what script to load.
If you get really enthousiastic and write lots of library scripts, you may If you get really enthousiastic and write lots of library scripts, you may
want to use subdirectories. Example: > want to use subdirectories. Example: >
call netlib:ftp:read('somefile') call netlib#ftp#read('somefile')
For Unix the library script used for this could be: For Unix the library script used for this could be:
@ -2251,7 +2251,7 @@ For Unix the library script used for this could be:
Where the function is defined like this: > Where the function is defined like this: >
function netlib:ftp:read(fname) function netlib#ftp#read(fname)
" Read the file fname through ftp " Read the file fname through ftp
endfunction endfunction
@ -2261,12 +2261,12 @@ exactly matches the subdirectory and script name.
You can use the same mechanism for variables: > You can use the same mechanism for variables: >
let weekdays = dutch:weekdays let weekdays = dutch#weekdays
This will load the script "autoload/dutch.vim", which should contain something This will load the script "autoload/dutch.vim", which should contain something
like: > like: >
let dutch:weekdays = ['zondag', 'maandag', 'dinsdag', 'woensdag', let dutch#weekdays = ['zondag', 'maandag', 'dinsdag', 'woensdag',
\ 'donderdag', 'vrijdag', 'zaterdag'] \ 'donderdag', 'vrijdag', 'zaterdag']
Further reading: |autoload|. Further reading: |autoload|.

View File

@ -1259,7 +1259,7 @@ POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(TCL
ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS) ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS)
LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) -Dinline= -D__extension__= -Dalloca=alloca LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) -Dinline= -D__extension__= -Dalloca=alloca -D"__attribute__(x)="
DEPEND_CFLAGS = -DPROTO -DDEPEND -DFEAT_GUI $(LINT_CFLAGS) DEPEND_CFLAGS = -DPROTO -DDEPEND -DFEAT_GUI $(LINT_CFLAGS)

View File

@ -1075,11 +1075,11 @@ else
fi fi
fi fi
test "x$with_x" = xno -a "x$BEOS" != "xyes" -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
AC_MSG_CHECKING(--enable-gui argument) AC_MSG_CHECKING(--enable-gui argument)
AC_ARG_ENABLE(gui, AC_ARG_ENABLE(gui,
[ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/kde/motif/athena/neXtaw/beos/photon/carbon]], , enable_gui="auto") [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/kde/motif/athena/neXtaw/photon/carbon]], , enable_gui="auto")
dnl Canonicalize the --enable-gui= argument so that it can be easily compared. dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
dnl Do not use character classes for portability with old tools. dnl Do not use character classes for portability with old tools.

View File

@ -1209,7 +1209,11 @@ gui_mch_destroy_scrollbar(scrollbar_T *sb)
/* /*
* Implementation of the file selector related stuff * Implementation of the file selector related stuff
*/ */
#if defined(HAVE_GTK2) && GTK_CHECK_VERSION(2,4,0)
# define USE_FILE_CHOOSER
#endif
#ifndef USE_FILE_CHOOSER
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
browse_ok_cb(GtkWidget *widget, gpointer cbdata) browse_ok_cb(GtkWidget *widget, gpointer cbdata)
@ -1258,6 +1262,7 @@ browse_destroy_cb(GtkWidget * widget)
return FALSE; return FALSE;
} }
#endif
/* /*
* Put up a file requester. * Put up a file requester.
@ -1278,7 +1283,9 @@ gui_mch_browse(int saving,
char_u *initdir, char_u *initdir,
char_u *filter) char_u *filter)
{ {
GtkFileSelection *fs; /* shortcut */ #ifdef USE_FILE_CHOOSER
GtkWidget *fc;
#endif
char_u dirbuf[MAXPATHL]; char_u dirbuf[MAXPATHL];
char_u *p; char_u *p;
@ -1286,12 +1293,56 @@ gui_mch_browse(int saving,
title = CONVERT_TO_UTF8(title); title = CONVERT_TO_UTF8(title);
# endif # endif
if (!gui.filedlg) /* Concatenate "initdir" and "dflt". */
if (initdir == NULL || *initdir == NUL)
mch_dirname(dirbuf, MAXPATHL);
else if (STRLEN(initdir) + 2 < MAXPATHL)
STRCPY(dirbuf, initdir);
else
dirbuf[0] = NUL;
/* Always need a trailing slash for a directory. */
add_pathsep(dirbuf);
if (dflt != NULL && *dflt != NUL
&& STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
STRCAT(dirbuf, dflt);
/* If our pointer is currently hidden, then we should show it. */
gui_mch_mousehide(FALSE);
#ifdef USE_FILE_CHOOSER
/* We create the dialog each time, so that the button text can be "Open"
* or "Save" according to the action. */
fc = gtk_file_chooser_dialog_new((const gchar *)title,
GTK_WINDOW(gui.mainwin),
saving ? GTK_FILE_CHOOSER_ACTION_SAVE
: GTK_FILE_CHOOSER_ACTION_OPEN,
saving ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fc),
(const gchar *)dirbuf);
gui.browse_fname = NULL;
if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT)
{ {
char *filename;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
gui.browse_fname = (char_u *)g_strdup(filename);
g_free(filename);
}
gtk_widget_destroy(GTK_WIDGET(fc));
#else
if (gui.filedlg == NULL)
{
GtkFileSelection *fs; /* shortcut */
gui.filedlg = gtk_file_selection_new((const gchar *)title); gui.filedlg = gtk_file_selection_new((const gchar *)title);
gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE); gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE);
gtk_window_set_transient_for(GTK_WINDOW(gui.filedlg), gtk_window_set_transient_for(GTK_WINDOW(gui.filedlg),
GTK_WINDOW(gui.mainwin)); GTK_WINDOW(gui.mainwin));
fs = GTK_FILE_SELECTION(gui.filedlg); fs = GTK_FILE_SELECTION(gui.filedlg);
gtk_container_border_width(GTK_CONTAINER(fs), 4); gtk_container_border_width(GTK_CONTAINER(fs), 4);
@ -1308,26 +1359,6 @@ gui_mch_browse(int saving,
else else
gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title); gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title);
# ifdef HAVE_GTK2
CONVERT_TO_UTF8_FREE(title);
# endif
/* if our pointer is currently hidden, then we should show it. */
gui_mch_mousehide(FALSE);
/* Concatenate "initdir" and "dflt". */
if (initdir == NULL || *initdir == NUL)
mch_dirname(dirbuf, MAXPATHL);
else if (STRLEN(initdir) + 2 < MAXPATHL)
STRCPY(dirbuf, initdir);
else
dirbuf[0] = NUL;
/* Always need a trailing slash for a directory. */
add_pathsep(dirbuf);
if (dflt != NULL && *dflt != NUL
&& STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
STRCAT(dirbuf, dflt);
gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg), gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg),
(const gchar *)dirbuf); (const gchar *)dirbuf);
# ifndef HAVE_GTK2 # ifndef HAVE_GTK2
@ -1338,7 +1369,11 @@ gui_mch_browse(int saving,
gtk_widget_show(gui.filedlg); gtk_widget_show(gui.filedlg);
while (gui.filedlg && GTK_WIDGET_DRAWABLE(gui.filedlg)) while (gui.filedlg && GTK_WIDGET_DRAWABLE(gui.filedlg))
gtk_main_iteration_do(TRUE); gtk_main_iteration_do(TRUE);
#endif
# ifdef HAVE_GTK2
CONVERT_TO_UTF8_FREE(title);
# endif
if (gui.browse_fname == NULL) if (gui.browse_fname == NULL)
return NULL; return NULL;
@ -1422,6 +1457,7 @@ gui_mch_browsedir(
} }
#endif #endif
#endif /* FEAT_BROWSE */ #endif /* FEAT_BROWSE */
#if defined(FEAT_GUI_DIALOG) && !defined(HAVE_GTK2) #if defined(FEAT_GUI_DIALOG) && !defined(HAVE_GTK2)
@ -3104,7 +3140,6 @@ gui_gtk_position_in_parent(
pos_x = xP + wP - c_size.width - 2; pos_x = xP + wP - c_size.width - 2;
/* Assume 'guiheadroom' indicates the title bar height... */ /* Assume 'guiheadroom' indicates the title bar height... */
if ((pos_y + c_size.height + p_ghr / 2) > (hP + yP)) if ((pos_y + c_size.height + p_ghr / 2) > (hP + yP))
pos_y = yP + hP - c_size.height - 2 - p_ghr / 2;
gtk_widget_set_uposition(child, pos_x, pos_y); gtk_widget_set_uposition(child, pos_x, pos_y);
} }

View File

@ -3073,6 +3073,81 @@ static linenr_T reg_firstlnum;
static linenr_T reg_maxline; static linenr_T reg_maxline;
static int reg_line_lbr; /* "\n" in string is line break */ static int reg_line_lbr; /* "\n" in string is line break */
/* Values for rs_state in regitem_T. */
typedef enum regstate_E
{
RS_NOPEN = 0 /* NOPEN and NCLOSE */
, RS_MOPEN /* MOPEN + [0-9] */
, RS_MCLOSE /* MCLOSE + [0-9] */
#ifdef FEAT_SYN_HL
, RS_ZOPEN /* ZOPEN + [0-9] */
, RS_ZCLOSE /* ZCLOSE + [0-9] */
#endif
, RS_BRANCH /* BRANCH */
, RS_BRCPLX_MORE /* BRACE_COMPLEX and trying one more match */
, RS_BRCPLX_LONG /* BRACE_COMPLEX and trying longest match */
, RS_BRCPLX_SHORT /* BRACE_COMPLEX and trying shortest match */
, RS_NOMATCH /* NOMATCH */
, RS_BEHIND1 /* BEHIND / NOBEHIND matching rest */
, RS_BEHIND2 /* BEHIND / NOBEHIND matching behind part */
, RS_STAR_LONG /* STAR/PLUS/BRACE_SIMPLE longest match */
, RS_STAR_SHORT /* STAR/PLUS/BRACE_SIMPLE shortest match */
} regstate_T;
/*
* When there are alternatives a regstate_T is put on the regstack to remember
* what we are doing.
* Before it may be another type of item, depending on rs_state, to remember
* more things.
*/
typedef struct regitem_S
{
regstate_T rs_state; /* what we are doing, one of RS_ above */
char_u *rs_scan; /* current node in program */
union
{
save_se_T sesave;
regsave_T regsave;
} rs_un; /* room for saving reginput */
short rs_no; /* submatch nr */
} regitem_T;
static regitem_T *regstack_push __ARGS((regstate_T state, char_u *scan));
static void regstack_pop __ARGS((char_u **scan));
/* used for BEHIND and NOBEHIND matching */
typedef struct regbehind_S
{
regsave_T save_after;
regsave_T save_behind;
} regbehind_T;
/* used for STAR, PLUS and BRACE_SIMPLE matching */
typedef struct regstar_S
{
int nextb; /* next byte */
int nextb_ic; /* next byte reverse case */
long count;
long minval;
long maxval;
} regstar_T;
/* used to store input position when a BACK was encountered, so that we now if
* we made any progress since the last time. */
typedef struct backpos_S
{
char_u *bp_scan; /* "scan" where BACK was encountered */
regsave_T bp_pos; /* last input position */
} backpos_T;
/*
* regstack and backpos are used by regmatch(). They are kept over calls to
* avoid invoking malloc() and free() often.
*/
static garray_T regstack; /* stack with regitem_T items, sometimes
preceded by regstar_T or regbehind_T. */
static garray_T backpos; /* table with backpos_T for BACK */
/* /*
* Get pointer to the line "lnum", which is relative to "reg_firstlnum". * Get pointer to the line "lnum", which is relative to "reg_firstlnum".
*/ */
@ -3202,6 +3277,14 @@ vim_regexec_both(line, col)
reg_tofree = NULL; reg_tofree = NULL;
/* Init the regstack empty. Use an item size of 1 byte, since we push
* different things onto it. Use a large grow size to avoid reallocating
* it too often. */
ga_init2(&regstack, 1, 10000);
/* Init the backpos table empty. */
ga_init2(&backpos, sizeof(backpos_T), 10);
if (REG_MULTI) if (REG_MULTI)
{ {
prog = reg_mmatch->regprog; prog = reg_mmatch->regprog;
@ -3360,8 +3443,10 @@ vim_regexec_both(line, col)
} }
theend: theend:
/* Didn't find a match. */
vim_free(reg_tofree); vim_free(reg_tofree);
ga_clear(&regstack);
ga_clear(&backpos);
return retval; return retval;
} }
@ -3519,73 +3604,6 @@ reg_prev_class()
static long bl_minval; static long bl_minval;
static long bl_maxval; static long bl_maxval;
/* Values for rs_state in regitem_T. */
typedef enum regstate_E
{
RS_NOPEN = 0 /* NOPEN and NCLOSE */
, RS_MOPEN /* MOPEN + [0-9] */
, RS_MCLOSE /* MCLOSE + [0-9] */
#ifdef FEAT_SYN_HL
, RS_ZOPEN /* ZOPEN + [0-9] */
, RS_ZCLOSE /* ZCLOSE + [0-9] */
#endif
, RS_BRANCH /* BRANCH */
, RS_BRCPLX_MORE /* BRACE_COMPLEX and trying one more match */
, RS_BRCPLX_LONG /* BRACE_COMPLEX and trying longest match */
, RS_BRCPLX_SHORT /* BRACE_COMPLEX and trying shortest match */
, RS_NOMATCH /* NOMATCH */
, RS_BEHIND1 /* BEHIND / NOBEHIND matching rest */
, RS_BEHIND2 /* BEHIND / NOBEHIND matching behind part */
, RS_STAR_LONG /* STAR/PLUS/BRACE_SIMPLE longest match */
, RS_STAR_SHORT /* STAR/PLUS/BRACE_SIMPLE shortest match */
} regstate_T;
/*
* When there are alternatives a regstate_T is put on the regstack to remember
* what we are doing.
* Before it may be another type of item, depending on rs_state, to remember
* more things.
*/
typedef struct regitem_S
{
regstate_T rs_state; /* what we are doing, one of RS_ above */
char_u *rs_scan; /* current node in program */
union
{
save_se_T sesave;
regsave_T regsave;
} rs_un; /* room for saving reginput */
short rs_no; /* submatch nr */
} regitem_T;
static regitem_T *regstack_push __ARGS((garray_T *regstack, regstate_T state, char_u *scan));
static void regstack_pop __ARGS((garray_T *regstack, char_u **scan));
/* used for BEHIND and NOBEHIND matching */
typedef struct regbehind_S
{
regsave_T save_after;
regsave_T save_behind;
} regbehind_T;
/* used for STAR, PLUS and BRACE_SIMPLE matching */
typedef struct regstar_S
{
int nextb; /* next byte */
int nextb_ic; /* next byte reverse case */
long count;
long minval;
long maxval;
} regstar_T;
/* used to store input position when a BACK was encountered, so that we now if
* we made any progress since the last time. */
typedef struct backpos_S
{
char_u *bp_scan; /* "scan" where BACK was encountered */
regsave_T bp_pos; /* last input position */
} backpos_T;
/* /*
* regmatch - main matching routine * regmatch - main matching routine
* *
@ -3608,8 +3626,6 @@ regmatch(scan)
char_u *next; /* Next node. */ char_u *next; /* Next node. */
int op; int op;
int c; int c;
garray_T regstack; /* stack with regitem_T items, sometimes
preceded by regstar_T or regbehind_T. */
regitem_T *rp; regitem_T *rp;
int no; int no;
int status; /* one of the RA_ values: */ int status; /* one of the RA_ values: */
@ -3618,14 +3634,11 @@ regmatch(scan)
#define RA_BREAK 3 /* break inner loop */ #define RA_BREAK 3 /* break inner loop */
#define RA_MATCH 4 /* successful match */ #define RA_MATCH 4 /* successful match */
#define RA_NOMATCH 5 /* didn't match */ #define RA_NOMATCH 5 /* didn't match */
garray_T backpos; /* table with backpos_T for BACK */
/* Init the regstack empty. Use an item size of 1 byte, since we push /* Init the regstack and backpos table empty. They are initialized and
* different things onto it. Use a large grow size to avoid reallocating * freed in vim_regexec_both() to reduce malloc()/free() calls. */
* it too often. */ regstack.ga_len = 0;
ga_init2(&regstack, 1, 10000); backpos.ga_len = 0;
ga_init2(&backpos, sizeof(backpos_T), 10);
/* /*
* Repeat until "regstack" is empty. * Repeat until "regstack" is empty.
@ -4133,7 +4146,7 @@ regmatch(scan)
{ {
no = op - MOPEN; no = op - MOPEN;
cleanup_subexpr(); cleanup_subexpr();
rp = regstack_push(&regstack, RS_MOPEN, scan); rp = regstack_push(RS_MOPEN, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4148,7 +4161,7 @@ regmatch(scan)
case NOPEN: /* \%( */ case NOPEN: /* \%( */
case NCLOSE: /* \) after \%( */ case NCLOSE: /* \) after \%( */
if (regstack_push(&regstack, RS_NOPEN, scan) == NULL) if (regstack_push(RS_NOPEN, scan) == NULL)
status = RA_FAIL; status = RA_FAIL;
/* We simply continue and handle the result when done. */ /* We simply continue and handle the result when done. */
break; break;
@ -4166,7 +4179,7 @@ regmatch(scan)
{ {
no = op - ZOPEN; no = op - ZOPEN;
cleanup_zsubexpr(); cleanup_zsubexpr();
rp = regstack_push(&regstack, RS_ZOPEN, scan); rp = regstack_push(RS_ZOPEN, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4193,7 +4206,7 @@ regmatch(scan)
{ {
no = op - MCLOSE; no = op - MCLOSE;
cleanup_subexpr(); cleanup_subexpr();
rp = regstack_push(&regstack, RS_MCLOSE, scan); rp = regstack_push(RS_MCLOSE, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4218,7 +4231,7 @@ regmatch(scan)
{ {
no = op - ZCLOSE; no = op - ZCLOSE;
cleanup_zsubexpr(); cleanup_zsubexpr();
rp = regstack_push(&regstack, RS_ZCLOSE, scan); rp = regstack_push(RS_ZCLOSE, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4396,7 +4409,7 @@ regmatch(scan)
next = OPERAND(scan); /* Avoid recursion. */ next = OPERAND(scan); /* Avoid recursion. */
else else
{ {
rp = regstack_push(&regstack, RS_BRANCH, scan); rp = regstack_push(RS_BRANCH, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4446,7 +4459,7 @@ regmatch(scan)
if (brace_count[no] <= (brace_min[no] <= brace_max[no] if (brace_count[no] <= (brace_min[no] <= brace_max[no]
? brace_min[no] : brace_max[no])) ? brace_min[no] : brace_max[no]))
{ {
rp = regstack_push(&regstack, RS_BRCPLX_MORE, scan); rp = regstack_push(RS_BRCPLX_MORE, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4465,7 +4478,7 @@ regmatch(scan)
/* Range is the normal way around, use longest match */ /* Range is the normal way around, use longest match */
if (brace_count[no] <= brace_max[no]) if (brace_count[no] <= brace_max[no])
{ {
rp = regstack_push(&regstack, RS_BRCPLX_LONG, scan); rp = regstack_push(RS_BRCPLX_LONG, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4482,7 +4495,7 @@ regmatch(scan)
/* Range is backwards, use shortest match first */ /* Range is backwards, use shortest match first */
if (brace_count[no] <= brace_min[no]) if (brace_count[no] <= brace_min[no])
{ {
rp = regstack_push(&regstack, RS_BRCPLX_SHORT, scan); rp = regstack_push(RS_BRCPLX_SHORT, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4562,7 +4575,7 @@ regmatch(scan)
else else
{ {
regstack.ga_len += sizeof(regstar_T); regstack.ga_len += sizeof(regstar_T);
rp = regstack_push(&regstack, rst.minval <= rst.maxval rp = regstack_push(rst.minval <= rst.maxval
? RS_STAR_LONG : RS_STAR_SHORT, scan); ? RS_STAR_LONG : RS_STAR_SHORT, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
@ -4582,7 +4595,7 @@ regmatch(scan)
case NOMATCH: case NOMATCH:
case MATCH: case MATCH:
case SUBPAT: case SUBPAT:
rp = regstack_push(&regstack, RS_NOMATCH, scan); rp = regstack_push(RS_NOMATCH, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4607,7 +4620,7 @@ regmatch(scan)
else else
{ {
regstack.ga_len += sizeof(regbehind_T); regstack.ga_len += sizeof(regbehind_T);
rp = regstack_push(&regstack, RS_BEHIND1, scan); rp = regstack_push(RS_BEHIND1, scan);
if (rp == NULL) if (rp == NULL)
status = RA_FAIL; status = RA_FAIL;
else else
@ -4675,7 +4688,7 @@ regmatch(scan)
{ {
case RS_NOPEN: case RS_NOPEN:
/* Result is passed on as-is, simply pop the state. */ /* Result is passed on as-is, simply pop the state. */
regstack_pop(&regstack, &scan); regstack_pop(&scan);
break; break;
case RS_MOPEN: case RS_MOPEN:
@ -4683,7 +4696,7 @@ regmatch(scan)
if (status == RA_NOMATCH) if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, &reg_startpos[rp->rs_no], restore_se(&rp->rs_un.sesave, &reg_startpos[rp->rs_no],
&reg_startp[rp->rs_no]); &reg_startp[rp->rs_no]);
regstack_pop(&regstack, &scan); regstack_pop(&scan);
break; break;
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
@ -4692,7 +4705,7 @@ regmatch(scan)
if (status == RA_NOMATCH) if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, &reg_startzpos[rp->rs_no], restore_se(&rp->rs_un.sesave, &reg_startzpos[rp->rs_no],
&reg_startzp[rp->rs_no]); &reg_startzp[rp->rs_no]);
regstack_pop(&regstack, &scan); regstack_pop(&scan);
break; break;
#endif #endif
@ -4701,7 +4714,7 @@ regmatch(scan)
if (status == RA_NOMATCH) if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, &reg_endpos[rp->rs_no], restore_se(&rp->rs_un.sesave, &reg_endpos[rp->rs_no],
&reg_endp[rp->rs_no]); &reg_endp[rp->rs_no]);
regstack_pop(&regstack, &scan); regstack_pop(&scan);
break; break;
#ifdef FEAT_SYN_HL #ifdef FEAT_SYN_HL
@ -4710,14 +4723,14 @@ regmatch(scan)
if (status == RA_NOMATCH) if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, &reg_endzpos[rp->rs_no], restore_se(&rp->rs_un.sesave, &reg_endzpos[rp->rs_no],
&reg_endzp[rp->rs_no]); &reg_endzp[rp->rs_no]);
regstack_pop(&regstack, &scan); regstack_pop(&scan);
break; break;
#endif #endif
case RS_BRANCH: case RS_BRANCH:
if (status == RA_MATCH) if (status == RA_MATCH)
/* this branch matched, use it */ /* this branch matched, use it */
regstack_pop(&regstack, &scan); regstack_pop(&scan);
else else
{ {
if (status != RA_BREAK) if (status != RA_BREAK)
@ -4730,7 +4743,7 @@ regmatch(scan)
{ {
/* no more branches, didn't find a match */ /* no more branches, didn't find a match */
status = RA_NOMATCH; status = RA_NOMATCH;
regstack_pop(&regstack, &scan); regstack_pop(&scan);
} }
else else
{ {
@ -4749,7 +4762,7 @@ regmatch(scan)
reg_restore(&rp->rs_un.regsave, &backpos); reg_restore(&rp->rs_un.regsave, &backpos);
--brace_count[rp->rs_no]; /* decrement match count */ --brace_count[rp->rs_no]; /* decrement match count */
} }
regstack_pop(&regstack, &scan); regstack_pop(&scan);
break; break;
case RS_BRCPLX_LONG: case RS_BRCPLX_LONG:
@ -4762,7 +4775,7 @@ regmatch(scan)
/* continue with the items after "\{}" */ /* continue with the items after "\{}" */
status = RA_CONT; status = RA_CONT;
} }
regstack_pop(&regstack, &scan); regstack_pop(&scan);
if (status == RA_CONT) if (status == RA_CONT)
scan = regnext(scan); scan = regnext(scan);
break; break;
@ -4772,7 +4785,7 @@ regmatch(scan)
if (status == RA_NOMATCH) if (status == RA_NOMATCH)
/* There was no match, try to match one more item. */ /* There was no match, try to match one more item. */
reg_restore(&rp->rs_un.regsave, &backpos); reg_restore(&rp->rs_un.regsave, &backpos);
regstack_pop(&regstack, &scan); regstack_pop(&scan);
if (status == RA_NOMATCH) if (status == RA_NOMATCH)
{ {
scan = OPERAND(scan); scan = OPERAND(scan);
@ -4792,7 +4805,7 @@ regmatch(scan)
if (rp->rs_no != SUBPAT) /* zero-width */ if (rp->rs_no != SUBPAT) /* zero-width */
reg_restore(&rp->rs_un.regsave, &backpos); reg_restore(&rp->rs_un.regsave, &backpos);
} }
regstack_pop(&regstack, &scan); regstack_pop(&scan);
if (status == RA_CONT) if (status == RA_CONT)
scan = regnext(scan); scan = regnext(scan);
break; break;
@ -4800,7 +4813,7 @@ regmatch(scan)
case RS_BEHIND1: case RS_BEHIND1:
if (status == RA_NOMATCH) if (status == RA_NOMATCH)
{ {
regstack_pop(&regstack, &scan); regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T); regstack.ga_len -= sizeof(regbehind_T);
} }
else else
@ -4844,7 +4857,7 @@ regmatch(scan)
else else
/* But we didn't want a match. */ /* But we didn't want a match. */
status = RA_NOMATCH; status = RA_NOMATCH;
regstack_pop(&regstack, &scan); regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T); regstack.ga_len -= sizeof(regbehind_T);
} }
else else
@ -4897,7 +4910,7 @@ regmatch(scan)
} }
else else
status = RA_NOMATCH; status = RA_NOMATCH;
regstack_pop(&regstack, &scan); regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T); regstack.ga_len -= sizeof(regbehind_T);
} }
} }
@ -4910,7 +4923,7 @@ regmatch(scan)
if (status == RA_MATCH) if (status == RA_MATCH)
{ {
regstack_pop(&regstack, &scan); regstack_pop(&scan);
regstack.ga_len -= sizeof(regstar_T); regstack.ga_len -= sizeof(regstar_T);
break; break;
} }
@ -4976,7 +4989,7 @@ regmatch(scan)
if (status != RA_CONT) if (status != RA_CONT)
{ {
/* Failed. */ /* Failed. */
regstack_pop(&regstack, &scan); regstack_pop(&scan);
regstack.ga_len -= sizeof(regstar_T); regstack.ga_len -= sizeof(regstar_T);
status = RA_NOMATCH; status = RA_NOMATCH;
} }
@ -5000,7 +5013,6 @@ regmatch(scan)
*/ */
if (regstack.ga_len == 0 || status == RA_FAIL) if (regstack.ga_len == 0 || status == RA_FAIL)
{ {
ga_clear(&regstack);
if (scan == NULL) if (scan == NULL)
{ {
/* /*
@ -5027,26 +5039,25 @@ regmatch(scan)
* Returns pointer to new item. Returns NULL when out of memory. * Returns pointer to new item. Returns NULL when out of memory.
*/ */
static regitem_T * static regitem_T *
regstack_push(regstack, state, scan) regstack_push(state, scan)
garray_T *regstack;
regstate_T state; regstate_T state;
char_u *scan; char_u *scan;
{ {
regitem_T *rp; regitem_T *rp;
if ((long)((unsigned)regstack->ga_len >> 10) >= p_mmp) if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)
{ {
EMSG(_(e_maxmempat)); EMSG(_(e_maxmempat));
return NULL; return NULL;
} }
if (ga_grow(regstack, sizeof(regitem_T)) == FAIL) if (ga_grow(&regstack, sizeof(regitem_T)) == FAIL)
return NULL; return NULL;
rp = (regitem_T *)((char *)regstack->ga_data + regstack->ga_len); rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len);
rp->rs_state = state; rp->rs_state = state;
rp->rs_scan = scan; rp->rs_scan = scan;
regstack->ga_len += sizeof(regitem_T); regstack.ga_len += sizeof(regitem_T);
return rp; return rp;
} }
@ -5054,16 +5065,15 @@ regstack_push(regstack, state, scan)
* Pop an item from the regstack. * Pop an item from the regstack.
*/ */
static void static void
regstack_pop(regstack, scan) regstack_pop(scan)
garray_T *regstack;
char_u **scan; char_u **scan;
{ {
regitem_T *rp; regitem_T *rp;
rp = (regitem_T *)((char *)regstack->ga_data + regstack->ga_len) - 1; rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;
*scan = rp->rs_scan; *scan = rp->rs_scan;
regstack->ga_len -= sizeof(regitem_T); regstack.ga_len -= sizeof(regitem_T);
} }
/* /*

View File

@ -23,7 +23,8 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test33.out test34.out test35.out test36.out test37.out \ test33.out test34.out test35.out test36.out test37.out \
test38.out test39.out test40.out test41.out test42.out \ test38.out test39.out test40.out test41.out test42.out \
test43.out test44.out test45.out test46.out test47.out \ test43.out test44.out test45.out test46.out test47.out \
test48.out test51.out test53.out test54.out test55.out test48.out test51.out test53.out test54.out test55.out \
test56.out
.SUFFIXES: .in .out .SUFFIXES: .in .out
@ -98,3 +99,4 @@ test51.out: test51.in
test53.out: test53.in test53.out: test53.in
test54.out: test54.in test54.out: test54.in
test55.out: test55.in test55.out: test55.in
test56.out: test56.in

View File

@ -17,7 +17,8 @@ SCRIPTS16 = test1.out test19.out test20.out test22.out \
test23.out test24.out test28.out test29.out \ test23.out test24.out test28.out test29.out \
test35.out test36.out test43.out \ test35.out test36.out test43.out \
test44.out test45.out test46.out test47.out \ test44.out test45.out test46.out test47.out \
test48.out test51.out test53.out test54.out test55.out test48.out test51.out test53.out test54.out \
test55.out test56.out
SCRIPTS = test3.out test4.out test5.out test6.out test7.out \ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test8.out test9.out test11.out test13.out test14.out \ test8.out test9.out test11.out test13.out test14.out \

View File

@ -1,6 +1,6 @@
" Vim script language tests " Vim script language tests
" Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com> " Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com>
" Last Change: 2005 Feb 03 " Last Change: 2005 May 18
"------------------------------------------------------------------------------- "-------------------------------------------------------------------------------
" Test environment {{{1 " Test environment {{{1

View File

@ -36,5 +36,5 @@
#define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_NODOT "vim70aa"
#define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_SHORT "7.0aa"
#define VIM_VERSION_MEDIUM "7.0aa ALPHA" #define VIM_VERSION_MEDIUM "7.0aa ALPHA"
#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Apr 24)" #define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 May 18)"
#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Apr 24, compiled " #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 May 18, compiled "