~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/alias.c

Version: ~ [ linux-5.19-rc8 ] ~ [ linux-5.18.14 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.57 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.133 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.207 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.253 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.289 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.324 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include "cache.h"
  2 
  3 static const char *alias_key;
  4 static char *alias_val;
  5 
  6 static int alias_lookup_cb(const char *k, const char *v,
  7                            void *cb __maybe_unused)
  8 {
  9         if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) {
 10                 if (!v)
 11                         return config_error_nonbool(k);
 12                 alias_val = strdup(v);
 13                 return 0;
 14         }
 15         return 0;
 16 }
 17 
 18 char *alias_lookup(const char *alias)
 19 {
 20         alias_key = alias;
 21         alias_val = NULL;
 22         perf_config(alias_lookup_cb, NULL);
 23         return alias_val;
 24 }
 25 
 26 int split_cmdline(char *cmdline, const char ***argv)
 27 {
 28         int src, dst, count = 0, size = 16;
 29         char quoted = 0;
 30 
 31         *argv = malloc(sizeof(char*) * size);
 32 
 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)) {
 38                         cmdline[dst++] = 0;
 39                         while (cmdline[++src]
 40                                         && isspace(cmdline[src]))
 41                                 ; /* skip */
 42                         if (count >= size) {
 43                                 size += 16;
 44                                 *argv = realloc(*argv, sizeof(char*) * size);
 45                         }
 46                         (*argv)[count++] = cmdline + dst;
 47                 } else if (!quoted && (c == '\'' || c == '"')) {
 48                         quoted = c;
 49                         src++;
 50                 } else if (c == quoted) {
 51                         quoted = 0;
 52                         src++;
 53                 } else {
 54                         if (c == '\\' && quoted != '\'') {
 55                                 src++;
 56                                 c = cmdline[src];
 57                                 if (!c) {
 58                                         zfree(argv);
 59                                         return error("cmdline ends with \\");
 60                                 }
 61                         }
 62                         cmdline[dst++] = c;
 63                         src++;
 64                 }
 65         }
 66 
 67         cmdline[dst] = 0;
 68 
 69         if (quoted) {
 70                 zfree(argv);
 71                 return error("unclosed quote");
 72         }
 73 
 74         return count;
 75 }
 76 
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp