Compression/showpref fix

David Shaw dshaw at jabberwocky.com
Fri Nov 16 05:43:01 CET 2001


I found a minor bug in "pref" (edit menu) in 1.0.6c, which makes the
compression algorithms not list properly.

Fix is attached, along with a minor enhancement to "showpref" to show
the compression algorithms along with the other prefs (symmetric algo
and hash).  Also included is a couple of fixes to allow setting the
pref to no compression (legal, but there was no way to set it before).

David

-- 
   David Shaw  |  dshaw at jabberwocky.com  |  WWW http://www.jabberwocky.com/
+---------------------------------------------------------------------------+
   "There are two major products that come out of Berkeley: LSD and UNIX.
      We don't believe this to be a coincidence." - Jeremy S. Anderson
-------------- next part --------------
Index: g10.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/Attic/g10.c,v
retrieving revision 1.129.2.58
diff -u -r1.129.2.58 g10.c
--- g10.c	2001/11/08 13:25:48	1.129.2.58
+++ g10.c	2001/11/16 04:23:42
@@ -1184,8 +1184,8 @@
 	if( check_policy_url( opt.set_policy_url ) )
 	    log_error(_("the given policy URL is invalid\n"));
     }
-    if( opt.def_compress_algo < 1 || opt.def_compress_algo > 2 )
-	log_error(_("compress algorithm must be in range %d..%d\n"), 1, 2);
+    if( opt.def_compress_algo < 0 || opt.def_compress_algo > 2 )
+	log_error(_("compress algorithm must be in range %d..%d\n"), 0, 2);
     if( opt.completes_needed < 1 )
 	log_error(_("completes-needed must be greater than 0\n"));
     if( opt.marginals_needed < 2 )
@@ -1233,6 +1233,9 @@
 	g10_opt_verbose = opt.verbose;
     }
 
+    /* Compression algorithm 0 means no compression at all */
+    if( opt.def_compress_algo == 0)
+        opt.compress = 0;
 
     /* kludge to let -sat generate a clear text signature */
     if( opt.textmode == 2 && !detached_sig && opt.armor && cmd == aSign )
Index: getkey.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/getkey.c,v
retrieving revision 1.66.2.36
diff -u -r1.66.2.36 getkey.c
--- getkey.c	2001/09/28 16:59:47	1.66.2.36
+++ getkey.c	2001/11/16 04:23:44
@@ -1163,7 +1163,7 @@
         }
         for (; nzip; nzip--, n++) {
             uid->prefs[n].type = PREFTYPE_ZIP;
-            uid->prefs[n].value = *sym++;
+            uid->prefs[n].value = *zip++;
         }
         uid->prefs[n].type = PREFTYPE_NONE; /* end of list marker */
         uid->prefs[n].value = 0;
Index: keyedit.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/keyedit.c,v
retrieving revision 1.58.2.37
diff -u -r1.58.2.37 keyedit.c
--- keyedit.c	2001/10/23 08:03:45	1.58.2.37
+++ keyedit.c	2001/11/16 04:23:46
@@ -1099,6 +1099,35 @@
                     tty_printf ("[%d]", prefs[i].value);
             }    
         }
+        tty_printf ("\n     Compression: ");
+        for(i=any=0; prefs[i].type; i++ ) {
+            if( prefs[i].type == PREFTYPE_ZIP ) {
+                const char *s=NULL;
+		switch(prefs[i].value)
+		  {
+		  case 0:
+		    s="Uncompressed";
+		    break;
+
+		  case 1:
+		    s="ZIP";
+		    break;
+
+		  case 2:
+		    s="ZLIB";
+		    break;
+		  }
+                
+                if (any)
+                    tty_printf (", ");
+                any = 1;
+                /* We don't want to display strings for experimental algos */
+                if (s && prefs[i].value < 100 )
+                    tty_printf ("%s", s );
+                else
+                    tty_printf ("[%d]", prefs[i].value);
+            }    
+        }
         tty_printf("\n");
     }
     else {
Index: keygen.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/keygen.c,v
retrieving revision 1.70.2.29
diff -u -r1.70.2.29 keygen.c
--- keygen.c	2001/09/24 16:03:13	1.70.2.29
+++ keygen.c	2001/11/16 04:23:48
@@ -175,7 +175,7 @@
 {
     int i;
 
-    if (!val || val > 127 || cf (val)) {
+    if (cf (val)) {
         log_info (_("preference %c%lu is not valid\n"), type, val);
         return -1;
     }


More information about the Gnupg-devel mailing list