From 6130fe1aa5c07d0204205bcf5dd1f86b8449fb16 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Mon, 13 Dec 1999 00:05:34 +0000 Subject: [PATCH] read the ChangeLog, use the C++ style casts more, some changes to the debugbufs, some whitespace changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@366 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 19 + acinclude.m4 | 4 +- configure.in | 1 - src/BufferView.C | 67 ++-- src/FontInfo.C | 4 +- src/LyXAction.C | 741 ++++++++++++++++---------------------- src/Makefile.am | 7 +- src/bmtable.C | 12 +- src/buffer.C | 6 +- src/bufferlist.C | 3 +- src/combox.C | 41 ++- src/combox.h | 4 +- src/debug.h | 2 - src/insets/figinset.C | 56 +-- src/insets/insetinclude.h | 2 +- src/insets/insetquotes.C | 6 +- src/kbmap.C | 8 +- src/lyx_cb.C | 2 +- src/lyx_gui.C | 12 +- src/lyx_main.C | 7 +- src/lyxdraw.C | 2 +- src/lyxfont.C | 7 +- src/lyxfunc.C | 2 +- src/lyxserver.C | 2 +- src/lyxtext.h | 2 + src/mathed/formula.C | 20 +- src/mathed/formulamacro.C | 2 +- src/mathed/math_cursor.C | 185 +++++----- src/mathed/math_delim.C | 26 +- src/mathed/math_iter.C | 4 +- src/mathed/math_macro.C | 6 +- src/mathed/math_parser.C | 8 +- src/mathed/math_symbols.C | 8 +- src/mathed/math_write.C | 14 +- src/spellchecker.C | 6 +- src/support/DebugStream.C | 27 +- src/support/DebugStream.h | 2 +- src/support/LSubstring.C | 4 +- src/support/lyxlib.h | 6 +- src/support/lyxsum.C | 40 +- src/support/syscall.C | 8 +- src/support/syscontr.C | 4 +- src/table.C | 20 +- src/tex-accent.C | 14 +- src/text.C | 58 +-- src/toolbar.C | 14 +- src/trans.C | 25 +- src/trans.h | 6 +- src/trans_mgr.C | 4 +- src/vspace.C | 4 +- 50 files changed, 747 insertions(+), 787 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49e076a1a1..0924cb4ede 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +1999-12-12 Lars Gullik Bjønnes + + * Makefile.in.in (MKINSTALLDIRS): use $(srcdir)/@MKINSTALLDIRS@ + * intl/Makefile.in (MKINSTALLDIRS): ditto + + * src/LyXAction.C (init): changed to hold the LFUN data in a + automatic array in stead of in callso to newFunc, this speeds up + compilation a lot. Also all the memory used by the array is + returned when the init is completed. + + * a lot of files: compiled with -Wold-style-cast, changed most of + the reported offenders to C++ style casts. Did not change the + offenders in C files. + + * src/trans.h (Match): change argument type to unsigned int. + + * src/support/DebugStream.C: fix some types on the streambufs so + that it works on a conforming implementation. + 1999-12-10 Jean-Marc Lasgouttes * lib/examples/example_{raw,lyxified}.lyx: fix embarassing sentence. diff --git a/acinclude.m4 b/acinclude.m4 index f0712c8862..51bd89efab 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -184,8 +184,8 @@ dnl Check the version of g++ elif test $ac_cv_prog_cxx_g = yes; then case $gxx_version in 2.7*) CXXFLAGS="$lyx_opt";; - 2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive";; - 2.95.*) CXXFLAGS="-g $lyx_opt";; + 2.95.1) CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti";; + 2.95.*) CXXFLAGS="-g $lyx_opt -fno-rtti";; *) CXXFLAGS="-g $lyx_opt -fno-exceptions -fno-rtti";; esac else diff --git a/configure.in b/configure.in index 36682055ec..1d9c8c851a 100644 --- a/configure.in +++ b/configure.in @@ -141,7 +141,6 @@ LYX_ERROR(dnl the development tools.]) fi - ### Setup GNU gettext dnl GNU gettext is written in C AC_LANG_C diff --git a/src/BufferView.C b/src/BufferView.C index 718f11bd8f..5c913c7c7f 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -43,24 +43,24 @@ #include "layout.h" extern BufferList bufferlist; -void sigchldhandler(pid_t pid, int *status); +void sigchldhandler(pid_t pid, int * status); extern void SetXtermCursor(Window win); extern bool input_prohibited; extern bool selection_possible; extern void BeforeChange(); extern char ascii_type; -extern int UnlockInset(UpdatableInset* inset); +extern int UnlockInset(UpdatableInset * inset); extern void ToggleFloat(); extern void MenuPasteSelection(char at); -extern InsetUpdateStruct *InsetUpdateList; +extern InsetUpdateStruct * InsetUpdateList; extern void UpdateInsetUpdateList(); extern void FreeUpdateTimer(); // This is _very_ temporary FL_OBJECT * figinset_canvas; -BufferView::BufferView(LyXView *o, int xpos, int ypos, +BufferView::BufferView(LyXView * o, int xpos, int ypos, int width, int height) : owner_(o) { @@ -93,7 +93,7 @@ BufferView::~BufferView() } -void BufferView::buffer(Buffer *b) +void BufferView::buffer(Buffer * b) { lyxerr[Debug::INFO] << "Setting buffer in BufferView" << endl; if (buffer_) { @@ -470,27 +470,39 @@ void BufferView::gotoError() } +extern "C" { // Just a bunch of C wrappers around static members of BufferView -extern "C" void C_BufferView_UpCB(FL_OBJECT * ob, long buf) { - BufferView::UpCB(ob, buf); -} + void C_BufferView_UpCB(FL_OBJECT * ob, long buf) + { + BufferView::UpCB(ob, buf); + } -extern "C" void C_BufferView_DownCB(FL_OBJECT * ob, long buf) { - BufferView::DownCB(ob, buf); -} -extern "C" void C_BufferView_ScrollCB(FL_OBJECT * ob, long buf) { - BufferView::ScrollCB(ob, buf); -} + void C_BufferView_DownCB(FL_OBJECT * ob, long buf) + { + BufferView::DownCB(ob, buf); + } -extern "C" void C_BufferView_CursorToggleCB(FL_OBJECT * ob, long buf) { - BufferView::CursorToggleCB(ob, buf); -} -extern "C" int C_BufferView_work_area_handler(FL_OBJECT * ob, int event, - FL_Coord, FL_Coord, - int key, void * xev) { - return BufferView::work_area_handler(ob, event, 0, 0, key, xev); + void C_BufferView_ScrollCB(FL_OBJECT * ob, long buf) + { + BufferView::ScrollCB(ob, buf); + } + + + void C_BufferView_CursorToggleCB(FL_OBJECT * ob, long buf) + { + BufferView::CursorToggleCB(ob, buf); + } + + + int C_BufferView_work_area_handler(FL_OBJECT * ob, int event, + FL_Coord, FL_Coord, + int key, void * xev) + { + return BufferView::work_area_handler(ob, event, + 0, 0, key, xev); + } } @@ -576,9 +588,9 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_border_width(-2); // to get visible feedback #endif button_down = obj = fl_add_pixmapbutton(FL_TOUCH_BUTTON, - width-15+4*bw, - ypos + height-15, - 15, 15, ""); + width - 15 + 4 * bw, + ypos + height - 15, + 15, 15, ""); fl_set_object_boxtype(obj, FL_UP_BOX); fl_set_object_color(obj, FL_MCOL, FL_BLUE); fl_set_object_resize(obj, FL_RESIZE_ALL); @@ -588,7 +600,7 @@ void BufferView::create_view(int xpos, int ypos, int width, int height) fl_set_pixmapbutton_data(obj, const_cast(down_xpm)); fl_set_border_width(-bw); -#if FL_REVISION >85 +#if FL_REVISION > 85 // Remove the blue feedback rectangle fl_set_pixmapbutton_focus_outline(obj, 0); #endif @@ -612,9 +624,8 @@ void BufferView::UpCB(FL_OBJECT * ob, long) if (view->buffer_ == 0) return; - XEvent const * ev2; static long time = 0; - ev2 = fl_last_event(); + XEvent const * ev2 = fl_last_event(); if (ev2->type == ButtonPress || ev2->type == ButtonRelease) time = 0; int button = fl_get_button_numb(ob); @@ -1854,7 +1865,7 @@ void BufferView::CursorToggleCB(FL_OBJECT * ob, long) // these comments posted to lyx@via { int status = 1; - int pid = waitpid((pid_t)0, &status, WNOHANG); + int pid = waitpid(static_cast(0), &status, WNOHANG); if (pid == -1) // error find out what is wrong ; // ignore it for now. else if (pid > 0) diff --git a/src/FontInfo.C b/src/FontInfo.C index 0a1e664e3f..f9a10c2a9a 100644 --- a/src/FontInfo.C +++ b/src/FontInfo.C @@ -33,7 +33,7 @@ string FontInfo::getFontname(int size) int closestind = -1; double error = 100000; - for (int i = 0; i(action)); return iit != lyx_info_map.end() ? (*iit).second.name : string(); } @@ -668,7 +533,7 @@ string LyXAction::helpText(int pseudoaction) const if (isPseudoAction(pseudoaction)) action = retrieveActionArg(pseudoaction, arg); else - action = (kb_action) pseudoaction; + action = static_cast(pseudoaction); info_map::const_iterator ici = lyx_info_map.find(action); if (ici != lyx_info_map.end()) { diff --git a/src/Makefile.am b/src/Makefile.am index 7304712dda..386c441766 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -177,14 +177,13 @@ lyx_SOURCES = \ lyx_main.o: lyx_main.C lyx_main.h config.h version.h debug.h gettext.h \ lyx_gui.h lyx_gui_misc.h lyxrc.h support/path.h support/filetools.h \ - bufferlist.h debug.h support/FileInfo.h lastfiles.h intl.h \ + bufferlist.h support/FileInfo.h lastfiles.h intl.h \ lyxserver.h layout.h gettext.h $(CXXCOMPILE) -DLYX_DIR=\"$(LYX_DIR)\" -DTOP_SRCDIR=\"$(top_srcdir)\" \ - -DLYX_NAME=\"$(PACKAGE)\" -c $(top_srcdir)/src/lyx_main.C + -c $(top_srcdir)/src/lyx_main.C main.o: main.C config.h lyx_main.h gettext.h LString.h support/filetools.h - $(CXXCOMPILE) -DPACKAGE=\"$(PACKAGE)\" -DLOCALEDIR=\"$(localedir)\" \ - -c ${top_srcdir}/src/main.C + $(CXXCOMPILE) -DLOCALEDIR=\"$(localedir)\" -c $(top_srcdir)/src/main.C dist-hook: cd $(distdir) ; rm -rf `find cheaders -name \*CVS\*` diff --git a/src/bmtable.C b/src/bmtable.C index d0e98ae5c5..98438f3a4f 100644 --- a/src/bmtable.C +++ b/src/bmtable.C @@ -374,14 +374,14 @@ int fl_get_bmtable(FL_OBJECT *ob) /* * You can change the max number of items if you want. */ -void fl_set_bmtable_maxitems(FL_OBJECT *ob, int i) +void fl_set_bmtable_maxitems(FL_OBJECT * ob, int i) { - if (i>0 && (BMTABLE_SPEC *)ob->spec) + if (i > 0 && (BMTABLE_SPEC *)ob->spec) ((BMTABLE_SPEC *)ob->spec)->maxi = i; } -int fl_get_bmtable_maxitems(FL_OBJECT *ob) +int fl_get_bmtable_maxitems(FL_OBJECT * ob) { if ((BMTABLE_SPEC *)ob->spec) return ((BMTABLE_SPEC *)ob->spec)->maxi; @@ -417,7 +417,7 @@ int fl_get_bmtable_numb(FL_OBJECT *ob) } -Pixmap fl_get_bmtable_pixmap(FL_OBJECT *ob) +Pixmap fl_get_bmtable_pixmap(FL_OBJECT * ob) { if ((BMTABLE_SPEC *)ob->spec) return ((BMTABLE_SPEC *)ob->spec)->pix; @@ -426,11 +426,11 @@ Pixmap fl_get_bmtable_pixmap(FL_OBJECT *ob) } -void fl_draw_bmtable_item(FL_OBJECT *ob, int i, Drawable d, int xx, int yy) +void fl_draw_bmtable_item(FL_OBJECT * ob, int i, Drawable d, int xx, int yy) { int x, y, w, h; GC gc = fl_state[fl_get_vclass()].gc[0]; - BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec; + BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec; if (sp && sp->pix) { x = (i % sp->nx)*sp->dx + FL_abs(ob->bw); diff --git a/src/buffer.C b/src/buffer.C index 760527b8f0..e0c81f2b3c 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -420,7 +420,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par) tmpret = lex.FindToken(string_footnotekinds); if (tmpret == -1) tmpret++; if (tmpret != LYX_LAYOUT_DEFAULT) - footnotekind = (LyXParagraph::footnote_kind)tmpret; // bad + footnotekind = static_cast(tmpret); // bad if (footnotekind == LyXParagraph::FOOTNOTE || footnotekind == LyXParagraph::MARGIN) footnoteflag = LyXParagraph::CLOSED_FOOTNOTE; @@ -2201,7 +2201,7 @@ void Buffer::makeLinuxDocFile(string const & filename, int column) string userName(getUserName()); ofs << "\n"; + << "by <" << userName << "> " << date() << " -->\n"; if(params.options.empty()) sgmlOpenTag(ofs, 0, top_element); @@ -2791,7 +2791,7 @@ void Buffer::makeDocBookFile(string const & filename, int column) string userName(getUserName()); ofs << "\n"; + << "by <" << userName << "> " << date() << " -->\n"; if(params.options.empty()) sgmlOpenTag(ofs, 0, top_element); diff --git a/src/bufferlist.C b/src/bufferlist.C index 55bbcb650d..cb0ca68637 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -162,9 +162,8 @@ bool BufferList::write(Buffer * buf, bool makeBackup) FileInfo finfo(buf->fileName()); if (finfo.exist()) { mode_t fmode = finfo.getMode(); + struct utimbuf * times = new struct utimbuf; - struct utimbuf *times = - (struct utimbuf*)new char[sizeof(struct utimbuf)]; times->actime = finfo.getAccessTime(); times->modtime = finfo.getModificationTime(); long blksize = finfo.getBlockSize(); diff --git a/src/combox.C b/src/combox.C index 58efa6534e..ab91726cd3 100644 --- a/src/combox.C +++ b/src/combox.C @@ -197,8 +197,8 @@ void Combox::add(int x, int y, int w, int hmin, int hmax) } } // end of switch - label->u_vdata = (void*)this; - button->u_vdata = (void*)this; + label->u_vdata = this; + button->u_vdata = this; // Hmm, it seems fl_create_browser is broken in xforms 0.86. // We have to work around that by creating the dropped browser form @@ -207,7 +207,7 @@ void Combox::add(int x, int y, int w, int hmin, int hmax) FL_FORM * current_form = fl_current_form; fl_end_form(); - bw = w+20; bh = hmax-hmin-12; + bw = w + 20; bh = hmax - hmin - 12; form = fl_bgn_form(FL_NO_BOX, bw, bh); browser = obj = fl_add_browser(FL_HOLD_BROWSER, 0, 0, bw, bh, ""); @@ -216,7 +216,7 @@ void Combox::add(int x, int y, int w, int hmin, int hmax) fl_set_object_gravity(obj, NorthWestGravity, NorthWestGravity); fl_set_object_callback(obj, C_Combox_combo_cb, 2); fl_end_form(); - browser->u_vdata = (void*)this; + browser->u_vdata = this; form->u_vdata = browser; fl_register_raw_callback(form, ButtonPressMask|KeyPressMask, @@ -309,23 +309,23 @@ void Combox::deactivate() void Combox::input_cb(FL_OBJECT *ob, long) { - Combox *combo = (Combox*)ob->u_vdata; + Combox * combo = static_cast(ob->u_vdata); - char const *text = fl_get_input(ob); + char const * text = fl_get_input(ob); combo->addto(text); combo->is_empty = false; } -extern "C" void C_Combox_input_cb(FL_OBJECT *ob, long data) +extern "C" void C_Combox_input_cb(FL_OBJECT * ob, long data) { Combox::input_cb(ob, data); } -void Combox::combo_cb(FL_OBJECT *ob, long data) +void Combox::combo_cb(FL_OBJECT * ob, long data) { - Combox *combo = (Combox*)ob->u_vdata; + Combox * combo = static_cast(ob->u_vdata); switch (data) { case 0: { @@ -357,39 +357,40 @@ void Combox::combo_cb(FL_OBJECT *ob, long data) } } -extern "C" void C_Combox_combo_cb(FL_OBJECT *ob, long data) +extern "C" void C_Combox_combo_cb(FL_OBJECT * ob, long data) { Combox::combo_cb(ob, data); } -int Combox::peek_event(FL_FORM * form, void *xev) +int Combox::peek_event(FL_FORM * form, void * xev) { - FL_OBJECT *ob = (FL_OBJECT *)form->u_vdata; - Combox *combo = (Combox*)ob->u_vdata; + FL_OBJECT * ob = static_cast(form->u_vdata); + Combox * combo = static_cast(ob->u_vdata); #if FL_REVISION < 86 if(((XEvent *)xev)->type == ButtonPress && !ob->belowmouse) #endif #if FL_REVISION > 85 // I don't know why belowmouse does not work, but it doesn't. (Asger) - if (((XEvent *) xev)->type == ButtonPress && ( - ((XEvent *)xev)->xbutton.x - ob->x < 0 || - ((XEvent *)xev)->xbutton.x - ob->x > ob->w || - ((XEvent *)xev)->xbutton.y - ob->y < 0 || - ((XEvent *)xev)->xbutton.y - ob->y > ob->h)) + // Are we sure? + if (static_cast(xev)->type == ButtonPress && ( + static_cast(xev)->xbutton.x - ob->x < 0 || + static_cast(xev)->xbutton.x - ob->x > ob->w || + static_cast(xev)->xbutton.y - ob->y < 0 || + static_cast(xev)->xbutton.y - ob->y > ob->h)) #endif { combo->Hide(1); return 1; } - if (((XEvent*)xev)->type != KeyPress) return 0; + if (static_cast(xev)->type != KeyPress) return 0; char s_r[10]; static int num_bytes; KeySym keysym_return; - num_bytes = XLookupString(&((XEvent*)xev)->xkey, s_r, 10, + num_bytes = XLookupString(&static_cast(xev)->xkey, s_r, 10, &keysym_return, 0); XFlush(fl_display); switch (keysym_return) { diff --git a/src/combox.h b/src/combox.h index fb32d648be..6774fe3625 100644 --- a/src/combox.h +++ b/src/combox.h @@ -203,12 +203,12 @@ int Combox::get() } inline -char const*Combox::getline() +char const * Combox::getline() { if (type == FL_COMBOX_INPUT) return fl_get_input(label); else - return ((browser) ? fl_get_browser_line(browser, sel): (char const*)0); + return browser ? fl_get_browser_line(browser, sel) : 0; } #endif diff --git a/src/debug.h b/src/debug.h index 36dd2a0e6c..05ab7afc1a 100644 --- a/src/debug.h +++ b/src/debug.h @@ -122,5 +122,3 @@ ostream & operator<<(ostream & o, Debug::type t); extern DebugStream lyxerr; #endif - - diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 50f3ddee0f..6eadca591a 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -367,14 +367,14 @@ void InitFigures() Visual *vi; bmparrsize = figarrsize = figallocchunk; - figures = (Figref**) malloc(sizeof(Figref*)*figallocchunk); - bitmaps = (figdata**) malloc(sizeof(figdata*)*figallocchunk); + figures = static_cast(malloc(sizeof(Figref*)*figallocchunk)); + bitmaps = static_cast(malloc(sizeof(figdata*)*figallocchunk)); for (i = 0; i < 256; ++i) { k = 0; for (j = 0; j < 8; ++j) if (i & (1 << (7-j))) k |= 1 << j; - bittable[i] = (char) ~k; + bittable[i] = char(~k); } fl_add_canvas_handler(figinset_canvas, ClientMessage, @@ -579,14 +579,14 @@ static void runqueue() bool err = true; for (i = 0; i < nprop; ++i) { - char *p = XGetAtomName(tempdisp, prop[i]); + char * p = XGetAtomName(tempdisp, prop[i]); if (strcmp(p, "GHOSTVIEW") == 0) { err = false; break; } XFree(p); } - XFree((char *)prop); /* jc: */ + XFree(reinterpret_cast(prop)); /* jc: */ if (err) break; // release the server XUngrabServer(tempdisp); @@ -659,7 +659,7 @@ static void runqueue() // set up environment while (environ[ne]) ++ne; - env = (char **) malloc(sizeof(char*)*(ne+2)); + env = static_cast(malloc(sizeof(char*)*(ne+2))); env[0] = tbuf2; memcpy(&env[1], environ, sizeof(char*)*(ne+1)); environ = env; @@ -717,8 +717,8 @@ static void addwait(int psx, int psy, int pswid, int pshgh, figdata *data) queue * p = new queue; p->ofsx = psx; p->ofsy = psy; - p->rx = ((float)data->raw_wid*72)/pswid; - p->ry = ((float)data->raw_hgh*72)/pshgh; + p->rx = (float(data->raw_wid) * 72.0)/pswid; + p->ry = (float(data->raw_hgh) * 72.0)/pshgh; p->data = data; p->next = 0; @@ -759,7 +759,7 @@ static figdata * getfigdata(int wid, int hgh, string const & fname, if (bmpinsref > bmparrsize) { // allocate more space bmparrsize += figallocchunk; - figdata ** tmp = (figdata**) malloc(sizeof(figdata*)*bmparrsize); + figdata ** tmp = static_cast(malloc(sizeof(figdata*)*bmparrsize)); memcpy(tmp, bitmaps, sizeof(figdata*)*(bmparrsize-figallocchunk)); free(bitmaps); bitmaps = tmp; @@ -934,7 +934,7 @@ static void RegisterFigure(InsetFig *fi) if (figinsref > figarrsize) { // allocate more space figarrsize += figallocchunk; - Figref **tmp = (Figref**) malloc(sizeof(Figref*)*figarrsize); + Figref **tmp = static_cast(malloc(sizeof(Figref*)*figarrsize)); memcpy(tmp, figures, sizeof(Figref*)*(figarrsize-figallocchunk)); free(figures); figures = tmp; @@ -1080,7 +1080,7 @@ void InsetFig::Draw(LyXFont font, LyXScreen & scr, int baseline, float & x) char * msg = 0; // draw frame XDrawRectangle(fl_display, pm, getGC(gc_copy), - (int) x, + int(x), baseline - hgh - 1, wid+1, hgh+1); if (figure && figure->data) { if (figure->data->broken) msg = _("[render error]"); @@ -1097,11 +1097,11 @@ void InsetFig::Draw(LyXFont font, LyXScreen & scr, int baseline, float & x) string justname = OnlyFilename (fname); font.drawString(justname, pm, baseline - font.maxAscent() - 4, - (int) x + 8); + int(x) + 8); font.setSize (LyXFont::SIZE_TINY); font.drawText (msg, strlen(msg), pm, baseline - 4, - (int) x + 8); + int(x) + 8); } x += Width(font); // ? @@ -1599,8 +1599,8 @@ void InsetFig::Recompute() float sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */ float cos_a = cos (angle / DEG2PI); - int frame_wid = (int) ceil (fabs(cos_a * pswid) + fabs(sin_a * pshgh)); - int frame_hgh= (int) ceil (fabs(cos_a * pshgh) + fabs(sin_a * pswid)); + int frame_wid = int(ceil(fabs(cos_a * pswid) + fabs(sin_a * pshgh))); + int frame_hgh= int(ceil(fabs(cos_a * pshgh) + fabs(sin_a * pswid))); /* now recompute wid and hgh, and if that is changed, set changed */ /* this depends on chosen size of the picture and its bbox */ @@ -1614,16 +1614,16 @@ void InsetFig::Recompute() case DEF: break; case CM: /* cm */ - newx = (int) (28.346*xwid); + newx = int(28.346 * xwid); break; case IN: /* in */ - newx = (int) (72*xwid); + newx = int(72 * xwid); break; case PER_PAGE: /* % of page */ - newx = (int) (5.95*xwid); + newx = int(5.95 * xwid); break; case PER_COL: /* % of col */ - newx = (int) (2.975*xwid); + newx = int(2.975 * xwid); break; } @@ -1634,13 +1634,13 @@ void InsetFig::Recompute() //lyxerr << "This should not happen!" << endl; break; case CM: /* cm */ - newy = (int) (28.346*xhgh); + newy = int(28.346 * xhgh); break; case IN: /* in */ - newy = (int) (72*xhgh); + newy = int(72 * xhgh); break; case PER_PAGE: /* % of page */ - newy = (int) (8.42*xhgh); + newy = int(8.42 * xhgh); break; case PER_COL: // Doesn't occur; case exists to suppress @@ -1656,12 +1656,12 @@ void InsetFig::Recompute() if (frame_wid == 0) nraw_x = 5; else - nraw_x = (int) ((1.0 * pswid * newx)/frame_wid); + nraw_x = int((1.0 * pswid * newx)/frame_wid); if (frame_hgh == 0) nraw_y = 5; else - nraw_y = (int) ((1.0 * pshgh * newy)/frame_hgh); + nraw_y = int((1.0 * pshgh * newy)/frame_hgh); // cannot be zero, actually, set it to some minimum, so its clickable if (newx < 5) newx = 5; @@ -1746,10 +1746,10 @@ void InsetFig::GetPSSizes() float fpsx, fpsy, fpswid, fpshgh; if (fscanf(f, "%f %f %f %f", &fpsx, &fpsy, &fpswid, &fpshgh) == 4) { - psx = (int) fpsx; - psy = (int) fpsy; - pswid = (int) fpswid; - pshgh = (int) fpshgh; + psx = int(fpsx); + psy = int(fpsy); + pswid = int(fpswid); + pshgh = int(fpshgh); } if (lyxerr.debugging()) { diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 95e9136dc1..9cceef197d 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -135,7 +135,7 @@ private: inline bool InsetInclude::isVerb() const { - return (bool)(flag == InsetInclude::VERB || flag == InsetInclude::VERBAST); + return flag == InsetInclude::VERB || flag == InsetInclude::VERBAST; } diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 6341bd7984..d069cc2d6b 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -102,7 +102,7 @@ void InsetQuotes::ParseString(string const & s) for (i = 0; i < 6; ++i) { if (str[0] == language_char[i]) { - language = (InsetQuotes::quote_language)i; + language = InsetQuotes::quote_language(i); break; } } @@ -114,7 +114,7 @@ void InsetQuotes::ParseString(string const & s) for (i = 0; i < 2; ++i) { if (str[1] == side_char[i]) { - side = (InsetQuotes::quote_side)i; + side = InsetQuotes::quote_side(i); break; } } @@ -126,7 +126,7 @@ void InsetQuotes::ParseString(string const & s) for (i = 0; i < 2; ++i) { if (str[2] == times_char[i]) { - times = (InsetQuotes::quote_times)i; + times = InsetQuotes::quote_times(i); break; } } diff --git a/src/kbmap.C b/src/kbmap.C index a9f7e7a26a..cca84dafef 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -1,10 +1,10 @@ /* This file is part of * ====================================================== * - * LyX, The Document Processor + * LyX, The Document Processor * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-1999 The LyX Team. + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1999 The LyX Team. * * ====================================================== */ @@ -357,7 +357,7 @@ char kb_sequence::getiso() if(c > 0xff) return '\0'; - return (char)c; + return c; } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 8223a89ff7..db609955b4 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -4156,7 +4156,7 @@ void LaTeXOptions() return; fl_set_button(fd_latex_options->accents, - (int)current_view->buffer()->params.allowAccents); + int(current_view->buffer()->params.allowAccents)); if (fd_latex_options->LaTeXOptions->visible) { fl_raise_form(fd_latex_options->LaTeXOptions); diff --git a/src/lyx_gui.C b/src/lyx_gui.C index e498bc056d..80cde4bacb 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -186,11 +186,11 @@ LyXGUI::LyXGUI(LyX *owner, int *argc, char *argv[], bool GUI) // Make sure default screen is not larger than monitor if (width == 690 && height == 510) { - Screen * scr = (DefaultScreenOfDisplay(fl_get_display())); - if (HeightOfScreen(scr)-24(banner)); #if FL_REVISION > 85 fl_set_pixmapbutton_focus_outline(obj, 3); #endif diff --git a/src/lyx_main.C b/src/lyx_main.C index 01f9c504e0..7a9a615df5 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -226,7 +226,6 @@ void LyX::init(int */*argc*/, char **argv) build_lyxdir.clear(); } - bool FollowLink; do { // Path of binary/../share/name of binary/ @@ -301,7 +300,7 @@ void LyX::init(int */*argc*/, char **argv) // Determine user lyx-dir // - user_lyxdir = AddPath(GetEnvPath("HOME"), string(".") + LYX_NAME); + user_lyxdir = AddPath(GetEnvPath("HOME"), string(".") + PACKAGE); lyxerr[Debug::INIT] << "User LyX directory: '" << user_lyxdir << '\'' << endl; @@ -330,11 +329,11 @@ void LyX::init(int */*argc*/, char **argv) } // Calculate screen dpi as average of x-DPI and y-DPI: - Screen * scr= (DefaultScreenOfDisplay(fl_get_display())); + Screen * scr = DefaultScreenOfDisplay(fl_get_display()); lyxrc->dpi = ((HeightOfScreen(scr)* 25.4 / HeightMMOfScreen(scr)) + (WidthOfScreen(scr)* 25.4 / WidthMMOfScreen(scr))) / 2; lyxerr[Debug::INFO] << "DPI setting detected to be " - << lyxrc->dpi+0.5 << endl; + << lyxrc->dpi + 0.5 << endl; // // Read configuration files diff --git a/src/lyxdraw.C b/src/lyxdraw.C index 326d8edd00..cba27858dc 100644 --- a/src/lyxdraw.C +++ b/src/lyxdraw.C @@ -225,7 +225,7 @@ GC GetClearGC() val.foreground= WhitePixel(fl_display, DefaultScreen(fl_display)); } - val.function= GXcopy; + val.function = GXcopy; val.graphics_exposures = false; if (!fast_selection && background_color != "white") { setForegroundColor(background_color.c_str(), val); diff --git a/src/lyxfont.C b/src/lyxfont.C index 1af5356e39..2e10553633 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -3,8 +3,8 @@ * * LyX, The Document Processor * - * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1995-1999 The LyX Team. + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1999 The LyX Team. * * ====================================================== */ @@ -903,14 +903,13 @@ int LyXFont::drawText(char const * s, int n, Pixmap pm, } else { // emulate smallcaps since X doesn't support this - int i; char c; int sx = x; LyXFont smallfont = *this; smallfont.decSize(); smallfont.decSize(); smallfont.setShape(LyXFont::UP_SHAPE); - for (i= 0; i < n; i++){ + for (int i = 0; i < n; ++i){ c = s[i]; if (islower(c)){ c = toupper(c); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 4099b02136..6d26656eef 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -2048,7 +2048,7 @@ string LyXFunc::Dispatch(int ac, case LFUN_GETTIP: { int qa = lyxaction.LookupFunc(argument.c_str()); - setMessage(lyxaction.helpText((kb_action)qa)); + setMessage(lyxaction.helpText(static_cast(qa))); } break; diff --git a/src/lyxserver.C b/src/lyxserver.C index 4c94d07805..58e1af3497 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -153,7 +153,7 @@ void LyXComm::openConnection() { << strerror(errno) << endl; return; } - fl_add_io_callback(infd, FL_READ, C_LyXComm_callback, (void*)this); + fl_add_io_callback(infd, FL_READ, C_LyXComm_callback, this); // --- prepare output pipe --------------------------------------- diff --git a/src/lyxtext.h b/src/lyxtext.h index 04b2e8af8b..f46b05edbe 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -580,6 +580,8 @@ private: specified row */ LyXParagraph::size_type RowLast(Row * row); + /// + void charInserted(); }; #endif diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 59a102833b..7165601da9 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -302,7 +302,7 @@ InsetFormula::InsetFormula(bool display) InsetFormula::InsetFormula(MathParInset * p) { par = (p->GetType()>= LM_OT_MPAR) ? - new MathMatrixInset((MathMatrixInset*)p): + new MathMatrixInset(static_cast(p)): new MathParInset(p); // mathcursor = 0; @@ -461,7 +461,7 @@ void InsetFormula::Draw(LyXFont f, LyXScreen & scr, int baseline, float & x) font.drawString(s, pm, baseline, int(x+20)); } else if (par->GetType() == LM_OT_MPARN) { - MathMatrixInset *mt = (MathMatrixInset*)par; + MathMatrixInset * mt = static_cast(par); int y; MathedRowSt const* crow = mt->getRowSt(); while (crow) { @@ -1113,9 +1113,11 @@ bool InsetFormula::LocalDispatch(int action, char const * arg) } else if (!varcode) { short f = (mathcursor->getLastCode()) ? - mathcursor->getLastCode(): - (MathedTextCodes)mathcursor->GetFCode(); - varcode = MathIsAlphaFont(f) ? (MathedTextCodes)f:LM_TC_VAR; + mathcursor->getLastCode() : + static_cast(mathcursor->GetFCode()); + varcode = MathIsAlphaFont(f) ? + static_cast(f) : + LM_TC_VAR; } // lyxerr << "Varcode << vardoce; @@ -1161,9 +1163,11 @@ bool InsetFormula::LocalDispatch(int action, char const * arg) if (c == ' ') { if (!varcode) { short f = (mathcursor->getLastCode()) ? - mathcursor->getLastCode(): - (MathedTextCodes)mathcursor->GetFCode(); - varcode = MathIsAlphaFont(f) ? (MathedTextCodes)f:LM_TC_VAR; + mathcursor->getLastCode() : + static_cast(mathcursor->GetFCode()); + varcode = MathIsAlphaFont(f) ? + static_cast(f) : + LM_TC_VAR; } if (varcode == LM_TC_TEXTRM) { mathcursor->Insert(c, LM_TC_TEXTRM); diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 39c7b5046b..abc12fe4a4 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -105,7 +105,7 @@ void InsetFormulaMacro::Read(LyXLex & lex) { FILE * file = lex.getFile(); mathed_parser_file(file, lex.GetLineNo()); - mathed_parse(0, 0, (MathParInset **)&tmacro); + mathed_parse(0, 0, reinterpret_cast(&tmacro)); // Update line number lex.setLineNo(mathed_parser_lineno()); diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 8d02039c92..4b79eca89f 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -33,11 +33,11 @@ extern void mathed_set_font(short type, int style); extern GC canvasGC, mathGC, latexGC, cursorGC, mathFrameGC; -static LyxArrayBase *selarray= 0; +static LyxArrayBase * selarray = 0; inline bool IsAlpha(char c) { - return ('A' <= c && c<= 'Z' || 'a' <= c && c<= 'z'); + return ('A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'); } // This was very smaller, I'll change it later @@ -51,10 +51,11 @@ inline bool IsMacro(short tok, int id) !(tok == LM_TK_SYM && id < 255)); } + // Yes, mathed isn't using string yet. -inline char *strnew(char const* s) +inline char * strnew(char const * s) { - char *s1 = new char[strlen(s)+1]; + char * s1 = new char[strlen(s)+1]; strcpy(s1, s); return s1; } @@ -66,54 +67,54 @@ inline char *strnew(char const* s) struct MathStackXIter { int i, imax; - MathedXIter *item; + MathedXIter * item; - MathStackXIter(int n= MAX_STACK_ITEMS): imax(n) { + MathStackXIter(int n = MAX_STACK_ITEMS): imax(n) { item = new MathedXIter[imax]; i = 0; } - MathStackXIter(MathStackXIter &stk); + MathStackXIter(MathStackXIter & stk); ~MathStackXIter() { delete[] item; } - void push(MathedXIter** a) { + void push(MathedXIter ** a) { *a = &item[i++]; } - MathedXIter* pop() { - i--; - return &item[i-1]; + MathedXIter * pop() { + --i; + return &item[i - 1]; } - MathedXIter* Item(int idx) { - return (idx+1 <= i) ? &item[i-idx-1]: (MathedXIter*)0; + MathedXIter * Item(int idx) { + return (idx + 1 <= i) ? &item[i - idx - 1] : 0; } void Reset() { i = 0; } - int Full() { - return (i>= MAX_STACK_ITEMS); + bool Full() { + return i >= MAX_STACK_ITEMS; } - int Empty() { - return (i<= 1); + bool Empty() { + return i <= 1; } int Level() { return i; } -} mathstk, *selstk= 0; +} mathstk, *selstk = 0; -MathStackXIter::MathStackXIter(MathStackXIter &stk) { +MathStackXIter::MathStackXIter(MathStackXIter & stk) { imax = stk.imax; item = new MathedXIter[imax]; i = stk.i; - for (int k= 0; kSetData(par); } + void MathedCursor::Draw(long unsigned pm, int x, int y) { // lyxerr << "Cursor[" << x << " " << y << "] "; win = pm; // win = (mathedCanvas) ? mathedCanvas: pm; par->Metrics(); int w = par->Width()+2, a = par->Ascent()+1, h = par->Height()+1; - if (par->GetType()>LM_OT_PAR) { a += 4; h += 8; } + if (par->GetType() > LM_OT_PAR) { a += 4; h += 8; } if (!canvasGC) mathed_set_font(LM_TC_VAR, 1); // XFillRectangle(fl_display, pm, canvasGC, x, y-a, w, h); - XDrawRectangle(fl_display, pm, mathFrameGC, x-1, y-a, w, h); + XDrawRectangle(fl_display, pm, mathFrameGC, x - 1, y - a, w, h); XFlush(fl_display); MathParInset::pm = pm; par->Draw(x, y); @@ -179,6 +181,7 @@ void MathedCursor::Redraw() par->Draw(x, y); } + bool MathedCursor::Left(bool sel) { if (macro_mode) { @@ -204,7 +207,7 @@ bool MathedCursor::Left(bool sel) return true; } if (!selection) { - MathParInset *p = cursor->GetActiveInset(); + MathParInset * p = cursor->GetActiveInset(); if (!p) return result; @@ -217,6 +220,7 @@ bool MathedCursor::Left(bool sel) return result; } + // Leave the inset bool MathedCursor::Pop() { @@ -228,11 +232,12 @@ bool MathedCursor::Pop() return false; } + // Go to the inset bool MathedCursor::Push() { if (cursor->IsActive()) { - MathParInset *p = cursor->GetActiveInset(); + MathParInset * p = cursor->GetActiveInset(); if (!p) return false; mathstk.push(&cursor); cursor->SetData(p); @@ -241,6 +246,7 @@ bool MathedCursor::Push() return false; } + bool MathedCursor::Right(bool sel) { if (macro_mode) { @@ -299,7 +305,7 @@ void MathedCursor::SetPos(int x, int y) cursor->fitCoord(x, y); while (cursor->GetX()OK()) { if (cursor->IsActive()) { - MathParInset *p = cursor->GetActiveInset(); + MathParInset * p = cursor->GetActiveInset(); if (p->Inside(x, y)) { p->SetFocus(x, y); mathstk.push(&cursor); @@ -327,6 +333,7 @@ void MathedCursor::Home() cursor->GoBegin(); } + void MathedCursor::End() { if (macro_mode) MacroModeClose(); @@ -336,6 +343,7 @@ void MathedCursor::End() cursor->GoLast(); } + void MathedCursor::Insert(byte c, MathedTextCodes t) { if (selection) SelDel(); @@ -347,9 +355,9 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) MacroModeClose(); if (t == LM_TC_CR) { - MathParInset *p= cursor->p; + MathParInset * p = cursor->p; if (p == par && p->GetType()GetType()>LM_OT_MIN) { - MathMatrixInset* mt = new MathMatrixInset(3, 0); + MathMatrixInset * mt = new MathMatrixInset(3, 0); mt->SetAlign(' ', "rcl"); mt->SetStyle(LM_ST_DISPLAY); mt->SetType((p->GetType() == LM_OT_PARN) ? LM_OT_MPARN: LM_OT_MPAR); @@ -368,7 +376,7 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) } } else if (t == LM_TC_TAB) { - MathParInset *p = cursor->p; + MathParInset * p = cursor->p; if (p && p->Permit(LMPF_ALLOW_TAB)) { if (c) { cursor->Insert(c, t); @@ -401,18 +409,19 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) clearLastCode(); } -void MathedCursor::Insert(MathedInset* p, int t) + +void MathedCursor::Insert(MathedInset * p, int t) { if (macro_mode) MacroModeClose(); if (selection) { if (MathIsActive(t)) { SelCut(); - ((MathParInset*)p)->SetData(selarray); + static_cast(p)->SetData(selarray); } else SelDel(); } - if (mathstk.icheckTabs(); } + void MathedCursor::DelLine() { if (macro_mode) MacroModeClose(); @@ -467,7 +478,6 @@ bool MathedCursor::Up(bool sel) if (sel && !selection) SelStart(); if (!sel && selection) SelClear(); - MathParInset *p; if (cursor->IsScript()) { char cd = cursor->GetChar(); @@ -488,10 +498,10 @@ bool MathedCursor::Up(bool sel) result = cursor->Up(); if (!result && cursor->p) { - p = cursor->p; + MathParInset * p = cursor->p; if (p->GetType() == LM_OT_SCRIPT) { - MathedXIter *cx = mathstk.Item(1); + MathedXIter * cx = mathstk.Item(1); bool is_down = (cx->GetChar() == LM_TC_DOWN); cursor = mathstk.pop(); cursor->Next(); @@ -522,8 +532,6 @@ bool MathedCursor::Down(bool sel) if (!sel && selection) SelClear(); // if (selection) SelClear(); - MathParInset *p; - if (cursor->IsScript()) { char cd = cursor->GetChar(); if (MathIsDown(cd)) { @@ -543,9 +551,9 @@ bool MathedCursor::Down(bool sel) result = cursor->Down(); if (!result && cursor->p) { - p= cursor->p; + MathParInset * p= cursor->p; if (p->GetType() == LM_OT_SCRIPT) { - MathedXIter *cx = mathstk.Item(1); + MathedXIter * cx = mathstk.Item(1); bool is_up = (cx->GetChar() == LM_TC_UP); cursor = mathstk.pop(); cursor->Next(); @@ -565,10 +573,11 @@ bool MathedCursor::Down(bool sel) return result; } + bool MathedCursor::Limits() { if (cursor->IsInset()) { - MathedInset *p = cursor->GetInset(); + MathedInset * p = cursor->GetInset(); bool ol = p->GetLimits(); p->SetLimits(!ol); return (ol!= p->GetLimits()); @@ -576,15 +585,16 @@ bool MathedCursor::Limits() return false; } + void MathedCursor::SetSize(short size) { - MathParInset *p = cursor->p; + MathParInset * p = cursor->p; p->UserSetSize(size); cursor->SetData(p); } -void MathedCursor::setLabel(char const* label) +void MathedCursor::setLabel(char const * label) { // ugly hack and possible bug if (!cursor->setLabel(strnew(label))) lyxerr << "MathErr: Bad place to set labels." << endl; @@ -593,16 +603,16 @@ void MathedCursor::setLabel(char const* label) void MathedCursor::setNumbered() { // another ugly hack - MathedRowSt *crow = cursor->crow; + MathedRowSt * crow = cursor->crow; if (!crow) return; crow->setNumbered(!crow->isNumbered()); } -void MathedCursor::Interpret(char const *s) +void MathedCursor::Interpret(char const * s) { - MathedInset *p = 0; - latexkeys *l = 0; + MathedInset * p = 0; + latexkeys * l = 0; MathedTextCodes tcode = LM_TC_INSET; if (s[0] == '^' || s[0] == '_') { @@ -643,7 +653,7 @@ void MathedCursor::Interpret(char const *s) } else p = new MathFuncInset(s, LM_OT_UNDEF); } else { - tcode = ((MathMacro*)p)->getTCode(); + tcode = static_cast(p)->getTCode(); lyxerr << "Macro2 " << s << ' ' << tcode << " " ; } } else { @@ -657,7 +667,7 @@ void MathedCursor::Interpret(char const *s) case LM_TK_SYM: { if (l->id<255) { - Insert((byte)l->id, MathIsBOPS(l->id) ? + Insert(static_cast(l->id), MathIsBOPS(l->id) ? LM_TC_BOPS: LM_TC_SYMB); } else { p = new MathFuncInset(l->name); @@ -705,7 +715,7 @@ void MathedCursor::Interpret(char const *s) break; case LM_TK_MACRO: p = MathMacroTable::mathMTable.getMacro(s); - tcode = ((MathMacro*)p)->getTCode(); + tcode = static_cast(p)->getTCode(); lyxerr[Debug::MATHED] << "Macro " << s << ' ' << tcode << endl; break; default: @@ -725,11 +735,11 @@ void MathedCursor::Interpret(char const *s) bool MathedCursor::pullArg() { if (cursor->IsActive()) { - MathParInset *p = cursor->GetActiveInset(); + MathParInset * p = cursor->GetActiveInset(); if (!p) { return false; } - LyxArrayBase *a = p->GetData(); + LyxArrayBase * a = p->GetData(); p->SetData(0); Delete(); if (a) { @@ -755,12 +765,13 @@ void MathedCursor::MacroModeOpen() lyxerr << "Mathed Warning: Already in macro mode" << endl; } + void MathedCursor::MacroModeClose() { if (macro_mode) { macro_mode = false; - latexkeys *l = in_word_set(macrobf, macroln); - if (macroln>0 && (!l || (l && IsMacro(l->token, l->id))) && + latexkeys * l = in_word_set(macrobf, macroln); + if (macroln > 0 && (!l || (l && IsMacro(l->token, l->id))) && !MathMacroTable::mathMTable.getMacro(macrobf)) { if (!l) { imacro->SetName(strnew(macrobf)); @@ -772,7 +783,7 @@ void MathedCursor::MacroModeClose() Left(); imacro->SetName(0); if (cursor->GetInset()->GetType() == LM_OT_ACCENT) { - setAccent(((MathAccentInset*)cursor->GetInset())->getAccentCode()); + setAccent(static_cast(cursor->GetInset())->getAccentCode()); } cursor->Delete(); if (l || MathMacroTable::mathMTable.getMacro(macrobf)) { @@ -783,6 +794,7 @@ void MathedCursor::MacroModeClose() } } + void MathedCursor::MacroModeBack() { if (macro_mode) { @@ -795,36 +807,37 @@ void MathedCursor::MacroModeBack() lyxerr << "Mathed Warning: we are not in macro mode" << endl; } + void MathedCursor::MacroModeInsert(char c) { if (macro_mode) { - macrobf[macroln+1] = macrobf[macroln]; + macrobf[macroln + 1] = macrobf[macroln]; macrobf[macroln++] = c; imacro->Metrics(); } else lyxerr << "Mathed Warning: we are not in macro mode" << endl; } + void MathedCursor::SelCopy() { if (selection) { - int p1, p2; - p1 = (cursor->pos < selpos) ? cursor->pos: selpos; - p2 = (cursor->pos > selpos) ? cursor->pos: selpos; + int p1 = (cursor->pos < selpos) ? cursor->pos: selpos; + int p2 = (cursor->pos > selpos) ? cursor->pos: selpos; selarray = cursor->Copy(p1, p2); cursor->Adjust(); SelClear(); } } + void MathedCursor::SelCut() { if (selection) { if (cursor->pos == selpos) return; - int p1, p2; - p1 = (cursor->pos < selpos) ? cursor->pos: selpos; - p2 = (cursor->pos > selpos) ? cursor->pos: selpos; + int p1 = (cursor->pos < selpos) ? cursor->pos: selpos; + int p2 = (cursor->pos > selpos) ? cursor->pos: selpos; selarray = cursor->Copy(p1, p2); cursor->Clean(selpos); cursor->Adjust(); @@ -832,6 +845,7 @@ void MathedCursor::SelCut() } } + void MathedCursor::SelDel() { // lyxerr << "Deleting sel " @@ -843,6 +857,7 @@ void MathedCursor::SelDel() } } + void MathedCursor::SelPaste() { // lyxerr << "paste " << selarray << " " << curor->pos; @@ -853,6 +868,7 @@ void MathedCursor::SelPaste() } } + void MathedCursor::SelStart() { lyxerr[Debug::MATHED] << "Starting sel " << endl; @@ -868,6 +884,7 @@ void MathedCursor::SelStart() } } + void MathedCursor::SelClear() { lyxerr[Debug::MATHED] << "Clearing sel " << endl; @@ -886,7 +903,7 @@ void MathedCursor::SelBalance() // If unbalanced, balance them while (d != 0) { - if (d<0) { + if (d < 0) { // lyxerr << "b[" << mathstk.Level() << " " << selstk->Level << " " << anchor->GetX() << " " << cursor->GetX() << "]"; anchor = selstk->pop(); if (anchor->GetX() >= cursor->GetX()) @@ -903,7 +920,7 @@ void MathedCursor::SelBalance() } -XPoint *MathedCursor::SelGetArea(int& np) +XPoint * MathedCursor::SelGetArea(int & np) { if (!selection) { np = 0; @@ -913,13 +930,13 @@ XPoint *MathedCursor::SelGetArea(int& np) static XPoint point[10]; // single row selection - int i = 0, x, y, a, d, w, xo, yo, x1, y1, a1, d1; //, p1, p2; + int i = 0, x, y, a, d, xo, yo, x1, y1, a1, d1; //, p1, p2; // Balance anchor and cursor SelBalance(); cursor->p->GetXY(xo, yo); - w = cursor->p->Width(); + int w = cursor->p->Width(); cursor->GetPos(x1, y1); cursor->getAD(a1, d1); anchor->GetPos(x, y); @@ -930,26 +947,26 @@ XPoint *MathedCursor::SelGetArea(int& np) point[i].x = x; point[i++].y = y-a; - if (y!= y1) { + if (y != y1) { point[i].x = xo + w; - point[i++].y = y-a; - if (x1xo) { + point[i++].y = y1 + d; + if (x > xo) { point[i].x = xo; - point[i++].y = y+d; + point[i++].y = y + d; } } point[i].x = point[0].x; @@ -976,16 +993,16 @@ void MathedCursor::setAccent(int ac) int MathedCursor::getAccent() const { - return (accent>0) ? nestaccent[accent-1]: 0; + return (accent > 0) ? nestaccent[accent - 1]: 0; } void MathedCursor::doAccent(byte c, MathedTextCodes t) { - MathedInset *ac = 0; + MathedInset * ac = 0; - for (int i= accent-1; i>= 0; i--) { - if (i == accent-1) + for (int i = accent - 1; i >= 0; --i) { + if (i == accent - 1) ac = new MathAccentInset(c, t, nestaccent[i]); else ac = new MathAccentInset(ac, nestaccent[i]); @@ -997,12 +1014,12 @@ void MathedCursor::doAccent(byte c, MathedTextCodes t) } -void MathedCursor::doAccent(MathedInset *p) +void MathedCursor::doAccent(MathedInset * p) { - MathedInset *ac = 0; + MathedInset * ac = 0; - for (int i= accent-1; i>= 0; i--) { - if (i == accent-1) + for (int i = accent - 1; i >= 0; --i) { + if (i == accent - 1) ac = new MathAccentInset(p, nestaccent[i]); else ac = new MathAccentInset(ac, nestaccent[i]); diff --git a/src/mathed/math_delim.C b/src/mathed/math_delim.C index a60dce8217..ae8a9e4511 100644 --- a/src/mathed/math_delim.C +++ b/src/mathed/math_delim.C @@ -302,16 +302,16 @@ void mathed_draw_deco(Window win, int x, int y, int w, int h, int code) { Matriz mt, sqmt; XPoint p[32]; - float *d, xx, yy, x2, y2; - int i= 0, j, n, r; + float xx, yy, x2, y2; + int i= 0, j, n; j = search_deco(code); - if (j<0) return; + if (j < 0) return; - r = math_deco_table[j].angle; - d = math_deco_table[j].data; + int r = math_deco_table[j].angle; + float * d = math_deco_table[j].data; - if (h > 70 && (math_deco_table[j].code == (int) '(' || math_deco_table[j].code == (int) ')')) + if (h > 70 && (math_deco_table[j].code == int('(') || math_deco_table[j].code == int(')'))) d = parenthHigh; mt.rota(r); @@ -323,7 +323,7 @@ void mathed_draw_deco(Window win, int x, int y, int w, int h, int code) if (r> 0 && r< 3) y += h; if (r>= 2) x += w; do { - code = (int)d[i++]; + code = int(d[i++]); switch (code) { case 0: break; case 1: @@ -336,24 +336,24 @@ void mathed_draw_deco(Window win, int x, int y, int w, int h, int code) else mt.transf(xx, yy, xx, yy); mt.transf(x2, y2, x2, y2); - XDrawLine(fl_display, win, mathGC, x+(int)xx, y+(int)yy, - x+(int)x2, y+(int)y2); + XDrawLine(fl_display, win, mathGC, x + int(xx), y + int(yy), + x + int(x2), y + int(y2)); XFlush(fl_display); break; } case 2: case 4: { - n = (int)d[i++]; - for (j= 0; j(GetInset()); } lyxerr << "Math Error: This is not an active inset" << endl; diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 749f0aafa4..c047d2db1e 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -228,7 +228,7 @@ void MathMacroArgument::Draw(int x, int baseline) MathParInset::Draw(x, baseline); } else { unsigned char s[3]; - sprintf((char*)s, "#%d", number); + sprintf(reinterpret_cast(s), "#%d", number); drawStr(LM_TC_TEX, size, x, baseline, &s[0], 2); } } @@ -240,7 +240,7 @@ void MathMacroArgument::Metrics() MathParInset::Metrics(); } else { unsigned char s[3]; - sprintf((char*)s, "#%d", number); + sprintf(reinterpret_cast(s), "#%d", number); width = mathed_string_width(LM_TC_TEX, size, &s[0], 2); mathed_string_height(LM_TC_TEX, size, &s[0], 2, ascent, descent); } @@ -424,7 +424,7 @@ void MathMacroTemplate::GetMacroXY(int i, int & x, int & y) const MathParInset * MathMacroTemplate::getMacroPar(int i) const { - return (i >= 0 && i < nargs) ? (MathParInset*)&args[i] : 0; + return (i >= 0 && i < nargs) ? static_cast(&args[i]) : 0; } diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index d8db81f1c1..3b10d551f2 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -483,7 +483,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array, case LM_TK_LIMIT: { if (binset) { - binset->SetLimits((bool)(yylval.l->id)); + binset->SetLimits(bool(yylval.l->id)); binset = 0; } break; @@ -630,7 +630,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array, case LM_TK_FONT: { - varcode = (MathedTextCodes)yylval.l->id; + varcode = static_cast(yylval.l->id); yy_mtextmode = bool(varcode == LM_TC_TEXTRM); flags |= (FLAG_BRACE|FLAG_BRACE_FONT); break; @@ -759,7 +759,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array, if (p) { data.Insert(p, p->getTCode()); p->setArgumentIdx(0); - mathed_parse(FLAG_END, p->GetData(), (MathParInset**)&p); + mathed_parse(FLAG_END, p->GetData(), reinterpret_cast(&p)); // for (int i= 0; p->setArgumentIdx(i); i++) // p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST)); } else @@ -777,7 +777,7 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array, if (accent) { data.Insert(doAccent(p)); } else - data.Insert(p, ((MathMacro*)p)->getTCode()); + data.Insert(p, static_cast(p)->getTCode()); } break; } diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index c8df4a9b45..fac799250d 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -145,7 +145,7 @@ BitmapMenu::BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx): nb(n) w = h = 0; form = 0; i = 0; - ww = 2*FL_abs(FL_BOUND_WIDTH); + ww = 2 * FL_abs(FL_BOUND_WIDTH); x = y = ww; y += 8; bitmap = new FL_OBJECTP[nb]; @@ -245,16 +245,16 @@ int peek_event(FL_FORM * /*form*/, void *xev) if (BitmapMenu::active == 0) return 0; - if(((XEvent *)xev)->type == ButtonPress) + if(static_cast(xev)->type == ButtonPress) { BitmapMenu::active->Hide(); return 1; } - if(((XEvent *)xev)->type == KeyPress) + if(static_cast(xev)->type == KeyPress) { char c[5]; KeySym keysym; - XLookupString(&((XEvent *)xev)->xkey, &c[0], 5, &keysym, 0); + XLookupString(&static_cast(xev)->xkey, &c[0], 5, &keysym, 0); if (keysym == XK_Left) BitmapMenu::active->Prev(); else if (keysym == XK_Right) diff --git a/src/mathed/math_write.C b/src/mathed/math_write.C index 97aa9a5071..82a8b1e3df 100644 --- a/src/mathed/math_write.C +++ b/src/mathed/math_write.C @@ -118,10 +118,10 @@ void MathDelimInset::Write(string & outf) } else { if (left == '{' || left == '}') { outf += '\\'; - outf += (char) left; + outf += char(left); outf += ' '; } else { - outf += (char) left; + outf += char(left); outf += ' '; } } @@ -134,10 +134,10 @@ void MathDelimInset::Write(string & outf) } else { if (right == '{' || right == '}') { outf += '\\'; - outf += (char) right; + outf += char(right); outf += ' '; } else { - outf += (char) right; + outf += char(right); outf += ' '; } } @@ -197,7 +197,7 @@ void MathAccentInset::Write(string & outf) outf += ' '; } } else - outf += (char) c; + outf += char(c); if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM) outf += '}'; @@ -315,7 +315,7 @@ void MathParInset::Write(string & outf) lyxerr <<"Math warning: Unexpected closing brace." << endl; else - outf += (char) *s; + outf += char(*s); } s++; ls--; } @@ -397,7 +397,7 @@ void MathMatrixInset::Write(string & outf) outf += '}'; if (v_align == 't' || v_align == 'b') { outf += '['; - outf += (char) v_align; + outf += char(v_align); outf += ']'; } outf += '{'; diff --git a/src/spellchecker.C b/src/spellchecker.C index f97e8e4c94..6b92ce4bae 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -91,7 +91,7 @@ struct isp_result { isp_result() { flag = ISP_UNKNOWN; count = 0; - misses = (char**)0; + misses = static_cast(0); } ~isp_result() { if (misses) delete[] misses; @@ -337,7 +337,7 @@ void create_ispell_pipe(string const & lang) argv[argc++] = 0; - execvp("ispell", (char * const *) argv); + execvp("ispell", static_cast(argv)); // free the memory used by string::copy in the // setup of argv @@ -412,7 +412,7 @@ isp_result *ispell_check_word(char *word) /* I think we have to check if ispell is still alive here because the signal-handler could have disabled blocking on the fd */ - if (isp_pid == -1) return (isp_result *) 0; + if (isp_pid == -1) return 0; result = new isp_result; diff --git a/src/support/DebugStream.C b/src/support/DebugStream.C index e682c97332..ad610636ff 100644 --- a/src/support/DebugStream.C +++ b/src/support/DebugStream.C @@ -37,15 +37,19 @@ ostream & operator<<(ostream & o, Debug::type t) */ class nullbuf : public streambuf { protected: +#ifndef MODERN_STL_STREAMS + typedef char char_type; + typedef int int_type; /// virtual int sync() { return 0; } +#endif /// - virtual streamsize xsputn(char const *, streamsize n) { + virtual streamsize xsputn(char_type const *, streamsize n) { // fakes a purge of the buffer by returning n return n; } /// - virtual int overflow(int c = EOF) { + virtual int_type overflow(int_type c = EOF) { // fakes success by returning c return c == EOF ? ' ' : c; } @@ -60,6 +64,10 @@ public: teebuf(streambuf * b1, streambuf * b2) : streambuf(), sb1(b1), sb2(b2) {} protected: +#ifndef MODERN_STL_STREAMS + typedef char char_type; + typedef int int_type; +#endif /// virtual int sync() { #ifdef MODERN_STL_STREAMS @@ -71,7 +79,7 @@ protected: #endif } /// - virtual streamsize xsputn(char const * p, streamsize n) { + virtual streamsize xsputn(char_type const * p, streamsize n) { #ifdef MODERN_STL_STREAMS sb2->sputn(p, n); return sb1->sputn(p, n); @@ -81,7 +89,7 @@ protected: #endif } /// - virtual int overflow(int c = EOF) { + virtual int_type overflow(int_type c = EOF) { #ifdef MODERN_STL_STREAMS sb2->sputc(c); return sb1->sputc(c); @@ -104,6 +112,10 @@ public: debugbuf(streambuf * b) : streambuf(), sb(b) {} protected: +#ifndef MODERN_STL_STREAMS + typedef char char_type; + typedef int int_type; +#endif /// virtual int sync() { #ifdef MODERN_STL_STREAMS @@ -113,7 +125,7 @@ protected: #endif } /// - virtual streamsize xsputn(char const * p, streamsize n) { + virtual streamsize xsputn(char_type const * p, streamsize n) { #ifdef MODERN_STL_STREAMS return sb->sputn(p, n); #else @@ -121,7 +133,7 @@ protected: #endif } /// - virtual int overflow(int c = EOF) { + virtual int_type overflow(int_type c = EOF) { #ifdef MODERN_STL_STREAMS return sb->sputc(c); #else @@ -133,12 +145,14 @@ private: streambuf * sb; }; + /// So that public parts of DebugStream does not need to know about filebuf struct DebugStream::debugstream_internal { /// Used when logging to file. filebuf fbuf; }; + /// Constructor, sets the debug level to t. DebugStream::DebugStream(Debug::type t) : ostream(new debugbuf(cerr.rdbuf())), @@ -165,6 +179,7 @@ DebugStream::~DebugStream() delete internal; } + /// Sets the debugstreams' logfile to f. void DebugStream::logFile(char const * f) { diff --git a/src/support/DebugStream.h b/src/support/DebugStream.h index 8952248bf2..c055205a9c 100644 --- a/src/support/DebugStream.h +++ b/src/support/DebugStream.h @@ -12,7 +12,7 @@ #ifndef DEBUGSTREAM_H #define DEBUGSTREAM_H -#include "LOstream.h" +#include #ifdef TEST_DEBUGSTREAM #include diff --git a/src/support/LSubstring.C b/src/support/LSubstring.C index 6c5509fdad..c253d0e060 100644 --- a/src/support/LSubstring.C +++ b/src/support/LSubstring.C @@ -3,8 +3,8 @@ * * LyX, The Document Processor * - * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1995-1998 The LyX Team. + * Copyright 1995 Matthias Ettrich + * Copyright 1995-1999 The LyX Team. * * ====================================================== */ diff --git a/src/support/lyxlib.h b/src/support/lyxlib.h index 7fd7616275..da5a4858f9 100644 --- a/src/support/lyxlib.h +++ b/src/support/lyxlib.h @@ -26,10 +26,10 @@ unsigned long lyxsum(char const * file); inline char * date() { time_t tid; - if ((tid= time(0)) == (time_t)-1) - return (char*)0; + if ((tid= time(0)) == static_cast(-1)) + return 0; else - return (ctime(&tid)); + return ctime(&tid); } diff --git a/src/support/lyxsum.C b/src/support/lyxsum.C index 3bd9262e98..04f1bdc154 100644 --- a/src/support/lyxsum.C +++ b/src/support/lyxsum.C @@ -14,7 +14,11 @@ #include -#include +#ifdef __GLIBCPP__ +#include +#else +#include +#endif /* Number of bytes to read at once. */ #define BUFLEN (1 << 16) @@ -80,15 +84,39 @@ static unsigned long const crctab[256] = Return crc if successful, 0 if an error occurs. */ unsigned long -lyxsum (char const*file) +lyxsum (char const * file) { - unsigned char buf[BUFLEN]; unsigned long crc = 0; long length = 0; long bytes_read; - register FILE *fp; +#if __GLIBCPP__ + char buf[BUFLEN]; + ifstream ifs(file); + if (!ifs) { + return 0; + } + + while ((bytes_read = ifs.readsome(buf, BUFLEN)) > 0) { + unsigned char * cp = reinterpret_cast(buf); + + length += bytes_read; + while (bytes_read--) + crc = (crc << 8) ^ crctab[((crc >> 24) ^ *(cp++)) & 0xFF]; + } - fp = fopen (file, "r"); + if (ifs.fail()) { + ifs.close(); + return 0; + } + + ifs.close(); + if (ifs.fail()) { + return 0; + } +#else + unsigned char buf[BUFLEN]; + + register FILE * fp = fopen (file, "r"); if (fp == 0) { return 0; } @@ -109,7 +137,7 @@ lyxsum (char const*file) if (fclose (fp) == EOF) { return 0; } - +#endif bytes_read = length; while (bytes_read > 0) { crc = (crc << 8) ^ crctab[((crc >> 24) ^ bytes_read) & 0xFF]; diff --git a/src/support/syscall.C b/src/support/syscall.C index 295785f713..2ea868f73d 100644 --- a/src/support/syscall.C +++ b/src/support/syscall.C @@ -4,10 +4,10 @@ #pragma implementation #endif -#include +#include #include #include -#include +#include #include #include #include @@ -25,7 +25,7 @@ Systemcalls::Systemcalls(Starttype how, string const & what, Callbackfct cback) start = how; command = what; cbk = cback; - pid = (pid_t) 0; + pid = static_cast(0); retval = 0; startscript(); } @@ -183,7 +183,7 @@ int Systemcalls::startscript(Starttype how, string const & what, start = how; command = what; cbk = cback; - pid = (pid_t) 0; // yet no child + pid = static_cast(0); // yet no child retval = 0; return startscript(); } diff --git a/src/support/syscontr.C b/src/support/syscontr.C index 192ef9058b..769d74f228 100644 --- a/src/support/syscontr.C +++ b/src/support/syscontr.C @@ -1,7 +1,7 @@ #include -#include -#include +#include +#include #include #include #include "syscontr.h" diff --git a/src/table.C b/src/table.C index 2c42794da9..a00a4e5d32 100644 --- a/src/table.C +++ b/src/table.C @@ -905,7 +905,7 @@ void LyXTable::Read(FILE * file) *atmp = 0; fgets(vtmp, sizeof(vtmp), file); sscanf(vtmp, "%d %d %d %s %s", &a, &b, &c, stmp, atmp); - column_info[i].alignment = (char) a; + column_info[i].alignment = static_cast(a); column_info[i].left_line = b; column_info[i].right_line = c; if (*stmp == '"') { /* strip quotes if they exists */ @@ -923,21 +923,21 @@ void LyXTable::Read(FILE * file) } else if (*stmp) column_info[i].p_width = stmp; } - for (i = 0; i(a); + cell_info[i][j].alignment = static_cast(b); + cell_info[i][j].top_line = static_cast(c); + cell_info[i][j].bottom_line = static_cast(d); + cell_info[i][j].has_cont_row = static_cast(e); + cell_info[i][j].rotate = static_cast(f); + cell_info[i][j].linebreaks = static_cast(g); // this is only to see if I have an empty string first // this clause should be always TRUE!!! if (*stmp == '"') { diff --git a/src/tex-accent.C b/src/tex-accent.C index 12ecb90a65..f5e8470864 100644 --- a/src/tex-accent.C +++ b/src/tex-accent.C @@ -38,7 +38,7 @@ //static tex_accent_struct lyx_accent_table[18] = { - { (tex_accent)0, "", "", "",(kb_action)0}, + { static_cast(0), "", "", "", static_cast(0)}, {TEX_ACUTE, "\\'", " AEIOUYaeiouySZszRLCNrlcn", "acute", LFUN_ACUTE}, {TEX_GRAVE, "\\`", " aeiouAEIOU", "grave", LFUN_GRAVE}, {TEX_MACRON, "\\=", " EeAIOUaiou", "macron", LFUN_MACRON}, @@ -56,19 +56,19 @@ tex_accent_struct lyx_accent_table[18] = { {TEX_UMLAUT, "\\\"", " AEIOUaeiouy", "umlaut", LFUN_UMLAUT}, {TEX_DOT, "\\.", " ZzICGicgEe", "dot", LFUN_DOT}, {TEX_OGONEK, "\\k", " AaEe", "ogonek", LFUN_OGONEK}, - { (tex_accent)0, "", "", "",(kb_action)0}}; + { static_cast(0), "", "", "", static_cast(0)}}; tex_accent_struct get_accent(kb_action action) { - int i= 0; - while (i<= TEX_MAX_ACCENT){ + int i = 0; + while (i <= TEX_MAX_ACCENT){ if (lyx_accent_table[i].action == action) return lyx_accent_table[i]; - i++; + ++i; } - struct tex_accent_struct temp = { (tex_accent)0, 0, 0, - 0,(kb_action)0}; + struct tex_accent_struct temp = { static_cast(0), 0, 0, + 0, static_cast(0)}; return temp; } diff --git a/src/text.C b/src/text.C index e51f772fb3..b678921aae 100644 --- a/src/text.C +++ b/src/text.C @@ -2178,16 +2178,6 @@ void LyXText::RedoParagraph() * same Paragraph one to the right and make a rebreak */ void LyXText::InsertChar(char c) { - Row * row; - Row * tmprow; - long y; - bool jumped_over_space; - LyXFont realtmpfont; - LyXFont rawtmpfont; - LyXParagraph::size_type z; - LyXParagraph::size_type lastpos; - LyXFont rawparfont; - SetUndo(Undo::INSERT, cursor.par->ParFromPos(cursor.pos)->previous, cursor.par->ParFromPos(cursor.pos)->next); @@ -2205,7 +2195,8 @@ void LyXText::InsertChar(char c) /* table stuff -- begin*/ if (cursor.par->table) { InsertCharInTable(c); - goto out; + charInserted(); + return; } /* table stuff -- end*/ @@ -2222,18 +2213,18 @@ void LyXText::InsertChar(char c) #warning There is a bug here! (Asger) #endif - realtmpfont = real_current_font; - rawtmpfont = current_font; /* store the current font. + LyXFont realtmpfont = real_current_font; + LyXFont rawtmpfont = current_font; /* store the current font. * This is because of the use * of cursor movements. The moving * cursor would refresh the * current font */ // Get the font that is used to calculate the baselineskip - lastpos = cursor.par->Last(); - rawparfont = cursor.par->GetFontSettings(lastpos - 1); + LyXParagraph::size_type lastpos = cursor.par->Last(); + LyXFont rawparfont = cursor.par->GetFontSettings(lastpos - 1); - jumped_over_space = false; + bool jumped_over_space = false; if (IsLineSeparatorChar(c)) { @@ -2266,12 +2257,15 @@ void LyXText::InsertChar(char c) minibuffer->Set(_("You cannot insert a space at the beginning of a paragraph. Please read the Tutorial.")); else minibuffer->Set(_("You cannot type two spaces this way. Please read the Tutorial.")); - goto out; + charInserted(); + return; } } else if (IsNewlineChar(c)) { if (cursor.par->FirstPhysicalPar() == cursor.par - && cursor.pos <= BeginningOfMainBody(cursor.par)) - goto out; + && cursor.pos <= BeginningOfMainBody(cursor.par)) { + charInserted(); + return; + } /* no newline at first position * of a paragraph or behind labels. * TeX does not allow that. */ @@ -2293,8 +2287,8 @@ void LyXText::InsertChar(char c) in future */ /* row = GetRow(cursor.par, cursor.pos, y);*/ /* ok, heres a better way: */ - row = cursor.row; - y = cursor.y - row->baseline; + Row * row = cursor.row; + long y = cursor.y - row->baseline; if (c != LyXParagraph::META_INSET) /* in this case LyXText::InsertInset * already insertet the character */ cursor.par->InsertChar(cursor.pos, c); @@ -2302,7 +2296,7 @@ void LyXText::InsertChar(char c) if (!jumped_over_space) { /* refresh the positions */ - tmprow = row; + Row * tmprow = row; while (tmprow->next && tmprow->next->par == row->par) { tmprow = tmprow->next; tmprow->pos++; @@ -2314,7 +2308,8 @@ void LyXText::InsertChar(char c) || cursor.par->IsNewline(cursor.pos) || cursor.row->fill == -1) && row->previous && row->previous->par == row->par) { - z = NextBreakPoint(row->previous, paperwidth); + LyXParagraph::size_type z = NextBreakPoint(row->previous, + paperwidth); if ( z >= row->pos) { row->pos = z + 1; @@ -2345,7 +2340,8 @@ void LyXText::InsertChar(char c) && rawparfont != rawtmpfont) RedoHeightOfParagraph(cursor); - goto out; + charInserted(); + return; } } @@ -2407,21 +2403,25 @@ void LyXText::InsertChar(char c) RedoDrawingOfParagraph(cursor); } } - out: + charInserted(); +} + + +void LyXText::charInserted() +{ // Here we could call FinishUndo for every 20 characters inserted. // This is from my experience how emacs does it. - static unsigned short counter = 0; + static unsigned int counter = 0; if (counter < 20) { ++counter; } else { FinishUndo(); counter = 0; } - return; } - - + + void LyXText::PrepareToPrint(Row * row, float & x, float & fill_separator, float & fill_hfill, float & fill_label_hfill) { diff --git a/src/toolbar.C b/src/toolbar.C index c950b4579f..433ee6b9b5 100644 --- a/src/toolbar.C +++ b/src/toolbar.C @@ -161,7 +161,8 @@ int Toolbar::BubblePost(FL_OBJECT *ob, int event, if(event == FL_ENTER && !help.empty()){ fl_set_object_callback(t->bubble_timer, - C_Toolbar_BubbleTimerCB, (long) ob); + C_Toolbar_BubbleTimerCB, + reinterpret_cast(ob)); fl_set_timer(t->bubble_timer, 1); } else if(event != FL_MOTION){ @@ -327,17 +328,18 @@ void Toolbar::set(bool doingmain) NorthWestGravity, NorthWestGravity); fl_set_object_callback(obj, C_Toolbar_ToolbarCB, - (long)item->action); + static_cast(item->action)); #if FL_REVISION >85 // Remove the blue feedback rectangle fl_set_pixmapbutton_focus_outline(obj, 0); #endif // set the bubble-help (Matthias) - obj->u_vdata = (void *) item->help.c_str(); +#warning This is dangerous! + obj->u_vdata = const_cast(item->help.c_str()); // we need to know what toolbar this item // belongs too. (Lgb) - obj->u_ldata = (long) this; + obj->u_ldata = reinterpret_cast(this); fl_set_object_posthandler(obj, C_Toolbar_BubblePost); @@ -485,8 +487,8 @@ void Toolbar::add(int action, bool doclean) help += arg; lyxerr.debug() << "Pseudo action " << action << endl; } else { - pixmap = getPixmap((kb_action)action); - help = lyxaction.helpText((kb_action)action); + pixmap = getPixmap(static_cast(action)); + help = lyxaction.helpText(static_cast(action)); } // adds an item to the list diff --git a/src/trans.C b/src/trans.C index 62fe8d1b2a..f543bbd2e6 100644 --- a/src/trans.C +++ b/src/trans.C @@ -161,8 +161,9 @@ void Trans::AddDeadkey(tex_accent accent, string const & keys, } for(string::size_type i = 0; i < keys.length(); ++i) { - char * temp; - temp = keymap_[static_cast(keys[i])] = new char[2]; + char * temp = + keymap_[static_cast(keys[i])] = + new char[2]; temp[0] = 0; temp[1] = accent; } kmod_list_[accent]->exception_list = 0; @@ -222,11 +223,11 @@ int Trans::Load(LyXLex & lex) } else return -1; - tex_accent accent_1= getkeymod(str); + tex_accent accent_1 = getkeymod(str); if (accent_1 == TEX_NOACCENT) return -1; if (lex.next(true)) { - str= lex.text(); + str = lex.text(); lyxerr[Debug::KBMAP] << str << endl; } else return -1; @@ -237,10 +238,10 @@ int Trans::Load(LyXLex & lex) if (kmod_list_[accent_1] == 0 || kmod_list_[accent_2] == 0) return -1; - // Find what key accent_2 is on - should check about accent_1 also - int key; - - for(key = 0; key < 256; ++key) { + // Find what key accent_2 is on - should + // check about accent_1 also + int key = 0; + for(; key < 256; ++key) { if (keymap_[key] && keymap_[key][0] == 0 && keymap_[key][1] == accent_2) break; @@ -254,7 +255,9 @@ int Trans::Load(LyXLex & lex) } else return -1; - InsertException(kmod_list_[accent_1]->exception_list,(char)key, allowed, true, accent_2); + InsertException(kmod_list_[accent_1]->exception_list, + static_cast(key), allowed, + true, accent_2); } break; case KMAP: { @@ -349,7 +352,7 @@ string Trans::process(char c, TransManager & k) if ((t == 0 && (*dt = c)) || (t[0] != 0 && (dt = t)) ){ return k.normalkey(c, dt); } else { - return k.deadkey(c, *kmod_list_[(tex_accent)t[1]]); + return k.deadkey(c, *kmod_list_[static_cast(t[1])]); } } @@ -387,7 +390,7 @@ tex_accent getkeymod(string const & p) if ( lyx_accent_table[i].name && contains(p, lyx_accent_table[i].name)) { lyxerr[Debug::KBMAP] << "Found it!" << endl; - return (tex_accent)i; + return static_cast(i); } } return TEX_NOACCENT; diff --git a/src/trans.h b/src/trans.h index 259433f300..917260d6ce 100644 --- a/src/trans.h +++ b/src/trans.h @@ -77,7 +77,7 @@ private: /// int Load(LyXLex &); /// - inline char * Match(char c); + inline char * Match(unsigned int c); /// void InsertException(keyexc & exclist, char c, string const & data, bool = false, @@ -95,9 +95,9 @@ private: }; -char * Trans::Match(char c) +char * Trans::Match(unsigned int c) { - return keymap_[static_cast(c)]; + return keymap_[c]; } #endif diff --git a/src/trans_mgr.C b/src/trans_mgr.C index 10bdc4655c..a9b9168d57 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -278,7 +278,7 @@ void TransManager::TranslateAndInsert(char c, LyXText * text) // Process with tokens string temp; - while(res.length()>0) { + while(res.length() > 0) { res = split(res, temp, TransState::TOKEN_SEP); insert(temp, text); } @@ -289,7 +289,7 @@ void TransManager::insertVerbatim(string const & str, LyXText * text) { int l = str.length(); - for (int i = 0;iGetFont(text->cursor.par, text->cursor.pos).latex() == LyXFont::OFF) diff --git a/src/vspace.C b/src/vspace.C index f80632bc54..2ed02b39e0 100644 --- a/src/vspace.C +++ b/src/vspace.C @@ -42,8 +42,8 @@ static char const * unit_name[num_units] = { "sp", "pt", "bp", "dd", LyXLength::UNIT unitFromString (string const & data) { int i = 0; - while ((i(i); } /* The following static items form a simple scanner for -- 2.39.5