Skip to content

Commit a243813

Browse files
yegappanbrammool
authored andcommitted
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)
1 parent 31e2176 commit a243813

21 files changed

Lines changed: 1673 additions & 1627 deletions

Filelist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ SRC_ALL = \
134134
src/spell.h \
135135
src/spellfile.c \
136136
src/spellsuggest.c \
137+
src/strings.c \
137138
src/structs.h \
138139
src/syntax.c \
139140
src/tag.c \
@@ -296,6 +297,7 @@ SRC_ALL = \
296297
src/proto/spell.pro \
297298
src/proto/spellfile.pro \
298299
src/proto/spellsuggest.pro \
300+
src/proto/strings.pro \
299301
src/proto/syntax.pro \
300302
src/proto/tag.pro \
301303
src/proto/term.pro \

src/Make_ami.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ SRC += \
162162
spell.c \
163163
spellfile.c \
164164
spellsuggest.c \
165+
strings.c \
165166
syntax.c \
166167
tag.c \
167168
term.c \

src/Make_cyg_ming.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ OBJ = \
809809
$(OUTDIR)/spell.o \
810810
$(OUTDIR)/spellfile.o \
811811
$(OUTDIR)/spellsuggest.o \
812+
$(OUTDIR)/strings.o \
812813
$(OUTDIR)/syntax.o \
813814
$(OUTDIR)/tag.o \
814815
$(OUTDIR)/term.o \

src/Make_mvc.mak

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ OBJ = \
819819
$(OUTDIR)\spell.obj \
820820
$(OUTDIR)\spellfile.obj \
821821
$(OUTDIR)\spellsuggest.obj \
822+
$(OUTDIR)\strings.obj \
822823
$(OUTDIR)\syntax.obj \
823824
$(OUTDIR)\tag.obj \
824825
$(OUTDIR)\term.obj \
@@ -1792,6 +1793,8 @@ $(OUTDIR)/spellfile.obj: $(OUTDIR) spellfile.c $(INCL)
17921793

17931794
$(OUTDIR)/spellsuggest.obj: $(OUTDIR) spellsuggest.c $(INCL)
17941795

1796+
$(OUTDIR)/strings.obj: $(OUTDIR) strings.c $(INCL)
1797+
17951798
$(OUTDIR)/syntax.obj: $(OUTDIR) syntax.c $(INCL)
17961799

17971800
$(OUTDIR)/tag.obj: $(OUTDIR) tag.c $(INCL)
@@ -2012,6 +2015,7 @@ proto.h: \
20122015
proto/spell.pro \
20132016
proto/spellfile.pro \
20142017
proto/spellsuggest.pro \
2018+
proto/strings.pro \
20152019
proto/syntax.pro \
20162020
proto/tag.pro \
20172021
proto/term.pro \

src/Make_vms.mms

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ SRC = \
393393
spell.c \
394394
spellfile.c \
395395
spellsuggest.c \
396+
strings.c \
396397
syntax.c \
397398
tag.c \
398399
term.c \
@@ -512,6 +513,7 @@ OBJ = \
512513
spell.obj \
513514
spellfile.obj \
514515
spellsuggest.obj \
516+
strings.obj \
515517
syntax.obj \
516518
tag.obj \
517519
term.obj \
@@ -1048,6 +1050,10 @@ spellsuggest.obj : spellsuggest.c vim.h [.auto]config.h feature.h os_unix.h \
10481050
ascii.h keymap.h term.h macros.h option.h structs.h \
10491051
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
10501052
proto.h errors.h globals.h
1053+
strings.obj : strings.c vim.h [.auto]config.h feature.h os_unix.h \
1054+
ascii.h keymap.h term.h macros.h option.h structs.h \
1055+
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
1056+
proto.h errors.h globals.h
10511057
syntax.obj : syntax.c vim.h [.auto]config.h feature.h os_unix.h \
10521058
ascii.h keymap.h term.h macros.h structs.h regexp.h \
10531059
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \

