3 static const char *alias_key
;
4 static char *alias_val
;
6 static int alias_lookup_cb(const char *k
, const char *v
,
7 void *cb __maybe_unused
)
9 if (!prefixcmp(k
, "alias.") && !strcmp(k
+6, alias_key
)) {
11 return config_error_nonbool(k
);
12 alias_val
= strdup(v
);
18 char *alias_lookup(const char *alias
)
22 perf_config(alias_lookup_cb
, NULL
);
26 int split_cmdline(char *cmdline
, const char ***argv
)
28 int src
, dst
, count
= 0, size
= 16;
31 *argv
= malloc(sizeof(char*) * size
);
33 /* split alias_string */
34 (*argv
)[count
++] = cmdline
;
35 for (src
= dst
= 0; cmdline
[src
];) {
36 char c
= cmdline
[src
];
37 if (!quoted
&& isspace(c
)) {
40 && isspace(cmdline
[src
]))
44 *argv
= realloc(*argv
, sizeof(char*) * size
);
46 (*argv
)[count
++] = cmdline
+ dst
;
47 } else if (!quoted
&& (c
== '\'' || c
== '"')) {
50 } else if (c
== quoted
) {
54 if (c
== '\\' && quoted
!= '\'') {
59 return error("cmdline ends with \\");
71 return error("unclosed quote");