Changeset 144
- Timestamp:
- Feb 26, 2002, 9:28:01 PM (23 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/stringh.c
r143 r144 873 873 * 874 874 *@@added V0.9.6 (2000-11-12) [umoeller] 875 *@@changed V0.9.18 (2002-02-23) [umoeller]: fixed end char check 875 876 */ 876 877 877 878 BOOL strhIsWord(PCSZ pcszBuf, 878 879 PCSZ p, // in: start of word 879 ULONG cbSearch, 880 ULONG cbSearch, // in: length of word 880 881 PCSZ pcszBeginChars, // suggestion: "\x0d\x0a ()/\\-,." 881 882 PCSZ pcszEndChars) // suggestion: "\x0d\x0a ()/\\-,.:;" 882 883 { 883 BOOL fEndOK = FALSE;884 885 884 // check previous char 886 885 if ( (p == pcszBuf) … … 890 889 // OK, valid begin char: 891 890 // check end char 892 CHAR cNextChar = *(p + cbSearch); 893 if (cNextChar == 0) 894 fEndOK = TRUE; 891 CHAR cNextChar; 892 if (!(cNextChar = p[cbSearch])) 893 // null terminator: 894 return TRUE; 895 895 else 896 896 { 897 char *pc = strchr(pcszEndChars, cNextChar); 898 if (pc) 897 // not null terminator: check if char is 898 // in the list of valid end chars 899 if (strchr(pcszEndChars, cNextChar)) 900 { 899 901 // OK, is end char: avoid doubles of that char, 900 902 // but allow spaces 901 if ( (cNextChar+1 != *pc) 902 || (cNextChar+1 == ' ') 903 || (cNextChar+1 == 0) 903 // fixed V0.9.18 (2002-02-23) [umoeller] 904 CHAR cNextNext = p[cbSearch + 1]; 905 if ( (cNextNext != cNextChar) 906 || (cNextNext == ' ') 907 || (cNextNext == 0) 904 908 ) 905 fEndOK = TRUE; 906 } 907 } 908 909 return (fEndOK); 909 return TRUE; 910 } 911 } 912 } 913 914 return FALSE; 910 915 } 911 916 -
trunk/src/helpers/xstring.c
r141 r144 15 15 * a char* pointer pointing to heap memory, which is managed 16 16 * automatically. 17 * 18 * Besides being convenient, these functions are highly 19 * optimized to use as few strlen's and memcpy's as 20 * possible. 17 21 * 18 22 * Using these functions has the following advantages: … … 85 89 86 90 /* 87 * Copyright (C) 1999-200 1Ulrich Mller.91 * Copyright (C) 1999-2002 Ulrich Mller. 88 92 * This file is part of the "XWorkplace helpers" source package. 89 93 * This is free software; you can redistribute it and/or modify … … 210 214 * 211 215 + XSTRING str; 212 + xstrInitSet(&str, strdup("blah") );216 + xstrInitSet(&str, strdup("blah"), 0); 213 217 * 214 218 *@@added V0.9.16 (2002-01-13) [umoeller] 215 219 */ 216 220 217 void xstrInitSet2(PXSTRING pxstr, 218 PSZ pszNew, 219 ULONG ulNewLength) 221 void xstrInitSet2(PXSTRING pxstr, // in/out: string 222 PSZ pszNew, // in: malloc'd string to load pxstr with 223 ULONG ulNewLength) // in: length of pszNew or 0 to run strlen() 220 224 { 221 225 if (!pszNew) … … 326 330 if (pcszSource) 327 331 { 328 pxstr->ulLength = strlen(pcszSource); 329 330 if (pxstr->ulLength) 332 if (pxstr->ulLength = strlen(pcszSource)) 331 333 { 332 334 // we do have a source string: … … 542 544 543 545 xstrClear(pxstr); 544 pxstr->psz = pszNew; 545 if (pszNew) 546 if (pxstr->psz = pszNew) 546 547 { 547 548 if (!ulNewLength) … … 576 577 * as necessary. 577 578 * 578 * If pxstr contains something, its contents are destroyed.579 * If pxstr contains something, its contents are overwritten. 579 580 * 580 581 * With ulSourceLength, specify the length of pcszSource … … 1010 1011 // now overwrite "found" in the middle 1011 1012 if (cReplaceWithLen) 1012 {1013 1013 memcpy(pFound, 1014 1014 pcszReplaceWith, 1015 1015 cReplaceWithLen); // no null terminator 1016 }1017 1016 1018 1017 // that's it; adjust the string length now
Note:
See TracChangeset
for help on using the changeset viewer.