Introduction
Introduction Statistics Contact Development Disclaimer Help
tex: make ex_pathexpand() more compact - neatvi - [fork] simple vi-type editor …
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit debb1a79efbabb95f0ce6383bc091c96b5bf1edc
parent 2413a868f0ce3e3d67a8732f7174de731c3f7a05
Author: Ali Gholami Rudi <[email protected]>
Date: Thu, 7 Oct 2021 13:04:29 +0330
ex: make ex_pathexpand() more compact
Diffstat:
M ex.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/ex.c b/ex.c
t@@ -122,27 +122,19 @@ static char *ex_pathexpand(char *src, int spaceallowed)
char *end = dst + sizeof(buf);
while (dst + 1 < end && *src && *src != '\n' &&
(spaceallowed || (*src != ' ' && *src != '\t'))) {
- if (*src == '%') {
- if (!bufs[0].path || !bufs[0].path[0]) {
- ex_show("\"%\" is unset\n");
+ if (*src == '%' || *src == '#') {
+ int idx = *src == '#';
+ if (!bufs[idx].path || !bufs[idx].path[0]) {
+ ex_show("pathname \"%\" or \"#\" is not set\n"…
return NULL;
}
- dst += snprintf(dst, end - dst, "%s", bufs[0].path);
+ dst += snprintf(dst, end - dst, "%s", bufs[idx].path);
src++;
- continue;
- }
- if (*src == '#') {
- if (!bufs[1].path || !bufs[1].path[0]) {
- ex_show("\"#\" is unset\n");
- return NULL;
- }
- dst += snprintf(dst, end - dst, "%s", bufs[1].path);
- src++;
- continue;
+ } else {
+ if (*src == '\\' && src[1])
+ src++;
+ *dst++ = *src++;
}
- if (*src == '\\' && src[1])
- src++;
- *dst++ = *src++;
}
if (dst + 1 >= end)
dst = end - 1;
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.