some nicer code...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@952 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-08-03 21:17:52 +00:00
parent c44a392c34
commit f4b8943ebb
20 changed files with 278 additions and 158 deletions

View File

@ -1,3 +1,80 @@
2000-08-03 Lars Gullik Bjønnes <larsbj@lyx.org>
* lib/lyxrc.example: mark te pdf options as non functional.
* src/support/lstrings.C (strToInt): move initalization of tmpstr
(isStrDbl): move tmpstr.end() out of loop.
(strToDbl): move intialization of tmpstr
(lowercase): return string const and move tmp.end() out of loop.
(uppercase): return string const and move tmp.edn() out of loop.
(prefixIs): add assertion
(suffixIs): ditto
(contains): ditto
(contains): ditto
(contains): ditto
(containsOnly): ditto
(containsOnly): ditto
(containsOnly): ditto
(countChar): make last arg char not char const
(token): return string const
(subst): return string const, move tmp.end() out of loop.
(subst): return string const, add assertion
(strip): return string const
(frontStrip): return string const, add assertion
(frontStrip): return string const
(split): ditto
(split): ditto
(rsplit): ditto
* src/support/lstrings.C: add inclde "LAssert.h"
(isStrInt): move tmpstr.end() out of loop.
* src/frontends/xforms/Toolbar_pimpl.C (activate): move
toollist.end() out of loop.
(deactivate): move toollist.end() out of loop.
(update): move toollist.end() out of loop.
(updateLayoutList): move tc.end() out of loop.
(add): move toollist.end() out of loop.
* src/frontends/xforms/Menubar_pimpl.C (create_submenu): move
md.end() out of loop.
* src/texrow.h: make getIdFromRow const, make rowlist mutable.
* src/texrow.C (getIdFromRow): make const, more rowlist.end() out
of loop.
* src/paragraph.C (Erase): move fontlist.end() out of loop.
(Erase): move insetlist.end() out of loop.
* src/lyx_sendfax_main.C: make show_logfile static and to take a
ref to const string as first arg. Move initialization of some
variables, whitespace changes.
* src/kbmap.C (defkey): move table.end() out of loop.
(kb_keymap): move table.end() out of loop.
(findbinding): move table.end() out of loop.
* src/MenuBackend.C (hasMenu): move end() out of loop.
(getMenu): move end() out of loop.
(getMenu): move menulist_.end() out of loop.
* src/Makefile.am (#lyx_LDFLAGS): interesting option commented out.
* src/LaTeXFeatures.C (getIncludedFiles): move IncludedFiles.end()
out of loop.
* src/LColor.C (getFromGUIName): move infotab.end() out of loop.
(getFromLyXName): move infotab.end() out of loop.
* config/lyxinclude.m4 (CXXFLAGS): change for 2.96 add
-fvtable-thunks -ffunction-sections -fdata-sections
2000-08-03 Dekel Tsur <dekel@math.tau.ac.il>
* src/frontends/xforms/RadioButtonGroup.h: Changed <forms.h> to
FORMS_H_LOCATION.
2000-08-03 Angus Leeming <a.leeming@ic.ac.uk>
* src/frontends/xforms/FormCommand.[Ch] (d-tor): removed

View File

@ -186,7 +186,7 @@ dnl Check the version of g++
case $gxx_version in
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
2.96*) CXXFLAGS="-g $lyx_opt -fhonor-std";;
2.96*) CXXFLAGS="-g $lyx_opt -fhonor-std -fvtable-thunks -ffunction-sections -fdata-sections";;
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
esac

View File

@ -186,7 +186,7 @@ dnl Check the version of g++
case $gxx_version in
2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
2.96*) CXXFLAGS="-g $lyx_opt -fhonor-std";;
2.96*) CXXFLAGS="-g $lyx_opt -fhonor-std -fvtable-thunks -ffunction-sections -fdata-sections";;
*2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
esac

View File

@ -118,6 +118,7 @@
# You can include any options you need by "quoting" the entire command
# The default is auto-detected, but you might want to override it.
# Usual values are: xpdf, acroread, gv, ghostscript.
# Warning: This option is not functional!
#\view_pdf_command "xpdf"
# Define which program to use to view postscript files here.
@ -401,13 +402,16 @@
# The command used to generate pdf files directly from a latex file.
# A program that works in anyother way is not guarantied to work.
# Warning: This option is not functional!
#\pdflatex_command pdflatex
# The command used to generate postscript files from pdf files.
# Warning: This option is not functional!
#\pdf_to_ps_command pdf2ps
# If to use pdf as native export format instead of dvi. This makes LyX use
# pdflatex, pdf2ps and other utility programs. Default is false.
# Warning: This option is not functional!
#\pdf_mode false
# The font encoding used for the LaTeX2e fontenc package.

