Skip to content
Snippets Groups Projects
Commit a8db694b authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Use text/menu/*.###col.* display files for even-wider terminals

e.g. display basename.132col.msg even if the terminal is 133+ columns wide.

Fixes issue #380.
parent ce74d0e0
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2926 passed
......@@ -304,9 +304,28 @@ bool sbbs_t::menu_exists(const char *code, const char* ext, char* path)
FULLPATH(path, prefix, MAX_PATH);
SAFECOPY(prefix, path);
}
safe_snprintf(path, MAX_PATH, "%s.%lucol.%s", prefix, cols, ext);
if(fexistcase(path))
return true;
glob_t g = {0};
safe_snprintf(path, MAX_PATH, "%s.*col.%s", prefix, ext);
if(globi(path, GLOB_NOESCAPE|GLOB_MARK, NULL, &g) == 0) {
char* p;
char term[MAX_PATH + 1];
safe_snprintf(term, sizeof(term), "col.%s", ext);
size_t skip = safe_snprintf(path, MAX_PATH, "%s.", prefix);
long max = 0;
for(size_t i = 0; i < g.gl_pathc; i++) {
long c = strtol(g.gl_pathv[i] + skip, &p, 10);
if(stricmp(p, term) != 0) // Some other weird pattern ending in col.<ext>
continue;
if(c <= cols && c > max) {
max = c;
safe_snprintf(path, MAX_PATH, "%s", g.gl_pathv[i]);
}
}
globfree(&g);
if(max > 0)
return true;
}
safe_snprintf(path, MAX_PATH, "%s.%s", prefix, ext);
return fexistcase(path) ? true : false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment