John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 1 | #include "sort.h" |
Arnaldo Carvalho de Melo | 8a6c5b2 | 2010-07-20 14:42:52 -0300 | [diff] [blame^] | 2 | #include "hist.h" |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 3 | |
| 4 | regex_t parent_regex; |
Arnaldo Carvalho de Melo | edb7c60 | 2010-05-17 16:22:41 -0300 | [diff] [blame] | 5 | const char default_parent_pattern[] = "^sys_|^do_page_fault"; |
| 6 | const char *parent_pattern = default_parent_pattern; |
| 7 | const char default_sort_order[] = "comm,dso,symbol"; |
| 8 | const char *sort_order = default_sort_order; |
Frederic Weisbecker | af0a6fa | 2009-10-22 23:23:22 +0200 | [diff] [blame] | 9 | int sort__need_collapse = 0; |
| 10 | int sort__has_parent = 0; |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 11 | |
| 12 | enum sort_type sort__first_dimension; |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 13 | |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 14 | char * field_sep; |
| 15 | |
| 16 | LIST_HEAD(hist_entry__sort_list); |
| 17 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 18 | static int hist_entry__thread_snprintf(struct hist_entry *self, char *bf, |
| 19 | size_t size, unsigned int width); |
| 20 | static int hist_entry__comm_snprintf(struct hist_entry *self, char *bf, |
| 21 | size_t size, unsigned int width); |
| 22 | static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf, |
| 23 | size_t size, unsigned int width); |
| 24 | static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf, |
| 25 | size_t size, unsigned int width); |
| 26 | static int hist_entry__parent_snprintf(struct hist_entry *self, char *bf, |
| 27 | size_t size, unsigned int width); |
Arun Sharma | f60f359 | 2010-06-04 11:27:10 -0300 | [diff] [blame] | 28 | static int hist_entry__cpu_snprintf(struct hist_entry *self, char *bf, |
| 29 | size_t size, unsigned int width); |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 30 | |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 31 | struct sort_entry sort_thread = { |
Frederic Weisbecker | fcd1498 | 2010-04-14 19:11:29 +0200 | [diff] [blame] | 32 | .se_header = "Command: Pid", |
| 33 | .se_cmp = sort__thread_cmp, |
| 34 | .se_snprintf = hist_entry__thread_snprintf, |
Arnaldo Carvalho de Melo | 8a6c5b2 | 2010-07-20 14:42:52 -0300 | [diff] [blame^] | 35 | .se_width_idx = HISTC_THREAD, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | struct sort_entry sort_comm = { |
Frederic Weisbecker | fcd1498 | 2010-04-14 19:11:29 +0200 | [diff] [blame] | 39 | .se_header = "Command", |
| 40 | .se_cmp = sort__comm_cmp, |
| 41 | .se_collapse = sort__comm_collapse, |
| 42 | .se_snprintf = hist_entry__comm_snprintf, |
Arnaldo Carvalho de Melo | 8a6c5b2 | 2010-07-20 14:42:52 -0300 | [diff] [blame^] | 43 | .se_width_idx = HISTC_COMM, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct sort_entry sort_dso = { |
Frederic Weisbecker | fcd1498 | 2010-04-14 19:11:29 +0200 | [diff] [blame] | 47 | .se_header = "Shared Object", |
| 48 | .se_cmp = sort__dso_cmp, |
| 49 | .se_snprintf = hist_entry__dso_snprintf, |
Arnaldo Carvalho de Melo | 8a6c5b2 | 2010-07-20 14:42:52 -0300 | [diff] [blame^] | 50 | .se_width_idx = HISTC_DSO, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | struct sort_entry sort_sym = { |
Frederic Weisbecker | fcd1498 | 2010-04-14 19:11:29 +0200 | [diff] [blame] | 54 | .se_header = "Symbol", |
| 55 | .se_cmp = sort__sym_cmp, |
| 56 | .se_snprintf = hist_entry__sym_snprintf, |
Arnaldo Carvalho de Melo | 8a6c5b2 | 2010-07-20 14:42:52 -0300 | [diff] [blame^] | 57 | .se_width_idx = HISTC_SYMBOL, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | struct sort_entry sort_parent = { |
Frederic Weisbecker | fcd1498 | 2010-04-14 19:11:29 +0200 | [diff] [blame] | 61 | .se_header = "Parent symbol", |
| 62 | .se_cmp = sort__parent_cmp, |
| 63 | .se_snprintf = hist_entry__parent_snprintf, |
Arnaldo Carvalho de Melo | 8a6c5b2 | 2010-07-20 14:42:52 -0300 | [diff] [blame^] | 64 | .se_width_idx = HISTC_PARENT, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 65 | }; |
Arun Sharma | f60f359 | 2010-06-04 11:27:10 -0300 | [diff] [blame] | 66 | |
| 67 | struct sort_entry sort_cpu = { |
| 68 | .se_header = "CPU", |
| 69 | .se_cmp = sort__cpu_cmp, |
| 70 | .se_snprintf = hist_entry__cpu_snprintf, |
Arnaldo Carvalho de Melo | 8a6c5b2 | 2010-07-20 14:42:52 -0300 | [diff] [blame^] | 71 | .se_width_idx = HISTC_CPU, |
Arun Sharma | f60f359 | 2010-06-04 11:27:10 -0300 | [diff] [blame] | 72 | }; |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 73 | |
| 74 | struct sort_dimension { |
| 75 | const char *name; |
| 76 | struct sort_entry *entry; |
| 77 | int taken; |
| 78 | }; |
| 79 | |
| 80 | static struct sort_dimension sort_dimensions[] = { |
| 81 | { .name = "pid", .entry = &sort_thread, }, |
| 82 | { .name = "comm", .entry = &sort_comm, }, |
| 83 | { .name = "dso", .entry = &sort_dso, }, |
| 84 | { .name = "symbol", .entry = &sort_sym, }, |
| 85 | { .name = "parent", .entry = &sort_parent, }, |
Arun Sharma | f60f359 | 2010-06-04 11:27:10 -0300 | [diff] [blame] | 86 | { .name = "cpu", .entry = &sort_cpu, }, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | int64_t cmp_null(void *l, void *r) |
| 90 | { |
| 91 | if (!l && !r) |
| 92 | return 0; |
| 93 | else if (!l) |
| 94 | return -1; |
| 95 | else |
| 96 | return 1; |
| 97 | } |
| 98 | |
| 99 | /* --sort pid */ |
| 100 | |
| 101 | int64_t |
| 102 | sort__thread_cmp(struct hist_entry *left, struct hist_entry *right) |
| 103 | { |
| 104 | return right->thread->pid - left->thread->pid; |
| 105 | } |
| 106 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 107 | static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 108 | { |
| 109 | int n; |
| 110 | va_list ap; |
| 111 | |
| 112 | va_start(ap, fmt); |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 113 | n = vsnprintf(bf, size, fmt, ap); |
| 114 | if (field_sep && n > 0) { |
| 115 | char *sep = bf; |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 116 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 117 | while (1) { |
| 118 | sep = strchr(sep, *field_sep); |
| 119 | if (sep == NULL) |
| 120 | break; |
| 121 | *sep = '.'; |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 122 | } |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 123 | } |
| 124 | va_end(ap); |
| 125 | return n; |
| 126 | } |
| 127 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 128 | static int hist_entry__thread_snprintf(struct hist_entry *self, char *bf, |
| 129 | size_t size, unsigned int width) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 130 | { |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 131 | return repsep_snprintf(bf, size, "%*s:%5d", width, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 132 | self->thread->comm ?: "", self->thread->pid); |
| 133 | } |
| 134 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 135 | static int hist_entry__comm_snprintf(struct hist_entry *self, char *bf, |
| 136 | size_t size, unsigned int width) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 137 | { |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 138 | return repsep_snprintf(bf, size, "%*s", width, self->thread->comm); |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /* --sort dso */ |
| 142 | |
| 143 | int64_t |
| 144 | sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) |
| 145 | { |
Arnaldo Carvalho de Melo | 59fd530 | 2010-03-24 16:40:17 -0300 | [diff] [blame] | 146 | struct dso *dso_l = left->ms.map ? left->ms.map->dso : NULL; |
| 147 | struct dso *dso_r = right->ms.map ? right->ms.map->dso : NULL; |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 148 | const char *dso_name_l, *dso_name_r; |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 149 | |
| 150 | if (!dso_l || !dso_r) |
| 151 | return cmp_null(dso_l, dso_r); |
| 152 | |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 153 | if (verbose) { |
| 154 | dso_name_l = dso_l->long_name; |
| 155 | dso_name_r = dso_r->long_name; |
| 156 | } else { |
| 157 | dso_name_l = dso_l->short_name; |
| 158 | dso_name_r = dso_r->short_name; |
| 159 | } |
| 160 | |
| 161 | return strcmp(dso_name_l, dso_name_r); |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 162 | } |
| 163 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 164 | static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf, |
| 165 | size_t size, unsigned int width) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 166 | { |
Arnaldo Carvalho de Melo | 59fd530 | 2010-03-24 16:40:17 -0300 | [diff] [blame] | 167 | if (self->ms.map && self->ms.map->dso) { |
| 168 | const char *dso_name = !verbose ? self->ms.map->dso->short_name : |
| 169 | self->ms.map->dso->long_name; |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 170 | return repsep_snprintf(bf, size, "%-*s", width, dso_name); |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 171 | } |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 172 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 173 | return repsep_snprintf(bf, size, "%*Lx", width, self->ip); |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | /* --sort symbol */ |
| 177 | |
| 178 | int64_t |
| 179 | sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) |
| 180 | { |
| 181 | u64 ip_l, ip_r; |
| 182 | |
Arnaldo Carvalho de Melo | 59fd530 | 2010-03-24 16:40:17 -0300 | [diff] [blame] | 183 | if (left->ms.sym == right->ms.sym) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 184 | return 0; |
| 185 | |
Arnaldo Carvalho de Melo | 59fd530 | 2010-03-24 16:40:17 -0300 | [diff] [blame] | 186 | ip_l = left->ms.sym ? left->ms.sym->start : left->ip; |
| 187 | ip_r = right->ms.sym ? right->ms.sym->start : right->ip; |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 188 | |
| 189 | return (int64_t)(ip_r - ip_l); |
| 190 | } |
| 191 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 192 | static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf, |
| 193 | size_t size, unsigned int width __used) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 194 | { |
| 195 | size_t ret = 0; |
| 196 | |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 197 | if (verbose) { |
Arnaldo Carvalho de Melo | 59fd530 | 2010-03-24 16:40:17 -0300 | [diff] [blame] | 198 | char o = self->ms.map ? dso__symtab_origin(self->ms.map->dso) : '!'; |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 199 | ret += repsep_snprintf(bf, size, "%#018llx %c ", self->ip, o); |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 200 | } |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 201 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 202 | ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", self->level); |
Arnaldo Carvalho de Melo | 59fd530 | 2010-03-24 16:40:17 -0300 | [diff] [blame] | 203 | if (self->ms.sym) |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 204 | ret += repsep_snprintf(bf + ret, size - ret, "%s", |
| 205 | self->ms.sym->name); |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 206 | else |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 207 | ret += repsep_snprintf(bf + ret, size - ret, "%#016llx", self->ip); |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 208 | |
| 209 | return ret; |
| 210 | } |
| 211 | |
| 212 | /* --sort comm */ |
| 213 | |
| 214 | int64_t |
| 215 | sort__comm_cmp(struct hist_entry *left, struct hist_entry *right) |
| 216 | { |
| 217 | return right->thread->pid - left->thread->pid; |
| 218 | } |
| 219 | |
| 220 | int64_t |
| 221 | sort__comm_collapse(struct hist_entry *left, struct hist_entry *right) |
| 222 | { |
| 223 | char *comm_l = left->thread->comm; |
| 224 | char *comm_r = right->thread->comm; |
| 225 | |
| 226 | if (!comm_l || !comm_r) |
| 227 | return cmp_null(comm_l, comm_r); |
| 228 | |
| 229 | return strcmp(comm_l, comm_r); |
| 230 | } |
| 231 | |
| 232 | /* --sort parent */ |
| 233 | |
| 234 | int64_t |
| 235 | sort__parent_cmp(struct hist_entry *left, struct hist_entry *right) |
| 236 | { |
| 237 | struct symbol *sym_l = left->parent; |
| 238 | struct symbol *sym_r = right->parent; |
| 239 | |
| 240 | if (!sym_l || !sym_r) |
| 241 | return cmp_null(sym_l, sym_r); |
| 242 | |
| 243 | return strcmp(sym_l->name, sym_r->name); |
| 244 | } |
| 245 | |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 246 | static int hist_entry__parent_snprintf(struct hist_entry *self, char *bf, |
| 247 | size_t size, unsigned int width) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 248 | { |
Arnaldo Carvalho de Melo | a4e3b95 | 2010-03-31 11:33:40 -0300 | [diff] [blame] | 249 | return repsep_snprintf(bf, size, "%-*s", width, |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 250 | self->parent ? self->parent->name : "[other]"); |
| 251 | } |
| 252 | |
Arun Sharma | f60f359 | 2010-06-04 11:27:10 -0300 | [diff] [blame] | 253 | /* --sort cpu */ |
| 254 | |
| 255 | int64_t |
| 256 | sort__cpu_cmp(struct hist_entry *left, struct hist_entry *right) |
| 257 | { |
| 258 | return right->cpu - left->cpu; |
| 259 | } |
| 260 | |
| 261 | static int hist_entry__cpu_snprintf(struct hist_entry *self, char *bf, |
| 262 | size_t size, unsigned int width) |
| 263 | { |
| 264 | return repsep_snprintf(bf, size, "%-*d", width, self->cpu); |
| 265 | } |
| 266 | |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 267 | int sort_dimension__add(const char *tok) |
| 268 | { |
| 269 | unsigned int i; |
| 270 | |
| 271 | for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) { |
| 272 | struct sort_dimension *sd = &sort_dimensions[i]; |
| 273 | |
| 274 | if (sd->taken) |
| 275 | continue; |
| 276 | |
| 277 | if (strncasecmp(tok, sd->name, strlen(tok))) |
| 278 | continue; |
| 279 | |
Frederic Weisbecker | fcd1498 | 2010-04-14 19:11:29 +0200 | [diff] [blame] | 280 | if (sd->entry->se_collapse) |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 281 | sort__need_collapse = 1; |
| 282 | |
| 283 | if (sd->entry == &sort_parent) { |
| 284 | int ret = regcomp(&parent_regex, parent_pattern, REG_EXTENDED); |
| 285 | if (ret) { |
| 286 | char err[BUFSIZ]; |
| 287 | |
| 288 | regerror(ret, &parent_regex, err, sizeof(err)); |
Arnaldo Carvalho de Melo | 2aefa4f | 2010-04-02 12:30:57 -0300 | [diff] [blame] | 289 | pr_err("Invalid regex: %s\n%s", parent_pattern, err); |
| 290 | return -EINVAL; |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 291 | } |
| 292 | sort__has_parent = 1; |
| 293 | } |
| 294 | |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 295 | if (list_empty(&hist_entry__sort_list)) { |
| 296 | if (!strcmp(sd->name, "pid")) |
| 297 | sort__first_dimension = SORT_PID; |
| 298 | else if (!strcmp(sd->name, "comm")) |
| 299 | sort__first_dimension = SORT_COMM; |
| 300 | else if (!strcmp(sd->name, "dso")) |
| 301 | sort__first_dimension = SORT_DSO; |
| 302 | else if (!strcmp(sd->name, "symbol")) |
| 303 | sort__first_dimension = SORT_SYM; |
| 304 | else if (!strcmp(sd->name, "parent")) |
| 305 | sort__first_dimension = SORT_PARENT; |
Arun Sharma | f60f359 | 2010-06-04 11:27:10 -0300 | [diff] [blame] | 306 | else if (!strcmp(sd->name, "cpu")) |
| 307 | sort__first_dimension = SORT_CPU; |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 308 | } |
Frederic Weisbecker | af0a6fa | 2009-10-22 23:23:22 +0200 | [diff] [blame] | 309 | |
John Kacur | dd68ada | 2009-09-24 18:02:49 +0200 | [diff] [blame] | 310 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); |
| 311 | sd->taken = 1; |
| 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | return -ESRCH; |
| 317 | } |
Arnaldo Carvalho de Melo | c8829c7 | 2009-12-14 20:09:29 -0200 | [diff] [blame] | 318 | |
| 319 | void setup_sorting(const char * const usagestr[], const struct option *opts) |
| 320 | { |
| 321 | char *tmp, *tok, *str = strdup(sort_order); |
| 322 | |
| 323 | for (tok = strtok_r(str, ", ", &tmp); |
| 324 | tok; tok = strtok_r(NULL, ", ", &tmp)) { |
| 325 | if (sort_dimension__add(tok) < 0) { |
| 326 | error("Unknown --sort key: `%s'", tok); |
| 327 | usage_with_options(usagestr, opts); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | free(str); |
| 332 | } |
Arnaldo Carvalho de Melo | c351c28 | 2009-12-16 13:49:27 -0200 | [diff] [blame] | 333 | |
| 334 | void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list, |
| 335 | const char *list_name, FILE *fp) |
| 336 | { |
| 337 | if (list && strlist__nr_entries(list) == 1) { |
| 338 | if (fp != NULL) |
| 339 | fprintf(fp, "# %s: %s\n", list_name, |
| 340 | strlist__entry(list, 0)->s); |
| 341 | self->elide = true; |
| 342 | } |
| 343 | } |