Make flags be macros rather than enumerations, to ensure that they're
[u/mdw/catacomb] / hashsum.c
index 051fdb1..5776d93 100644 (file)
--- a/hashsum.c
+++ b/hashsum.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: hashsum.c,v 1.3 2000/07/29 17:02:43 mdw Exp $
+ * $Id: hashsum.c,v 1.5 2000/12/06 20:33:27 mdw Exp $
  *
  * Hash files using some secure hash function
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: hashsum.c,v $
+ * Revision 1.5  2000/12/06 20:33:27  mdw
+ * Make flags be macros rather than enumerations, to ensure that they're
+ * unsigned.
+ *
+ * Revision 1.4  2000/08/04 23:23:44  mdw
+ * Various <ctype.h> fixes.
+ *
  * Revision 1.3  2000/07/29 17:02:43  mdw
  * (checkhash): Be pettier about spaces between the hash and filename, for
  * compatiblity with `md5sum'.
@@ -79,16 +86,14 @@ static const gchash *hashtab[] = {
   0
 };
 
-enum {
-  f_binary = 1,
-  f_bogus = 2,
-  f_verbose = 4,
-  f_check = 8,
-  f_files = 16,
-  f_raw = 32,
-  f_oddhash = 64,
-  f_escape = 128
-};
+#define f_binary 1u
+#define f_bogus 2u
+#define f_verbose 4u
+#define f_check 8u
+#define f_files 16u
+#define f_raw 32u
+#define f_oddhash 64u
+#define f_escape 128u
 
 /*----- Support functions -------------------------------------------------*/
 
@@ -225,7 +230,7 @@ static int getstring(FILE *fp, const char *p, dstr *d, unsigned raw)
 
   /* --- Raw: just read exactly what's written up to a null byte --- */
 
-#define NEXTCH (fp ? getc(fp) : *p++)
+#define NEXTCH (fp ? getc(fp) : (unsigned char)*p++)
 #define EOFCH (fp ? EOF : 0)
 
   if (raw) {
@@ -249,7 +254,7 @@ static int getstring(FILE *fp, const char *p, dstr *d, unsigned raw)
 
 again:
   ch = NEXTCH;
-  while (isspace((unsigned char)ch))
+  while (isspace(ch))
     ch = NEXTCH;
   if (ch == '#') {
     do ch = NEXTCH; while (ch != '\n' && ch != EOFCH);
@@ -298,7 +303,7 @@ again:
 
     if (ch == q)
       break;
-    if (!q && isspace((unsigned char)ch))
+    if (!q && isspace(ch))
       break;
 
     /* --- Otherwise contribute and continue --- */