]> git.lyx.org Git - features.git/commitdiff
(Herbert): fix parsing of bibtex entry bug.
authorAngus Leeming <leeming@lyx.org>
Tue, 16 Apr 2002 09:09:42 +0000 (09:09 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 16 Apr 2002 09:09:42 +0000 (09:09 +0000)
(Henry Pfister): also fixes bug in loading bibtex database.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3999 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ChangeLog
src/frontends/controllers/biblio.C
src/insets/ChangeLog
src/insets/insetbib.C

index f2730c68d714c6678f29cd0b632b831b33e27b9f..b723d65fa408f1a0187bec517359648648b0019f 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-15  Herbert Voss  <voss@perce.de>
+
+       * biblio.[Ch] (parseBibTeX): fix bug while scanning bibtexentries
+       with something like ,,...blah...`` (two commas)
+
 2002-04-14  Herbert Voss  <voss@perce.de>
 
        * helper_funcs.[Ch]: move the getVectorFromString and the vice versa
index 9ed9961bfc7b17bfcbdbd0b81d3aaa80a1f039b4..bda91ed8e36a3c3dfacb6cc90298fdef9ebadbe0 100644 (file)
@@ -355,7 +355,8 @@ string const parseBibTeX(string data, string const & findkey)
                }
                dummy = token(data, '\n', ++Entries);
        }
-       data = data_;
+       // replace double commas with "" for easy scanning
+       data = subst(data_, ",,", "\"\"");
 
        // unlikely!
        if (data.empty())
@@ -370,9 +371,12 @@ string const parseBibTeX(string data, string const & findkey)
        while (!contains(lowercase(dummy), findkey) && !dummy.empty())
                dummy = token(data, ',', ++Entries);
        if (dummy.empty())
-               return string();                        // no such keyword
-       // we are not sure, if we get all, because "key= "blah, blah" is allowed.
-       // therefore we read all until the next "=" character, which follows a
+               // no such keyword
+               return string();
+
+       // we are not sure, if we get all, because "key= "blah, blah" is
+       // allowed.
+       // Therefore we read all until the next "=" character, which follows a
        // new keyword
        keyvalue = dummy;
        dummy = token(data, ',', ++Entries);
@@ -380,10 +384,17 @@ string const parseBibTeX(string data, string const & findkey)
                keyvalue += (',' + dummy);
                dummy = token(data, ',', ++Entries);
        }
-       data = keyvalue;                // now we have the important line
-       data = strip(data, ' ');                // all spaces
-       if (!contains(data, '{'))       // no opening '{'
-               data = strip(data, '}');// maybe there is a main closing '}'
+
+       // replace double "" with originals ,, (two commas)
+       // leaving us with the all-important line
+       data = subst(keyvalue, "\"\"", ",,");
+
+       // Clean-up.
+       // 1. Spaces
+       data = strip(data, ' ');
+       // 2. if there is no opening '{' then a closing '{' is probably cruft.
+       if (!contains(data, '{'))
+               data = strip(data, '}');
        // happens, when last keyword
        string::size_type const idx =
                !data.empty() ? data.find('=') : string::npos;
index 448a456a03311c3a8a49b6847cc6459d839242c9..b86eca6d83d413f6c6ddf2a2d1d0147a762a0c32 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-16  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * insetbib.C (getKeys): strip leading '\t's from the line too.
+       With thanks to Henry Pfister <hpfister@ucsd.edu>.
+
 2002-04-12  Juergen Vigna  <jug@sad.it>
 
        * insettext.h: added cix() helper function and use it where appropriate
index 481e8dfe545d7e57e246e32ab418043833f21abe..8b4ca13d18711b14d6f1c152186beeb26c50bc4b 100644 (file)
@@ -264,6 +264,7 @@ vector<pair<string, string> > const InsetBibtex::getKeys(Buffer const * buffer)
                                    && !prefixIs(tmp, "@preamble")) {
                                        linebuf = split(linebuf, tmp, ',');
                                        tmp = frontStrip(tmp);
+                                       tmp = frontStrip(tmp,'\t');
                                        if (!tmp.empty()) {
                                                keys.push_back(pair<string,string>(tmp,string()));
                                        }