|
24 | 24 | #include <linux/sysctl.h>
|
25 | 25 | #include <linux/ctype.h>
|
26 | 26 | #include <linux/string.h>
|
| 27 | +#include <linux/string_helpers.h> |
27 | 28 | #include <linux/uaccess.h>
|
28 | 29 | #include <linux/dynamic_debug.h>
|
29 | 30 | #include <linux/debugfs.h>
|
@@ -276,47 +277,6 @@ static inline int parse_lineno(const char *str, unsigned int *val)
|
276 | 277 | return 0;
|
277 | 278 | }
|
278 | 279 |
|
279 |
| -/* |
280 |
| - * Undo octal escaping in a string, inplace. This is useful to |
281 |
| - * allow the user to express a query which matches a format |
282 |
| - * containing embedded spaces. |
283 |
| - */ |
284 |
| -static char *unescape(char *str) |
285 |
| -{ |
286 |
| - char *in = str; |
287 |
| - char *out = str; |
288 |
| - |
289 |
| - while (*in) { |
290 |
| - if (*in == '\\') { |
291 |
| - if (in[1] == '\\') { |
292 |
| - *out++ = '\\'; |
293 |
| - in += 2; |
294 |
| - continue; |
295 |
| - } else if (in[1] == 't') { |
296 |
| - *out++ = '\t'; |
297 |
| - in += 2; |
298 |
| - continue; |
299 |
| - } else if (in[1] == 'n') { |
300 |
| - *out++ = '\n'; |
301 |
| - in += 2; |
302 |
| - continue; |
303 |
| - } else if (isodigit(in[1]) && |
304 |
| - isodigit(in[2]) && |
305 |
| - isodigit(in[3])) { |
306 |
| - *out++ = (((in[1] - '0') << 6) | |
307 |
| - ((in[2] - '0') << 3) | |
308 |
| - (in[3] - '0')); |
309 |
| - in += 4; |
310 |
| - continue; |
311 |
| - } |
312 |
| - } |
313 |
| - *out++ = *in++; |
314 |
| - } |
315 |
| - *out = '\0'; |
316 |
| - |
317 |
| - return str; |
318 |
| -} |
319 |
| - |
320 | 280 | static int check_set(const char **dest, char *src, char *name)
|
321 | 281 | {
|
322 | 282 | int rc = 0;
|
@@ -370,8 +330,10 @@ static int ddebug_parse_query(char *words[], int nwords,
|
370 | 330 | } else if (!strcmp(words[i], "module")) {
|
371 | 331 | rc = check_set(&query->module, words[i+1], "module");
|
372 | 332 | } else if (!strcmp(words[i], "format")) {
|
373 |
| - rc = check_set(&query->format, unescape(words[i+1]), |
374 |
| - "format"); |
| 333 | + string_unescape_inplace(words[i+1], UNESCAPE_SPACE | |
| 334 | + UNESCAPE_OCTAL | |
| 335 | + UNESCAPE_SPECIAL); |
| 336 | + rc = check_set(&query->format, words[i+1], "format"); |
375 | 337 | } else if (!strcmp(words[i], "line")) {
|
376 | 338 | char *first = words[i+1];
|
377 | 339 | char *last = strchr(first, '-');
|
|
0 commit comments