summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-10-17 14:56:02 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-10-17 14:56:02 +0100
commit41e269801406c374a041da0fd0c6b4eff6ba4f3d (patch)
treed06f13be57b3c8df23e21798a8907d648c56e05c /src
parent2d588f5579993181b8e0326cdce4d0b4689b3260 (diff)
downloadrspamd-41e269801406c374a041da0fd0c6b4eff6ba4f3d.tar.gz
rspamd-41e269801406c374a041da0fd0c6b4eff6ba4f3d.zip
Fix rcl issues (ported from libucl).
Diffstat (limited to 'src')
-rw-r--r--src/rcl/rcl_emitter.c130
-rw-r--r--src/rcl/rcl_parser.c56
2 files changed, 113 insertions, 73 deletions
diff --git a/src/rcl/rcl_emitter.c b/src/rcl/rcl_emitter.c
index 9702ffefd..bf394ee1d 100644
--- a/src/rcl/rcl_emitter.c
+++ b/src/rcl/rcl_emitter.c
@@ -31,9 +31,12 @@
*/
-static void rspamd_cl_elt_write_json (rspamd_cl_object_t *obj, GString *buf, guint tabs, gboolean start_tabs, gboolean compact);
-static void rspamd_cl_obj_write_json (rspamd_cl_object_t *obj, GString *buf, guint tabs, gboolean start_tabs, gboolean compact);
-static void rspamd_cl_elt_write_rcl (rspamd_cl_object_t *obj, GString *buf, guint tabs, gboolean start_tabs, gboolean is_top);
+static void rspamd_cl_elt_write_json (rspamd_cl_object_t *obj, GString *buf, guint tabs,
+ gboolean start_tabs, gboolean compact);
+static void rspamd_cl_obj_write_json (rspamd_cl_object_t *obj, GString *buf, guint tabs,
+ gboolean start_tabs, gboolean compact);
+static void rspamd_cl_elt_write_rcl (rspamd_cl_object_t *obj, GString *buf, guint tabs,
+ gboolean start_tabs, gboolean is_top, gboolean expand_array);
/**
* Add tabulation to the output buffer
@@ -306,25 +309,22 @@ rspamd_cl_elt_obj_write_rcl (rspamd_cl_object_t *obj, GString *buf, guint tabs,
g_string_append_len (buf, "{\n", 2);
}
- while (obj) {
- HASH_ITER (hh, obj, cur, tmp) {
- rspamd_cl_add_tabs (buf, tabs + 1, is_top);
- g_string_append (buf, cur->key);
- if (cur->type != RSPAMD_CL_OBJECT && cur->type != RSPAMD_CL_ARRAY) {
- g_string_append_len (buf, " = ", 3);
- }
- else {
- g_string_append_c (buf, ' ');
- }
- rspamd_cl_elt_write_rcl (cur, buf, is_top ? tabs : tabs + 1, FALSE, FALSE);
- if (cur->type != RSPAMD_CL_OBJECT && cur->type != RSPAMD_CL_ARRAY) {
- g_string_append_len (buf, ";\n", 2);
- }
- else {
- g_string_append_c (buf, '\n');
- }
+ HASH_ITER (hh, obj, cur, tmp) {
+ rspamd_cl_add_tabs (buf, tabs + 1, is_top);
+ g_string_append (buf, cur->key);
+ if (cur->type != RSPAMD_CL_OBJECT && cur->type != RSPAMD_CL_ARRAY) {
+ g_string_append_len (buf, " = ", 3);
+ }
+ else {
+ g_string_append_c (buf, ' ');
+ }
+ rspamd_cl_elt_write_rcl (cur, buf, is_top ? tabs : tabs + 1, FALSE, FALSE, TRUE);
+ if (cur->type != RSPAMD_CL_OBJECT && cur->type != RSPAMD_CL_ARRAY) {
+ g_string_append_len (buf, ";\n", 2);
+ }
+ else {
+ g_string_append_c (buf, '\n');
}
- obj = obj->next;
}
rspamd_cl_add_tabs (buf, tabs, is_top);
if (!is_top) {
@@ -348,7 +348,7 @@ rspamd_cl_elt_array_write_rcl (rspamd_cl_object_t *obj, GString *buf, guint tabs
g_string_append_len (buf, "[\n", 2);
while (cur) {
- rspamd_cl_elt_write_rcl (cur, buf, tabs + 1, TRUE, FALSE);
+ rspamd_cl_elt_write_rcl (cur, buf, tabs + 1, TRUE, FALSE, FALSE);
g_string_append_len (buf, ",\n", 2);
cur = cur->next;
}
@@ -362,47 +362,53 @@ rspamd_cl_elt_array_write_rcl (rspamd_cl_object_t *obj, GString *buf, guint tabs
* @param buf buffer
*/
static void
-rspamd_cl_elt_write_rcl (rspamd_cl_object_t *obj, GString *buf, guint tabs, gboolean start_tabs, gboolean is_top)
+rspamd_cl_elt_write_rcl (rspamd_cl_object_t *obj, GString *buf, guint tabs,
+ gboolean start_tabs, gboolean is_top, gboolean expand_array)
{
- switch (obj->type) {
- case RSPAMD_CL_INT:
- if (start_tabs) {
- rspamd_cl_add_tabs (buf, tabs, FALSE);
- }
- g_string_append_printf (buf, "%ld", (long int)rspamd_cl_obj_toint (obj));
- break;
- case RSPAMD_CL_FLOAT:
- if (start_tabs) {
- rspamd_cl_add_tabs (buf, tabs, FALSE);
- }
- g_string_append_printf (buf, "%.4lf", rspamd_cl_obj_todouble (obj));
- break;
- case RSPAMD_CL_TIME:
- if (start_tabs) {
- rspamd_cl_add_tabs (buf, tabs, FALSE);
- }
- g_string_append_printf (buf, "%.4lf", rspamd_cl_obj_todouble (obj));
- break;
- case RSPAMD_CL_BOOLEAN:
- if (start_tabs) {
- rspamd_cl_add_tabs (buf, tabs, FALSE);
- }
- g_string_append_printf (buf, "%s", rspamd_cl_obj_toboolean (obj) ? "true" : "false");
- break;
- case RSPAMD_CL_STRING:
- if (start_tabs) {
- rspamd_cl_add_tabs (buf, tabs, FALSE);
+ if (expand_array && obj->next) {
+ rspamd_cl_elt_array_write_rcl (obj, buf, tabs, start_tabs, is_top);
+ }
+ else {
+ switch (obj->type) {
+ case RSPAMD_CL_INT:
+ if (start_tabs) {
+ rspamd_cl_add_tabs (buf, tabs, FALSE);
+ }
+ g_string_append_printf (buf, "%ld", (long int)rspamd_cl_obj_toint (obj));
+ break;
+ case RSPAMD_CL_FLOAT:
+ if (start_tabs) {
+ rspamd_cl_add_tabs (buf, tabs, FALSE);
+ }
+ g_string_append_printf (buf, "%.4lf", rspamd_cl_obj_todouble (obj));
+ break;
+ case RSPAMD_CL_TIME:
+ if (start_tabs) {
+ rspamd_cl_add_tabs (buf, tabs, FALSE);
+ }
+ g_string_append_printf (buf, "%.4lf", rspamd_cl_obj_todouble (obj));
+ break;
+ case RSPAMD_CL_BOOLEAN:
+ if (start_tabs) {
+ rspamd_cl_add_tabs (buf, tabs, FALSE);
+ }
+ g_string_append_printf (buf, "%s", rspamd_cl_obj_toboolean (obj) ? "true" : "false");
+ break;
+ case RSPAMD_CL_STRING:
+ if (start_tabs) {
+ rspamd_cl_add_tabs (buf, tabs, FALSE);
+ }
+ rspamd_cl_elt_string_write_json (rspamd_cl_obj_tostring (obj), buf);
+ break;
+ case RSPAMD_CL_OBJECT:
+ rspamd_cl_elt_obj_write_rcl (obj->value.ov, buf, tabs, start_tabs, is_top);
+ break;
+ case RSPAMD_CL_ARRAY:
+ rspamd_cl_elt_array_write_rcl (obj->value.ov, buf, tabs, start_tabs, is_top);
+ break;
+ case RSPAMD_CL_USERDATA:
+ break;
}
- rspamd_cl_elt_string_write_json (rspamd_cl_obj_tostring (obj), buf);
- break;
- case RSPAMD_CL_OBJECT:
- rspamd_cl_elt_obj_write_rcl (obj->value.ov, buf, tabs, start_tabs, is_top);
- break;
- case RSPAMD_CL_ARRAY:
- rspamd_cl_elt_array_write_rcl (obj->value.ov, buf, tabs, start_tabs, is_top);
- break;
- case RSPAMD_CL_USERDATA:
- break;
}
}
@@ -420,7 +426,7 @@ rspamd_cl_object_emit_rcl (rspamd_cl_object_t *obj)
/* Allocate large enough buffer */
buf = g_string_sized_new (BUFSIZ);
- rspamd_cl_elt_write_rcl (obj, buf, 0, FALSE, TRUE);
+ rspamd_cl_elt_write_rcl (obj, buf, 0, FALSE, TRUE, TRUE);
res = buf->str;
g_string_free (buf, FALSE);
diff --git a/src/rcl/rcl_parser.c b/src/rcl/rcl_parser.c
index 7989ece15..b601df310 100644
--- a/src/rcl/rcl_parser.c
+++ b/src/rcl/rcl_parser.c
@@ -32,6 +32,13 @@
* The implementation of rcl parser
*/
+struct rspamd_cl_parser_saved_state {
+ guint line;
+ guint column;
+ gsize remain;
+ const guchar *pos;
+};
+
/**
* Move up to len characters
* @param parser
@@ -54,6 +61,34 @@ rspamd_cl_chunk_skipc (struct rspamd_cl_chunk *chunk, guchar c)
chunk->remain --;
}
+/**
+ * Save parser state
+ * @param chunk
+ * @param s
+ */
+static inline void
+rspamd_cl_chunk_save_state (struct rspamd_cl_chunk *chunk, struct rspamd_cl_parser_saved_state *s)
+{
+ s->column = chunk->column;
+ s->pos = chunk->pos;
+ s->line = chunk->line;
+ s->remain = chunk->remain;
+}
+
+/**
+ * Restore parser state
+ * @param chunk
+ * @param s
+ */
+static inline void
+rspamd_cl_chunk_restore_state (struct rspamd_cl_chunk *chunk, struct rspamd_cl_parser_saved_state *s)
+{
+ chunk->column = s->column;
+ chunk->pos = s->pos;
+ chunk->line = s->line;
+ chunk->remain = s->remain;
+}
+
static inline gboolean
rcl_test_character (guchar c, gint type_flags)
{
@@ -227,6 +262,9 @@ rspamd_cl_lex_number (struct rspamd_cl_parser *parser,
gboolean got_dot = FALSE, got_exp = FALSE, need_double = FALSE, is_date = FALSE;
gdouble dv;
gint64 lv;
+ struct rspamd_cl_parser_saved_state s;
+
+ rspamd_cl_chunk_save_state (chunk, &s);
if (*p == '-') {
rspamd_cl_chunk_skipc (chunk, *p);
@@ -240,11 +278,13 @@ rspamd_cl_lex_number (struct rspamd_cl_parser *parser,
else {
if (p == c) {
/* Empty digits sequence, not a number */
+ rspamd_cl_chunk_restore_state (chunk, &s);
return FALSE;
}
else if (*p == '.') {
if (got_dot) {
/* Double dots, not a number */
+ rspamd_cl_chunk_restore_state (chunk, &s);
return FALSE;
}
else {
@@ -257,6 +297,7 @@ rspamd_cl_lex_number (struct rspamd_cl_parser *parser,
else if (*p == 'e' || *p == 'E') {
if (got_exp) {
/* Double exp, not a number */
+ rspamd_cl_chunk_restore_state (chunk, &s);
return FALSE;
}
else {
@@ -265,10 +306,12 @@ rspamd_cl_lex_number (struct rspamd_cl_parser *parser,
rspamd_cl_chunk_skipc (chunk, *p);
p ++;
if (p >= chunk->end) {
+ rspamd_cl_chunk_restore_state (chunk, &s);
return FALSE;
}
if (!g_ascii_isdigit (*p) && *p != '+' && *p != '-') {
/* Wrong exponent sign */
+ rspamd_cl_chunk_restore_state (chunk, &s);
return FALSE;
}
else {
@@ -295,6 +338,7 @@ rspamd_cl_lex_number (struct rspamd_cl_parser *parser,
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "numeric value is out of range", err);
parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
+ rspamd_cl_chunk_restore_state (chunk, &s);
return FALSE;
}
@@ -950,7 +994,7 @@ static gboolean
rspamd_cl_parse_after_value (struct rspamd_cl_parser *parser, struct rspamd_cl_chunk *chunk, GError **err)
{
const guchar *p;
- gboolean got_sep = FALSE, got_comma = FALSE, got_semicolon = FALSE;
+ gboolean got_sep = FALSE;
struct rspamd_cl_stack *st;
p = chunk->pos;
@@ -973,22 +1017,12 @@ rspamd_cl_parse_after_value (struct rspamd_cl_parser *parser, struct rspamd_cl_c
else if (*p == ',') {
/* Got a separator */
got_sep = TRUE;
- if (got_comma || got_semicolon) {
- rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "unexpected comma detected", err);
- return FALSE;
- }
- got_comma = TRUE;
rspamd_cl_chunk_skipc (chunk, *p);
p ++;
}
else if (*p == ';') {
/* Got a separator */
got_sep = TRUE;
- if (got_comma || got_semicolon) {
- rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "unexpected semicolon detected", err);
- return FALSE;
- }
- got_semicolon = TRUE;
rspamd_cl_chunk_skipc (chunk, *p);
p ++;
}
'>backport/48282/stable25 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/core/l10n/fr.json
blob: b7934e8e6ed92cd0d6c3dc08e36fa1c171bdf88b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321