You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/11/09 16:07:48 UTC

svn commit: r1033006 - /subversion/trunk/subversion/include/svn_types.h

Author: stefan2
Date: Tue Nov  9 15:07:47 2010
New Revision: 1033006

URL: http://svn.apache.org/viewvc?rev=1033006&view=rev
Log:
Tri-states are not a superset of booleans. Therefore, use
numerical values for the svn_tristate_t enum members
different from TRUE and FALSE.

* subversion/include/svn_types.h
  (svn_tristate_t): make disjoint with {TRUE, FALSE}

Modified:
    subversion/trunk/subversion/include/svn_types.h

Modified: subversion/trunk/subversion/include/svn_types.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_types.h?rev=1033006&r1=1033005&r2=1033006&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_types.h (original)
+++ subversion/trunk/subversion/include/svn_types.h Tue Nov  9 15:07:47 2010
@@ -183,13 +183,13 @@ svn_node_kind_from_word(const char *word
 
 /** Generic three-state property to represent an unknown value for values
  * that are just like booleans.  The values have been set deliberately to
- * make tristates mainly compatible with #svn_boolean_t.
+ * make tristates disjoint from #svn_boolean_t.
  *
  * @since New in 1.7. */
 typedef enum
 {
-  svn_tristate_false = FALSE,
-  svn_tristate_true = TRUE,
+  svn_tristate_false = 2,
+  svn_tristate_true,
   svn_tristate_unknown
 } svn_tristate_t;
 



RE: svn_tristate_t Re: svn commit: r1033006 - /subversion/trunk/subversion/include/svn_types.h

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Daniel Shahaf [mailto:d.s@daniel.shahaf.name]
> Sent: woensdag 10 november 2010 0:26
> To: dev@subversion.apache.org
> Cc: Daniel Shahaf
> Subject: Re: svn_tristate_t Re: svn commit: r1033006 -
> /subversion/trunk/subversion/include/svn_types.h
> 
> Daniel Shahaf wrote on Wed, Nov 10, 2010 at 00:31:11 +0200:
> > I see us someday pcalloc()'ing one of these and forgetting to reset
> it
> > to the 'svn_tristate_unknown' value.
> 
> Actually, svn_log_changed_path2_create() does exactly this.  Right now.

When I introduced svn_tristate_t, 0 was the unknown value...
(And this might have been the reason to do that... but I don't remember the
exact reasoning any more)

	Bert

Re: svn_tristate_t Re: svn commit: r1033006 - /subversion/trunk/subversion/include/svn_types.h

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Daniel Shahaf wrote on Wed, Nov 10, 2010 at 00:31:11 +0200:
> I see us someday pcalloc()'ing one of these and forgetting to reset it
> to the 'svn_tristate_unknown' value.

Actually, svn_log_changed_path2_create() does exactly this.  Right now.

svn_tristate_t Re: svn commit: r1033006 - /subversion/trunk/subversion/include/svn_types.h

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
stefan2@apache.org wrote on Tue, Nov 09, 2010 at 15:07:48 -0000:
>  /** Generic three-state property to represent an unknown value for values
>   * that are just like booleans.  The values have been set deliberately to
> - * make tristates mainly compatible with #svn_boolean_t.
> + * make tristates disjoint from #svn_boolean_t.
>   *
>   * @since New in 1.7. */
>  typedef enum
>  {
> -  svn_tristate_false = FALSE,
> -  svn_tristate_true = TRUE,
> +  svn_tristate_false = 2,
> +  svn_tristate_true,
>    svn_tristate_unknown
>  } svn_tristate_t;

I see us someday pcalloc()'ing one of these and forgetting to reset it
to the 'svn_tristate_unknown' value.

Could we make compilers catch that for us?

Or should we just assert that the value really is one of those three
values?  Or even interpret any value (except svn_tristate_true and
svn_tristate_false) as "unknown"?