erase->clear, AM_CONDTIONAL for conditional compilation of lyxstring, better LYX_CXX_STL_STRING

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@214 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 1999-10-19 20:59:27 +00:00
parent 2f3e0b32e6
commit bd29a5db31
20 changed files with 108 additions and 79 deletions

View File

@ -1,5 +1,20 @@
1999-10-19 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/support/lyxstring.C: removed the compilation guards
* src/vspace.C (nextToken): use i + 1 instead of ++i. Maks things
a bit clearer.
* src/support/Makefile.am (LYXSTRING): bruker USE_LYXSTRING for
conditional compile of lyxstring.Ch
* acinclude.m4 (LYX_CXX_STL_STRING): new and improved, still a
stupid check, but it is a lot better than the bastring hack.
(LYX_CXX_STL_STRING): bruker nå AM_CONDITIONAL(USE_LYXSTRING
* several files: changed string::erase into string::clear. Not
really needed.
* src/chset.C (encodeString): use a char temporary instead
* src/table.C (TexEndOfCell): added tostr around

View File

@ -294,18 +294,35 @@ fi])
dnl Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler
dnl has a working stl string container
dnl has a working stl string container, the check is really stupid
dnl and could need some improvement.
AC_DEFUN(LYX_CXX_STL_STRING,[
AC_ARG_WITH(included-string,
[ --with-included-string use LyX string class instead of STL string],,
[AC_CHECK_HEADER(std/bastring.h,
[with_included_string=yes],
[with_included_string=no])])
if test x$with_included_string = xyes ; then
AC_DEFINE(USE_INCLUDED_STRING, 1,
[Define to use the LString class bundled with LyX])
lyx_flags="$lyx_flags included-string"
fi])
AC_REQUIRE([LYX_PROG_CXX])
AC_MSG_CHECKING(Use the included std::string)
AC_ARG_WITH(included-string,[
--with-included-string use LyX string class instead of STL string
],[
with_included_string=$withval
],[
AC_TRY_COMPILE([
#include <string>
],[
string a("hello there");
a.clear();
a = "hey";
a.erase();
],[
with_included_string=no
],[
with_included_string=yes
AC_DEFINE(USE_INCLUDED_STRING, 1,
[Define to use the lyxstring class bundled with LyX.])
lyx_flags="$lyx_flags included-string"
])
])
AM_CONDITIONAL(USE_LYXSTRING, test x$with_included_string = xyes)
AC_MSG_RESULT([$with_included_string])
])
dnl LYX_CXX_MUTABLE

View File

