[packages/xplanet] - updated to 1.3.1 - removed obsolete giflib patch (upstream supports giflib up to 5.0) - added gifl

qboosh qboosh at pld-linux.org
Mon Dec 24 12:13:24 CET 2018


commit 2d4614e54c41e65bad5a6ce6ae2602d46430c7e8
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Mon Dec 24 12:18:05 2018 +0100

    - updated to 1.3.1
    - removed obsolete giflib patch (upstream supports giflib up to 5.0)
    - added giflib patch to support giflib 5.1
    - added c++ patch (don't include standard C headers inside a namespace), compile in C++98 mode

 files-xplanet-1.3.0-giflib.patch | 741 ---------------------------------------
 xplanet-gcc43.patch              | 115 ------
 xplanet.spec                     |  38 +-
 3 files changed, 23 insertions(+), 871 deletions(-)
---
diff --git a/xplanet.spec b/xplanet.spec
index fcbca42..084fd49 100644
--- a/xplanet.spec
+++ b/xplanet.spec
@@ -1,27 +1,32 @@
+# TODO: cspice
 Summary:	Render a planetary image into an X window
 Summary(pl.UTF-8):	Renderuje obrazek planety w okienku X window
 Name:		xplanet
-Version:	1.3.0
-Release:	4
-License:	GPL
+Version:	1.3.1
+Release:	1
+License:	GPL v2
 Group:		X11/Amusements
 Source0:	http://downloads.sourceforge.net/xplanet/%{name}-%{version}.tar.gz
-# Source0-md5:	41f7db2ccd1d8b4b989cacaf9adfe692
-Patch0:		files-xplanet-1.3.0-giflib.patch
+# Source0-md5:	9797dbd9697d10205ca1671f728ea30d
+Patch0:		%{name}-c++.patch
+Patch1:		%{name}-giflib.patch
 URL:		http://xplanet.sourceforge.net/
 BuildRequires:	autoconf >= 2.50
 BuildRequires:	automake
-BuildRequires:	freetype-devel
+BuildRequires:	freetype-devel >= 2
 BuildRequires:	gettext-tools
-BuildRequires:	giflib4-devel
+BuildRequires:	giflib-devel
 BuildRequires:	libjpeg-devel
 BuildRequires:	libpng-devel
 BuildRequires:	libstdc++-devel
 BuildRequires:	libtiff-devel
 BuildRequires:	netpbm-devel
-BuildRequires:	pango-devel
+BuildRequires:	pango-devel >= 1:1.2.0
 BuildRequires:	pkgconfig
+BuildRequires:	xorg-lib-libX11-devel
 BuildRequires:	xorg-lib-libXScrnSaver-devel
+BuildRequires:	xorg-lib-libXext-devel
+Requires:	pango >= 1:1.2.0
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -41,20 +46,23 @@ lądowe. Strona domowa Xplanet zawiera odnośniki do plików z mapami.
 
 %prep
 %setup -q
-%patch0 -p0
+%patch0 -p1
+%patch1 -p1
 
 %build
 %{__aclocal}
 %{__autoconf}
 %{__autoheader}
 %{__automake}
+# current code doesn't build in C++11 mode
+CXXFLAGS="%{rpmcxxflags} -std=gnu++98"
 # force using nl_langinfo interface instead of libcharset
 %configure \
 	ac_cv_header_localcharset_h=no
 
-%{__make} \
-	CPPFLAGS="-I/usr/include/freetype2 -I/usr/X11R6/include -I`pwd`" \
-	CXXFLAGS="%{rpmcflags}"
+%{__make}
+#	CPPFLAGS="-I/usr/include/freetype2 -I/usr/X11R6/include -I`pwd`" \
+#	CXXFLAGS="%{rpmcflags}"
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -67,7 +75,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(644,root,root,755)
-%doc ChangeLog README
-%attr(755,root,root) %{_bindir}/*
-%{_mandir}/man1/*
+%doc AUTHORS ChangeLog NEWS README TODO
+%attr(755,root,root) %{_bindir}/xplanet
+%{_mandir}/man1/xplanet.1*
 %{_datadir}/xplanet
diff --git a/files-xplanet-1.3.0-giflib.patch b/files-xplanet-1.3.0-giflib.patch
deleted file mode 100644
index 193719e..0000000
--- a/files-xplanet-1.3.0-giflib.patch
+++ /dev/null
@@ -1,741 +0,0 @@
-Fixes from upstream SVN, to support giflib-4.2 and giflib-5.
-
-Index: src/libimage/gif.c
-===================================================================
---- src/libimage/gif.c	(revision 184)
-+++ src/libimage/gif.c	(revision 186)
-@@ -20,222 +20,581 @@
- 
- #include <stdio.h>
- #include <stdlib.h>
-+#include <string.h>
- 
- #include <gif_lib.h>
- 
- /*
--  A lot of this is based on the gif2rgb and rgb2gif codes in the libungif 
--  distribution. 
-+  Based on the gif2rgb and rgb2gif codes in the libgif distribution. 
- */
- 
- int
- read_gif(const char *filename, int *width, int *height, unsigned char **rgb)
- {
--    int interlace_offset[] = { 0, 4, 2, 1 };
--    int interlace_jump[] = { 8, 8, 4, 2 };
--    GifColorType *colormap;
--    GifFileType *infile;
--    GifRecordType record_type;
--    GifRowType *buffer = NULL;
-+    int	BackGround = 0;
-+    /* The way Interlaced image should be read - offsets and
-+       jumps... */
-+    int InterlacedOffset[] = { 0, 4, 2, 1 }; 
-+    int InterlacedJumps[] = { 8, 8, 4, 2 };
-+    ColorMapObject *ColorMap;
- 
--    int i, j;
--    int color_index;
--    unsigned char *ptr = NULL;
-+    int	i, j, Size, Row, Col, Width, Height, ExtCode, Count;
-+    GifRecordType RecordType;
-+    GifByteType *Extension;
-+    GifRowType *ScreenBuffer;
- 
--    infile = DGifOpenFileName(filename);
-+    GifRowType GifRow;
-+    GifColorType *ColorMapEntry;
-+    unsigned char *BufferP;
- 
--    if (infile == NULL)
-+    GifFileType *GifFile;
-+#if GIFLIB_MAJOR >= 5
-+    GifFile = DGifOpenFileName(filename, NULL);
-+#else
-+    GifFile = DGifOpenFileName(filename);
-+#endif
-+    if (GifFile == NULL) {
-+	fprintf(stderr, "Can't open GIF file %s\n", filename);
-+	return(0);
-+    }
-+    /* (Following comment was probably written on a 286 running under DOS.)  */
-+    /* Allocate the screen as vector of column of rows. We can't allocate the*/
-+    /* whole screen at once, as this broken minded CPU can allocate up to    */
-+    /* 64k at a time and our image can be bigger than that:		     */
-+    /* Note this screen is device independent - it's the screen defined by   */
-+    /* the GIF file parameters.						     */
-+    if ((ScreenBuffer = (GifRowType *)
-+	 malloc(GifFile->SHeight * sizeof(GifRowType))) == NULL)
-     {
--        PrintGifError();
--        return(0);
-+	fprintf(stderr, "Failed to allocate memory required, aborted.");
-+	return(0);
-     }
- 
--    do
-+    Size = GifFile->SWidth * sizeof(GifPixelType);/* Size in bytes one row.*/
-+    if ((ScreenBuffer[0] = (GifRowType) malloc(Size)) == NULL) /* First row. */
-     {
--        if (DGifGetRecordType(infile, &record_type) == GIF_ERROR) 
--        {
--            PrintGifError();
--            return(0);
-+	fprintf(stderr, "Failed to allocate memory required, aborted.");
-+	return(0);
-+    }
-+
-+    for (i = 0; i < GifFile->SWidth; i++)  /* Set its color to BackGround. */
-+	ScreenBuffer[0][i] = GifFile->SBackGroundColor;
-+    for (i = 1; i < GifFile->SHeight; i++) {
-+	/* Allocate the other rows, and set their color to background too: */
-+	if ((ScreenBuffer[i] = (GifRowType) malloc(Size)) == NULL)
-+	{
-+	    fprintf(stderr, "Failed to allocate memory required, aborted.\n");
-+	    return(0);
-+	}
-+
-+	memcpy(ScreenBuffer[i], ScreenBuffer[0], Size);
-+    }
-+
-+    /* Scan the content of the GIF file and load the image(s) in: */
-+    do {
-+	if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
-+	    fprintf(stderr, "Can't read GIF file\n");
-+	    return(0);
-+	}
-+	switch (RecordType) {
-+	case IMAGE_DESC_RECORD_TYPE:
-+	    if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
-+		return(0);
-+	    }
-+	    Row = GifFile->Image.Top; /* Image Position relative to Screen. */
-+	    Col = GifFile->Image.Left;
-+	    Width = GifFile->Image.Width;
-+	    Height = GifFile->Image.Height;
-+	    if (GifFile->Image.Left + GifFile->Image.Width > GifFile->SWidth ||
-+		GifFile->Image.Top + GifFile->Image.Height > GifFile->SHeight) {
-+		return(0);
-+	    }
-+	    if (GifFile->Image.Interlace) {
-+		/* Need to perform 4 passes on the images: */
-+		for (Count = i = 0; i < 4; i++)
-+		    for (j = Row + InterlacedOffset[i]; j < Row + Height;
-+			 j += InterlacedJumps[i]) {
-+			if (DGifGetLine(GifFile, &ScreenBuffer[j][Col],
-+					Width) == GIF_ERROR) {
-+			    return(0);
-+			}
-+		    }
-+	    }
-+	    else {
-+		for (i = 0; i < Height; i++) {
-+		    if (DGifGetLine(GifFile, &ScreenBuffer[Row++][Col],
-+				    Width) == GIF_ERROR) {
-+			return(0);
-+		    }
-+		}
-+	    }
-+	    break;
-+	case EXTENSION_RECORD_TYPE:
-+	    /* Skip any extension blocks in file: */
-+	    if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR) {
-+		return(0);
-+	    }
-+	    while (Extension != NULL) {
-+		if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR) {
-+		    return(0);
-+		}
-+	    }
-+	    break;
-+	case TERMINATE_RECORD_TYPE:
-+	    break;
-+	default:		    /* Should be traps by DGifGetRecordType. */
-+	    break;
-+	}
-+    } while (RecordType != TERMINATE_RECORD_TYPE);
-+
-+    /* Lets dump it - set the global variables required and do it: */
-+    BackGround = GifFile->SBackGroundColor;
-+    ColorMap = (GifFile->Image.ColorMap
-+		? GifFile->Image.ColorMap
-+		: GifFile->SColorMap);
-+    if (ColorMap == NULL) {
-+	fprintf(stderr, "Gif Image does not have a colormap\n");
-+	return(0);
-+    }
-+
-+    *width = GifFile->SWidth;
-+    *height = GifFile->SHeight;
-+
-+    rgb[0] = malloc(3 * *width * *height);
-+    if (rgb[0] == NULL)
-+    {
-+	fprintf(stderr, "Can't allocate memory for GIF file.\n");
-+	return(0);
-+    }
-+
-+    BufferP = rgb[0];
-+    
-+    for (i = 0; i < *height; i++) {
-+	GifRow = ScreenBuffer[i];
-+	for (j = 0; j < *width; j++) {
-+	    ColorMapEntry = &ColorMap->Colors[GifRow[j]];
-+	    *BufferP++ = ColorMapEntry->Red;
-+	    *BufferP++ = ColorMapEntry->Green;
-+	    *BufferP++ = ColorMapEntry->Blue;
-+	}
-+    }
-+    
-+    if (DGifCloseFile(GifFile) == GIF_ERROR) {
-+	return(0);
-+    }
-+
-+    return(1);
-+}
-+
-+/* Make some variables global, so we could access them faster: */
-+static int
-+    ExpNumOfColors = 8,
-+    ColorMapSize = 256;
-+
-+/******************************************************************************
-+ * Code to quantize high resolution image into lower one. You may want to
-+ * peek into the following article this code is based on:
-+ * "Color Image Quantization for frame buffer Display", by Paul Heckbert
-+ * SIGGRAPH 1982 page 297-307.
-+ ******************************************************************************
-+ * History:
-+ * 5 Jan 90 - Version 1.0 by Gershon Elber.
-+ *****************************************************************************/
-+
-+#define ABS(x)    ((x) > 0 ? (x) : (-(x)))
-+
-+#define COLOR_ARRAY_SIZE 32768
-+#define BITS_PER_PRIM_COLOR 5
-+#define MAX_PRIM_COLOR      0x1f
-+
-+static int SortRGBAxis;
-+
-+typedef struct QuantizedColorType {
-+    GifByteType RGB[3];
-+    GifByteType NewColorIndex;
-+    long Count;
-+    struct QuantizedColorType *Pnext;
-+} QuantizedColorType;
-+
-+typedef struct NewColorMapType {
-+    GifByteType RGBMin[3], RGBWidth[3];
-+    unsigned int NumEntries; /* # of QuantizedColorType in linked list below */
-+    unsigned long Count; /* Total number of pixels in all the entries */
-+    QuantizedColorType *QuantizedColors;
-+} NewColorMapType;
-+
-+static int SubdivColorMap(NewColorMapType * NewColorSubdiv,
-+                          unsigned int ColorMapSize,
-+                          unsigned int *NewColorMapSize);
-+static int SortCmpRtn(const void *Entry1, const void *Entry2);
-+
-+/******************************************************************************
-+ * Quantize high resolution image into lower one. Input image consists of a
-+ * 2D array for each of the RGB colors with size Width by Height. There is no
-+ * Color map for the input. Output is a quantized image with 2D array of
-+ * indexes into the output color map.
-+ *   Note input image can be 24 bits at the most (8 for red/green/blue) and
-+ * the output has 256 colors at the most (256 entries in the color map.).
-+ * ColorMapSize specifies size of color map up to 256 and will be updated to
-+ * real size before returning.
-+ *   Also non of the parameter are allocated by this routine.
-+ *   This function returns GIF_OK if succesfull, GIF_ERROR otherwise.
-+ ******************************************************************************/
-+static int
-+QuantizeBuffer(unsigned int Width,
-+               unsigned int Height,
-+               int *ColorMapSize,
-+               GifByteType * RedInput,
-+               GifByteType * GreenInput,
-+               GifByteType * BlueInput,
-+               GifByteType * OutputBuffer,
-+               GifColorType * OutputColorMap) {
-+
-+    unsigned int Index, NumOfEntries;
-+    int i, j, MaxRGBError[3];
-+    unsigned int NewColorMapSize;
-+    long Red, Green, Blue;
-+    NewColorMapType NewColorSubdiv[256];
-+    QuantizedColorType *ColorArrayEntries, *QuantizedColor;
-+
-+    ColorArrayEntries = (QuantizedColorType *)malloc(
-+                           sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE);
-+    if (ColorArrayEntries == NULL) {
-+        return GIF_ERROR;
-+    }
-+
-+    for (i = 0; i < COLOR_ARRAY_SIZE; i++) {
-+        ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR);
-+        ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) &
-+           MAX_PRIM_COLOR;
-+        ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR;
-+        ColorArrayEntries[i].Count = 0;
-+    }
-+
-+    /* Sample the colors and their distribution: */
-+    for (i = 0; i < (int)(Width * Height); i++) {
-+        Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+                  (2 * BITS_PER_PRIM_COLOR)) +
-+                ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+                  BITS_PER_PRIM_COLOR) +
-+                (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
-+        ColorArrayEntries[Index].Count++;
-+    }
-+
-+    /* Put all the colors in the first entry of the color map, and call the
-+     * recursive subdivision process.  */
-+    for (i = 0; i < 256; i++) {
-+        NewColorSubdiv[i].QuantizedColors = NULL;
-+        NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0;
-+        for (j = 0; j < 3; j++) {
-+            NewColorSubdiv[i].RGBMin[j] = 0;
-+            NewColorSubdiv[i].RGBWidth[j] = 255;
-         }
-+    }
- 
--        switch (record_type)
--        {
--        case IMAGE_DESC_RECORD_TYPE:
--            if (DGifGetImageDesc(infile) == GIF_ERROR)
--            {
--                PrintGifError();
--                return(0);
-+    /* Find the non empty entries in the color table and chain them: */
-+    for (i = 0; i < COLOR_ARRAY_SIZE; i++)
-+        if (ColorArrayEntries[i].Count > 0)
-+            break;
-+    QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i];
-+    NumOfEntries = 1;
-+    while (++i < COLOR_ARRAY_SIZE)
-+        if (ColorArrayEntries[i].Count > 0) {
-+            QuantizedColor->Pnext = &ColorArrayEntries[i];
-+            QuantizedColor = &ColorArrayEntries[i];
-+            NumOfEntries++;
-+        }
-+    QuantizedColor->Pnext = NULL;
-+
-+    NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */
-+    NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */
-+    NewColorMapSize = 1;
-+    if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) !=
-+       GIF_OK) {
-+        free((char *)ColorArrayEntries);
-+        return GIF_ERROR;
-+    }
-+    if (NewColorMapSize < *ColorMapSize) {
-+        /* And clear rest of color map: */
-+        for (i = NewColorMapSize; i < *ColorMapSize; i++)
-+            OutputColorMap[i].Red = OutputColorMap[i].Green =
-+                OutputColorMap[i].Blue = 0;
-+    }
-+
-+    /* Average the colors in each entry to be the color to be used in the
-+     * output color map, and plug it into the output color map itself. */
-+    for (i = 0; i < NewColorMapSize; i++) {
-+        if ((j = NewColorSubdiv[i].NumEntries) > 0) {
-+            QuantizedColor = NewColorSubdiv[i].QuantizedColors;
-+            Red = Green = Blue = 0;
-+            while (QuantizedColor) {
-+                QuantizedColor->NewColorIndex = i;
-+                Red += QuantizedColor->RGB[0];
-+                Green += QuantizedColor->RGB[1];
-+                Blue += QuantizedColor->RGB[2];
-+                QuantizedColor = QuantizedColor->Pnext;
-             }
-+            OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j;
-+            OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j;
-+            OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j;
-+        } else
-+            fprintf(stderr,
-+                    "Null entry in quantized color map - that's weird.\n");
-+    }
- 
--            *width = infile->Image.Width;
--            *height = infile->Image.Height;
-+    /* Finally scan the input buffer again and put the mapped index in the
-+     * output buffer.  */
-+    MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0;
-+    for (i = 0; i < (int)(Width * Height); i++) {
-+        Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+                 (2 * BITS_PER_PRIM_COLOR)) +
-+                ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
-+                 BITS_PER_PRIM_COLOR) +
-+                (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
-+        Index = ColorArrayEntries[Index].NewColorIndex;
-+        OutputBuffer[i] = Index;
-+        if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i]))
-+            MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]);
-+        if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i]))
-+            MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]);
-+        if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i]))
-+            MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]);
-+    }
- 
--            buffer = malloc(*height * sizeof(GifRowType *));
--            if (buffer == NULL)
--            {
--                fprintf(stderr, "Can't allocate memory for GIF file.\n");
--                return(0);
--            }
--            
--            for (i = 0; i < *height; i++) 
--            {
--                buffer[i] = malloc(*width * sizeof(GifPixelType));
--                if (buffer[i] == NULL)
--                {
--                    fprintf(stderr, "Can't allocate memory for GIF line.\n");
--                    return(0);
-+    free((char *)ColorArrayEntries);
-+
-+    *ColorMapSize = NewColorMapSize;
-+
-+    return GIF_OK;
-+}
-+
-+/******************************************************************************
-+ * Routine to subdivide the RGB space recursively using median cut in each
-+ * axes alternatingly until ColorMapSize different cubes exists.
-+ * The biggest cube in one dimension is subdivide unless it has only one entry.
-+ * Returns GIF_ERROR if failed, otherwise GIF_OK.
-+ ******************************************************************************/
-+static int
-+SubdivColorMap(NewColorMapType * NewColorSubdiv,
-+               unsigned int ColorMapSize,
-+               unsigned int *NewColorMapSize) {
-+
-+    int MaxSize;
-+    unsigned int i, j, Index = 0, NumEntries, MinColor, MaxColor;
-+    long Sum, Count;
-+    QuantizedColorType *QuantizedColor, **SortArray;
-+
-+    while (ColorMapSize > *NewColorMapSize) {
-+        /* Find candidate for subdivision: */
-+        MaxSize = -1;
-+        for (i = 0; i < *NewColorMapSize; i++) {
-+            for (j = 0; j < 3; j++) {
-+                if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) &&
-+                      (NewColorSubdiv[i].NumEntries > 1)) {
-+                    MaxSize = NewColorSubdiv[i].RGBWidth[j];
-+                    Index = i;
-+                    SortRGBAxis = j;
-                 }
-             }
--            
--            if (infile->Image.Interlace)
--            {
--                for (i = 0; i < 4; i++)
--                    for (j = interlace_offset[i]; j < *height; 
--                         j += interlace_jump[i])
--                        DGifGetLine(infile, buffer[j], *width);
--            }
--            else
--            {
--                for (i = 0; i < *height; i++)
--                    DGifGetLine(infile, buffer[i], *width);
--            }
--            break;
--        case EXTENSION_RECORD_TYPE:
--        {
--            /* Skip extension blocks */
--            int ext_code;
--            GifByteType *ext;
--            if (DGifGetExtension(infile, &ext_code, &ext) == GIF_ERROR) 
--            {
--                PrintGifError();
--                return(0);
--            }
--            while (ext != NULL) 
--            {
--                if (DGifGetExtensionNext(infile, &ext) == GIF_ERROR) 
--                {
--                    PrintGifError();
--                    return(0);
--                }
--            }
-         }
--        break;
--        case TERMINATE_RECORD_TYPE:
--            break;
--        default:
--            fprintf(stderr, "unknown record type in GIF file\n");
--            break;
--        }
--    } while (record_type != TERMINATE_RECORD_TYPE);
- 
--    colormap = (infile->Image.ColorMap ? infile->Image.ColorMap->Colors
--                : infile->SColorMap->Colors);
-+        if (MaxSize == -1)
-+            return GIF_OK;
- 
--    rgb[0] = malloc(3 * *width * *height);
--    if (rgb[0] == NULL)
--    {
--        fprintf(stderr, "Can't allocate memory for GIF file.\n");
--        return(0);
--    }
-+        /* Split the entry Index into two along the axis SortRGBAxis: */
- 
--    ptr = rgb[0];
-+        /* Sort all elements in that entry along the given axis and split at
-+         * the median.  */
-+        SortArray = (QuantizedColorType **)malloc(
-+                      sizeof(QuantizedColorType *) * 
-+                      NewColorSubdiv[Index].NumEntries);
-+        if (SortArray == NULL)
-+            return GIF_ERROR;
-+        for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors;
-+             j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL;
-+             j++, QuantizedColor = QuantizedColor->Pnext)
-+            SortArray[j] = QuantizedColor;
- 
--    for (j = 0; j < *height; j++)
--    {
--        for (i = 0; i < *width; i++)
--        {
--            color_index = (int) buffer[j][i];
--            *ptr++ = (unsigned char) colormap[color_index].Red;
--            *ptr++ = (unsigned char) colormap[color_index].Green;
--            *ptr++ = (unsigned char) colormap[color_index].Blue;
-+        qsort(SortArray, NewColorSubdiv[Index].NumEntries,
-+              sizeof(QuantizedColorType *), SortCmpRtn);
-+
-+        /* Relink the sorted list into one: */
-+        for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++)
-+            SortArray[j]->Pnext = SortArray[j + 1];
-+        SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL;
-+        NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0];
-+        free((char *)SortArray);
-+
-+        /* Now simply add the Counts until we have half of the Count: */
-+        Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count;
-+        NumEntries = 1;
-+        Count = QuantizedColor->Count;
-+        while (QuantizedColor->Pnext != NULL &&
-+	       (Sum -= QuantizedColor->Pnext->Count) >= 0 &&
-+               QuantizedColor->Pnext->Pnext != NULL) {
-+            QuantizedColor = QuantizedColor->Pnext;
-+            NumEntries++;
-+            Count += QuantizedColor->Count;
-         }
--        free(buffer[j]);
-+        /* Save the values of the last color of the first half, and first
-+         * of the second half so we can update the Bounding Boxes later.
-+         * Also as the colors are quantized and the BBoxes are full 0..255,
-+         * they need to be rescaled.
-+         */
-+        MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */
-+	/* coverity[var_deref_op] */
-+        MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */
-+        MaxColor <<= (8 - BITS_PER_PRIM_COLOR);
-+        MinColor <<= (8 - BITS_PER_PRIM_COLOR);
-+
-+        /* Partition right here: */
-+        NewColorSubdiv[*NewColorMapSize].QuantizedColors =
-+           QuantizedColor->Pnext;
-+        QuantizedColor->Pnext = NULL;
-+        NewColorSubdiv[*NewColorMapSize].Count = Count;
-+        NewColorSubdiv[Index].Count -= Count;
-+        NewColorSubdiv[*NewColorMapSize].NumEntries =
-+           NewColorSubdiv[Index].NumEntries - NumEntries;
-+        NewColorSubdiv[Index].NumEntries = NumEntries;
-+        for (j = 0; j < 3; j++) {
-+            NewColorSubdiv[*NewColorMapSize].RGBMin[j] =
-+               NewColorSubdiv[Index].RGBMin[j];
-+            NewColorSubdiv[*NewColorMapSize].RGBWidth[j] =
-+               NewColorSubdiv[Index].RGBWidth[j];
-+        }
-+        NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] =
-+           NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] +
-+           NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor;
-+        NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor;
-+
-+        NewColorSubdiv[Index].RGBWidth[SortRGBAxis] =
-+           MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis];
-+
-+        (*NewColorMapSize)++;
-     }
--    
--    free(buffer);
- 
--    DGifCloseFile(infile);
--    return(1);
-+    return GIF_OK;
- }
- 
-+/****************************************************************************
-+ * Routine called by qsort to compare two entries.
-+ ****************************************************************************/
-+static int
-+SortCmpRtn(const void *Entry1,
-+           const void *Entry2) {
-+
-+    return (*((QuantizedColorType **) Entry1))->RGB[SortRGBAxis] -
-+       (*((QuantizedColorType **) Entry2))->RGB[SortRGBAxis];
-+}
-+
-+/******************************************************************************
-+* Close output file (if open), and exit.
-+******************************************************************************/
-+static void QuitGifError(GifFileType *GifFile)
-+{
-+    fprintf(stderr, "Error writing GIF file\n");
-+    if (GifFile != NULL) EGifCloseFile(GifFile);
-+}
-+
- int 
- write_gif(const char *filename, int width, int height, char *rgb)
- {
-     int i;
--    int colormap_size = 256;
--    GifByteType *red, *green, *blue, *buffer, *ptr;
--    GifFileType *outfile;
--    ColorMapObject *colormap;
-+    GifByteType *red, *green, *blue;
- 
-+    GifByteType *OutputBuffer = NULL;
-+    ColorMapObject *OutputColorMap = NULL;
-+
-+    GifFileType *GifFile;
-+    GifByteType *Ptr;
-+
-+    bool GifTestExistance = false;
-+
-+    ColorMapSize = 1 << ExpNumOfColors;
-+
-+#if GIFLIB_MAJOR >= 5
-+    OutputColorMap = GifMakeMapObject(ColorMapSize, NULL);
-+#else
-+    OutputColorMap = MakeMapObject(ColorMapSize, NULL);
-+#endif
-+    
-+    if (OutputColorMap == NULL ||
-+	(OutputBuffer = (GifByteType *) malloc(width * height *
-+					       sizeof(GifByteType))) == NULL)
-+    {
-+	fprintf(stderr,"Failed to allocate memory required, aborted.");
-+	return(0);
-+    }
-+
-     red = malloc(width * height * sizeof(GifByteType));
-     green = malloc(width * height * sizeof(GifByteType));
-     blue = malloc(width * height * sizeof(GifByteType));
--    buffer = malloc(width * height * sizeof(GifByteType));
--
--    if (red == NULL || green == NULL || blue == NULL || buffer == NULL)
-+    if (red == NULL || green == NULL || blue == NULL)
-     {
--        fprintf(stderr, "Can't allocate memory for GIF file.\n");
--        return(0);
-+	fprintf(stderr, "Can't allocate memory for GIF file.\n");
-+	return(0);
-     }
--
--    colormap = MakeMapObject(colormap_size, NULL);
--
-     for (i = 0; i < width * height; i++)
-     {
--        red[i]   = (GifByteType) rgb[3*i  ];
--        green[i] = (GifByteType) rgb[3*i+1];
--        blue[i]  = (GifByteType) rgb[3*i+2];
-+	red[i]   = (GifByteType) rgb[3*i  ];
-+	green[i] = (GifByteType) rgb[3*i+1];
-+	blue[i]  = (GifByteType) rgb[3*i+2];
-     }
--  
--    if (QuantizeBuffer(width, height, &colormap_size, red, green, blue,   
--                       buffer, colormap->Colors) == GIF_ERROR)
-+
-+    if (QuantizeBuffer(width, height, &ColorMapSize,
-+		       red, green, blue,
-+		       OutputBuffer, OutputColorMap->Colors) == GIF_ERROR)
-+
-     {
--        PrintGifError();
--        return(0);
-+	QuitGifError(NULL);
-+	return(0);
-     }
- 
-     free(red);
-     free(green);
-     free(blue);
- 
--    outfile = EGifOpenFileName((char *) filename, FALSE);
--    if (outfile == NULL)
-+    Ptr = OutputBuffer;
-+
-+#if GIFLIB_MAJOR >= 5
-+    GifFile = EGifOpenFileName(filename, GifTestExistance, NULL);
-+#else
-+    GifFile = EGifOpenFileName(filename, GifTestExistance);
-+#endif
-+    /* Open stdout for the output file: */
-+    if (GifFile == NULL)
-     {
--        PrintGifError();
--        return(0);
-+	QuitGifError(GifFile);
-+	return(0);
-     }
- 
--    if (EGifPutScreenDesc(outfile, width, height, colormap_size, 0, colormap)
--        == GIF_ERROR)
-+    if (EGifPutScreenDesc(GifFile,
-+			  width, height, ExpNumOfColors, 0,
-+			  OutputColorMap) == GIF_ERROR ||
-+	EGifPutImageDesc(GifFile,
-+			 0, 0, width, height, false, NULL) == GIF_ERROR)
-+
-     {
--        PrintGifError();
--        return(0);
-+	QuitGifError(GifFile);
-+	return(0);
-     }
- 
--    if (EGifPutImageDesc(outfile, 0, 0, width, height, FALSE, NULL)
--        == GIF_ERROR)
--    {
--        PrintGifError();
--        return(0);
-+    for (i = 0; i < height; i++) {
-+	if (EGifPutLine(GifFile, Ptr, width) == GIF_ERROR)
-+
-+	{
-+	    QuitGifError(GifFile);
-+	    return(0);
-+	}
-+	Ptr += width;
-     }
- 
--    ptr = buffer;
--    for (i = 0; i < height; i++)
-+    if (EGifCloseFile(GifFile) == GIF_ERROR)
-+
-     {
--        if (EGifPutLine(outfile, ptr, width) == GIF_ERROR)
--        {
--            PrintGifError();
--            return(0);
--        }
--        ptr += width;
-+	QuitGifError(GifFile);
-+	return(0);
-     }
- 
--    EGifSpew(outfile);
--
--    if (EGifCloseFile(outfile) == GIF_ERROR) 
--        PrintGifError();
--
--    free(buffer);
--
-     return(1);
- }
diff --git a/xplanet-gcc43.patch b/xplanet-gcc43.patch
deleted file mode 100644
index 75b6cca..0000000
--- a/xplanet-gcc43.patch
+++ /dev/null
@@ -1,115 +0,0 @@
-diff -ur xplanet-1.2.0.orig/src/libannotate/addArcs.cpp xplanet-1.2.0/src/libannotate/addArcs.cpp
---- xplanet-1.2.0.orig/src/libannotate/addArcs.cpp	2005-03-15 19:27:13.000000000 +0100
-+++ xplanet-1.2.0/src/libannotate/addArcs.cpp	2008-03-20 15:44:58.000000000 +0100
-@@ -3,7 +3,7 @@
- #include <fstream>
- #include <sstream>
- #include <map>
--#include <string>
-+#include <cstring>
- #include <vector>
- using namespace std;
- 
-diff -ur xplanet-1.2.0.orig/src/libannotate/addMarkers.cpp xplanet-1.2.0/src/libannotate/addMarkers.cpp
---- xplanet-1.2.0.orig/src/libannotate/addMarkers.cpp	2004-08-29 22:41:58.000000000 +0200
-+++ xplanet-1.2.0/src/libannotate/addMarkers.cpp	2008-03-20 15:45:11.000000000 +0100
-@@ -5,7 +5,7 @@
- #include <fstream>
- #include <map>
- #include <sstream>
--#include <string>
-+#include <cstring>
- #include <vector>
- using namespace std;
- 
-diff -ur xplanet-1.2.0.orig/src/libannotate/addSatellites.cpp xplanet-1.2.0/src/libannotate/addSatellites.cpp
---- xplanet-1.2.0.orig/src/libannotate/addSatellites.cpp	2004-07-23 02:46:20.000000000 +0200
-+++ xplanet-1.2.0/src/libannotate/addSatellites.cpp	2008-03-20 15:45:23.000000000 +0100
-@@ -4,7 +4,7 @@
- #include <fstream>
- #include <map>
- #include <sstream>
--#include <string>
-+#include <cstring>
- #include <vector>
- using namespace std;
- 
-diff -ur xplanet-1.2.0.orig/src/libannotate/Icon.cpp xplanet-1.2.0/src/libannotate/Icon.cpp
---- xplanet-1.2.0.orig/src/libannotate/Icon.cpp	2004-02-16 19:36:42.000000000 +0100
-+++ xplanet-1.2.0/src/libannotate/Icon.cpp	2008-03-20 15:45:58.000000000 +0100
-@@ -1,4 +1,5 @@
- #include <sstream>
-+#include <cstring>
- using namespace std;
- 
- #include "findFile.h"
-diff -ur xplanet-1.2.0.orig/src/libplanet/Planet.cpp xplanet-1.2.0/src/libplanet/Planet.cpp
---- xplanet-1.2.0.orig/src/libplanet/Planet.cpp	2005-06-14 20:04:05.000000000 +0200
-+++ xplanet-1.2.0/src/libplanet/Planet.cpp	2008-03-20 15:46:53.000000000 +0100
-@@ -2,7 +2,7 @@
- #include <cstdio>
- #include <cctype>
- #include <sstream>
--#include <string>
-+#include <cstring>
- using namespace std;
- 
- #include "findFile.h"
-diff -ur xplanet-1.2.0.orig/src/libprojection/getProjection.cpp xplanet-1.2.0/src/libprojection/getProjection.cpp
---- xplanet-1.2.0.orig/src/libprojection/getProjection.cpp	2005-06-13 17:13:11.000000000 +0200
-+++ xplanet-1.2.0/src/libprojection/getProjection.cpp	2008-03-20 15:47:34.000000000 +0100
-@@ -1,5 +1,6 @@
- #include <cctype>
- #include <cstring>
-+#include <cstdlib>
- #include <sstream>
- #include <vector>
- using namespace std;
-diff -ur xplanet-1.2.0.orig/src/Map.cpp xplanet-1.2.0/src/Map.cpp
---- xplanet-1.2.0.orig/src/Map.cpp	2005-06-15 01:40:46.000000000 +0200
-+++ xplanet-1.2.0/src/Map.cpp	2008-03-20 15:48:01.000000000 +0100
-@@ -1,5 +1,6 @@
- #include <map>
- #include <sstream>
-+#include <cstdlib>
- #include <string>
- using namespace std;
- 
-diff -ur xplanet-1.2.0.orig/src/parseColor.cpp xplanet-1.2.0/src/parseColor.cpp
---- xplanet-1.2.0.orig/src/parseColor.cpp	2004-11-23 18:49:48.000000000 +0100
-+++ xplanet-1.2.0/src/parseColor.cpp	2008-03-20 15:49:23.000000000 +0100
-@@ -2,7 +2,8 @@
- #include <fstream>
- #include <map>
- #include <sstream>
--#include <string>
-+#include <cstring>
-+#include <cstdlib>
- using namespace std;
- 
- #include "findFile.h"
-diff -ur xplanet-1.2.0.orig/src/PlanetProperties.h xplanet-1.2.0/src/PlanetProperties.h
---- xplanet-1.2.0.orig/src/PlanetProperties.h	2005-04-02 02:43:06.000000000 +0200
-+++ xplanet-1.2.0/src/PlanetProperties.h	2008-03-20 15:46:16.000000000 +0100
-@@ -1,7 +1,7 @@
- #ifndef PLANETPROPERTIES_H
- #define PLANETPROPERTIES_H
- 
--#include <string>
-+#include <cstring>
- #include <vector>
- 
- #include "body.h"
-diff -ur xplanet-1.2.0.orig/src/xpUtil.cpp xplanet-1.2.0/src/xpUtil.cpp
---- xplanet-1.2.0.orig/src/xpUtil.cpp	2005-04-02 02:22:51.000000000 +0200
-+++ xplanet-1.2.0/src/xpUtil.cpp	2008-03-20 15:50:06.000000000 +0100
-@@ -5,7 +5,8 @@
- #include <ctime>
- #include <iostream>
- #include <sstream>
--#include <string>
-+#include <cstring>
-+#include <cstdlib>
- using namespace std;
- 
- #include <unistd.h>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/xplanet.git/commitdiff/2d4614e54c41e65bad5a6ce6ae2602d46430c7e8



More information about the pld-cvs-commit mailing list