mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
Statically allocate NameBuff
This commit is contained in:
parent
845d1bfa90
commit
9453b7230b
@ -5156,7 +5156,11 @@ void fix_help_buffer(void)
|
||||
/* Find all "doc/ *.txt" files in this directory. */
|
||||
add_pathsep(NameBuff);
|
||||
STRCAT(NameBuff, "doc/*.??[tx]");
|
||||
if (gen_expand_wildcards(1, &NameBuff, &fcount,
|
||||
|
||||
// Note: We cannot just do `&NameBuff` because it is a statically sized array
|
||||
// so `NameBuff == &NameBuff` according to C semantics.
|
||||
char_u *buff_list[1] = {(char_u*) NameBuff};
|
||||
if (gen_expand_wildcards(1, buff_list, &fcount,
|
||||
&fnames, EW_FILE|EW_SILENT) == OK
|
||||
&& fcount > 0) {
|
||||
int i1;
|
||||
@ -5324,7 +5328,11 @@ void ex_helptags(exarg_T *eap)
|
||||
STRCPY(NameBuff, dirname);
|
||||
add_pathsep(NameBuff);
|
||||
STRCAT(NameBuff, "**");
|
||||
if (gen_expand_wildcards(1, &NameBuff, &filecount, &files,
|
||||
|
||||
// Note: We cannot just do `&NameBuff` because it is a statically sized array
|
||||
// so `NameBuff == &NameBuff` according to C semantics.
|
||||
char_u *buff_list[1] = {(char_u*) NameBuff};
|
||||
if (gen_expand_wildcards(1, buff_list, &filecount, &files,
|
||||
EW_FILE|EW_SILENT) == FAIL
|
||||
|| filecount == 0) {
|
||||
EMSG2("E151: No match: %s", NameBuff);
|
||||
@ -5422,7 +5430,11 @@ helptags_one (
|
||||
STRCPY(NameBuff, dir);
|
||||
STRCAT(NameBuff, "/**/*");
|
||||
STRCAT(NameBuff, ext);
|
||||
if (gen_expand_wildcards(1, &NameBuff, &filecount, &files,
|
||||
|
||||
// Note: We cannot just do `&NameBuff` because it is a statically sized array
|
||||
// so `NameBuff == &NameBuff` according to C semantics.
|
||||
char_u *buff_list[1] = {(char_u*) NameBuff};
|
||||
if (gen_expand_wildcards(1, buff_list, &filecount, &files,
|
||||
EW_FILE|EW_SILENT) == FAIL
|
||||
|| filecount == 0) {
|
||||
if (!got_int)
|
||||
|
@ -40,6 +40,20 @@
|
||||
# define MSG_BUF_CLEN (MSG_BUF_LEN / 6) // cell length (worst case: utf-8
|
||||
// takes 6 bytes for one cell)
|
||||
|
||||
/*
|
||||
* Maximum length of a path (for non-unix systems) Make it a bit long, to stay
|
||||
* on the safe side. But not too long to put on the stack.
|
||||
* TODO(metrix78): Move this to os_defs.h
|
||||
*/
|
||||
#ifndef MAXPATHL
|
||||
# ifdef MAXPATHLEN
|
||||
# define MAXPATHL MAXPATHLEN
|
||||
# else
|
||||
# define MAXPATHL 256
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Values for "starting" */
|
||||
#define NO_SCREEN 2 /* no screen updating yet */
|
||||
#define NO_BUFFERS 1 /* not all buffers loaded yet */
|
||||
@ -841,11 +855,9 @@ EXTERN int swap_exists_action INIT(= SEA_NONE);
|
||||
EXTERN int swap_exists_did_quit INIT(= FALSE);
|
||||
/* Selected "quit" at the dialog. */
|
||||
|
||||
EXTERN char_u IObuff[IOSIZE]; /* sprintf's are done in this buffer,
|
||||
size is IOSIZE */
|
||||
EXTERN char_u *NameBuff; /* file names are expanded in this
|
||||
* buffer, size is MAXPATHL */
|
||||
EXTERN char_u msg_buf[MSG_BUF_LEN]; /* small buffer for messages */
|
||||
EXTERN char_u IObuff[IOSIZE]; /* sprintf's are done in this buffer */
|
||||
EXTERN char_u NameBuff[MAXPATHL]; /* buffer for expanding file names */
|
||||
EXTERN char_u msg_buf[MSG_BUF_LEN]; /* small buffer for messages */
|
||||
|
||||
/* When non-zero, postpone redrawing. */
|
||||
EXTERN int RedrawingDisabled INIT(= 0);
|
||||
|
@ -144,10 +144,6 @@ int main(int argc, char **argv)
|
||||
char_u *fname = NULL; /* file name from command line */
|
||||
mparm_T params; /* various parameters passed between
|
||||
* main() and other functions. */
|
||||
/*
|
||||
* Do any system-specific initialisations. These can NOT use IObuff or
|
||||
* NameBuff. Thus emsg2() cannot be called!
|
||||
*/
|
||||
mch_early_init();
|
||||
|
||||
/* Many variables are in "params" so that we can pass them to invoked
|
||||
@ -167,12 +163,6 @@ int main(int argc, char **argv)
|
||||
/* Init the table of Normal mode commands. */
|
||||
init_normal_cmds();
|
||||
|
||||
/*
|
||||
* Allocate space for the generic buffers (needed for set_init_1() and
|
||||
* EMSG2()).
|
||||
*/
|
||||
allocate_generic_buffers();
|
||||
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
/*
|
||||
* Setup to use the current locale (for ctype() and many other things).
|
||||
@ -1476,16 +1466,6 @@ static void init_startuptime(mparm_T *paramp)
|
||||
starttime = time(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate space for the generic buffers (needed for set_init_1() and
|
||||
* EMSG2()).
|
||||
*/
|
||||
static void allocate_generic_buffers(void)
|
||||
{
|
||||
NameBuff = xmalloc(MAXPATHL);
|
||||
TIME_MSG("Allocated generic buffers");
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we have an interactive window.
|
||||
* On the Amiga: If there is no window, we open one with a newcli command
|
||||
|
@ -510,8 +510,6 @@ void free_all_mem(void)
|
||||
free_screenlines();
|
||||
|
||||
clear_hl_tables();
|
||||
|
||||
free(NameBuff);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -3540,7 +3540,11 @@ void ex_helpgrep(exarg_T *eap)
|
||||
/* Find all "*.txt" and "*.??x" files in the "doc" directory. */
|
||||
add_pathsep(NameBuff);
|
||||
STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)");
|
||||
if (gen_expand_wildcards(1, &NameBuff, &fcount,
|
||||
|
||||
// Note: We cannot just do `&NameBuff` because it is a statically sized array
|
||||
// so `NameBuff == &NameBuff` according to C semantics.
|
||||
char_u *buff_list[1] = {(char_u*) NameBuff};
|
||||
if (gen_expand_wildcards(1, buff_list, &fcount,
|
||||
&fnames, EW_FILE|EW_SILENT) == OK
|
||||
&& fcount > 0) {
|
||||
for (fi = 0; fi < fcount && !got_int; ++fi) {
|
||||
|
@ -60,7 +60,11 @@ void vim_deltempdir(void)
|
||||
|
||||
char_u **files;
|
||||
int file_count;
|
||||
if (gen_expand_wildcards(1, &NameBuff, &file_count, &files,
|
||||
|
||||
// Note: We cannot just do `&NameBuff` because it is a statically
|
||||
// sized array so `NameBuff == &NameBuff` according to C semantics.
|
||||
char_u *buff_list[1] = {(char_u*) NameBuff};
|
||||
if (gen_expand_wildcards(1, buff_list, &file_count, &files,
|
||||
EW_DIR|EW_FILE|EW_SILENT) == OK) {
|
||||
for (int i = 0; i < file_count; ++i) {
|
||||
os_remove((char *)files[i]);
|
||||
|
@ -45,18 +45,6 @@ Error: configure did not run properly.Check auto/config.log.
|
||||
|
||||
#include "nvim/os_unix_defs.h" /* bring lots of system header files */
|
||||
|
||||
/*
|
||||
* Maximum length of a path (for non-unix systems) Make it a bit long, to stay
|
||||
* on the safe side. But not too long to put on the stack.
|
||||
*/
|
||||
#ifndef MAXPATHL
|
||||
# ifdef MAXPATHLEN
|
||||
# define MAXPATHL MAXPATHLEN
|
||||
# else
|
||||
# define MAXPATHL 256
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */
|
||||
|
||||
# define MAX_TYPENR 65535
|
||||
|
@ -6,10 +6,7 @@ local tempfile = helpers.cimport './src/nvim/tempfile.h'
|
||||
|
||||
describe('tempfile related functions', function()
|
||||
after_each(function()
|
||||
-- This won't work because vim_deltempdir() uses global buffer
|
||||
-- that is initialized in main() and main() is not called for unit tests.
|
||||
-- But it is not a big problem: all tests can work with or without it.
|
||||
-- tempfile.vim_deltempdir()
|
||||
tempfile.vim_deltempdir()
|
||||
end)
|
||||
|
||||
local vim_gettempdir = function()
|
||||
|
Loading…
Reference in New Issue
Block a user