Commit 31dc8f98f6ab7d8091d43a76937b0d01adc8de5c

Werner Lemberg 2016-03-29T08:37:07

* src/pfr/pfrtypes.h: Replace all enums with macros. We need `~FOO' to unset bits, and only with unsigned values (which `enum' isn't normally) this works cleanly.

diff --git a/ChangeLog b/ChangeLog
index 33c18b9..68c01f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-03-29  Werner Lemberg  <wl@gnu.org>
+
+	* src/pfr/pfrtypes.h: Replace all enums with macros.
+
+	We need `~FOO' to unset bits, and only with unsigned values (which
+	`enum' isn't normally) this works cleanly.
+
 2016-03-26  Werner Lemberg  <wl@gnu.org>
 
 	[pfr] Robustify bitmap strike handling (#47514).
diff --git a/src/pfr/pfrload.c b/src/pfr/pfrload.c
index ca1f37f..0bee83a 100644
--- a/src/pfr/pfrload.c
+++ b/src/pfr/pfrload.c
@@ -377,7 +377,7 @@
         if ( flags & PFR_LOG_2BYTE_STROKE )
           local++;
 
-        if ( (flags & PFR_LINE_JOIN_MASK) == PFR_LINE_JOIN_MITER )
+        if ( ( flags & PFR_LINE_JOIN_MASK ) == PFR_LINE_JOIN_MITER )
           local += 3;
       }
       if ( flags & PFR_LOG_BOLD )
diff --git a/src/pfr/pfrtypes.h b/src/pfr/pfrtypes.h
index 24ca4d3..bd6c2cd 100644
--- a/src/pfr/pfrtypes.h
+++ b/src/pfr/pfrtypes.h
@@ -69,12 +69,8 @@ FT_BEGIN_HEADER
 
 
   /* used in `color_flags' field of the PFR_Header */
-  typedef enum  PFR_HeaderFlags_
-  {
-    PFR_FLAG_BLACK_PIXEL   = 1,
-    PFR_FLAG_INVERT_BITMAP = 2
-
-  } PFR_HeaderFlags;
+#define PFR_FLAG_BLACK_PIXEL    0x01U
+#define PFR_FLAG_INVERT_BITMAP  0x02U
 
 
   /************************************************************************/
@@ -96,40 +92,27 @@ FT_BEGIN_HEADER
   } PFR_LogFontRec, *PFR_LogFont;
 
 
-  typedef enum  PFR_LogFlags_
-  {
-    PFR_LOG_EXTRA_ITEMS  = 0x40,
-    PFR_LOG_2BYTE_BOLD   = 0x20,
-    PFR_LOG_BOLD         = 0x10,
-    PFR_LOG_2BYTE_STROKE = 8,
-    PFR_LOG_STROKE       = 4,
-    PFR_LINE_JOIN_MASK   = 3
-
-  } PFR_LogFlags;
-
+#define PFR_LINE_JOIN_MITER   0x00U
+#define PFR_LINE_JOIN_ROUND   0x01U
+#define PFR_LINE_JOIN_BEVEL   0x02U
+#define PFR_LINE_JOIN_MASK    ( PFR_LINE_JOIN_ROUND | PFR_LINE_JOIN_BEVEL )
 
-  typedef enum  PFR_LineJoinFlags_
-  {
-    PFR_LINE_JOIN_MITER = 0,
-    PFR_LINE_JOIN_ROUND = 1,
-    PFR_LINE_JOIN_BEVEL = 2
-
-  } PFR_LineJoinFlags;
+#define PFR_LOG_STROKE        0x04U
+#define PFR_LOG_2BYTE_STROKE  0x08U
+#define PFR_LOG_BOLD          0x10U
+#define PFR_LOG_2BYTE_BOLD    0x20U
+#define PFR_LOG_EXTRA_ITEMS   0x40U
 
 
   /************************************************************************/
 
-  typedef enum  PFR_BitmapFlags_
-  {
-    /* not part of the specification but used for implementation */
-    PFR_BITMAP_VALID_CHARCODES     = 0x80,
-    PFR_BITMAP_CHARCODES_VALIDATED = 0x40,
+#define PFR_BITMAP_2BYTE_CHARCODE  0x01U
+#define PFR_BITMAP_2BYTE_SIZE      0x02U
+#define PFR_BITMAP_3BYTE_OFFSET    0x04U
 
-    PFR_BITMAP_3BYTE_OFFSET   = 4,
-    PFR_BITMAP_2BYTE_SIZE     = 2,
-    PFR_BITMAP_2BYTE_CHARCODE = 1
-
-  } PFR_BitmapFlags;
+  /*not part of the specification but used for implementation */
+#define PFR_BITMAP_CHARCODES_VALIDATED  0x40U
+#define PFR_BITMAP_VALID_CHARCODES      0x80U
 
 
   typedef struct  PFR_BitmapCharRec_
@@ -141,15 +124,11 @@ FT_BEGIN_HEADER
   } PFR_BitmapCharRec, *PFR_BitmapChar;
 
 
-  typedef enum  PFR_StrikeFlags_
-  {
-    PFR_STRIKE_2BYTE_COUNT  = 0x10,
-    PFR_STRIKE_3BYTE_OFFSET = 0x08,
-    PFR_STRIKE_3BYTE_SIZE   = 0x04,
-    PFR_STRIKE_2BYTE_YPPM   = 0x02,
-    PFR_STRIKE_2BYTE_XPPM   = 0x01
-
-  } PFR_StrikeFlags;
+#define PFR_STRIKE_2BYTE_XPPM    0x01U
+#define PFR_STRIKE_2BYTE_YPPM    0x02U
+#define PFR_STRIKE_3BYTE_SIZE    0x04U
+#define PFR_STRIKE_3BYTE_OFFSET  0x08U
+#define PFR_STRIKE_2BYTE_COUNT   0x10U
 
 
   typedef struct  PFR_StrikeRec_
@@ -270,41 +249,29 @@ FT_BEGIN_HEADER
   } PFR_PhyFontRec, *PFR_PhyFont;
 
 
-  typedef enum  PFR_PhyFlags_
-  {
-    PFR_PHY_EXTRA_ITEMS      = 0x80,
-    PFR_PHY_3BYTE_GPS_OFFSET = 0x20,
-    PFR_PHY_2BYTE_GPS_SIZE   = 0x10,
-    PFR_PHY_ASCII_CODE       = 0x08,
-    PFR_PHY_PROPORTIONAL     = 0x04,
-    PFR_PHY_2BYTE_CHARCODE   = 0x02,
-    PFR_PHY_VERTICAL         = 0x01
-
-  } PFR_PhyFlags;
+#define PFR_PHY_VERTICAL          0x01U
+#define PFR_PHY_2BYTE_CHARCODE    0x02U
+#define PFR_PHY_PROPORTIONAL      0x04U
+#define PFR_PHY_ASCII_CODE        0x08U
+#define PFR_PHY_2BYTE_GPS_SIZE    0x10U
+#define PFR_PHY_3BYTE_GPS_OFFSET  0x20U
+#define PFR_PHY_EXTRA_ITEMS       0x80U
 
 
-  typedef enum PFR_KernFlags_
-  {
-    PFR_KERN_2BYTE_CHAR  = 0x01,
-    PFR_KERN_2BYTE_ADJ   = 0x02
-
-  } PFR_KernFlags;
+#define PFR_KERN_2BYTE_CHAR  0x01U
+#define PFR_KERN_2BYTE_ADJ   0x02U
 
 
   /************************************************************************/
 
-  typedef enum  PFR_GlyphFlags_
-  {
-    PFR_GLYPH_IS_COMPOUND = 0x80,
-
-    PFR_GLYPH_SINGLE_EXTRA_ITEMS   = 0x08,
-    PFR_GLYPH_COMPOUND_EXTRA_ITEMS = 0x40,
+#define PFR_GLYPH_YCOUNT         0x01U
+#define PFR_GLYPH_XCOUNT         0x02U
+#define PFR_GLYPH_1BYTE_XYCOUNT  0x04U
 
-    PFR_GLYPH_1BYTE_XYCOUNT = 0x04,
-    PFR_GLYPH_XCOUNT        = 0x02,
-    PFR_GLYPH_YCOUNT        = 0x01
+#define PFR_GLYPH_SINGLE_EXTRA_ITEMS    0x08U
+#define PFR_GLYPH_COMPOUND_EXTRA_ITEMS  0x40U
 
-  } PFR_GlyphFlags;
+#define PFR_GLYPH_IS_COMPOUND  0x80U
 
 
   /* controlled coordinate */
@@ -328,14 +295,10 @@ FT_BEGIN_HEADER
   } PFR_SubGlyphRec, *PFR_SubGlyph;
 
 
-  typedef enum  PFR_SubgGlyphFlags_
-  {
-    PFR_SUBGLYPH_3BYTE_OFFSET = 0x80,
-    PFR_SUBGLYPH_2BYTE_SIZE   = 0x40,
-    PFR_SUBGLYPH_YSCALE       = 0x20,
-    PFR_SUBGLYPH_XSCALE       = 0x10
-
-  } PFR_SubGlyphFlags;
+#define PFR_SUBGLYPH_XSCALE        0x10U
+#define PFR_SUBGLYPH_YSCALE        0x20U
+#define PFR_SUBGLYPH_2BYTE_SIZE    0x40U
+#define PFR_SUBGLYPH_3BYTE_OFFSET  0x80U
 
 
   typedef struct  PFR_GlyphRec_