Mail Archives: djgpp-workers/2002/05/25/05:42:19
> > Please note that confstr.c as simple as I thought and I am wtill working
on
> > it as the compiler does not like the following line in the file:-
> > out_len = snprintf(buf, len, "");
> > GCC 3.1 complains about the third parameter.
> [snip]
>
> What complaint does it have? I suspect it's complaining that there's no
format
> string. Does it complain about this?
Correct.
> out_len = snprintf(buf, len, "%s", "");
>
> It looks like this call is intended to truncate the buffer, to return to
an
> empty string.
Correct. The GNU LIBC code to do this is as follows, when the lines that are
not required are chopped out:-
size_t
confstr (name, buf, len)
int name;
char *buf;
size_t len;
{
const char *string;
size_t string_len;
..SNIP..SWITCH...
/* GNU libc does not require special actions to use LFS functions. */
string = "";
string_len = 1;
break;
default:
__set_errno (EINVAL);
return 0;
}
if (len > 0 && buf != NULL)
{
if (string_len <= len)
memcpy (buf, string, string_len);
else
{
memcpy (buf, string, len - 1);
buf[len - 1] = '\0';
}
}
return string_len;
I have translated this into my WIP version as follows:-
/* No options are required for the default 32-bit environment. */
case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
case _CS_POSIX_V6_ILP32_OFF32_LIBS:
{
out_len = 1;
memcpy (buf, "\0", out_len);
break;
}
Any comments on this?
Andrew
- Raw text -