chiark / gitweb /
Define flags with macros, to ensure unsignedness.
authormdw <mdw>
Sat, 20 Jan 2001 12:06:01 +0000 (12:06 +0000)
committermdw <mdw>
Sat, 20 Jan 2001 12:06:01 +0000 (12:06 +0000)
crc-mktab.c
dputf.c
lbuf.h
pkbuf.h
url.h

index def53613df0b431b691bf9a45d0e1408e2de8586..a3ba4301486b7a835a847316cb18cdae0c24d8b4 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: crc-mktab.c,v 1.2 2000/10/08 11:07:21 mdw Exp $
+ * $Id: crc-mktab.c,v 1.3 2001/01/20 12:06:01 mdw Exp $
  *
  * Build CRC tables
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: crc-mktab.c,v $
+ * Revision 1.3  2001/01/20 12:06:01  mdw
+ * Define flags with macros, to ensure unsignedness.
+ *
  * Revision 1.2  2000/10/08 11:07:21  mdw
  * With no arguments, give an error rather than spewing a big table at the
  * user.
@@ -66,11 +69,9 @@ static const char *type = 0;
 static const char *inc = 0;
 static FILE *fp;
 
-enum {
-  f_bogus = 1,
-  f_ctab = 2,
-  f_reverse = 4
-};
+#define f_bogus 1u
+#define f_ctab 2u
+#define f_reverse 4u
 
 #define BSCOL 72
 
diff --git a/dputf.c b/dputf.c
index d78851ffbd10ab1e072c3f9013d5884cdf69fc4e..5df210c055f67c35b8e821a9075c28009956ecc3 100644 (file)
--- a/dputf.c
+++ b/dputf.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: dputf.c,v 1.2 2000/08/15 21:26:45 mdw Exp $
+ * $Id: dputf.c,v 1.3 2001/01/20 12:06:01 mdw Exp $
  *
  * `printf'-style formatting for dynamic strings
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: dputf.c,v $
+ * Revision 1.3  2001/01/20 12:06:01  mdw
+ * Define flags with macros, to ensure unsignedness.
+ *
  * Revision 1.2  2000/08/15 21:26:45  mdw
  * (dstr_vputf): Don't try calling @va_arg@ on things @char@-sized.
  *
@@ -84,13 +87,11 @@ int dstr_vputf(dstr *d, const char *p, va_list ap)
     unsigned f;
     int wd, prec;
 
-    enum {
-      f_short = 1,
-      f_long = 2,
-      f_Long = 4,
-      f_wd = 8,
-      f_prec = 16
-    };
+#define f_short 1u
+#define f_long 2u
+#define f_Long 4u
+#define f_wd 8u
+#define f_prec 16u
 
     /* --- Most stuff gets passed on through --- */
 
@@ -198,9 +199,9 @@ int dstr_vputf(dstr *d, const char *p, va_list ap)
            if (mx > sz)
              sz = mx;
          }
-         if ((f & f_prec) == 0)
+         if (!(f & f_prec))
            prec = 6;
-         if ((f & f_prec))
+         else
            sz += prec + 16;        
          if ((f & f_wd) && wd + 1 > sz)
            sz = wd + 1;
@@ -270,6 +271,12 @@ int dstr_vputf(dstr *d, const char *p, va_list ap)
   formatted:
     DRESET(&dd);
     q = ++p;
+
+#undef f_short
+#undef f_long
+#undef f_Long
+#undef f_wd
+#undef f_prec
   }
 
   DPUTM(d, q, p - q);
diff --git a/lbuf.h b/lbuf.h
index 3f25dacefd6c9da869ed1dc1854a5c9c32706bc2..9f290b808538d05610cd5f70175b7cd12de9a5cf 100644 (file)
--- a/lbuf.h
+++ b/lbuf.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: lbuf.h,v 1.4 2000/06/17 10:38:14 mdw Exp $
+ * $Id: lbuf.h,v 1.5 2001/01/20 12:06:01 mdw Exp $
  *
  * Block-to-line buffering
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: lbuf.h,v $
+ * Revision 1.5  2001/01/20 12:06:01  mdw
+ * Define flags with macros, to ensure unsignedness.
+ *
  * Revision 1.4  2000/06/17 10:38:14  mdw
  * Add support for variable buffer sizes.
  *
@@ -119,10 +122,8 @@ typedef struct lbuf {
   char *buf;                           /* The actual buffer */
 } lbuf;
 
-enum {
-  LBUF_CR = 1,                         /* Read a carriage return */
-  LBUF_ENABLE = 2                      /* Buffer is currently enabled */
-};
+#define LBUF_CR 1u                     /* Read a carriage return */
+#define LBUF_ENABLE 2u                 /* Buffer is currently enabled */
 
 /*----- Functions provided ------------------------------------------------*/
 
diff --git a/pkbuf.h b/pkbuf.h
index e6bbec362826f9827f498b8e78643ddf6dfa0623..d98d826555a72e1e5abc93d30e491ba72f7b299b 100644 (file)
--- a/pkbuf.h
+++ b/pkbuf.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: pkbuf.h,v 1.1 2000/06/17 10:39:19 mdw Exp $
+ * $Id: pkbuf.h,v 1.2 2001/01/20 12:06:01 mdw Exp $
  *
  * Simple packet buffering
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: pkbuf.h,v $
+ * Revision 1.2  2001/01/20 12:06:01  mdw
+ * Define flags with macros, to ensure unsignedness.
+ *
  * Revision 1.1  2000/06/17 10:39:19  mdw
  * Experimental new support for packet buffering.
  *
@@ -69,9 +72,7 @@ typedef struct pkbuf {
   octet *buf;                          /* Actual buffer space */
 } pkbuf;
 
-enum {
-  PKBUF_ENABLE = 1                     /* Buffer is currently enabled */
-};
+#define PKBUF_ENABLE 1u                        /* Buffer is currently enabled */
 
 /*----- Functions provided ------------------------------------------------*/
 
diff --git a/url.h b/url.h
index 55e443dacb11b3513a2ac60d695d83ce6b7d2818..90b649a745ecaf15c875dcb9594a98aa416b70f9 100644 (file)
--- a/url.h
+++ b/url.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: url.h,v 1.2 1999/12/10 23:42:04 mdw Exp $
+ * $Id: url.h,v 1.3 2001/01/20 12:06:01 mdw Exp $
  *
  * Parsing and construction of url-encoded name/value pairs
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: url.h,v $
+ * Revision 1.3  2001/01/20 12:06:01  mdw
+ * Define flags with macros, to ensure unsignedness.
+ *
  * Revision 1.2  1999/12/10 23:42:04  mdw
  * Change header file guard names.
  *
@@ -57,9 +60,7 @@ typedef struct url_ectx {
   unsigned f;
 } url_ectx;
 
-enum {
-  URLF_SEP = 1
-};
+#define URLF_SEP 1u
 
 typedef struct url_dctx {
   const char *p;