summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/findutils/findutils-4.4.2/01-27017.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended/findutils/findutils-4.4.2/01-27017.patch')
-rw-r--r--meta/recipes-extended/findutils/findutils-4.4.2/01-27017.patch781
1 files changed, 0 insertions, 781 deletions
diff --git a/meta/recipes-extended/findutils/findutils-4.4.2/01-27017.patch b/meta/recipes-extended/findutils/findutils-4.4.2/01-27017.patch
deleted file mode 100644
index 69c1486cf7..0000000000
--- a/meta/recipes-extended/findutils/findutils-4.4.2/01-27017.patch
+++ /dev/null
@@ -1,781 +0,0 @@
1Upstream-Status: Backport
2
3commit af974034b68bf59337c7a384e488a518a77dfecd
4Author: James Youngman <jay@gnu.org>
5Date: Sat Jul 11 19:55:27 2009 +0100
6
7 Fix Savannah bug #27017: find -D opt / -fstype ext3 -print , -quit coredump.
8
9 Fix Savannah bug #27017: find -D opt / -fstype ext3 -print , -quit
10 coredumps.
11 * find/tree.c (set_new_parent): Initialise struct
12 predicate->arg_text to NULL (instead of leaving it uninitialised).
13 (get_new_pred_noarg): Likewise.
14 (get_new_pred): Initialise predicate->arg_text to
15 "ThisShouldBeSetToSomethingElse" to make it easier to notice
16 bugs.
17 (get_new_pred_chk_op): Use get_new_pred_noarg.
18 (print_predicate): Use an if statement instead of
19 two ternary operators.
20 * find/util.c (insert_primary_withpred): Accept new argument, arg,
21 being the argument (if any) of this predicate. Pass it to
22 get_new_pred_chk_op.
23 (insert_primary): Likewise (pass arg to insert_primary_withpred).
24 (insert_primary_noarg): New function; calls insert_primary with
25 arg=NULL.
26 * find/parser.c (collect_arg_stat_info): Add an output parameter;
27 the filename from which we collected the stat information.
28 (parse_closeparen, parse_delete, parse_and, parse_or,
29 parse_comma): Use get_new_pred_noarg.
30 (parse_cnewer, parse_newer, parse_anewer): Use new
31 collect_arg_stat_info and insert_primary interface.
32 (parse_print, parse_prune, parse_nouser, parse_empty): Use
33 insert_primary_noarg.
34 (parse_accesscheck, parse_false): Use insert_primary_noarg.
35 (parse_used, parse_iname, parse_fprint, insert_fprint,
36 parse_fstype, parse_ilname): Use new collect_arg and
37 insert_primary interfaces.
38 (parse_ipath, parse_lname, do_parse_xmin, parse_name, parse_path,
39 parse_perm, parse_size, parse_user, parse_time): Use new
40 collect_arg and insert_primary_withpred interface.
41 (parse_negate, parse_openparen): Use new get_new_pred_chk_op interface.
42 (parse_newerXY, parse_nogroup): Use new insert_primary interface.
43 (insert_regex, parse_samefile): Use new insert_primary_withpred
44 interface.
45 (insert_type, insert_fprintf, new_insert_exec_ok, insert_num): Use
46 new insert_primary_withpred interface.
47 * find/defs.h (struct predicate.arg_text): make const.
48 Add declarations for new function get_new_pred_noarg and
49 insert_primary_noarg. Add 'arg' parameter to get_new_pred_chk_op
50 and insert_primary_withpred.
51
52diff --git a/ChangeLog b/ChangeLog
53index 6e346b8..e8ba0f8 100644
54--- a/ChangeLog
55+++ b/ChangeLog
56@@ -1,0 +1,45 @@
57+2009-07-11 James Youngman <jay@gnu.org>
58+
59+ Fix Savannah bug #27017: find -D opt / -fstype ext3 -print , -quit
60+ coredumps.
61+ * find/tree.c (set_new_parent): Initialise struct
62+ predicate->arg_text to NULL (instead of leaving it uninitialised).
63+ (get_new_pred_noarg): Likewise.
64+ (get_new_pred): Initialise predicate->arg_text to
65+ "ThisShouldBeSetToSomethingElse" to make it easier to notice
66+ bugs.
67+ (get_new_pred_chk_op): Use get_new_pred_noarg.
68+ (print_predicate): Use an if statement instead of
69+ two ternary operators.
70+ * find/util.c (insert_primary_withpred): Accept new argument, arg,
71+ being the argument (if any) of this predicate. Pass it to
72+ get_new_pred_chk_op.
73+ (insert_primary): Likewise (pass arg to insert_primary_withpred).
74+ (insert_primary_noarg): New function; calls insert_primary with
75+ arg=NULL.
76+ * find/parser.c (collect_arg_stat_info): Add an output parameter;
77+ the filename from which we collected the stat information.
78+ (parse_closeparen, parse_delete, parse_and, parse_or,
79+ parse_comma): Use get_new_pred_noarg.
80+ (parse_cnewer, parse_newer, parse_anewer): Use new
81+ collect_arg_stat_info and insert_primary interface.
82+ (parse_print, parse_prune, parse_nouser, parse_empty): Use
83+ insert_primary_noarg.
84+ (parse_accesscheck, parse_false): Use insert_primary_noarg.
85+ (parse_used, parse_iname, parse_fprint, insert_fprint,
86+ parse_fstype, parse_ilname): Use new collect_arg and
87+ insert_primary interfaces.
88+ (parse_ipath, parse_lname, do_parse_xmin, parse_name, parse_path,
89+ parse_perm, parse_size, parse_user, parse_time): Use new
90+ collect_arg and insert_primary_withpred interface.
91+ (parse_negate, parse_openparen): Use new get_new_pred_chk_op interface.
92+ (parse_newerXY, parse_nogroup): Use new insert_primary interface.
93+ (insert_regex, parse_samefile): Use new insert_primary_withpred
94+ interface.
95+ (insert_type, insert_fprintf, new_insert_exec_ok, insert_num): Use
96+ new insert_primary_withpred interface.
97+ * find/defs.h (struct predicate.arg_text): make const.
98+ Add declarations for new function get_new_pred_noarg and
99+ insert_primary_noarg. Add 'arg' parameter to get_new_pred_chk_op
100+ and insert_primary_withpred.
101+
102diff --git a/find/defs.h b/find/defs.h
103index 1708d83..4539fd9 100644
104--- a/find/defs.h
105+++ b/find/defs.h
106@@ -297,7 +297,7 @@ struct predicate
107 boolean artificial;
108
109 /* The raw text of the argument of this predicate. */
110- char *arg_text;
111+ const char *arg_text;
112
113 /* Information needed by the predicate processor.
114 Next to each member are listed the predicates that use it. */
115@@ -480,13 +480,16 @@ void show_success_rates(const struct predicate *node);
116 /* tree.c */
117 struct predicate * build_expression_tree PARAMS((int argc, char *argv[], int end_of_leading_options));
118 struct predicate * get_eval_tree PARAMS((void));
119+struct predicate *get_new_pred_noarg (const struct parser_table *entry);
120 struct predicate *get_new_pred PARAMS((const struct parser_table *entry));
121-struct predicate *get_new_pred_chk_op PARAMS((const struct parser_table *entry));
122+struct predicate *get_new_pred_chk_op PARAMS((const struct parser_table *entry,
123+ const char *arg));
124 float calculate_derived_rates PARAMS((struct predicate *p));
125
126 /* util.c */
127-struct predicate *insert_primary PARAMS((const struct parser_table *entry));
128-struct predicate *insert_primary_withpred PARAMS((const struct parser_table *entry, PRED_FUNC fptr));
129+struct predicate *insert_primary PARAMS((const struct parser_table *entry, const char *arg));
130+struct predicate *insert_primary_noarg PARAMS((const struct parser_table *entry));
131+struct predicate *insert_primary_withpred PARAMS((const struct parser_table *entry, PRED_FUNC fptr, const char *arg));
132 void usage PARAMS((FILE *fp, int status, char *msg));
133 extern boolean check_nofollow(void);
134 void complete_pending_execs(struct predicate *p);
135diff --git a/find/parser.c b/find/parser.c
136index 534b670..2e6b989 100644
137--- a/find/parser.c
138+++ b/find/parser.c
139@@ -640,11 +640,13 @@ collect_arg(char **argv, int *arg_ptr, const char **collected_arg)
140 }
141
142 static boolean
143-collect_arg_stat_info(char **argv, int *arg_ptr, struct stat *p)
144+collect_arg_stat_info(char **argv, int *arg_ptr, struct stat *p,
145+ const char **argument)
146 {
147 const char *filename;
148 if (collect_arg(argv, arg_ptr, &filename))
149 {
150+ *argument = filename;
151 if (0 == (options.xstat)(filename, p))
152 {
153 return true;
154@@ -656,6 +658,7 @@ collect_arg_stat_info(char **argv, int *arg_ptr, struct stat *p)
155 }
156 else
157 {
158+ *argument = NULL;
159 return false;
160 }
161 }
162@@ -679,7 +682,7 @@ parse_and (const struct parser_table* entry, char **argv, int *arg_ptr)
163 (void) argv;
164 (void) arg_ptr;
165
166- our_pred = get_new_pred (entry);
167+ our_pred = get_new_pred_noarg (entry);
168 our_pred->pred_func = pred_and;
169 our_pred->p_type = BI_OP;
170 our_pred->p_prec = AND_PREC;
171@@ -691,11 +694,12 @@ static boolean
172 parse_anewer (const struct parser_table* entry, char **argv, int *arg_ptr)
173 {
174 struct stat stat_newer;
175+ const char *arg;
176
177 set_stat_placeholders(&stat_newer);
178- if (collect_arg_stat_info(argv, arg_ptr, &stat_newer))
179+ if (collect_arg_stat_info(argv, arg_ptr, &stat_newer, &arg))
180 {
181- struct predicate *our_pred = insert_primary (entry);
182+ struct predicate *our_pred = insert_primary (entry, arg);
183 our_pred->args.reftime.xval = XVAL_ATIME;
184 our_pred->args.reftime.ts = get_stat_mtime(&stat_newer);
185 our_pred->args.reftime.kind = COMP_GT;
186@@ -713,7 +717,7 @@ parse_closeparen (const struct parser_table* entry, char **argv, int *arg_ptr)
187 (void) argv;
188 (void) arg_ptr;
189
190- our_pred = get_new_pred (entry);
191+ our_pred = get_new_pred_noarg (entry);
192 our_pred->pred_func = pred_closeparen;
193 our_pred->p_type = CLOSE_PAREN;
194 our_pred->p_prec = NO_PREC;
195@@ -725,11 +729,12 @@ static boolean
196 parse_cnewer (const struct parser_table* entry, char **argv, int *arg_ptr)
197 {
198 struct stat stat_newer;
199+ const char *arg;
200
201 set_stat_placeholders(&stat_newer);
202- if (collect_arg_stat_info(argv, arg_ptr, &stat_newer))
203+ if (collect_arg_stat_info(argv, arg_ptr, &stat_newer, &arg))
204 {
205- struct predicate *our_pred = insert_primary (entry);
206+ struct predicate *our_pred = insert_primary (entry, arg);
207 our_pred->args.reftime.xval = XVAL_CTIME; /* like -newercm */
208 our_pred->args.reftime.ts = get_stat_mtime(&stat_newer);
209 our_pred->args.reftime.kind = COMP_GT;
210@@ -747,7 +752,7 @@ parse_comma (const struct parser_table* entry, char **argv, int *arg_ptr)
211 (void) argv;
212 (void) arg_ptr;
213
214- our_pred = get_new_pred (entry);
215+ our_pred = get_new_pred_noarg (entry);
216 our_pred->pred_func = pred_comma;
217 our_pred->p_type = BI_OP;
218 our_pred->p_prec = COMMA_PREC;
219@@ -786,7 +791,7 @@ parse_delete (const struct parser_table* entry, char *argv[], int *arg_ptr)
220 (void) argv;
221 (void) arg_ptr;
222
223- our_pred = insert_primary (entry);
224+ our_pred = insert_primary_noarg (entry);
225 our_pred->side_effects = our_pred->no_default_print = true;
226 /* -delete implies -depth */
227 options.do_dir_first = false;
228@@ -831,7 +836,7 @@ parse_empty (const struct parser_table* entry, char **argv, int *arg_ptr)
229 (void) argv;
230 (void) arg_ptr;
231
232- our_pred = insert_primary (entry);
233+ our_pred = insert_primary_noarg (entry);
234 our_pred->est_success_rate = 0.01f; /* assume 1% of files are empty. */
235 return true;
236 }
237@@ -856,7 +861,7 @@ parse_false (const struct parser_table* entry, char **argv, int *arg_ptr)
238 (void) argv;
239 (void) arg_ptr;
240
241- our_pred = insert_primary (entry);
242+ our_pred = insert_primary_noarg (entry);
243 our_pred->need_stat = our_pred->need_type = false;
244 our_pred->side_effects = our_pred->no_default_print = false;
245 our_pred->est_success_rate = 0.0f;
246@@ -866,7 +871,7 @@ parse_false (const struct parser_table* entry, char **argv, int *arg_ptr)
247 static boolean
248 insert_fls (const struct parser_table* entry, const char *filename)
249 {
250- struct predicate *our_pred = insert_primary (entry);
251+ struct predicate *our_pred = insert_primary_noarg (entry);
252 if (filename)
253 open_output_file (filename, &our_pred->args.printf_vec);
254 else
255@@ -899,7 +904,7 @@ parse_fprint (const struct parser_table* entry, char **argv, int *arg_ptr)
256 const char *filename;
257 if (collect_arg(argv, arg_ptr, &filename))
258 {
259- our_pred = insert_primary (entry);
260+ our_pred = insert_primary (entry, filename);
261 open_output_file (filename, &our_pred->args.printf_vec);
262 our_pred->side_effects = our_pred->no_default_print = true;
263 our_pred->need_stat = our_pred->need_type = false;
264@@ -915,7 +920,7 @@ parse_fprint (const struct parser_table* entry, char **argv, int *arg_ptr)
265 static boolean
266 insert_fprint(const struct parser_table* entry, const char *filename)
267 {
268- struct predicate *our_pred = insert_primary (entry);
269+ struct predicate *our_pred = insert_primary (entry, filename);
270 if (filename)
271 open_output_file (filename, &our_pred->args.printf_vec);
272 else
273@@ -960,7 +965,7 @@ parse_fstype (const struct parser_table* entry, char **argv, int *arg_ptr)
274 const char *typename;
275 if (collect_arg(argv, arg_ptr, &typename))
276 {
277- struct predicate *our_pred = insert_primary (entry);
278+ struct predicate *our_pred = insert_primary (entry, typename);
279 our_pred->args.str = typename;
280
281 /* This is an expensive operation, so although there are
282@@ -1090,7 +1095,7 @@ parse_group (const struct parser_table* entry, char **argv, int *arg_ptr)
283 return false;
284 }
285 }
286- our_pred = insert_primary (entry);
287+ our_pred = insert_primary (entry, groupname);
288 our_pred->args.gid = gid;
289 our_pred->est_success_rate = (our_pred->args.numinfo.l_val < 100) ? 0.99 : 0.2;
290 return true;
291@@ -1160,7 +1165,7 @@ parse_ilname (const struct parser_table* entry, char **argv, int *arg_ptr)
292 const char *name;
293 if (collect_arg(argv, arg_ptr, &name))
294 {
295- struct predicate *our_pred = insert_primary (entry);
296+ struct predicate *our_pred = insert_primary (entry, name);
297 our_pred->args.str = name;
298 /* Use the generic glob pattern estimator to figure out how many
299 * links will match, but bear in mind that most files won't be links.
300@@ -1227,7 +1232,7 @@ parse_iname (const struct parser_table* entry, char **argv, int *arg_ptr)
301 {
302 if (check_name_arg("-iname", name))
303 {
304- struct predicate *our_pred = insert_primary (entry);
305+ struct predicate *our_pred = insert_primary (entry, name);
306 our_pred->need_stat = our_pred->need_type = false;
307 our_pred->args.str = name;
308 our_pred->est_success_rate = estimate_pattern_match_rate(name, 0);
309@@ -1268,7 +1273,7 @@ parse_ipath (const struct parser_table* entry, char **argv, int *arg_ptr)
310 fnmatch_sanitycheck ();
311 if (collect_arg (argv, arg_ptr, &name))
312 {
313- struct predicate *our_pred = insert_primary_withpred (entry, pred_ipath);
314+ struct predicate *our_pred = insert_primary_withpred (entry, pred_ipath, name);
315 our_pred->need_stat = our_pred->need_type = false;
316 our_pred->args.str = name;
317 our_pred->est_success_rate = estimate_pattern_match_rate (name, 0);
318@@ -1316,7 +1321,7 @@ parse_lname (const struct parser_table* entry, char **argv, int *arg_ptr)
319 fnmatch_sanitycheck();
320 if (collect_arg(argv, arg_ptr, &name))
321 {
322- struct predicate *our_pred = insert_primary (entry);
323+ struct predicate *our_pred = insert_primary (entry, name);
324 our_pred->args.str = name;
325 our_pred->est_success_rate = 0.1 * estimate_pattern_match_rate(name, 0);
326 return true;
327@@ -1391,7 +1396,7 @@ do_parse_xmin (const struct parser_table* entry,
328 "arithmetic overflow while converting %s "
329 "minutes to a number of seconds"))
330 {
331- struct predicate *our_pred = insert_primary (entry);
332+ struct predicate *our_pred = insert_primary (entry, minutes);
333 our_pred->args.reftime = tval;
334 our_pred->est_success_rate = estimate_timestamp_success_rate(tval.ts.tv_sec);
335 return true;
336@@ -1427,7 +1432,7 @@ parse_name (const struct parser_table* entry, char **argv, int *arg_ptr)
337 fnmatch_sanitycheck();
338 if (check_name_arg("-name", name))
339 {
340- struct predicate *our_pred = insert_primary (entry);
341+ struct predicate *our_pred = insert_primary (entry, name);
342 our_pred->need_stat = our_pred->need_type = false;
343 our_pred->args.str = name;
344 our_pred->est_success_rate = estimate_pattern_match_rate(name, 0);
345@@ -1445,7 +1450,7 @@ parse_negate (const struct parser_table* entry, char **argv, int *arg_ptr)
346 (void) &argv;
347 (void) &arg_ptr;
348
349- our_pred = get_new_pred_chk_op (entry);
350+ our_pred = get_new_pred_chk_op (entry, NULL);
351 our_pred->pred_func = pred_negate;
352 our_pred->p_type = UNI_OP;
353 our_pred->p_prec = NEGATE_PREC;
354@@ -1458,11 +1463,12 @@ parse_newer (const struct parser_table* entry, char **argv, int *arg_ptr)
355 {
356 struct predicate *our_pred;
357 struct stat stat_newer;
358+ const char *arg;
359
360 set_stat_placeholders(&stat_newer);
361- if (collect_arg_stat_info(argv, arg_ptr, &stat_newer))
362+ if (collect_arg_stat_info(argv, arg_ptr, &stat_newer, &arg))
363 {
364- our_pred = insert_primary (entry);
365+ our_pred = insert_primary (entry, arg);
366 our_pred->args.reftime.ts = get_stat_mtime(&stat_newer);
367 our_pred->args.reftime.xval = XVAL_MTIME;
368 our_pred->args.reftime.kind = COMP_GT;
369@@ -1530,7 +1536,7 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
370 (*arg_ptr)++;
371 }
372
373- our_pred = insert_primary (entry);
374+ our_pred = insert_primary (entry, argv[*arg_ptr]);
375
376
377 switch (x)
378@@ -1623,7 +1629,7 @@ parse_nogroup (const struct parser_table* entry, char **argv, int *arg_ptr)
379 (void) &argv;
380 (void) &arg_ptr;
381
382- our_pred = insert_primary (entry);
383+ our_pred = insert_primary (entry, NULL);
384 our_pred->est_success_rate = 1e-4;
385 #ifdef CACHE_IDS
386 if (gid_unused == NULL)
387@@ -1660,7 +1666,7 @@ parse_nouser (const struct parser_table* entry, char **argv, int *arg_ptr)
388 (void) arg_ptr;
389
390
391- our_pred = insert_primary (entry);
392+ our_pred = insert_primary_noarg (entry);
393 our_pred->est_success_rate = 1e-3;
394 #ifdef CACHE_IDS
395 if (uid_unused == NULL)
396@@ -1716,7 +1722,7 @@ parse_openparen (const struct parser_table* entry, char **argv, int *arg_ptr)
397 (void) argv;
398 (void) arg_ptr;
399
400- our_pred = get_new_pred_chk_op (entry);
401+ our_pred = get_new_pred_chk_op (entry, NULL);
402 our_pred->pred_func = pred_openparen;
403 our_pred->p_type = OPEN_PAREN;
404 our_pred->p_prec = NO_PREC;
405@@ -1732,7 +1738,7 @@ parse_or (const struct parser_table* entry, char **argv, int *arg_ptr)
406 (void) argv;
407 (void) arg_ptr;
408
409- our_pred = get_new_pred (entry);
410+ our_pred = get_new_pred_noarg (entry);
411 our_pred->pred_func = pred_or;
412 our_pred->p_type = BI_OP;
413 our_pred->p_prec = OR_PREC;
414@@ -1756,7 +1762,7 @@ parse_path (const struct parser_table* entry, char **argv, int *arg_ptr)
415 const char *name;
416 if (collect_arg(argv, arg_ptr, &name))
417 {
418- struct predicate *our_pred = insert_primary_withpred (entry, pred_path);
419+ struct predicate *our_pred = insert_primary_withpred (entry, pred_path, name);
420 our_pred->need_stat = our_pred->need_type = false;
421 our_pred->args.str = name;
422 our_pred->est_success_rate = estimate_pattern_match_rate (name, 0);
423@@ -1894,7 +1900,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
424 rate = 0.9986; /* probably matches anything but a broken symlink */
425 }
426
427- our_pred = insert_primary (entry);
428+ our_pred = insert_primary (entry, perm_expr);
429 our_pred->est_success_rate = rate;
430 if (havekind)
431 {
432@@ -1928,7 +1934,7 @@ parse_print (const struct parser_table* entry, char **argv, int *arg_ptr)
433 (void) argv;
434 (void) arg_ptr;
435
436- our_pred = insert_primary (entry);
437+ our_pred = insert_primary_noarg (entry);
438 /* -print has the side effect of printing. This prevents us
439 from doing undesired multiple printing when the user has
440 already specified -print. */
441@@ -1981,7 +1987,7 @@ parse_prune (const struct parser_table* entry, char **argv, int *arg_ptr)
442 (void) argv;
443 (void) arg_ptr;
444
445- our_pred = insert_primary (entry);
446+ our_pred = insert_primary_noarg (entry);
447 if (options.do_dir_first == false)
448 our_pred->need_stat = our_pred->need_type = false;
449 /* -prune has a side effect that it does not descend into
450@@ -1994,7 +2000,7 @@ parse_prune (const struct parser_table* entry, char **argv, int *arg_ptr)
451 static boolean
452 parse_quit (const struct parser_table* entry, char **argv, int *arg_ptr)
453 {
454- struct predicate *our_pred = insert_primary (entry);
455+ struct predicate *our_pred = insert_primary_noarg (entry);
456 (void) argv;
457 (void) arg_ptr;
458 our_pred->need_stat = our_pred->need_type = false;
459@@ -2036,7 +2042,7 @@ insert_regex (char **argv,
460 {
461 struct re_pattern_buffer *re;
462 const char *error_message;
463- struct predicate *our_pred = insert_primary_withpred (entry, pred_regex);
464+ struct predicate *our_pred = insert_primary_withpred (entry, pred_regex, rx);
465 our_pred->need_stat = our_pred->need_type = false;
466 re = xmalloc (sizeof (struct re_pattern_buffer));
467 our_pred->args.regex = re;
468@@ -2061,6 +2067,7 @@ static boolean
469 parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
470 {
471 struct predicate *our_pred;
472+ char *arg;
473 uintmax_t num;
474 char suffix;
475 enum comparison_type c_type;
476@@ -2073,42 +2080,43 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
477 */
478 if ((argv == NULL) || (argv[*arg_ptr] == NULL))
479 return false;
480+ arg = argv[*arg_ptr];
481
482- len = strlen (argv[*arg_ptr]);
483+ len = strlen (arg);
484 if (len == 0)
485 error (1, 0, _("invalid null argument to -size"));
486
487- suffix = argv[*arg_ptr][len - 1];
488+ suffix = arg[len - 1];
489 switch (suffix)
490 {
491 case 'b':
492 blksize = 512;
493- argv[*arg_ptr][len - 1] = '\0';
494+ arg[len - 1] = '\0';
495 break;
496
497 case 'c':
498 blksize = 1;
499- argv[*arg_ptr][len - 1] = '\0';
500+ arg[len - 1] = '\0';
501 break;
502
503 case 'k':
504 blksize = 1024;
505- argv[*arg_ptr][len - 1] = '\0';
506+ arg[len - 1] = '\0';
507 break;
508
509 case 'M': /* Megabytes */
510 blksize = 1024*1024;
511- argv[*arg_ptr][len - 1] = '\0';
512+ arg[len - 1] = '\0';
513 break;
514
515 case 'G': /* Gigabytes */
516 blksize = 1024*1024*1024;
517- argv[*arg_ptr][len - 1] = '\0';
518+ arg[len - 1] = '\0';
519 break;
520
521 case 'w':
522 blksize = 2;
523- argv[*arg_ptr][len - 1] = '\0';
524+ arg[len - 1] = '\0';
525 break;
526
527 case '0':
528@@ -2127,14 +2135,14 @@ parse_size (const struct parser_table* entry, char **argv, int *arg_ptr)
529 error (1, 0, _("invalid -size type `%c'"), argv[*arg_ptr][len - 1]);
530 }
531 /* TODO: accept fractional megabytes etc. ? */
532- if (!get_num (argv[*arg_ptr], &num, &c_type))
533+ if (!get_num (arg, &num, &c_type))
534 {
535 error(1, 0,
536 _("Invalid argument `%s%c' to -size"),
537- argv[*arg_ptr], (int)suffix);
538+ arg, (int)suffix);
539 return false;
540 }
541- our_pred = insert_primary (entry);
542+our_pred = insert_primary (entry, arg);
543 our_pred->args.size.kind = c_type;
544 our_pred->args.size.blocksize = blksize;
545 our_pred->args.size.size = num;
546@@ -2162,9 +2170,10 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr)
547 struct predicate *our_pred;
548 struct stat st, fst;
549 int fd, openflags;
550+ const char *filename;
551
552 set_stat_placeholders(&st);
553- if (!collect_arg_stat_info(argv, arg_ptr, &st))
554+ if (!collect_arg_stat_info(argv, arg_ptr, &st, &filename))
555 return false;
556
557 set_stat_placeholders(&fst);
558@@ -2289,7 +2298,7 @@ parse_samefile (const struct parser_table* entry, char **argv, int *arg_ptr)
559 }
560 }
561
562- our_pred = insert_primary (entry);
563+ our_pred = insert_primary (entry, filename);
564 our_pred->args.samefileid.ino = st.st_ino;
565 our_pred->args.samefileid.dev = st.st_dev;
566 our_pred->args.samefileid.fd = fd;
567@@ -2350,7 +2359,7 @@ parse_true (const struct parser_table* entry, char **argv, int *arg_ptr)
568 (void) argv;
569 (void) arg_ptr;
570
571- our_pred = insert_primary (entry);
572+ our_pred = insert_primary_noarg (entry);
573 our_pred->need_stat = our_pred->need_type = false;
574 our_pred->est_success_rate = 1.0f;
575 return true;
576@@ -2369,7 +2378,7 @@ parse_accesscheck (const struct parser_table* entry, char **argv, int *arg_ptr)
577 struct predicate *our_pred;
578 (void) argv;
579 (void) arg_ptr;
580- our_pred = insert_primary (entry);
581+ our_pred = insert_primary_noarg (entry);
582 our_pred->need_stat = our_pred->need_type = false;
583 our_pred->side_effects = our_pred->no_default_print = false;
584 if (pred_is(our_pred, pred_executable))
585@@ -2414,7 +2423,7 @@ parse_used (const struct parser_table* entry, char **argv, int *arg_ptr)
586 struct timespec zero = {0,0};
587 if (get_relative_timestamp(offset_str, &tval, zero, DAYSECS, errmsg))
588 {
589- our_pred = insert_primary (entry);
590+ our_pred = insert_primary (entry, offset_str);
591 our_pred->args.reftime = tval;
592 our_pred->est_success_rate = estimate_file_age_success_rate(tval.ts.tv_sec / DAYSECS);
593 return true;
594@@ -2472,7 +2481,7 @@ parse_user (const struct parser_table* entry, char **argv, int *arg_ptr)
595 return false;
596 }
597 }
598- our_pred = insert_primary (entry);
599+ our_pred = insert_primary (entry, username);
600 our_pred->args.uid = uid;
601 our_pred->est_success_rate = (our_pred->args.uid < 100) ? 0.99 : 0.2;
602 return true;
603@@ -2650,7 +2659,7 @@ insert_type (char **argv, int *arg_ptr,
604 error(1, 0, _("Unknown argument to -type: %c"), (*typeletter));
605 return false;
606 }
607- our_pred = insert_primary_withpred (entry, which_pred);
608+ our_pred = insert_primary_withpred (entry, which_pred, typeletter);
609 our_pred->est_success_rate = rate;
610
611 /* Figure out if we will need to stat the file, because if we don't
612@@ -2706,7 +2715,7 @@ insert_fprintf (struct format_val *vec,
613 struct segment **segmentp; /* Address of current segment. */
614 struct predicate *our_pred;
615
616- our_pred = insert_primary_withpred (entry, func);
617+ our_pred = insert_primary_withpred (entry, func, format_const);
618 our_pred->side_effects = our_pred->no_default_print = true;
619 our_pred->args.printf_vec = *vec;
620 our_pred->need_type = false;
621@@ -3045,7 +3054,7 @@ new_insert_exec_ok (const char *action,
622 if ((argv == NULL) || (argv[*arg_ptr] == NULL))
623 return false;
624
625- our_pred = insert_primary_withpred (entry, func);
626+ our_pred = insert_primary_withpred (entry, func, "(some -exec* arguments)");
627 our_pred->side_effects = our_pred->no_default_print = true;
628 our_pred->need_type = our_pred->need_stat = false;
629
630@@ -3374,7 +3383,7 @@ parse_time (const struct parser_table* entry, char *argv[], int *arg_ptr)
631 if (!get_relative_timestamp(timearg, &tval, origin, DAYSECS, errmsg))
632 return false;
633
634- our_pred = insert_primary (entry);
635+ our_pred = insert_primary (entry, orig_timearg);
636 our_pred->args.reftime = tval;
637 our_pred->est_success_rate = estimate_timestamp_success_rate(tval.ts.tv_sec);
638
639@@ -3487,7 +3496,7 @@ insert_num (char **argv, int *arg_ptr, const struct parser_table *entry)
640
641 if (get_num (numstr, &num, &c_type))
642 {
643- struct predicate *our_pred = insert_primary (entry);
644+ struct predicate *our_pred = insert_primary (entry, numstr);
645 our_pred->args.numinfo.kind = c_type;
646 our_pred->args.numinfo.l_val = num;
647
648diff --git a/find/tree.c b/find/tree.c
649index 7420c60..60a0601 100644
650--- a/find/tree.c
651+++ b/find/tree.c
652@@ -269,10 +269,14 @@ predicate_is_cost_free(const struct predicate *p)
653 /* Prints a predicate */
654 void print_predicate(FILE *fp, const struct predicate *p)
655 {
656- fprintf (fp, "%s%s%s",
657- p->p_name,
658- p->arg_text ? " " : "",
659- p->arg_text ? p->arg_text : "");
660+ if (p->arg_text)
661+ {
662+ fprintf (fp, "%s %s", p->p_name, p->arg_text);
663+ }
664+ else
665+ {
666+ fprintf (fp, "%s", p->p_name);
667+ }
668 }
669
670
671@@ -832,7 +836,8 @@ set_new_parent (struct predicate *curr, enum predicate_precedence high_prec, str
672 new_parent->need_stat = false;
673 new_parent->need_type = false;
674 new_parent->p_cost = NeedsNothing;
675-
676+ new_parent->arg_text = NULL;
677+
678 switch (high_prec)
679 {
680 case COMMA_PREC:
681@@ -1393,6 +1398,18 @@ init_pred_perf(struct predicate *pred)
682 p->visits = p->successes = 0;
683 }
684
685+
686+struct predicate *
687+get_new_pred_noarg (const struct parser_table *entry)
688+{
689+ struct predicate *p = get_new_pred(entry);
690+ if (p)
691+ {
692+ p->arg_text = NULL;
693+ }
694+ return p;
695+}
696+
697
698 /* Return a pointer to a new predicate structure, which has been
699 linked in as the last one in the predicates list.
700@@ -1433,6 +1450,8 @@ get_new_pred (const struct parser_table *entry)
701 last_pred->no_default_print = false;
702 last_pred->need_stat = true;
703 last_pred->need_type = true;
704+ last_pred->p_cost = NeedsUnknown;
705+ last_pred->arg_text = "ThisShouldBeSetToSomethingElse";
706 last_pred->args.str = NULL;
707 last_pred->pred_next = NULL;
708 last_pred->pred_left = NULL;
709@@ -1449,7 +1468,8 @@ get_new_pred (const struct parser_table *entry)
710 predicate is an operator. If it isn't, the AND operator is inserted. */
711
712 struct predicate *
713-get_new_pred_chk_op (const struct parser_table *entry)
714+get_new_pred_chk_op (const struct parser_table *entry,
715+ const char *arg)
716 {
717 struct predicate *new_pred;
718 static const struct parser_table *entry_and = NULL;
719@@ -1471,13 +1491,14 @@ get_new_pred_chk_op (const struct parser_table *entry)
720 case PRIMARY_TYPE:
721 case CLOSE_PAREN:
722 /* We need to interpose the and operator. */
723- new_pred = get_new_pred (entry_and);
724+ new_pred = get_new_pred_noarg (entry_and);
725 new_pred->pred_func = pred_and;
726 new_pred->p_name = "-a";
727 new_pred->p_type = BI_OP;
728 new_pred->p_prec = AND_PREC;
729 new_pred->need_stat = false;
730 new_pred->need_type = false;
731+ new_pred->arg_text = NULL;
732 new_pred->args.str = NULL;
733 new_pred->side_effects = false;
734 new_pred->no_default_print = false;
735@@ -1488,6 +1509,7 @@ get_new_pred_chk_op (const struct parser_table *entry)
736 }
737
738 new_pred = get_new_pred (entry);
739+ new_pred->arg_text = arg;
740 new_pred->parser_entry = entry;
741 return new_pred;
742 }
743diff --git a/find/util.c b/find/util.c
744index a06eada..cc9a3eb 100644
745--- a/find/util.c
746+++ b/find/util.c
747@@ -89,11 +89,13 @@ static struct debug_option_assoc debugassoc[] =
748 operator. */
749
750 struct predicate *
751-insert_primary_withpred (const struct parser_table *entry, PRED_FUNC pred_func)
752+insert_primary_withpred (const struct parser_table *entry,
753+ PRED_FUNC pred_func,
754+ const char *arg)
755 {
756 struct predicate *new_pred;
757
758- new_pred = get_new_pred_chk_op (entry);
759+ new_pred = get_new_pred_chk_op (entry, arg);
760 new_pred->pred_func = pred_func;
761 new_pred->p_name = entry->parser_name;
762 new_pred->args.str = NULL;
763@@ -118,10 +120,16 @@ insert_primary_withpred (const struct parser_table *entry, PRED_FUNC pred_func)
764 either not there at all (we are the very first node) or is an
765 operator. */
766 struct predicate *
767-insert_primary (const struct parser_table *entry)
768+insert_primary (const struct parser_table *entry, const char *arg)
769 {
770 assert (entry->pred_func != NULL);
771- return insert_primary_withpred(entry, entry->pred_func);
772+ return insert_primary_withpred(entry, entry->pred_func, arg);
773+}
774+
775+struct predicate *
776+insert_primary_noarg (const struct parser_table *entry)
777+{
778+ return insert_primary(entry, NULL);
779 }
780
781