Changeset 956 for trunk/mkspecs


Ignore:
Timestamp:
Aug 10, 2011, 7:00:44 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

qmake: gnumake/os2: Fix using relative cmd paths in mapsym wrapper.

It is necessary since the path to the mapsym command may be relative
(as in case of wmapsym). Note that for this to work we had to add argument
quoting support since REXX doesn't have it per se.

File:
1 edited

Legend:

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

    r954 r956  
    88'@echo off'
    99
    10 parse arg aMapSymEXE aMapFile aSymFile
     10if (RxFuncQuery('SysLoadFuncs')) then do
     11    call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
     12    call SysLoadFuncs
     13end
    1114
    12 if (aMapSymEXE == '' | aMapFile == '' | aSymFile == '') then do
     15parse arg aArgs
     16call TokenizeString aArgs, 'G.!args'
     17
     18if (G.!args.0 < 3) then do
    1319    say "Usage: runmapsym <mapsym_cmd> <map_file> <sym_file>"
    1420    exit 255
    1521end
     22
     23aMapSymEXE = G.!args.1
     24aMapFile = G.!args.2
     25aSymFile = G.!args.3
     26
     27curDir = directory()
     28
     29mapSymExeDir = filespec('D', aMapSymEXE)||filespec('P', aMapSymEXE)
     30if (mapSymExeDir \== '') then do
     31    if (right(mapSymExeDir, 2) \== ':\') then
     32        mapSymExeDir = strip(mapSymExeDir, 'T', '\')
     33    mapSymExeDir = directory(mapSymExeDir)
     34    if (mapSymExeDir == '') then do
     35        say 'ERROR: Directory of "'aMapSymEXE'" does not exist.'
     36        exit 255
     37    end
     38    if (right(mapSymExeDir, 2) \== ':\') then
     39        mapSymExeDir = mapSymExeDir'\'
     40    mapSymExe = mapSymExeDir||filespec('N', aMapSymEXE)
     41end
     42
     43call directory curDir
    1644
    1745mapFile = stream(aMapFile, 'C', 'QUERY EXISTS')
     
    2048    exit 255
    2149end
    22 
    23 curDir = directory()
    2450
    2551symDir = filespec('D', aSymFile)||filespec('P', aSymFile)
     
    3460symFile = fileSpec('N', aSymFile)
    3561
    36 'call' aMapSymExe mapFile
     62'call' mapSymExe mapFile
    3763
    3864if (rc \== 0) then do
     
    5783
    5884exit rc
     85
     86/**
     87 *  Returns a list of all words from the string as a stem.
     88 *  Delimiters are spaces, tabs and new line characters.
     89 *  Words containg spaces must be enclosed with double
     90 *  quotes. Double quote symbols that need to be a part
     91 *  of the word, must be doubled.
     92 *
     93 *  @param string   the string to tokenize
     94 *  @param stem
     95 *      the name of the stem. The stem must be global
     96 *      (i.e. its name must start with 'G.!'), for example,
     97 *      'G.!wordlist'.
     98 *  @param leave_ws
     99 *      1 means whitespace chars are considered as a part of words they follow.
     100 *      Leading whitespace (if any) is always a part of the first word (if any).
     101 *
     102 *  @version 1.1
     103 */
     104TokenizeString: procedure expose G.
     105
     106    parse arg string, stem, leave_ws
     107    leave_ws = (leave_ws == 1)
     108
     109    delims  = '20090D0A'x
     110    quote   = '22'x /* " */
     111
     112    num = 0
     113    token = ''
     114
     115    len = length(string)
     116    last_state = '' /* D - in delim, Q - in quotes, W - in word */
     117    seen_QW = 0
     118
     119    do i = 1 to len
     120        c = substr(string, i, 1)
     121        /* determine a new state */
     122        if (c == quote) then do
     123            if (last_state == 'Q') then do
     124                /* detect two double quotes in a row */
     125                if (substr(string, i + 1, 1) == quote) then i = i + 1
     126                else state = 'W'
     127            end
     128            else state = 'Q'
     129        end
     130        else if (verify(c, delims) == 0 & last_state \== 'Q') then do
     131            state = 'D'
     132        end
     133        else do
     134            if (last_state == 'Q') then state = 'Q'
     135            else state = 'W'
     136        end
     137        /* process state transitions */
     138        if ((last_state == 'Q' | state == 'Q') & state \== last_state) then c = ''
     139        else if (state == 'D' & \leave_ws) then c = ''
     140        if (last_state == 'D' & state \== 'D' & seen_QW) then do
     141            /* flush the token */
     142            num = num + 1
     143            call value stem'.'num, token
     144            token = ''
     145        end
     146        token = token||c
     147        last_state = state
     148        seen_QW = (seen_QW | state \== 'D')
     149    end
     150
     151    /* flush the last token if any */
     152    if (token \== '' | seen_QW) then do
     153        num = num + 1
     154        call value stem'.'num, token
     155    end
     156
     157    call value stem'.0', num
     158
     159    return
Note: See TracChangeset for help on using the changeset viewer.