Changeset 71 for trunk/src/helpers/configsys.c
- Timestamp:
- May 22, 2001, 7:18:41 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/configsys.c
r63 r71 159 159 * for analyzing CONFIG.SYS settings. 160 160 * 161 * Remarks: 162 * 163 * -- With pcszKey, you can either specify a CONFIG.SYS 164 * key WITH an equals sign (e.g. search for "LIBPATH=") 165 * or the key name only (e.g. "SET SHELL"). 166 * 167 * Only in the latter case, this function makes sure 168 * that the search key is complete; e.g. it will not 169 * find "SET SHELLHANDLESINC=" then. 170 * 171 * -- If the line found starts with leading spaces, 172 * *ppStartOfLine will still receive the start of 173 * the line. 174 * For example, if you're searching for "SET PATH" 175 * and the PATH line is 176 * 177 + " SET PATH=C:\os2" 178 * 179 * the first space in the line is written into 180 * *ppStartOfLine. 181 * 161 182 *@@changed V0.9.0 [umoeller]: fixed bug in that this would also return something if only the first chars matched 162 183 *@@changed V0.9.0 [umoeller]: fixed bug which could cause character before pszSearchIn to be examined … … 164 185 *@@changed V0.9.7 (2001-01-15) [umoeller]: now checking for tabs too 165 186 *@@changed V0.9.11 (2001-04-25) [umoeller]: this never found lines which had leading spaces, fixed 187 *@@changed V0.9.12 (2001-05-22) [umoeller]: added checks for key termination (SET SHELLHANDLESINC) 166 188 */ 167 189 … … 177 199 ULONG ulKeyLength = strlen(pcszKey); 178 200 201 BOOL fSearchKeyContainsEquals = (strchr(pcszKey, '=') != 0); 202 179 203 do 180 204 { 181 p = strhistr(p, pcszKey);182 183 if ( (p)184 && (p >= pcszSearchIn)185 205 // find the key 206 // (on first loop, p is start of buffer; 207 // on subsequent loops, p is somewhere in bufer, 208 // if we've found the key somewhere else) 209 if (p = strhistr(p, pcszKey)) 186 210 { 187 211 // make sure the key is at the beginning of a line … … 207 231 // OK, we're at the start of a line: 208 232 209 // return address of key 210 pReturn = (PSZ)p; 211 // return start of line 212 if (ppStartOfLine) 213 *ppStartOfLine = (PSZ)pStartOfLine; 214 215 // test for all upper case? 216 if (pfIsAllUpperCase) 233 // check the character AFTER the 234 // key if it's a space or '='; 235 // without this check, we'd find 236 // SET SHELL= if caller is really 237 // looking for SET SHELLHANDLESINC=, 238 // but only do this check if the caller 239 // doesn't have '=' in the search string 240 // already 241 // V0.9.12 (2001-05-22) [umoeller] 242 CHAR c = *(p + ulKeyLength); 243 if ( (fSearchKeyContainsEquals) 244 || (c == ' ') 245 || (c == '=') 246 || (c == '\n') 247 || (c == '\r') 248 || (c == '\t') 249 ) 217 250 { 218 ULONG ul = 0; 219 *pfIsAllUpperCase = TRUE; 220 221 for (ul = 0; 222 ul < ulKeyLength; 223 ul++) 251 // return address of key 252 pReturn = (PSZ)p; 253 // return start of line 254 if (ppStartOfLine) 255 *ppStartOfLine = (PSZ)pStartOfLine; 256 257 // test for all upper case? 258 if (pfIsAllUpperCase) 224 259 { 225 if (islower(*(p + ul))) 260 ULONG ul = 0; 261 *pfIsAllUpperCase = TRUE; 262 263 for (ul = 0; 264 ul < ulKeyLength; 265 ul++) 226 266 { 227 *pfIsAllUpperCase = FALSE; 228 break; // for 267 if (islower(*(p + ul))) 268 { 269 *pfIsAllUpperCase = FALSE; 270 break; // for 271 } 229 272 } 230 273 } 231 } 232 233 break; // do274 275 break; // do 276 } // else search next key 234 277 } // else search next key 235 278 236 p++; // search on after this key 279 p += ulKeyLength; // search on after this key 280 // now skipping ulKeyLength V0.9.12 (2001-05-22) [umoeller] 237 281 } 238 282 else … … 475 519 * 476 520 * If the manipulation succeeded, NO_ERROR is returned 477 * and *ppszChanged receives a new string describing521 * and pstrChanged receives a new string describing 478 522 * what was changed. This can be: 479 523 * … … 502 546 * 503 547 * -- This assumes that the line breaks are represented 504 * by \r\n items ONLY. 548 * by \n ONLY. If *ppszContents has \r\n line breaks, 549 * they must be converted to pure \n first. 505 550 */ 506 551 … … 611 656 &pStartOfLineWithKeyFound, 612 657 &fIsAllUpperCase); 658 // returns beginning of line 613 659 614 660 if (!pKeyFound)
Note:
See TracChangeset
for help on using the changeset viewer.