@ -119,7 +119,7 @@ Buffer::Buffer(string const & file, LyXRC *lyxrc, bool ronly)
lyxerr.debug() << "Buffer::Buffer()" << endl;
if (read_only || (lyxrc && lyxrc->use_tempdir)) {
tmppath = CreateBufferTmpDir();
} else tmppath.erase();
} else tmppath.clear();
}
@ -1871,7 +1871,7 @@ void Buffer::makeLaTeXFile(string const & filename,
// Write out what we've generated so far...and reset LFile
fwrite(LFile.c_str(), sizeof(char), LFile.length(), file);
LFile.erase();
LFile.clear();
// Now insert the LyX specific LaTeX commands...
string preamble, tmppreamble;
@ -2000,7 +2000,7 @@ void Buffer::makeLaTeXFile(string const & filename,
}
LFile += ftnote;
texrow += ft_texrow;
ftnote.erase();
ftnote.clear();
ft_texrow.reset();
ftcount = 0;
}
@ -2011,7 +2011,7 @@ void Buffer::makeLaTeXFile(string const & filename,
// LFile.length() in a future revision. ARRae
fwrite(LFile.c_str(), sizeof(char),
LFile.length(), file);
LFile.erase();
LFile.clear();
loop_count = 0;
}
}
@ -2037,7 +2037,7 @@ void Buffer::makeLaTeXFile(string const & filename,
// Write out what we've generated...and reset LFile
fwrite(LFile.c_str(), sizeof(char), LFile.length(), file);
LFile.erase();
LFile.clear();
// tex_code_break_column's value is used to decide
// if we are in batchmode or not (within mathed_write()
@ -2165,7 +2165,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column)
/* environment tag closing */
for( ;depth > par->depth; depth--) {
sgmlCloseTag(file,depth,environment_stack[depth]);
environment_stack[depth].erase();
environment_stack[depth].clear();
}
/* write opening SGML tags */
@ -2174,7 +2174,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column)
if(depth == par->depth
&& !environment_stack[depth].empty()) {
sgmlCloseTag(file,depth,environment_stack[depth]);
environment_stack[depth].erase();
environment_stack[depth].clear();
if(depth)
depth--;
else
@ -2192,7 +2192,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column)
fprintf(file, "</p>");
}
environment_stack[depth].erase();
environment_stack[depth].clear();
sgmlOpenTag(file,depth, style->latexname);
break;
@ -2203,11 +2203,11 @@ void Buffer::makeLinuxDocFile(string const & filename, int column)
&& !environment_stack[depth].empty()) {
sgmlCloseTag(file,depth,environment_stack[depth]);
environment_stack[depth].erase();
environment_stack[depth].clear();
}
if (depth < par->depth) {
depth = par->depth;
environment_stack[depth].erase();
environment_stack[depth].clear();
}
if (environment_stack[depth] != style->latexname) {
if(depth==0) {
@ -2331,7 +2331,7 @@ void Buffer::DocBookHandleFootnote(FILE *file,LyXParagraph* &par, int const dept
if(inner_span) {
if(!tmp_par.empty()) {
fprintf(file,"%s",tmp_par.c_str());
tmp_par.erase();
tmp_par.clear();
sgmlCloseTag(file,depth+1,inner_tag);
sgmlOpenTag(file,depth+1,inner_tag);
}
@ -2343,7 +2343,7 @@ void Buffer::DocBookHandleFootnote(FILE *file,LyXParagraph* &par, int const dept
if(!inner_tag.empty()) sgmlCloseTag(file,depth+1,inner_tag);
if(!extra_par.empty()) fprintf(file,"%s",extra_par.c_str());
if(!tag.empty()) sgmlCloseTag(file,depth,tag);
extra_par.erase();
extra_par.clear();
switch (par->footnotekind) {
case LyXParagraph::FOOTNOTE:
@ -2378,7 +2378,7 @@ void Buffer::DocBookHandleFootnote(FILE *file,LyXParagraph* &par, int const dept
if ((present == TAB_LIKE) || (present == FIG_LIKE)) {
DocBookHandleCaption(file, inner_tag, depth,
desc_on, par);
inner_tag.erase();
inner_tag.clear();
} else {
sgmlOpenTag(file,depth+1,inner_tag);
}
@ -2741,8 +2741,8 @@ void Buffer::makeDocBookFile(string const & filename, int column)
}
sgmlCloseTag(file,depth+command_depth,
environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
environment_stack[depth].clear();
environment_inner[depth].clear();
}
if(depth == par->depth
@ -2760,8 +2760,8 @@ void Buffer::makeDocBookFile(string const & filename, int column)
sgmlCloseTag(file,depth+command_depth,
environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
environment_stack[depth].clear();
environment_inner[depth].clear();
}
// Write opening SGML tags.
@ -2832,7 +2832,7 @@ void Buffer::makeDocBookFile(string const & filename, int column)
case LATEX_ITEM_ENVIRONMENT:
if (depth < par->depth) {
depth = par->depth;
environment_stack[depth].erase();
environment_stack[depth].clear();
}
if (environment_stack[depth] != style->latexname) {

View File

@ -31,7 +31,7 @@ void CharacterSet::freeMap()
delete t;
}
name_.erase();
name_.clear();
}

View File

@ -1905,7 +1905,7 @@ void InsetFig::CallbackFig(long arg)
} else {
if (!fname.empty()) {
changedfname = true;
fname.erase();
fname.clear();
}
}
subcaption = fl_get_input(form->Subcaption);

View File

@ -417,7 +417,7 @@ string InsetBibtex::getKeys()
keys += strip(tmp) + ",";
}
}
linebuf.erase();
linebuf.clear();
} else {
linebuf += c;
}

View File

@ -225,7 +225,7 @@ void LyX::init(int */*argc*/, char **argv)
lyxerr[Debug::INIT]
<< "Checking whether LyX is run in place... no"
<< endl;
build_lyxdir.erase();
build_lyxdir.clear();
}

View File

@ -337,7 +337,7 @@ void LyXComm::callback(int fd, void *v)
{
lyxerr << "LyxComm: truncated command: "
<< lsbuf << endl;
lsbuf.erase();
lsbuf.clear();
}
break; // reset connection
}
@ -485,7 +485,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
}
if (i<serv->numclients) {
serv->numclients--;
serv->clients[i].erase();
serv->clients[i].clear();
lyxerr[Debug::LYXSERVER]
<< "LyXServer: Client "
<< client << " said goodbye"

View File

@ -589,7 +589,7 @@ void InsetFormula::SetDisplay(bool dspf)
par->SetType(LM_OT_MIN);
par->SetStyle(LM_ST_TEXT);
if (!label.empty() && par->GetType()!=LM_OT_MPARN) {
label.erase();
label.clear();
}
}
disp_flag = dspf;
@ -890,7 +890,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
if (oldf) {
type--;
if (!label.empty()) {
label.erase();
label.clear();
}
minibuffer->Set(_("No number"));
} else {
@ -1038,7 +1038,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
}
UpdateLocal();
} else
label.erase();
label.clear();
//label = 0;
break;
}

