summaryrefslogtreecommitdiff
path: root/src/poparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/poparser.c')
-rw-r--r--src/poparser.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/poparser.c b/src/poparser.c
index dc4cf86..55f9c49 100644
--- a/src/poparser.c
+++ b/src/poparser.c
@@ -358,20 +358,24 @@ size_t poparser_sysdep(const char *in, char *out, int cnt[]) {
outs = out;
x = in;
- for (n=0; n < st_max;) {
- if ((y = strstr(x, sysdep_str[n])) && *(y-1) == '%') {
- if (outs)
- memcpy(out, x, y-x);
- out += y-x;
- x = y + strlen(sysdep_str[n]);
-
- y = sysdep_repl[n][cnt[n]+1];
- if (outs)
- memcpy(out, y, strlen(y));
- out += strlen(y);
-
- n = 0;
- } else n++;
+ while ((y = strchr(x, '%'))) {
+ y++;
+
+ for (n=0; n < st_max; n++) {
+ if (!memcmp(y, sysdep_str[n], strlen(sysdep_str[n]))) {
+ if (outs)
+ memcpy(out, x, y-x);
+ out += y-x;
+ x = y + strlen(sysdep_str[n]);
+
+ y = sysdep_repl[n][cnt[n]+1];
+ if (outs)
+ memcpy(out, y, strlen(y));
+ out += strlen(y);
+
+ break;
+ }
+ }
}
if (outs)