summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-07-09 21:08:57 +0000
committerBram Moolenaar <Bram@vim.org>2005-07-09 21:08:57 +0000
commit35fdbb540aa6f7572557cd88b21c5ee2e9c8c70e (patch)
tree2ee9f79196afa6f3b737e463c767ccd70f5d311a /src
parenta466c99842c4b482c847b6336aae458509963dcd (diff)
downloadvim-git-35fdbb540aa6f7572557cd88b21c5ee2e9c8c70e.tar.gz
updated for version 7.0106
Diffstat (limited to 'src')
-rw-r--r--src/ex_getln.c102
-rw-r--r--src/mbyte.c128
-rw-r--r--src/os_unix.c2
-rw-r--r--src/proto/eval.pro3
-rw-r--r--src/undo.c2
-rw-r--r--src/version.h4
6 files changed, 179 insertions, 62 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index d221249e7..5bd079ab2 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -100,6 +100,7 @@ static int expand_showtail __ARGS((expand_T *xp));
static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname));
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
+static int ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file));
# endif
#endif
@@ -3702,7 +3703,8 @@ addstar(fname, len, context)
/* Custom expansion takes care of special things, match
* backslashes literally (perhaps also for other types?) */
- if (context == EXPAND_USER_DEFINED && fname[i] == '\\')
+ if ((context == EXPAND_USER_DEFINED ||
+ context == EXPAND_USER_LIST) && fname[i] == '\\')
new_len++; /* '\' becomes "\\" */
}
retval = alloc(new_len);
@@ -3715,7 +3717,9 @@ addstar(fname, len, context)
/* Skip backslash. But why? At least keep it for custom
* expansion. */
if (context != EXPAND_USER_DEFINED
- && fname[i] == '\\' && ++i == len)
+ && context != EXPAND_USER_LIST
+ && fname[i] == '\\'
+ && ++i == len)
break;
switch (fname[i])
@@ -3729,7 +3733,8 @@ addstar(fname, len, context)
case '.': if (context == EXPAND_BUFFERS)
retval[j++] = '\\';
break;
- case '\\': if (context == EXPAND_USER_DEFINED)
+ case '\\': if (context == EXPAND_USER_DEFINED
+ || context == EXPAND_USER_LIST)
retval[j++] = '\\';
break;
}
@@ -4029,6 +4034,10 @@ ExpandFromContext(xp, pat, num_file, file, options)
return ExpandRTDir(pat, num_file, file, "colors");
if (xp->xp_context == EXPAND_COMPILER)
return ExpandRTDir(pat, num_file, file, "compiler");
+# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
+ if (xp->xp_context == EXPAND_USER_LIST)
+ return ExpandUserList(xp, num_file, file);
+# endif
regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
if (regmatch.regprog == NULL)
@@ -4185,27 +4194,25 @@ ExpandGeneric(xp, regmatch, num_file, file, func)
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
/*
- * Expand names with a function defined by the user.
+ * call "user_expand_func()" to invoke a user defined VimL function and return
+ * the result (either a string or a List).
*/
- static int
-ExpandUserDefined(xp, regmatch, num_file, file)
+ static void *
+call_user_expand_func(user_expand_func, xp, num_file, file)
+ void *(*user_expand_func) __ARGS((char_u *, int, char_u **, int));
expand_T *xp;
- regmatch_T *regmatch;
int *num_file;
char_u ***file;
{
+ char_u keep;
+ char_u num[50];
char_u *args[3];
- char_u *all;
- char_u *s;
- char_u *e;
- char_u keep;
- char_u num[50];
- garray_T ga;
int save_current_SID = current_SID;
+ void *ret;
struct cmdline_info save_ccline;
if (xp->xp_arg == NULL || xp->xp_arg[0] == '\0')
- return FAIL;
+ return NULL;
*num_file = 0;
*file = NULL;
@@ -4222,17 +4229,38 @@ ExpandUserDefined(xp, regmatch, num_file, file)
ccline.cmdprompt = NULL;
current_SID = xp->xp_scriptID;
- all = call_vim_function(xp->xp_arg, 3, args, FALSE);
+ ret = user_expand_func(xp->xp_arg, 3, args, FALSE);
ccline = save_ccline;
current_SID = save_current_SID;
ccline.cmdbuff[ccline.cmdlen] = keep;
- if (all == NULL)
+
+ return ret;
+}
+
+/*
+ * Expand names with a function defined by the user.
+ */
+ static int
+ExpandUserDefined(xp, regmatch, num_file, file)
+ expand_T *xp;
+ regmatch_T *regmatch;
+ int *num_file;
+ char_u ***file;
+{
+ char_u *retstr;
+ char_u *s;
+ char_u *e;
+ char_u keep;
+ garray_T ga;
+
+ retstr = call_user_expand_func(call_func_retstr, xp, num_file, file);
+ if (retstr == NULL)
return FAIL;
ga_init2(&ga, (int)sizeof(char *), 3);
- for (s = all; *s != NUL; s = e)
+ for (s = retstr; *s != NUL; s = e)
{
e = vim_strchr(s, '\n');
if (e == NULL)
@@ -4258,7 +4286,45 @@ ExpandUserDefined(xp, regmatch, num_file, file)
if (*e != NUL)
++e;
}
- vim_free(all);
+ vim_free(retstr);
+ *file = ga.ga_data;
+ *num_file = ga.ga_len;
+ return OK;
+}
+
+/*
+ * Expand names with a list returned by a function defined by the user.
+ */
+ static int
+ExpandUserList(xp, num_file, file)
+ expand_T *xp;
+ int *num_file;
+ char_u ***file;
+{
+ list_T *retlist;
+ listitem_T *li;
+ garray_T ga;
+
+ retlist = call_user_expand_func(call_func_retlist, xp, num_file, file);
+ if (retlist == NULL)
+ return FAIL;
+
+ ga_init2(&ga, (int)sizeof(char *), 3);
+ /* Loop over the items in the list. */
+ for (li = retlist->lv_first; li != NULL; li = li->li_next)
+ {
+ if (li->li_tv.v_type != VAR_STRING)
+ continue; /* Skip non-string items */
+
+ if (ga_grow(&ga, 1) == FAIL)
+ break;
+
+ ((char_u **)ga.ga_data)[ga.ga_len] =
+ vim_strsave(li->li_tv.vval.v_string);
+ ++ga.ga_len;
+ }
+ list_unref(retlist);
+
*file = ga.ga_data;
*num_file = ga.ga_len;
return OK;
diff --git a/src/mbyte.c b/src/mbyte.c
index ef091e378..ff165fa1d 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -201,67 +201,117 @@ enc_canon_table[] =
{"iso-8859-6", ENC_8BIT, 0},
#define IDX_ISO_7 6
{"iso-8859-7", ENC_8BIT, 0},
-#define IDX_CP1255 7
- {"cp1255", ENC_8BIT, 1255}, /* close to iso-8859-8 */
-#define IDX_ISO_8 8
+#define IDX_ISO_8 7
{"iso-8859-8", ENC_8BIT, 0},
-#define IDX_ISO_9 9
+#define IDX_ISO_9 8
{"iso-8859-9", ENC_8BIT, 0},
-#define IDX_ISO_10 10
+#define IDX_ISO_10 9
{"iso-8859-10", ENC_8BIT, 0},
-#define IDX_ISO_11 11
+#define IDX_ISO_11 10
{"iso-8859-11", ENC_8BIT, 0},
-#define IDX_ISO_13 12
+#define IDX_ISO_13 11
{"iso-8859-13", ENC_8BIT, 0},
-#define IDX_ISO_14 13
+#define IDX_ISO_14 12
{"iso-8859-14", ENC_8BIT, 0},
-#define IDX_ISO_15 14
+#define IDX_ISO_15 13
{"iso-8859-15", ENC_8BIT + ENC_LATIN9, 0},
-#define IDX_KOI8_R 15
+#define IDX_KOI8_R 14
{"koi8-r", ENC_8BIT, 0},
-#define IDX_KOI8_U 16
+#define IDX_KOI8_U 15
{"koi8-u", ENC_8BIT, 0},
-#define IDX_UTF8 17
+#define IDX_UTF8 16
{"utf-8", ENC_UNICODE, 0},
-#define IDX_UCS2 18
+#define IDX_UCS2 17
{"ucs-2", ENC_UNICODE + ENC_ENDIAN_B + ENC_2BYTE, 0},
-#define IDX_UCS2LE 19
+#define IDX_UCS2LE 18
{"ucs-2le", ENC_UNICODE + ENC_ENDIAN_L + ENC_2BYTE, 0},
-#define IDX_UTF16 20
+#define IDX_UTF16 19
{"utf-16", ENC_UNICODE + ENC_ENDIAN_B + ENC_2WORD, 0},
-#define IDX_UTF16LE 21
+#define IDX_UTF16LE 20
{"utf-16le", ENC_UNICODE + ENC_ENDIAN_L + ENC_2WORD, 0},
-#define IDX_UCS4 22
+#define IDX_UCS4 21
{"ucs-4", ENC_UNICODE + ENC_ENDIAN_B + ENC_4BYTE, 0},
-#define IDX_UCS4LE 23
+#define IDX_UCS4LE 22
{"ucs-4le", ENC_UNICODE + ENC_ENDIAN_L + ENC_4BYTE, 0},
-#define IDX_DEBUG 24
+
+ /* For debugging DBCS encoding on Unix. */
+#define IDX_DEBUG 23
{"debug", ENC_DBCS, DBCS_DEBUG},
-#define IDX_CP932 25
- {"cp932", ENC_DBCS, DBCS_JPN},
-#define IDX_CP949 26
- {"cp949", ENC_DBCS, DBCS_KOR},
-#define IDX_CP936 27
- {"cp936", ENC_DBCS, DBCS_CHS},
-#define IDX_CP950 28
- {"cp950", ENC_DBCS, DBCS_CHT},
-#define IDX_EUC_JP 29
+#define IDX_EUC_JP 24
{"euc-jp", ENC_DBCS, DBCS_JPNU},
-#define IDX_SJIS 30
+#define IDX_SJIS 25
{"sjis", ENC_DBCS, DBCS_JPN},
-#define IDX_EUC_KR 31
+#define IDX_EUC_KR 26
{"euc-kr", ENC_DBCS, DBCS_KORU},
-#define IDX_EUC_CN 32
+#define IDX_EUC_CN 27
{"euc-cn", ENC_DBCS, DBCS_CHSU},
-#define IDX_EUC_TW 33
+#define IDX_EUC_TW 28
{"euc-tw", ENC_DBCS, DBCS_CHTU},
-#define IDX_BIG5 34
+#define IDX_BIG5 29
{"big5", ENC_DBCS, DBCS_CHT},
-#define IDX_CP1251 35
- {"cp1251", ENC_8BIT, 1251},
-#define IDX_MACROMAN 36
- {"macroman", ENC_8BIT + ENC_MACROMAN, 0},
-#define IDX_COUNT 37
+
+ /* MS-DOS and MS-Windows codepages are included here, so that they can be
+ * used on Unix too. Most of them are similar to ISO-8859 encodings, but
+ * not exactly the same. */
+#define IDX_CP437 30
+ {"cp437", ENC_8BIT, 437}, /* like iso-8859-1 */
+#define IDX_CP737 31
+ {"cp737", ENC_8BIT, 737}, /* like iso-8859-7 */
+#define IDX_CP775 32
+ {"cp775", ENC_8BIT, 775}, /* Baltic */
+#define IDX_CP850 33
+ {"cp850", ENC_8BIT, 850}, /* like iso-8859-4 */
+#define IDX_CP852 34
+ {"cp852", ENC_8BIT, 852}, /* like iso-8859-1 */
+#define IDX_CP855 35
+ {"cp855", ENC_8BIT, 855}, /* like iso-8859-2 */
+#define IDX_CP857 36
+ {"cp857", ENC_8BIT, 857}, /* like iso-8859-5 */
+#define IDX_CP860 37
+ {"cp860", ENC_8BIT, 860}, /* like iso-8859-9 */
+#define IDX_CP861 38
+ {"cp861", ENC_8BIT, 861}, /* like iso-8859-1 */
+#define IDX_CP862 39
+ {"cp862", ENC_8BIT, 862}, /* like iso-8859-1 */
+#define IDX_CP863 40
+ {"cp863", ENC_8BIT, 863}, /* like iso-8859-8 */
+#define IDX_CP865 41
+ {"cp865", ENC_8BIT, 865}, /* like iso-8859-1 */
+#define IDX_CP866 42
+ {"cp866", ENC_8BIT, 866}, /* like iso-8859-5 */
+#define IDX_CP869 43
+ {"cp869", ENC_8BIT, 869}, /* like iso-8859-7 */
+#define IDX_CP874 44
+ {"cp874", ENC_8BIT, 874}, /* Thai */
+#define IDX_CP932 45
+ {"cp932", ENC_DBCS, DBCS_JPN},
+#define IDX_CP936 46
+ {"cp936", ENC_DBCS, DBCS_CHS},
+#define IDX_CP949 47
+ {"cp949", ENC_DBCS, DBCS_KOR},
+#define IDX_CP950 48
+ {"cp950", ENC_DBCS, DBCS_CHT},
+#define IDX_CP1250 49
+ {"cp1250", ENC_8BIT, 1250}, /* Czech, Polish, etc. */
+#define IDX_CP1251 50
+ {"cp1251", ENC_8BIT, 1251}, /* Cyrillic */
+ /* cp1252 is considered to be equal to latin1 */
+#define IDX_CP1253 51
+ {"cp1253", ENC_8BIT, 1253}, /* Greek */
+#define IDX_CP1254 52
+ {"cp1254", ENC_8BIT, 1254}, /* Turkish */
+#define IDX_CP1255 53
+ {"cp1255", ENC_8BIT, 1255}, /* Hebrew */
+#define IDX_CP1256 54
+ {"cp1256", ENC_8BIT, 1256}, /* Arabic */
+#define IDX_CP1257 55
+ {"cp1257", ENC_8BIT, 1257}, /* Baltic */
+#define IDX_CP1258 56
+ {"cp1258", ENC_8BIT, 1258}, /* Vietnamese */
+
+#define IDX_MACROMAN 57
+ {"macroman", ENC_8BIT + ENC_MACROMAN, 0}, /* Mac OS */
+#define IDX_COUNT 58
};
/*
@@ -2882,7 +2932,7 @@ enc_locale()
if (acp == 1200)
STRCPY(buf, "ucs-2le");
- else if (acp == 1252)
+ else if (acp == 1252) /* cp1252 is used as latin1 */
STRCPY(buf, "latin1");
else
sprintf(buf, "cp%ld", acp);
diff --git a/src/os_unix.c b/src/os_unix.c
index c269e8779..ce30a2db9 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4432,7 +4432,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
#endif
#ifdef MAY_LOOP
- while (1)
+ for (;;)
#endif
{
#ifdef MAY_LOOP
diff --git a/src/proto/eval.pro b/src/proto/eval.pro
index 9505ed027..1f8f21fc0 100644
--- a/src/proto/eval.pro
+++ b/src/proto/eval.pro
@@ -22,7 +22,8 @@ char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd));
int eval_to_number __ARGS((char_u *expr));
list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
int get_spellword __ARGS((list_T *list, char_u **pp));
-char_u *call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe));
+void *call_func_retstr __ARGS((char_u *func, int argc, char_u **argv, int safe));
+void *call_func_retlist __ARGS((char_u *func, int argc, char_u **argv, int safe));
void *save_funccal __ARGS((void));
void restore_funccal __ARGS((void *vfc));
void prof_child_enter __ARGS((proftime_T *tm));
diff --git a/src/undo.c b/src/undo.c
index e586e5633..53070af52 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -1372,7 +1372,7 @@ u_alloc_line(size)
/* In this block find a chunk with enough space. */
mprev = curbuf->b_m_search;
mp = curbuf->b_m_search->m_next;
- while (1)
+ for (;;)
{
if (mp == NULL) /* at end of the list */
mp = &(mbp->mb_info); /* wrap around to begin */
diff --git a/src/version.h b/src/version.h
index 833182209..bff24b212 100644
--- a/src/version.h
+++ b/src/version.h
@@ -36,5 +36,5 @@
#define VIM_VERSION_NODOT "vim70aa"
#define VIM_VERSION_SHORT "7.0aa"
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
-#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 8)"
-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 8, compiled "
+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 9)"
+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 9, compiled "