Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #17583 > unrolled thread

Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets?

Started byLord Voldermort <nospam@nospam.com>
First post2012-02-18 22:18 +0000
Last post2012-03-01 05:57 -0500
Articles 3 on this page of 23 — 12 participants

Back to article view | Back to comp.lang.c


Contents

  Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Lord Voldermort <nospam@nospam.com> - 2012-02-18 22:18 +0000
    Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Lord Voldermort <nospam@nospam.com> - 2012-02-18 22:36 +0000
      Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-18 22:55 +0000
      Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Kaz Kylheku <kaz@kylheku.com> - 2012-02-19 06:05 +0000
    Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Keith Thompson <kst-u@mib.org> - 2012-02-18 15:01 -0800
      Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Lord Voldermort <nospam@nospam.com> - 2012-02-19 10:54 +0000
        Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-19 12:21 +0000
          Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Lord Voldermort <nospam@nospam.com> - 2012-02-19 19:53 +0000
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Keith Thompson <kst-u@mib.org> - 2012-02-19 12:15 -0800
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Geoff <geoff@invalid.invalid> - 2012-02-19 13:58 -0800
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Stephen Sprunk <stephen@sprunk.org> - 2012-02-19 17:19 -0600
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? James Kuyper <jameskuyper@verizon.net> - 2012-02-19 18:41 -0500
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Robert Wessel <robertwessel2@yahoo.com> - 2012-02-20 01:51 -0600
              Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Keith Thompson <kst-u@mib.org> - 2012-02-20 02:19 -0800
        Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 00:45 -0800
        Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-20 00:52 -0800
          Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-02-20 13:25 +0000
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Keith Thompson <kst-u@mib.org> - 2012-02-20 10:33 -0800
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2012-02-21 19:51 +0000
              Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? James Kuyper <jameskuyper@verizon.net> - 2012-02-21 15:11 -0500
                Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Jens Gustedt <jens.gustedt@loria.fr> - 2012-02-22 08:35 +0100
                  Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? Keith Thompson <kst-u@mib.org> - 2012-02-22 02:18 -0800
            Re: Has Implicit Int been disabled in the new C11 standard? What about other previously depreciated constructions eg gets? David Thompson <dave.thompson2@verizon.net> - 2012-03-01 05:57 -0500

Page 2 of 2 — ← Prev page 1 [2]


#17775

FromJens Gustedt <jens.gustedt@loria.fr>
Date2012-02-22 08:35 +0100
Message-ID<4F449AD0.2040809@loria.fr>
In reply to#17748
Hello,

Am 02/21/2012 09:11 PM, schrieb James Kuyper:
> On 02/21/2012 02:51 PM, Quentin Pope wrote:
> ...
>> Does that mean that the identifier gets has been returned to the user's 
>> namespace? ...
> 
> Yes. ...
> 
> For the next decade or two, any decent C2011+ compiler will probably
> have an option that warns about user-provided definitions of 'gets', but
> I wouldn't recommend counting on that in the long-term.

Probably this is just something that nobody thought about, since it
never happened before. Sounds like a good point for a DR.

Jens

[toc] | [prev] | [next] | [standalone]


#17780

FromKeith Thompson <kst-u@mib.org>
Date2012-02-22 02:18 -0800
Message-ID<ln8vjvb27p.fsf@nuthaus.mib.org>
In reply to#17775
Jens Gustedt <jens.gustedt@loria.fr> writes:
> Am 02/21/2012 09:11 PM, schrieb James Kuyper:
>> On 02/21/2012 02:51 PM, Quentin Pope wrote:
>> ...
>>> Does that mean that the identifier gets has been returned to the user's 
>>> namespace? ...
>> 
>> Yes. ...
>> 
>> For the next decade or two, any decent C2011+ compiler will probably
>> have an option that warns about user-provided definitions of 'gets', but
>> I wouldn't recommend counting on that in the long-term.
>
> Probably this is just something that nobody thought about, since it
> never happened before. Sounds like a good point for a DR.

It's unlikely that nobody thought about it.  I seem to recall it being
discussed in comp.std.c.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#18080

FromDavid Thompson <dave.thompson2@verizon.net>
Date2012-03-01 05:57 -0500
Message-ID<0fluk716sp62chq1d38jcfs6h2j5qp1nf6@4ax.com>
In reply to#17658
On Mon, 20 Feb 2012 13:25:52 +0000, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:

> Nick Keighley <nick_keighley_nospam@hotmail.com> writes:
<snip>
> If you simply must get your gets-containing code to run today, you can use:
> 
> #define gets(s) (scanf("%[^\n]%*c", (s)) == 1 ? (s) : NULL)
> 
> but you should fix it tomorrow!  (Not you personally, of course, but
> "one" is sometimes too formal for Usenet).

Not quite. That gets 'stuck' on an empty line (newline only).

You need to split the call like
  ( scanf ("%[^\n]", (s)) == 1 ? scanf ("%*c"), (s)
  : (scanf ("%*c"), NULL ) )

or you can substitute getchar (or getc(stdin) etc)
  ( scanf ("%[^\n", (s)) == 1 ? getchar(), (s) : ( getchar(), NULL ) )

And of course it usually evaluates s twice and thus is wrong for an
argument that is not idempotent (often inexactly stated as having side
effects). One could argue that using gets() that way is a bad idea --
but then using gets() at all is a bad idea!

By this point it isn't really fun anymore. If it was necessary (which
as Keith says it's not) I'd just write something straightforward like

  char * gets (char * s){
    size_t i = 0; int c;
    while ( (c = getchar()) != EOF && c != '\n' ) s[i++] = c;
    if (c == EOF && i == 0) return NULL;
    s[i] = 0; return s;
  }

or the obvious pointer equivalent.

Or to be (extra) cautious about the external name, I might write it as
another name like mygets and #define gets to that.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.c


csiph-web