summaryrefslogtreecommitdiff
path: root/src/sp_config_utils.c
diff options
context:
space:
mode:
authorjvoisin2017-09-25 14:04:21 +0200
committerjvoisin2017-09-25 14:04:21 +0200
commitbed568094b95b65a43c44d7b4d38aced394fce1c (patch)
treedfa1fece12df05adee964eb27b98b46cb5a34ead /src/sp_config_utils.c
parent302dd00ff445a3b8257fa75bdb24ed354a513746 (diff)
Show the line number in case of processing error
Diffstat (limited to 'src/sp_config_utils.c')
-rw-r--r--src/sp_config_utils.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/sp_config_utils.c b/src/sp_config_utils.c
index e05e95e..39951cc 100644
--- a/src/sp_config_utils.c
+++ b/src/sp_config_utils.c
@@ -1,5 +1,7 @@
1#include "php_snuffleupagus.h" 1#include "php_snuffleupagus.h"
2 2
3size_t sp_line_no;
4
3static int validate_int(const char *value); 5static int validate_int(const char *value);
4static int validate_str(const char *value); 6static int validate_str(const char *value);
5 7
@@ -55,8 +57,8 @@ int parse_keywords(sp_config_functions *funcs, char *line) {
55 } 57 }
56 58
57 if (*line) { 59 if (*line) {
58 sp_log_err("config", "Trailing chars '%s' at the end of '%s'.", line, 60 sp_log_err("config", "Trailing chars '%s' at the end of '%s' on line %zu.",
59 original_line); 61 line, original_line, sp_line_no);
60 return -1; 62 return -1;
61 } 63 }
62 return 0; 64 return 0;
@@ -116,8 +118,8 @@ static char *get_string(size_t *consumed, char *restrict line,
116 } 118 }
117err: 119err:
118 sp_log_err("error", 120 sp_log_err("error",
119 "There is an issue with the parsing of '%s': it doesn't look like a valid string.", 121 "There is an issue with the parsing of '%s': it doesn't look like a valid string on line %zu.",
120 original_line ? original_line : "NULL"); 122 original_line ? original_line : "NULL", sp_line_no);
121 line = NULL; 123 line = NULL;
122 return NULL; 124 return NULL;
123} 125}
@@ -133,15 +135,15 @@ static char *get_misc(char *restrict line, const char *restrict keyword) {
133 135
134 if (line[i] != SP_TOKEN_END_PARAM) { 136 if (line[i] != SP_TOKEN_END_PARAM) {
135 if (i >= 1024 - 1) { 137 if (i >= 1024 - 1) {
136 sp_log_err("config", "The following line is too long: %s.", line); 138 sp_log_err("config", "The following line is too long: %s on line %zu.", line, sp_line_no);
137 } else { 139 } else {
138 sp_log_err("config", "Missing closing %c in line %s.", SP_TOKEN_END_PARAM, 140 sp_log_err("config", "Missing closing %c in line %s on line %zu.", SP_TOKEN_END_PARAM,
139 line); 141 line, sp_line_no);
140 } 142 }
141 return NULL; 143 return NULL;
142 } else if (i == 0) { 144 } else if (i == 0) {
143 sp_log_err("config", "The keyword %s%c is expecting a parameter.", 145 sp_log_err("config", "The keyword %s%c is expecting a parameter on line %zu.",
144 keyword, SP_TOKEN_END_PARAM); 146 keyword, SP_TOKEN_END_PARAM, sp_line_no);
145 return NULL; 147 return NULL;
146 } 148 }
147 return ret; 149 return ret;