Fixed DO /L with stringset starting with /n /e

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

samintz

Scott Mintz
May 20, 2008
1,228
11
Solon, OH, USA
#1
I have a foo.BTM script containing:
Code:
do i in /L %*
if not %@index[%i,/] == -1 echos ` `%i
enddo
If I invoke it as:
Code:
foo a1 /n /e a2 a3
It spits out /n /e correctly. However, if I invoke it as:

Code:
foo /n /e a1 a2 a3
TCC hangs. Ctrl+C/Ctrl+Break do nothing. I expected the above code to iterate over the stringset and display /n /e. I can work around it by quoting the stringset, but then I have to unquote everything before using the loop variable.

TCC 15.01.39 x64 Windows 7 [Version 6.1.7601]
 
#2
This sends TCC into a tizzy ... full CPU and you can't break out of it.
Code:
do a in /l /n /g /t (echo %a)
It seems that after encountering "/L", "/C", or "/P", DO should stop looking for more switches.
 

rconn

Administrator
Staff member
May 14, 2008
10,162
86
#3
This sends TCC into a tizzy ... full CPU and you can't break out of it.
Code:
do a in /l /n /g /t (echo %a)
It seems that after encountering "/L", "/C", or "/P", DO should stop looking for more switches.
It does. The problem is that the /N is found *before* the /L, and DO keeps looking for the missing arguments to /N. (Multi-character switches are processed before single-character switches.)

It's behaved this way for about 20 years. I'm not going to write a custom parser for DO, but I'll see if I can hack something horrible to post-process the pre-processing.