View File

@ -60,7 +60,7 @@ void MiniBuffer::ExecutingCB(FL_OBJECT *ob, long)
function = strip(function);
} else {
function = arg;
arg.erase();
arg.clear();
}
lyxerr.debug() << "Function: " << function
<< "\nArg : " << arg << endl;
@ -95,7 +95,7 @@ void MiniBuffer::ExecutingCB(FL_OBJECT *ob, long)
void MiniBuffer::ExecCommand()
{
text.erase();
text.clear();
fl_set_input(the_buffer, "");
fl_set_focus_object(owner->getForm(),the_buffer);
}
@ -207,7 +207,7 @@ void MiniBuffer::Reset()
{
if (!text_stored.empty()){
Set(text_stored);
text_stored.erase();
text_stored.clear();
}
}

View File

@ -482,14 +482,14 @@ void LyXParagraph::Clear()
noindent = false;
pextra_type = PEXTRA_NONE;
pextra_width.erase();
pextra_widthp.erase();
pextra_width.clear();
pextra_widthp.clear();
pextra_alignment = MINIPAGE_ALIGN_TOP;
pextra_hfill = false;
pextra_start_minipage = false;
labelstring.erase();
labelwidthstring.erase();
labelstring.clear();
labelwidthstring.clear();
layout = 0;
bibkey = 0;
@ -1736,7 +1736,7 @@ void LyXParagraph::SetLayout(char new_layout)
*npar = 0;
par->layout = new_layout;
par->labelwidthstring.erase();
par->labelwidthstring.clear();
par->align = LYX_ALIGN_LAYOUT;
//par->depth = 0;
par->added_space_top = VSpace(VSpace::NONE);
@ -2529,7 +2529,7 @@ bool LyXParagraph::linuxDocConvertChar(char c, string &sgml_string)
bool retval = false;
switch (c) {
case LYX_META_HFILL:
sgml_string.erase();
sgml_string.clear();
break;
case LYX_META_PROTECTED_SEPARATOR:
sgml_string = ' ';
@ -2581,7 +2581,7 @@ bool LyXParagraph::linuxDocConvertChar(char c, string &sgml_string)
sgml_string = ' ';
break;
case '\0': /* Ignore :-) */
sgml_string.erase();
sgml_string.clear();
break;
default:
sgml_string = c;
@ -3531,7 +3531,7 @@ LyXParagraph* LyXParagraph::TeXEnvironment(string &file, TexRow &texrow,
}
file += foot;
texrow += foot_texrow;
foot.erase();
foot.clear();
foot_texrow.reset();
foot_count = 0;
}
@ -3851,8 +3851,8 @@ void LyXParagraph::UnsetPExtraType()
return;
pextra_type = PEXTRA_NONE;
pextra_width.erase();
pextra_widthp.erase();
pextra_width.clear();
pextra_widthp.clear();
if (lyxstyle.Style(GetCurrentTextClass(),
layout)->isEnvironment()) {
@ -3874,8 +3874,8 @@ void LyXParagraph::UnsetPExtraType()
par = ppar;
while (par && (par->layout == layout) && (par->depth == depth)) {
par->pextra_type = PEXTRA_NONE;
par->pextra_width.erase();
par->pextra_widthp.erase();
par->pextra_width.clear();
par->pextra_widthp.clear();
par = par->NextAfterFootnote();
if (par && (par->depth > depth))
par->UnsetPExtraType();

View File

@ -3,6 +3,11 @@ noinst_LIBRARIES = libsupport.a
libsupport_a_LIBADD = @LIBOBJS@
ETAGS_ARGS = --c++
INCLUDES = -I${srcdir}/../
if USE_LYXSTRING
LYXSTRING = lyxstring.C lyxstring.h
endif
libsupport_a_SOURCES = \
DebugStream.C \
DebugStream.h \
@ -14,9 +19,7 @@ libsupport_a_SOURCES = \
lstrings.C \
lstrings.h \
lyxlib.h \
lyxstring.C \
lyxstring.h \
lyxsum.C \
$(LYXSTRING) lyxsum.C \
path.h \
syscall.C \
syscall.h \
@ -24,3 +27,4 @@ libsupport_a_SOURCES = \
syscontr.h \
syssingleton.C \
textutils.h

View File

@ -738,7 +738,7 @@ string ReplaceEnvironmentPath(string const & path)
if (!regexMatch(copy1, RegExp)) {
// No EndChar inside. So we are finished
result1 += CompareString + result0;
result0.erase();
result0.clear();
continue;
}

View File

@ -313,7 +313,7 @@ string strip(string const & a, char const c)
if (i != string::npos)
tmp.erase(i + 1, string::npos);
else
tmp.erase(); // only c in the whole string
tmp.clear(); // only c in the whole string
return tmp;
}
@ -350,7 +350,7 @@ string split(string const & a, string & piece, char delim)
piece = a.substr(0, i);
tmp = a.substr(i + 1);
} else if (i == 0) {
piece.erase();
piece.clear();
tmp = a.substr(i + 1);
} else {
piece = a;
@ -378,7 +378,7 @@ string rsplit(string const & a, string & piece, char delim)
piece = a.substr(0, i);
tmp = a.substr(i + 1);
} else { // delimter was not found
piece.erase();
piece.clear();
}
return tmp;
}

