mIRC Home    About    Download    Register    News    Help

Print Thread
$findfile doublespace wildfile #265324 01/04/19 06:12 PM
Joined: Jan 2004
Posts: 1,173
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,173
Both $findfile and $finddir can see consecutive spaces in the path parameter, but are ignoring consecutive spaces in the wildfile parameter, causing it to also return all filenames containing only 1 space. Assuming there's at least 1 name having 1 space and at least 1 name having consecutive spaces:

//var %a $+(*,$str($chr(32),2),*) | echo -a %a $len(%a) $findfile(c:\path\,%a,0,echo -a $parms)

//var %a $+(*,$str($chr(32),2),*) | echo -a %a $len(%a) $findfile(c:\path\,* $chr(32) $+ *,0,echo -a $parms)

I know the output can see the spaces because $regex can filter the individual lines but not the grand total.

//var %a $+(*,$str($chr(32),2),*) | echo -a %a $len(%a) $findfile(c:\path\,%a,0,if ($regex($parms,\s\s)) echo -a $parms)

Re: $findfile doublespace wildfile [Re: maroon] #265326 02/04/19 06:58 AM
Joined: Dec 2002
Posts: 4,519
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,519
Thanks for your bug report. This is a known issue. Spaces, such as multiple consecutive, leading, or trailing spaces, are rarely preserved in the script parser. The issue is not only limited to the script parser, it applies to many features, where extra spaces are removed from parameters.

While it is possible to preserve spaces using some combinations of identifiers, that is simply exploiting aspects of the scripting language that happen to work that way. If it works for you in one context, or one identifier, that does not mean that it will work in another one.

There is little that can done other than rewriting the script parser from the ground up to preserve spaces in commands and their parameters, including the addition of quote "" support to delimit strings, and so on, which would likely lead to the breaking of scripts in many ways.

Re: $findfile doublespace wildfile [Re: maroon] #265806 27/07/19 11:23 AM
Joined: Dec 2002
Posts: 4,519
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,519
I looked through the $findfile() code again and there is a point where extra spaces are removed from the wildcard parameter due to parsing the multiple wildcard ; separator, which itself allows spaces between each wildcard and the ; separator. This can be changed so that only spaces surrounding each wildcard are removed, which should preserve internal spaces. Unless anyone can see a backwards compatibility issue with this, this change will be in the next version.