Skip to content

Commit 875d4f2

Browse files
committed
Minor edits
1 parent 4849479 commit 875d4f2

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

src/init.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,15 @@ set_encoded_prompt(void)
27522752
}
27532753
}
27542754

2755+
static char *
2756+
set_warning_prompt_str(void)
2757+
{
2758+
return (conf.colorize == 1
2759+
? savestring(DEF_WPROMPT_STR, sizeof(DEF_WPROMPT_STR) - 1)
2760+
: savestring(DEF_WPROMPT_STR_NO_COLOR,
2761+
sizeof(DEF_WPROMPT_STR_NO_COLOR) - 1));
2762+
}
2763+
27552764
#define SETOPT(cmd_line, def) ((cmd_line) == UNSET ? (def) : (cmd_line))
27562765

27572766
/* If some option was not set, set it to the default value. */
@@ -3004,13 +3013,8 @@ check_options(void)
30043013

30053014
set_prompt_options();
30063015

3007-
if (!conf.wprompt_str) {
3008-
if (conf.colorize == 1)
3009-
conf.wprompt_str = savestring(DEF_WPROMPT_STR, sizeof(DEF_WPROMPT_STR) - 1);
3010-
else
3011-
conf.wprompt_str = savestring(DEF_WPROMPT_STR_NO_COLOR,
3012-
sizeof(DEF_WPROMPT_STR_NO_COLOR) - 1);
3013-
}
3016+
if (!conf.wprompt_str)
3017+
conf.wprompt_str = set_warning_prompt_str();
30143018

30153019
if ((xargs.stealth_mode == 1 || home_ok == 0 ||
30163020
config_ok == 0 || !config_file) && !*div_line) {

src/keybinds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,7 @@ rl_switch_workspace(const int n)
27752775
if (rl_line_buffer && *rl_line_buffer)
27762776
rl_delete_text(0, rl_end);
27772777

2778-
char t[16];
2778+
char t[MAX_INT_STR + 4];
27792779
exec_prompt_cmds = 1;
27802780

27812781
if (cur_ws == (n - 1)) {

src/misc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,11 +1861,10 @@ handle_stdin(void)
18611861
* == (65535 * PATH_MAX)
18621862
* == 262MiB of data ((65535 * PATH_MAX) / 1024). */
18631863

1864-
size_t chunk = (size_t)512 * 1024;
1864+
const size_t chunk = (size_t)512 * 1024;
1865+
const size_t max_chunks = 512;
18651866
size_t chunks_n = 1;
18661867
size_t total_len = 0;
1867-
size_t max_chunks = 512;
1868-
18691868
ssize_t input_len = 0;
18701869

18711870
/* Initial buffer allocation == 1 chunk */

src/sanitize.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ sanitize_shell_level(char *str)
161161
if (!str || !*str || !is_number(str))
162162
return FUNC_FAILURE;
163163

164-
int a = atoi(str);
164+
const int a = atoi(str);
165165
if (a < 1 || a > MAX_SHELL_LEVEL)
166166
return FUNC_FAILURE;
167167

@@ -172,10 +172,10 @@ sanitize_shell_level(char *str)
172172
static void
173173
drop_privs(void)
174174
{
175-
uid_t ruid = getuid();
176-
uid_t euid = geteuid();
177-
gid_t rgid = getgid();
178-
gid_t egid = getegid();
175+
const uid_t ruid = getuid();
176+
const uid_t euid = geteuid();
177+
const gid_t rgid = getgid();
178+
const gid_t egid = getegid();
179179

180180
if (rgid != egid) {
181181
int err = 0;

src/sort.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,6 @@ print_sort_method(void)
359359
putchar('\n');
360360
}
361361

362-
static inline void
363-
toggle_sort_reverse(void)
364-
{
365-
conf.sort_reverse = !conf.sort_reverse;
366-
}
367-
368362
static inline int
369363
re_sort_files_list(void)
370364
{
@@ -421,7 +415,7 @@ sort_function(char **arg)
421415
/* Argument is an alphanumerical string */
422416
if (!is_number(arg[1])) {
423417
if (*arg[1] == 'r' && strcmp(arg[1], "rev") == 0) {
424-
toggle_sort_reverse();
418+
conf.sort_reverse = !conf.sort_reverse;
425419
return re_sort_files_list();
426420
}
427421

@@ -449,7 +443,7 @@ sort_function(char **arg)
449443
conf.sort = n;
450444

451445
if (arg[2] && *arg[2] == 'r' && strcmp(arg[2], "rev") == 0)
452-
toggle_sort_reverse();
446+
conf.sort_reverse = !conf.sort_reverse;
453447

454448
update_autocmd_opts(AC_SORT);
455449

0 commit comments

Comments
 (0)