Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Fixed @REREPLACE bug

Jul
32
0
(Using version TCC 14.00.29 x64 on Windows 7)

For some reason, the following rereplace pattern outputs corrupt data and potentially crashes TCC:
do a in *
echo "%@rereplace["(?i)( )(..|r5)",\1,%a]"​
enddo

Further investigation shows that the back reference is probably the culprit of a memory overrun. Try:
echo %@rereplace["(.)","\1",r2gggr1]​
 
I don't understand what you're trying to do here -- why are you using a single back reference, and what do you expect to see as a result?
I figure
echo "%@rereplace["(?i)( )(..|r5)",\1,%a]"​
is supposed to replace a space followed by any two characters ( "|r5" is redundant) with the space alone. It's an odd thing to do and there are easier ways to do it (%@rereplace[" .."," ",%a]). And "|r5" being redundant makes (?i) needless.

This one was given as a test.
echo %@rereplace["(.)","\1",r2gggr1]
All it does is replace every character with itself(!!). But it does show that something's wrong with @REREPLACE.
 
:)

The original intent was to perform a sub-string rename of specific files:
do a in ::" - (low|high|top|ultra)[.]"​
iff %o == low then​
set r=1​
elseiff %o == high then​
set r=2​
elseiff %o EQC top then​
set r=3​
elseiff %o EQC TOP then​
set r=4​
elseiff %o EQC ULTRA then​
set r=5​
endiff​
ren /Nst "%a" "%@rereplace["(?i)(.* - )(low|high|top|ultra)([.].*)$",\1r%r\3,%a]"​
enddo​
The result was that the loop ran for about 1-20 cycles and then crashed TCC. I then replaced the ren line to the following:
ren /Nst "%a" "%@regexsub[1,"(?i)(.* - )(low|high|top|ultra)([.].*)$",%a]r%[r]%@regexsub[3,"(?i)(.* - )(low|high|top|ultra)([.].*)$",%a]"​

Which worked. Now, in order to report on the problem, I tried to reproduce it with the simplest conditions I could, and my top post is the result. So, no - there's not much sense in using the original patterns per se. Just for bug reproduction... :)

Cheers,
Gilad
 
Just updated to v14.00.30 x64.
I still get a crash and burn when I run the following command:

Code:
move ::"(.*)win\.*" ::"\1"

REN works fine though.
 
I have no idea what you're trying to do here.

I interpret move ::"(.*)win\.*" ::"\1" as...

move all files named...
Code:
(.*)   {grouping}zero_or_more_characters{/grouping}
win    followed by the characters "win"
\.*    followed by zero_or_more_periods

... to ...
Code:
\1    previous_grouping_of_zero_or_more_characters (which may or may not actually consist of any characters)

Basically... I don't understand it either.
 
Ooops - now I see my typo - should have been
move ::"(.*)win\..*" ::"\1"

Basically, rename any file with "*win.*" to the contents of the first asterisk. Originally I also move the target to ..\ directory, but for simplicity sake of bug reproduction I've omitted that part.
 
Rename any file with "*win.*" to the contents of the first asterisk.

In that case, the first regex part of your command should be
Code:
::"(.+)win\..*"
which is...
Code:
(.+)    {group}one_or_more_characters{/group} to make sure that there is a destination
win     the characters "win"
\.      dot
.*      zero_or_more_characters
 
:)
I'm fine with your correction John, though in my case I knew I only had files with text in front of the "win" so it doesn't really matter. Nonetheless, even with that correction, TCC crashes. Try the following in Windows\System32:

move /n ::"win(.+)\..*" ::"\1"

Mine crashes on sight.
 
Try the following in Windows\System32:

move /n ::"win(.+)\..*" ::"\1"

Mine crashes on sight.
I suspect that MOVE supports targets with simple asterisk wildcards only (not regex).
Code:
C:\temp>dir /b ::csb
csb
csbcmd.txt
csbtcc.txt
 
C:\temp>move /n ::(csb) ::x\1
TCC: Can't COPY or MOVE file to itself "C:\temp\csb"
0 files would be moved
 
C:\temp>move /n ::(csb) x\1
C:\temp\csb -> C:\temp\x\1
TCC: Can't create "C:\temp\x\1"
1 file would be moved
 
C:\temp>move /n ::(csb) x*  & rem note that x replaces c
C:\temp\csb -> C:\temp\xsb
C:\temp\csbcmd.txt -> C:\temp\xsbcmd.txt
C:\temp\csbtcc.txt -> C:\temp\xsbtcc.txt
3 files would be moved
 
From v14's help:
Code:
MOVE supports regular expression back references in the target name.  If you are using back references, you must also use a regular expression in the source name. The syntax is:
move ::filename ::target
It works OK in a very simple test.
Code:
v:\test> dir /k /m /h
2012-08-01  00:54              0  abc.bat
2012-08-01  00:54              0  def.bat
 
v:\test> ren ::(.*\.)bat ::\1btm
V:\test\abc.bat -> V:\test\abc.btm
V:\test\def.bat -> V:\test\def.btm
    2 files renamed
 
v:\test> dir /k /m /h
2012-08-01  00:54              0  abc.btm
2012-08-01  00:54              0  def.btm
 
v:\test> ren ::"(.*\.)btm" ::"\1bat"
V:\test\abc.btm -> V:\test\abc.bat
V:\test\def.btm -> V:\test\def.bat
    2 files renamed
 
Vince, you quoted the help entry for MOVE and used REN in your example. Move gives an error message here, TCC 14.00.30
Code:
C:\temp>move ::(.*\.bat) ::\1.btm
TCC: Can't COPY or MOVE file to itself "C:\temp\abc.bat"
0 files moved
 
C:\temp>ren ::(.*\.bat) ::\1.btm
C:\temp\abc.bat -> C:\temp\abc.bat.btm
C:\temp\def.bat -> C:\temp\def.bat.btm
2 files renamed
 
Vince, you quoted the help entry for MOVE and used REN in your example. Move gives an error message here, TCC 14.00.30
Code:
C:\temp>move ::(.*\.bat) ::\1.btm
TCC: Can't COPY or MOVE file to itself "C:\temp\abc.bat"
0 files moved
 
C:\temp>ren ::(.*\.bat) ::\1.btm
C:\temp\abc.bat -> C:\temp\abc.bat.btm
C:\temp\def.bat -> C:\temp\def.bat.btm
2 files renamed
Oops! The help for REN says the same thing. But it seems REN works while MOVE doesn't.

Your example is a little strange (what does "." refer to in the target?). But it still doesn't work.

This makes TCC disappear (no GPF file)!
Code:
v:\test> dir /k /m /h
2012-08-01  00:54              0  abc.btm
2012-08-01  00:54              0  def.btm
 
v:\test> move ::(.*)\.btm ::d:\\\1\.bat
 

Similar threads

Back
Top