core: Add string-append.

* src/strings.c (string_append): New function.
* mes/module/mes/boot-0.scm.in (string-append): Remove.
* mes/module/mes/boot-03.scm (string-append): Remove.
* scaffold/boot/50-make-string.scm (string-append): Remove.
* scaffold/boot/50-string-append.scm (string-append): Remove.
* scaffold/boot/50-string-join.scm (string-append): Remove.
* scaffold/boot/51-module.scm (string-append): Remove.
* scaffold/boot/52-define-module.scm (string-append): Remove.
* tests/macro.test (string-append): Remove.
* scaffold/boot/17-string-append.scm: Move from 50-string-append.scm.
This commit is contained in:
Jan Nieuwenhuizen 2018-11-15 23:09:56 +01:00
parent 149f2a3e51
commit 819b32e61c
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
10 changed files with 26 additions and 61 deletions

View file

@ -50,6 +50,7 @@ tests="
17-memq-keyword.scm 17-memq-keyword.scm
17-string-equal.scm 17-string-equal.scm
17-equal2.scm 17-equal2.scm
17-string-append.scm
17-open-input-string.scm 17-open-input-string.scm
20-define.scm 20-define.scm

View file

@ -148,9 +148,6 @@
(include (list->string (include (list->string
(append2 (string->list %moduledir) (string->list "mes/type-0.mes")))) (append2 (string->list %moduledir) (string->list "mes/type-0.mes"))))
(define (string-append . rest)
(apply string (apply append (map1 string->list rest))))
(if (and (getenv "MES_DEBUG") (if (and (getenv "MES_DEBUG")
(not (equal2? (getenv "MES_DEBUG") "0")) (not (equal2? (getenv "MES_DEBUG") "0"))
(not (equal2? (getenv "MES_DEBUG") "1"))) (not (equal2? (getenv "MES_DEBUG") "1")))

View file

@ -148,9 +148,6 @@
(include (list->string (include (list->string
(append2 (string->list %moduledir) (string->list "mes/type-0.mes")))) (append2 (string->list %moduledir) (string->list "mes/type-0.mes"))))
(define (string-append . rest)
(apply string (apply append (map1 string->list rest))))
(if (and (getenv "MES_DEBUG") (if (and (getenv "MES_DEBUG")
(not (equal2? (getenv "MES_DEBUG") "0")) (not (equal2? (getenv "MES_DEBUG") "0"))
(not (equal2? (getenv "MES_DEBUG") "1"))) (not (equal2? (getenv "MES_DEBUG") "1")))

View file

@ -16,34 +16,6 @@
;;; You should have received a copy of the GNU General Public License ;;; You should have received a copy of the GNU General Public License
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(cond-expand
(guile)
(mes
(define (cons* . rest)
(if (null? (cdr rest)) (car rest)
(cons (car rest) (core:apply cons* (cdr rest) (current-module)))))
(define (apply f h . t)
(if (null? t) (core:apply f h (current-module))
(apply f (apply cons* (cons h t)))))
(define (append . rest)
(if (null? rest) '()
(if (null? (cdr rest)) (car rest)
(append2 (car rest) (apply append (cdr rest))))))
(define (string . lst)
(list->string lst))
(define (map1 f lst)
(if (null? lst) (list)
(cons (f (car lst)) (map1 f (cdr lst)))))
(define map map1)
(define (string-append . rest)
(apply string (apply append (map string->list rest))))))
(if (string=? (string-append "foo" "/" "bar") "foo/bar") (if (string=? (string-append "foo" "/" "bar") "foo/bar")
(exit 0)) (exit 0))
(exit 1) (exit 1)

View file

@ -33,16 +33,7 @@
(append2 (car rest) (apply append (cdr rest)))))) (append2 (car rest) (apply append (cdr rest))))))
(define (string . lst) (define (string . lst)
(list->string lst)) (list->string lst))))
(define (map1 f lst)
(if (null? lst) (list)
(cons (f (car lst)) (map1 f (cdr lst)))))
(define map map1)
(define (string-append . rest)
(apply string (apply append (map string->list rest))))))
(define (make-list n . fill) (define (make-list n . fill)
fill) fill)

View file

@ -39,10 +39,7 @@
(if (null? lst) (list) (if (null? lst) (list)
(cons (f (car lst)) (map1 f (cdr lst))))) (cons (f (car lst)) (map1 f (cdr lst)))))
(define map map1) (define map map1)))
(define (string-append . rest)
(apply string (apply append (map string->list rest))))))
(define (string-join lst infix) (define (string-join lst infix)
(if (null? (cdr lst)) (car lst) (if (null? (cdr lst)) (car lst)

View file

@ -45,9 +45,6 @@
(define (string . lst) (define (string . lst)
(list->string lst)) (list->string lst))
(define (string-append . rest)
(apply string (apply append (map string->list rest))))
(define %prefix (getenv "MES_PREFIX")) (define %prefix (getenv "MES_PREFIX"))
(define (not x) (if x #f #t)) (define (not x) (if x #f #t))

View file

@ -49,9 +49,6 @@
(define map map1) (define map map1)
(define (string-append . rest)
(apply string (apply append (map string->list rest))))
;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;
(define (string-join lst infix) (define (string-join lst infix)
(if (null? (cdr lst)) (car lst) (if (null? (cdr lst)) (car lst)

View file

@ -240,3 +240,23 @@ read_string (SCM port) ///((arity . n))
g_stdin = fd; g_stdin = fd;
return make_string (buf, i); return make_string (buf, i);
} }
SCM
string_append (SCM x) ///((arity . n))
{
static char buf[MAX_STRING];
char const *p = buf;
buf[0] = 0;
size_t size = 0;
while (x != cell_nil)
{
SCM string = CAR (x);
assert (TYPE (string) == TSTRING);
memcpy (p, CSTRING (string), LENGTH (string) + 1);
p += LENGTH (string);
size += LENGTH (string);
assert (size < MAX_STRING);
x = CDR (x);
}
return make_string (buf, size);
}

View file

@ -59,10 +59,6 @@ exec ${MES-mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests macr
(define (string . lst) (define (string . lst)
(list->string lst)) (list->string lst))
;; boot-0.scm
(define (string-append . rest)
(apply string (apply append (map1 string->list rest))))
;; scm.mes ;; scm.mes
(define (symbol-append . rest) (define (symbol-append . rest)
(string->symbol (apply string-append (map symbol->string rest)))) (string->symbol (apply string-append (map symbol->string rest))))