Changeset 132 for trunk/src/helpers/xstring.c
- Timestamp:
- Jan 19, 2002, 11:50:39 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/xstring.c
r129 r132 129 129 void XWPENTRY xstrInitDebug(PXSTRING pxstr, 130 130 ULONG ulPreAllocate, 131 const char *file,131 PCSZ file, 132 132 unsigned long line, 133 const char *function)133 PCSZ function) 134 134 { 135 135 memset(pxstr, 0, sizeof(XSTRING)); … … 194 194 195 195 /* 196 *@@ xstrInitSet :196 *@@ xstrInitSet2: 197 197 * this can be used instead of xstrInit if you 198 198 * have a free()'able string you want to initialize … … 212 212 + xstrInitSet(&str, strdup("blah")); 213 213 * 214 *@@added V0.9. 6 (2000-11-01) [umoeller]215 * @@changed V0.9.9 (2001-03-09) [umoeller]: added ulDelta216 */ 217 218 void xstrInitSet(PXSTRING pxstr,219 PSZ pszNew)214 *@@added V0.9.16 (2002-01-13) [umoeller] 215 */ 216 217 void xstrInitSet2(PXSTRING pxstr, 218 PSZ pszNew, 219 ULONG ulNewLength) 220 220 { 221 221 if (!pszNew) … … 223 223 else 224 224 { 225 if (!ulNewLength) 226 ulNewLength = strlen(pszNew); 225 227 pxstr->psz = pszNew; 226 pxstr->ulLength = strlen(pszNew); 227 pxstr->cbAllocated = pxstr->ulLength + 1; 228 pxstr->ulDelta = pxstr->ulLength * 10 / 100; 229 } 228 pxstr->ulLength = ulNewLength; 229 pxstr->cbAllocated = ulNewLength + 1; 230 pxstr->ulDelta = ulNewLength * 10 / 100; 231 } 232 } 233 234 /* 235 *@@ xstrInitSet: 236 * shortcut to xstrInitSet2 to retain compatibility. 237 * 238 *@@added V0.9.6 (2000-11-01) [umoeller] 239 *@@changed V0.9.9 (2001-03-09) [umoeller]: added ulDelta 240 */ 241 242 void xstrInitSet(PXSTRING pxstr, 243 PSZ pszNew) 244 { 245 xstrInitSet2(pxstr, pszNew, 0); 230 246 } 231 247 … … 239 255 240 256 void XWPENTRY xstrInitCopyDebug(PXSTRING pxstr, 241 const char *pcszSource,257 PCSZ pcszSource, 242 258 ULONG ulExtraAllocate, 243 const char *file,259 PCSZ file, 244 260 unsigned long line, 245 const char *function)261 PCSZ function) 246 262 { 247 263 if (pxstr) … … 301 317 302 318 void xstrInitCopy(PXSTRING pxstr, 303 const char *pcszSource,319 PCSZ pcszSource, 304 320 ULONG ulExtraAllocate) // in: if > 0, extra memory to allocate 305 321 { … … 497 513 498 514 /* 499 *@@ xstrset :515 *@@ xstrset2: 500 516 * sets the specified XSTRING to a new string 501 517 * without copying it. … … 511 527 * is true if pszNew comes from strdup(). 512 528 * 513 *@@added V0.9.6 (2000-11-01) [umoeller] 514 *@@changed V0.9.9 (2001-02-14) [umoeller]: fixed NULL target crash 515 */ 516 517 ULONG xstrset(PXSTRING pxstr, // in/out: string 518 PSZ pszNew) // in: heap PSZ to use 529 * With this function, you can pass in the 530 * length of the string in ulNewLength. 531 * Otherwise use xstrset. 532 * 533 *@@added V0.9.16 (2002-01-13) [umoeller] 534 */ 535 536 ULONG xstrset2(PXSTRING pxstr, // in/out: string 537 PSZ pszNew, // in: heap PSZ to use 538 ULONG ulNewLength) // in: length of string or 0 to run strlen here 519 539 { 520 540 if (!pxstr) … … 525 545 if (pszNew) 526 546 { 527 pxstr->ulLength = strlen(pszNew); 528 pxstr->cbAllocated = pxstr->ulLength + 1; 529 530 pxstr->ulDelta = pxstr->cbAllocated * 10 / 100; 547 if (!ulNewLength) 548 ulNewLength = strlen(pszNew); 549 pxstr->ulLength = ulNewLength; 550 pxstr->cbAllocated = ulNewLength + 1; 551 552 pxstr->ulDelta = ulNewLength * 10 / 100; 531 553 } 532 554 // else null string: cbAllocated and ulLength are 0 already 533 555 534 556 return (pxstr->ulLength); 557 } 558 559 /* 560 *@@ xstrset: 561 * shortcut for xstrset2 for retaining compatibility. 562 * 563 *@@added V0.9.6 (2000-11-01) [umoeller] 564 *@@changed V0.9.9 (2001-02-14) [umoeller]: fixed NULL target crash 565 */ 566 567 ULONG xstrset(PXSTRING pxstr, // in/out: string 568 PSZ pszNew) // in: heap PSZ to use 569 { 570 return (xstrset2(pxstr, pszNew, 0)); 535 571 } 536 572 … … 583 619 584 620 ULONG xstrcpy(PXSTRING pxstr, // in/out: string 585 const char *pcszSource, // in: source, can be NULL621 PCSZ pcszSource, // in: source, can be NULL 586 622 ULONG ulSourceLength) // in: length of pcszSource or 0 587 623 { … … 694 730 695 731 ULONG xstrcat(PXSTRING pxstr, // in/out: string 696 const char *pcszSource, // in: source, can be NULL732 PCSZ pcszSource, // in: source, can be NULL 697 733 ULONG ulSourceLength) // in: length of pcszSource or 0 698 734 { … … 863 899 ULONG ulFirstReplOfs, // in: ofs of first char to replace 864 900 ULONG cReplLen, // in: no. of chars to replace 865 const char *pcszReplaceWith, // in: string to replace chars with901 PCSZ pcszReplaceWith, // in: string to replace chars with 866 902 ULONG cReplaceWithLen) // in: length of replacement string 867 903 // (this MUST be specified; if 0, chars are removed only) … … 1014 1050 size_t *pShiftTable, // in: shift table (see strhmemfind) 1015 1051 PBOOL pfRepeatFind, // in: repeat find? (see strhmemfind) 1016 const char *pcszBeginChars, // suggestion: "\x0d\x0a ()/\\-,."1017 const char *pcszEndChars) // suggestion: "\x0d\x0a ()/\\-,.:;"1052 PCSZ pcszBeginChars, // suggestion: "\x0d\x0a ()/\\-,." 1053 PCSZ pcszEndChars) // suggestion: "\x0d\x0a ()/\\-,.:;" 1018 1054 { 1019 1055 PSZ pReturn = 0; … … 1025 1061 if ((pxstr->ulLength) && (ulFoundLen)) 1026 1062 { 1027 const char *p = pxstr->psz + ulOfs;1063 PCSZ p = pxstr->psz + ulOfs; 1028 1064 1029 1065 do // while p … … 1152 1188 // yes: 1153 1189 ULONG ulOfs = *pulOfs; 1154 const char *pFound1155 = ( const char *)strhmemfind(pxstr->psz + ulOfs, // in: haystack1190 PCSZ pFound 1191 = (PCSZ)strhmemfind(pxstr->psz + ulOfs, // in: haystack 1156 1192 pxstr->ulLength - ulOfs, 1157 1193 pstrSearch->psz, … … 1199 1235 PULONG pulOfs, // in: where to begin search (0 = start); 1200 1236 // out: ofs of first char after replacement string 1201 const char *pcszSearch, // in: search string; cannot be NULL1202 const char *pcszReplace) // in: replacement string; cannot be NULL1237 PCSZ pcszSearch, // in: search string; cannot be NULL 1238 PCSZ pcszReplace) // in: replacement string; cannot be NULL 1203 1239 { 1204 1240 XSTRING xstrFind, … … 1292 1328 1293 1329 ULONG xstrEncode(PXSTRING pxstr, // in/out: string to convert 1294 const char *pcszEncode) // in: characters to encode (e.g. "%,();=")1330 PCSZ pcszEncode) // in: characters to encode (e.g. "%,();=") 1295 1331 { 1296 1332 ULONG ulrc = 0,
Note:
See TracChangeset
for help on using the changeset viewer.