Hi there,

after stumbling twice over this issue, I ran grep
and found that the current usage of svn_tristate_t
does not depend on the actual numerical values
used for its states.

Therefore, I propose to define svn_tristate_false
equal to FALSE and svn_tristate_true equal to
TRUE. That way, we can compare booleans with
tristates and assign booleans to tristates. Without
that, we need to write code like

if ((get_some_bool() ? svn_tristate_true : svn_tristate_false) == get_a_tristate())
 ...

Also, the following will compile without warning but
requires the patch to do what was intended:

// FALSE becomes "unknown", TRUE becomes "false"
svn_tristate_t my_tristate = get_some_bool();

-- Stefan^2.

[[[
Make svn_tristate_t mainly compatible to svn_boolean_t
by making its numerical values match the ones used for
svn_boolean_t.

* subversion/include/svn_types.h
  (svn_tristate_t): define *_true and *_false in terms of
  the svn_boolean_t values TRUE and FALSE, respectively.
]]]

Index: subversion/include/svn_types.h
===================================================================
--- subversion/include/svn_types.h      (revision 1030747)
+++ subversion/include/svn_types.h      (working copy)
@@ -181,13 +181,15 @@
 svn_node_kind_t
 svn_node_kind_from_word(const char *word);
 
-/** Generic three-state property to represent an unknown value for values that
- * are just like booleans. @since New in 1.7. */
+/** Generic three-state property to represent an unknown value for values
+ * that are just like booleans. Please note that the values have been set
+ * deliberately to make tristates mainly compatible to @ref svn_boolean_t.
+ * @since New in 1.7. */
 typedef enum
 {
-  svn_tristate_unknown = 0,
-  svn_tristate_false,
-  svn_tristate_true
+  svn_tristate_false = FALSE,
+  svn_tristate_true = TRUE,
+  svn_tristate_unknown
 } svn_tristate_t;
 
 /** Return a constant string "true", "false" or NULL representing the value of

Reply via email to