[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: recommend strdup or strdup-posix?
From: |
Bruno Haible |
Subject: |
Re: recommend strdup or strdup-posix? |
Date: |
Sat, 29 Jan 2011 14:04:30 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Simon,
> I was using strdup and it triggered this warning in gnulib:
>
> _GL_WARN_ON_USE (strdup, "strdup is unportable - "
> "use gnulib module strdup for portability");
> So string.h should probably point to strdup-posix?
Yes. The warning is inconsistent with the documentation at
<http://www.gnu.org/software/gnulib/manual/html_node/strdup.html>.
Feel free to fix the warning.
> However the strdup module is deprecated according to modules/strdup:
>
> This module is obsolete. But you may want to use the strdup-posix module.
It is obsolete, not deprecated. Which means, you don't normally need
the 'strdup' module, but you _can_ use it. This is documented at
<http://www.gnu.org/software/gnulib/manual/html_node/Obsolete-modules.html>
> But what is the purpose of the strdup module then? According to
>
> http://www.gnu.org/software/gnulib/manual/html_node/strdup.html
... the purpose is portability to extremely old systems.
> Can't we just rename strdup-posix to strdup?
I wouldn't do it, because few people really use the value of 'errno'
after an strdup failure. The typical idiom is to just terminate the
current block or function when strdup fails.
> I suspect strdup is one of the initial modules a new gnulib user would
> import, so this complexity might be confusing and I don't see the gain.
Yes, strdup is one of the first functions someone can stumble upon.
If the documentation at
<http://www.gnu.org/software/gnulib/manual/html_node/strdup.html>
<http://www.gnu.org/software/gnulib/manual/html_node/Obsolete-modules.html>
is not clear, please, what can be done to improve it?
Bruno