src/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,7 @@ BASIC_SRC = \
16771677
spell.c \
16781678
spellfile.c \
16791679
spellsuggest.c \
1680+
strings.c \
16801681
syntax.c \
16811682
tag.c \
16821683
term.c \
@@ -1828,6 +1829,7 @@ OBJ_COMMON = \
18281829
objects/spell.o \
18291830
objects/spellfile.o \
18301831
objects/spellsuggest.o \
1832+
objects/strings.o \
18311833
objects/syntax.o \
18321834
objects/tag.o \
18331835
objects/term.o \
@@ -2011,6 +2013,7 @@ PRO_AUTO = \
20112013
spell.pro \
20122014
spellfile.pro \
20132015
spellsuggest.pro \
2016+
strings.pro \
20142017
syntax.pro \
20152018
tag.pro \
20162019
term.pro \
@@ -3516,6 +3519,9 @@ objects/spellfile.o: spellfile.c
35163519
objects/spellsuggest.o: spellsuggest.c
35173520
$(CCC) -o $@ spellsuggest.c
35183521

3522+
objects/strings.o: strings.c
3523+
$(CCC) -o $@ strings.c
3524+
35193525
objects/syntax.o: syntax.c
35203526
$(CCC) -o $@ syntax.c
35213527

@@ -4049,6 +4055,10 @@ objects/spellsuggest.o: spellsuggest.c vim.h protodef.h auto/config.h feature.h
40494055
os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
40504056
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
40514057
proto.h errors.h globals.h
4058+
objects/strings.o: strings.c vim.h protodef.h auto/config.h feature.h os_unix.h \
4059+
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
4060+
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
4061+
proto.h errors.h globals.h
40524062
objects/syntax.o: syntax.c vim.h protodef.h auto/config.h feature.h os_unix.h \
40534063
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
40544064
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ sign.c | signs
8080
spell.c | spell checking core
8181
spellfile.c | spell file handling
8282
spellsuggest.c | spell correction suggestions
83+
strings.c | string manipulation functions
8384
syntax.c | syntax and other highlighting
8485
tag.c | tags
8586
term.c | terminal handling, termcap codes

src/eval.c

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static int eval7_leader(typval_T *rettv, int numeric_only, char_u *start_leader,
5757

5858
static int free_unref_items(int copyID);
5959
static char_u *make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end);
60+
static char_u *eval_next_line(evalarg_T *evalarg);
6061

6162
/*
6263
* Return "n1" divided by "n2", taking care of dividing by zero.
@@ -2113,7 +2114,7 @@ getline_peek_skip_comments(evalarg_T *evalarg)
21132114
* FALSE.
21142115
* "arg" must point somewhere inside a line, not at the start.
21152116
*/
2116-
char_u *
2117+
static char_u *
21172118
eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
21182119
{
21192120
char_u *p = skipwhite(arg);
@@ -2144,7 +2145,7 @@ eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
21442145
* To be called after eval_next_non_blank() sets "getnext" to TRUE.
21452146
* Only called for Vim9 script.
21462147
*/
2147-
char_u *
2148+
static char_u *
21482149
eval_next_line(evalarg_T *evalarg)
21492150
{
21502151
garray_T *gap = &evalarg->eval_ga;
@@ -5171,50 +5172,6 @@ echo_string(
51715172
return echo_string_core(tv, tofree, numbuf, copyID, TRUE, FALSE, FALSE);
51725173
}
51735174

5174-
/*
5175-
* Return string "str" in ' quotes, doubling ' characters.
5176-
* If "str" is NULL an empty string is assumed.
5177-
* If "function" is TRUE make it function('string').
5178-
*/
5179-
char_u *
5180-
string_quote(char_u *str, int function)
5181-
{
5182-
unsigned len;
5183-
char_u *p, *r, *s;
5184-
5185-
len = (function ? 13 : 3);
5186-
if (str != NULL)
5187-
{
5188-
len += (unsigned)STRLEN(str);
5189-
for (p = str; *p != NUL; MB_PTR_ADV(p))
5190-
if (*p == '\'')
5191-
++len;
5192-
}
5193-
s = r = alloc(len);
5194-
if (r != NULL)
5195-
{
5196-
if (function)
5197-
{
5198-
STRCPY(r, "function('");
5199-
r += 10;
5200-
}
5201-
else
5202-
*r++ = '\'';
5203-
if (str != NULL)
5204-
for (p = str; *p != NUL; )
5205-
{
5206-
if (*p == '\'')
5207-
*r++ = '\'';
5208-
MB_COPY_CHAR(p, r);
5209-
}
5210-
*r++ = '\'';
5211-
if (function)
5212-
*r++ = ')';
5213-
*r++ = NUL;
5214-
}
5215-
return s;
5216-
}
5217-
52185175
/*
52195176
* Convert the specified byte index of line 'lnum' in buffer 'buf' to a
52205177
* character index. Works only for loaded buffers. Returns -1 on failure.

0 commit comments

Comments
 (0)