Lines Matching +full:de +full:- +full:assert

1 // SPDX-License-Identifier: GPL-2.0
12 #include <assert.h>
13 #include "subcmd-util.h"
15 #include "exec-cmd.h"
23 ent->len = len; in add_cmdname()
24 memcpy(ent->name, name, len); in add_cmdname()
25 ent->name[len] = 0; in add_cmdname()
27 ALLOC_GROW(cmds->names, cmds->cnt + 1, cmds->alloc); in add_cmdname()
28 cmds->names[cmds->cnt++] = ent; in add_cmdname()
35 for (i = 0; i < cmds->cnt; ++i) in clean_cmdnames()
36 zfree(&cmds->names[i]); in clean_cmdnames()
37 zfree(&cmds->names); in clean_cmdnames()
38 cmds->cnt = 0; in clean_cmdnames()
39 cmds->alloc = 0; in clean_cmdnames()
46 return strcmp(a->name, b->name); in cmdname_compare()
53 if (!cmds->cnt) in uniq()
56 for (i = 1; i < cmds->cnt; i++) { in uniq()
57 if (!strcmp(cmds->names[i]->name, cmds->names[i-1]->name)) in uniq()
58 zfree(&cmds->names[i - 1]); in uniq()
60 for (i = 0, j = 0; i < cmds->cnt; i++) { in uniq()
61 if (cmds->names[i]) { in uniq()
65 cmds->names[j++] = cmds->names[i]; in uniq()
68 cmds->cnt = j; in uniq()
70 cmds->names[j++] = NULL; in uniq()
78 if (!excludes->cnt) in exclude_cmds()
82 while (ci < cmds->cnt && ei < excludes->cnt) { in exclude_cmds()
83 cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name); in exclude_cmds()
89 cmds->names[cj++] = cmds->names[ci]; in exclude_cmds()
90 cmds->names[ci++] = NULL; in exclude_cmds()
93 zfree(&cmds->names[ci]); in exclude_cmds()
101 while (ci < cmds->cnt) { in exclude_cmds()
102 cmds->names[cj++] = cmds->names[ci]; in exclude_cmds()
103 cmds->names[ci++] = NULL; in exclude_cmds()
106 for (ci = cj; ci < cmds->cnt; ci++) in exclude_cmds()
107 assert(cmds->names[ci] == NULL); in exclude_cmds()
108 cmds->cnt = cj; in exclude_cmds()
116 ws->ws_row = atoi(s); in get_term_dimensions()
119 ws->ws_col = atoi(s); in get_term_dimensions()
120 if (ws->ws_row && ws->ws_col) in get_term_dimensions()
126 ws->ws_row && ws->ws_col) in get_term_dimensions()
129 ws->ws_row = 25; in get_term_dimensions()
130 ws->ws_col = 80; in get_term_dimensions()
142 max_cols = win.ws_col - 1; /* don't print *on* the edge */ in pretty_print_string_list()
146 rows = (cmds->cnt + cols - 1) / cols; in pretty_print_string_list()
155 if (n >= cmds->cnt) in pretty_print_string_list()
157 if (j == cols-1 || n + rows >= cmds->cnt) in pretty_print_string_list()
159 printf("%-*s", size, cmds->names[n]->name); in pretty_print_string_list()
181 return len > extlen && !memcmp(filename + len - extlen, ext, extlen); in has_extension()
190 struct dirent *de; in list_commands_in_dir() local
196 prefix = "perf-"; in list_commands_in_dir()
201 while ((de = readdir(dir)) != NULL) { in list_commands_in_dir()
204 if (!strstarts(de->d_name, prefix)) in list_commands_in_dir()
207 astrcat(&buf, de->d_name); in list_commands_in_dir()
211 entlen = strlen(de->d_name) - prefix_len; in list_commands_in_dir()
212 if (has_extension(de->d_name, ".exe")) in list_commands_in_dir()
213 entlen -= 4; in list_commands_in_dir()
215 add_cmdname(cmds, de->d_name + prefix_len, entlen); in list_commands_in_dir()
230 qsort(main_cmds->names, main_cmds->cnt, in load_command_list()
231 sizeof(*main_cmds->names), cmdname_compare); in load_command_list()
250 qsort(other_cmds->names, other_cmds->cnt, in load_command_list()
251 sizeof(*other_cmds->names), cmdname_compare); in load_command_list()
263 for (i = 0; i < main_cmds->cnt; i++) in list_commands()
264 if (longest < main_cmds->names[i]->len) in list_commands()
265 longest = main_cmds->names[i]->len; in list_commands()
266 for (i = 0; i < other_cmds->cnt; i++) in list_commands()
267 if (longest < other_cmds->names[i]->len) in list_commands()
268 longest = other_cmds->names[i]->len; in list_commands()
270 if (main_cmds->cnt) { in list_commands()
273 printf("----------------"); in list_commands()
274 mput_char('-', strlen(title) + strlen(exec_path)); in list_commands()
281 if (other_cmds->cnt) { in list_commands()
283 printf("---------------------------------------"); in list_commands()
284 mput_char('-', strlen(title)); in list_commands()
295 for (i = 0; i < c->cnt; i++) in is_in_cmdlist()
296 if (!strcmp(s, c->names[i]->name)) in is_in_cmdlist()