From 184d5e75434f52170df930dcb6928014d03a7081 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 3 Oct 2024 10:34:55 +0800 Subject: [PATCH] refactor: fix incorrect use of enum (#30631) --- src/nvim/ex_cmds.c | 4 ++-- src/nvim/os/shell.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 1b6861f750..4319995d87 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1160,7 +1160,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b linenr_T read_linecount = curbuf->b_ml.ml_line_count; // Pass on the kShellOptDoOut flag when the output is being redirected. - call_shell(cmd_buf, (ShellOpts)(kShellOptFilter | shell_flags), NULL); + call_shell(cmd_buf, kShellOptFilter | shell_flags, NULL); xfree(cmd_buf); did_check_timestamps = false; @@ -1305,7 +1305,7 @@ void do_shell(char *cmd, int flags) // This ui_cursor_goto is required for when the '\n' resulted in a "delete line // 1" command to the terminal. ui_cursor_goto(msg_row, msg_col); - call_shell(cmd, (ShellOpts)flags, NULL); + call_shell(cmd, flags, NULL); if (msg_silent == 0) { msg_didout = true; } diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index a1ec9449df..efcdee9c8b 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -115,7 +115,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in size_t len; char *p; char *extra_shell_arg = NULL; - ShellOpts shellopts = kShellOptExpand | kShellOptSilent; + int shellopts = kShellOptExpand | kShellOptSilent; int j; char *tempname; #define STYLE_ECHO 0 // use "echo", the default @@ -659,7 +659,7 @@ char *shell_argv_to_str(char **const argv) /// @param extra_args Extra arguments to the shell, or NULL. /// /// @return shell command exit code -int os_call_shell(char *cmd, ShellOpts opts, char *extra_args) +int os_call_shell(char *cmd, int opts, char *extra_args) { StringBuilder input = KV_INITIAL_VALUE; char *output = NULL; @@ -714,8 +714,10 @@ int os_call_shell(char *cmd, ShellOpts opts, char *extra_args) /// os_call_shell() wrapper. Handles 'verbose', :profile, and v:shell_error. /// Invalidates cached tags. /// +/// @param opts a combination of ShellOpts flags +/// /// @return shell command exit code -int call_shell(char *cmd, ShellOpts opts, char *extra_shell_arg) +int call_shell(char *cmd, int opts, char *extra_shell_arg) { int retval; proftime_T wait_time; @@ -759,7 +761,7 @@ int call_shell(char *cmd, ShellOpts opts, char *extra_shell_arg) /// @param ret_len length of the stdout /// /// @return an allocated string, or NULL for error. -char *get_cmd_output(char *cmd, char *infile, ShellOpts flags, size_t *ret_len) +char *get_cmd_output(char *cmd, char *infile, int flags, size_t *ret_len) { char *buffer = NULL;