Skip to content

Commit

Permalink
README, changelog, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
vindarel committed Oct 14, 2019
1 parent ff2796e commit 1d00ea3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,19 @@ Return list of words, which were delimited by whitespace.

Join the list of strings with a whitespace.

#### lines `(s)`
#### lines `(s &key omit-nulls)`

Split string by newline character and return list of lines.

A terminal newline character does *not* result in an extra empty string
(new in **v0.14**, october 2019).


#### unlines `(strings)`

Join the list of strings with a newline character.

#### split `(separator s &key omit-nulls limit)`
#### split `(separator s &key omit-nulls limit start end)`

Split into subtrings (unlike cl-ppcre, without a regexp). If
`omit-nulls` is non-nil, zero-length substrings are omitted.
Expand All @@ -307,6 +311,19 @@ Split into subtrings (unlike cl-ppcre, without a regexp). If
(split "+" "foo++bar" :omit-nulls t) ;; => ("foo" "bar")
```

cl-ppcre has an inconsistency such that when the separator appears at
the end, it doesn't return a trailing empty string. But we do **since
v0.14** (october, 2019).

~~~lisp
(cl-ppcre:split " " "a b c ")
("a" "b" "c")
(str:split " " "a b c ")
("a" "b" "c" "")
~~~


#### split-omit-nulls (in v0.6, QL january 2018)

Because it is a common pattern and it can be clearer than an option
Expand Down Expand Up @@ -530,6 +547,22 @@ Note that there is also http://quickdocs.org/string-case/.

## Changelog

* 0.14, october, 2019: fixed the cl-ppcre inconsistency in `split` and `lines`. A trailing separator now returns a trailing empty string.

Before:

~~~lisp
(str:split " " "a b c ")
("a" "b" "c") ;; like cl-ppcre:split
~~~

Now:

~~~lisp
(str:split " " "a b c ")
("a" "b" "c" "")
~~~

* august, 2019: deprecated `prune`, renamed to `shorten`.
* added `:limit` to `split`.
* 0.13 june, 2019
Expand Down
2 changes: 1 addition & 1 deletion str.asd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:author "vindarel <[email protected]>"
:maintainer "vindarel <[email protected]>"
:license "MIT"
:version "0.13"
:version "0.14"
:homepage "https://github.com/vindarel/cl-str"
:bug-tracker "https://github.com/vindarel/cl-str/issues"
:source-control (:git "[email protected]:vindarel/cl-str.git")
Expand Down
4 changes: 2 additions & 2 deletions str.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
(defvar *whitespaces* '(#\Space #\Newline #\Backspace #\Tab
#\Linefeed #\Page #\Return #\Rubout))

(defvar +version+ "0.13")
(defvar +version+ "0.14")

(defun version ()
(print +version+))
Expand Down Expand Up @@ -211,7 +211,7 @@ It uses `subseq' with differences:
(join " " strings))

(defun lines (s &key (omit-nulls *omit-nulls*))
"Split the string by newline characters and return a list of lines. A terminal newline character does NOT result an extra empty string."
"Split the string by newline characters and return a list of lines. A terminal newline character does NOT result in an extra empty string."
(when (and s (> (length s) 0))
(let ((end (if (eql #\Newline (elt s (1- (length s))))
(1- (length s))
Expand Down

0 comments on commit 1d00ea3

Please sign in to comment.