Преглед изворни кода

libdpkg: Uppercase compressor enum values

Guillem Jover пре 12 година
родитељ
комит
eb3c2635f9
6 измењених фајлова са 64 додато и 64 уклоњено
  1. 3 3
      dpkg-deb/build.c
  2. 6 6
      dpkg-deb/extract.c
  3. 9 9
      dpkg-deb/main.c
  4. 31 31
      lib/dpkg/compress.c
  5. 14 14
      lib/dpkg/compress.h
  6. 1 1
      m4/dpkg-build.m4

+ 3 - 3
dpkg-deb/build.c

@@ -4,7 +4,7 @@
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2000,2001 Wichert Akkerman <wakkerma@debian.org>
- * Copyright © 2007-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2007-2014 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -521,8 +521,8 @@ do_build(const char *const *argv)
   if (opt_uniform_compression) {
     control_compress_params = compress_params;
   } else {
-    control_compress_params.type = compressor_type_gzip;
-    control_compress_params.strategy = compressor_strategy_none;
+    control_compress_params.type = COMPRESSOR_TYPE_GZIP;
+    control_compress_params.strategy = COMPRESSOR_STRATEGY_NONE;
     control_compress_params.level = -1;
   }
 

+ 6 - 6
dpkg-deb/extract.c

@@ -3,7 +3,7 @@
  * extract.c - extracting archives
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-2014 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -122,7 +122,7 @@ extracthalf(const char *debar, const char *dir,
   char nlc;
   int adminmember = -1;
   bool header_done;
-  enum compressor_type decompressor = compressor_type_gzip;
+  enum compressor_type decompressor = COMPRESSOR_TYPE_GZIP;
 
   arfd = open(debar, O_RDONLY);
   if (arfd < 0)
@@ -183,9 +183,9 @@ extracthalf(const char *debar, const char *dir,
 
 	  adminmember = 1;
           decompressor = compressor_find_by_extension(extension);
-          if (decompressor != compressor_type_none &&
-              decompressor != compressor_type_gzip &&
-              decompressor != compressor_type_xz)
+          if (decompressor != COMPRESSOR_TYPE_NONE &&
+              decompressor != COMPRESSOR_TYPE_GZIP &&
+              decompressor != COMPRESSOR_TYPE_XZ)
             ohshit(_("archive '%s' uses unknown compression for member '%.*s', "
                      "giving up"),
                    debar, (int)sizeof(arh.ar_name), arh.ar_name);
@@ -200,7 +200,7 @@ extracthalf(const char *debar, const char *dir,
 
 	    adminmember= 0;
 	    decompressor = compressor_find_by_extension(extension);
-            if (decompressor == compressor_type_unknown)
+            if (decompressor == COMPRESSOR_TYPE_UNKNOWN)
               ohshit(_("archive '%s' uses unknown compression for member '%.*s', "
                        "giving up"),
                      debar, (int)sizeof(arh.ar_name), arh.ar_name);

+ 9 - 9
dpkg-deb/main.c

@@ -3,7 +3,7 @@
  * main.c - main program
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-2014 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -183,7 +183,7 @@ set_deb_new(const struct cmdinfo *cip, const char *value)
 
 struct compress_params compress_params = {
   .type = DPKG_DEB_DEFAULT_COMPRESSOR,
-  .strategy = compressor_strategy_none,
+  .strategy = COMPRESSOR_STRATEGY_NONE,
   .level = -1,
 };
 
@@ -203,7 +203,7 @@ static void
 set_compress_strategy(const struct cmdinfo *cip, const char *value)
 {
   compress_params.strategy = compressor_get_strategy(value);
-  if (compress_params.strategy == compressor_strategy_unknown)
+  if (compress_params.strategy == COMPRESSOR_STRATEGY_UNKNOWN)
     ohshit(_("unknown compression strategy '%s'!"), value);
 }
 
@@ -211,11 +211,11 @@ static void
 set_compress_type(const struct cmdinfo *cip, const char *value)
 {
   compress_params.type = compressor_find_by_name(value);
-  if (compress_params.type == compressor_type_unknown)
+  if (compress_params.type == COMPRESSOR_TYPE_UNKNOWN)
     ohshit(_("unknown compression type `%s'!"), value);
-  if (compress_params.type == compressor_type_lzma)
+  if (compress_params.type == COMPRESSOR_TYPE_LZMA)
     warning(_("deprecated compression type '%s'; use xz instead"), value);
-  if (compress_params.type == compressor_type_bzip2)
+  if (compress_params.type == COMPRESSOR_TYPE_BZIP2)
     warning(_("deprecated compression type '%s'; use xz or gzip instead"), value);
 }
 
@@ -261,9 +261,9 @@ int main(int argc, const char *const *argv) {
     badusage(_("invalid compressor parameters: %s"), err.str);
 
   if (opt_uniform_compression &&
-      (compress_params.type != compressor_type_none &&
-       compress_params.type != compressor_type_gzip &&
-       compress_params.type != compressor_type_xz))
+      (compress_params.type != COMPRESSOR_TYPE_NONE &&
+       compress_params.type != COMPRESSOR_TYPE_GZIP &&
+       compress_params.type != COMPRESSOR_TYPE_XZ))
     badusage(_("unsupported compression type '%s' with uniform compression"),
              compressor_get_name(compress_params.type));
 

+ 31 - 31
lib/dpkg/compress.c

@@ -4,7 +4,7 @@
  *
  * Copyright © 2000 Wichert Akkerman <wakkerma@debian.org>
  * Copyright © 2004 Scott James Remnant <scott@netsplit.com>
- * Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-2014 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -142,7 +142,7 @@ fixup_gzip_params(struct compress_params *params)
 {
 	/* Normalize compression level. */
 	if (params->level == 0)
-		params->type = compressor_type_none;
+		params->type = COMPRESSOR_TYPE_NONE;
 }
 
 #ifdef WITH_ZLIB
@@ -189,13 +189,13 @@ compress_gzip(int fd_in, int fd_out, struct compress_params *params, const char
 	int z_errnum;
 	gzFile gzfile;
 
-	if (params->strategy == compressor_strategy_filtered)
+	if (params->strategy == COMPRESSOR_STRATEGY_FILTERED)
 		strategy = 'f';
-	else if (params->strategy == compressor_strategy_huffman)
+	else if (params->strategy == COMPRESSOR_STRATEGY_HUFFMAN)
 		strategy = 'h';
-	else if (params->strategy == compressor_strategy_rle)
+	else if (params->strategy == COMPRESSOR_STRATEGY_RLE)
 		strategy = 'R';
-	else if (params->strategy == compressor_strategy_fixed)
+	else if (params->strategy == COMPRESSOR_STRATEGY_FIXED)
 		strategy = 'F';
 	else
 		strategy = ' ';
@@ -532,7 +532,7 @@ filter_xz_init(struct io_lzma *io, lzma_stream *s)
 	io->status |= DPKG_STREAM_COMPRESS;
 
 	preset = io->params->level;
-	if (io->params->strategy == compressor_strategy_extreme)
+	if (io->params->strategy == COMPRESSOR_STRATEGY_EXTREME)
 		preset |= LZMA_PRESET_EXTREME;
 	ret = lzma_easy_encoder(s, preset, LZMA_CHECK_CRC32);
 	if (ret != LZMA_OK)
@@ -598,7 +598,7 @@ compress_xz(int fd_in, int fd_out, struct compress_params *params, const char *d
 	char combuf[6];
 	const char *strategy;
 
-	if (params->strategy == compressor_strategy_extreme)
+	if (params->strategy == COMPRESSOR_STRATEGY_EXTREME)
 		strategy = "-e";
 	else
 		strategy = NULL;
@@ -645,7 +645,7 @@ filter_lzma_init(struct io_lzma *io, lzma_stream *s)
 	io->status |= DPKG_STREAM_COMPRESS;
 
 	preset = io->params->level;
-	if (io->params->strategy == compressor_strategy_extreme)
+	if (io->params->strategy == COMPRESSOR_STRATEGY_EXTREME)
 		preset |= LZMA_PRESET_EXTREME;
 	if (lzma_lzma_preset(&options, preset))
 		filter_lzma_error(io, LZMA_OPTIONS_ERROR);
@@ -712,11 +712,11 @@ static const struct compressor compressor_lzma = {
  */
 
 static const struct compressor *compressor_array[] = {
-	[compressor_type_none] = &compressor_none,
-	[compressor_type_gzip] = &compressor_gzip,
-	[compressor_type_xz] = &compressor_xz,
-	[compressor_type_bzip2] = &compressor_bzip2,
-	[compressor_type_lzma] = &compressor_lzma,
+	[COMPRESSOR_TYPE_NONE] = &compressor_none,
+	[COMPRESSOR_TYPE_GZIP] = &compressor_gzip,
+	[COMPRESSOR_TYPE_XZ] = &compressor_xz,
+	[COMPRESSOR_TYPE_BZIP2] = &compressor_bzip2,
+	[COMPRESSOR_TYPE_LZMA] = &compressor_lzma,
 };
 
 static const struct compressor *
@@ -751,7 +751,7 @@ compressor_find_by_name(const char *name)
 		if (strcmp(compressor_array[i]->name, name) == 0)
 			return i;
 
-	return compressor_type_unknown;
+	return COMPRESSOR_TYPE_UNKNOWN;
 }
 
 enum compressor_type
@@ -763,26 +763,26 @@ compressor_find_by_extension(const char *extension)
 		if (strcmp(compressor_array[i]->extension, extension) == 0)
 			return i;
 
-	return compressor_type_unknown;
+	return COMPRESSOR_TYPE_UNKNOWN;
 }
 
 enum compressor_strategy
 compressor_get_strategy(const char *name)
 {
 	if (strcmp(name, "none") == 0)
-		return compressor_strategy_none;
+		return COMPRESSOR_STRATEGY_NONE;
 	if (strcmp(name, "filtered") == 0)
-		return compressor_strategy_filtered;
+		return COMPRESSOR_STRATEGY_FILTERED;
 	if (strcmp(name, "huffman") == 0)
-		return compressor_strategy_huffman;
+		return COMPRESSOR_STRATEGY_HUFFMAN;
 	if (strcmp(name, "rle") == 0)
-		return compressor_strategy_rle;
+		return COMPRESSOR_STRATEGY_RLE;
 	if (strcmp(name, "fixed") == 0)
-		return compressor_strategy_fixed;
+		return COMPRESSOR_STRATEGY_FIXED;
 	if (strcmp(name, "extreme") == 0)
-		return compressor_strategy_extreme;
+		return COMPRESSOR_STRATEGY_EXTREME;
 
-	return compressor_strategy_unknown;
+	return COMPRESSOR_STRATEGY_UNKNOWN;
 }
 
 static void
@@ -799,18 +799,18 @@ compressor_check_params(struct compress_params *params, struct dpkg_error *err)
 {
 	compressor_fixup_params(params);
 
-	if (params->strategy == compressor_strategy_none)
+	if (params->strategy == COMPRESSOR_STRATEGY_NONE)
 		return true;
 
-	if (params->type == compressor_type_gzip &&
-	    (params->strategy == compressor_strategy_filtered ||
-	     params->strategy == compressor_strategy_huffman ||
-	     params->strategy == compressor_strategy_rle ||
-	     params->strategy == compressor_strategy_fixed))
+	if (params->type == COMPRESSOR_TYPE_GZIP &&
+	    (params->strategy == COMPRESSOR_STRATEGY_FILTERED ||
+	     params->strategy == COMPRESSOR_STRATEGY_HUFFMAN ||
+	     params->strategy == COMPRESSOR_STRATEGY_RLE ||
+	     params->strategy == COMPRESSOR_STRATEGY_FIXED))
 		return true;
 
-	if (params->type == compressor_type_xz &&
-	    params->strategy == compressor_strategy_extreme)
+	if (params->type == COMPRESSOR_TYPE_XZ &&
+	    params->strategy == COMPRESSOR_STRATEGY_EXTREME)
 		return true;
 
 	dpkg_put_error(err, _("unknown compression strategy"));

+ 14 - 14
lib/dpkg/compress.h

@@ -3,7 +3,7 @@
  * compress.h - compression support functions
  *
  * Copyright © 2004 Scott James Remnant <scott@netsplit.com>
- * Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-2014 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,22 +36,22 @@ DPKG_BEGIN_DECLS
  */
 
 enum compressor_type {
-	compressor_type_unknown = -1,
-	compressor_type_none,
-	compressor_type_gzip,
-	compressor_type_xz,
-	compressor_type_bzip2,
-	compressor_type_lzma,
+	COMPRESSOR_TYPE_UNKNOWN = -1,
+	COMPRESSOR_TYPE_NONE,
+	COMPRESSOR_TYPE_GZIP,
+	COMPRESSOR_TYPE_XZ,
+	COMPRESSOR_TYPE_BZIP2,
+	COMPRESSOR_TYPE_LZMA,
 };
 
 enum compressor_strategy {
-	compressor_strategy_unknown = -1,
-	compressor_strategy_none,
-	compressor_strategy_filtered,
-	compressor_strategy_huffman,
-	compressor_strategy_rle,
-	compressor_strategy_fixed,
-	compressor_strategy_extreme,
+	COMPRESSOR_STRATEGY_UNKNOWN = -1,
+	COMPRESSOR_STRATEGY_NONE,
+	COMPRESSOR_STRATEGY_FILTERED,
+	COMPRESSOR_STRATEGY_HUFFMAN,
+	COMPRESSOR_STRATEGY_RLE,
+	COMPRESSOR_STRATEGY_FIXED,
+	COMPRESSOR_STRATEGY_EXTREME,
 };
 
 struct compress_params {

+ 1 - 1
m4/dpkg-build.m4

@@ -56,7 +56,7 @@ AC_DEFUN([DPKG_DEB_COMPRESSOR], [
     [gzip|xz|bzip2], [:],
     [AC_MSG_ERROR([unsupported default compressor $with_dpkg_deb_compressor])])
   AC_DEFINE_UNQUOTED([DPKG_DEB_DEFAULT_COMPRESSOR],
-                     [compressor_type_${with_dpkg_deb_compressor}],
+                     [COMPRESSOR_TYPE_]AS_TR_CPP(${with_dpkg_deb_compressor}),
                      [default dpkg-deb build compressor])
   AC_MSG_NOTICE([using default dpkg-deb compressor = $with_dpkg_deb_compressor])
 ]) # DPKG_DEB_COMPRESSOR