Changeset 956 for trunk/mkspecs
- Timestamp:
- Aug 10, 2011, 7:00:44 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mkspecs/os2-g++/runmapsym.cmd
r954 r956 8 8 '@echo off' 9 9 10 parse arg aMapSymEXE aMapFile aSymFile 10 if (RxFuncQuery('SysLoadFuncs')) then do 11 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 12 call SysLoadFuncs 13 end 11 14 12 if (aMapSymEXE == '' | aMapFile == '' | aSymFile == '') then do 15 parse arg aArgs 16 call TokenizeString aArgs, 'G.!args' 17 18 if (G.!args.0 < 3) then do 13 19 say "Usage: runmapsym <mapsym_cmd> <map_file> <sym_file>" 14 20 exit 255 15 21 end 22 23 aMapSymEXE = G.!args.1 24 aMapFile = G.!args.2 25 aSymFile = G.!args.3 26 27 curDir = directory() 28 29 mapSymExeDir = filespec('D', aMapSymEXE)||filespec('P', aMapSymEXE) 30 if (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) 41 end 42 43 call directory curDir 16 44 17 45 mapFile = stream(aMapFile, 'C', 'QUERY EXISTS') … … 20 48 exit 255 21 49 end 22 23 curDir = directory()24 50 25 51 symDir = filespec('D', aSymFile)||filespec('P', aSymFile) … … 34 60 symFile = fileSpec('N', aSymFile) 35 61 36 'call' aMapSymExe mapFile62 'call' mapSymExe mapFile 37 63 38 64 if (rc \== 0) then do … … 57 83 58 84 exit 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 */ 104 TokenizeString: 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.