Partially undo r351659, which unconditionally removed gets(3) from libc++.

Instead, pull in r371324 from upstream libc++ trunk (by me):

  Remove ::gets for FreeBSD 13 and later

  Summary:

  In https://svnweb.freebsd.org/changeset/base/351659 @emaste removed
  gets() from FreeBSD 13's libc, and our copies of libc++ and
  libstdc++.  In that change, the declarations were simply deleted, but
  I would like to propose this conditional test instead.

  Reviewers: EricWF, mclow.lists, emaste

  Reviewed By: mclow.lists

  Subscribers: krytarowski, christof, ldionne, emaste, libcxx-commits

  Differential Revision: https://reviews.llvm.org/D67316

This makes these changes more MFCable.
This commit is contained in:
Dimitry Andric 2019-09-19 19:39:34 +00:00
parent 0f80acb965
commit 2ee8a62f0f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang900-import/; revision=352538
2 changed files with 11 additions and 0 deletions

View File

@ -1129,6 +1129,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_STDOUT
#endif
// Some systems do not provide gets() in their C library, for security reasons.
#ifndef _LIBCPP_C_HAS_NO_GETS
# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD__) && __FreeBSD__ >= 13)
# define _LIBCPP_C_HAS_NO_GETS
# endif
#endif
#if defined(__BIONIC__) || defined(__CloudABI__) || \
defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE

View File

@ -73,6 +73,7 @@ int fputc(int c, FILE* stream);
int fputs(const char* restrict s, FILE* restrict stream);
int getc(FILE* stream);
int getchar(void);
char* gets(char* s); // removed in C++14
int putc(int c, FILE* stream);
int putchar(int c);
int puts(const char* s);
@ -151,6 +152,9 @@ using ::tmpnam;
#ifndef _LIBCPP_HAS_NO_STDIN
using ::getchar;
#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS)
using ::gets;
#endif
using ::scanf;
using ::vscanf;
#endif