View File

@ -191,7 +191,8 @@ bool LColor::setColor(string const & lyxname, string const & x11name)
LColor::color LColor::getFromGUIName(string const & guiname) const
{
InfoTab::const_iterator ici = infotab.begin();
for (; ici != infotab.end(); ++ici) {
InfoTab::const_iterator end = infotab.end();
for (; ici != end; ++ici) {
if (!compare_no_case((*ici).second.guiname, guiname))
return (*ici).first;
}
@ -203,7 +204,8 @@ LColor::color LColor::getFromLyXName(string const & lyxname) const
{
InfoTab::const_iterator ici = infotab.begin();
for (; ici != infotab.end(); ++ici) {
InfoTab::const_iterator end = infotab.end();
for (; ici != end; ++ici) {
if (!compare_no_case((*ici).second.lyxname, lyxname))
return (*ici).first;
}

View File

@ -350,9 +350,10 @@ string LaTeXFeatures::getTClassPreamble()
string LaTeXFeatures::getIncludedFiles()
{
string sgmlpreamble;
for(FileMap::const_iterator fi=IncludedFiles.begin(); fi != IncludedFiles.end(); ++fi)
sgmlpreamble += "\n<!entity " + fi->first + " system \"" + fi->second + "\">";
FileMap::const_iterator end = IncludedFiles.end();
for(FileMap::const_iterator fi=IncludedFiles.begin(); fi != end; ++fi)
sgmlpreamble += "\n<!entity " + fi->first
+ " system \"" + fi->second + "\">";
return sgmlpreamble;
}

View File

@ -24,7 +24,8 @@ extern bool CreatePostscript(Buffer * buffer, bool wait);
void MenuSendto()
{
static int ow = -1, oh;
static int ow = -1;
static int oh;
// do this only if the command is empty
if (!fl_get_input(fd_form_sendto->input_cmd) &&
@ -81,7 +82,8 @@ void SendtoApplyCB(FL_OBJECT *, long)
}
}
string fname = OnlyFilename(ChangeExtension(buffer->getLatexName(), ftypeext));
string fname = OnlyFilename(ChangeExtension(buffer->getLatexName(),
ftypeext));
if (!contains(command, "$$FName"))
command = "( " + command + " ) <$$FName";
command = subst(command, "$$FName", fname);

View File

@ -13,6 +13,7 @@ lyx_DEPENDENCIES = mathed/libmathed.la insets/libinsets.la \
frontends/libfrontends.la support/libsupport.la @INCLUDED_SIGC@
lyx_LDADD = $(lyx_DEPENDENCIES) @INTLLIBS@ $(LYX_LIBS) $(SIGC_LIBS) \
@FRONTEND_LDFLAGS@ @FRONTEND_LIBS@
#lyx_LDFLAGS=-Wl,-O1
EXTRA_DIST = config.h.in stamp-h.in cheaders
ETAGS_ARGS = --lang=c++
INCLUDES = $(SIGC_CFLAGS) @FRONTEND_INCLUDES@

View File

@ -274,7 +274,8 @@ void MenuBackend::add(Menu const & menu)
bool MenuBackend::hasMenu(string const & name) const
{
for (const_iterator cit = begin(); cit != end(); ++cit) {
const_iterator mend = end();
for (const_iterator cit = begin(); cit != mend; ++cit) {
if ((*cit).name() == name)
return true;
}
@ -284,7 +285,8 @@ bool MenuBackend::hasMenu(string const & name) const
Menu const & MenuBackend::getMenu(string const & name) const
{
for (const_iterator cit = begin(); cit != end(); ++cit) {
const_iterator mend = end();
for (const_iterator cit = begin(); cit != mend; ++cit) {
if ((*cit).name() == name)
return (*cit);
}
@ -295,8 +297,9 @@ Menu const & MenuBackend::getMenu(string const & name) const
Menu & MenuBackend::getMenu(string const & name)
{
MenuList::iterator end = menulist_.end();
for (MenuList::iterator cit = menulist_.begin();
cit != menulist_.end(); ++cit) {
cit != end; ++cit) {
if ((*cit).name() == name)
return (*cit);
}

View File

@ -290,7 +290,8 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
// not able to support shortcuts correctly...)
int max_width = 0;
string widest_label;
for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
Menu::const_iterator end = md.end();
for (Menu::const_iterator i = md.begin(); i != end; ++i) {
MenuItem item = (*i);
if (item.kind() == MenuItem::Command) {
string label = item.label() + '\t';
@ -305,11 +306,11 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
<< ", widest_label=`" << widest_label
<< "'" << endl;
for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
for (Menu::const_iterator i = md.begin(); i != end; ++i) {
MenuItem item = (*i);
// Is there a separator after this item?
string extra_label;
if ((i+1) != md.end()
if ((i+1) != end
&& (i+1)->kind() == MenuItem::Separator)
extra_label = "%l";

View File

@ -28,7 +28,7 @@
using std::vector;
using std::pair;
#include <forms.h>
#include FORMS_H_LOCATION
class RadioButtonGroup {
public:

View File

@ -146,7 +146,8 @@ extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event,
void Toolbar::Pimpl::activate()
{
ToolbarList::const_iterator p = toollist.begin();
for (; p != toollist.end(); ++p) {
ToolbarList::const_iterator end = toollist.end();
for (; p != end; ++p) {
if (p->icon) {
fl_activate_object(p->icon);
}
@ -157,7 +158,8 @@ void Toolbar::Pimpl::activate()
void Toolbar::Pimpl::deactivate()
{
ToolbarList::const_iterator p = toollist.begin();
for (; p != toollist.end(); ++p) {
ToolbarList::const_iterator end = toollist.end();
for (; p != end; ++p) {
if (p->icon) {
fl_deactivate_object(p->icon);
}
@ -167,7 +169,8 @@ void Toolbar::Pimpl::deactivate()
void Toolbar::Pimpl::update()
{
ToolbarList::const_iterator p = toollist.begin();
for (; p != toollist.end(); ++p) {
ToolbarList::const_iterator end = toollist.end();
for (; p != end; ++p) {
if (p->icon) {
int status = owner->getLyXFunc()->getStatus(p->action);
if (status & LyXFunc::ToggleOn) {
@ -213,8 +216,9 @@ void Toolbar::Pimpl::updateLayoutList(bool force)
LyXTextClass const & tc =
textclasslist.TextClass(owner->buffer()->
params.textclass);
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
cit != tc.end(); ++cit) {
cit != end; ++cit) {
if ((*cit).obsoleted_by().empty())
combox->addline(_((*cit).name().c_str()));
else
@ -335,7 +339,8 @@ void Toolbar::Pimpl::set(bool doingmain)
#endif
ToolbarList::iterator item = toollist.begin();
for (; item != toollist.end(); ++item) {
ToolbarList::iterator end = toollist.end();
for (; item != end; ++item) {
switch(item->action){
case ToolbarDefaults::SEPARATOR:
xpos += sepspace;
@ -424,7 +429,8 @@ void Toolbar::Pimpl::add(int action, bool doclean)
fl_freeze_form(owner->getForm());
ToolbarList::iterator p = toollist.begin();
for (; p != toollist.end(); ++p) {
ToolbarList::iterator end = toollist.end();
for (; p != end; ++p) {
p->clean();
}

View File

@ -172,8 +172,9 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/)
unsigned int modmsk = seq->modifiers[idx];
// --- check if key is already there --------------------------------
if (table.size() != 0) // without this I get strange crashes
for (Table::iterator it = table.begin(); it != table.end(); ++it) {
if (table.size() != 0) { // without this I get strange crashes
Table::iterator end = table.end();
for (Table::iterator it = table.begin(); it != end; ++it) {
if (code == (*it).code && modmsk == (*it).mod) {
// overwrite binding
if (idx + 1 == seq->length) {
@ -203,7 +204,8 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/)
}
}
}
}
Table::iterator newone = table.insert(table.end(), kb_key());
(*newone).code = code;
(*newone).mod = modmsk;
@ -229,7 +231,8 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/)
kb_keymap::~kb_keymap()
{
// This could be done by a destructor in kb_key.
for(Table::iterator it = table.begin(); it != table.end(); ++it) {
Table::iterator end = table.end();
for(Table::iterator it = table.begin(); it != end; ++it) {
delete (*it).table;
}
}
@ -249,8 +252,9 @@ string kb_keymap::findbinding(int act) const
string res;
if (table.empty()) return res;
Table::const_iterator end = table.end();
for(Table::const_iterator cit = table.begin();
cit != table.end(); ++cit) {
cit != end; ++cit) {
if ((*cit).table) {
string suffix = (*cit).table->findbinding(act);
suffix = strip(suffix, ' ');

View File

@ -16,9 +16,11 @@ using std::endl;
/* Prototypes */
bool sendfax(string const &fname, string const &sendcmd);
bool button_send(string const &fname, string const &sendcmd = string());
void show_logfile(string logfile, bool show_if_empty);
bool sendfax(string const & fname, string const & sendcmd);
bool button_send(string const & fname, string const & sendcmd = string());
static
void show_logfile(string const & logfile, bool show_if_empty);
const int LEN_PHONE = 20;
const int LEN_NAME = 25;
@ -29,11 +31,12 @@ string phone_book;
string global_sendcmd;
string filename;
FD_xsendfax *fd_xsendfax;
FD_phonebook *fd_phonebook;
FD_logfile *fd_logfile;
FD_xsendfax * fd_xsendfax;
FD_phonebook * fd_phonebook;
FD_logfile * fd_logfile;
bool send_fax(string const &fname, string const &sendcmd)
bool send_fax(string const & fname, string const & sendcmd)
{
// I put FAXCMD here to see if I can get rid of some strange errors. (Lgb)
string FAXCMD = "sendfax -n -h '$$Host' -c '$$Comment' -x '$$Enterprise' -d '$$Name'@'$$Phone' '$$FName'";
@ -42,7 +45,7 @@ bool send_fax(string const &fname, string const &sendcmd)
if (fname.empty())
return false;
path= OnlyPath(fname);
path = OnlyPath(fname);
if (path.empty() || path == "./")
filename = GetCWD() + "/" + fname;
else
@ -79,7 +82,8 @@ bool send_fax(string const &fname, string const &sendcmd)
title += OnlyFilename(fname);
/* show the first form */
fl_show_form(fd_xsendfax->xsendfax, FL_PLACE_MOUSE, FL_FULLBORDER, title.c_str());
fl_show_form(fd_xsendfax->xsendfax,
FL_PLACE_MOUSE, FL_FULLBORDER, title.c_str());
/*
while(true) {
obj = fl_do_forms();
@ -100,21 +104,18 @@ bool send_fax(string const &fname, string const &sendcmd)
}
bool button_send(string const &fname, string const &sendcmd)
bool button_send(string const & fname, string const & sendcmd)
{
string
name = fl_get_input(fd_xsendfax->Input_Name),
phone = fl_get_input(fd_xsendfax->Input_Phone),
enterprise = fl_get_input(fd_xsendfax->Input_Enterprise),
comment = fl_get_input(fd_xsendfax->Input_Comment),
host = GetEnv("FAX_SERVER"),
logfile,
cmd;
string name = fl_get_input(fd_xsendfax->Input_Name);
string phone = fl_get_input(fd_xsendfax->Input_Phone);
string enterprise = fl_get_input(fd_xsendfax->Input_Enterprise);
string comment = fl_get_input(fd_xsendfax->Input_Comment);
string host = GetEnv("FAX_SERVER");
if (phone.empty())
return false;
logfile = TmpFileName(OnlyPath(fname), "FAX");
cmd = sendcmd + " >";
string logfile = TmpFileName(OnlyPath(fname), "FAX");
string cmd = sendcmd + " >";
cmd += logfile + " 2>";
cmd += logfile;
cmd = subst(cmd, "$$Host", host);
@ -131,7 +132,7 @@ bool button_send(string const &fname, string const &sendcmd)
}
void cb_hide_form(FL_OBJECT *ob, long)
void cb_hide_form(FL_OBJECT * ob, long)
{
fl_hide_form(ob->form);
}
@ -139,23 +140,19 @@ void cb_hide_form(FL_OBJECT *ob, long)
void cb_select_phoneno(FL_OBJECT *, long)
{
int
i,
n= fl_get_browser_maxline(fd_phonebook->browser);
char const
*line;
int n = fl_get_browser_maxline(fd_phonebook->browser);
fl_hide_form(fd_phonebook->phonebook);
line = fl_get_browser_line(fd_phonebook->browser, 1);
char const * line = fl_get_browser_line(fd_phonebook->browser, 1);
if (!n || strstr(line, _("Empty Phonebook"))) {
fl_clear_browser(fd_phonebook->browser);
return;
}
i = fl_get_browser(fd_phonebook->browser);
int i = fl_get_browser(fd_phonebook->browser);
line = fl_get_browser_line(fd_phonebook->browser, i);
if (!line)
return;
char *buf = new char [strlen(line)+1];
char * buf = new char [strlen(line)+1];
strcpy(buf, line);
for(i = LEN_PHONE; (i > 0) && (buf[i] == ' '); --i)
@ -173,34 +170,31 @@ void cb_select_phoneno(FL_OBJECT *, long)
void cb_add_phoneno(FL_OBJECT *, long )
{
char const
*line;
char const
*name = fl_get_input(fd_xsendfax->Input_Name),
*phone = fl_get_input(fd_xsendfax->Input_Phone),
*enterprise = fl_get_input(fd_xsendfax->Input_Enterprise);
int
i, n;
char const * phone = fl_get_input(fd_xsendfax->Input_Phone);
if (!strlen(phone))
return;
char const * name = fl_get_input(fd_xsendfax->Input_Name);
char const * enterprise = fl_get_input(fd_xsendfax->Input_Enterprise);
char * buf = new char [50 + strlen(enterprise)];
sprintf(buf, "%-*.*s %-*.*s %s",
LEN_PHONE, LEN_PHONE, phone,
LEN_NAME, LEN_NAME, name,
enterprise);
n = fl_get_browser_maxline(fd_phonebook->browser);
int n = fl_get_browser_maxline(fd_phonebook->browser);
if (n) {
line = fl_get_browser_line(fd_phonebook->browser, 1);
char const * line = fl_get_browser_line(fd_phonebook->browser, 1);
if (strstr(line, _("Empty Phonebook"))) {
fl_clear_browser(fd_phonebook->browser);
n = 0;
}
}
for(i = 1; i <= n; ++i) {
line = fl_get_browser_line(fd_phonebook->browser, i);
int i = 1;
for(; i <= n; ++i) {
char const * line = fl_get_browser_line(fd_phonebook->browser, i);
if (!strncmp(buf, line, 46))
break;
}
@ -214,32 +208,31 @@ void cb_add_phoneno(FL_OBJECT *, long )
void cb_delete_phoneno(FL_OBJECT *, long )
{
char const
*line;
char const
*name = fl_get_input(fd_xsendfax->Input_Name),
*phone = fl_get_input(fd_xsendfax->Input_Phone),
*enterprise = fl_get_input(fd_xsendfax->Input_Enterprise);
int
i, n;
char const * phone = fl_get_input(fd_xsendfax->Input_Phone);
if (!strlen(phone))
return;
char *buf = new char [50+strlen(enterprise)];
char const * name = fl_get_input(fd_xsendfax->Input_Name);
char const * enterprise = fl_get_input(fd_xsendfax->Input_Enterprise);
char * buf = new char [50+strlen(enterprise)];
sprintf(buf, "%-*.*s %-*.*s %s",
LEN_PHONE, LEN_PHONE, phone,
LEN_NAME, LEN_NAME, name,
enterprise);
n = fl_get_browser_maxline(fd_phonebook->browser);
int n = fl_get_browser_maxline(fd_phonebook->browser);
if (n) {
line = fl_get_browser_line(fd_phonebook->browser, 1);
char const * line = fl_get_browser_line(fd_phonebook->browser, 1);
if (strstr(line, _("Empty Phonebook"))) {
fl_clear_browser(fd_phonebook->browser);
n = 0;
}
}
for(i = 1; i <= n; ++i) {
line = fl_get_browser_line(fd_phonebook->browser, i);
int i = 1;
for(; i <= n; ++i) {
char const * line = fl_get_browser_line(fd_phonebook->browser, i);
if (!strncmp(buf, line, 46))
break;
}
@ -253,27 +246,22 @@ void cb_delete_phoneno(FL_OBJECT *, long )
void cb_save_phoneno(FL_OBJECT *, long )
{
char const
*line;
int
i, n;
FILE
*fp;
if (!(fp = fopen(phone_book.c_str(), "w"))) {
FILE * fp = fopen(phone_book.c_str(), "w");
if (!fp) {
WriteAlert(_("Error!"), _("Cannot open phone book: "), phone_book);
return;
}
n = fl_get_browser_maxline(fd_phonebook->browser);
int n = fl_get_browser_maxline(fd_phonebook->browser);
if (n) {
line = fl_get_browser_line(fd_phonebook->browser, 1);
char const * line = fl_get_browser_line(fd_phonebook->browser, 1);
if (strstr(line, _("Empty Phonebook"))) {
fl_clear_browser(fd_phonebook->browser);
n = 0;
}
}
for(i = 1; i <= n; ++i) {
line = fl_get_browser_line(fd_phonebook->browser, i);
int i = 1;
for(; i <= n; ++i) {
char const * line = fl_get_browser_line(fd_phonebook->browser, i);
fprintf(fp, "%s\n", line);
}
fclose(fp);
@ -281,7 +269,9 @@ void cb_save_phoneno(FL_OBJECT *, long )
fl_redraw_form(fd_xsendfax->xsendfax);
}
void show_logfile(string logfile, bool show_if_empty)
static
void show_logfile(string const & logfile, bool show_if_empty)
{
if (logfile.empty())
return;
@ -300,31 +290,35 @@ void show_logfile(string logfile, bool show_if_empty)
}
}
void FaxLogfileCloseCB(FL_OBJECT *, long)
{
fl_hide_form(fd_logfile->logfile);
}
void FaxCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_xsendfax->xsendfax);
}
void FaxApplyCB(FL_OBJECT *, long)
{
button_send(filename, global_sendcmd);
}
void FaxSendCB(FL_OBJECT *, long)
{
if (button_send(filename, global_sendcmd))
FaxCancelCB(0, 0);
}
void FaxOpenPhonebookCB(FL_OBJECT *, long)
{
int
n= fl_get_browser_maxline(fd_phonebook->browser);
int n = fl_get_browser_maxline(fd_phonebook->browser);
if (!n)
fl_addto_browser(fd_phonebook->browser, _("@L@b@cEmpty Phonebook"));

View File

@ -609,16 +609,18 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
}
// Update all other entries.
for (; it != fontlist.end(); ++it)
FontList::iterator fend = fontlist.end();
for (; it != fend; ++it)
--(*it).pos;
// Update the inset table.
InsetTable search_inset(pos, 0);
InsetList::iterator lend = insetlist.end();
for (InsetList::iterator it =
upper_bound(insetlist.begin(),
insetlist.end(),
lend,
search_inset, matchIT());
it != insetlist.end(); ++it)
it != lend; ++it)
--(*it).pos;
#ifndef NEW_INSETS
} else {

View File

@ -22,6 +22,7 @@
#include "LString.h"
#include "lstrings.h"
#include "LRegex.h"
#include "LAssert.h"
using std::count;
using std::transform;
@ -88,20 +89,19 @@ bool isStrInt(string const & str)
string::const_iterator cit = tmpstr.begin();
if ( (*cit) == '-') ++cit;
for (; cit != tmpstr.end(); ++cit) {
string::const_iterator end = tmpstr.end();
for (; cit != end; ++cit) {
if (!isdigit((*cit))) return false;
}
return true;
}
int strToInt(string const & str)
int strToInt(string const & str)
{
string tmpstr;
if (isStrInt(str)) {
// Remove leading and trailing white space chars.
tmpstr = frontStrip(strip(str, ' '), ' ');
string tmpstr = frontStrip(strip(str, ' '), ' ');
// Do the conversion proper.
return atoi(tmpstr.c_str());
} else {
@ -110,8 +110,6 @@ int strToInt(string const & str)
}
///
bool isStrDbl(string const & str)
{
if (str.empty()) return false;
@ -124,7 +122,8 @@ bool isStrDbl(string const & str)
string::const_iterator cit = tmpstr.begin();
bool found_dot(false);
if ( (*cit) == '-') ++cit;
for (; cit != tmpstr.end(); ++cit) {
string::const_iterator end = tmpstr.end();
for (; cit != end; ++cit) {
if (!isdigit((*cit))
&& '.' != (*cit)) {
return false;
@ -140,14 +139,12 @@ bool isStrDbl(string const & str)
return true;
}
///
double strToDbl(string const & str)
{
string tmpstr;
if (isStrDbl(str)) {
// Remove leading and trailing white space chars.
tmpstr = frontStrip(strip(str, ' '), ' ');
string tmpstr = frontStrip(strip(str, ' '), ' ');
// Do the conversion proper.
return atof(tmpstr.c_str());
} else {
@ -155,25 +152,27 @@ double strToDbl(string const & str)
}
}
///
char lowercase(char c)
{
return tolower(c);
}
///
char uppercase(char c)
{
return toupper(c);
}
string lowercase(string const & a)
string const lowercase(string const & a)
{
string tmp(a);
//#ifdef __GLIBCPP__
string::iterator result = tmp.begin();
string::iterator end = tmp.end();
for (string::iterator first = tmp.begin();
first != tmp.end(); ++first, ++result) {
first != end; ++first, ++result) {
*result = lowercase(*first);
}
//#else
@ -183,13 +182,14 @@ string lowercase(string const & a)
}
string uppercase(string const & a)
string const uppercase(string const & a)
{
string tmp(a);
//#ifdef __GLIBCPP__
string::iterator result = tmp.begin();
string::iterator end = tmp.end();
for (string::iterator first = tmp.begin();
first != tmp.end(); ++first, ++result) {
first != end; ++first, ++result) {
*result = uppercase(*first);
}
//#else
@ -201,6 +201,8 @@ string uppercase(string const & a)
bool prefixIs(string const & a, char const * pre)
{
Assert(pre);
unsigned int l = strlen(pre);
if (l > a.length() || a.empty())
return false;
@ -228,7 +230,9 @@ bool suffixIs(string const & a, char c)
bool suffixIs(string const & a, char const * suf)
{
unsigned int suflen = strlen(suf);
Assert(suf);
unsigned int const suflen = strlen(suf);
if (suflen > a.length())
return false;
else {
@ -249,13 +253,17 @@ bool suffixIs(string const & a, char const * suf)
bool contains(char const * a, string const & b)
{
if (!a || !*a || b.empty()) return false;
Assert(a);
if (!*a || b.empty()) return false;
return strstr(a, b.c_str()) != 0;
}
bool contains(string const & a, char const * b)
{
Assert(b);
if (a.empty())
return false;
return a.find(b) != string::npos;
@ -272,13 +280,17 @@ bool contains(string const & a, string const & b)
bool contains(char const * a, char const * b)
{
if (!a || !b || !*a || !*b) return false;
Assert(a && b);
if (!*a || !*b) return false;
return strstr(a, b) != 0;
}
bool containsOnly(string const & s, char const * cset)
{
Assert(cset);
return s.find_first_not_of(cset) == string::npos;
}
@ -291,17 +303,21 @@ bool containsOnly(string const & s, string const & cset)
bool containsOnly(char const * s, char const * cset)
{
Assert(s && cset);
return string(s).find_first_not_of(cset) == string::npos;
}
bool containsOnly(char const * s, string const & cset)
{
Assert(s);
return string(s).find_first_not_of(cset) == string::npos;
}
unsigned int countChar(string const & a, char const c)
unsigned int countChar(string const & a, char c)
{
#ifdef HAVE_STD_COUNT
return count(a.begin(), a.end(), c);
@ -315,7 +331,7 @@ unsigned int countChar(string const & a, char const c)
// ale970405+lasgoutt-970425
// rewritten to use new string (Lgb)
string token(string const & a, char delim, int n)
string const token(string const & a, char delim, int n)
{
if (a.empty()) return string();
@ -342,7 +358,7 @@ string token(string const & a, char delim, int n)
int tokenPos(string const & a, char delim, string const & tok)
{
int i = 0;
string str = a;
string str(a);
string tmptok;
while (!str.empty()) {
@ -370,20 +386,23 @@ bool regexMatch(string const & a, string const & pattern)
}
string subst(string const & a, char oldchar, char newchar)
string const subst(string const & a, char oldchar, char newchar)
{
string tmp = a;
string tmp(a);
string::iterator lit = tmp.begin();
for(; lit != tmp.end(); ++lit)
string::iterator end = tmp.end();
for(; lit != end; ++lit)
if ((*lit) == oldchar)
(*lit) = newchar;
return tmp;
}
string subst(string const & a,
string const subst(string const & a,
char const * oldstr, string const & newstr)
{
Assert(oldstr);
string lstr(a);
string::size_type i = 0;
int olen = strlen(oldstr);
@ -396,10 +415,10 @@ string subst(string const & a,
}
string strip(string const & a, char const c)
string const strip(string const & a, char c)
{
if (a.empty()) return a;
string tmp = a;
string tmp(a);
string::size_type i = tmp.find_last_not_of(c);
if (i == a.length() - 1) return tmp; // no c's at end of a
if (i != string::npos)
@ -410,10 +429,12 @@ string strip(string const & a, char const c)
}
string frontStrip(string const & a, char const * p)
string const frontStrip(string const & a, char const * p)
{
if (a.empty() || !p || !*p) return a;
string tmp = a;
Assert(p);
if (a.empty() || !*p) return a;
string tmp(a);
string::size_type i = tmp.find_first_not_of(p);
if (i > 0)
tmp.erase(0, i);
@ -421,10 +442,10 @@ string frontStrip(string const & a, char const * p)
}
string frontStrip(string const & a, char const c)
string const frontStrip(string const & a, char c)
{
if (a.empty()) return a;
string tmp = a;
string tmp(a);
string::size_type i = tmp.find_first_not_of(c);
if (i > 0)
tmp.erase(0, i);
@ -432,7 +453,7 @@ string frontStrip(string const & a, char const c)
}
string split(string const & a, string & piece, char delim)
string const split(string const & a, string & piece, char delim)
{
string tmp;
string::size_type i = a.find(delim);
@ -451,7 +472,7 @@ string split(string const & a, string & piece, char delim)
}
string split(string const & a, char delim)
string const split(string const & a, char delim)
{
string tmp;
string::size_type i = a.find(delim);
@ -462,7 +483,7 @@ string split(string const & a, char delim)
// ale970521
string rsplit(string const & a, string & piece, char delim)
string const rsplit(string const & a, string & piece, char delim)
{
string tmp;
string::size_type i = a.rfind(delim);

View File

@ -65,15 +65,15 @@ char lowercase(char c);
char uppercase(char c);
///
string lowercase(string const &);
string const lowercase(string const &);
///
string uppercase(string const &);
string const uppercase(string const &);
// convert T to string
template<typename T>
inline
string tostr(T const & t)
string const tostr(T const & t)
{
#ifdef HAVE_SSTREAM
std::ostringstream ostr;
@ -95,7 +95,7 @@ string tostr(T const & t)
}
inline
string tostr(bool b)
string const tostr(bool b)
{
return (b ? "true" : "false");
}
@ -134,7 +134,7 @@ bool containsOnly(char const *, char const *);
bool containsOnly(char const *, string const &);
/// Counts how many of character c there is in a
unsigned int countChar(string const & a, char const c);
unsigned int countChar(string const & a, char c);
/** Extracts a token from this string at the nth delim.
Doesn't modify the original string. Similar to strtok.
@ -142,7 +142,7 @@ unsigned int countChar(string const & a, char const c);
#"a;bc;d".token(';', 1) == "bc";#
#"a;bc;d".token(';', 2) == "d";#
*/
string token(string const & a, char delim, int n);
string const token(string const & a, char delim, int n);
/** Search a token in this string using the delim.
@ -161,24 +161,24 @@ int tokenPos(string const & a, char delim, string const & tok);
bool regexMatch(string const & a, string const & pattern);
/// Substitute all "oldchar"s with "newchar"
string subst(string const & a, char oldchar, char newchar);
string const subst(string const & a, char oldchar, char newchar);
/// Substitutes all instances of oldstr with newstr
string subst(string const & a,
string const subst(string const & a,
char const * oldstr, string const & newstr);
/** Strips characters off the end of a string.
#"abccc".strip('c') = "ab".#
*/
string strip(string const & a, char const c = ' ');
string const strip(string const & a, char c = ' ');
/** Strips characters of the beginning of a string.
#"cccba".frontstrip('c') = "ba"#. */
string frontStrip(string const & a, char const c = ' ');
string const frontStrip(string const & a, char c = ' ');
/** Strips characters off the beginning of a string.
#"ababcdef".frontstrip("ab") = "cdef"# .*/
string frontStrip(string const & a, char const * p);
string const frontStrip(string const & a, char const * p);
/** Splits the string by the first delim.
Splits the string by the first appearance of delim.
@ -187,12 +187,12 @@ string frontStrip(string const & a, char const * p);
Example:
#s1= ""; s2= "a;bc".split(s1, ';') -> s1 == "a"; s2 == "bc";#
*/
string split(string const & a, string & piece, char delim);
string const split(string const & a, string & piece, char delim);
/// Same as split but does not return a piece
string split(string const & a, char delim);
string const split(string const & a, char delim);
/// Same as split but uses the last delim.
string rsplit(string const & a, string & piece, char delim);
string const rsplit(string const & a, string & piece, char delim);
#endif

View File

@ -51,19 +51,20 @@ void TexRow::newline()
}
void TexRow::getIdFromRow(int row, int & id, int & pos)
void TexRow::getIdFromRow(int row, int & id, int & pos) const
{
RowList::const_iterator cit = rowlist.begin();
for (; cit != rowlist.end(); ++cit) {
RowList::const_iterator end = rowlist.end();
for (; cit != end; ++cit) {
if ((*cit).rownumber() == row) break;
}
if (cit != rowlist.end()) {
if (cit != end) {
RowList::iterator kit = rowlist.begin();
// Increase the pos of all rows with the
// same id (and where the pos is larger)
// to avoid putting errorinsets at the
// same pos.
for(; kit != rowlist.end(); ++kit) {
for(; kit != end; ++kit) {
if (&(*kit) != &(*cit)
&& (*kit).id() == (*cit).id()
&& (*kit).pos() >= (*cit).pos())

View File

@ -36,7 +36,7 @@ public:
void newline();
/// Returns paragraph id and position from a row number
void getIdFromRow(int row, int & id, int & pos);
void getIdFromRow(int row, int & id, int & pos) const;
/// Appends another TexRow
TexRow & operator+= (TexRow const &);
@ -87,7 +87,7 @@ private:
///
typedef std::list<RowItem> RowList;
///
RowList rowlist;
mutable RowList rowlist;
/// Last paragraph
LyXParagraph * lastpar;
/// Last position

View File

@ -330,7 +330,8 @@ void LyXText::ComputeBidiTables(Buffer const * buf, Row * row) const
}
LyXParagraph::size_type vpos = bidi_start - 1;
for (LyXParagraph::size_type lpos = bidi_start; lpos <= bidi_end; ++lpos) {
for (LyXParagraph::size_type lpos = bidi_start;
lpos <= bidi_end; ++lpos) {
vpos += log2vis_list[lpos - bidi_start];
vis2log_list[vpos - bidi_start] = lpos;
log2vis_list[lpos - bidi_start] = vpos;