len = buf.len;
while ((de = readdir(dir)) != NULL) {
- int entlen;
+ size_t entlen;
if (!starts_with(de->d_name, prefix))
continue;
continue;
entlen = strlen(de->d_name) - prefix_len;
- if (has_extension(de->d_name, ".exe"))
- entlen -= 4;
+ strip_suffix(de->d_name, ".exe", &entlen);
add_cmdname(cmds, de->d_name + prefix_len, entlen);
}