Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Cy Schubert
In message <20180403204240.gn1...@kib.kiev.ua>, Konstantin Belousov 
writes:
> On Tue, Apr 03, 2018 at 01:24:42PM -0700, Cy Schubert wrote:
> > In message <20180403202010.gk1...@kib.kiev.ua>, Konstantin Belousov 
> > writes:
> > > On Tue, Apr 03, 2018 at 06:52:39PM +, Cy Schubert wrote:
> > > > Modified: head/lib/libc/stdio/Symbol.map
> > > > ===
> 
> > > ===
> > > > --- head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:43:00 2018
>   (r33193
> > > 5)
> > > > +++ head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:52:38 2018
>   (r33193
> > > 6)
> > > > @@ -165,6 +165,7 @@ FBSD_1.3 {
> > > >  FBSD_1.4 {
> > > > fdclose;
> > > > fopencookie;
> > > > +   gets_s;
> > > >  };
> > > This is wrong.
> > 
> > Would you suggest a different version number?
>
> Right version number for HEAD while it is 12 is FBSD_1.5.  You will need
> to add it to stdio/Symbol.map since this is the first symbol in that
> namespace from stdio subdirectory.

Ok. I understand now.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Konstantin Belousov
On Tue, Apr 03, 2018 at 01:24:42PM -0700, Cy Schubert wrote:
> In message <20180403202010.gk1...@kib.kiev.ua>, Konstantin Belousov 
> writes:
> > On Tue, Apr 03, 2018 at 06:52:39PM +, Cy Schubert wrote:
> > > Modified: head/lib/libc/stdio/Symbol.map
> > > ===
> > ===
> > > --- head/lib/libc/stdio/Symbol.mapTue Apr  3 18:43:00 2018
> > > (r33193
> > 5)
> > > +++ head/lib/libc/stdio/Symbol.mapTue Apr  3 18:52:38 2018
> > > (r33193
> > 6)
> > > @@ -165,6 +165,7 @@ FBSD_1.3 {
> > >  FBSD_1.4 {
> > >   fdclose;
> > >   fopencookie;
> > > + gets_s;
> > >  };
> > This is wrong.
> 
> Would you suggest a different version number?

Right version number for HEAD while it is 12 is FBSD_1.5.  You will need
to add it to stdio/Symbol.map since this is the first symbol in that
namespace from stdio subdirectory.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Cy Schubert
In message <20180403202010.gk1...@kib.kiev.ua>, Konstantin Belousov 
writes:
> On Tue, Apr 03, 2018 at 06:52:39PM +, Cy Schubert wrote:
> > Modified: head/lib/libc/stdio/Symbol.map
> > ===
> ===
> > --- head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:43:00 2018(r33193
> 5)
> > +++ head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:52:38 2018(r33193
> 6)
> > @@ -165,6 +165,7 @@ FBSD_1.3 {
> >  FBSD_1.4 {
> > fdclose;
> > fopencookie;
> > +   gets_s;
> >  };
> This is wrong.

Fixed. Thanks for input Konstantin.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Cy Schubert
In message <20180403202010.gk1...@kib.kiev.ua>, Konstantin Belousov 
writes:
> On Tue, Apr 03, 2018 at 06:52:39PM +, Cy Schubert wrote:
> > Modified: head/lib/libc/stdio/Symbol.map
> > ===
> ===
> > --- head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:43:00 2018(r33193
> 5)
> > +++ head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:52:38 2018(r33193
> 6)
> > @@ -165,6 +165,7 @@ FBSD_1.3 {
> >  FBSD_1.4 {
> > fdclose;
> > fopencookie;
> > +   gets_s;
> >  };
> This is wrong.

Would you suggest a different version number?



-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Cy Schubert
In message <20180403202233.gl1...@kib.kiev.ua>, Konstantin Belousov 
writes:
> On Tue, Apr 03, 2018 at 11:20:10PM +0300, Konstantin Belousov wrote:
> > On Tue, Apr 03, 2018 at 06:52:39PM +, Cy Schubert wrote:
> > > Modified: head/lib/libc/stdio/Symbol.map
> > > =
> =
> > > --- head/lib/libc/stdio/Symbol.mapTue Apr  3 18:43:00 2018
>   (r331935)
> > > +++ head/lib/libc/stdio/Symbol.mapTue Apr  3 18:52:38 2018
>   (r331936)
> > > @@ -165,6 +165,7 @@ FBSD_1.3 {
> > >  FBSD_1.4 {
> > >   fdclose;
> > >   fopencookie;
> > > + gets_s;
> > >  };
> > This is wrong.

I replied to this previously.

>
> And then, I noticed that the function is not added to the header file as well
> ,
> am I missing it ?

I my attempt to only commit gets_s() and nothing else I missed 
committing the header file. It's there now.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Konstantin Belousov
On Tue, Apr 03, 2018 at 11:20:10PM +0300, Konstantin Belousov wrote:
> On Tue, Apr 03, 2018 at 06:52:39PM +, Cy Schubert wrote:
> > Modified: head/lib/libc/stdio/Symbol.map
> > ==
> > --- head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:43:00 2018
> > (r331935)
> > +++ head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:52:38 2018
> > (r331936)
> > @@ -165,6 +165,7 @@ FBSD_1.3 {
> >  FBSD_1.4 {
> > fdclose;
> > fopencookie;
> > +   gets_s;
> >  };
> This is wrong.

And then, I noticed that the function is not added to the header file as well,
am I missing it ?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Konstantin Belousov
On Tue, Apr 03, 2018 at 06:52:39PM +, Cy Schubert wrote:
> Modified: head/lib/libc/stdio/Symbol.map
> ==
> --- head/lib/libc/stdio/Symbol.mapTue Apr  3 18:43:00 2018
> (r331935)
> +++ head/lib/libc/stdio/Symbol.mapTue Apr  3 18:52:38 2018
> (r331936)
> @@ -165,6 +165,7 @@ FBSD_1.3 {
>  FBSD_1.4 {
>   fdclose;
>   fopencookie;
> + gets_s;
>  };
This is wrong.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331936 - in head/lib/libc: stdio tests/stdio

2018-04-03 Thread Cy Schubert
Author: cy
Date: Tue Apr  3 18:52:38 2018
New Revision: 331936
URL: https://svnweb.freebsd.org/changeset/base/331936

Log:
  Add new gets_s(3) stdio function.
  
  This implements the gets_s(3) function as documented at
  http://en.cppreference.com/w/c/io/gets. It facilitates the
  optional removal of gets(3).
  
  Reviewed by:  ed
  MFC after:2 weeks
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D12785

Added:
  head/lib/libc/stdio/gets_s.c
 - copied, changed from r326083, head/lib/libc/stdio/gets.c
  head/lib/libc/tests/stdio/gets_s_test.c   (contents, props changed)
Modified:
  head/lib/libc/stdio/Makefile.inc
  head/lib/libc/stdio/Symbol.map
  head/lib/libc/stdio/fgets.3
  head/lib/libc/tests/stdio/Makefile

Modified: head/lib/libc/stdio/Makefile.inc
==
--- head/lib/libc/stdio/Makefile.incTue Apr  3 18:43:00 2018
(r331935)
+++ head/lib/libc/stdio/Makefile.incTue Apr  3 18:52:38 2018
(r331936)
@@ -14,7 +14,7 @@ SRCS+=_flock_stub.c asprintf.c clrerr.c dprintf.c \
fputwc.c fputws.c fread.c freopen.c fscanf.c fseek.c fsetpos.c \
ftell.c funopen.c fvwrite.c fwalk.c fwide.c fwprintf.c fwscanf.c \
fwrite.c getc.c getchar.c getdelim.c getline.c \
-   gets.c getw.c getwc.c getwchar.c makebuf.c mktemp.c \
+   gets.c gets_s.c getw.c getwc.c getwchar.c makebuf.c mktemp.c \
open_memstream.c open_wmemstream.c \
perror.c printf.c printf-pos.c putc.c putchar.c \
puts.c putw.c putwc.c putwchar.c \
@@ -50,6 +50,7 @@ MLINKS+=ferror.3 ferror_unlocked.3 \
ferror.3 fileno.3 ferror.3 fileno_unlocked.3
 MLINKS+=fflush.3 fpurge.3
 MLINKS+=fgets.3 gets.3
+MLINKS+=fgets.3 gets_s.3
 MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3
 MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 fopen.3 fmemopen.3
 MLINKS+=fputs.3 puts.3

Modified: head/lib/libc/stdio/Symbol.map
==
--- head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:43:00 2018
(r331935)
+++ head/lib/libc/stdio/Symbol.map  Tue Apr  3 18:52:38 2018
(r331936)
@@ -165,6 +165,7 @@ FBSD_1.3 {
 FBSD_1.4 {
fdclose;
fopencookie;
+   gets_s;
 };
 
 FBSDprivate_1.0 {

Modified: head/lib/libc/stdio/fgets.3
==
--- head/lib/libc/stdio/fgets.3 Tue Apr  3 18:43:00 2018(r331935)
+++ head/lib/libc/stdio/fgets.3 Tue Apr  3 18:52:38 2018(r331936)
@@ -46,6 +46,8 @@
 .Ft char *
 .Fn fgets "char * restrict str" "int size" "FILE * restrict stream"
 .Ft char *
+.Fn gets_s "char *str" "rsize_t size"
+.Ft char *
 .Fn gets "char *str"
 .Sh DESCRIPTION
 The
@@ -65,6 +67,17 @@ If any characters are read and there is no error, a
 character is appended to end the string.
 .Pp
 The
+.Fn gets_s
+function
+is equivalent to
+.Fn fgets
+with a
+.Fa stream
+of
+.Dv stdin ,
+except that the newline character (if any) is not stored in the string.
+.Pp
+The
 .Fn gets
 function
 is equivalent to
@@ -80,7 +93,8 @@ It is the caller's responsibility to ensure that the i
 if any, is sufficiently short to fit in the string.
 .Sh RETURN VALUES
 Upon successful completion,
-.Fn fgets
+.Fn fgets ,
+.Fn gets_s ,
 and
 .Fn gets
 return
@@ -94,7 +108,8 @@ they return
 .Dv NULL
 and the buffer contents are indeterminate.
 The
-.Fn fgets
+.Fn fgets ,
+.Fn gets_s ,
 and
 .Fn gets
 functions
@@ -141,6 +156,13 @@ and
 .Fn gets
 conform to
 .St -isoC-99 .
+.Fn gets_s
+conforms to
+.St -isoC-2011
+K.3.7.4.1.
+.Fn gets
+has been removed from
+.St -isoC-2011 .
 .Sh SECURITY CONSIDERATIONS
 The
 .Fn gets

Copied and modified: head/lib/libc/stdio/gets_s.c (from r326083, 
head/lib/libc/stdio/gets.c)
==
--- head/lib/libc/stdio/gets.c  Wed Nov 22 01:53:59 2017(r326083, copy 
source)
+++ head/lib/libc/stdio/gets_s.cTue Apr  3 18:52:38 2018
(r331936)
@@ -3,6 +3,8 @@
  *
  * Copyright (c) 1990, 1993
  * The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 2017, 2018
+ * Cyril S. E. Schubert.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Chris Torek.
@@ -32,49 +34,69 @@
  * SUCH DAMAGE.
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
 #include 
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include 
 #include 
+#include 
 #include 
 #include "un-namespace.h"
 #include "libc_private.h"
 #include "local.h"
 
-__warn_references(gets, "warning: this program uses gets(), which is unsafe.");
-
-char *
-gets(char *buf)
+static inline char *
+_gets_s(char *buf, rsize_t n)
 {
int c;
-   char *s, *ret;
-   static int warned;
-