mirror of
https://github.com/fluencelabs/redis
synced 2025-03-21 01:50:50 +00:00
CONFIG REWRITE: strip multiple empty lines.
This commit is contained in:
parent
c184f36d21
commit
ee721f1e5c
11
src/config.c
11
src/config.c
@ -1397,11 +1397,20 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Glue together the configuration lines in the current configuration
|
||||||
|
* rewrite state into a single string, stripping multiple empty lines. */
|
||||||
sds rewriteConfigGetContentFromState(struct rewriteConfigState *state) {
|
sds rewriteConfigGetContentFromState(struct rewriteConfigState *state) {
|
||||||
sds content = sdsempty();
|
sds content = sdsempty();
|
||||||
int j;
|
int j, was_empty = 0;
|
||||||
|
|
||||||
for (j = 0; j < state->numlines; j++) {
|
for (j = 0; j < state->numlines; j++) {
|
||||||
|
/* Every cluster of empty lines is turned into a single empty line. */
|
||||||
|
if (sdslen(state->lines[j]) == 0) {
|
||||||
|
if (was_empty) continue;
|
||||||
|
was_empty = 1;
|
||||||
|
} else {
|
||||||
|
was_empty = 0;
|
||||||
|
}
|
||||||
content = sdscatsds(content,state->lines[j]);
|
content = sdscatsds(content,state->lines[j]);
|
||||||
content = sdscatlen(content,"\n",1);
|
content = sdscatlen(content,"\n",1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user