mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-12 00:39:18 +00:00
Add forgotten functions and apply literate programming fix from Edmar.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/lyx-1_1_5@1080 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
be967977f2
commit
62a50191cc
@ -1,3 +1,12 @@
|
||||
2000-10-04 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* src/support/lstrings.[Ch]: add isStrDbl and StrToDbl that I
|
||||
forgot earlier :(
|
||||
|
||||
2000-10-04 Edmar Wienskoski Jr <edmar-w-jr@technologist.com>
|
||||
|
||||
* src/Literate.[Ch]: fix parsing of LaTeX errors.
|
||||
|
||||
2000-09-29 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* src/paragraph.C (TeXFootnote): Fixed bug with LTR table floats.
|
||||
|
File diff suppressed because it is too large
Load Diff
160
src/Literate.C
160
src/Literate.C
@ -66,13 +66,13 @@ int Literate::weave(TeXErrors & terr, MiniBuffer * minib)
|
||||
ret1 = one.startscript(Systemcalls::System, tmp1);
|
||||
ret2 = two.startscript(Systemcalls::System, tmp2);
|
||||
lyxerr.debug() << "LITERATE {" << tmp1 << "} {" << tmp2 << "}" << endl;
|
||||
scanres = scanLiterateLogFile();
|
||||
scanres = scanLiterateLogFile(terr);
|
||||
if (scanres & Literate::ERRORS) return scanres; // return on literate error
|
||||
return run(terr, minib);
|
||||
}
|
||||
|
||||
|
||||
int Literate::build(TeXErrors & /*terr*/, MiniBuffer * minib)
|
||||
int Literate::build(TeXErrors & terr, MiniBuffer * minib)
|
||||
// We know that this function will only be run if the lyx buffer
|
||||
// has been changed.
|
||||
{
|
||||
@ -95,66 +95,156 @@ int Literate::build(TeXErrors & /*terr*/, MiniBuffer * minib)
|
||||
tmp2 = build_filter + " < " + litfile + ".out" + " > " + litfile + ".log";
|
||||
ret1 = one.startscript(Systemcalls::System, tmp1);
|
||||
ret2 = two.startscript(Systemcalls::System, tmp2);
|
||||
scanres = scanBuildLogFile();
|
||||
scanres = scanBuildLogFile(terr);
|
||||
lyxerr[Debug::LATEX] << "Done." << endl;
|
||||
|
||||
return scanres;
|
||||
}
|
||||
|
||||
|
||||
int Literate::scanLiterateLogFile()
|
||||
int Literate::scanLiterateLogFile(TeXErrors & terr)
|
||||
{
|
||||
string token;
|
||||
int retval = NO_ERRORS;
|
||||
|
||||
string tmp = litfile + ".log";
|
||||
|
||||
int last_line = -1;
|
||||
int line_count = 1;
|
||||
int retval = NO_ERRORS;
|
||||
lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
|
||||
ifstream ifs(tmp.c_str());
|
||||
while (getline(ifs, token)) {
|
||||
lyxerr[Debug::LATEX] << token << endl;
|
||||
|
||||
if (prefixIs(token, "Build Warning:")) {
|
||||
// Here shall we handle different
|
||||
// types of warnings
|
||||
retval |= LATEX_WARNING;
|
||||
lyxerr[Debug::LATEX] << "Build Warning." << endl;
|
||||
} else if (prefixIs(token, "! Build Error:")) {
|
||||
// Here shall we handle different
|
||||
// types of errors
|
||||
string token;
|
||||
while (getline(ifs, token)) {
|
||||
lyxerr[Debug::LATEX] << "Log line: " << token << endl;
|
||||
|
||||
if (token.empty())
|
||||
continue;
|
||||
|
||||
if (prefixIs(token, "! ")) {
|
||||
// Ok, we have something that looks like a TeX Error
|
||||
// but what do we really have.
|
||||
|
||||
// Just get the error description:
|
||||
string desc(token, 2);
|
||||
if (contains(token, "Build Error:"))
|
||||
retval |= LATEX_ERROR;
|
||||
lyxerr[Debug::LATEX] << "Build Error." << endl;
|
||||
// this is not correct yet
|
||||
// get the next line
|
||||
string tmp;
|
||||
int count = 0;
|
||||
do {
|
||||
if (!getline(ifs, tmp))
|
||||
break;
|
||||
if (++count > 10)
|
||||
break;
|
||||
} while (!prefixIs(tmp, "l."));
|
||||
if (prefixIs(tmp, "l.")) {
|
||||
// we have a build error
|
||||
retval |= TEX_ERROR;
|
||||
// get the line number:
|
||||
int line = 0;
|
||||
sscanf(tmp.c_str(), "l.%d", &line);
|
||||
// get the rest of the message:
|
||||
string errstr(tmp, tmp.find(' '));
|
||||
errstr += '\n';
|
||||
getline(ifs, tmp);
|
||||
while (!contains(errstr, "l.")
|
||||
&& !tmp.empty()
|
||||
&& !prefixIs(tmp, "! ")
|
||||
&& !contains(tmp, " ...")) {
|
||||
errstr += tmp;
|
||||
errstr += "\n";
|
||||
getline(ifs, tmp);
|
||||
}
|
||||
lyxerr[Debug::LATEX]
|
||||
<< "line: " << line << '\n'
|
||||
<< "Desc: " << desc << '\n'
|
||||
<< "Text: " << errstr << endl;
|
||||
if (line == last_line)
|
||||
++line_count;
|
||||
else {
|
||||
line_count = 1;
|
||||
last_line = line;
|
||||
}
|
||||
if (line_count <= 5) {
|
||||
terr.insertError(line, desc, errstr);
|
||||
++num_errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lyxerr[Debug::LATEX] << "Log line: " << token << endl;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
int Literate::scanBuildLogFile()
|
||||
int Literate::scanBuildLogFile(TeXErrors & terr)
|
||||
{
|
||||
string token;
|
||||
int retval = NO_ERRORS;
|
||||
|
||||
string tmp = litfile + ".log";
|
||||
|
||||
int last_line = -1;
|
||||
int line_count = 1;
|
||||
int retval = NO_ERRORS;
|
||||
lyxerr[Debug::LATEX] << "Log file: " << tmp << endl;
|
||||
ifstream ifs(tmp.c_str());
|
||||
while (getline(ifs, token)) {
|
||||
lyxerr[Debug::LATEX] << token << endl;
|
||||
|
||||
if (prefixIs(token, "Build Warning:")) {
|
||||
// Here shall we handle different
|
||||
// types of warnings
|
||||
retval |= LATEX_WARNING;
|
||||
lyxerr[Debug::LATEX] << "Build Warning." << endl;
|
||||
} else if (prefixIs(token, "! Build Error:")) {
|
||||
// Here shall we handle different
|
||||
// types of errors
|
||||
string token;
|
||||
while (getline(ifs, token)) {
|
||||
lyxerr[Debug::LATEX] << "Log line: " << token << endl;
|
||||
|
||||
if (token.empty())
|
||||
continue;
|
||||
|
||||
if (prefixIs(token, "! ")) {
|
||||
// Ok, we have something that looks like a TeX Error
|
||||
// but what do we really have.
|
||||
|
||||
// Just get the error description:
|
||||
string desc(token, 2);
|
||||
if (contains(token, "Build Error:"))
|
||||
retval |= LATEX_ERROR;
|
||||
lyxerr[Debug::LATEX] << "Build Error." << endl;
|
||||
// this is not correct yet
|
||||
// get the next line
|
||||
string tmp;
|
||||
int count = 0;
|
||||
do {
|
||||
if (!getline(ifs, tmp))
|
||||
break;
|
||||
if (++count > 10)
|
||||
break;
|
||||
} while (!prefixIs(tmp, "l."));
|
||||
if (prefixIs(tmp, "l.")) {
|
||||
// we have a build error
|
||||
retval |= TEX_ERROR;
|
||||
// get the line number:
|
||||
int line = 0;
|
||||
sscanf(tmp.c_str(), "l.%d", &line);
|
||||
// get the rest of the message:
|
||||
string errstr(tmp, tmp.find(' '));
|
||||
errstr += '\n';
|
||||
getline(ifs, tmp);
|
||||
while (!contains(errstr, "l.")
|
||||
&& !tmp.empty()
|
||||
&& !prefixIs(tmp, "! ")
|
||||
&& !contains(tmp, " ...")) {
|
||||
errstr += tmp;
|
||||
errstr += "\n";
|
||||
getline(ifs, tmp);
|
||||
}
|
||||
lyxerr[Debug::LATEX]
|
||||
<< "line: " << line << '\n'
|
||||
<< "Desc: " << desc << '\n'
|
||||
<< "Text: " << errstr << endl;
|
||||
if (line == last_line)
|
||||
++line_count;
|
||||
else {
|
||||
line_count = 1;
|
||||
last_line = line;
|
||||
}
|
||||
if (line_count <= 5) {
|
||||
terr.insertError(line, desc, errstr);
|
||||
++num_errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lyxerr[Debug::LATEX] << "Log line: " << token << endl;
|
||||
return retval;
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ public:
|
||||
int build(TeXErrors &, MiniBuffer *);
|
||||
private:
|
||||
///
|
||||
int scanLiterateLogFile();
|
||||
int scanLiterateLogFile(TeXErrors & terr);
|
||||
|
||||
///
|
||||
int scanBuildLogFile();
|
||||
int scanBuildLogFile(TeXErrors & terr);
|
||||
|
||||
///
|
||||
string litfile;
|
||||
|
@ -95,6 +95,49 @@ int strToInt(string const & str)
|
||||
}
|
||||
|
||||
|
||||
bool isStrDbl(string const & str)
|
||||
{
|
||||
if (str.empty()) return false;
|
||||
|
||||
// Remove leading and trailing white space chars.
|
||||
string const tmpstr = frontStrip(strip(str, ' '), ' ');
|
||||
if (tmpstr.empty()) return false;
|
||||
// if (1 < tmpstr.count('.')) return false;
|
||||
|
||||
string::const_iterator cit = tmpstr.begin();
|
||||
bool found_dot(false);
|
||||
if ( (*cit) == '-') ++cit;
|
||||
string::const_iterator end = tmpstr.end();
|
||||
for (; cit != end; ++cit) {
|
||||
if (!isdigit((*cit))
|
||||
&& '.' != (*cit)) {
|
||||
return false;
|
||||
}
|
||||
if ('.' == (*cit)) {
|
||||
if (found_dot) {
|
||||
return false;
|
||||
} else {
|
||||
found_dot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
double strToDbl(string const & str)
|
||||
{
|
||||
if (isStrDbl(str)) {
|
||||
// Remove leading and trailing white space chars.
|
||||
string const tmpstr = frontStrip(strip(str, ' '), ' ');
|
||||
// Do the conversion proper.
|
||||
return ::atof(tmpstr.c_str());
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string lowercase(string const & a)
|
||||
{
|
||||
string tmp(a);
|
||||
|
@ -48,6 +48,12 @@ bool isStrInt(string const & str);
|
||||
///
|
||||
int strToInt(string const & str);
|
||||
|
||||
///
|
||||
bool isStrDbl(string const & str);
|
||||
|
||||
///
|
||||
double strToDbl(string const & str);
|
||||
|
||||
///
|
||||
string lowercase(string const &);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user