fix remaining usses with RH7.0 compile and also with systems with suboptimal string. not compile tested.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/lyx-1_1_5@1266 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-12-06 21:17:09 +00:00
parent 78531e008a
commit 13394206d1
6 changed files with 95 additions and 2 deletions

View File

@ -1,3 +1,15 @@
2000-12-06 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/lyx_cb.C (InsertAsciiFile): use a vector to temporary store
the file when std::string does not have push_back.
* config/lyxinclude.m4 (public): add LYX_CXX_GOOD_STD_STRING
* configure.in (INSTALL_SCRIPT): call LYX_CXX_GOOD_STD_STRING
* src/support/lstrings.C (prefixIs): use STD_STRING_IS_GOOD
(suffixIs): ditto
2000-12-06 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lib/layouts/lyxmacros.inc: do not use \verbatim@font in lyxcode.

View File

@ -376,6 +376,43 @@ dnl AC_MSG_RESULT([$with_included_string])
])
dnl Usage: LYX_CXX_GOOD_STD_STRING : checks whether the C++ compiler
dnl has a std::string that is close to the standard. So close that
dnl methods not found in "unstandard" std::strings are present here.
AC_DEFUN(LYX_CXX_GOOD_STD_STRING,[
AC_REQUIRE([LYX_PROG_CXX])
AC_CACHE_CHECK([whether the systems std::string is really good],
[lyx_cv_std_string_good],
[AC_TRY_COMPILE([
#include <string>
using std::string;
],[
// From a std::string that is supposed to be close to the
// standard we require at least three things:
// - clear() and erase()
// - the strncmp of compare()
// - push_back()
string a("hello there");
a.erase();
a = "hey";
char s[] = "y";
int t = a.compare(a.length() - 1, 1, s);
a.push_back('g');
a.clear();
],[
lyx_cv_std_string_good=yes
],[
lyx_cv_std_string_good=no
])
])
if test x$lyx_cv_std_string_good = xyes ; then
AC_DEFINE(STD_STRING_IS_GOOD, 1,
[Define if the systems std::string is really good.])
fi
])
dnl Usage: LYX_REGEX : checks if the header regex.h is available
dnl if it is not available the automake variable USE_REGEX will be
dnl defined and the regex.h and regex.c that we provide will be used.

View File

@ -376,6 +376,43 @@ dnl AC_MSG_RESULT([$with_included_string])
])
dnl Usage: LYX_CXX_GOOD_STD_STRING : checks whether the C++ compiler
dnl has a std::string that is close to the standard. So close that
dnl methods not found in "unstandard" std::strings are present here.
AC_DEFUN(LYX_CXX_GOOD_STD_STRING,[
AC_REQUIRE([LYX_PROG_CXX])
AC_CACHE_CHECK([whether the systems std::string is really good],
[lyx_cv_std_string_good],
[AC_TRY_COMPILE([
#include <string>
using std::string;
],[
// From a std::string that is supposed to be close to the
// standard we require at least three things:
// - clear() and erase()
// - the strncmp of compare()
// - push_back()
string a("hello there");
a.erase();
a = "hey";
char s[] = "y";
int t = a.compare(a.length() - 1, 1, s);
a.push_back('g');
a.clear();
],[
lyx_cv_std_string_good=yes
],[
lyx_cv_std_string_good=no
])
])
if test x$lyx_cv_std_string_good = xyes ; then
AC_DEFINE(STD_STRING_IS_GOOD, 1,
[Define if the systems std::string is really good.])
fi
])
dnl Usage: LYX_REGEX : checks if the header regex.h is available
dnl if it is not available the automake variable USE_REGEX will be
dnl defined and the regex.h and regex.c that we provide will be used.

View File

@ -77,6 +77,7 @@ dnl we do not use stl stack, or at least not on gcc 2.7, which was the
dnl cause for this test.
dnl LYX_CXX_STL_STACK
LYX_CXX_STL_STRING
LYX_CXX_GOOD_STD_STRING
LYX_CXX_NAMESPACES
LYX_CXX_CHEADERS
LYX_STD_COUNT

View File

@ -1147,10 +1147,16 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
ifs.unsetf(ios::skipws);
istream_iterator<char> ii(ifs);
istream_iterator<char> end;
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
vector<char> tmp;
copy(ii, end, back_inserter(tmp));
string tmpstr(tmp.begin(), tmp.end());
#else
//string tmpstr(ii, end); // yet a reason for using std::string
// alternate approach to get the file into a string:
string tmpstr;
copy(ii, end, back_inserter(tmpstr));
#endif
// insert the string
current_view->hideCursor();

View File

@ -176,7 +176,7 @@ bool prefixIs(string const & a, char const * pre)
if (l > a.length() || a.empty())
return false;
else {
#if !defined(USE_INCLUDED_STRING)
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
return ::strncmp(a.c_str(), pre, l) == 0;
#else
return a.compare(0, l, pre, l) == 0;
@ -198,7 +198,7 @@ bool suffixIs(string const & a, char const * suf)
if (suflen > a.length())
return false;
else {
#if !defined(USE_INCLUDED_STRING)
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
string const tmp(a, a.length() - suflen);
return ::strncmp(tmp.c_str(), suf, suflen) == 0;
#else