Skip to content

Commit 748b308

Browse files
dpellebrammool
authored andcommitted
patch 8.2.4038: various code not used when features are disabled
Problem: Various code not used when features are disabled. Solution: Add #ifdefs. (Dominique Pellé, closes #9491)
1 parent 3707914 commit 748b308

35 files changed

+126
-74
lines changed

src/alloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ alloc(size_t size)
151151
return lalloc(size, TRUE);
152152
}
153153

154+
#if defined(FEAT_QUICKFIX) || defined(PROTO)
154155
/*
155156
* alloc() with an ID for alloc_fail().
156157
*/
@@ -163,6 +164,7 @@ alloc_id(size_t size, alloc_id_T id UNUSED)
163164
#endif
164165
return lalloc(size, TRUE);
165166
}
167+
#endif
166168

167169
/*
168170
* Allocate memory and set all bytes to zero.
@@ -178,6 +180,7 @@ alloc_clear(size_t size)
178180
return p;
179181
}
180182

183+
#if defined(FEAT_SIGNS) || defined(PROTO)
181184
/*
182185
* Same as alloc_clear() but with allocation id for testing
183186
*/
@@ -190,6 +193,7 @@ alloc_clear_id(size_t size, alloc_id_T id UNUSED)
190193
#endif
191194
return alloc_clear(size);
192195
}
196+
#endif
193197

194198
/*
195199
* Allocate memory like lalloc() and set all bytes to zero.
@@ -648,6 +652,7 @@ ga_clear_strings(garray_T *gap)
648652
ga_clear(gap);
649653
}
650654

655+
#if defined(FEAT_EVAL) || defined(PROTO)
651656
/*
652657
* Copy a growing array that contains a list of strings.
653658
*/
@@ -682,6 +687,7 @@ ga_copy_strings(garray_T *from, garray_T *to)
682687
to->ga_len = from->ga_len;
683688
return OK;
684689
}
690+
#endif
685691

686692
/*
687693
* Initialize a growing array. Don't forget to set ga_itemsize and

src/buffer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ read_buffer(
138138
return retval;
139139
}
140140

141+
#if defined(FEAT_EVAL) || defined(PROTO)
141142
/*
142143
* Ensure buffer "buf" is loaded. Does not trigger the swap-exists action.
143144
*/
@@ -154,6 +155,7 @@ buffer_ensure_loaded(buf_T *buf)
154155
aucmd_restbuf(&aco);
155156
}
156157
}
158+
#endif
157159

158160
/*
159161
* Open current buffer, that is: open the memfile and read the file into
@@ -5609,6 +5611,7 @@ bt_prompt(buf_T *buf)
56095611
return buf != NULL && buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'r';
56105612
}
56115613

5614+
#if defined(FEAT_PROP_POPUP) || defined(PROTO)
56125615
/*
56135616
* Return TRUE if "buf" is a buffer for a popup window.
56145617
*/
@@ -5618,6 +5621,7 @@ bt_popup(buf_T *buf)
56185621
return buf != NULL && buf->b_p_bt != NULL
56195622
&& buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'o';
56205623
}
5624+
#endif
56215625

56225626
/*
56235627
* Return TRUE if "buf" is a "nofile", "acwrite", "terminal" or "prompt"
@@ -5632,6 +5636,7 @@ bt_nofilename(buf_T *buf)
56325636
|| buf->b_p_bt[0] == 'p');
56335637
}
56345638

5639+
#if defined(FEAT_QUICKFIX) || defined(PROTO)
56355640
/*
56365641
* Return TRUE if "buf" has 'buftype' set to "nofile".
56375642
*/
@@ -5640,6 +5645,7 @@ bt_nofile(buf_T *buf)
56405645
{
56415646
return buf != NULL && buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f';
56425647
}
5648+
#endif
56435649

56445650
/*
56455651
* Return TRUE if "buf" is a "nowrite", "nofile", "terminal" or "prompt"

src/charset.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ skipwhite(char_u *q)
14761476
return p;
14771477
}
14781478

1479+
#if defined(FEAT_EVAL) || defined(PROTO)
14791480
/*
14801481
* skip over ' ', '\t' and '\n'.
14811482
*/
@@ -1488,6 +1489,7 @@ skipwhite_and_nl(char_u *q)
14881489
++p;
14891490
return p;
14901491
}
1492+
#endif
14911493

14921494
/*
14931495
* getwhitecols: return the number of whitespace

src/clipboard.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,7 @@ clip_x11_notify_cb(Widget w UNUSED, Atom *sel_atom UNUSED, Atom *target UNUSED)
15401540
/*
15411541
* Property callback to get a timestamp for XtOwnSelection.
15421542
*/
1543+
# if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO)
15431544
static void
15441545
clip_x11_timestamp_cb(
15451546
Widget w,
@@ -1592,6 +1593,7 @@ x11_setup_selection(Widget w)
15921593
XtAddEventHandler(w, PropertyChangeMask, False,
15931594
/*(XtEventHandler)*/clip_x11_timestamp_cb, (XtPointer)NULL);
15941595
}
1596+
# endif
15951597

15961598
static void
15971599
clip_x11_request_selection_cb(

src/cmdhist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,27 @@ get_histentry(int hist_type)
3737
return history[hist_type];
3838
}
3939