View File

@ -12,9 +12,6 @@
#include <config.h>
#endif
// If we use STL string, there is no need to compile this class.
#ifdef USE_INCLUDED_STRING
#ifdef __GNUG__
#pragma implementation "lyxstring.h"
#endif
@ -1622,5 +1619,3 @@ istream & getline(istream & is, lyxstring & s,
}
return is;
}
#endif /* USE_INCLUDED_STRING */

View File

@ -284,7 +284,7 @@ int LyXText::LeftMargin(Row* row)
/* table stuff -- begin*/
if (row->par->table)
parindent.erase();
parindent.clear();
/* table stuff -- end*/
x = LYX_PAPER_MARGIN;
@ -307,7 +307,7 @@ int LyXText::LeftMargin(Row* row)
if (row->par->FirstPhysicalPar()->Previous()) {
newpar = row->par->DepthHook(row->par->GetDepth());
if (newpar && lyxstyle.Style(parameters->textclass, newpar->GetLayout())->nextnoindent)
parindent.erase();
parindent.clear();
}
}
}
@ -337,7 +337,7 @@ int LyXText::LeftMargin(Row* row)
if (newpar && !row->par->GetLayout()) {
if (newpar->FirstPhysicalPar()->noindent)
parindent.erase();
parindent.clear();
else
parindent = lyxstyle.Style(parameters->textclass,
newpar->GetLayout())->parindent;

View File

@ -1463,7 +1463,7 @@ void LyXText::SetCounter(LyXParagraph *par)
}
if (!par->labelstring.empty()) {
par->labelstring.erase();
par->labelstring.clear();
}
if (layout->margintype == MARGIN_MANUAL) {
@ -1489,13 +1489,13 @@ void LyXText::SetCounter(LyXParagraph *par)
if (!layout->labelstring.empty())
par->labelstring = layout->labelstring;
else
par->labelstring.erase();
par->labelstring.clear();
}
else {
if (!layout->labelstring_appendix.empty())
par->labelstring = layout->labelstring_appendix;
else
par->labelstring.erase();
par->labelstring.clear();
}
if (!par->appendix){

View File

@ -390,7 +390,7 @@ int Trans::Load(string const &language)
if (res==0) {
name_=language;
} else
name_.erase();
name_.clear();
return res;
}

View File

@ -381,7 +381,7 @@ void TransManager::deadkey(char c,tex_accent accent,LyXText *t)
if (active_==default_ || c==0) {
i.accent=accent;
i.allowed=lyx_accent_table[accent].native;
i.data.erase();
i.data.clear();
i.exception_list=0;
string res=trans_fsm_.currentState->deadkey(c,i);

View File

@ -94,11 +94,10 @@ static char nextToken (string & data)
// I really mean assignment ("=") below, not equality!
if ((i = data.find_last_of("0123456789.")) != string::npos) {
if (number_index > 3) return 'E'; // Error
++i;
string buffer = data.substr(0, i);
string buffer = data.substr(0, i + 1);
if (sscanf (buffer.c_str(),
"%f", &number[number_index]) == 1) {
advance (data, i);
advance (data, i + 1);
++number_index;
return 'n';
} else
@ -106,11 +105,10 @@ static char nextToken (string & data)
} else if ((i=data.find_last_of("abcdefghijklmnopqrstuvwxyz"))
!= string::npos) {
if (unit_index > 3) return 'E'; // Error
++i;
string buffer = data.substr(0, i);
string buffer = data.substr(0, i + 1);
unit[unit_index] = unitFromString (buffer);
if (unit[unit_index] != LyXLength::UNIT_NONE) {
advance (data, i);
advance (data, i + 1);
++unit_index;
return 'u';
} else