[giflib] Update to 5.2.2 (#36975)

Refresh patches
Use strtok_s for strtok_r on MSVC, export GifDrawBoxedText8x8.
This commit is contained in:
Kai Pastor 2024-02-29 02:08:22 +01:00 committed by GitHub
parent 45d50eeaf5
commit 198ea1e47a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 102 additions and 138 deletions

View File

@ -1,36 +0,0 @@
diff --git a/gif_font.c b/gif_font.c
index d90783c..b682c7a 100644
--- a/gif_font.c
+++ b/gif_font.c
@@ -204,6 +204,7 @@ GifDrawRectangle(SavedImage *Image,
memset(bp + (i * Image->ImageDesc.Width), color, (size_t)w);
}
+#if !defined(_WIN32)
void
GifDrawBoxedText8x8(SavedImage *Image,
const int x, const int y,
@@ -257,5 +258,6 @@ GifDrawBoxedText8x8(SavedImage *Image,
border + LineCount * GIF_FONT_HEIGHT + border, fg);
}
}
+#endif
/* end */
diff --git a/gif_lib.h b/gif_lib.h
index ebdbd3c..41bf7a2 100644
--- a/gif_lib.h
+++ b/gif_lib.h
@@ -290,10 +290,12 @@ extern void GifDrawRectangle(SavedImage *Image,
const int x, const int y,
const int w, const int d, const int color);
+#if !defined(_WIN32)
extern void GifDrawBoxedText8x8(SavedImage *Image,
const int x, const int y,
const char *legend,
const int border, const int bg, const int fg);
+#endif
#ifdef __cplusplus
}

View File

@ -42,7 +42,7 @@ EXPORTS
GifAsciiTable8x8 @41 DATA
GifBitSize @42
GifDrawBox @43
; needs strtok_r: GifDrawBoxedText8x8 @44
GifDrawBoxedText8x8 @44
GifDrawRectangle @45
GifDrawText8x8 @46
GifErrorString @47

View File