40+
#if defined(FEAT_VIMINFO) || defined(PROTO)
4041
void
4142
set_histentry(int hist_type, histentry_T *entry)
4243
{
4344
history[hist_type] = entry;
4445
}
46+
#endif
4547

4648
int *
4749
get_hisidx(int hist_type)
4850
{
4951
return &hisidx[hist_type];
5052
}
5153

54+
#if defined(FEAT_VIMINFO) || defined(PROTO)
5255
int *
5356
get_hisnum(int hist_type)
5457
{
5558
return &hisnum[hist_type];
5659
}
60+
#endif
5761

5862
/*
5963
* Translate a history character to the associated type number.

src/crypt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ crypt_get_header_len(int method_nr)
247247
}
248248

249249

250+
#if defined(FEAT_SODIUM) || defined(PROTO)
250251
/*
251252
* Get maximum crypt method specific length of the file header in bytes.
252253
*/
@@ -265,6 +266,7 @@ crypt_get_max_header_len()
265266
}
266267
return max;
267268
}
269+
#endif
268270

269271
/*
270272
* Set the crypt method for buffer "buf" to "method_nr" using the int value as

src/edit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,7 @@ edit_putchar(int c, int highlight)
17151715
}
17161716
}
17171717

1718+
#if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
17181719
/*
17191720
* Set the insert start position for when using a prompt buffer.
17201721
*/
@@ -1728,6 +1729,7 @@ set_insstart(linenr_T lnum, int col)
17281729
Insstart_blank_vcol = MAXCOL;
17291730
arrow_used = FALSE;
17301731
}
1732+
#endif
17311733

17321734
/*
17331735
* Undo the previous edit_putchar().

src/eval.c

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -653,50 +653,10 @@ call_vim_function(
653653
return ret;
654654
}
655655

656-
/*
657-
* Call Vim script function "func" and return the result as a number.
658-
* Returns -1 when calling the function fails.
659-
* Uses argv[0] to argv[argc - 1] for the function arguments. argv[argc] should
660-
* have type VAR_UNKNOWN.
661-
*/
662-
varnumber_T
663-
call_func_retnr(
664-
char_u *func,
665-
int argc,
666-
typval_T *argv)
667-
{
668-
typval_T rettv;
669-
varnumber_T retval;
670-
671-
if (call_vim_function(func, argc, argv, &rettv) == FAIL)
672-
return -1;
673-
674-
retval = tv_get_number_chk(&rettv, NULL);
675-
clear_tv(&rettv);
676-
return retval;
677-
}
678-
679-
/*
680-
* Call Vim script function like call_func_retnr() and drop the result.
681-
* Returns FAIL when calling the function fails.
682-
*/
683-
int
684-
call_func_noret(
685-
char_u *func,
686-
int argc,
687-
typval_T *argv)
688-
{
689-
typval_T rettv;
690-
691-
if (call_vim_function(func, argc, argv, &rettv) == FAIL)
692-
return FAIL;
693-
clear_tv(&rettv);
694-
return OK;
695-
}
696-
697656
/*
698657
* Call Vim script function "func" and return the result as a string.
699-
* Uses "argv" and "argc" as call_func_retnr().
658+
* Uses "argv[0]" to "argv[argc - 1]" for the function arguments. "argv[argc]"
659+
* should have type VAR_UNKNOWN.
700660
* Returns NULL when calling the function fails.
701661
*/
702662
void *
@@ -718,7 +678,7 @@ call_func_retstr(
718678

719679
/*
720680
* Call Vim script function "func" and return the result as a List.
721-
* Uses "argv" and "argc" as call_func_retnr().
681+
* Uses "argv" and "argc" as call_func_retstr().
722682
* Returns NULL when there is something wrong.
723683
*/
724684
void *
@@ -4783,6 +4743,8 @@ set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack)
47834743
return abort;
47844744
}
47854745

4746+
#if defined(FEAT_LUA) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
4747+
|| defined(PROTO)
47864748
/*
47874749
* Mark a dict and its items with "copyID".
47884750
* Returns TRUE if setting references failed somehow.
@@ -4797,6 +4759,7 @@ set_ref_in_dict(dict_T *d, int copyID)
47974759
}
47984760
return FALSE;
47994761
}
4762+
#endif
48004763

48014764
/*
48024765
* Mark a list and its items with "copyID".

src/evalbuffer.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,7 @@ f_setline(typval_T *argvars, typval_T *rettv)
864864
}
865865
#endif // FEAT_EVAL
866866

867-
#if defined(FEAT_JOB_CHANNEL) \
868-
|| defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
869-
|| defined(PROTO)
867+
#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
870868
/*
871869
* Make "buf" the current buffer. restore_buffer() MUST be called to undo.
872870
* No autocommands will be executed. Use aucmd_prepbuf() if there are any.

src/evalfunc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,6 +3529,7 @@ execute_redir_str(char_u *value, int value_len)
35293529
}
35303530
}
35313531

3532+
#if defined(FEAT_LUA) || defined(PROTO)
35323533
/*
35333534
* Get next line from a string containing NL separated lines.
35343535
* Called by do_cmdline() to get the next line.
@@ -3570,6 +3571,7 @@ execute_cmds_from_string(char_u *str)
35703571
do_cmdline(NULL, get_str_line, (void *)&str,
35713572
DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED);
35723573
}
3574+
#endif
35733575

35743576
/*
35753577
* Get next line from a list.

0 commit comments

Comments
 (0)