Antoine said:
En CBFalconer va escriure:
I agree (personnal POV) with your point strlcpy() and strlcat() are very
good candidates for inclusion (along with the forced wcslcpy() and
wcslcat()) into the Standard library. However, it would take place in a
future revision (or even an amendment), which we have no date for.
Furthermore, the "safer" TR is *not* the good path for such a move: there is
a clear distinction between the standard library and the addendum provided
by the TR; also, the added baggage of the TR will probably *not* be
implemented by a number of people. Last but not least, the scheme of the
strlcpy() etc. functions is quite different from the other additions, even
if it more widely used this has further implications (like the different
variation in cycles used vs. the classical ones).
I am much more reserved about your ggets(): I believe there are already too
much ways to get strings in (fgets, *scanf, fwrite), adding a new one does
not seem necessary to me. YMMV, of course.
Well, that's why I put it out there and made it public domain. My
objective was the simplicity of gets with the safety of fgets
without any ambiguity and minimum data loss. What little feedback
I receive is generally positive. I consider the 1135 technique of
discarding data on error to be foul.
As I said, I had never heard of n1135 or n1147 before. This came
up when someone posted in c.l.c about deprecated messages from
Microsoft compilers, and I reacted with outrage at yet another
attempt to derail standards. I do not subscribe to c.stds.c. This
is written in c.l.c.
It is one thing to attempt to provide a set of safer routine
replacements, but I suspect it is forlorn. Working code will not
be upgraded to match, and any such upgrade will reduce
portability. The target should be new code. One urgent and
overdue step is the deprecation of gets. It is not possible to
overcome the fundamental insecurities of C, because such things as
pointer usage are too deeply inbred, and close typing (subranges)
is impossible. Therefore library errors are the obvious path.
Many items in the library can be eliminated, as being fabricable
with purely standard code. So I consider the first step is library
paring to essentials. After that pay attention to consistent
parameter format, allow for length controls a-la-strlcpy etc.
Eliminate subtly error prone constructs such as returning pointers
in strcat. The result can be a new set of include files, which is
feasible since the target is new code. A further set of includes
can cover the handy utilities, fabricable anywhere. These would
include strlcpy and strlcat, for example.
I suggest cross-posting any publicity about such efforts to c.l.c,
with suitable follow-ups. That will at least have a chance of
alerting those with opinions.
BTW, just the use of '_' in routine names is counter-productive.
It is a pain to type because of the use of the shift key, and the
extremely lazy, such as myself, will avoid it.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <
http://cfaj.freeshell.org/google/>
Also see <
http://www.safalra.com/special/googlegroupsreply/>