@ -1,75 +0,0 @@
diff --git a/dgif_lib.c b/dgif_lib.c
index 82fc097..3bb302b 100644
--- a/dgif_lib.c
+++ b/dgif_lib.c
@@ -58,7 +58,7 @@ DGifOpenFileName(const char *FileName, int *Error)
int FileHandle;
GifFileType *GifFile;
- if ((FileHandle = open(FileName, O_RDONLY)) == -1) {
+ if ((FileHandle = _open(FileName, O_RDONLY)) == -1) {
if (Error != NULL)
*Error = D_GIF_ERR_OPEN_FAILED;
return NULL;
@@ -85,7 +85,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
if (GifFile == NULL) {
if (Error != NULL)
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
- (void)close(FileHandle);
+ (void)_close(FileHandle);
return NULL;
}
@@ -99,7 +99,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
if (Private == NULL) {
if (Error != NULL)
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
- (void)close(FileHandle);
+ (void)_close(FileHandle);
free((char *)GifFile);
return NULL;
}
@@ -110,7 +110,7 @@ DGifOpenFileHandle(int FileHandle, int *Error)
_setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
#endif /* _WIN32 */
- f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
+ f = _fdopen(FileHandle, "rb"); /* Make it into a stream: */
/*@-mustfreeonly@*/
GifFile->Private = (void *)Private;
diff --git a/egif_lib.c b/egif_lib.c
index 6219af0..8ddda1b 100644
--- a/egif_lib.c
+++ b/egif_lib.c
@@ -67,10 +67,10 @@ EGifOpenFileName(const char *FileName, const bool TestExistence, int *Error)
GifFileType *GifFile;
if (TestExistence)
- FileHandle = open(FileName, O_WRONLY | O_CREAT | O_EXCL,
+ FileHandle = _open(FileName, O_WRONLY | O_CREAT | O_EXCL,
S_IREAD | S_IWRITE);
else
- FileHandle = open(FileName, O_WRONLY | O_CREAT | O_TRUNC,
+ FileHandle = _open(FileName, O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE);
if (FileHandle == -1) {
@@ -80,7 +80,7 @@ EGifOpenFileName(const char *FileName, const bool TestExistence, int *Error)
}
GifFile = EGifOpenFileHandle(FileHandle, Error);
if (GifFile == (GifFileType *) NULL)
- (void)close(FileHandle);
+ (void)_close(FileHandle);
return GifFile;
}
@@ -125,7 +125,7 @@ EGifOpenFileHandle(const int FileHandle, int *Error)
_setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
#endif /* _WIN32 */
- f = fdopen(FileHandle, "wb"); /* Make it into a stream: */
+ f = _fdopen(FileHandle, "wb"); /* Make it into a stream: */
GifFile->Private = (void *)Private;
Private->FileHandle = FileHandle;

View File

@ -1,14 +0,0 @@
diff --git a/gif_hash.h b/gif_hash.h
index 6a1b585..e6712e8 100644
--- a/gif_hash.h
+++ b/gif_hash.h
@@ -9,7 +9,9 @@ SPDX-License-Identifier: MIT
#ifndef _GIF_HASH_H_
#define _GIF_HASH_H_
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include <stdint.h>
#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */

89
ports/giflib/msvc.diff Normal file
View File

@ -0,0 +1,89 @@
diff --git a/dgif_lib.c b/dgif_lib.c
index cbcf23f..15dee84 100644
--- a/dgif_lib.c
+++ b/dgif_lib.c
@@ -57,7 +57,7 @@ GifFileType *DGifOpenFileName(const char *FileName, int *Error) {
int FileHandle;
GifFileType *GifFile;
- if ((FileHandle = open(FileName, O_RDONLY)) == -1) {
+ if ((FileHandle = _open(FileName, O_RDONLY)) == -1) {
if (Error != NULL) {
*Error = D_GIF_ERR_OPEN_FAILED;
}
@@ -84,7 +84,7 @@ GifFileType *DGifOpenFileHandle(int FileHandle, int *Error) {
if (Error != NULL) {
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
}
- (void)close(FileHandle);
+ (void)_close(FileHandle);
return NULL;
}
@@ -99,7 +99,7 @@ GifFileType *DGifOpenFileHandle(int FileHandle, int *Error) {
if (Error != NULL) {
*Error = D_GIF_ERR_NOT_ENOUGH_MEM;
}
- (void)close(FileHandle);
+ (void)_close(FileHandle);
free((char *)GifFile);
return NULL;
}
@@ -110,7 +110,7 @@ GifFileType *DGifOpenFileHandle(int FileHandle, int *Error) {
_setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
#endif /* _WIN32 */
- f = fdopen(FileHandle, "rb"); /* Make it into a stream: */
+ f = _fdopen(FileHandle, "rb"); /* Make it into a stream: */
/*@-mustfreeonly@*/
GifFile->Private = (void *)Private;
diff --git a/egif_lib.c b/egif_lib.c
index 1526868..6644eed 100644
--- a/egif_lib.c
+++ b/egif_lib.c
@@ -64,10 +64,10 @@ GifFileType *EGifOpenFileName(const char *FileName, const bool TestExistence,
GifFileType *GifFile;
if (TestExistence) {
- FileHandle = open(FileName, O_WRONLY | O_CREAT | O_EXCL,
+ FileHandle = _open(FileName, O_WRONLY | O_CREAT | O_EXCL,
S_IREAD | S_IWRITE);
} else {
- FileHandle = open(FileName, O_WRONLY | O_CREAT | O_TRUNC,
+ FileHandle = _open(FileName, O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE);
}
@@ -79,7 +79,7 @@ GifFileType *EGifOpenFileName(const char *FileName, const bool TestExistence,
}
GifFile = EGifOpenFileHandle(FileHandle, Error);
if (GifFile == (GifFileType *)NULL) {
- (void)close(FileHandle);
+ (void)_close(FileHandle);
}
return GifFile;
}
@@ -125,7 +125,7 @@ GifFileType *EGifOpenFileHandle(const int FileHandle, int *Error) {
_setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */
#endif /* _WIN32 */
- f = fdopen(FileHandle, "wb"); /* Make it into a stream: */
+ f = _fdopen(FileHandle, "wb"); /* Make it into a stream: */
GifFile->Private = (void *)Private;
Private->FileHandle = FileHandle;
diff --git a/gif_font.c b/gif_font.c
index 75f9731..c215795 100644
--- a/gif_font.c
+++ b/gif_font.c
@@ -200,6 +200,9 @@ void GifDrawRectangle(SavedImage *Image, const int x, const int y, const int w,
}
}
+#ifdef _MSC_VER
+# define strtok_r strtok_s
+#endif
void GifDrawBoxedText8x8(SavedImage *Image, const int x, const int y,
const char *legend, const int border, const int bg,
const int fg) {

View File

@ -1,18 +1,14 @@
set(GIFLIB_VERSION 5.2.1)
set(EXTRA_PATCHES "")
if (VCPKG_TARGET_IS_WINDOWS)
list(APPEND EXTRA_PATCHES fix-compile-error.patch)
if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
list(APPEND EXTRA_PATCHES msvc.diff)
endif()
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO "giflib"
FILENAME "giflib-${GIFLIB_VERSION}.tar.gz"
SHA512 4550e53c21cb1191a4581e363fc9d0610da53f7898ca8320f0d3ef6711e76bdda2609c2df15dc94c45e28bff8de441f1227ec2da7ea827cb3c0405af4faa4736
FILENAME "giflib-${VERSION}.tar.gz"
SHA512 0865ab2b1904fa14640c655fdb14bb54244ad18a66e358565c00287875d00912343f9be8bfac7658cc0146200d626f7ec9160d7a339f20ba3be6b9941d73975f
PATCHES
msvc-guard-unistd-h.patch
disable-GifDrawBoxedText8x8-win32.patch # MSVC doesn't have strtok_r
${EXTRA_PATCHES}
)

View File

@ -1,7 +1,6 @@
{
"name": "giflib",
"version": "5.2.1",
"port-version": 3,
"version": "5.2.2",
"description": "A library for reading and writing gif images.",
"homepage": "https://sourceforge.net/projects/giflib/",
"license": "MIT",

View File

@ -2993,8 +2993,8 @@
"port-version": 3
},
"giflib": {
"baseline": "5.2.1",
"port-version": 3
"baseline": "5.2.2",
"port-version": 0
},
"ginkgo": {
"baseline": "1.7.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "3763c06b1c8fce08fe96398c747b343707832d62",
"version": "5.2.2",
"port-version": 0
},
{
"git-tree": "8ba54b2de43f1fe619e5a7e554f108fc01a771da",
"version": "5.2.1",