The nature of the question is such that there's going to be speculations and opinions. But we could find some information from the C99 rationale and C11 standard.
The C99 rationale, when gets()
was deprecated, states the following reason for the deprecating it:
Because gets does not check for buffer overrun, it is generally unsafe
to use when its input is not under the programmer’s control. This has
caused some to question whether it should appear in the Standard at
all. The Committee decided that gets was useful and convenient in
those special circumstances when the programmer does have adequate
control over the input, and as longstanding existing practice, it
needed a standard specification. In general, however, the preferred
function is fgets (see §7.19.7.2).
I don't think gets_s()
can be considered as an alternative either. Because gets_s()
is an optional interface. C11 actually recommends fgets()
over gets_s()
:
§K.3.5.4.1, C11 draft
The fgets function allows properly-written programs to safely process
input lines too long to store in the result array. In general this
requires that callers of fgets pay attention to the presence or
absence of a new-line character in the result array. Consider using
fgets (along with any needed processing based on new-line characters)
instead of gets_s.
So that leaves us with fgets()
as the only real replacement for gets()
in ISO C. fgets()
is equivalent to gets()
except it would read in the newline if there's buffer space. So is it worth introducing a new interface that has a minor improvement over a longstanding and widely used (fgets()
) one? IMO, no.
Besides, a lot of real world applications are not restricted to ISO C alone. So there's an opportunity to use extensions and POSIX getline()
etc as a replacement.
If it becomes necessary to find write a solution within ISO C, then it's quite easy to write a wrapper around fgets()
anyway such as my_fgets()
that would remove the newline, if present.
Of course, teaching fgets()
to newcomers involves explaining about the potential newline issue. But IMO, it's not that hard to understand and someone intending to do learn C should be able to grasp it quickly. It (finding the last character and replace it if it's character "X") could even be considered as a good exercise for a beginner.
So in light of the above stated reasons, I would say there's no overwhelming necessity for a new function in ISO C as a true replacement for gets()
.