[dovecot-cvs] dovecot/src/lib-settings settings.c,1.9,1.10
cras at procontrol.fi
cras at procontrol.fi
Wed Jun 23 19:36:21 EEST 2004
Update of /home/cvs/dovecot/src/lib-settings
In directory talvi:/tmp/cvs-serv3786/lib-settings
Modified Files:
settings.c
Log Message:
Allow empty section name.
Index: settings.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-settings/settings.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- settings.c 5 Jun 2004 19:09:14 -0000 1.9
+++ settings.c 23 Jun 2004 16:36:18 -0000 1.10
@@ -124,7 +124,7 @@
line[len] = '\0';
/* a) key = value
- b) section_type section_name {
+ b) section_type [section_name] {
c) } */
key = line;
while (!IS_WHITE(*line) && *line != '\0' && *line != '=')
@@ -134,25 +134,8 @@
while (IS_WHITE(*line)) line++;
}
- if (strcmp(key, "}") == 0 && *line == '\0') {
- if (sections == 0)
- errormsg = "Unexpected '}'";
- else {
- if (skip > 0)
- skip--;
- else {
- sect_callback(NULL, NULL, context,
- &errormsg);
- if (root_section == sections &&
- errormsg == NULL) {
- /* we found the section,
- now quit */
- break;
- }
- }
- sections--;
- }
- } else if (*line == '=') {
+ if (*line == '=') {
+ /* a) */
*line++ = '\0';
while (IS_WHITE(*line)) line++;
@@ -166,17 +149,22 @@
errormsg = skip ? NULL :
callback(key, line, context);
- } else {
+ } else if (strcmp(key, "}") != 0 || *line != '\0') {
+ /* b) + errors */
line[-1] = '\0';
- name = line;
- while (!IS_WHITE(*line) && *line != '\0')
- line++;
-
- if (*line != '\0') {
- *line++ = '\0';
- while (IS_WHITE(*line))
+ if (*line == '{')
+ name = "";
+ else {
+ name = line;
+ while (!IS_WHITE(*line) && *line != '\0')
line++;
+
+ if (*line != '\0') {
+ *line++ = '\0';
+ while (IS_WHITE(*line))
+ line++;
+ }
}
if (*line != '{')
@@ -207,6 +195,25 @@
&errormsg);
}
}
+ } else {
+ /* c) */
+ if (sections == 0)
+ errormsg = "Unexpected '}'";
+ else {
+ if (skip > 0)
+ skip--;
+ else {
+ sect_callback(NULL, NULL, context,
+ &errormsg);
+ if (root_section == sections &&
+ errormsg == NULL) {
+ /* we found the section,
+ now quit */
+ break;
+ }
+ }
+ sections--;
+ }
}
if (errormsg != NULL) {
More information about the dovecot-cvs
mailing list