Changeset 1002 for trunk/mkspecs


Ignore:
Timestamp:
Aug 17, 2011, 8:44:53 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

qmake: gnumake/os2: Make mkdir-p.cmd understand quotes in arguments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mkspecs/os2-g++/mkdir-p.cmd

    r731 r1002  
    88'@echo off'
    99
     10Globals = 'G.'
     11
    1012parse arg aArgs
    1113
     
    1416
    1517aArgs = strip(aArgs)
    16 if (aArgs == '') then do
     18call TokenizeString aArgs, 'G.Args'
     19if (G.Args.0 \= 1) then do
    1720    say "Usage: mkdir-p <directory>"
    1821    exit 255
    1922end
    2023
    21 exit MakeDir(strip(aArgs))
     24exit MakeDir(strip(G.Args.1))
    2225
    2326MakeDir: procedure expose (Globals)
     
    5962    return 0
    6063
     64/**
     65 *  Returns a list of all words from the string as a stem.
     66 *  Delimiters are spaces, tabs and new line characters.
     67 *  Words containg spaces must be enclosed with double
     68 *  quotes. Double quote symbols that need to be a part
     69 *  of the word, must be doubled.
     70 *
     71 *  @param string   the string to tokenize
     72 *  @param stem
     73 *      the name of the stem. The stem must be global
     74 *      (i.e. its name must start with 'G.!'), for example,
     75 *      'G.!wordlist'.
     76 *  @param leave_ws
     77 *      1 means whitespace chars are considered as a part of words they follow.
     78 *      Leading whitespace (if any) is always a part of the first word (if any).
     79 *
     80 *  @version 1.1
     81 */
     82TokenizeString: procedure expose (Globals)
     83
     84    parse arg string, stem, leave_ws
     85    leave_ws = (leave_ws == 1)
     86
     87    delims  = '20090D0A'x
     88    quote   = '22'x /* " */
     89
     90    num = 0
     91    token = ''
     92
     93    len = length(string)
     94    last_state = '' /* D - in delim, Q - in quotes, W - in word */
     95    seen_QW = 0
     96
     97    do i = 1 to len
     98        c = substr(string, i, 1)
     99        /* determine a new state */
     100        if (c == quote) then do
     101            if (last_state == 'Q') then do
     102                /* detect two double quotes in a row */
     103                if (substr(string, i + 1, 1) == quote) then i = i + 1
     104                else state = 'W'
     105            end
     106            else state = 'Q'
     107        end
     108        else if (verify(c, delims) == 0 & last_state \== 'Q') then do
     109            state = 'D'
     110        end
     111        else do
     112            if (last_state == 'Q') then state = 'Q'
     113            else state = 'W'
     114        end
     115        /* process state transitions */
     116        if ((last_state == 'Q' | state == 'Q') & state \== last_state) then c = ''
     117        else if (state == 'D' & \leave_ws) then c = ''
     118        if (last_state == 'D' & state \== 'D' & seen_QW) then do
     119            /* flush the token */
     120            num = num + 1
     121            call value stem'.'num, token
     122            token = ''
     123        end
     124        token = token||c
     125        last_state = state
     126        seen_QW = (seen_QW | state \== 'D')
     127    end
     128
     129    /* flush the last token if any */
     130    if (token \== '' | seen_QW) then do
     131        num = num + 1
     132        call value stem'.'num, token
     133    end
     134
     135    call value stem'.0', num
     136
     137    return
Note: See TracChangeset for help on using the changeset viewer.