Add on to SDL_RWops

For SDL_RWops, I made this addition to enhance usability of it on MacOS:
in function SDL_RWFromFile, insert after line 186 (i.e. after the
code that replaces all “…/” with “:”) the following code:


/* Remove all “./” */
p = path;
while ( (p=strstr(p, “./”)) != NULL ) {
strcpy (p, p+2);
}

This way, “./” is also supposed on MacOS. Helps a lot in getting
Abombniball to run :wink:

Max “Fingolfin”

p = path;
while ( (p=strstr(p, "./")) != NULL ) {
  strcpy (p, p+2);
}

strcpy on overlapping strings is undefined. use strlen + memmove instead
or roll your own

At 21:22 Uhr +0100 12.01.2001, Mattias Engdeg?rd wrote:

p = path;

while ( (p=strstr(p, “./”)) != NULL ) {
strcpy (p, p+2);
}

strcpy on overlapping strings is undefined. use strlen + memmove instead
or roll your own

Well… in fact I just copied the code from two lines above and
modified it. I should have checked it I guess… but at least I have
an excuse

Max–

Max Horn
International C/C++/Internet Development

email: mailto:Max_Horn
web: http://www.quendi.de
phone: (+49) 6151-494890

p = path;
while ( (p=strstr(p, “./”)) != NULL ) {
strcpy (p, p+2);
}

strcpy on overlapping strings is undefined. use strlen + memmove instead
or roll your own

Is there any compiler/platform where this will not work? Logically, if one
copies one string into another, it shouldn’t matter if it is a string copied
into itself, so long as destination pointer comes before source pointer. Are
there weird compilers that use special hardware to strcpy or a
multi-threaded strcpy?> From: “Mattias Engdeg?rd”

Reply-To: sdl at lokigames.com
Date: Fri, 12 Jan 2001 21:22:43 +0100 (MET)
To: sdl at lokigames.com
Subject: Re: [SDL] Add on to SDL_RWops

Is there any compiler/platform where this will not work? Logically, if one
copies one string into another, it shouldn’t matter if it is a string copied
into itself, so long as destination pointer comes before source pointer. Are
there weird compilers that use special hardware to strcpy or a
multi-threaded strcpy?

the C Standard explicitly says it’s undefined behaviour. you don’t
mess with the Standard or you’ll regret it :slight_smile:

At 17:38 Uhr -0500 12.01.2001, Darrell Walisser wrote:> > From: “Mattias Engdeg?rd”

Reply-To: sdl at lokigames.com
Date: Fri, 12 Jan 2001 21:22:43 +0100 (MET)
To: sdl at lokigames.com
Subject: Re: [SDL] Add on to SDL_RWops

p = path;
while ( (p=strstr(p, “./”)) != NULL ) {
strcpy (p, p+2);
}

strcpy on overlapping strings is undefined. use strlen + memmove instead
or roll your own

Is there any compiler/platform where this will not work? Logically, if one
copies one string into another, it shouldn’t matter if it is a string copied
into itself, so long as destination pointer comes before source pointer. Are
there weird compilers that use special hardware to strcpy or a
multi-threaded strcpy?

The whole discussion is not really needed. Yorick and me have agreed
that the whole algorithm is flawed anyway, full of bugs, and thus
will be rewritten from scratch :wink:

Max


Max Horn
International C/C++/Internet Development

email: mailto:Max_Horn
web: http://www.quendi.de
phone: (+49) 6151-494890

The whole discussion is not really needed. Yorick and me have agreed
that the whole algorithm is flawed anyway, full of bugs, and thus
will be rewritten from scratch :wink:

What bugs? What flaws? I would be glad to fix up what is needed. I wrote the first version, so I take the blame :wink:

I know it is not a universal solution, but I tested it extensively and it always works the way I expect. Obviously, I missed something here…

-DarrellOn Friday, January 12, 2001, at 05:31 PM, Max Horn wrote:

What bugs? What flaws? I would be glad to fix up what is needed. I
wrote the first version, so I take the blame :wink:

I think Max made it sound worse than it was. I was about to fix the
small strcpy() stuff but the surrounding code just didn’t feel right
(path name components ending in … didn’t work for example) so I ended up
rewriting it instead

If you find bugs in the new code or feel it’s too hard to understand then
please fix it; I’m no Mac programmer (yet :slight_smile: