aboutsummaryrefslogtreecommitdiffhomepage
path: root/bstr.c
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@mplayer2.org>2012-07-28 17:07:49 +0200
committerGravatar wm4 <wm4@mplayer2.org>2012-07-28 17:24:05 +0200
commit51e198c2a1e43b74ad35ef358628dcd8791158d9 (patch)
tree60f6c2255ed912a7a4866b71728104a2cb2442f1 /bstr.c
parent2793e7eb70a342b346788f83e1ed660c8e0d491e (diff)
parent7dfaaa95104a8e6dc024fddaf1b49c71768f1be7 (diff)
Merge remote-tracking branch 'origin/master'
Conflicts: .gitignore bstr.c cfg-mplayer.h defaultopts.c libvo/video_out.c The conflict in bstr.c is due to uau adding a bstr_getline function in commit 2ba8b91a97e7e8. This function already existed in this branch. While uau's function is obviously derived from mine, it's incompatible. His function preserves line breaks, while mine strips them. Add a bstr_strip_linebreaks function, fix all other uses of bstr_getline, and pick uau's implementation. In .gitignore, change vo_gl3_shaders.h to use an absolute path additional to resolving the merge conflict.
Diffstat (limited to 'bstr.c')
-rw-r--r--bstr.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/bstr.c b/bstr.c
index fcf73ca828..036cf69d42 100644
--- a/bstr.c
+++ b/bstr.c
@@ -192,9 +192,16 @@ struct bstr bstr_getline(struct bstr str, struct bstr *rest)
pos = str.len;
if (rest)
*rest = bstr_cut(str, pos + 1);
- str.len = pos;
- if (str.len > 0 && str.start[str.len - 1] == '\r')
- str.len -= 1;
+ return bstr_splice(str, 0, pos + 1);
+}
+
+struct bstr bstr_strip_linebreaks(struct bstr str)
+{
+ if (bstr_endswith0(str, "\r\n")) {
+ str = bstr_splice(str, 0, str.len - 2);
+ } else if (bstr_endswith0(str, "\n")) {
+ str = bstr_splice(str, 0, str.len - 1);
+ }
return str;
}