]> git.lyx.org Git - lyx.git/commitdiff
some bib fixes from Herbert
authorLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 13 May 2002 13:23:29 +0000 (13:23 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Mon, 13 May 2002 13:23:29 +0000 (13:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4154 a592a061-630c-0410-9148-cb99ea01b6c8

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

index ebad706c8fb3728b0ede5b9a16018c62b0065b08..bb4dfdfdd97cedc861ae215da63a163dda38f4dd 100644 (file)
@@ -1,3 +1,11 @@
+2002-05-13  Herbert Voss  <voss@perce.de>
+
+       * biblio.C (getAbbreviatedAuthor): fix bug with "and" for Authors
+       like "Odland, G. and ... "
+       (parseBibTeX): fix bug with title and booktitle 
+       and replace a \n with a space when one entry has more than
+       one line
+
 2002-05-01  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * ControlCharacter.C: use "ignore" and "reset" as the identifiers, not
index ccbc6cdfc515a9bce01bd7c14ac9f29a0be8d7a1..f01dad30693809516c19944bc32a393f424ef2f1 100644 (file)
@@ -205,7 +205,7 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
                return author;
        }
 
-       vector<string> authors = getVectorFromString(author, "and");
+       vector<string> authors = getVectorFromString(author, " and");
 
        if (!authors.empty()) {
                author.erase();
@@ -379,24 +379,32 @@ string const parseBibTeX(string data, string const & findkey)
        string keyvalue;
        // at first we delete all characters right of '%' and
        // replace tabs through a space and remove leading spaces
+       // we read the data line by line so that the \n are
+       // ignored, too. 
        string data_;
        int Entries = 0;
        string dummy = token(data,'\n', Entries);
        while (!dummy.empty()) {
                dummy = subst(dummy, '\t', ' ');        // no tabs
-               dummy = frontStrip(dummy);      // no leading spaces
+               dummy = frontStrip(dummy);              // no leading spaces
+               // ignore lines with a beginning '%' or ignore all right of %
                string::size_type const idx =
                        dummy.empty() ? string::npos : dummy.find('%');
-               if (idx != string::npos) {
-                       // ignore lines with a beginning '%'
-                       if (idx > 0) {
-                               data_ += dummy.substr(0,data.find('%'));
-                       }
-               } else {
-                       data_ += dummy;
+               if (idx != string::npos) 
+                       dummy.erase(idx, string::npos);
+               // do we have a new token or a new line of
+               // the same one? In the first case we ignore
+               // the \n and in the second we replace it
+               // with a space
+               if (!dummy.empty()) {
+                       if (!contains(dummy, "="))
+                               data_ += (' ' + dummy); 
+                       else
+                               data_ += dummy;
                }
                dummy = token(data, '\n', ++Entries);
        }
+
        // replace double commas with "" for easy scanning
        data = subst(data_, ",,", "\"\"");
 
@@ -409,9 +417,18 @@ string const parseBibTeX(string data, string const & findkey)
        data += ',';  // now we have same behaviour for all entries
                      // because the last one is "blah ... }"
        Entries = 0;
-       dummy = token(data, ',', Entries);
-       while (!contains(lowercase(dummy), findkey) && !dummy.empty())
-               dummy = token(data, ',', ++Entries);
+       bool found = false;
+       // parsing of title and booktitle is different from the
+       // others, because booktitle contains title
+       do {
+               dummy = token(data, ',', Entries++);
+               if (!dummy.empty()) {
+                       found = contains(lowercase(dummy), findkey);
+                       if (findkey == "title" && 
+                               contains(lowercase(dummy), "booktitle"))
+                               found = false;
+               }               
+       } while (!found && !dummy.empty());
        if (dummy.empty())
                // no such keyword
                return string();
@@ -421,10 +438,10 @@ string const parseBibTeX(string data, string const & findkey)
        // Therefore we read all until the next "=" character, which follows a
        // new keyword
        keyvalue = dummy;
-       dummy = token(data, ',', ++Entries);
+       dummy = token(data, ',', Entries++);
        while (!contains(dummy, '=') && !dummy.empty()) {
                keyvalue += (',' + dummy);
-               dummy = token(data, ',', ++Entries);
+               dummy = token(data, ',', Entries++);
        }
 
        // replace double "" with originals ,, (two commas)