Pelles C forum

Pelles C => Bug reports => Topic started by: japheth on June 17, 2009, 08:45:54 AM

Title: _makepath() implementation problem?
Post by: japheth on June 17, 2009, 08:45:54 AM

hello,

the following possible bug was found in v5.0. I didn't test it with v6rc2, but since I didn't find _makepath() mentioned in the change log shipping with v6 there may be a chance that it still occurs.

Problem: makepath() doesn't add filename and extension to the path.

Test case:


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

char drive[] = {"\0"};
char dir[] = {"\\masm32\\include\\"};
char fname[] = {"windows"};
char ext[] = {".inc"};

int main()
{
    char fullpath[FILENAME_MAX];
    _makepath( fullpath, drive, dir, fname, ext );
    printf( "fullpath=%s\n", fullpath );
    return(0);
}


the resulting program displays:

fullpath=\masm32\include\

OTOH, with MS VC, the program displays:

fullpath=\masm32\include\windows.inc

which is what I do expect.

Title: Re: _makepath() implementation problem?
Post by: AlexN on June 17, 2009, 11:04:02 AM
Quote from: japheth on June 17, 2009, 08:45:54 AM

Problem: makepath() doesn't add filename and extension to the path.


The runtime-lib from Pelle adds the filename to the path, but is a zero byte between path and name.

Until Pelle corrects his runtime you can link with msvcrt.lib and ignore the warning.  ;)
Title: Re: _makepath() implementation problem?
Post by: japheth on June 17, 2009, 02:40:26 PM
Quote from: AlexN on June 17, 2009, 11:04:02 AM
The runtime-lib from Pelle adds the filename to the path, but is a zero byte between path and name.
Until Pelle corrects his runtime you can link with msvcrt.lib and ignore the warning.  ;)

Thanks! It's not a problem for me, since I can replace the RTL implementation with a "self-written" one.  Just wondering why such an issue hasn't been noticed before.
Title: Re: _makepath() implementation problem?
Post by: Pelle on June 21, 2009, 12:57:20 PM
Apparently no one is using _makepath() - which is probably a good thing. The function hasn't changed from the initial version 2005-07-18.
Title: Re: _makepath() implementation problem?
Post by: nicolas.sitbon on June 21, 2009, 01:10:32 PM
I do use _makepath_s() from msvcrt.