File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -121,10 +121,19 @@ Functions
121121
122122* Related to the contents of the buffer
123123
124+ `strbuf_trim`::
125+
126+ Strip whitespace from the beginning and end of a string.
127+ Equivalent to performing `strbuf_rtrim()` followed by `strbuf_ltrim()`.
128+
124129`strbuf_rtrim`::
125130
126131 Strip whitespace from the end of a string.
127132
133+ `strbuf_ltrim`::
134+
135+ Strip whitespace from the beginning of a string.
136+
128137`strbuf_cmp`::
129138
130139 Compare two buffers. Returns an integer less than, equal to, or greater
Original file line number Diff line number Diff line change @@ -78,15 +78,8 @@ void strbuf_grow(struct strbuf *sb, size_t extra)
7878
7979void strbuf_trim (struct strbuf * sb )
8080{
81- char * b = sb -> buf ;
82- while (sb -> len > 0 && isspace ((unsigned char )sb -> buf [sb -> len - 1 ]))
83- sb -> len -- ;
84- while (sb -> len > 0 && isspace (* b )) {
85- b ++ ;
86- sb -> len -- ;
87- }
88- memmove (sb -> buf , b , sb -> len );
89- sb -> buf [sb -> len ] = '\0' ;
81+ strbuf_rtrim (sb );
82+ strbuf_ltrim (sb );
9083}
9184void strbuf_rtrim (struct strbuf * sb )
9285{
You can’t perform that action at this time.
0 commit comments