Skip to content

Commit 2c46b9a

Browse files
committed
prelude: add _chop and _chop_space procs
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 291cbbf commit 2c46b9a

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(abcx)
2+
(abc)
3+
(abc )
4+
(abc)
5+
(abcx)
6+
(abcx)

Tmain/common-prelude.d/chop.ps

122 Bytes
Binary file not shown.

Tmain/common-prelude.d/stdout-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
aindex.ps...0
22
amember.ps...0
33
buildstring.ps...0
4+
chop.ps...0
45
dedup.ps...0
56
dedup_spaces.ps...0
67
ndup.ps...0

main/CommonPrelude.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,27 @@ const char ctagsCommonPrelude []=
119119
" exch copy pop\n"
120120
"} __bddef\n"
121121
"\n"
122+
"(string _CHOP string)\n"
123+
"/_chop {\n"
124+
" mark exch {} forall pop _buildstring\n"
125+
"} __bddef\n"
126+
"\n"
127+
"(string _CHOP_SPACE string)\n"
128+
"/_chop_space {\n"
129+
" dup length dup 0 gt {\n"
130+
" % string length\n"
131+
" 1 sub\n"
132+
" % string `length - 1`\n"
133+
" 1 index exch\n"
134+
" % string string `length - 1`\n"
135+
" get (\\n\\t\\r\\f\\v ) exch _amember {\n"
136+
" _chop\n"
137+
" } if\n"
138+
" } {\n"
139+
" pop % pop the length\n"
140+
" } ifelse\n"
141+
"} __bddef\n"
142+
"\n"
122143
"% /x mark 40 (a) 32 32 10 (b) 10 10 9 9 (xyz) 9 9 41 _buildstring def\n"
123144
"% x _normalize_spaces! x pstack\n"
124145
"\n"

main/CommonPrelude.ps

432 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)