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
This commit is contained in:
Jean-Marc Lasgouttes 2000-10-04 14:19:07 +00:00
parent 62a50191cc
commit 40b1da348c
8 changed files with 82 additions and 31 deletions

View File

@ -1,5 +1,20 @@
2000-10-04 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* 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 :(

View File

@ -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.

View File

@ -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

View File

@ -128,6 +128,8 @@ Style Chapter_Exercises
End
Input lyxmacros.inc
### Finally a few obsolete definitions for compatibility
Input obsolete.inc

View File

@ -6,14 +6,8 @@
# paper "testmath.tex" of January, 1995
# Author : David L. Johnson <dlj0@lehigh.edu> (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

View File

@ -24,6 +24,10 @@
#include <algorithm>
#ifdef HAVE_LOCALE
#include <locale>
#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);

View File

@ -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;
}
}

View File

@ -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__