New option -iso_rr_pattern, influencing several options with multiple args

This commit is contained in:
2007-11-09 19:30:25 +00:00
parent 1ba31e618e
commit 6cc5a50ba4
7 changed files with 387 additions and 128 deletions

View File

@ -1874,6 +1874,7 @@ much_too_long:;
if(node==NULL)
continue;
size= iso_tree_node_get_size(node);
rpt[0]= 0;
if((flag&5)==1) { /* -ls_l */
if(LIBISO_ISDIR(node))
@ -1897,7 +1898,6 @@ much_too_long:;
(unsigned long) iso_tree_node_get_uid(node));
sprintf(rpt+strlen(rpt), "%-8lu ",
(unsigned long) iso_tree_node_get_gid(node));
size= iso_tree_node_get_size(node);
sprintf(rpt+strlen(rpt), "%8.f ",(double) size);
mtime= iso_tree_node_get_mtime(node);
tmpt= localtime_r(&mtime, &tms);
@ -2321,11 +2321,15 @@ out_of_memory:;
}
/* @param flag bit0= a match count !=1 is a SORRY event
bit1= with bit0 tolerate 0 matches if pattern is a constant
*/
int Xorriso_expand_pattern(struct XorrisO *xorriso,
int num_patterns, char **patterns,
int num_patterns, char **patterns, int extra_filec,
int *filec, char ***filev, off_t *mem, int flag)
{
int ret, count= 0, abs_adr= 0, i, l, was_count, was_filec;
int ret, count= 0, abs_adr= 0, i, l, was_count, was_filec, k;
int nonconst_mismatches= 0;
char mem_text[80], limit_text[80], sfe[5*SfileadrL];
struct iso_volume *volume;
struct iso_tree_node_dir *dir, *root_dir;
@ -2368,7 +2372,7 @@ cannot_compile:;
dir= root_dir;
abs_adr= 4;
} else {
/* This is done so late ito allow the following:
/* This is done so late to allow the following:
It is not an error if xorriso->wdi does not exist yet, but one may
not use it as base for relative address searches.
*/
@ -2396,8 +2400,19 @@ cannot_compile:;
1 | abs_adr);
if(ret<=0)
goto ex;
if(was_count==count && strcmp(patterns[i],"*")!=0) {
if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) {
count++;
/* Is this a constant pattern ? */
for(k= 0; k<xorriso->re_fill; k++) {
if(xorriso->re_constants[k]==NULL)
break;
if(xorriso->re_constants[k][0]==0)
break;
}
if(k<xorriso->re_fill)
nonconst_mismatches++; /* it is not */
l= strlen(patterns[i])+1;
(*mem)+= sizeof(char *)+l;
if(l % sizeof(char *))
@ -2405,13 +2420,30 @@ cannot_compile:;
}
}
if((flag&1) && (count!=1 || nonconst_mismatches)){
if(count-nonconst_mismatches>0)
sprintf(xorriso->info_text,
"Pattern match with more than one file object");
else
sprintf(xorriso->info_text, "No pattern match with any file object");
if(num_patterns==1)
sprintf(xorriso->info_text+strlen(xorriso->info_text), ": %s",
Text_shellsafe(patterns[0], sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}
count+= extra_filec;
mem+= extra_filec*sizeof(char *);
if(count<=0)
{ret= 0; goto ex;}
Sfile_scale((double) *mem, mem_text,5,1e4,0);
sprintf(xorriso->info_text,
"Temporary memory needed for pattern expansion : %s", mem_text);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
if(!(flag&1))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
if(*mem > xorriso->temp_mem_limit) {
Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1);
sprintf(xorriso->info_text,