# HG changeset patch # User John W. Eaton # Date 1466196669 14400 # Node ID 4b2eab5d2a6abf53a02a13df5f9e526bd33536de # Parent 2fc1ce5deae48279894c7bb220dc79431f4e76c2 provide wrapper for strdup * liboctave/wrappers/strdup-wrapper.c, liboctave/wrappers/strdup-wrapper.h: New files. * liboctave/wrappers/module.mk: Update. * bootstrap.conf: Include strdup module in the list. * cmd-edit.cc, main.in.cc: Use wrapper function. diff -r 2fc1ce5deae4 -r 4b2eab5d2a6a bootstrap.conf --- a/bootstrap.conf Fri Jun 17 14:39:59 2016 -0400 +++ b/bootstrap.conf Fri Jun 17 16:51:09 2016 -0400 @@ -95,6 +95,7 @@ stddef stdint stdio + strdup strerror strftime strptime diff -r 2fc1ce5deae4 -r 4b2eab5d2a6a liboctave/util/cmd-edit.cc --- a/liboctave/util/cmd-edit.cc Fri Jun 17 14:39:59 2016 -0400 +++ b/liboctave/util/cmd-edit.cc Fri Jun 17 16:51:09 2016 -0400 @@ -40,6 +40,7 @@ #include "oct-time.h" #include "quit.h" #include "singleton-cleanup.h" +#include "strdup-wrapper.h" #include "unistd-wrappers.h" #if defined (USE_READLINE) @@ -568,7 +569,7 @@ char * gnu_readline::do_completer_word_break_hook () { - static char *dir_sep = strdup (" '\""); + static char *dir_sep = octave_strdup_wrapper (" '\""); std::string word; std::string line = get_line_buffer (); diff -r 2fc1ce5deae4 -r 4b2eab5d2a6a liboctave/wrappers/module.mk --- a/liboctave/wrappers/module.mk Fri Jun 17 14:39:59 2016 -0400 +++ b/liboctave/wrappers/module.mk Fri Jun 17 16:51:09 2016 -0400 @@ -17,6 +17,7 @@ liboctave/wrappers/set-program-name-wrapper.h \ liboctave/wrappers/signal-wrappers.h \ liboctave/wrappers/stat-wrappers.h \ + liboctave/wrappers/strdup-wrapper.h \ liboctave/wrappers/strftime-wrapper.h \ liboctave/wrappers/strmode-wrapper.h \ liboctave/wrappers/strptime-wrapper.h \ @@ -47,6 +48,7 @@ liboctave/wrappers/set-program-name-wrapper.c \ liboctave/wrappers/signal-wrappers.c \ liboctave/wrappers/stat-wrappers.c \ + liboctave/wrappers/strdup-wrapper.c \ liboctave/wrappers/strftime-wrapper.c \ liboctave/wrappers/strmode-wrapper.c \ liboctave/wrappers/strptime-wrapper.c \ diff -r 2fc1ce5deae4 -r 4b2eab5d2a6a liboctave/wrappers/strdup-wrapper.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/wrappers/strdup-wrapper.c Fri Jun 17 16:51:09 2016 -0400 @@ -0,0 +1,39 @@ +/* + +Copyright (C) 2016 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +// strdup may be provided by gnulib. We don't include gnulib headers +// directly in Octave's C++ source files to avoid problems that may be +// caused by the way that gnulib overrides standard library functions. + +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + +#include + +#include "strdup-wrapper.h" + +char * +octave_strdup_wrapper (const char *str) +{ + return strdup (str); +} diff -r 2fc1ce5deae4 -r 4b2eab5d2a6a liboctave/wrappers/strdup-wrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/wrappers/strdup-wrapper.h Fri Jun 17 16:51:09 2016 -0400 @@ -0,0 +1,36 @@ +/* + +Copyright (C) 2016 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#if ! defined (octave_strdup_wrapper_h) +#define octave_strdup_wrapper_h 1 + +#if defined __cplusplus +extern "C" { +#endif + +extern char *octave_strdup_wrapper (const char *str); + +#if defined __cplusplus +} +#endif + +#endif diff -r 2fc1ce5deae4 -r 4b2eab5d2a6a src/main.in.cc --- a/src/main.in.cc Fri Jun 17 14:39:59 2016 -0400 +++ b/src/main.in.cc Fri Jun 17 16:51:09 2016 -0400 @@ -41,6 +41,7 @@ #include "fcntl-wrappers.h" #include "signal-wrappers.h" +#include "strdup-wrapper.h" #include "unistd-wrappers.h" #include "wait-wrappers.h" @@ -236,7 +237,7 @@ const char *string = argv[i]; if (string[0] == '\0') - new_argv[i] = strdup ("\"\""); + new_argv[i] = octave_strdup_wrapper ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);