Hi, > I wrote: >> Plib's behavior in the lines touched by this patch is platform >> independent. > > And this bit of the patch is just flat wrong. The original version > finds the first "_" in the string and nul-terminates it at that > location. The "fixed" code it a complete no-op. > > - char *p = strrchr(fname,'_'); > + char *dupfname = strdup( fname); > + char *p = strrchr( dupfname,'_'); > if (p != 0) { > *p = '\0';
Ahem. You should read the original context... (a little bit polished) bool ssgLoadMDLTexture ( const char *fname, ssgTextureInfo* info ) { FILE *tfile; int index = 0; if ( (tfile = fopen(fname, "rb")) == NULL) { char *p = strrchr( (char *)fname,'_'); if (p != 0) { *p = '\0'; p++; index = atoi (p); } Think about calling `ssgLoadTexture("myfile.0af_100", &info);' On many systems the string "myfile.0af_100" will be placed into the TEXT segment, R/O memory. Please do not mix the terms "compiles o.k. and works for me" with "the code is correct". The patch I supplied fixes this -- more or less esoteric bug condition -- and secondly cleans up a few ugly code part with uneccesarly conditional compilation. And as a side effect it compiles cleanly on MSVC8 (and many others, i hope). Thanks for listening, Olaf ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel