robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Jan Edmund Lazovim-patch:8.2.0098: exe stack length can be wrong without being detected (#37136)c81f7aeee2

master
2.4 KiB63 linesraw
1#pragma once
2
3#include <stddef.h>  // IWYU pragma: keep
4
5#include "nvim/api/private/defs.h"  // IWYU pragma: keep
6#include "nvim/cmdexpand_defs.h"  // IWYU pragma: keep
7#include "nvim/eval/typval_defs.h"  // IWYU pragma: keep
8#include "nvim/ex_cmds_defs.h"  // IWYU pragma: keep
9#include "nvim/garray_defs.h"
10#include "nvim/option_defs.h"  // IWYU pragma: keep
11#include "nvim/pos_defs.h"  // IWYU pragma: keep
12#include "nvim/runtime_defs.h"  // IWYU pragma: keep
13#include "nvim/types_defs.h"  // IWYU pragma: keep
14
15/// Stack of execution contexts.  Each entry is an estack_T.
16/// Current context is at ga_len - 1.
17extern garray_T exestack;
18#define HAVE_SOURCING_INFO  (exestack.ga_data != NULL && exestack.ga_len > 0)
19/// name of error message source
20#define SOURCING_NAME (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_name)
21/// line number in the message source or zero
22#define SOURCING_LNUM (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_lnum)
23
24/// Growarray to store info about already sourced scripts.
25extern garray_T script_items;
26#define SCRIPT_ITEM(id) (((scriptitem_T **)script_items.ga_data)[(id) - 1])
27#define SCRIPT_ID_VALID(id) ((id) > 0 && (id) <= script_items.ga_len)
28
29/// last argument for do_source()
30enum {
31  DOSO_NONE = 0,
32  DOSO_VIMRC = 1,  ///< loading vimrc file
33};
34
35/// Used for flags in do_in_path()
36enum {
37  DIP_ALL     = 0x01,   ///< all matches, not just the first one
38  DIP_DIR     = 0x02,   ///< find directories instead of files
39  DIP_ERR     = 0x04,   ///< give an error message when none found
40  DIP_START   = 0x08,   ///< also use "start" directory in 'packpath'
41  DIP_OPT     = 0x10,   ///< also use "opt" directory in 'packpath'
42  DIP_NORTP   = 0x20,   ///< do not use 'runtimepath'
43  DIP_NOAFTER = 0x40,   ///< skip "after" directories
44  DIP_AFTER   = 0x80,   ///< only use "after" directories
45  DIP_DIRFILE = 0x200,  ///< find both files and directories
46};
47
48#ifdef ABORT_ON_INTERNAL_ERROR
49# define ESTACK_CHECK_DECLARATION int estack_len_before
50# define ESTACK_CHECK_SETUP do { estack_len_before = exestack.ga_len; } while (0)
51# define ESTACK_CHECK_NOW \
52  do { \
53    if (estack_len_before != exestack.ga_len) { \
54      siemsg("Exestack length expected: %d, actual: %d", estack_len_before, exestack.ga_len); \
55    } \
56  } while (0)
57#else
58# define ESTACK_CHECK_DECLARATION do {} while (0)
59# define ESTACK_CHECK_SETUP do {} while (0)
60# define ESTACK_CHECK_NOW do {} while (0)
61#endif
62
63#include "runtime.h.generated.h"