Fix case of BibTeX keys and remove unused variable. By myself and Bernhard.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17919 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2007-04-23 15:18:01 +00:00
parent 65160d9ad6
commit 05ba87fe7a

View File

@ -373,13 +373,20 @@ namespace {
return true; return true;
} }
enum charCase {
makeLowerCase,
keepCase
};
/// remove whitespace characters, read characer sequence /// remove whitespace characters, read characer sequence
/// not containing whitespace characters or characters in /// not containing whitespace characters or characters in
/// delimChars, and remove further whitespace characters. /// delimChars, and remove further whitespace characters.
/// ///
/// @return true if a string of length > 0 could be read. /// @return true if a string of length > 0 could be read.
/// ///
bool readTypeOrKey(docstring & val, idocfstream & ifs, docstring const & delimChars) { bool readTypeOrKey(docstring & val, idocfstream & ifs,
docstring const & delimChars, charCase chCase) {
char_type ch; char_type ch;
@ -398,7 +405,11 @@ namespace {
// read value // read value
while (ifs && !isSpace(ch) && delimChars.find(ch) == docstring::npos) { while (ifs && !isSpace(ch) && delimChars.find(ch) == docstring::npos) {
if (chCase == makeLowerCase) {
val += lowercase(ch); val += lowercase(ch);
} else {
val += ch;
}
ifs.get(ch); ifs.get(ch);
} }
@ -578,7 +589,7 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
docstring entryType; docstring entryType;
if (!readTypeOrKey(entryType, ifs, from_ascii("{(")) || !ifs) if (!readTypeOrKey(entryType, ifs, from_ascii("{("), makeLowerCase) || !ifs)
continue; continue;
if (entryType == from_ascii("comment")) { if (entryType == from_ascii("comment")) {
@ -587,16 +598,11 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
continue; continue;
} }
// check entry delimiter
char_type entryDelim;
ifs.get(ch); ifs.get(ch);
if (!ifs) if (!ifs)
break; break;
if (ch == '(') entryDelim = ')'; if ((ch != '(') && (ch != '{')) {
else if (ch == '{') entryDelim = ')';
else {
// invalid entry delimiter // invalid entry delimiter
ifs.putback(ch); ifs.putback(ch);
continue; continue;
@ -610,7 +616,7 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
docstring name; docstring name;
docstring value; docstring value;
if (!readTypeOrKey(name, ifs, from_ascii("#=}),")) || !ifs) if (!readTypeOrKey(name, ifs, from_ascii("#=}),"), makeLowerCase) || !ifs)
continue; continue;
ifs.get(ch); ifs.get(ch);
@ -640,7 +646,7 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
docstring value; docstring value;
docstring commaNewline; docstring commaNewline;
if (!readTypeOrKey(key, ifs, from_ascii(",})")) || !ifs) if (!readTypeOrKey(key, ifs, from_ascii(",})"), keepCase) || !ifs)
continue; continue;
// now we have a key, so we will add an entry // now we have a key, so we will add an entry
@ -654,7 +660,7 @@ void InsetBibtex::fillWithBibKeys(Buffer const & buffer,
while (ifs && readNext) { while (ifs && readNext) {
// read field name // read field name
if (!readTypeOrKey(name, ifs, from_ascii("=}),")) || !ifs) if (!readTypeOrKey(name, ifs, from_ascii("=}),"), makeLowerCase) || !ifs)
break; break;
// next char must be an equal sign // next char must be an equal sign