Ignore:
Timestamp:
Feb 2, 2003, 9:22:17 PM (23 years ago)
Author:
umoeller
Message:

Sources as of 1.0.1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/xstring.c

    r222 r245  
    11131113 *      especially with large string bufffers.
    11141114 *
    1115  *      None of the pointers can be NULL, but if pstrReplace
    1116  *      is empty, this effectively erases pstrSearch in pxstr.
     1115 *      pxstr and pstrReplace may not be NULL, but if
     1116 *      pstrReplace is null or empty, this effectively
     1117 *      erases pstrSearch in pxstr.
    11171118 *
    11181119 *      Returns the length of the new string (exclusing the
     
    11691170 *@@changed V0.9.6 (2000-11-12) [umoeller]: now using strhmemfind
    11701171 *@@changed V0.9.7 (2001-01-15) [umoeller]: renamed from xstrrpl; extracted new xstrrpl
     1172 *@@changed V1.0.1 (2003-02-02) [umoeller]: now allowing for NULL pstrReplace
    11711173 */
    11721174
     
    11751177                                                    // out: ofs of first char after replacement string
    11761178                      const XSTRING *pstrSearch,    // in: search string; cannot be NULL
    1177                       const XSTRING *pstrReplace,   // in: replacement string; cannot be NULL
     1179                      const XSTRING *pstrReplace,   // in: replacement string or NULL
    11781180                      size_t *pShiftTable,          // in: shift table (see strhmemfind)
    11791181                      PBOOL pfRepeatFind)           // in: repeat find? (see strhmemfind)
     
    11811183    ULONG    ulrc = 0;      // default: not found
    11821184
    1183     if ((pxstr) && (pstrSearch) && (pstrReplace))
     1185    if ((pxstr) && (pstrSearch))
    11841186    {
    11851187        ULONG   cSearchLen = pstrSearch->ulLength;
     
    12011203            {
    12021204                ULONG ulFirstReplOfs = pFound - pxstr->psz;
     1205                ULONG   lenRepl = pstrReplace ? (pstrReplace->ulLength) : 0;
    12031206                // found in buffer from ofs:
    12041207                // replace pFound with pstrReplace
     
    12061209                               ulFirstReplOfs,              // where to start
    12071210                               cSearchLen,                  // chars to replace
    1208                                pstrReplace->psz,
    1209                                pstrReplace->ulLength);      // adjusted V0.9.11 (2001-04-22) [umoeller]
     1211                               pstrReplace ? (pstrReplace->psz) : NULL,
     1212                               lenRepl);      // adjusted V0.9.11 (2001-04-22) [umoeller]
    12101213
    12111214                // return new length
    1212                 *pulOfs = ulFirstReplOfs + pstrReplace->ulLength;
     1215                *pulOfs = ulFirstReplOfs + lenRepl;
    12131216            } // end if (pFound)
    12141217        } // end if (    (*pulOfs < pxstr->ulLength) ...
Note: See TracChangeset for help on using the changeset viewer.