Skip to content

Commit 46e72e6

Browse files
committed
Provide implementation for SRFI 118.
1 parent 45b6f9f commit 46e72e6

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

LispKit.xcodeproj/project.pbxproj

+6
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@
953953
CCC9516F2426B3E900FC915F /* 162.sld in Copy pre-installed SRFI libraries */ = {isa = PBXBuildFile; fileRef = CCC9516E2426B1E100FC915F /* 162.sld */; };
954954
CCC951712426B6B000FC915F /* SRFI-128.scm in Copy tests */ = {isa = PBXBuildFile; fileRef = CCC951702426B54600FC915F /* SRFI-128.scm */; };
955955
CCCACB5C248D753800F012AC /* SystemOSLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCCACB5B248D753800F012AC /* SystemOSLibrary.swift */; };
956+
CCCB5C9D28403E870005248D /* 118.sld in Copy pre-installed SRFI libraries */ = {isa = PBXBuildFile; fileRef = CCCB5C9C28403E550005248D /* 118.sld */; };
957+
CCCB5C9E28403E960005248D /* 118.sld in Copy pre-installed SRFI libraries */ = {isa = PBXBuildFile; fileRef = CCCB5C9C28403E550005248D /* 118.sld */; };
956958
CCCB66E1282DBBC80004827D /* DrawBarCharts.scm in Copy examples */ = {isa = PBXBuildFile; fileRef = CCCB66E0282DB9790004827D /* DrawBarCharts.scm */; };
957959
CCCB66E2282DBBDB0004827D /* DrawBarCharts.scm in Copy examples */ = {isa = PBXBuildFile; fileRef = CCCB66E0282DB9790004827D /* DrawBarCharts.scm */; };
958960
CCCB66E4283056E30004827D /* StyledTextLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCCB66E3283056E30004827D /* StyledTextLibrary.swift */; };
@@ -1725,6 +1727,7 @@
17251727
dstPath = Root/LispKit/Libraries/srfi;
17261728
dstSubfolderSpec = 7;
17271729
files = (
1730+
CCCB5C9D28403E870005248D /* 118.sld in Copy pre-installed SRFI libraries */,
17281731
CC6E93CB281CA1320002C4BC /* 232.sld in Copy pre-installed SRFI libraries */,
17291732
CC372CE027D56FB50091C474 /* 141.sld in Copy pre-installed SRFI libraries */,
17301733
CCEF3E3327CB66D900FB56EB /* 149.sld in Copy pre-installed SRFI libraries */,
@@ -1835,6 +1838,7 @@
18351838
dstPath = Root/LispKit/Libraries/srfi;
18361839
dstSubfolderSpec = 7;
18371840
files = (
1841+
CCCB5C9E28403E960005248D /* 118.sld in Copy pre-installed SRFI libraries */,
18381842
CC6E93CC281CA15A0002C4BC /* 232.sld in Copy pre-installed SRFI libraries */,
18391843
CC372CE127D56FC60091C474 /* 141.sld in Copy pre-installed SRFI libraries */,
18401844
CCEF3E3427CB66ED00FB56EB /* 149.sld in Copy pre-installed SRFI libraries */,
@@ -2890,6 +2894,7 @@
28902894
CCCACB5B248D753800F012AC /* SystemOSLibrary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemOSLibrary.swift; sourceTree = "<group>"; };
28912895
CCCAF5AE23B7A71400FE2C60 /* HtmlColors.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = HtmlColors.plist; sourceTree = "<group>"; };
28922896
CCCAF92D1F941A43006692E9 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; indentWidth = 2; path = Package.swift; sourceTree = "<group>"; tabWidth = 2; };
2897+
CCCB5C9C28403E550005248D /* 118.sld */ = {isa = PBXFileReference; lastKnownFileType = text; path = 118.sld; sourceTree = "<group>"; };
28932898
CCCB66E0282DB9790004827D /* DrawBarCharts.scm */ = {isa = PBXFileReference; lastKnownFileType = text; path = DrawBarCharts.scm; sourceTree = "<group>"; };
28942899
CCCB66E3283056E30004827D /* StyledTextLibrary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyledTextLibrary.swift; sourceTree = "<group>"; };
28952900
CCCEB3FE1DF2DAA9009BF66B /* FileHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileHandler.swift; sourceTree = "<group>"; };
@@ -3416,6 +3421,7 @@
34163421
CC26263B20F56DBF00AC08E8 /* 111.sld */,
34173422
CC26263D20F56F9300AC08E8 /* 112.sld */,
34183423
CC26263F20F7FB8100AC08E8 /* 113.sld */,
3424+
CCCB5C9C28403E550005248D /* 118.sld */,
34193425
CC7AAE6B1EC859E100B0F66C /* 121.sld */,
34203426
CC2C73DC21A217B500B18661 /* 125.sld */,
34213427
CCC072471F9C047D0063974E /* 128.sld */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
;;; SRFI 118
2+
;;; Simple adjustable-size strings
3+
;;;
4+
;;; Scheme specifies mutable fixed-length strings. We add two procedures
5+
;;; `string-append!` and `string-replace!` which allow the size of the string
6+
;;; to change. We also require that the standard Scheme procedures `make-string`
7+
;;; and `string-copy` return variable-size strings.
8+
;;;
9+
;;; Specification:
10+
;;; Copyright © 2015 Per Bothner. All rights reserved.
11+
;;;
12+
;;; Implementation:
13+
;;; Copyright © 2022 Matthias Zenger. All rights reserved.
14+
;;;
15+
;;; Permission is hereby granted, free of charge, to any person obtaining a copy
16+
;;; of this software and associated documentation files (the "Software"), to deal
17+
;;; in the Software without restriction, including without limitation the rights
18+
;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19+
;;; copies of the Software, and to permit persons to whom the Software is
20+
;;; furnished to do so, subject to the following conditions:
21+
;;;
22+
;;; The above copyright notice and this permission notice shall be included in
23+
;;; all copies or substantial portions of the Software.
24+
;;;
25+
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28+
;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29+
;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30+
;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31+
;;; DEALINGS IN THE SOFTWARE.
32+
33+
(define-library (srfi 118)
34+
35+
(export string-append!
36+
string-replace!)
37+
38+
(import (except (lispkit base) string-replace!))
39+
40+
(begin
41+
(define (string-replace! dst dst-start dst-end src . args)
42+
(let-optionals args ((start 0)
43+
(end (string-length src)))
44+
(string-insert! dst (substring src start end) dst-start dst-end)))
45+
)
46+
)

Sources/LispKit/Resources/Tests/Import.scm

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
(import (srfi 111))
114114
(import (srfi 112))
115115
(import (srfi 113))
116+
(import (srfi 118))
116117
(import (srfi 121))
117118
(import (srfi 125))
118119
(import (srfi 128))

0 commit comments

Comments
 (0)