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
121
121
122
122
* Related to the contents of the buffer
123
123
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
+
124
129
`strbuf_rtrim`::
125
130
126
131
Strip whitespace from the end of a string.
127
132
133
+ `strbuf_ltrim`::
134
+
135
+ Strip whitespace from the beginning of a string.
136
+
128
137
`strbuf_cmp`::
129
138
130
139
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)
78
78
79
79
void strbuf_trim (struct strbuf * sb )
80
80
{
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 );
90
83
}
91
84
void strbuf_rtrim (struct strbuf * sb )
92
85
{
You can’t perform that action at this time.
0 commit comments