Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package gifsicle for openSUSE:Factory checked in at 2026-11-25 16:14:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gifsicle (Old) and /work/SRC/openSUSE:Factory/.gifsicle.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "gifsicle" Wed Nov 25 16:14:47 2026 rev:16 rq:1400561 version:1.99 Changes: -------- --- /work/SRC/openSUSE:Factory/gifsicle/gifsicle.changes 2026-10-18 22:56:10.430290441 +0200 +++ /work/SRC/openSUSE:Factory/.gifsicle.new.1340718/gifsicle.changes 2026-11-25 16:16:48.499174620 +0100 @@ -0,0 +1,8 @@ +Tue Nov 24 16:18:54 UTC 2026 - Manfred Schwarb <[email protected]> + +- Update to version 1.99: + * Multithreaded resizing (-j) gives the same results as single-threaded resizing. + * Resizing no longer writes invalid pixels when a frames transparent color is + the only color in its colormap. + * Count transparent pixels correctly. + Old: ---- gifsicle-1.98.tar.gz New: ---- gifsicle-1.99.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gifsicle.spec ++++++ --- /var/tmp/diff_new_pack.KJhfBC/_old 2026-11-25 16:16:49.317208949 +0100 +++ /var/tmp/diff_new_pack.KJhfBC/_new 2026-11-25 16:16:49.319209033 +0100 @@ -21,7 +21,7 @@ BuildRequires: perl-Time-HiRes %endif Name: gifsicle -Version: 1.98 +Version: 1.99 Release: 0 Summary: Creating and editing GIF images and animations License: GPL-2.0-only ++++++ gifsicle-1.98.tar.gz -> gifsicle-1.99.tar.gz ++++++ ++++ 2237 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/Makefile.am new/gifsicle-1.99/Makefile.am --- old/gifsicle-1.98/Makefile.am 2026-10-15 00:54:16.000000000 +0200 +++ new/gifsicle-1.99/Makefile.am 2026-11-24 01:53:13.000000000 +0100 @@ -30,7 +30,9 @@ test/018-readerrors.testie \ test/019-truncated.testie \ test/020-geometry.testie \ - test/021-resizetransparent.testie + test/021-resizetransparent.testie \ + test/022-threadresize.testie \ + test/023-resizeonecolor.testie gifsicle: config.h @cd src && $(MAKE) gifsicle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/NEWS.md new/gifsicle-1.99/NEWS.md --- old/gifsicle-1.98/NEWS.md 2026-10-15 14:23:56.000000000 +0200 +++ new/gifsicle-1.99/NEWS.md 2026-11-24 16:13:34.000000000 +0100 @@ -1,6 +1,17 @@ Gifsicle NEWS ============= +## Version 1.99 – 24.Nov.2026 + +* Bug fixes + + * Multithreaded resizing (`-j`) gives the same results as single-threaded + resizing. + * Resizing no longer writes invalid pixels when a frame’s transparent + color is the only color in its colormap. + * Count transparent pixels correctly. + + ## Version 1.98 – 15.Oct.2026 * Add `--max-screen` option, which limits the size of logical screens to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/configure.ac new/gifsicle-1.99/configure.ac --- old/gifsicle-1.98/configure.ac 2026-10-15 14:20:10.000000000 +0200 +++ new/gifsicle-1.99/configure.ac 2026-11-24 16:13:53.000000000 +0100 @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([gifsicle],[1.98]) +AC_INIT([gifsicle],[1.99]) AC_PREREQ([2.69]) AC_CONFIG_SRCDIR([src/gifsicle.h]) AC_CONFIG_HEADERS([config.h]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/gifdiff.1 new/gifsicle-1.99/gifdiff.1 --- old/gifsicle-1.98/gifdiff.1 2026-10-15 14:21:07.000000000 +0200 +++ new/gifsicle-1.99/gifdiff.1 2026-11-24 16:14:25.000000000 +0100 @@ -1,5 +1,5 @@ .\" -*- mode: nroff -*- -.ds V 1.98 +.ds V 1.99 .ds E " \-\- .if t .ds E \(em .de Op diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/gifsicle.1 new/gifsicle-1.99/gifsicle.1 --- old/gifsicle-1.98/gifsicle.1 2026-10-15 14:21:07.000000000 +0200 +++ new/gifsicle-1.99/gifsicle.1 2026-11-24 16:14:25.000000000 +0100 @@ -1,6 +1,6 @@ .\" -*- mode: nroff -*- .AM -.ds V 1.98 +.ds V 1.99 .ds E " \-\- .if t .ds E \(em .de Op diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/gifview.1 new/gifsicle-1.99/gifview.1 --- old/gifsicle-1.98/gifview.1 2026-10-15 14:21:07.000000000 +0200 +++ new/gifsicle-1.99/gifview.1 2026-11-24 16:14:25.000000000 +0100 @@ -1,5 +1,5 @@ .\" -*- mode: nroff -*- -.ds V 1.98 +.ds V 1.99 .ds E " \-\- .if t .ds E \(em .de Op diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/include/lcdf/clp.h new/gifsicle-1.99/include/lcdf/clp.h --- old/gifsicle-1.98/include/lcdf/clp.h 2026-10-13 23:58:35.000000000 +0200 +++ new/gifsicle-1.99/include/lcdf/clp.h 2026-11-24 01:53:22.000000000 +0100 @@ -27,6 +27,12 @@ #include <stdio.h> #include <stdarg.h> +#if HAVE_INTTYPES_H || !defined(HAVE_CONFIG_H) +# include <inttypes.h> +#endif +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif typedef struct Clp_Option Clp_Option; typedef struct Clp_Parser Clp_Parser; @@ -192,8 +198,10 @@ double d; const char *s; void *pv; -#ifdef HAVE_INT64_TYPES +#if HAVE_INT64_T int64_t i64; +#endif +#if HAVE_UINT64_T uint64_t u64; #endif char cs[Clp_ValSize]; @@ -317,9 +325,6 @@ int Clp_vfprintf(Clp_Parser* clp, FILE* f, const char* format, va_list val); /** @brief Extract the current option as a string. */ -int Clp_CurOptionNameBuf(Clp_Parser *clp, char *buf, int len); - -/** @brief Extract the current option as a string. */ const char *Clp_CurOptionName(Clp_Parser *clp); /** @brief Test if the current option had long name @a name. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/src/clp.c new/gifsicle-1.99/src/clp.c --- old/gifsicle-1.98/src/clp.c 2026-10-15 02:01:40.000000000 +0200 +++ new/gifsicle-1.99/src/clp.c 2026-11-24 03:26:28.000000000 +0100 @@ -27,16 +27,11 @@ #include <ctype.h> #include <errno.h> #include <limits.h> +#include <math.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#if HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif -#if HAVE_INTTYPES_H || !defined(HAVE_CONFIG_H) -# include <inttypes.h> -#endif #if !defined(HAVE_UINTPTR_T) && defined(HAVE_CONFIG_H) typedef unsigned long uintptr_t; #endif @@ -185,8 +180,9 @@ Clp_ValType *valtype; int nvaltype; - const char * const *argv; - int argc; + const char * const *argv; /* next unread argument */ + int argc; /* number of unread arguments */ + const char *arg; /* current argument */ Clp_Oclass oclass[Clp_OclassSize]; int noclass; @@ -201,7 +197,6 @@ void (*error_handler)(Clp_Parser *, const char *); int option_processing; - int current_option; unsigned char is_short; unsigned char whole_negated; /* true if negated by an option character */ @@ -217,6 +212,7 @@ struct Clp_ParserState { const char * const *argv; int argc; + const char *arg; char option_chars[Clp_OptionCharsSize]; const char *xtext; @@ -224,7 +220,7 @@ int option_processing; unsigned opt_generation; - int current_option; + const Clp_Option *option; unsigned char is_short; unsigned char whole_negated; unsigned char current_short; @@ -235,6 +231,7 @@ typedef struct Clp_StringList { Clp_Option *items; Clp_InternOption *iopt; + long *lvals; int nitems; unsigned char allow_int; @@ -250,6 +247,22 @@ {"", 0, Clp_Error, 0, 0} }; +/* Returns true if clp->option is a sentinel. */ +static int +opt_sentinel(const Clp_Parser *clp) +{ + uintptr_t delta = (uintptr_t) clp->option - (uintptr_t) clp_option_sentinel; + return delta < sizeof(clp_option_sentinel); +} + +/* Returns true if clp->option is the Clp_BadOption or Clp_Error sentinel. */ +static int +opt_error_sentinel(const Clp_Parser *clp) +{ + return clp->option == &clp_option_sentinel[-Clp_BadOption] + || clp->option == &clp_option_sentinel[-Clp_Error]; +} + static int parse_string(Clp_Parser *, const char *, int, void *); static int parse_int(Clp_Parser *, const char *, int, void *); @@ -295,8 +308,10 @@ static int decode_utf8(const char *s, const char **cp) { - int c; - if ((unsigned char) *s <= 0x7F) /* 1 byte: 0x000000-0x00007F */ + int c, i; + if (*s == 0) /* end of string */ + c = 0; + else if ((unsigned char) *s <= 0x7F) /* 1 byte: 0x000001-0x00007F */ c = *s++; else if ((unsigned char) *s <= 0xC1) /* bad/overlong encoding */ goto replacement; @@ -332,8 +347,10 @@ c += (*s++ & 0x3F); } else { replacement: + /* Skip at most 3 continuation bytes, so a character is at most 4 + bytes long */ c = U_REPLACEMENT; - for (s++; (*s & 0xC0) == 0x80; s++) + for (s++, i = 0; i < 3 && (*s & 0xC0) == 0x80; s++, i++) /* nothing */; } if (cp) @@ -355,6 +372,12 @@ return (cli->utf8 ? utf8_charlen(s) : 1); } +static int +valid_short_name(const Clp_Internal *cli, int c) +{ + return c > 0 && c < (cli->utf8 ? 0x110000 : 256); +} + /******* * Clp_NewParser, etc. @@ -391,9 +414,10 @@ return failure; } +/* Options o1 and o2 are synonyms if same != 0. */ static void compare_options(Clp_Parser *clp, const Clp_Option *o1, Clp_InternOption *io1, - const Clp_Option *o2, Clp_InternOption *io2) + const Clp_Option *o2, Clp_InternOption *io2, int same) { Clp_Internal *cli = clp->internal; int short1, shortx1; @@ -401,7 +425,7 @@ /* ignore meaningless combinations */ if ((!io1->ishort && !io1->ilong) || (!io2->ishort && !io2->ilong) || !((io1->ipos && io2->ipos) || (io1->ineg && io2->ineg)) - || o1->option_id == o2->option_id) + || same) return; /* look for duplication of short options */ @@ -448,15 +472,23 @@ } } +/* Options with equal values are synonyms. Values come from lvals if it is + nonnull, and from option_id otherwise. */ static void -calculate_lmm(Clp_Parser *clp, const Clp_Option *opt, Clp_InternOption *iopt, int nopt) +calculate_lmm(Clp_Parser *clp, const Clp_Option *opt, Clp_InternOption *iopt, + int nopt, const long *lvals) { - int i, j; + int i, j, same; for (i = 0; i < nopt; ++i) { iopt[i].lmmpos = iopt[i].lmmneg = 1; iopt[i].lmmpos_short = iopt[i].lmmneg_short = 0; - for (j = 0; j < nopt; ++j) - compare_options(clp, &opt[i], &iopt[i], &opt[j], &iopt[j]); + for (j = 0; j < nopt; ++j) { + if (lvals) + same = lvals[i] == lvals[j]; + else + same = opt[i].option_id == opt[j].option_id; + compare_options(clp, &opt[i], &iopt[i], &opt[j], &iopt[j], same); + } } } @@ -501,7 +533,7 @@ { Clp_Parser *clp = (Clp_Parser *)malloc(sizeof(Clp_Parser)); Clp_Internal *cli = (Clp_Internal *)malloc(sizeof(Clp_Internal)); - Clp_InternOption *iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * nopt); + Clp_InternOption *iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * (nopt > 0 ? nopt : 1)); if (cli) cli->valtype = (Clp_ValType *)malloc(sizeof(Clp_ValType) * Clp_InitialValType); if (!clp || !cli || !iopt || !cli->valtype) @@ -511,6 +543,7 @@ clp->negated = 0; clp->have_val = 0; clp->vstr = 0; + memset(&clp->val, 0, sizeof(clp->val)); clp->user_data = 0; clp->internal = cli; @@ -528,7 +561,10 @@ cli->program_name = 0; /* Assign arguments, skipping program name */ - Clp_SetArguments(clp, argc - 1, argv + 1); + if (argc > 0) + Clp_SetArguments(clp, argc - 1, argv + 1); + else + Clp_SetArguments(clp, 0, 0); /* Initialize UTF-8 status and option classes */ { @@ -569,6 +605,15 @@ return 0; } +static void +free_string_list(Clp_StringList *clsl) +{ + free(clsl->items); + free(clsl->iopt); + free(clsl->lvals); + free(clsl); +} + /** @param clp the parser * * All memory associated with @a clp is freed. */ @@ -584,12 +629,8 @@ /* get rid of any string list types */ for (i = 0; i < cli->nvaltype; i++) - if (cli->valtype[i].func == parse_string_list) { - Clp_StringList *clsl = (Clp_StringList *)cli->valtype[i].user_data; - free(clsl->items); - free(clsl->iopt); - free(clsl); - } + if (cli->valtype[i].func == parse_string_list) + free_string_list((Clp_StringList *) cli->valtype[i].user_data); free(cli->valtype); free(cli->iopt); @@ -632,9 +673,12 @@ Clp_SetUTF8(Clp_Parser *clp, int utf8) { Clp_Internal *cli = clp->internal; - int old_utf8 = cli->utf8; + int old_utf8 = cli->utf8, i; cli->utf8 = utf8; - calculate_lmm(clp, cli->opt, cli->iopt, cli->nopt); + for (i = 0; i < cli->nopt; ++i) + if (cli->opt[i].option_id >= 0) + cli->iopt[i].ishort = valid_short_name(cli, cli->opt[i].short_name); + calculate_lmm(clp, cli->opt, cli->iopt, cli->nopt, 0); return old_utf8; } @@ -745,7 +789,7 @@ /* Must recheck option set */ cli->long1pos = long1pos; cli->long1neg = long1neg; - calculate_lmm(clp, cli->opt, cli->iopt, cli->nopt); + calculate_lmm(clp, cli->opt, cli->iopt, cli->nopt, 0); } return old; @@ -764,6 +808,7 @@ * * <ul> * <li>An option has a negative ID.</li> + * <li>A long option either equals "no-" or starts with "no-no-".</li> * <li>Two different short options have the same name.</li> * <li>Two different long options have the same name.</li> * <li>A short and a long option are ambiguous, in that some option character @@ -798,7 +843,7 @@ cli->nopt = nopt; cli->opt_generation = ++opt_generation; iopt = cli->iopt; - cli->current_option = -1; + clp->option = &clp_option_sentinel[-Clp_Done]; /* Massage the options to make them usable */ for (i = 0; i < nopt; ++i) { @@ -807,14 +852,12 @@ /* Ignore negative option_ids, which are internal to CLP */ if (opt[i].option_id < 0) { Clp_OptionError(clp, "CLP internal error: option %d has negative option_id", i); - iopt[i].ilong = iopt[i].ishort = iopt[i].ipos = iopt[i].ineg = iopt[i].unquoted = 0; continue; } /* Set flags based on input flags */ iopt[i].ilong = (opt[i].long_name != 0 && opt[i].long_name[0] != 0); - iopt[i].ishort = (opt[i].short_name > 0 - && opt[i].short_name < (cli->utf8 ? 0x110000 : 256)); + iopt[i].ishort = valid_short_name(cli, opt[i].short_name); iopt[i].ipos = 1; iopt[i].ineg = (opt[i].flags & Clp_Negate) != 0; iopt[i].imandatory = (opt[i].flags & Clp_Mandatory) != 0; @@ -833,9 +876,16 @@ if (iopt[i].ilong && strncmp(opt[i].long_name, "no-", 3) == 0) { iopt[i].ipos = 0; iopt[i].ineg = 1; - iopt[i].ilongoff = 3; - if (strncmp(opt[i].long_name + 3, "no-", 3) == 0) - Clp_OptionError(clp, "CLP internal error: option %d begins with \"no-no-\"", i); + if (opt[i].long_name[3] == 0) { + /* Long name "no-" is unusable; the short name (if any) + remains, but is only negated */ + Clp_OptionError(clp, "CLP internal error: option %d has long name \"no-\"", i); + iopt[i].ilong = 0; + } else { + iopt[i].ilongoff = 3; + if (strncmp(opt[i].long_name + 3, "no-", 3) == 0) + Clp_OptionError(clp, "CLP internal error: option %d begins with \"no-no-\"", i); + } } else if (opt[i].flags & Clp_OnlyNegated) { iopt[i].ipos = 0; iopt[i].ineg = 1; @@ -843,7 +893,7 @@ } /* Check option set */ - calculate_lmm(clp, opt, iopt, nopt); + calculate_lmm(clp, opt, iopt, nopt, 0); return 0; } @@ -870,13 +920,15 @@ { Clp_Internal *cli = clp->internal; - cli->argc = argc + 1; - cli->argv = argv - 1; + cli->argc = argc; + cli->argv = argv; + cli->arg = 0; + cli->xtext = 0; cli->is_short = 0; cli->whole_negated = 0; cli->option_processing = 1; - cli->current_option = -1; + clp->option = &clp_option_sentinel[-Clp_Done]; } @@ -956,6 +1008,10 @@ int negated = clp && clp->negated; int first_charlen = (clp ? clp_utf8_charlen(clp->internal, arg) : 1); + /* An empty name matches nothing (rather than being ambiguous) */ + if (*arg == 0 || *arg == '=') + return -1; + retry: for (i = 0; i < nopt; i++) { int len, lmm; @@ -1063,12 +1119,8 @@ cli->valtype[vtpos].func = 0; } - if (cli->valtype[vtpos].func == parse_string_list) { - Clp_StringList *clsl = (Clp_StringList *) cli->valtype[vtpos].user_data; - free(clsl->items); - free(clsl->iopt); - free(clsl); - } + if (cli->valtype[vtpos].func == parse_string_list) + free_string_list((Clp_StringList *) cli->valtype[vtpos].user_data); cli->valtype[vtpos].val_type = val_type; cli->valtype[vtpos].func = parser; @@ -1141,18 +1193,24 @@ parse_double(Clp_Parser *clp, const char *arg, int complain, void *user_data) { const char *val; + double d = 0; (void)user_data; + errno = 0; if (*arg == 0 || isspace((unsigned char) *arg)) val = arg; else - clp->val.d = strtod(arg, (char **) &val); - if (*arg != 0 && *val == 0) + d = strtod(arg, (char **) &val); + if (val != arg && *val == 0 && isfinite(d)) { + clp->val.d = d; return 1; - else { - if (complain) + } + if (complain) { + if (val != arg && *val == 0 && errno == ERANGE) + Clp_OptionError(clp, "%<%O%> argument %<%s%> out of range", arg); + else Clp_OptionError(clp, "%<%O%> expects a real number, not %<%s%>", arg); - return 0; } + return 0; } static int @@ -1175,7 +1233,7 @@ return 1; } else if (argcmp("no", lcarg, 1, 0) > 0 || argcmp("false", lcarg, 1, 0) > 0 - || argcmp("1", lcarg, 1, 0) > 0) { + || argcmp("0", lcarg, 1, 0) > 0) { clp->val.i = 0; return 1; } @@ -1197,6 +1255,7 @@ Clp_StringList *sl = (Clp_StringList *)user_data; int idx, ambiguous = 0; int ambiguous_values[MAX_AMBIGUOUS_VALUES + 1]; + const char* complaint; /* actually look for a string value */ idx = find_prefix_opt @@ -1204,9 +1263,9 @@ &ambiguous, ambiguous_values); if (idx >= 0) { if (sl->val_long) - clp->val.l = sl->items[idx].option_id; + clp->val.l = sl->lvals[idx]; else - clp->val.i = sl->items[idx].option_id; + clp->val.i = sl->lvals[idx]; return 1; } @@ -1215,33 +1274,39 @@ return 1; } - if (complain) { - const char *complaint = (ambiguous ? "ambiguous" : "invalid"); - if (!ambiguous) { - ambiguous = sl->nitems_invalid_report; - for (idx = 0; idx < ambiguous; idx++) - ambiguous_values[idx] = idx; - } - return ambiguity_error - (clp, ambiguous, ambiguous_values, sl->items, sl->iopt, - "", "option %<%V%> is %s", complaint); - } else + if (!complain) return 0; + + complaint = (ambiguous ? "ambiguous" : "invalid"); + if (!ambiguous) { + ambiguous = sl->nitems_invalid_report; + for (idx = 0; idx < ambiguous; idx++) + ambiguous_values[idx] = idx; + } + return ambiguity_error + (clp, ambiguous, ambiguous_values, sl->items, sl->iopt, + "", "option %<%V%> is %s", complaint); } +/* On success, the new string list owns items and lvals. */ static int finish_string_list(Clp_Parser *clp, int val_type, int flags, - Clp_Option *items, int nitems, int itemscap) + Clp_Option *items, long *lvals, int nitems, int itemscap) { int i, niitems = nitems + (flags & Clp_AllowNumbers ? 1 : 0); - Clp_StringList *clsl = (Clp_StringList *)malloc(sizeof(Clp_StringList)); - Clp_InternOption *iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * niitems); + Clp_StringList *clsl = 0; + Clp_InternOption *iopt = 0; + if (nitems < 0) + return -1; + clsl = (Clp_StringList *)malloc(sizeof(Clp_StringList)); + iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * (niitems > 0 ? niitems : 1)); if (!clsl || !iopt) goto error; clsl->items = items; clsl->iopt = iopt; + clsl->lvals = lvals; clsl->nitems = nitems; clsl->allow_int = (flags & Clp_AllowNumbers) != 0; clsl->val_long = (flags & Clp_StringListLong) != 0; @@ -1251,7 +1316,7 @@ iopt[i].ilong = iopt[i].ipos = 1; iopt[i].ishort = iopt[i].ineg = iopt[i].ilongoff = iopt[i].iprefmatch = iopt[i].unquoted = 0; } - calculate_lmm(clp, items, iopt, nitems); + calculate_lmm(clp, items, iopt, nitems, lvals); if (nitems < MAX_AMBIGUOUS_VALUES && nitems < itemscap && clsl->allow_int) { items[nitems].long_name = "any integer"; @@ -1304,49 +1369,54 @@ int nitems = 0; int itemscap = 5; Clp_Option *items = (Clp_Option *)malloc(sizeof(Clp_Option) * itemscap); + long *lvals = (long*) malloc(sizeof(long) * itemscap); va_list val; va_start(val, flags); - if (!items) + if (!items || !lvals) goto error; /* slurp up the arguments */ while (1) { - int value; char *name = va_arg(val, char *); if (!name) break; - if (flags & Clp_StringListLong) { - long lvalue = va_arg(val, long); - value = (int) lvalue; - assert(value == lvalue); - } else - value = va_arg(val, int); if (nitems >= itemscap) { - Clp_Option *new_items; + Clp_Option* new_items; + long* new_lvals; itemscap *= 2; new_items = (Clp_Option *)realloc(items, sizeof(Clp_Option) * itemscap); if (!new_items) goto error; items = new_items; + new_lvals = (long*) realloc(lvals, sizeof(long) * itemscap); + if (!new_lvals) + goto error; + lvals = new_lvals; } items[nitems].long_name = name; - items[nitems].option_id = value; items[nitems].flags = 0; + if (flags & Clp_StringListLong) + lvals[nitems] = va_arg(val, long); + else + lvals[nitems] = va_arg(val, int); nitems++; } va_end(val); - if (finish_string_list(clp, val_type, flags, items, nitems, itemscap) >= 0) + if (finish_string_list(clp, val_type, flags, items, lvals, nitems, itemscap) >= 0) return 0; + free(items); + free(lvals); + return -1; error: va_end(val); - if (items) - free(items); + free(items); + free(lvals); return -1; } @@ -1398,22 +1468,25 @@ int i; int itemscap = (nstrs < 5 ? 5 : nstrs); Clp_Option *items = (Clp_Option *)malloc(sizeof(Clp_Option) * itemscap); - if (!items) + long *lvals = (long *)malloc(sizeof(long) * itemscap); + if (!items || !lvals) { + free(items); + free(lvals); return -1; + } /* copy over items */ for (i = 0; i < nstrs; i++) { items[i].long_name = strs[i]; - items[i].option_id = vals[i]; items[i].flags = 0; + lvals[i] = vals[i]; } - if (finish_string_list(clp, val_type, flags, items, nstrs, itemscap) >= 0) + if (finish_string_list(clp, val_type, flags, items, lvals, nstrs, itemscap) >= 0) return 0; - else { - free(items); - return -1; - } + free(items); + free(lvals); + return -1; } @@ -1468,11 +1541,12 @@ if (state) { state->argv = 0; state->argc = 0; + state->arg = 0; state->option_chars[0] = 0; state->xtext = 0; state->option_processing = 0; state->opt_generation = 0; - state->current_option = -1; + state->option = &clp_option_sentinel[-Clp_Done]; state->is_short = 0; state->whole_negated = 0; state->current_short = 0; @@ -1501,12 +1575,13 @@ Clp_Internal *cli = clp->internal; state->argv = cli->argv; state->argc = cli->argc; + state->arg = cli->arg; memcpy(state->option_chars, cli->option_chars, Clp_OptionCharsSize); state->xtext = cli->xtext; state->option_processing = cli->option_processing; state->opt_generation = cli->opt_generation; - state->current_option = cli->current_option; + state->option = clp->option; state->is_short = cli->is_short; state->whole_negated = cli->whole_negated; state->current_short = cli->current_short; @@ -1534,6 +1609,7 @@ Clp_Internal *cli = clp->internal; cli->argv = state->argv; cli->argc = state->argc; + cli->arg = state->arg; memcpy(cli->option_chars, state->option_chars, Clp_OptionCharsSize); cli->xtext = state->xtext; cli->option_processing = state->option_processing; @@ -1542,9 +1618,9 @@ cli->current_short = state->current_short; cli->negated_by_no = state->negated_by_no; if (cli->opt_generation == state->opt_generation) - cli->current_option = state->current_option; + clp->option = state->option; else - cli->current_option = -1; + clp->option = &clp_option_sentinel[-Clp_Done]; } @@ -1555,9 +1631,12 @@ static void set_option_text(Clp_Internal *cli, const char *text, int n_option_chars) { + int ncopy = n_option_chars; assert(n_option_chars < Clp_OptionCharsSize); - memcpy(cli->option_chars, text, n_option_chars); - cli->option_chars[n_option_chars] = 0; + if (ncopy >= Clp_OptionCharsSize) + ncopy = Clp_OptionCharsSize - 1; + memcpy(cli->option_chars, text, ncopy); + cli->option_chars[ncopy] = 0; cli->xtext = text + n_option_chars; } @@ -1571,7 +1650,7 @@ *ocharskip = s - text; } else { c = (unsigned char) text[0]; - *ocharskip = 1; + *ocharskip = (c != 0); } return Clp_OptionChar(clp, c); } @@ -1589,12 +1668,12 @@ want_argument == 2: Accept ALL arguments. Where is the option stored when this returns? - Well, cli->argv[0] holds the whole of the next command line argument. + Well, cli->arg holds the whole of the current command line argument. cli->option_chars holds a string: what characters began the option? It is generally "-" or "--". - cli->text holds the text of the option: - for short options, cli->text[0] is the relevant character; - for long options, cli->text holds the rest of the option. */ + cli->xtext holds the text of the option: + for short options, cli->xtext[0] is the relevant character; + for long options, cli->xtext holds the rest of the option. */ { Clp_Internal *cli = clp->internal; const char *text; @@ -1630,12 +1709,12 @@ cli->whole_negated = 0; cli->xtext = 0; - if (cli->argc <= 1) + if (cli->argc <= 0) return 0; + text = cli->arg = cli->argv[0]; cli->argc--; cli->argv++; - text = cli->argv[0]; if (want_argument > 1) goto not_option; @@ -1714,12 +1793,11 @@ switch_to_short_argument(Clp_Parser *clp) { Clp_Internal *cli = clp->internal; - const char *text = cli->argv[0]; - int ocharskip, oclass = get_oclass(clp, text, &ocharskip); + int ocharskip, oclass = get_oclass(clp, cli->arg, &ocharskip); assert(cli->could_be_short); cli->is_short = 1; cli->whole_negated = !!(oclass & Clp_ShortNegated); - set_option_text(cli, cli->argv[0], ocharskip); + set_option_text(cli, cli->arg, ocharskip); } @@ -1845,7 +1923,7 @@ * <dd>The value string, if any. NULL if there was no value.</dd> * <dt><tt>val</tt></dt> * <dd>An option's value type will parse the value string into this - * union.</dd> + * union. Zeroed if the option had no value.</dd> * </dl> * * The parsed argument is shifted off the argument list, so that sequential @@ -1861,7 +1939,9 @@ int vtpos, complain; /* Set up clp */ - cli->current_option = -1; + clp->option = &clp_option_sentinel[-Clp_Done]; + clp->negated = 0; + memset(&clp->val, 0, sizeof(clp->val)); cli->ambiguous = 0; /* Get the next argument or option */ @@ -1882,6 +1962,7 @@ find a long option, look for a short option */ if (optno < 0 && cli->could_be_short) { switch_to_short_argument(clp); + clp->negated = cli->whole_negated; optno = find_short(clp, cli->xtext); } @@ -1889,30 +1970,30 @@ if (optno < 0 || (clp->negated && !cli->iopt[optno].ineg)) { /* default processing for the "--" option: turn off option processing and return the next argument */ - if (strcmp(cli->argv[0], "--") == 0) { + if (strcmp(cli->arg, "--") == 0) { Clp_SetOptionProcessing(clp, 0); return Clp_Next(clp); } /* otherwise, report some error or other */ + clp->option = &clp_option_sentinel[-Clp_BadOption]; + cli->current_short = cli->is_short && !cli->could_be_short; + cli->negated_by_no = 0; + /* If the argument could be either long or short, the error message + names the whole argument, so skip the whole argument. */ + if (cli->could_be_short) + cli->is_short = 0; if (cli->ambiguous) ambiguity_error(clp, cli->ambiguous, cli->ambiguous_values, cli->opt, cli->iopt, cli->option_chars, - "option %<%s%s%> is ambiguous", - cli->option_chars, cli->xtext); - else if (cli->is_short && !cli->could_be_short) - Clp_OptionError(clp, "unrecognized option %<%s%C%>", - cli->option_chars, cli->xtext); + "option %<%O%> is ambiguous"); else - Clp_OptionError(clp, "unrecognized option %<%s%s%>", - cli->option_chars, cli->xtext); - - clp->option = &clp_option_sentinel[-Clp_BadOption]; + Clp_OptionError(clp, "unrecognized option %<%O%>"); return Clp_BadOption; } /* Set the current option */ - cli->current_option = optno; + clp->option = &cli->opt[optno]; cli->current_short = cli->is_short; cli->negated_by_no = clp->negated && !cli->whole_negated; @@ -1923,10 +2004,8 @@ Clp_OptionError(clp, "%<%O%> can%,t take an argument"); clp->option = &clp_option_sentinel[-Clp_BadOption]; return Clp_BadOption; - } else { - clp->option = &cli->opt[optno]; + } else return cli->opt[optno].option_id; - } } /* Get an argument if we need one, or if it's optional */ @@ -1972,18 +2051,20 @@ next_argument(clp, 1); /* Parse the argument */ - clp->option = opt; if (clp->have_val) { Clp_ValType *atr = &cli->valtype[vtpos]; if (atr->func(clp, clp->vstr, complain, atr->user_data) <= 0) { /* parser failed */ clp->have_val = 0; if (complain) { + cli->xtext = clpsave.xtext; clp->option = &clp_option_sentinel[-Clp_BadOption]; return Clp_BadOption; } else { + /* optional value rejected: report no value */ Clp_RestoreParser(clp, &clpsave); - clp->option = opt; + clp->vstr = 0; + memset(&clp->val, 0, sizeof(clp->val)); } } } @@ -2026,6 +2107,8 @@ static void build_string_program_prefix(Clp_BuildString* bs, const Clp_Parser* clp); +static void Clp_bsprintf(Clp_Parser *clp, Clp_BuildString *bs, + const char *fmt, ...); static void build_string_init(Clp_BuildString* bs, Clp_Parser* clp) { bs->data = bs->pos = bs->buf; @@ -2048,8 +2131,12 @@ if (bs->data == bs->buf) { if ((bs->data = (char*) malloc(ncap))) memcpy(bs->data, bs->buf, bs->pos - bs->buf); - } else - bs->data = (char*) realloc(bs->data, ncap); + } else { + char* ndata = (char*) realloc(bs->data, ncap); + if (!ndata) + free(bs->data); + bs->data = ndata; + } if (!bs->data) { bs->pos = bs->end_data = bs->data; return 0; @@ -2118,10 +2205,7 @@ case 'C': { const char *s = va_arg(val, const char *); - if (cli->utf8) - c = decode_utf8(s, 0); - else - c = (unsigned char) *s; + c = cli->utf8 ? decode_utf8(s, 0) : (unsigned char) *s; goto char_c; } @@ -2160,27 +2244,39 @@ case 'O': case 'V': { - int optno = cli->current_option; - const Clp_Option *opt = &cli->opt[optno]; - if (optno < 0) - append_build_string(bs, "(no current option!)", -1); - else if (cli->current_short) { - append_build_string(bs, cli->option_chars, -1); + const Clp_Option *opt = clp->option; + int optno = opt_sentinel(clp) ? -1 : (int) (opt - cli->opt); + if (optno < 0) { + if (!opt_error_sentinel(clp) || !cli->xtext) { + append_build_string(bs, "(no current option!)", -1); + } else { + append_build_string(bs, cli->option_chars, -1); + if (clp->have_val && *percent == 'V') { + append_build_string(bs, cli->xtext, -1); + } else if (cli->current_short) { + c = cli->utf8 ? decode_utf8(cli->xtext, 0) : (unsigned char) *cli->xtext; + goto char_c; + } else { + const char* eq = strchr(cli->xtext, '='); + append_build_string(bs, cli->xtext, eq ? eq - cli->xtext : -1); + } + } + break; + } + append_build_string(bs, cli->option_chars, -1); + if (cli->current_short) { if (ENSURE_BUILD_STRING(bs, 5)) { if (cli->utf8) bs->pos = encode_utf8(bs->pos, 5, opt->short_name); else *bs->pos++ = opt->short_name; } - } else if (cli->negated_by_no) { - append_build_string(bs, cli->option_chars, -1); - append_build_string(bs, "no-", 3); - append_build_string(bs, opt->long_name + cli->iopt[optno].ilongoff, -1); } else { - append_build_string(bs, cli->option_chars, -1); + if (cli->negated_by_no) + append_build_string(bs, "no-", 3); append_build_string(bs, opt->long_name + cli->iopt[optno].ilongoff, -1); } - if (optno >= 0 && clp->have_val && *percent == 'V') { + if (clp->have_val && *percent == 'V') { if (cli->current_short && !cli->iopt[optno].ioptional) append_build_string(bs, " ", 1); else if (!cli->current_short) @@ -2206,6 +2302,7 @@ case 0: append_build_string(bs, "%", 1); + fmt = percent; goto done; default: @@ -2223,6 +2320,15 @@ append_build_string(bs, fmt, -1); } +static void +Clp_bsprintf(Clp_Parser *clp, Clp_BuildString *bs, const char *fmt, ...) +{ + va_list val; + va_start(val, fmt); + Clp_vbsprintf(clp, bs, fmt, val); + va_end(val); +} + static const char* build_string_text(Clp_BuildString* bs, int report_oom) { if (bs->pos && ENSURE_BUILD_STRING(bs, 1)) { *bs->pos = 0; @@ -2296,14 +2402,16 @@ { Clp_BuildString bs; va_list val; + int len; va_start(val, format); build_string_init(&bs, clp); Clp_vbsprintf(clp, &bs, format, val); append_build_string(&bs, "\n", 1); va_end(val); do_error(clp, &bs); + len = bs.pos - bs.data; build_string_cleanup(&bs); - return bs.pos - bs.data; + return len; } /** @param clp the parser @@ -2320,14 +2428,16 @@ { Clp_BuildString bs; va_list val; + int len; va_start(val, format); build_string_init(&bs, NULL); Clp_vbsprintf(clp, &bs, format, val); va_end(val); - if (bs.pos != bs.data) - fwrite(bs.data, 1, bs.pos - bs.data, f); + len = bs.pos - bs.data; + if (len > 0) + fwrite(bs.data, 1, len, f); build_string_cleanup(&bs); - return bs.pos - bs.data; + return len; } /** @param clp the parser @@ -2344,12 +2454,14 @@ Clp_vfprintf(Clp_Parser* clp, FILE* f, const char* format, va_list val) { Clp_BuildString bs; + int len; build_string_init(&bs, NULL); Clp_vbsprintf(clp, &bs, format, val); - if (bs.pos != bs.data) - fwrite(bs.data, 1, bs.pos - bs.data, f); + len = bs.pos - bs.data; + if (len > 0) + fwrite(bs.data, 1, len, f); build_string_cleanup(&bs); - return bs.pos - bs.data; + return len; } /** @param clp the parser @@ -2371,17 +2483,20 @@ const char* format, va_list val) { Clp_BuildString bs; + int len; build_string_init(&bs, NULL); Clp_vbsprintf(clp, &bs, format, val); - if ((size_t) (bs.pos - bs.data) < size) { - memcpy(str, bs.data, bs.pos - bs.data); - str[bs.pos - bs.data] = 0; - } else { - memcpy(str, bs.data, size - 1); - str[size - 1] = 0; + len = bs.pos - bs.data; + if (size > 0) { + size_t n = len; + if (n >= size) + n = size - 1; + if (n > 0) + memcpy(str, bs.data, n); + str[n] = 0; } build_string_cleanup(&bs); - return bs.pos - bs.data; + return len; } static int @@ -2398,6 +2513,9 @@ build_string_init(&bs, clp); Clp_vbsprintf(clp, &bs, fmt, val); append_build_string(&bs, "\n", 1); + va_end(val); + if (ambiguous <= 0) + goto done; build_string_program_prefix(&bs, clp); append_build_string(&bs, "(Possibilities are", -1); @@ -2425,95 +2543,47 @@ if (ambiguous > MAX_AMBIGUOUS_VALUES) append_build_string(&bs, ", and others", -1); append_build_string(&bs, ".)\n", -1); - va_end(val); + done: do_error(clp, &bs); build_string_cleanup(&bs); return 0; } -static int -copy_string(char *buf, int buflen, int bufpos, const char *what) -{ - int l = strlen(what); - if (l > buflen - bufpos - 1) - l = buflen - bufpos - 1; - memcpy(buf + bufpos, what, l); - return l; -} - -/** @param clp the parser - * @param buf output buffer - * @param len length of output buffer - * @return number of characters written to the buffer, not including the terminating NUL - * - * A string that looks like the last option parsed by @a clp is extracted into - * @a buf. The correct option characters are put into the string first, - * followed by the option text. The output buffer is null-terminated unless - * @a len == 0. - * - * @sa Clp_CurOptionName - */ -int -Clp_CurOptionNameBuf(Clp_Parser *clp, char *buf, int len) -{ - Clp_Internal *cli = clp->internal; - int optno = cli->current_option; - int pos = 0; - if (optno < 0) - pos += copy_string(buf, len, pos, "(no current option!)"); - else if (cli->current_short) { - pos += copy_string(buf, len, pos, cli->option_chars); - if (cli->utf8) - pos = (encode_utf8(buf + pos, len - pos - 1, cli->opt[optno].short_name) - buf); - else if (pos < len - 1) - buf[pos++] = cli->opt[optno].short_name; - } else if (cli->negated_by_no) { - pos += copy_string(buf, len, pos, cli->option_chars); - pos += copy_string(buf, len, pos, "no-"); - pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff); - } else { - pos += copy_string(buf, len, pos, cli->option_chars); - pos += copy_string(buf, len, pos, cli->opt[optno].long_name + cli->iopt[optno].ilongoff); - } - if (pos < len) - buf[pos] = 0; - return pos; -} - /** @param clp the parser * @return string describing the current option * - * This function acts like Clp_CurOptionNameBuf(), but returns a pointer into - * a static buffer that will be rewritten on the next call to - * Clp_CurOptionName(). + * Returns a string that looks like the last option parsed by @a clp. + * The correct option characters are put into the string first, followed + * by the option text. * * @note This function is not thread safe. - * - * @sa Clp_CurOptionName */ const char * Clp_CurOptionName(Clp_Parser *clp) { - static char buf[256]; - Clp_CurOptionNameBuf(clp, buf, 256); - return buf; + static Clp_BuildString bs; + const char* s; + if (!bs.pos) { + build_string_init(&bs, NULL); + } + bs.pos = bs.data; + Clp_bsprintf(clp, &bs, "%O"); + s = build_string_text(&bs, 0); + return s ? s : ""; } int Clp_IsLong(Clp_Parser *clp, const char *long_name) { - Clp_Internal *cli = clp->internal; - int optno = cli->current_option; - return optno >= 0 && strcmp(cli->opt[optno].long_name, long_name) == 0; + return !opt_sentinel(clp) && clp->option->long_name + && strcmp(clp->option->long_name, long_name) == 0; } int Clp_IsShort(Clp_Parser *clp, int short_name) { - Clp_Internal *cli = clp->internal; - int optno = cli->current_option; - return optno >= 0 && cli->opt[optno].short_name == short_name; + return !opt_sentinel(clp) && clp->option->short_name == short_name; } #ifdef __cplusplus diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/src/quantize.c new/gifsicle-1.99/src/quantize.c --- old/gifsicle-1.98/src/quantize.c 2026-10-14 14:06:53.000000000 +0200 +++ new/gifsicle-1.99/src/quantize.c 2026-11-24 14:03:47.000000000 +0100 @@ -431,7 +431,7 @@ } for (i = old_cm->ncol; i < 256; ++i) { Gif_Color* c = &old_cm->col[i]; - old_kc[i] = kd3_makegfcg(kd3, c); + old_kc[i] = kd3_make8g(kd3, 0, 0, 0); c->pixel = 0; c->haspixel = 1; } @@ -565,7 +565,7 @@ } for (i = old_cm->ncol; i < 256; ++i) { Gif_Color* c = &old_cm->col[i]; - old_kc[i] = kd3_makegfcg(kd3, c); + old_kc[i] = kd3_make8g(kd3, 0, 0, 0); c->pixel = 0; c->haspixel = 1; } @@ -976,7 +976,7 @@ if (transparent < 0) return 0; - if (old_cm) + if (old_cm && transparent < old_cm->ncol) transp_value = old_cm->col[transparent]; else GIF_SETCOLOR(&transp_value, 0, 0, 0); @@ -998,7 +998,9 @@ if (*new_ncol < 256) { assert(*new_ncol < new_cm->capacity); new_transparent = *new_ncol; - new_cm->col[new_transparent] = transp_value; + /* copy only the color: new_cm's `pixel` fields count uses */ + GIF_SETCOLOR(&new_cm->col[new_transparent], transp_value.gfc_red, + transp_value.gfc_green, transp_value.gfc_blue); (*new_ncol)++; goto found; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/src/support.c new/gifsicle-1.99/src/support.c --- old/gifsicle-1.98/src/support.c 2026-10-15 14:16:51.000000000 +0200 +++ new/gifsicle-1.99/src/support.c 2026-11-24 14:03:47.000000000 +0100 @@ -1012,11 +1012,12 @@ if (name && strcmp(name, "-") == 0) name = 0; if (!f) { - my_file = 1; if (!name) f = stdin; - else + else { f = fopen(name, "rb"); + my_file = 1; + } if (!f) { lerror(name, "%s", strerror(errno)); return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/src/win32cfg.h new/gifsicle-1.99/src/win32cfg.h --- old/gifsicle-1.98/src/win32cfg.h 2026-10-15 14:21:07.000000000 +0200 +++ new/gifsicle-1.99/src/win32cfg.h 2026-11-24 16:14:25.000000000 +0100 @@ -107,7 +107,7 @@ #define PACKAGE_NAME "gifsicle" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "gifsicle 1.98" +#define PACKAGE_STRING "gifsicle 1.99" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "gifsicle" @@ -116,7 +116,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.98" +#define PACKAGE_VERSION "1.99" /* Pathname separator character ('/' on Unix). */ #define PATHNAME_SEPARATOR '\\' @@ -144,7 +144,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "1.98 (Windows)" +#define VERSION "1.99 (Windows)" /* Define if X is not available. */ #define X_DISPLAY_MISSING 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/src/xform.c new/gifsicle-1.99/src/xform.c --- old/gifsicle-1.98/src/xform.c 2026-10-15 02:23:37.000000000 +0200 +++ new/gifsicle-1.99/src/xform.c 2026-11-24 01:53:13.000000000 +0100 @@ -416,19 +416,24 @@ kcs->data = kcs->scratch = NULL; } +/* set every pixel of `kcs` to the background */ +static void kcscreen_reset(kcscreen* kcs) { + unsigned i, sz = kcs->width * kcs->height; + if (kcs->data) + for (i = 0; i != sz; ++i) + kcs->data[i] = kcs->bg; +} + /* initialize `kcs` for stream `gfs`. Screen size is `sw`x`sh`; if either component is <= 0, the value of `gfs->screen_*` is taken. */ static void kcscreen_init(kcscreen* kcs, Gif_Stream* gfs, int sw, int sh) { - unsigned i, sz; assert(!kcs->data && !kcs->scratch); kcs->width = sw <= 0 ? gfs->screen_width : sw; kcs->height = sh <= 0 ? gfs->screen_height : sh; - sz = kcs->width * kcs->height; - kcs->data = Gif_NewArray(kacolor, sz); + kcs->data = Gif_NewArray(kacolor, kcs->width * kcs->height); /* the background is transparent, as in browsers */ kcs->bg.a[0] = kcs->bg.a[1] = kcs->bg.a[2] = kcs->bg.a[3] = 0; - for (i = 0; i != sz; ++i) - kcs->data[i] = kcs->bg; + kcscreen_reset(kcs); } /* free memory associated with `kcs` */ @@ -498,19 +503,24 @@ kss->data = kss->scratch = NULL; } +/* set every pixel of `kss` to the background */ +static void ksscreen_reset(ksscreen* kss) { + unsigned i, sz = kss->width * kss->height; + if (kss->data) + for (i = 0; i != sz; ++i) + kss->data[i] = kss->bg; +} + /* initialize `kss` for stream `gfs`. Screen size is `sw`x`sh`; if either component is <= 0, the value of `gfs->screen_*` is taken. */ static void ksscreen_init(ksscreen* kss, Gif_Stream* gfs, int sw, int sh) { - unsigned i, sz; assert(!kss->data && !kss->scratch); kss->width = sw <= 0 ? gfs->screen_width : sw; kss->height = sh <= 0 ? gfs->screen_height : sh; - sz = kss->width * kss->height; - kss->data = Gif_NewArray(scale_color, sz); + kss->data = Gif_NewArray(scale_color, kss->width * kss->height); /* the background is transparent, as in browsers */ sc_clear(&kss->bg); - for (i = 0; i != sz; ++i) - kss->data[i] = kss->bg; + ksscreen_reset(kss); } /* free memory associated with `kss` */ @@ -1307,7 +1317,7 @@ void* scale_image_threaded(void* args) { scale_thread_context* ctx = (scale_thread_context*) args; scale_context sctx; - int imageno; + int imageno, previous_disposal = GIF_DISPOSAL_BACKGROUND; sctx_init(&sctx, ctx->gfs, ctx->nw, ctx->nh); sctx.scale_colors = ctx->scale_colors; while (1) { @@ -1320,9 +1330,20 @@ #endif if (imageno >= ctx->gfs->nimages) break; + /* Frames resized in threads don't depend on earlier frames (see + resize_stream), except that a transparent frame always follows + a frame with background disposal, but a frame followed by an + opaque frame may have ASIS disposal. We may process frames out + of order, so clear the screen if necessary. */ + if (ctx->gfs->images[imageno]->transparent >= 0 + && previous_disposal != GIF_DISPOSAL_BACKGROUND) { + ksscreen_reset(&sctx.iscr); + kcscreen_reset(&sctx.oscr); + } sctx.gfi = ctx->gfs->images[imageno]; sctx.imageno = imageno; scale_image(&sctx, ctx->method); + previous_disposal = sctx.gfi->disposal; } sctx_cleanup(&sctx); return 0; @@ -1383,7 +1404,6 @@ { int nw, nh, i; scale_context sctx; - (void) i; Gif_CalculateScreenSize(gfs, 0); assert(gfs->nimages > 0); @@ -1413,6 +1433,16 @@ && method != SCALE_METHOD_LANCZOS3 && method != SCALE_METHOD_MITCHELL) method = SCALE_METHOD_POINT; + /* Opaque output pixels need a color other than the transparent one. */ + for (i = 0; i < gfs->nimages; ++i) { + Gif_Image* gfi = gfs->images[i]; + Gif_Colormap* gfcm = gfi->local ? gfi->local : gfs->global; + if (gfcm && gfcm->ncol == 1 && gfi->transparent == 0) { + Gif_Color gfc = gfcm->col[0]; + Gif_AddColor(gfcm, &gfc, -1); + } + } + if (nthreads > gfs->nimages) nthreads = gfs->nimages; sctx_init(&sctx, gfs, nw, nh); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/test/022-threadresize.testie new/gifsicle-1.99/test/022-threadresize.testie --- old/gifsicle-1.98/test/022-threadresize.testie 1970-01-01 01:00:00.000000000 +0100 +++ new/gifsicle-1.99/test/022-threadresize.testie 2026-11-24 01:53:13.000000000 +0100 @@ -0,0 +1,16 @@ +%script +# threaded resizing matches unthreaded: frame 2 is transparent and follows +# a frame with background disposal, so it composites over a cleared screen +gifsicle --resize 7x7 thr.gif -o serial.gif +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + gifsicle -j2 --resize 7x7 thr.gif -o threaded.gif + cmp -s serial.gif threaded.gif || echo "run $i differs" +done +echo done + +%file -e thr.gif +R0lGODlhBAAEAPEAAP8AAAAA/wD/AAAAACwAAAAABAAEAAAICQABCBxIsCCAgAAh+QQIAAAAACwA +AAAABAAEAAAICQADCBxIsGCAgAAh+QQBAAADACwAAAAABAAEAAAICwAFDBBIcKDBggEBADs= + +%expect stdout +done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/gifsicle-1.98/test/023-resizeonecolor.testie new/gifsicle-1.99/test/023-resizeonecolor.testie --- old/gifsicle-1.98/test/023-resizeonecolor.testie 1970-01-01 01:00:00.000000000 +0100 +++ new/gifsicle-1.99/test/023-resizeonecolor.testie 2026-11-24 01:53:13.000000000 +0100 @@ -0,0 +1,22 @@ +%script +# frame 2's transparent index is the colormap's only color, but resizing +# blends opaque pixels into it, so the colormap gains an opaque copy +gifsicle --resize 1x2 one.gif -o out.gif +gifsicle --careful --resize 1x2 one.gif -o careful.gif +gifdiff out.gif careful.gif && echo same +gifsicle --cinfo out.gif 2>&1 | grep -v '^\*' + +%file -e one.gif +R0lGODlhAQAEAPAAAP8AAAAAACwAAAAAAQAEAAACAoRRACH5BAkAAAAALAAAAQABAAMAAAIChAsA +IfkEAQAAAAAsAAAAAAEABAAAAgKEUQA7 + +%expect stdout +same + logical screen 1x2 + global color table [2] + | 0: #FF0000 1: #FF0000 + background 0 + + image #0 1x2 + + image #1 1x2 transparent 0 + disposal background + + image #2 1x2 transparent 0
