Remove 512 char limit of sourcepath variable.
Make attaching new path more efficient.
This commit is contained in:
parent
bbbeb1a4aa
commit
618f2c7abd
|
|
@ -9580,9 +9580,8 @@ static int inp_poly_2g6_compat(struct card* deck) {
|
||||||
/* add path or filepath (without file name) to variable sourcepath */
|
/* add path or filepath (without file name) to variable sourcepath */
|
||||||
int add_to_sourcepath(const char* filepath, const char* path)
|
int add_to_sourcepath(const char* filepath, const char* path)
|
||||||
{
|
{
|
||||||
const char* fpath;
|
char* fpath=NULL;
|
||||||
char buf[512];
|
wordlist *addwl=NULL, *newwl=NULL, *startwl, *endwl;
|
||||||
|
|
||||||
|
|
||||||
if ((filepath && path) || (!filepath && !path))
|
if ((filepath && path) || (!filepath && !path))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -9593,29 +9592,35 @@ int add_to_sourcepath(const char* filepath, const char* path)
|
||||||
else
|
else
|
||||||
fpath = ngdirname(filepath);
|
fpath = ngdirname(filepath);
|
||||||
|
|
||||||
|
if (fpath)
|
||||||
|
addwl = cp_doglob(cp_lexer(fpath));
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
startwl = newwl = wl_from_string("sourcepath = ( ");
|
||||||
|
endwl = wl_from_string(" )");
|
||||||
|
|
||||||
/* add fpath to 'sourcepath' list variable */
|
/* add fpath to 'sourcepath' list variable */
|
||||||
if (cp_getvar("sourcepath", CP_LIST, NULL, 0)) {
|
if (cp_getvar("sourcepath", CP_LIST, NULL, 0)) {
|
||||||
wordlist* wl;
|
wordlist* wl = vareval("sourcepath");
|
||||||
char* toklist;
|
wl_append(newwl, wl);
|
||||||
wl = vareval("sourcepath");
|
|
||||||
toklist = wl_flatten(wl);
|
|
||||||
(void)snprintf(buf, 511, "sourcepath = ( %s %s )", toklist, fpath);
|
|
||||||
wl_free(wl);
|
|
||||||
tfree(toklist);
|
|
||||||
}
|
}
|
||||||
|
/* new sourcepath variable */
|
||||||
else {
|
else {
|
||||||
(void)snprintf(buf, 511, "sourcepath = ( %s )", fpath);
|
wordlist* wl = wl_from_string(fpath);
|
||||||
|
wl_append(newwl, wl);
|
||||||
}
|
}
|
||||||
|
/* add new entry */
|
||||||
|
if (addwl)
|
||||||
|
wl_append(newwl, addwl);
|
||||||
|
/* add end section */
|
||||||
|
wl_append(newwl, endwl);
|
||||||
|
|
||||||
// fprintf(stdout, "Added to variable 'sourcepath':\n %s\n", fpath);
|
// fprintf(stdout, "Added to variable 'sourcepath':\n %s\n", fpath);
|
||||||
|
|
||||||
{
|
com_set(startwl);
|
||||||
wordlist* wl;
|
|
||||||
wl = cp_doglob(cp_lexer(buf));
|
|
||||||
com_set(wl);
|
|
||||||
wl_free(wl);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
wl_free(startwl);
|
||||||
tfree(fpath);
|
tfree(fpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue