public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-6289] bootstrap: std:stoul non-portable [PR 98412] Date: Mon, 21 Dec 2020 17:20:20 +0000 (GMT) [thread overview] Message-ID: <20201221172020.1857B386F818@sourceware.org> (raw) https://gcc.gnu.org/g:1467a5c5ab0dfbae3175b4a326467f939864dadb commit r11-6289-g1467a5c5ab0dfbae3175b4a326467f939864dadb Author: Nathan Sidwell <nathan@acm.org> Date: Mon Dec 21 09:16:48 2020 -0800 bootstrap: std:stoul non-portable [PR 98412] Fix some more system-specific issues. Not everyone's C++11 is the same :( PR bootstrap/98412 libcody/ * client.cc: Include cstdlib. * server.cc: Include cstdlib. gcc/cp/ * mapper-client.cc: INCLUDE_STRING, INCLUDE_VECTOR. (module_client::open_module_client): Avoid std::stoul. * mapper-resolver.cc: INCLUDE_STRING, INCLUDE_VECTOR. Diff: --- gcc/cp/mapper-client.cc | 20 ++++++++++++++------ gcc/cp/mapper-resolver.cc | 2 ++ libcody/client.cc | 1 + libcody/server.cc | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc index 2ad770b3d78..df821bab7e1 100644 --- a/gcc/cp/mapper-client.cc +++ b/gcc/cp/mapper-client.cc @@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see // will include it later under the above check #include <sys/socket.h> #endif +#define INCLUDE_STRING +#define INCLUDE_VECTOR #include "system.h" #include "line-map.h" @@ -171,14 +173,18 @@ module_client::open_module_client (location_t loc, const char *o, } else { + char *ptr; if (!from.empty ()) { - fd_from = std::stoul (from, &pos, 10); - if (pos != from.size ()) + /* Sadly str::stoul is not portable. */ + const char *cstr = from.c_str (); + fd_from = strtoul (cstr, &ptr, 10); + if (*ptr) { + /* Not a number -- a named pipe. */ int dir = to.empty () ? O_RDWR | O_CLOEXEC : O_RDONLY | O_CLOEXEC; - fd_from = open (from.c_str (), dir); + fd_from = open (cstr, dir); } if (to.empty ()) fd_to = fd_from; @@ -190,12 +196,14 @@ module_client::open_module_client (location_t loc, const char *o, ; else { - fd_to = std::stoul (to, &pos, 10); - if (pos != to.size ()) + const char *cstr = to.c_str (); + fd_to = strtoul (cstr, &ptr, 10); + if (*ptr) { + /* Not a number, a named pipe. */ int dir = from.empty () ? O_RDWR | O_CLOEXEC : O_WRONLY | O_CLOEXEC; - fd_to = open (to.c_str (), dir); + fd_to = open (cstr, dir); if (fd_to < 0) close (fd_from); } diff --git a/gcc/cp/mapper-resolver.cc b/gcc/cp/mapper-resolver.cc index 53c482441b4..e348757d99c 100644 --- a/gcc/cp/mapper-resolver.cc +++ b/gcc/cp/mapper-resolver.cc @@ -21,6 +21,8 @@ along with GCC; see the file COPYING3. If not see /* Forward to the resolver in c++tools. */ #include "config.h" +#define INCLUDE_STRING +#define INCLUDE_VECTOR #define INCLUDE_ALGORITHM #include "system.h" diff --git a/libcody/client.cc b/libcody/client.cc index 54111b851d0..edfe44d34b2 100644 --- a/libcody/client.cc +++ b/libcody/client.cc @@ -6,6 +6,7 @@ #include "internal.hh" // C #include <cerrno> +#include <cstdlib> #include <cstring> // Client code diff --git a/libcody/server.cc b/libcody/server.cc index b9ceec48a68..e2fa069bb93 100644 --- a/libcody/server.cc +++ b/libcody/server.cc @@ -8,6 +8,7 @@ #include <tuple> // C #include <cerrno> +#include <cstdlib> #include <cstring> // Server code
reply other threads:[~2020-12-21 17:20 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201221172020.1857B386F818@sourceware.org \ --to=nathan@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).