5 static const char *alias_key
;
6 static char *alias_val
;
8 static int alias_lookup_cb(const char *k
, const char *v
,
9 void *cb __maybe_unused
)
11 if (!prefixcmp(k
, "alias.") && !strcmp(k
+6, alias_key
)) {
13 return config_error_nonbool(k
);
14 alias_val
= strdup(v
);
20 char *alias_lookup(const char *alias
)
24 perf_config(alias_lookup_cb
, NULL
);
28 int split_cmdline(char *cmdline
, const char ***argv
)
30 int src
, dst
, count
= 0, size
= 16;
33 *argv
= malloc(sizeof(char*) * size
);
35 /* split alias_string */
36 (*argv
)[count
++] = cmdline
;
37 for (src
= dst
= 0; cmdline
[src
];) {
38 char c
= cmdline
[src
];
39 if (!quoted
&& isspace(c
)) {
42 && isspace(cmdline
[src
]))
46 *argv
= realloc(*argv
, sizeof(char*) * size
);
48 (*argv
)[count
++] = cmdline
+ dst
;
49 } else if (!quoted
&& (c
== '\'' || c
== '"')) {
52 } else if (c
== quoted
) {
56 if (c
== '\\' && quoted
!= '\'') {
61 return error("cmdline ends with \\");
73 return error("unclosed quote");