summaryrefslogtreecommitdiff
path: root/archivers/gsharutils/patches/patch-ac
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/gsharutils/patches/patch-ac')
-rw-r--r--archivers/gsharutils/patches/patch-ac119
1 files changed, 115 insertions, 4 deletions
diff --git a/archivers/gsharutils/patches/patch-ac b/archivers/gsharutils/patches/patch-ac
index 7b145a25917..6b5c3418400 100644
--- a/archivers/gsharutils/patches/patch-ac
+++ b/archivers/gsharutils/patches/patch-ac
@@ -1,8 +1,24 @@
-$NetBSD: patch-ac,v 1.2 1999/05/23 20:33:46 tv Exp $
+$NetBSD: patch-ac,v 1.2.20.1 2005/04/01 05:03:52 snj Exp $
---- src/shar.c.orig Sun Jun 8 22:47:22 1997
-+++ src/shar.c Sun Jun 8 22:47:37 1997
-@@ -688,7 +688,7 @@
+--- src/shar.c.orig 1999-09-10 21:20:41.000000000 +0200
++++ src/shar.c 2005-03-31 15:33:03.000000000 +0200
+@@ -211,11 +211,11 @@
+ /* Position for first file in the shar file. */
+ static long first_file_position;
+
+-/* Base for output filename. FIXME: No fix limit in GNU... */
+-static char output_base_name[50];
++/* Base for output filename. */
++static char *output_base_name;
+
+-/* Actual output filename. FIXME: No fix limit in GNU... */
+-static char output_filename[50];
++/* Actual output filename. */
++static char *output_filename;
+
+ static char *submitter_address = NULL;
+
+@@ -696,7 +696,7 @@
const char *local_name;
const char *restore_name;
{
@@ -11,3 +27,98 @@ $NetBSD: patch-ac,v 1.2 1999/05/23 20:33:46 tv Exp $
mode_string (struct_stat.st_mode), restore_name);
return 0;
}
+@@ -1571,7 +1571,7 @@
+ sprintf (command, "%s '%s'", CHARACTER_COUNT_COMMAND, local_name);
+ if (pfp = popen (command, "r"), pfp)
+ {
+- char wc[BUFSIZ];
++ char wc[BUFSIZ], tempform[50];
+ const char *prefix = "";
+
+ if (did_md5)
+@@ -1579,8 +1579,8 @@
+ fputs (" else\n", output);
+ prefix = " ";
+ }
+-
+- fscanf (pfp, "%s", wc);
++ sprintf (tempform, "%%%ds", BUFSIZ - 1);
++ fscanf (pfp, tempform, wc);
+ fprintf (output, "\
+ %s shar_count=\"`%s '%s'`\"\n\
+ %s test %s -eq \"$shar_count\" ||\n\
+@@ -1634,7 +1634,12 @@
+ static void
+ open_output ()
+ {
+- sprintf (output_filename, output_base_name, ++part_number);
++ size_t l;
++ l = strlen(output_base_name) + 128;
++ if (output_filename)
++ free(output_filename);
++ output_filename = xmalloc(l);
++ snprintf(output_filename, l, output_base_name, ++part_number);
+ output = fopen (output_filename, "w");
+ if (!output)
+ error (EXIT_FAILURE, errno, _("Opening `%s'"), output_filename);
+@@ -1771,6 +1776,42 @@
+ { NULL, 0, NULL, 0 },
+ };
+
++
++char *parse_output_base_name(char *arg)
++{
++ int c;
++ int hadarg = 0;
++ char *fmt, *p;
++
++ for (p = arg ; (c = *p++) != 0; )
++ {
++ if (c != '%')
++ continue;
++ c = *p++;
++ if (c == '%')
++ continue;
++ if (hadarg)
++ return 0;
++ while (c != 0 && strchr("#0+- 'I", c) != 0)
++ c = *p++;
++ while (c != 0 && c >= '0' && c <= '9')
++ c = *p++;
++ if (c == '.')
++ c = *p++;
++ while (c != 0 && c >= '0' && c <= '9')
++ c = *p++;
++ if (c == 0 || strchr("diouxX", c) == 0)
++ return 0;
++ hadarg = 1;
++ }
++ fmt = xmalloc(strlen(arg) + (hadarg ? 1 : 6));
++ strcpy(fmt, arg);
++ if (!hadarg)
++ strcat(fmt, ".%02d");
++ return fmt;
++}
++
++
+ /*---.
+ | ? |
+ `---*/
+@@ -1905,9 +1946,14 @@
+ break;
+
+ case 'o':
+- strcpy (output_base_name, optarg);
+- if (!strchr (output_base_name, '%'))
+- strcat (output_base_name, ".%02d");
++ if (output_base_name)
++ free (output_base_name);
++ output_base_name = parse_output_base_name(optarg);
++ if (!output_base_name)
++ {
++ fprintf (stderr, _("illegal output prefix\n"));
++ exit (EXIT_FAILURE);
++ }
+ part_number = 0;
+ open_output ();
+ break;