pkgsrc/graphics/gliv/patches/patch-aa
2005-03-14 14:55:24 +00:00

93 lines
2.7 KiB
Text

$NetBSD: patch-aa,v 1.3 2005/03/14 14:55:24 rillig Exp $
gcc-2.95.3 does not like unnamed structs and unions.
Needed for NetBSD-1.6.2.
--- src/collection.c.orig Tue Jan 4 20:40:06 2005
+++ src/collection.c Sat Mar 12 11:43:37 2005
@@ -714,8 +714,8 @@ struct coll_src {
guchar *base;
guchar *ptr;
guchar *end;
- };
- };
+ } s;
+ } u;
};
static void free_buffer(struct coll_src *source, guchar * buffer)
@@ -731,16 +731,16 @@ static guchar *read_buffer(struct coll_s
if (source->is_file) {
data = g_new(guchar, length);
- if (fread(data, 1, length, source->file) != length) {
+ if (fread(data, 1, length, source->u.file) != length) {
g_free(data);
return NULL;
}
} else {
- if (source->ptr + length > source->end)
+ if (source->u.s.ptr + length > source->u.s.end)
return NULL;
- data = source->ptr;
- source->ptr += length;
+ data = source->u.s.ptr;
+ source->u.s.ptr += length;
}
if (is_string && data[length - 1] != '\0') {
@@ -754,12 +754,12 @@ static guchar *read_buffer(struct coll_s
static gint read_char(struct coll_src *source)
{
if (source->is_file)
- return fgetc(source->file);
+ return fgetc(source->u.file);
- if (source->ptr >= source->end)
+ if (source->u.s.ptr >= source->u.s.end)
return EOF;
- return *(source->ptr++);
+ return *(source->u.s.ptr++);
}
static GdkPixbufDestroyNotify destroy_func(struct coll_src *source)
@@ -931,22 +931,22 @@ static struct coll_src *build_source(FIL
goto no_mmap;
}
- source->base = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fileno(file), 0);
- if (source->base == MAP_FAILED) {
+ source->u.s.base = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fileno(file), 0);
+ if (source->u.s.base == MAP_FAILED) {
perror("mmap");
goto no_mmap;
}
source->is_file = FALSE;
- source->ptr = source->base;
- source->end = source->base + length;
+ source->u.s.ptr = source->u.s.base;
+ source->u.s.end = source->u.s.base + length;
goto ok;
no_mmap:
fseeko(file, 0, SEEK_SET);
source->is_file = TRUE;
- source->file = file;
+ source->u.file = file;
ok:
return source;
@@ -955,7 +955,7 @@ static struct coll_src *build_source(FIL
static void destroy_source(struct coll_src *source, gboolean ok)
{
if (ok == FALSE && source->is_file == FALSE)
- if (munmap(source->base, source->end - source->base) < 0)
+ if (munmap(source->u.s.base, source->u.s.end - source->u.s.base) < 0)
perror("munmap");
}