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

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

Discussion in 'Support' started by samintz, Apr 23, 2013.

  1. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,968
    Likes Received:
    30
    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.
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,868
    Likes Received:
    83
    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.
     

Share This Page