mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
fix(autocmd): API functions accept garbage after event name #25523
"VimEnter foo" was accepted as a valid event name for "VimEnter". Events delimited with commas, eg. "VimEnter,BufRead", were also accepted, even though only the first event was actually parsed. Co-authored-by: ii14 <ii14@users.noreply.github.com>
This commit is contained in:
@@ -597,9 +597,9 @@ bool is_aucmd_win(win_T *win)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the event number for event name "start".
|
||||
// Return NUM_EVENTS if the event name was not found.
|
||||
// Return a pointer to the next event name in "end".
|
||||
/// Return the event number for event name "start".
|
||||
/// Return NUM_EVENTS if the event name was not found.
|
||||
/// Return a pointer to the next event name in "end".
|
||||
event_T event_name2nr(const char *start, char **end)
|
||||
{
|
||||
const char *p;
|
||||
@@ -623,6 +623,18 @@ event_T event_name2nr(const char *start, char **end)
|
||||
return event_names[i].event;
|
||||
}
|
||||
|
||||
/// Return the event number for event name "str".
|
||||
/// Return NUM_EVENTS if the event name was not found.
|
||||
event_T event_name2nr_str(String str)
|
||||
{
|
||||
for (int i = 0; event_names[i].name != NULL; i++) {
|
||||
if (str.size == event_names[i].len && STRNICMP(str.data, event_names[i].name, str.size) == 0) {
|
||||
return event_names[i].event;
|
||||
}
|
||||
}
|
||||
return NUM_EVENTS;
|
||||
}
|
||||
|
||||
/// Return the name for event
|
||||
///
|
||||
/// @param[in] event Event to return name for.
|
||||
|
Reference in New Issue
Block a user