vala r1009 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1009 - in trunk: . vala
- Date: Thu, 14 Feb 2008 17:03:21 +0000 (GMT)
Author: juergbi
Date: Thu Feb 14 17:03:21 2008
New Revision: 1009
URL: http://svn.gnome.org/viewvc/vala?rev=1009&view=rev
Log:
2008-02-14 Juerg Billeter <j bitron ch>
* vala/valainterfacewriter.vala: avoid testing floating point
numbers for equality, fixes bug 516259
Modified:
trunk/ChangeLog
trunk/vala/valainterfacewriter.vala
Modified: trunk/vala/valainterfacewriter.vala
==============================================================================
--- trunk/vala/valainterfacewriter.vala (original)
+++ trunk/vala/valainterfacewriter.vala Thu Feb 14 17:03:21 2008
@@ -448,6 +448,11 @@
}
}
+ // equality comparison with 3 digit precision
+ private bool float_equal (double d1, double d2) {
+ return ((int) (d1 * 1000)) == ((int) (d2 * 1000));
+ }
+
private void write_params (Collection<FormalParameter> params) {
write_string ("(");
@@ -466,11 +471,11 @@
var ccode_params = new String ();
var separator = "";
- if (param.carray_length_parameter_position != i + 0.1) {
+ if (!float_equal (param.carray_length_parameter_position, i + 0.1)) {
ccode_params.append_printf ("%sarray_length_pos = %g", separator, param.carray_length_parameter_position);
separator = ", ";
}
- if (param.cdelegate_target_parameter_position != i + 0.1) {
+ if (!float_equal (param.cdelegate_target_parameter_position, i + 0.1)) {
ccode_params.append_printf ("%sdelegate_target_pos = %g", separator, param.cdelegate_target_parameter_position);
separator = ", ";
}
@@ -571,15 +576,15 @@
ccode_params.append_printf ("%scname = \"%s\"", separator, m.get_cname ());
separator = ", ";
}
- if (m.cinstance_parameter_position != 0) {
+ if (!float_equal (m.cinstance_parameter_position, 0)) {
ccode_params.append_printf ("%sinstance_pos = %g", separator, m.cinstance_parameter_position);
separator = ", ";
}
- if (m.carray_length_parameter_position != -3) {
+ if (!float_equal (m.carray_length_parameter_position, -3)) {
ccode_params.append_printf ("%sarray_length_pos = %g", separator, m.carray_length_parameter_position);
separator = ", ";
}
- if (m.cdelegate_target_parameter_position != -3) {
+ if (!float_equal (m.cdelegate_target_parameter_position, -3)) {
ccode_params.append_printf ("%sdelegate_target_pos = %g", separator, m.cdelegate_target_parameter_position);
separator = ", ";
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]