summaryrefslogtreecommitdiff
path: root/pico/browse.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2021-07-31 21:16:15 -0600
committerEduardo Chappa <chappa@washington.edu>2021-07-31 21:16:15 -0600
commit8167f58e118afa658590253f8696c816511c3708 (patch)
treeb79d65ce860848c50449b69ae299898b71c3e322 /pico/browse.c
parentbba1f63e9be0b65c090d1707a6c9168443604ed6 (diff)
downloadalpine-8167f58e118afa658590253f8696c816511c3708.tar.xz
* Clear more warnings given by gcc-10. Work in progress.
Diffstat (limited to 'pico/browse.c')
-rw-r--r--pico/browse.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/pico/browse.c b/pico/browse.c
index 595185f1..f5fb1e79 100644
--- a/pico/browse.c
+++ b/pico/browse.c
@@ -721,6 +721,7 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen,
case 'e': /* exit or edit */
case 'E':
if(gmode&MDBRONLY){ /* run "pico" */
+ char *t;
snprintf(child, sizeof(child), "%.*s%c%.*s", NLINE, gmp->dname, C_FILESEP,
NLINE, gmp->current->fname);
/* make sure selected isn't a directory or executable */
@@ -729,17 +730,22 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen,
break;
}
- if((envp = (char *) getenv("EDITOR")) != NULL)
- snprintf(tmp, sizeof(tmp), "%s \'%s\'", envp, child);
- else
- snprintf(tmp, sizeof(tmp), "pico%s%s%s \'%s\'",
+ if((envp = (char *) getenv("EDITOR")) != NULL){
+ t = fs_get(strlen(envp) + strlen(child) + 3 + 1);
+ sprintf(t, "%s \'%s\'", envp, child);
+ }
+ else{
+ t = fs_get(strlen(child) + 16 + 1);
+ sprintf(t, "pico%s%s%s \'%s\'",
(gmode & MDFKEY) ? " -f" : "",
(gmode & MDSHOCUR) ? " -g" : "",
(gmode & MDMOUSE) ? " -m" : "",
child);
+ }
- BrowserRunChild(tmp, gmp->dname); /* spawn pico */
+ BrowserRunChild(t, gmp->dname); /* spawn pico */
PaintBrowser(gmp, 0, &crow, &ccol); /* redraw browser */
+ if(t) fs_give((void **) &t);
}
else{
zotmaster(&gmp);
@@ -1585,11 +1591,14 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen,
NLINE, gmp->current->fname);
if(LikelyASCII(child)){
- snprintf(tmp, sizeof(tmp), "%s \'%s\'",
- (envp = (char *) getenv("PAGER"))
- ? envp : BROWSER_PAGER, child);
- BrowserRunChild(tmp, gmp->dname);
+ char *t;
+ envp = (char *) getenv("PAGER");
+ t = fs_get((envp ? strlen(envp) : strlen(BROWSER_PAGER))
+ + strlen(child) + 3 + 1);
+ sprintf(t, "%s \'%s\'", envp ? envp : BROWSER_PAGER, child);
+ BrowserRunChild(t, gmp->dname);
PaintBrowser(gmp, 0, &crow, &ccol);
+ if(t) fs_give((void **) &t);
}
break;