replace   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/base/base.xtm

Implementation

(bind-func replace
  (lambda (orig:i8* rep:i8* with:i8*)
    (if (null? (strstr orig rep)) (Str orig)
        (let ((origl (strlen orig))
              (repl (strlen rep))
              (withl (strlen with))
              (pos (strstr orig rep))
              (start (- (ptrtoi64 pos) (ptrtoi64 orig)))
              (newstr:i8* (salloc (+ 1 (strlen orig) (- withl repl)))))
          (memset newstr 0 (+ 1 (strlen orig) (- withl repl)))
          (strncpy newstr orig start)
          (strncpy (pref-ptr newstr start) with withl)
          (strncpy (pref-ptr newstr (+ start withl))
                   (pref-ptr orig (+ start repl))
                   (- origl (+ start repl)))
          (Str newstr)))))


Back to Index

Similar Entries

  • multi_replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/cas.xtm
  • regex:replace-all    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • regex:replace-everything    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • regex_replace    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • regex_replace    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • regex_replace    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • regex_replace    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • regex_replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • regex_replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • regex_replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • regex_replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/core/adt.xtm
  • replace    xtlang    /digego/extempore/tree/v0.8.9/libs/base/base.xtm
  • replace    xtlang    /digego/extempore/tree/v0.8.9/libs/base/base.xtm
  • replace    xtlang    /digego/extempore/tree/v0.8.9/libs/base/base.xtm
  • replace-all    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • replace-first    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/base/base.xtm
  • replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/base/base.xtm
  • replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/base/base.xtm
  • replace_all    xtlang    /digego/extempore/tree/v0.8.9/libs/base/base.xtm