dbus/dbus dbus-string.c, 1.59, 1.60 dbus-string.h, 1.33,
1.34 dbus-sysdeps.c, 1.83, 1.84
Havoc Pennington
hp at freedesktop.org
Sun Jan 2 23:16:14 PST 2005
Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv1127/dbus
Modified Files:
dbus-string.c dbus-string.h dbus-sysdeps.c
Log Message:
2005-01-03 Havoc Pennington <hp at redhat.com>
* dbus/dbus-sysdeps.c (_dbus_sysdeps_test): fix using == on
floating point
* dbus/dbus-string.c (_dbus_string_insert_alignment): new function
Index: dbus-string.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- dbus-string.c 1 Jan 2005 02:35:09 -0000 1.59
+++ dbus-string.c 3 Jan 2005 07:16:12 -0000 1.60
@@ -59,6 +59,12 @@
* because it could keep us from detecting bogus huge lengths. i.e. if
* we passed in some bogus huge length it would be taken to mean
* "current length of string" instead of "broken crack"
+ *
+ * @todo #DBusString needs a lot of cleaning up; some of the
+ * API is no longer used, and the API is pretty inconsistent.
+ * In particular all the "append" APIs, especially those involving
+ * alignment but probably lots of them, are no longer used by the
+ * marshaling code which always does "inserts" now.
*/
/**
@@ -1155,6 +1161,32 @@
return TRUE;
}
+
+/**
+ * Inserts padding at *insert_at such to align it to the given
+ * boundary. Initializes the padding to nul bytes. Sets *insert_at
+ * to the aligned position.
+ *
+ * @param str the DBusString
+ * @param insert_at location to be aligned
+ * @param alignment alignment boundary (1, 4, or 8)
+ * @returns #FALSE if not enough memory.
+ */
+dbus_bool_t
+_dbus_string_insert_alignment (DBusString *str,
+ int *insert_at,
+ int alignment)
+{
+ DBUS_STRING_PREAMBLE (str);
+
+ if (!align_insert_point_then_open_gap (str, insert_at, 8, 0))
+ return FALSE;
+
+ _dbus_assert (_DBUS_ALIGN_VALUE (*insert_at, 8) == (unsigned) *insert_at);
+
+ return TRUE;
+}
+
/**
* Appends a printf-style formatted string
* to the #DBusString.
Index: dbus-string.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-string.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- dbus-string.h 31 Dec 2004 21:01:56 -0000 1.33
+++ dbus-string.h 3 Jan 2005 07:16:12 -0000 1.34
@@ -153,6 +153,9 @@
dbus_bool_t _dbus_string_insert_8_aligned (DBusString *str,
int insert_at,
const unsigned char octets[8]);
+dbus_bool_t _dbus_string_insert_alignment (DBusString *str,
+ int *insert_at,
+ int alignment);
void _dbus_string_delete (DBusString *str,
int start,
int len);
Index: dbus-sysdeps.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- dbus-sysdeps.c 26 Nov 2004 01:53:13 -0000 1.83
+++ dbus-sysdeps.c 3 Jan 2005 07:16:12 -0000 1.84
@@ -3510,7 +3510,7 @@
_dbus_warn ("Failed to parse double");
exit (1);
}
- if (val != 3.5)
+ if (ABS(3.5 - val) > 1e-6)
{
_dbus_warn ("Failed to parse 3.5 correctly, got: %f", val);
exit (1);
@@ -3528,7 +3528,7 @@
_dbus_warn ("Failed to parse double");
exit (1);
}
- if (val != 0xff)
+ if (ABS (0xff - val) < 1e-6)
{
_dbus_warn ("Failed to parse 0xff correctly, got: %f", val);
exit (1);
More information about the dbus-commit
mailing list