mirror of
https://github.com/redis/redis.git
synced 2026-06-08 16:24:26 -04:00
Merge 50dae24779 into 138263a1b4
This commit is contained in:
commit
89ebe935ab
1 changed files with 19 additions and 0 deletions
19
src/config.c
19
src/config.c
|
|
@ -473,6 +473,25 @@ void loadServerConfigFromString(char *config) {
|
|||
/* Skip comments and blank lines */
|
||||
if (lines[i][0] == '#' || lines[i][0] == '\0') continue;
|
||||
|
||||
/* Strip inline comments */
|
||||
char *comment = strchr(lines[i], '#');
|
||||
if (comment) {
|
||||
/* Check if # is inside quotes by counting quotes before it */
|
||||
char *p = lines[i];
|
||||
int in_quotes = 0;
|
||||
while (p < comment) {
|
||||
if (*p == '"' || *p == '\''){
|
||||
in_quotes = !in_quotes;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
/* Only treat as comment if not inside quotes */
|
||||
if (!in_quotes){
|
||||
*comment = '\0';
|
||||
lines[i] = sdstrim(lines[i], " \t\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Split into arguments */
|
||||
argv = sdssplitargs(lines[i],&argc);
|
||||
if (argv == NULL) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue