ソースを参照

Use DPKG_BIT to define bit flags instead of literal octal values

If we are defining bit flags, it's more natural to just name the bits
by their index instead of using octal values.

Use the opportunity to assign bit indices in increasing order, as some
flags had been inserted in alphabetical/group order but keeping the
other flag's values.
Guillem Jover 14 年 前
コミット
49c76f6186
共有10 個のファイルを変更した62 個の追加57 個の削除を含む
  1. 1 1
      lib/dpkg/atomic-file.h
  2. 4 0
      lib/dpkg/debug.h
  3. 21 20
      lib/dpkg/dpkg-db.h
  4. 3 3
      lib/dpkg/ehandle.h
  5. 1 1
      lib/dpkg/parsedump.h
  6. 4 4
      lib/dpkg/pkg-spec.h
  7. 5 5
      lib/dpkg/trigdeferred.h
  8. 3 3
      lib/dpkg/version.h
  9. 8 8
      src/configure.c
  10. 12 12
      src/filesdb.h

+ 1 - 1
lib/dpkg/atomic-file.h

@@ -34,7 +34,7 @@ DPKG_BEGIN_DECLS
  */
 
 enum atomic_file_flags {
-	aff_backup = 01,
+	aff_backup		= DPKG_BIT(0),
 };
 
 struct atomic_file {

+ 4 - 0
lib/dpkg/debug.h

@@ -34,6 +34,10 @@ DPKG_BEGIN_DECLS
  * @{
  */
 
+/*
+ * XXX: We do not use DPKG_BIT() here, because the octal values are part
+ * of the current output interface.
+ */
 enum debugflags {
 	dbg_general = 01,
 	dbg_scripts = 02,

+ 21 - 20
lib/dpkg/dpkg-db.h

@@ -233,11 +233,10 @@ enum modstatdb_rw {
   msdbrw_writeifposs,
   msdbrw_write/*s*/, msdbrw_needsuperuser,
 
-  /* Now some optional flags: */
-  msdbrw_available_mask= ~077,
-  /* Flags start at 0100. */
-  msdbrw_available_readonly = 0100,
-  msdbrw_available_write = 0200,
+  /* Now some optional flags (starting at bit 8): */
+  msdbrw_available_readonly	= DPKG_BIT(8),
+  msdbrw_available_write	= DPKG_BIT(9),
+  msdbrw_available_mask		= 0xff00,
 };
 
 void modstatdb_init(void);
@@ -281,29 +280,31 @@ void pkg_db_report(FILE *);
 /*** from parse.c ***/
 
 enum parsedbflags {
+  /** Parse the control file from a binary .deb package. */
+  pdb_deb_control		= DPKG_BIT(0),
   /** Store in ‘available’ in-core structures, not ‘status’. */
-  pdb_recordavailable = 001,
+  pdb_recordavailable		= DPKG_BIT(1),
   /** Throw up an error if ‘Status’ encountered. */
-  pdb_rejectstatus = 002,
+  pdb_rejectstatus		= DPKG_BIT(2),
   /** Ignore priority/section info if we already have any. */
-  pdb_weakclassification = 004,
+  pdb_weakclassification	= DPKG_BIT(3),
   /** Ignore files info if we already have them. */
-  pdb_ignorefiles = 010,
+  pdb_ignorefiles		= DPKG_BIT(4),
   /** Ignore packages with older versions already read. */
-  pdb_ignoreolder = 020,
+  pdb_ignoreolder		= DPKG_BIT(5),
   /** Perform laxer version parsing. */
-  pdb_lax_version_parser = 040,
+  pdb_lax_version_parser	= DPKG_BIT(6),
   /** Perform laxer parsing, used to transition to stricter parsing. */
-  pdb_lax_parser = pdb_lax_version_parser,
-  /** Parse the control file from a binary .deb package. */
-  pdb_deb_control = 0100,
+  pdb_lax_parser		= pdb_lax_version_parser,
 
   /* Standard operations. */
 
-  pdb_parse_status = pdb_lax_parser | pdb_weakclassification,
-  pdb_parse_update = pdb_parse_status | pdb_deb_control,
-  pdb_parse_available = pdb_recordavailable | pdb_rejectstatus | pdb_lax_parser,
-  pdb_parse_binary = pdb_recordavailable | pdb_rejectstatus | pdb_deb_control,
+  pdb_parse_status		= pdb_lax_parser | pdb_weakclassification,
+  pdb_parse_update		= pdb_parse_status | pdb_deb_control,
+  pdb_parse_available		= pdb_recordavailable | pdb_rejectstatus |
+				  pdb_lax_parser,
+  pdb_parse_binary		= pdb_recordavailable | pdb_rejectstatus |
+				  pdb_deb_control,
 };
 
 const char *pkg_name_is_illegal(const char *p);
@@ -359,9 +360,9 @@ void writerecord(FILE*, const char*,
 
 enum writedb_flags {
   /** Dump ‘available’ in-core structures, not ‘status’. */
-  wdb_dump_available = 001,
+  wdb_dump_available		= DPKG_BIT(0),
   /** Must sync the written file. */
-  wdb_must_sync = 002,
+  wdb_must_sync			= DPKG_BIT(1),
 };
 
 void writedb(const char *filename, enum writedb_flags flags);

+ 3 - 3
lib/dpkg/ehandle.h

@@ -39,9 +39,9 @@ DPKG_BEGIN_DECLS
 extern volatile int onerr_abort;
 
 enum {
-	ehflag_normaltidy = 01,
-	ehflag_bombout = 02,
-	ehflag_recursiveerror = 04
+	ehflag_normaltidy	= DPKG_BIT(0),
+	ehflag_bombout		= DPKG_BIT(1),
+	ehflag_recursiveerror	= DPKG_BIT(2),
 };
 
 typedef void error_handler(void);

+ 1 - 1
lib/dpkg/parsedump.h

@@ -94,7 +94,7 @@ freadfunction f_trigpend, f_trigaw;
 
 enum fwriteflags {
 	/** Print field header and trailing newline. */
-	fw_printheader = 001,
+	fw_printheader		= DPKG_BIT(0),
 };
 
 typedef void fwritefunction(struct varbuf*,

+ 4 - 4
lib/dpkg/pkg-spec.h

@@ -44,12 +44,12 @@ struct pkg_spec {
 
 	enum pkg_spec_flags {
 		/** Recognize glob patterns. */
-		psf_patterns = 00001,
+		psf_patterns		= DPKG_BIT(0),
 
 		/* How to consider the lack of an arch qualifier. */
-		psf_arch_def_single = 00100,
-		psf_arch_def_wildcard = 00200,
-		psf_arch_def_mask = 00300,
+		psf_arch_def_single	= DPKG_BIT(8),
+		psf_arch_def_wildcard	= DPKG_BIT(9),
+		psf_arch_def_mask	= 0xff00,
 	} flags;
 
 	/* Members below are private state. */

+ 5 - 5
lib/dpkg/trigdeferred.h

@@ -33,12 +33,12 @@ DPKG_BEGIN_DECLS
  */
 
 enum trigdef_updateflags {
-	tduf_nolockok =           001,
-	tduf_write =              002,
-	tduf_nolock =             003,
+	tduf_nolockok		= DPKG_BIT(0),
+	tduf_write		= DPKG_BIT(1),
+	tduf_nolock		= tduf_nolockok | tduf_write,
 	/** Should not be set unless _write is. */
-	tduf_writeifempty =       010,
-	tduf_writeifenoent =      020,
+	tduf_writeifempty	= DPKG_BIT(3),
+	tduf_writeifenoent	= DPKG_BIT(4),
 };
 
 enum trigdef_update_status {

+ 3 - 3
lib/dpkg/version.h

@@ -41,10 +41,10 @@ struct dpkg_version {
 
 enum dpkg_relation {
 	dpkg_relation_none	= 0,
-	dpkg_relation_eq	= 001,
-	dpkg_relation_lt	= 002,
+	dpkg_relation_eq	= DPKG_BIT(0),
+	dpkg_relation_lt	= DPKG_BIT(1),
 	dpkg_relation_le	= dpkg_relation_lt | dpkg_relation_eq,
-	dpkg_relation_gt	= 004,
+	dpkg_relation_gt	= DPKG_BIT(2),
 	dpkg_relation_ge	= dpkg_relation_gt | dpkg_relation_eq,
 };
 

+ 8 - 8
src/configure.c

@@ -58,14 +58,14 @@
 #include "main.h"
 
 enum conffopt {
-	cfof_prompt		= 00001,
-	cfof_keep		= 00002,
-	cfof_install		= 00004,
-	cfof_backup		= 00100,
-	cfof_newconff		= 00200,
-	cfof_isnew		= 00400,
-	cfof_isold		= 01000,
-	cfof_userrmd		= 02000,
+	cfof_prompt		= DPKG_BIT(0),
+	cfof_keep		= DPKG_BIT(1),
+	cfof_install		= DPKG_BIT(2),
+	cfof_backup		= DPKG_BIT(3),
+	cfof_newconff		= DPKG_BIT(4),
+	cfof_isnew		= DPKG_BIT(5),
+	cfof_isold		= DPKG_BIT(6),
+	cfof_userrmd		= DPKG_BIT(7),
 
 	cfo_keep		= cfof_keep,
 	cfo_identical		= cfof_keep,

+ 12 - 12
src/filesdb.h

@@ -51,9 +51,9 @@ struct pkginfo;
  */
 enum fnnflags {
     /** Do not need to copy filename. */
-    fnn_nocopy = 000001,
+    fnn_nocopy			= DPKG_BIT(0),
     /** findnamenode may return NULL. */
-    fnn_nonew = 000002,
+    fnn_nonew			= DPKG_BIT(1),
 };
 
 struct filenamenode {
@@ -77,23 +77,23 @@ struct filenamenode {
   /** Set to zero when a new node is created. */
   enum {
     /** In the newconffiles list. */
-    fnnf_new_conff = 000001,
+    fnnf_new_conff		= DPKG_BIT(0),
     /** In the new filesystem archive. */
-    fnnf_new_inarchive = 000002,
+    fnnf_new_inarchive		= DPKG_BIT(1),
     /** In the old package's conffiles list. */
-    fnnf_old_conff = 000004,
+    fnnf_old_conff		= DPKG_BIT(2),
     /** Obsolete conffile. */
-    fnnf_obs_conff = 000100,
+    fnnf_obs_conff		= DPKG_BIT(3),
     /** Must remove from other packages' lists. */
-    fnnf_elide_other_lists = 000010,
+    fnnf_elide_other_lists	= DPKG_BIT(4),
     /** >= 1 instance is a dir, cannot rename over. */
-    fnnf_no_atomic_overwrite = 000020,
+    fnnf_no_atomic_overwrite	= DPKG_BIT(5),
     /** New file has been placed on the disk. */
-    fnnf_placed_on_disk = 000040,
-    fnnf_deferred_fsync = 000200,
-    fnnf_deferred_rename = 000400,
+    fnnf_placed_on_disk		= DPKG_BIT(6),
+    fnnf_deferred_fsync		= DPKG_BIT(7),
+    fnnf_deferred_rename	= DPKG_BIT(8),
     /** Path being filtered. */
-    fnnf_filtered = 001000,
+    fnnf_filtered		= DPKG_BIT(9),
   } flags;
 
   /** Valid iff this namenode is in the newconffiles list. */