Compression/showpref fix

David Shaw dshaw at jabberwocky.com
Fri Nov 16 21:23:01 CET 2001


On Fri, Nov 16, 2001 at 07:12:43PM +0100, Werner Koch wrote:
> On Thu, 15 Nov 2001 23:40:08 -0500, David Shaw said:
> 
> > Fix is attached, along with a minor enhancement to "showpref" to show
> > the compression algorithms along with the other prefs (symmetric algo
> 
> Thanks.  Due to the tight schedule for the Aegypten project I have to
> postpone a lot of tasks to end of November ;-(.
> 
> I will apply your patches then or ask you for a patch against the CVS.
> If you do a patch for the CVS you would really help me if you can
> write ChangeLog entries for all chnages and an prepend them to the
> diff.  As you know pacthing a ChangeLog is not more or less pointless.

No problem.  Here's the patch again with ChangeLog info.

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: ChangeLog
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/ChangeLog,v
retrieving revision 1.162.2.170
diff -u -r1.162.2.170 ChangeLog
--- ChangeLog	2001/11/09 09:36:22	1.162.2.170
+++ ChangeLog	2001/11/16 20:21:24
@@ -1,3 +1,17 @@
+2001-11-16  David Shaw  <dshaw at jabberwocky.com>
+
+	* Allow the user to select no compression via "--compress-algo 0"
+	on the command line.
+
+	* keyedit.c (show_prefs): Show compression preferences in the
+	long-form "showpref" style.
+
+	* keygen.c (set_one_pref): Permit setting a no-compression ("Z0")
+	preference.
+
+	* getkey.c (fixup_uidnode): Fix compression preference corruption
+	bug.
+
 2001-11-09  Werner Koch  <wk at gnupg.org>
 
 	* export.c (do_export_stream): Put all given names into a search
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 20:21:25
@@ -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 20:21:25
@@ -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 20:21:26
@@ -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 20:21:26
@@ -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