mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.3139: functions for string manipulation are spread out
Problem: Functions for string manipulation are spread out. Solution: Move string related functions to a new source file. (Yegappan Lakshmanan, closes #8470)
This commit is contained in:
committed by
Bram Moolenaar
parent
31e21766d6
commit
a2438132a6
49
src/eval.c
49
src/eval.c
@@ -57,6 +57,7 @@ static int eval7_leader(typval_T *rettv, int numeric_only, char_u *start_leader,
|
||||
|
||||
static int free_unref_items(int copyID);
|
||||
static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end);
|
||||
static char_u *eval_next_line(evalarg_T *evalarg);
|
||||
|
||||
/*
|
||||
* Return "n1" divided by "n2", taking care of dividing by zero.
|
||||
@@ -2113,7 +2114,7 @@ getline_peek_skip_comments(evalarg_T *evalarg)
|
||||
* FALSE.
|
||||
* "arg" must point somewhere inside a line, not at the start.
|
||||
*/
|
||||
char_u *
|
||||
static char_u *
|
||||
eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
|
||||
{
|
||||
char_u *p = skipwhite(arg);
|
||||
@@ -2144,7 +2145,7 @@ eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
|
||||
* To be called after eval_next_non_blank() sets "getnext" to TRUE.
|
||||
* Only called for Vim9 script.
|
||||
*/
|
||||
char_u *
|
||||
static char_u *
|
||||
eval_next_line(evalarg_T *evalarg)
|
||||
{
|
||||
garray_T *gap = &evalarg->eval_ga;
|
||||
@@ -5171,50 +5172,6 @@ echo_string(
|
||||
return echo_string_core(tv, tofree, numbuf, copyID, TRUE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return string "str" in ' quotes, doubling ' characters.
|
||||
* If "str" is NULL an empty string is assumed.
|
||||
* If "function" is TRUE make it function('string').
|
||||
*/
|
||||
char_u *
|
||||
string_quote(char_u *str, int function)
|
||||
{
|
||||
unsigned len;
|
||||
char_u *p, *r, *s;
|
||||
|
||||
len = (function ? 13 : 3);
|
||||
if (str != NULL)
|
||||
{
|
||||
len += (unsigned)STRLEN(str);
|
||||
for (p = str; *p != NUL; MB_PTR_ADV(p))
|
||||
if (*p == '\'')
|
||||
++len;
|
||||
}
|
||||
s = r = alloc(len);
|
||||
if (r != NULL)
|
||||
{
|
||||
if (function)
|
||||
{
|
||||
STRCPY(r, "function('");
|
||||
r += 10;
|
||||
}
|
||||
else
|
||||
*r++ = '\'';
|
||||
if (str != NULL)
|
||||
for (p = str; *p != NUL; )
|
||||
{
|
||||
if (*p == '\'')
|
||||
*r++ = '\'';
|
||||
MB_COPY_CHAR(p, r);
|
||||
}
|
||||
*r++ = '\'';
|
||||
if (function)
|
||||
*r++ = ')';
|
||||
*r++ = NUL;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the specified byte index of line 'lnum' in buffer 'buf' to a
|
||||
* character index. Works only for loaded buffers. Returns -1 on failure.
|
||||
|
Reference in New Issue
Block a user