[Fwd: SDL_RWops bug fixes]

Is anyone going to respond to this? This is a simple and obvious bug. If
the extra functionality and cleanups are not wanted I can submit a patch
with just the fix… but no one has said anything about this either way.> ----- Original Message -----

Subject: [SDL] SDL_RWops bug fixes
Date: Tue, 24 May 2005 00:43:05 -0400
From: @Antonio_Musumeci (Antonio Musumeci)
Reply-To: A list for developers using the SDL library. (includes
SDL-announce)
To: sdl at libsdl.org

This code with SDL-1.2.8 and CVS:

#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>

int
main(int argc, char** argv)
{
char alphabet[26] = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
char buffer_file[27] = {0};
char buffer_mem[27] = {0};
int rv_file;
int rv_mem;
FILE* file_ptr;
SDL_RWops* rwop_file;
SDL_RWops* rwop_mem;

file_ptr = fopen("./blah", "w");
fwrite(alphabet, 1, sizeof(alphabet), file_ptr);
fclose(file_ptr);

rwop_mem  = SDL_RWFromMem(alphabet, sizeof(alphabet));
rwop_file = SDL_RWFromFile("./blah", "r");
rv_mem  = SDL_RWread(rwop_mem , buffer_mem,  5, 6);
rv_file = SDL_RWread(rwop_file, buffer_file, 5, 6);
printf("From File: %d %s\n"
       "From Mem:  %d %s\n",

rv_file,
buffer_file,
rv_mem,
buffer_mem);
printf(“Seek end of File: %d\n”
“Seek end of Mem: %d\n”,
SDL_RWseek(rwop_file, 0, SEEK_END),
SDL_RWseek(rwop_mem , 0, SEEK_END));
SDL_RWclose(rwop_file);
SDL_RWclose(rwop_mem);

return 0;

}

Produces this output:

From File: 5 ABCDEFGHIJKLMNOPQRSTUVWXYZ
From Mem: 5 ABCDEFGHIJKLMNOPQRSTUVWXY
Seek end of File: 26
Seek end of Mem: 26

Attached is a patch which fixes this along with a few other
inconsistencies and bugs in SDL_rwops.c… it also enhances the API. It
should however still be compatible. Also attached is a list of all the
changes/enhancements made by this patch.

-Antonio SJ Musumeci

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: sdl_rwops.diff
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050530/60da8fc4/attachment.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: sdl_rwops.changes
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050530/60da8fc4/attachment.asc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: file:///tmp/nsmail-3.asc
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050530/60da8fc4/attachment-0001.asc

Antonio SJ Musumeci wrote:

Is anyone going to respond to this? This is a simple and obvious bug. If
the extra functionality and cleanups are not wanted I can submit a patch
with just the fix… but no one has said anything about this either way.

I’ll commit the fixes, but I’d rather not extend the RWops API at this
point.

–ryan.

What about the eof and error stuff? i dont see how RWops is is truely
useful without it.

Ryan C. Gordon wrote:>

Antonio SJ Musumeci wrote:

Is anyone going to respond to this? This is a simple and obvious bug.
If the extra functionality and cleanups are not wanted I can submit a
patch with just the fix… but no one has said anything about this
either way.

I’ll commit the fixes, but I’d rather not extend the RWops API at this
point.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Antonio SJ Musumeci wrote:

What about the eof and error stuff? i dont see how RWops is is truely
useful without it.

Changing the RWops structure breaks binary compatibility with legacy
apps and libraries.

I’m not against replacing RWops completely (indeed, I’ve wanted to do
that for a long time for many of the reasons you’ve put forth), but
what’s there has to stay more or less as it is.

–ryan.

Hello !

Then why not adding this stuff to SDL1.3 ?

CU> Antonio SJ Musumeci wrote:

What about the eof and error stuff? i dont see how RWops is is truely
useful without it.

Changing the RWops structure breaks binary compatibility with legacy
apps and libraries.

I’m not against replacing RWops completely (indeed, I’ve wanted to do
that for a long time for many of the reasons you’ve put forth), but what’s
there has to stay more or less as it is.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl