Home » U++ Library support » U++ Core » PatternMatchMulti problem
PatternMatchMulti problem [message #26993] |
Fri, 18 June 2010 13:33 |
|
koldo
Messages: 3357 Registered: August 2008
|
Senior Veteran |
|
|
Hello all
Now PatternMatchMulti implementation is this:
bool PatternMatchMulti(const char *p, const char *s) {
String pt;
while(*p) {
if(*p == ';' || *p == ',' || *p == ' ') {
if(PatternMatch(pt, s)) return true;
p++;
while(*p == ';' || *p == ',' || *p == ' ') p++;
pt.Clear();
}
else
pt.Cat(*p++);
}
return pt.IsEmpty() ? false : PatternMatch(pt, s);
}
It separates patterns with ';', ',' and ' '. I thing to have patterns with spaces it would be better to remove the ' ' form the function.
Best regards
Iñaki
|
|
|
Re: PatternMatchMulti problem [message #26994 is a reply to message #26993] |
Sat, 19 June 2010 11:47 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
koldo wrote on Fri, 18 June 2010 07:33 | Hello all
Now PatternMatchMulti implementation is this:
bool PatternMatchMulti(const char *p, const char *s) {
String pt;
while(*p) {
if(*p == ';' || *p == ',' || *p == ' ') {
if(PatternMatch(pt, s)) return true;
p++;
while(*p == ';' || *p == ',' || *p == ' ') p++;
pt.Clear();
}
else
pt.Cat(*p++);
}
return pt.IsEmpty() ? false : PatternMatch(pt, s);
}
It separates patterns with ';', ',' and ' '. I thing to have patterns with spaces it would be better to remove the ' ' form the function.
|
It is designed to be used with file patterns - spaces are unlikely. Especially in FileSel, using ' ' as separator is common. Changing behaviour would be break a lot of existing code.
Also, space as separator works in commandline. So perhaps, if you insist on changing behaviour, we should rather introduce "pattern with spaces" (using ").
Mirek
Mirek
|
|
|
Re: PatternMatchMulti problem [message #26996 is a reply to message #26994] |
Sat, 19 June 2010 14:53 |
|
koldo
Messages: 3357 Registered: August 2008
|
Senior Veteran |
|
|
luzr wrote on Sat, 19 June 2010 11:47 |
koldo wrote on Fri, 18 June 2010 07:33 | Hello all
Now PatternMatchMulti implementation is this:
bool PatternMatchMulti(const char *p, const char *s) {
String pt;
while(*p) {
if(*p == ';' || *p == ',' || *p == ' ') {
if(PatternMatch(pt, s)) return true;
p++;
while(*p == ';' || *p == ',' || *p == ' ') p++;
pt.Clear();
}
else
pt.Cat(*p++);
}
return pt.IsEmpty() ? false : PatternMatch(pt, s);
}
It separates patterns with ';', ',' and ' '. I thing to have patterns with spaces it would be better to remove the ' ' form the function.
|
It is designed to be used with file patterns - spaces are unlikely. Especially in FileSel, using ' ' as separator is common. Changing behaviour would be break a lot of existing code.
Also, space as separator works in commandline. So perhaps, if you insist on changing behaviour, we should rather introduce "pattern with spaces" (using ").
Mirek
Mirek
|
Hello Mirek
I did not want to break anything, but it is common to have spaces in folder and file names so I think a function like PatternMatchMulti would have to consider this.
Best regards
Iñaki
[Updated on: Sat, 19 June 2010 14:53] Report message to a moderator
|
|
|
Re: PatternMatchMulti problem [message #26999 is a reply to message #26994] |
Sun, 20 June 2010 17:12 |
|
luzr wrote on Sat, 19 June 2010 11:47 | Also, space as separator works in commandline. So perhaps, if you insist on changing behaviour, we should rather introduce "pattern with spaces" (using ").
|
Hi,
Just a note: If you decide to support "pattern with spaces", could you also consider escaped\ spaces? Not that I need it, but it would make the behavior more consistent with common shells...
Best regards,
Honza
|
|
|
Re: PatternMatchMulti problem [message #27001 is a reply to message #26999] |
Sun, 20 June 2010 17:49 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
dolik.rce wrote on Sun, 20 June 2010 11:12 |
luzr wrote on Sat, 19 June 2010 11:47 | Also, space as separator works in commandline. So perhaps, if you insist on changing behaviour, we should rather introduce "pattern with spaces" (using ").
|
Hi,
Just a note: If you decide to support "pattern with spaces", could you also consider escaped\ spaces? Not that I need it, but it would make the behavior more consistent with common shells...
Best regards,
Honza
|
Well, actually, I am not for changing anything, I have just proposed the path if the change is required..
|
|
|
Re: PatternMatchMulti problem [message #27003 is a reply to message #27001] |
Sun, 20 June 2010 20:53 |
|
koldo
Messages: 3357 Registered: August 2008
|
Senior Veteran |
|
|
luzr wrote on Sun, 20 June 2010 17:49 |
dolik.rce wrote on Sun, 20 June 2010 11:12 |
luzr wrote on Sat, 19 June 2010 11:47 | Also, space as separator works in commandline. So perhaps, if you insist on changing behaviour, we should rather introduce "pattern with spaces" (using ").
|
Hi,
Just a note: If you decide to support "pattern with spaces", could you also consider escaped\ spaces? Not that I need it, but it would make the behavior more consistent with common shells...
Best regards,
Honza
|
Well, actually, I am not for changing anything, I have just proposed the path if the change is required..
|
Ok
If PatternMatchMulti is used to check extensions for Filsel for example, you could do new function similar to PatternMatchMulti for comparing not
- Files <-> extensions
but
- Files <-> sets of patterns
Best regards
Iñaki
|
|
|
Goto Forum:
Current Time: Sat Apr 27 21:49:31 CEST 2024
Total time taken to generate the page: 0.05151 seconds
|