summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-03 07:16:12 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-03 07:16:12 +0000
commit07d2fd5aa2891d94bcb97db89178a4d536599d14 (patch)
treedb8904967f507a05ca582a04ac7beb4f114b3d60
parentc7e05f9ca4ff7ab0c8499b2059004dd38d2c8784 (diff)
2005-01-03 Havoc Pennington <hp@redhat.com>
* dbus/dbus-sysdeps.c (_dbus_sysdeps_test): fix using == on floating point * dbus/dbus-string.c (_dbus_string_insert_alignment): new function
-rw-r--r--ChangeLog11
-rw-r--r--dbus/dbus-string.c32
-rw-r--r--dbus/dbus-string.h3
-rw-r--r--dbus/dbus-sysdeps.c4
4 files changed, 48 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 45f1ef6c..f37e712f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-01-03 Havoc Pennington <hp@redhat.com>
+
+ * dbus/dbus-sysdeps.c (_dbus_sysdeps_test): fix using == on
+ floating point
+
+ * dbus/dbus-string.c (_dbus_string_insert_alignment): new function
+
+2005-01-02 Havoc Pennington <hp@redhat.com>
+
+ * dbus/dbus-internals.h (_DBUS_ALIGN_OFFSET): new macro
+
2005-01-01 Havoc Pennington <hp@redhat.com>
* configure.in: add -Wfloat-equal
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index 108ddad5..7040e155 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -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 @@ _dbus_string_insert_8_aligned (DBusString *str,
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.
diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h
index 96f3d560..792b8194 100644
--- a/dbus/dbus-string.h
+++ b/dbus/dbus-string.h
@@ -153,6 +153,9 @@ dbus_bool_t _dbus_string_insert_4_aligned (DBusString *str,
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);
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 8c3a2be4..be9d8e99 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -3510,7 +3510,7 @@ _dbus_sysdeps_test (void)
_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_sysdeps_test (void)
_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);