Ethereal-dev: [Ethereal-dev] bool keyword in prefs-int.h

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Chris Waters <chris@xxxxxxxxxxxx>
Date: Fri, 14 Jun 2002 08:50:25 -0700
Hi,

The declaration for the preference structure in prefs-int.h uses the name
'bool' for a couple of the fields in the structure. bool is a keyword in C++
and when compiling prefs-int.h with a C++ compiler (Borland C++ Builder in
this case) the compiler complains. I haven't tried compiling with MSVC++,
but its syntax highlighter thinks that bool is a keyword too.

I would like to suggest that the name of the field be changed to 'bool_val'.

The asn1_bool_decode function in the asn1.h file also uses bool as the name
of a parameter.

Here is a patch for the change:

cvs diff -u prefs-int.h prefs.c asn1.c asn1.h gtk/prefs_dlg.c
Index: prefs-int.h
===================================================================
RCS file: /cvsroot/ethereal/prefs-int.h,v
retrieving revision 1.6
diff -u -r1.6 prefs-int.h
--- prefs-int.h 2002/05/25 01:47:46 1.6
+++ prefs-int.h 2002/06/14 15:48:11
@@ -57,13 +57,13 @@
  pref_type_t type; /* type of that preference */
  union {
   guint *uint;
-  gboolean *bool;
+  gboolean *bool_val;
   gint *enump;
   char **string;
  } varp;   /* pointer to variable storing the value */
  union {
   guint uint;
-  gboolean bool;
+  gboolean bool_val;
   gint enumval;
   char *string;
  } saved_val;  /* original value, when editing from the GUI */
Index: prefs.c
===================================================================
RCS file: /cvsroot/ethereal/prefs.c,v
retrieving revision 1.84
diff -u -r1.84 prefs.c
--- prefs.c 2002/05/29 07:35:55 1.84
+++ prefs.c 2002/06/14 15:48:16
@@ -387,7 +387,7 @@

  preference = register_preference(module, name, title, description);
  preference->type = PREF_BOOL;
- preference->varp.bool = var;
+ preference->varp.bool_val = var;
 }

 /*
@@ -1524,9 +1524,9 @@
         bval = TRUE;
       else
         bval = FALSE;
-      if (*pref->varp.bool != bval) {
+      if (*pref->varp.bool_val != bval) {
  module->prefs_changed = TRUE;
- *pref->varp.bool = bval;
+ *pref->varp.bool_val = bval;
       }
       break;

@@ -1613,7 +1613,7 @@
  case PREF_BOOL:
   fprintf(arg->pf, "# TRUE or FALSE (case-insensitive).\n");
   fprintf(arg->pf, "%s.%s: %s\n", arg->module->name, pref->name,
-      *pref->varp.bool ? "TRUE" : "FALSE");
+      *pref->varp.bool_val ? "TRUE" : "FALSE");
   break;

  case PREF_ENUM:
Index: asn1.c
===================================================================
RCS file: /cvsroot/ethereal/asn1.c,v
retrieving revision 1.13
diff -u -r1.13 asn1.c
--- asn1.c 2002/05/13 01:24:45 1.13
+++ asn1.c 2002/06/14 15:48:18
@@ -386,17 +386,17 @@
  *                  (
  *                      ASN1_SCK *asn1,
  *                      int      enc_len,
- *                      gboolean *bool
+ *                      gboolean *bool_val
  *                  )
  * DESCRIPTION: Decodes Boolean.
  *              Parameters:
  *              asn1:    pointer to ASN1 socket.
  *              enc_len: length of encoding of value.
- *              bool:    False, True (0, !0).
+ *              bool_val:    False, True (0, !0).
  * RETURNS:     ASN1_ERR value (ASN1_ERR_NOERROR on success)
  */
 int
-asn1_bool_decode ( ASN1_SCK *asn1, int enc_len, gboolean *bool)
+asn1_bool_decode ( ASN1_SCK *asn1, int enc_len, gboolean *bool_val)
 {
     int    ret;
     guchar ch;
@@ -406,7 +406,7 @@
     ret = asn1_octet_decode (asn1, &ch);
     if (ret != ASN1_ERR_NOERROR)
         return ret;
-    *bool = ch ? TRUE : FALSE;
+    *bool_val = ch ? TRUE : FALSE;
     return ASN1_ERR_NOERROR;
 }

Index: asn1.h
===================================================================
RCS file: /cvsroot/ethereal/asn1.h,v
retrieving revision 1.7
diff -u -r1.7 asn1.h
--- asn1.h 2002/03/12 10:37:01 1.7
+++ asn1.h 2002/06/14 15:48:19
@@ -122,7 +122,7 @@
 int asn1_eoc (ASN1_SCK *asn1, int eoc);
 int asn1_eoc_decode (ASN1_SCK *asn1, int eoc);
 int asn1_null_decode (ASN1_SCK *asn1, int enc_len);
-int asn1_bool_decode (ASN1_SCK *asn1, int enc_len, gboolean *bool);
+int asn1_bool_decode (ASN1_SCK *asn1, int enc_len, gboolean *bool_val);
 int asn1_int32_value_decode (ASN1_SCK *asn1, int enc_len, gint32 *integer);
 int asn1_int32_decode (ASN1_SCK *asn1, gint32 *integer, guint *nbytes);
 int asn1_uint32_value_decode (ASN1_SCK *asn1, int enc_len, guint *integer);
Index: gtk/prefs_dlg.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/prefs_dlg.c,v
retrieving revision 1.46
diff -u -r1.46 prefs_dlg.c
--- prefs_dlg.c 2002/04/20 20:29:28 1.46
+++ prefs_dlg.c 2002/06/14 15:48:21
@@ -165,10 +165,10 @@
     break;

   case PREF_BOOL:
-    pref->saved_val.bool = *pref->varp.bool;
+    pref->saved_val.bool_val = *pref->varp.bool_val;
     pref->control = create_preference_check_button(main_tb, pref->ordinal,
             label_string, pref->description,
-            pref->saved_val.bool);
+            pref->saved_val.bool_val);
     break;

   case PREF_ENUM:
@@ -715,9 +715,9 @@

   case PREF_BOOL:
     bval = GTK_TOGGLE_BUTTON(pref->control)->active;
-    if (*pref->varp.bool != bval) {
+    if (*pref->varp.bool_val != bval) {
       *pref_changed_p = TRUE;
-      *pref->varp.bool = bval;
+      *pref->varp.bool_val = bval;
     }
     break;

@@ -949,9 +949,9 @@
     break;

   case PREF_BOOL:
-    if (*pref->varp.bool != pref->saved_val.bool) {
+    if (*pref->varp.bool_val != pref->saved_val.bool_val) {
       *pref_changed_p = TRUE;
-      *pref->varp.bool = pref->saved_val.bool;
+      *pref->varp.bool_val = pref->saved_val.bool_val;
     }
     break;



Regards,

Chris.