Hello community, here is the log from the commit of package xcursorgen for openSUSE:Factory checked in at 2019-01-15 13:13:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/xcursorgen (Old) and /work/SRC/openSUSE:Factory/.xcursorgen.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xcursorgen" Tue Jan 15 13:13:25 2019 rev:7 rq:663359 version:1.0.7 Changes: -------- --- /work/SRC/openSUSE:Factory/xcursorgen/xcursorgen.changes 2014-06-05 10:50:12.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.xcursorgen.new.28833/xcursorgen.changes 2019-01-15 13:13:26.884495439 +0100 @@ -1,0 +2,18 @@ +Mon Jan 7 13:42:57 UTC 2019 - [email protected] + +- Update to version 1.0.7 + * configure: Drop AM_MAINTAINER_MODE + * autogen.sh: Honor NOCONFIGURE=1 + * Fix type mismatch warnings for loop index variables + * Include more information in error messages + * Use asprintf if available, instead of malloc+strcpy+strcat + * Convert to X.Org standard code style + * Update README for gitlab migration + * Add README.md to EXTRA_DIST in Makefile.am + * Update configure.ac bug URL for gitlab migration + * autogen.sh: use quoted string variables + * autogen: add default patch prefix + * autogen.sh: use exec instead of waiting for configure to finish + * Fix null pointer dereference on very large images. + +------------------------------------------------------------------- Old: ---- xcursorgen-1.0.6.tar.bz2 New: ---- xcursorgen-1.0.7.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ xcursorgen.spec ++++++ --- /var/tmp/diff_new_pack.2u8VDc/_old 2019-01-15 13:13:27.336495086 +0100 +++ /var/tmp/diff_new_pack.2u8VDc/_new 2019-01-15 13:13:27.336495086 +0100 @@ -1,7 +1,7 @@ # # spec file for package xcursorgen # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: xcursorgen -Version: 1.0.6 +Version: 1.0.7 Release: 0 Summary: Utility to create an X cursor file from a collection of PNG images License: MIT @@ -48,7 +48,7 @@ %files %defattr(-,root,root) -%doc AUTHORS ChangeLog COPYING README +%doc AUTHORS ChangeLog COPYING README.md %{_bindir}/xcursorgen %{_mandir}/man1/xcursorgen.1%{?ext_man} ++++++ xcursorgen-1.0.6.tar.bz2 -> xcursorgen-1.0.7.tar.bz2 ++++++ ++++ 10437 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/xcursorgen-1.0.6/ChangeLog new/xcursorgen-1.0.7/ChangeLog --- old/xcursorgen-1.0.6/ChangeLog 2014-06-01 01:33:37.000000000 +0200 +++ new/xcursorgen-1.0.7/ChangeLog 2019-01-07 00:20:53.000000000 +0100 @@ -1,3 +1,137 @@ +commit 291d9a052aec0ad4a315c09a9af8b451c94ed57a +Author: Alan Coopersmith <[email protected]> +Date: Sun Jan 6 15:17:17 2019 -0800 + + xcursorgen 1.0.7 + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit 6be3f22358014834b7f38a0434c500292e081beb +Author: Alan Coopersmith <[email protected]> +Date: Wed Nov 21 17:00:47 2018 -0800 + + Update configure.ac bug URL for gitlab migration + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit 1b627b744ce604a9546f1ecb4379d1f73d8e81ed +Author: Alan Coopersmith <[email protected]> +Date: Fri Nov 16 18:17:58 2018 -0800 + + Add README.md to EXTRA_DIST in Makefile.am + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit 95d577ac15263362e65b7a667adbb462c0c5ff05 +Author: Alan Coopersmith <[email protected]> +Date: Mon Nov 12 11:53:39 2018 -0800 + + Update README for gitlab migration + + Signed-off-by: Alan Coopersmith <[email protected]> + Reviewed-by: Peter Hutterer <[email protected]> + +commit 29094ff258861dba611f029202a1ab0aa3b71a0e +Author: Alan Coopersmith <[email protected]> +Date: Sat Aug 25 15:05:46 2018 -0700 + + Convert to X.Org standard code style + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit 7f00938c6d4499d78b61feaddb4bfb6af00f6e26 +Author: Alan Coopersmith <[email protected]> +Date: Sat Aug 25 14:47:01 2018 -0700 + + Use asprintf if available, instead of malloc+strcpy+strcat + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit 538ddd32790f0031357807b1b0c6c10879607209 +Author: Alan Coopersmith <[email protected]> +Date: Sat Aug 25 14:45:36 2018 -0700 + + Include more information in error messages + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit fa1bb8ee9cc190416902a5929ac5cddfb6d6304b +Author: Alan Coopersmith <[email protected]> +Date: Sat Aug 25 13:59:19 2018 -0700 + + Fix type mismatch warnings for loop index variables + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit f04b349f8dce94c7efaee48049829e6a17a3a60a +Author: Tobias Stoeckmann <[email protected]> +Date: Mon Jun 25 09:02:24 2018 +0200 + + Fix null pointer dereference on very large images. + + If xcursorgen encounters a PNG file which is larger than 32767 pixels + in width or height, a null pointer dereference occurs because the + return value of XcursorImageCreate is not checked. + + The largest possible value is 32767 for libXcursor, which is a hard + coded limit due to a 16 bit integer used (0x7FFF). + + Fixes: https://gitlab.freedesktop.org/xorg/app/xcursorgen/issues/1 + + Signed-off-by: Tobias Stoeckmann <[email protected]> + Reviewed-by: Alan Coopersmith <[email protected]> + Signed-off-by: Alan Coopersmith <[email protected]> + +commit f66844351bbf5ca5c1697b2092941d4db65a9e87 +Author: Mihail Konev <[email protected]> +Date: Thu Jan 26 14:00:20 2017 +1000 + + autogen: add default patch prefix + + Signed-off-by: Mihail Konev <[email protected]> + +commit 58ddf95244f25ee04982b707d2bd6a664149e5ba +Author: Emil Velikov <[email protected]> +Date: Mon Mar 9 12:00:52 2015 +0000 + + autogen.sh: use quoted string variables + + Place quotes around the $srcdir, $ORIGDIR and $0 variables to prevent + fall-outs, when they contain space. + + Signed-off-by: Emil Velikov <[email protected]> + Reviewed-by: Peter Hutterer <[email protected]> + Signed-off-by: Peter Hutterer <[email protected]> + +commit 46d8acc5a3886002fdab484a6a45c6e1ea4ad939 +Author: Peter Hutterer <[email protected]> +Date: Tue Jan 24 10:32:07 2017 +1000 + + autogen.sh: use exec instead of waiting for configure to finish + + Syncs the invocation of configure with the one from the server. + + Signed-off-by: Peter Hutterer <[email protected]> + Reviewed-by: Emil Velikov <[email protected]> + +commit 3b80e52aa8648f8eebbe69ff30534786d4e84342 +Author: Alan Coopersmith <[email protected]> +Date: Sat May 31 21:39:32 2014 -0700 + + autogen.sh: Honor NOCONFIGURE=1 + + See http://people.gnome.org/~walters/docs/build-api.txt + + Signed-off-by: Alan Coopersmith <[email protected]> + +commit 3f16a99240cf124ac189a15118f516cf7c0d0c41 +Author: Alan Coopersmith <[email protected]> +Date: Sat May 31 21:38:41 2014 -0700 + + configure: Drop AM_MAINTAINER_MODE + + Signed-off-by: Alan Coopersmith <[email protected]> + commit 68939d23da457d4beeab73fca644b5c68224bdd3 Author: Alan Coopersmith <[email protected]> Date: Sat May 31 16:33:07 2014 -0700 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/xcursorgen-1.0.6/Makefile.am new/xcursorgen-1.0.7/Makefile.am --- old/xcursorgen-1.0.6/Makefile.am 2014-06-01 01:33:10.000000000 +0200 +++ new/xcursorgen-1.0.7/Makefile.am 2019-01-07 00:20:43.000000000 +0100 @@ -18,3 +18,5 @@ $(CHANGELOG_CMD) dist-hook: ChangeLog INSTALL + +EXTRA_DIST = README.md 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/xcursorgen-1.0.6/README new/xcursorgen-1.0.7/README --- old/xcursorgen-1.0.6/README 2014-06-01 01:33:10.000000000 +0200 +++ new/xcursorgen-1.0.7/README 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ -xcursorgen prepares X11 cursor sets for use with libXcursor. - -All questions regarding this software should be directed at the -Xorg mailing list: - - http://lists.freedesktop.org/mailman/listinfo/xorg - -Please submit bug reports to the Xorg bugzilla: - - https://bugs.freedesktop.org/enter_bug.cgi?product=xorg - -The master development code repository can be found at: - - git://anongit.freedesktop.org/git/xorg/app/xcursorgen - - http://cgit.freedesktop.org/xorg/app/xcursorgen - -For patch submission instructions, see: - - http://www.x.org/wiki/Development/Documentation/SubmittingPatches - -For more information on the git code manager, see: - - http://wiki.x.org/wiki/GitPage - 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/xcursorgen-1.0.6/README.md new/xcursorgen-1.0.7/README.md --- old/xcursorgen-1.0.6/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/xcursorgen-1.0.7/README.md 2019-01-07 00:20:43.000000000 +0100 @@ -0,0 +1,17 @@ +xcursorgen prepares X11 cursor sets for use with libXcursor. + +All questions regarding this software should be directed at the +Xorg mailing list: + + https://lists.x.org/mailman/listinfo/xorg + +The master development code repository can be found at: + + https://gitlab.freedesktop.org/xorg/app/xcursorgen + +Please submit bug reports and requests to merge patches there. + +For patch submission instructions, see: + + https://www.x.org/wiki/Development/Documentation/SubmittingPatches + 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/xcursorgen-1.0.6/compile new/xcursorgen-1.0.7/compile --- old/xcursorgen-1.0.6/compile 2014-06-01 01:33:17.000000000 +0200 +++ new/xcursorgen-1.0.7/compile 2019-01-07 00:20:47.000000000 +0100 @@ -3,7 +3,7 @@ scriptversion=2012-10-14.11; # UTC -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # Written by Tom Tromey <[email protected]>. # # This program is free software; you can redistribute it and/or modify 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/xcursorgen-1.0.6/config.h.in new/xcursorgen-1.0.7/config.h.in --- old/xcursorgen-1.0.6/config.h.in 2014-06-01 01:33:16.000000000 +0200 +++ new/xcursorgen-1.0.7/config.h.in 2019-01-07 00:20:46.000000000 +0100 @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Define to 1 if you have the `asprintf' function. */ +#undef HAVE_ASPRINTF + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H @@ -60,5 +63,37 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + /* Version number of package */ #undef VERSION + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE 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/xcursorgen-1.0.6/configure.ac new/xcursorgen-1.0.7/configure.ac --- old/xcursorgen-1.0.6/configure.ac 2014-06-01 01:33:10.000000000 +0200 +++ new/xcursorgen-1.0.7/configure.ac 2019-01-07 00:20:43.000000000 +0100 @@ -3,15 +3,15 @@ # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([xcursorgen], - [1.0.6], - [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], + [1.0.7], + [https://gitlab.freedesktop.org/xorg/app/xcursorgen/issues], [xcursorgen]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) +AC_USE_SYSTEM_EXTENSIONS # Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2]) -AM_MAINTAINER_MODE # Require xorg-macros 1.8 or later: XORG_MANPAGE_SECTIONS m4_ifndef([XORG_MACROS_VERSION], @@ -22,6 +22,8 @@ # Checks for pkg-config packages PKG_CHECK_MODULES(XCURSORGEN, x11 xcursor libpng >= 1.2.0) +AC_CHECK_FUNCS([asprintf]) + AC_CONFIG_FILES([ Makefile man/Makefile]) 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/xcursorgen-1.0.6/missing new/xcursorgen-1.0.7/missing --- old/xcursorgen-1.0.6/missing 2014-06-01 01:33:17.000000000 +0200 +++ new/xcursorgen-1.0.7/missing 2019-01-07 00:20:47.000000000 +0100 @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2012-06-26.16; # UTC +scriptversion=2013-10-28.13; # UTC -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <[email protected]>, 1996. # This program is free software; you can redistribute it and/or modify @@ -160,7 +160,7 @@ ;; autom4te*) echo "You might have modified some maintainer files that require" - echo "the 'automa4te' program to be rebuilt." + echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) 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/xcursorgen-1.0.6/xcursorgen.c new/xcursorgen-1.0.7/xcursorgen.c --- old/xcursorgen-1.0.6/xcursorgen.c 2014-06-01 01:33:10.000000000 +0200 +++ new/xcursorgen-1.0.7/xcursorgen.c 2019-01-07 00:20:43.000000000 +0100 @@ -28,6 +28,7 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <errno.h> #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -35,410 +36,414 @@ #include <png.h> -struct flist -{ - int size; - int xhot, yhot; - int delay; - char *pngfile; - struct flist *next; +static const char *ProgramName; + +struct flist { + int size; + int xhot, yhot; + int delay; + char *pngfile; + struct flist *next; }; static void -usage (const char *name) +usage(const char *name) { - fprintf (stderr, - "usage: %s [-V] [--version] [-?] [--help] [-p <dir>] [--prefix <dir>] [CONFIG [OUT]]\n%s", - name, - "Generate an Xcursor file from a series of PNG images\n" - "\n" - " -V, --version display the version number and exit\n" - " -?, --help display this message and exit\n" - " -p, --prefix <dir> find cursor images in <dir>\n" - "\n" - "With no CONFIG, or when CONFIG is -, read standard input. " - "Same with OUT and\n" - "standard output.\n"); + fprintf(stderr, + "usage: %s [-V] [--version] [-?] [--help] [-p <dir>] [--prefix <dir>] [CONFIG [OUT]]\n%s", + name, + "Generate an Xcursor file from a series of PNG images\n" + "\n" + " -V, --version display the version number and exit\n" + " -?, --help display this message and exit\n" + " -p, --prefix <dir> find cursor images in <dir>\n" + "\n" + "With no CONFIG, or when CONFIG is -, read standard input. " + "Same with OUT and\n" + "standard output.\n"); } static int -read_config_file (const char *config, struct flist **list) +read_config_file(const char *config, struct flist **list) { - FILE *fp; - char line[4096], pngfile[4000]; - int size, xhot, yhot, delay; - struct flist *start = NULL, *end = NULL, *curr; - int count = 0; - - if (strcmp (config, "-") != 0) - { - fp = fopen (config, "r"); - if (!fp) - { - *list = NULL; - return 0; - } - } - else - fp = stdin; - - while (fgets (line, sizeof (line), fp) != NULL) - { - if (line[0] == '#') - continue; - - switch (sscanf (line, "%d %d %d %3999s %d", &size, &xhot, &yhot, pngfile, &delay)) - { - case 4: - delay = 50; - break; - case 5: - break; - default: - { - fprintf (stderr, "Bad config file data!\n"); - fclose (fp); - return 0; - } - } - - curr = malloc (sizeof (struct flist)); - if (curr == NULL) - { - fprintf (stderr, "malloc() failed\n"); - fclose (fp); - return 0; - } - - curr->size = size; - curr->xhot = xhot; - curr->yhot = yhot; - - curr->delay = delay; - - curr->pngfile = strdup (pngfile); - if (curr->pngfile == NULL) - { - fprintf (stderr, "strdup() failed\n"); - fclose (fp); - free(curr); - return 0; - } - - curr->next = NULL; - - if (start) - { - end->next = curr; - end = curr; - } - else - { - start = curr; - end = curr; + FILE *fp; + char line[4096], pngfile[4000]; + int size, xhot, yhot, delay; + struct flist *start = NULL, *end = NULL, *curr; + int count = 0; + + if (strcmp(config, "-") != 0) { + fp = fopen(config, "r"); + if (!fp) { + *list = NULL; + return 0; + } + } + else + fp = stdin; + + while (fgets(line, sizeof(line), fp) != NULL) { + if (line[0] == '#') + continue; + + switch (sscanf (line, "%d %d %d %3999s %d", &size, &xhot, &yhot, + pngfile, &delay)) { + case 4: + delay = 50; + break; + case 5: + break; + default: + { + fprintf(stderr, "%s: Bad config file data on line %d of %s\n", + ProgramName, count + 1, + strcmp(config, "-") ? config : "stdin"); + fclose(fp); + return 0; + } } - count++; + curr = malloc(sizeof(struct flist)); + if (curr == NULL) { + fprintf(stderr, "%s: malloc() failed: %s\n", + ProgramName, strerror(errno)); + fclose(fp); + return 0; + } + + curr->size = size; + curr->xhot = xhot; + curr->yhot = yhot; + + curr->delay = delay; + + curr->pngfile = strdup(pngfile); + if (curr->pngfile == NULL) { + fprintf(stderr, "%s: strdup() failed: %s\n", + ProgramName, strerror(errno)); + fclose(fp); + free(curr); + return 0; + } + + curr->next = NULL; + + if (start) { + end->next = curr; + end = curr; + } + else { + start = curr; + end = curr; + } + + count++; } - fclose (fp); + fclose(fp); - *list = start; - return count; + *list = start; + return count; } #define div_255(x) (((x) + 0x80 + (((x) + 0x80) >> 8)) >> 8) static void -premultiply_data (png_structp png, png_row_infop row_info, png_bytep data) +premultiply_data(png_structp png, png_row_infop row_info, png_bytep data) { - int i; + png_size_t i; - for (i = 0; i < row_info->rowbytes; i += 4) - { - unsigned char *base = &data[i]; - unsigned char blue = base[0]; - unsigned char green = base[1]; - unsigned char red = base[2]; - unsigned char alpha = base[3]; - XcursorPixel p; - - red = div_255((unsigned)red * (unsigned)alpha); - green = div_255((unsigned)green * (unsigned)alpha); - blue = div_255((unsigned)blue * (unsigned)alpha); - p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); - memcpy (base, &p, sizeof (XcursorPixel)); + for (i = 0; i < row_info->rowbytes; i += 4) { + unsigned char *base = &data[i]; + unsigned char blue = base[0]; + unsigned char green = base[1]; + unsigned char red = base[2]; + unsigned char alpha = base[3]; + XcursorPixel p; + + red = div_255((unsigned) red * (unsigned) alpha); + green = div_255((unsigned) green * (unsigned) alpha); + blue = div_255((unsigned) blue * (unsigned) alpha); + p = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); + memcpy(base, &p, sizeof(XcursorPixel)); } } static XcursorImage * -load_image (struct flist *list, const char *prefix) +load_image(struct flist *list, const char *prefix) { - XcursorImage *image; - png_structp png; - png_infop info; - png_bytepp rows; - FILE *fp; - int i; - png_uint_32 width, height; - int depth, color, interlace; - char *file; - - png = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png == NULL) - return NULL; - - info = png_create_info_struct (png); - if (info == NULL) - { - png_destroy_read_struct (&png, NULL, NULL); - return NULL; - } - - if (setjmp (png_jmpbuf(png))) - { - png_destroy_read_struct (&png, &info, NULL); - return NULL; - } - - if (prefix) - { - file = malloc (strlen (prefix) + 1 + strlen (list->pngfile) + 1); - if (file == NULL) - { - fprintf (stderr, "malloc() failed\n"); - png_destroy_read_struct (&png, &info, NULL); - return NULL; - } - strcpy (file, prefix); - strcat (file, "/"); - strcat (file, list->pngfile); + XcursorImage *image; + png_structp png; + png_infop info; + png_bytepp rows; + FILE *fp; + png_uint_32 i; + png_uint_32 width, height; + int depth, color, interlace; + char *file; + + png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png == NULL) + return NULL; + + info = png_create_info_struct(png); + if (info == NULL) { + png_destroy_read_struct(&png, NULL, NULL); + return NULL; + } + + if (setjmp(png_jmpbuf(png))) { + png_destroy_read_struct(&png, &info, NULL); + return NULL; + } + + if (prefix) { +#ifdef HAVE_ASPRINTF + if (asprintf(&file, "%s/%s", prefix, list->pngfile) == -1) { + fprintf(stderr, "%s: asprintf() failed: %s\n", + ProgramName, strerror(errno)); + png_destroy_read_struct(&png, &info, NULL); + return NULL; + } +#else + file = malloc(strlen(prefix) + 1 + strlen(list->pngfile) + 1); + if (file == NULL) { + fprintf(stderr, "%s: malloc() failed: %s\n", + ProgramName, strerror(errno)); + png_destroy_read_struct(&png, &info, NULL); + return NULL; + } + strcpy(file, prefix); + strcat(file, "/"); + strcat(file, list->pngfile); +#endif } - else - file = list->pngfile; - fp = fopen (file, "rb"); - if (prefix) - free (file); + else + file = list->pngfile; + fp = fopen(file, "rb"); + if (prefix) + free(file); - if (fp == NULL) - { - png_destroy_read_struct (&png, &info, NULL); - return NULL; + if (fp == NULL) { + png_destroy_read_struct(&png, &info, NULL); + return NULL; } - png_init_io (png, fp); - png_read_info (png, info); - png_get_IHDR (png, info, &width, &height, &depth, &color, &interlace, - NULL, NULL); + png_init_io(png, fp); + png_read_info(png, info); + png_get_IHDR(png, info, &width, &height, &depth, &color, &interlace, + NULL, NULL); - /* TODO: More needs to be done here maybe */ + /* TODO: More needs to be done here maybe */ - if (color == PNG_COLOR_TYPE_PALETTE && depth <= 8) - png_set_expand (png); + if (color == PNG_COLOR_TYPE_PALETTE && depth <= 8) + png_set_expand(png); - if (color == PNG_COLOR_TYPE_GRAY && depth < 8) - png_set_expand (png); + if (color == PNG_COLOR_TYPE_GRAY && depth < 8) + png_set_expand(png); - if (png_get_valid (png, info, PNG_INFO_tRNS)) - png_set_expand (png); + if (png_get_valid(png, info, PNG_INFO_tRNS)) + png_set_expand(png); - if (depth == 16) - png_set_strip_16 (png); + if (depth == 16) + png_set_strip_16(png); - if (depth < 8) - png_set_packing (png); + if (depth < 8) + png_set_packing(png); - if (color == PNG_COLOR_TYPE_GRAY || color == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb (png); + if (color == PNG_COLOR_TYPE_GRAY || color == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png); - if (interlace != PNG_INTERLACE_NONE) - png_set_interlace_handling (png); + if (interlace != PNG_INTERLACE_NONE) + png_set_interlace_handling(png); - png_set_bgr (png); - png_set_filler (png, 255, PNG_FILLER_AFTER); + png_set_bgr(png); + png_set_filler(png, 255, PNG_FILLER_AFTER); - png_set_read_user_transform_fn (png, premultiply_data); + png_set_read_user_transform_fn(png, premultiply_data); - png_read_update_info (png, info); + png_read_update_info(png, info); - image = XcursorImageCreate (width, height); + image = XcursorImageCreate(width, height); + if (image == NULL) { + fprintf (stderr, + "%s: XcursorImageCreate() failed to create %u x %u image\n" + " for file %s\n", + ProgramName, width, height, list->pngfile); + fclose(fp); + png_destroy_read_struct(&png, &info, NULL); + return NULL; + } - image->size = list->size; - image->xhot = list->xhot; - image->yhot = list->yhot; - image->delay = list->delay; + image->size = list->size; + image->xhot = list->xhot; + image->yhot = list->yhot; + image->delay = list->delay; - rows = malloc (sizeof (png_bytep) * height); - if (rows == NULL) - { - fclose (fp); - png_destroy_read_struct (&png, &info, NULL); - return NULL; + rows = malloc(sizeof(png_bytep) * height); + if (rows == NULL) { + fclose(fp); + png_destroy_read_struct(&png, &info, NULL); + return NULL; } - for (i = 0; i < height; i++) - rows[i] = (png_bytep) (image->pixels + i * width); + for (i = 0; i < height; i++) + rows[i] = (png_bytep) (image->pixels + i * width); - png_read_image (png, rows); - png_read_end (png, info); + png_read_image(png, rows); + png_read_end(png, info); - free (rows); - fclose (fp); - png_destroy_read_struct (&png, &info, NULL); + free(rows); + fclose(fp); + png_destroy_read_struct(&png, &info, NULL); - return image; + return image; } static int -write_cursors (int count, struct flist *list, - const char *filename, const char *prefix) +write_cursors(int count, struct flist *list, + const char *filename, const char *prefix) { - XcursorImages *cimages; - XcursorImage *image; - int i; - FILE *fp; - int ret; - - if (strcmp (filename, "-") != 0) - { - fp = fopen (filename, "wb"); - if (!fp) - return 1; - } - else - fp = stdout; - - cimages = XcursorImagesCreate (count); - - cimages->nimage = count; - - for (i = 0; i < count; i++, list = list->next) - { - image = load_image (list, prefix); - if (image == NULL) - { - fprintf (stderr, "PNG error while reading %s!\n", list->pngfile); - fclose(fp); - return 1; - } + XcursorImages *cimages; + XcursorImage *image; + int i; + FILE *fp; + int ret; + + if (strcmp(filename, "-") != 0) { + fp = fopen(filename, "wb"); + if (!fp) + return 1; + } + else + fp = stdout; + + cimages = XcursorImagesCreate(count); + + cimages->nimage = count; + + for (i = 0; i < count; i++, list = list->next) { + image = load_image(list, prefix); + if (image == NULL) { + fprintf(stderr, "%s: PNG error while reading %s\n", + ProgramName, list->pngfile); + fclose(fp); + return 1; + } - cimages->images[i] = image; + cimages->images[i] = image; } - ret = XcursorFileSaveImages (fp, cimages); + ret = XcursorFileSaveImages(fp, cimages); - fclose (fp); + fclose(fp); - return ret ? 0 : 1; + return ret ? 0 : 1; } static int -check_image (char *image) +check_image(char *image) { - unsigned int width, height; - unsigned char *data; - int x_hot, y_hot; - unsigned char hash[XCURSOR_BITMAP_HASH_SIZE]; - int i; - - if (XReadBitmapFileData (image, &width, &height, &data, &x_hot, &y_hot) != BitmapSuccess) - { - fprintf (stderr, "Can't open bitmap file \"%s\"\n", image); - return 1; - } - else { - XImage ximage = { - .width = width, - .height = height, - .depth = 1, - .bits_per_pixel = 1, - .xoffset = 0, - .format = XYPixmap, - .data = (char *)data, - .byte_order = LSBFirst, - .bitmap_unit = 8, - .bitmap_bit_order = LSBFirst, - .bitmap_pad = 8, - .bytes_per_line = (width+7)/8 - }; - XcursorImageHash (&ximage, hash); - } - printf ("%s: ", image); - for (i = 0; i < XCURSOR_BITMAP_HASH_SIZE; i++) - printf ("%02x", hash[i]); - printf ("\n"); - return 0; + unsigned int width, height; + unsigned char *data; + int x_hot, y_hot; + unsigned char hash[XCURSOR_BITMAP_HASH_SIZE]; + int i; + + if (XReadBitmapFileData(image, &width, &height, &data, &x_hot, &y_hot) + != BitmapSuccess) { + fprintf(stderr, "%s: Can't open bitmap file \"%s\"\n", ProgramName, + image); + return 1; + } + else { + XImage ximage = { + .width = width, + .height = height, + .depth = 1, + .bits_per_pixel = 1, + .xoffset = 0, + .format = XYPixmap, + .data = (char *) data, + .byte_order = LSBFirst, + .bitmap_unit = 8, + .bitmap_bit_order = LSBFirst, + .bitmap_pad = 8, + .bytes_per_line = (width + 7) / 8 + }; + XcursorImageHash(&ximage, hash); + } + printf("%s: ", image); + for (i = 0; i < XCURSOR_BITMAP_HASH_SIZE; i++) + printf("%02x", hash[i]); + printf("\n"); + return 0; } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { - struct flist *list; - int count; - const char *in = NULL, *out = NULL; - const char *prefix = NULL; - int i; - - for (i = 1; i < argc; i++) - { - if (strcmp (argv[i], "-V") == 0 || strcmp (argv[i], "--version") == 0) - { - printf ("xcursorgen version %s\n", PACKAGE_VERSION); - return 0; - } - - if (strcmp (argv[i], "-?") == 0 || strcmp (argv[i], "--help") == 0) - { - usage (argv[0]); - return 0; - } - if (strcmp (argv[i], "-image") == 0) - { - int ret = 0; - while (argv[++i]) - { - if (check_image (argv[i])) - ret = i; - } - return ret; - } - if (strcmp (argv[i], "-p") == 0 || strcmp (argv[i], "--prefix") == 0) - { - i++; - if (argv[i] == NULL) - { - fprintf (stderr, "%s: %s requires an argument\n", - argv[0], argv[i-1]); - usage (argv[0]); - return 1; - } - prefix = argv[i]; - continue; - } - - if (!in) - in = argv[i]; - else if (!out) - out = argv[i]; - else - { - fprintf (stderr, "%s: unexpected argument '%s'\n", argv[0], argv[i]); - usage (argv[0]); - return 1; - } - } - - if (!in) - in = "-"; - if (!out) - out = "-"; - - count = read_config_file (in, &list); - if (count == 0) - { - fprintf (stderr, "Error reading config file!\n"); - return 1; + struct flist *list; + int count; + const char *in = NULL, *out = NULL; + const char *prefix = NULL; + int i; + + ProgramName = argv[0]; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) { + printf("xcursorgen version %s\n", PACKAGE_VERSION); + return 0; + } + + if (strcmp(argv[i], "-?") == 0 || strcmp(argv[i], "--help") == 0) { + usage(argv[0]); + return 0; + } + if (strcmp(argv[i], "-image") == 0) { + int ret = 0; + + while (argv[++i]) { + if (check_image(argv[i])) + ret = i; + } + return ret; + } + if (strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--prefix") == 0) { + i++; + if (argv[i] == NULL) { + fprintf(stderr, "%s: %s requires an argument\n", + argv[0], argv[i - 1]); + usage(argv[0]); + return 1; + } + prefix = argv[i]; + continue; + } + + if (!in) + in = argv[i]; + else if (!out) + out = argv[i]; + else { + fprintf(stderr, "%s: unexpected argument '%s'\n", argv[0], argv[i]); + usage(argv[0]); + return 1; + } + } + + if (!in) + in = "-"; + if (!out) + out = "-"; + + count = read_config_file(in, &list); + if (count == 0) { + fprintf(stderr, "%s: Error reading config file %s\n", argv[0], + strcmp(in, "-") ? in : "from stdin"); + return 1; } - return write_cursors (count, list, out, prefix); + return write_cursors(count, list, out, prefix); }
