-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#244] Allows spaces and comments in configuration parameters
This commit refactors the `extract_key_value()` function to handle quoted strings as values. A quoted string must start with either '"' or '\''. Everything between the quotes is handled as a value. If quotes do not match (e.g., "foo') the value is not set, so the line is ignored at all. Quoted strings can contain also spaces and comment charaters. Therefore, the following is a good string: log_line_prefix = "PGAGROAL #%Y-%m-%d-%H:%M:%S" Also, quotes can be nested: log_line_prefix = "'PGAGROAL' #%Y-%m-%d-%H:%M:%S" Values that do not need a quoting (because of spaces or comment signs) can be quoted as well, and that will not affect the value parsing. The following two lines are the same: log_rotation_size = 1M log_rotation_size = "1M" The `extract_key_value()` function now returns also an integer to indicate if it has parsed the key and the value correctly. The return value is not used because there is already a check on the validity of both key and value in `pgagroal_read_configuration()`, but to be coherent the function returns a status. This commit also allows to use comment-only line that begin with spaces or tabs, therefore the following are all ignored lines. The `is_comment_line()` function has therefore been refactored so that the following is a valid snippet of configuration: ; comment ; comment <tab> ; comment Last, a comment can be placed on the right side of a configuration option, so log_line_prefix = "PGAGROAL #%Y-%m-%d-%H:%M:%S" # the prefix is a valid line. The trick here is that any space after the option makes the rest of the line ignored. But now, even without spaces the comment is ignored: log_type = create; overwrites the file Updated also the documentation to reflect the changes. Close #244
- Loading branch information
1 parent
3929b53
commit 856f03a
Showing
2 changed files
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters