mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

strpbrk_esq() and strdup_esq() are new variants for strpbrk() and strdup() which handles escaped characters and quoted strings. - strpbrk_esq() searches specified set of characters but ignores the escaped characters and quoted strings. e.g. strpbrk_esq("'quote\d' \queue quiz", "qd") returns "quiz". - strdup_esq() duplicates string but removes backslash and quotes which is used for quotation. It also keeps the string (including backslash) in the quoted part. e.g. strdup_esq("'quote\d' \queue quiz") returns "quote\d queue quiz". The (single, double) quotes in the quoted part should be escaped by backslash. In this case, strdup_esq() removes that backslash. The same quotes must be paired. If you use double quotation, you need to use the double quotation to close the quoted part. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Cc: Alexander Lobakin <aleksander.lobakin@intel.com> Cc: Dima Kogan <dima@secretsauce.net> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com> Link: https://lore.kernel.org/r/173099116045.2431889.15772916605719019533.stgit@mhiramat.roam.corp.google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
46 lines
1.3 KiB
C
46 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef PERF_STRING_H
|
|
#define PERF_STRING_H
|
|
|
|
#include <linux/string.h>
|
|
#include <linux/types.h>
|
|
#include <sys/types.h> // pid_t
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
extern const char *graph_dotted_line;
|
|
extern const char *dots;
|
|
|
|
s64 perf_atoll(const char *str);
|
|
bool strglobmatch(const char *str, const char *pat);
|
|
bool strglobmatch_nocase(const char *str, const char *pat);
|
|
bool strlazymatch(const char *str, const char *pat);
|
|
static inline bool strisglob(const char *str)
|
|
{
|
|
return strpbrk(str, "*?[") != NULL;
|
|
}
|
|
int strtailcmp(const char *s1, const char *s2);
|
|
|
|
char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
|
|
|
|
static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
|
|
{
|
|
return asprintf_expr_inout_ints(var, true, nints, ints);
|
|
}
|
|
|
|
static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
|
|
{
|
|
return asprintf_expr_inout_ints(var, false, nints, ints);
|
|
}
|
|
|
|
char *asprintf__tp_filter_pids(size_t npids, pid_t *pids);
|
|
|
|
char *strpbrk_esc(char *str, const char *stopset);
|
|
char *strdup_esc(const char *str);
|
|
char *strpbrk_esq(char *str, const char *stopset);
|
|
char *strdup_esq(const char *str);
|
|
|
|
unsigned int hex(char c);
|
|
char *strreplace_chars(char needle, const char *haystack, const char *replace);
|
|
|
|
#endif /* PERF_STRING_H */
|