zipcmp: add -s to print a summary of how many files where added/removed
diff --git a/man/zipcmp.mdoc b/man/zipcmp.mdoc
index d1b1513..4998c00 100644
--- a/man/zipcmp.mdoc
+++ b/man/zipcmp.mdoc
@@ -1,5 +1,5 @@
 .\" zipcmp.mdoc -- compare zip archives
-.\" Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd March 17, 2021
+.Dd March 19, 2022
 .Dt ZIPCMP 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd compare contents of zip archives
 .Sh SYNOPSIS
 .Nm
-.Op Fl ChipqtVv
+.Op Fl ChipqstVv
 .Ar archive1 archive2
 .Sh DESCRIPTION
 .Nm
@@ -68,6 +68,8 @@
 Quiet mode.
 Compare
 .Fl v .
+.It Fl s
+Print a summary of how many files where added and removed.
 .It Fl t
 Test zip files by comparing the contents to their checksums.
 .It Fl V
diff --git a/src/zipcmp.c b/src/zipcmp.c
index 6a1e741..49046d8 100644
--- a/src/zipcmp.c
+++ b/src/zipcmp.c
@@ -194,6 +194,7 @@
   -i       compare names ignoring case distinctions\n\
   -p       compare as many details as possible\n\
   -q       be quiet\n\
+  -s       print a summary\n\
   -t       test zip files (compare file contents to checksum)\n\
   -V       display version number\n\
   -v       be verbose (print differences, default)\n\
@@ -201,10 +202,10 @@
 Report bugs to <libzip@nih.at>.\n";
 
 char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\
-Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner\n\
+Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner\n\
 " PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n";
 
-#define OPTIONS "hVCipqtv"
+#define OPTIONS "hVCipqstv"
 
 
 #define BOTH_ARE_ZIPS(a) (a[0].za && a[1].za)
@@ -230,7 +231,8 @@
 static int list_zip(const char *name, struct archive *a);
 static int test_file(zip_t *za, zip_uint64_t idx, const char *zipname, const char *filename, zip_uint64_t size, zip_uint32_t crc);
 
-int ignore_case, test_files, paranoid, verbose, have_directory, check_consistency;
+int ignore_case, test_files, paranoid, verbose, have_directory, check_consistency, summary;
+int plus_count = 0, minus_count = 0;
 
 diff_output_t output;
 
@@ -247,6 +249,7 @@
     paranoid = 0;
     have_directory = 0;
     verbose = 1;
+    summary = 0;
 
     while ((c = getopt(argc, argv, OPTIONS)) != -1) {
         switch (c) {
@@ -262,6 +265,9 @@
             case 'q':
                 verbose = 0;
                 break;
+	    case 's':
+		summary = 1;
+		break;
             case 't':
                 test_files = 1;
                 break;
@@ -340,9 +346,11 @@
         if (comment_compare(a[0].comment, a[0].comment_length, a[1].comment, a[1].comment_length) != 0) {
             if (a[0].comment_length > 0) {
                 diff_output_data(&output, '-', (const zip_uint8_t *)a[0].comment, a[0].comment_length, "archive comment");
+		minus_count++;
             }
             if (a[1].comment_length > 0) {
                 diff_output_data(&output, '+', (const zip_uint8_t *)a[1].comment, a[1].comment_length, "archive comment");
+		plus_count++;
             }
             res = 1;
         }
@@ -360,6 +368,10 @@
         free(a[i].entry);
     }
 
+    if (summary) {
+	printf("%d files added, %d files removed\n", plus_count, minus_count);
+    }
+
     switch (res) {
     case 0:
         exit(0);
@@ -596,6 +608,7 @@
             break;                                        \
         }                                                 \
         print((k) ? '+' : '-', list[k]);                  \
+        (k) ? plus_count++ : minus_count++;		  \
         diff = 1;                                         \
     } while (0)