all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Adam Sjøgren" <asjo@koldfront.dk>
Cc: 61326@debbugs.gnu.org
Subject: bug#61326: Adding --no-add-suffix to zip patch
Date: Tue, 7 Feb 2023 09:31:11 +0800	[thread overview]
Message-ID: <8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz> (raw)
In-Reply-To: <87ilgeoc4w.fsf@tullinup.koldfront.dk>

On Feb 7, 2023, at 02:58, Adam Sjøgren via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
> 
> Adding a '--no-add-suffix' option to zip 3.0 is not too bad:
> 
> diff -u orig/zip-3.0/globals.c chan/zip-3.0/globals.c
> --- orig/zip-3.0/globals.c    2008-05-25 19:26:38.000000000 +0200
> +++ chan/zip-3.0/globals.c    2023-02-06 19:42:48.000000000 +0100
> @@ -106,6 +106,7 @@
> int noisy = 1;                /* 0=quiet operation */
> int extra_fields = 1;         /* 0=create minimum, 1=don't copy old, 2=keep old */
> int use_descriptors = 0;      /* 1=use data descriptors 12/29/04 */
> +int no_add_suffix = 0;        /* 1=do not add suffix .zip to archive names without . */
> int zip_to_stdout = 0;        /* output zipfile to stdout 12/30/04 */
> int allow_empty_archive = 0;  /* if no files, create empty archive anyway 12/28/05 */
> int copy_only = 0;            /* 1=copying archive entries only */
> diff -u orig/zip-3.0/zip.c chan/zip-3.0/zip.c
> --- orig/zip-3.0/zip.c    2023-02-06 19:49:42.000000000 +0100
> +++ chan/zip-3.0/zip.c    2023-02-06 19:47:26.000000000 +0100
> @@ -1942,6 +1942,7 @@
> #ifdef UNICODE_TEST
> #define o_sC            0x146
> #endif
> +#define o_nas           0x147
> 
> 
> /* the below is mainly from the old main command line
> @@ -2042,6 +2043,7 @@
>     {"N",  "notes",       o_NO_VALUE,       o_NOT_NEGATABLE, 'N',  "add notes as entry comments"},
> #endif
>     {"o",  "latest-time", o_NO_VALUE,       o_NOT_NEGATABLE, 'o',  "use latest entry time as archive time"},
> +    {"",   "no-add-suffix", o_NO_VALUE,     o_NOT_NEGATABLE, o_nas, "do not add .zip suffix to archive name without ."},
>     {"O",  "output-file", o_REQUIRED_VALUE, o_NOT_NEGATABLE, 'O',  "set out zipfile different than in zipfile"},
>     {"p",  "paths",       o_NO_VALUE,       o_NOT_NEGATABLE, 'p',  "store paths"},
>     {"P",  "password",    o_REQUIRED_VALUE, o_NOT_NEGATABLE, 'P',  "encrypt entries, option value is password"},
> @@ -2378,6 +2380,7 @@
>   before = 0;             /* 0=ignore, else exclude files before this time */
>   after = 0;              /* 0=ignore, else exclude files newer than this time */
> 
> +  no_add_suffix = 0       /* 0=add .zip if no . as usual, else use archive name unchanged */
>   special = ".Z:.zip:.zoo:.arc:.lzh:.arj"; /* List of special suffixes */
>   key = NULL;             /* Scramble password if scrambling */
>   key_needed = 0;         /* Need scramble password */
> @@ -3299,6 +3302,11 @@
>           break;
> #endif
> 
> +        case o_nas:
> +          no_add_suffix = 1;
> +          break;
> +
> +
>         case o_NON_OPTION_ARG:
>           /* not an option */
>           /* no more options as permuting */
> @@ -3340,8 +3348,14 @@
> #endif /* !MACOS && !WINDLL */
>               {
>                 /* name of zipfile */
> -                if ((zipfile = ziptyp(value)) == NULL) {
> -                  ZIPERR(ZE_MEM, "was processing arguments");
> +                if (no_add_suffix) {
> +                  zipfile = value;
> +                }
> +                else {
> +                  if ((zipfile = ziptyp(value)) == NULL) {
> +                    ZIPERR(ZE_MEM, "was processing arguments");
> +                  }
> +                  free(value);
>                 }
>                 /* read zipfile if exists */
>                 /*
> @@ -3349,7 +3363,6 @@
>                   ZIPERR(r, zipfile);
>                 }
>                 */
> -                free(value);
>               }
>               if (show_what_doing) {
>                 fprintf(mesg, "sd: Zipfile name '%s'\n", zipfile);
> diff -u orig/zip-3.0/zip.h chan/zip-3.0/zip.h
> --- orig/zip-3.0/zip.h    2008-05-25 19:23:22.000000000 +0200
> +++ chan/zip-3.0/zip.h    2023-02-06 19:43:41.000000000 +0100
> @@ -442,6 +442,7 @@
>  extern int use_privileges;     /* use security privilege overrides */
> #endif
> extern int use_descriptors;     /* use data descriptors (extended headings) */
> +extern int no_add_suffix;       /* do not add suffix .zip to archive names without . */
> extern int allow_empty_archive; /* if no files, create empty archive anyway */
> extern int copy_only;           /* 1 = copy archive with no changes */
> extern int zip_to_stdout;       /* output to stdout */
> 
> But getting something like that accepted and distributed, and for Emacs
> to tell whether the installed zip has that option or not, seems like a
> lot of work.

Maybe, at least in the meantime, we change it such that all write operations for zip create files in temp, and move to / overwrite the original file when done? Although I don’t have a full understanding on how that would be done and whether there are problems along with it. 





  reply	other threads:[~2023-02-07  1:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 17:00 bug#61326: 30.0.50; Editing fil in zip file without extension save creates new file Adam Sjøgren via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-06 18:04 ` Eli Zaretskii
2023-02-06 18:15   ` Adam Sjøgren via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-06 18:57 ` bug#61326: Adding --no-add-suffix to zip patch Adam Sjøgren via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-07  1:31   ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-07  3:27     ` Eli Zaretskii
2023-02-07 13:53       ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-07 14:54         ` Eli Zaretskii
2023-02-08 16:48         ` bug#61326: [DRAFT PATCH] Work around zip's filename extension limitation (was: Adding --no-add-suffix to zip patch) Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-08 18:02           ` Eli Zaretskii
2023-02-10  8:40             ` bug#61326: [DRAFT PATCH v2] " Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-13 10:35               ` bug#61326: [DRAFT PATCH v3] " Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-04 11:21                 ` Eli Zaretskii
2023-03-04 14:56                   ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-04 15:12                     ` Eli Zaretskii
2023-03-05 15:23                       ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-05 15:52                         ` Eli Zaretskii
2023-03-06  4:05                           ` bug#61326: [DRAFT PATCH v4] " Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-11  8:54                             ` Eli Zaretskii
2023-03-11  8:57                               ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-17  3:19                                 ` bug#61326: [DRAFT PATCH v5] " Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-17  8:48                                   ` bug#61326: [PATCH " Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-20  7:47                                     ` Eli Zaretskii
2023-04-20  8:49                                       ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-20  9:29                                         ` Eli Zaretskii
2023-02-07 19:59     ` bug#61326: Adding --no-add-suffix to zip patch Adam Sjøgren via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-08  1:21       ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-08  3:28         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8574C128-9560-490A-88E6-49E415BBDB24@netyu.xyz \
    --to=bug-gnu-emacs@gnu.org \
    --cc=61326@debbugs.gnu.org \
    --cc=asjo@koldfront.dk \
    --cc=ruijie@netyu.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.