summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-string.c
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2006-12-12 23:58:32 +0000
committerRalf Habacker <ralf.habacker@freenet.de>2006-12-12 23:58:32 +0000
commitf2e17db66f2e07e165fc90bba030a9f1d430834b (patch)
tree6f88b7e79cab0a38dc6d04f65a144b3c27b0d18b /dbus/dbus-string.c
parentea18bc0d071b8293008236383e827370c12a664d (diff)
* dbus/dbus-string.c (_dbus_string_pop_line),
bus/desktop-file.c (parse_section_start, parse_comment_or_blank,parse_key_value,): uses _dbus_string_find_eol() to support platform independent eol style.
Diffstat (limited to 'dbus/dbus-string.c')
-rw-r--r--dbus/dbus-string.c42
1 files changed, 6 insertions, 36 deletions
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index 5ae8ac3f..d83a3f39 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -2088,52 +2088,22 @@ dbus_bool_t
_dbus_string_pop_line (DBusString *source,
DBusString *dest)
{
- int eol;
- dbus_bool_t have_newline;
+ int eol, eol_len;
_dbus_string_set_length (dest, 0);
eol = 0;
- if (_dbus_string_find (source, 0, "\n", &eol))
- {
- have_newline = TRUE;
- eol += 1; /* include newline */
- }
- else
- {
+ if (!_dbus_string_find_eol (source, 0, &eol, &eol_len))
eol = _dbus_string_get_length (source);
- have_newline = FALSE;
- }
if (eol == 0)
return FALSE; /* eof */
- if (!_dbus_string_move_len (source, 0, eol,
- dest, 0))
- {
- return FALSE;
- }
+ if (!_dbus_string_move_len (source, 0, eol + eol_len, dest, 0))
+ return FALSE;
- /* dump the newline and the \r if we have one */
- if (have_newline)
- {
- dbus_bool_t have_cr;
-
- _dbus_assert (_dbus_string_get_length (dest) > 0);
-
- if (_dbus_string_get_length (dest) > 1 &&
- _dbus_string_get_byte (dest,
- _dbus_string_get_length (dest) - 2) == '\r')
- have_cr = TRUE;
- else
- have_cr = FALSE;
-
- _dbus_string_set_length (dest,
- _dbus_string_get_length (dest) -
- (have_cr ? 2 : 1));
- }
-
- return TRUE;
+ /* remove line ending */
+ return _dbus_string_set_length(dest, eol);
}
#ifdef DBUS_BUILD_TESTS