From 40b1da348c8ab6f689138401dbfd9b7c5b9f5891 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 4 Oct 2000 14:19:07 +0000 Subject: [PATCH] Fix the lyxformat problem + other small things. Are we ready for 1.1.5fix2? git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/lyx-1_1_5@1081 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 15 +++++++++++ configure.in | 2 +- lib/layouts/amsart.layout | 2 +- lib/layouts/amsbook.layout | 2 ++ lib/layouts/revtex4.layout | 51 ++++++++++++++++++++++++-------------- src/buffer.C | 20 +++++++++++++-- src/lyxlex.C | 20 +++++++++------ src/main.C | 1 + 8 files changed, 82 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62c314b775..85efa6ceaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2000-10-04 Jean-Marc Lasgouttes + * src/lyxlex.C (GetFloat): rewrite to use strToDbl() and + understand ',' instead of '.'. + (GetInteger): rewrite to use strToInt(). + + * src/buffer.C (readFile): make sure that the whole version number + is read after \lyxformat (even when it contains a comma) + + * lib/layouts/revtex4.layout: update from Amir Karger. + + * lib/layouts/amsart.layout: include lyxmacros.inc, so that + LyX-Code is defined. + * lib/layouts/amsbook.layout: ditto. + + * src/main.C (main): set locale LC_NUMERIC to "C". + * src/support/lstrings.[Ch]: add isStrDbl and StrToDbl that I forgot earlier :( diff --git a/configure.in b/configure.in index 1f4cc9f0a2..526b656688 100644 --- a/configure.in +++ b/configure.in @@ -82,7 +82,7 @@ LYX_CXX_CHEADERS LYX_STD_COUNT dnl we disable rtti for now dnl LYX_CXX_RTTI -AC_CHECK_HEADERS(ostream istream sstream) +AC_CHECK_HEADERS(ostream istream sstream locale) LYX_CXX_STL_MODERN_STREAMS ### We need a regex implementation, so we provide our own if none is found. diff --git a/lib/layouts/amsart.layout b/lib/layouts/amsart.layout index e974513162..6e8ab40a4b 100644 --- a/lib/layouts/amsart.layout +++ b/lib/layouts/amsart.layout @@ -99,7 +99,7 @@ NoStyle Verse # Although mathematicians tend to be poets at times, Input stdlists.inc - +Input lyxmacros.inc ### Finally a few obsolete definitions for compatibility Input obsolete.inc diff --git a/lib/layouts/amsbook.layout b/lib/layouts/amsbook.layout index 00e669068c..0a73227929 100644 --- a/lib/layouts/amsbook.layout +++ b/lib/layouts/amsbook.layout @@ -128,6 +128,8 @@ Style Chapter_Exercises End +Input lyxmacros.inc + ### Finally a few obsolete definitions for compatibility Input obsolete.inc diff --git a/lib/layouts/revtex4.layout b/lib/layouts/revtex4.layout index e848a70b84..8df02183ec 100644 --- a/lib/layouts/revtex4.layout +++ b/lib/layouts/revtex4.layout @@ -6,14 +6,8 @@ # paper "testmath.tex" of January, 1995 # Author : David L. Johnson (AMS) # Marc Mengel (RevTeX) -# Amir Karger (LyX v11.34 style modifications - using changes -# made by Jean-Marc Lasgouttes to amsart.layout) -# Amir Karger (RevTeX 4 beta) 9/1999 - -#TODO: need to make a thanks layout and write note in template not to -#put footnotes in the title matter! -#TODO: examine this issue that it seems you need to put the address last or you -#get errors (seems to happen even when not using lyx...) +# Amir Karger (LyX v11.34 style modifications) +# Amir Karger (RevTeX 4 beta) 9/1999, 7/2000 # General textclass parameters Columns 1 @@ -152,40 +146,40 @@ Style Date EndFont End -# Address style definition -# (This style is same as Afilliation for Phys. Rev.) -Style Address +Style Affiliation Margin Dynamic LatexType Command InTitle 1 - LatexName address + LatexName affiliation ParSkip 0.4 # BottomSep 1.5 # ParSep 1.5 Align Center AlignPossible Block, Left, Right, Center LabelType Static - LabelString "Address: " + LabelString "Affiliation: " LabelFont Shape Italic EndFont End -Style Affiliation - CopyStyle Address - LatexName affiliation - LabelString "Affiliation: " +# Address is exactly the same as Affiliation. We just put this in so +# that reLyX will know what to do with it. +Style Address + CopyStyle Affiliation + LatexName address + LabelString "Address: " End Style Thanks - CopyStyle Address + CopyStyle Affiliation LatexName thanks LabelString "Thanks: " End Style Author_Email - CopyStyle Address + CopyStyle Affiliation LatexName email LabelString "Electronic Address: " @@ -215,6 +209,25 @@ Style Abstract EndFont End +Style Acknowledgments + LatexType Environment + LatexName acknowledgments + ParIndent MM + ParSkip 0.4 + Align Block + AlignPossible Block, Left, Right, Center + + # label definition + LabelType Centered_Top_Environment + LabelString acknowledgments + LabelBottomSep 0.5 + LabelFont + Series Medium + Shape Smallcaps + Size Large + EndFont +End + Style PACS Margin Dynamic LatexType Command diff --git a/src/buffer.C b/src/buffer.C index 899e88b447..1265157a25 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -24,6 +24,10 @@ #include +#ifdef HAVE_LOCALE +#include +#endif + #ifdef __GNUG__ #pragma implementation "buffer.h" #endif @@ -1085,7 +1089,7 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par) lex.next(); token = lex.GetString(); if (token == "\\lyxformat") { // the first token _must_ be... - lex.next(); + lex.EatLine(); format = lex.GetFloat(); if (format > 1) { if (LYX_FORMAT - format > 0.05) { @@ -1259,6 +1263,12 @@ bool Buffer::writeFile(string const & fname, bool flag) const fname); return false; } + +#ifdef HAVE_LOCALE + // Use the standard "C" locale for file output. + ofs.imbue(locale::classic()); +#endif + // The top of the file should not be written by params. // write out a comment in the top of the file @@ -1266,8 +1276,14 @@ bool Buffer::writeFile(string const & fname, bool flag) const << " created this file. For more info see http://www.lyx.org/\n"; ofs.setf(ios::showpoint|ios::fixed); ofs.precision(2); +#ifndef HAVE_LOCALE + char dummy_format[512]; + sprintf(dummy_format, "%.2f", LYX_FORMAT); + ofs << "\\lyxformat " << dummy_format << "\n"; +#else ofs << "\\lyxformat " << setw(4) << LYX_FORMAT << "\n"; - +#endif + // now write out the buffer paramters. params.writeFile(ofs); diff --git a/src/lyxlex.C b/src/lyxlex.C index 3e7206dcc2..350137726a 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -103,8 +103,8 @@ int LyXLex::lex() int LyXLex::GetInteger() const { - if (pimpl_->buff[0] > ' ') - return atoi(pimpl_->buff); + if (isStrInt(pimpl_->GetString())) + return strToInt(pimpl_->GetString()); else { pimpl_->printError("Bad integer `$$Token'"); return -1; @@ -114,12 +114,16 @@ int LyXLex::GetInteger() const float LyXLex::GetFloat() const { - if (pimpl_->buff[0] > ' ') - return atof(pimpl_->buff); - else { - pimpl_->printError("Bad float `$$Token'"); - return -1; - } + // replace comma with dot in case the file was written with + // the wrong locale (should be rare, but is easy enough to + // avoid). + string str = subst(pimpl_->GetString(), ",", "."); + if (isStrDbl(str)) + return strToDbl(str); + else { + pimpl_->printError("Bad float `$$Token'"); + return -1; + } } diff --git a/src/main.C b/src/main.C index e3f9e6159e..57832f7bc6 100644 --- a/src/main.C +++ b/src/main.C @@ -66,6 +66,7 @@ int main(int argc, char * argv[]) // initialize for internationalized version *EK* locale_init(); + setlocale(LC_NUMERIC, "C"); gettext_init(); #ifdef __EMX__