]> git.lyx.org Git - features.git/commitdiff
Those parts of Herbert's natbib patch that either fix bugs or just move
authorAngus Leeming <leeming@lyx.org>
Mon, 15 Apr 2002 12:05:07 +0000 (12:05 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 15 Apr 2002 12:05:07 +0000 (12:05 +0000)
functions around.

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

src/frontends/controllers/ChangeLog
src/frontends/controllers/biblio.C
src/frontends/controllers/biblio.h
src/frontends/controllers/helper_funcs.C
src/frontends/controllers/helper_funcs.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormCharacter.C
src/frontends/xforms/FormExternal.C
src/support/ChangeLog
src/support/lstrings.C
src/support/lstrings.h

index 2e1d53a1d25ceea691f2646bac5b4aaed3b4400a..f2730c68d714c6678f29cd0b632b831b33e27b9f 100644 (file)
@@ -1,3 +1,13 @@
+2002-04-14  Herbert Voss  <voss@perce.de>
+
+       * helper_funcs.[Ch]: move the getVectorFromString and the vice versa
+       into the support/lstrings for better use in other programs.
+
+       * biblio.[Ch] (getYear, getAbbreviatedAuthor, familyName): move out of
+       namespace anon and make globally accessible.
+       (familyName): test for the presence of a LaTeX Space at the front of
+       of a name; strip it if it exists.
+
 2002-04-11  Herbert Voss  <voss@perce.de>
 
        * ControlGraphics.C: expand "browse-string" to all available formats
index 12fe7f12ef3f6b61ab165b07bb9e401fd53967ba..9ed9961bfc7b17bfcbdbd0b81d3aaa80a1f039b4 100644 (file)
@@ -142,6 +142,10 @@ regexSearch(InfoMap const & theMap,
        return keys.end();
 }
 
+
+} // namespace anon
+
+
 string const familyName(string const & name)
 {
        // Very simple parser
@@ -158,6 +162,9 @@ string const familyName(string const & name)
        idx = fname.rfind(".");
        if (idx != string::npos)
                fname = frontStrip(fname.substr(idx+1));
+       // test if we have a LaTeX Space in front
+       if (fname[0] == '\\')
+               return fname.substr(2);
 
        return fname;
 }
@@ -217,9 +224,6 @@ string const getYear(InfoMap const & map, string const & key)
        return year;
 }
 
-} // namespace anon
-
-
 
 // A functor for use with std::sort, leading to case insensitive sorting
 struct compareNoCase: public std::binary_function<string, string, bool>
index b933aa53be972a1562ae3293d1779124eb076c9b..393d800400d9ed768829a83ee448b181e0f2b123 100644 (file)
@@ -60,6 +60,15 @@ namespace biblio
            Empty if no info exists. */
        string const getInfo(InfoMap const &, string const &);
 
+       // rturn the year from the bibtex data record
+       string const getYear(InfoMap const & map, string const & key);
+       
+       /// return the short form of an authorlist
+       string const getAbbreviatedAuthor(InfoMap const & map, string const & key);
+
+       // return only the family name
+       string const familyName(string const & name);
+
        /** Search a BibTeX info field for the given key and return the
            associated field. */
        string const parseBibTeX(string data, string const & findkey);
index 7bb293c1cfa49ba79ca2182084052fbad75c187d..32d6ddb6bd220e00a5736280a01b216edcb19487 100644 (file)
@@ -31,50 +31,6 @@ using std::pair;
 using std::vector;
 using std::make_pair;
 
-
-string const getStringFromVector(vector<string> const & vec,
-                                string const & delim)
-{
-       string str;
-       int i = 0;
-       for (vector<string>::const_iterator it = vec.begin();
-            it != vec.end(); ++it) {
-               string item = strip(frontStrip(*it));
-               if (item.empty()) continue;
-
-               if (i++ > 0) str += delim;
-               str += item;
-       }
-       return str;
-}
-
-vector<string> const getVectorFromString(string const & str,
-                                        string const & delim)
-{
-       vector<string> vec;
-       if (str.empty())
-               return vec;
-
-       string keys(strip(str));
-
-       for(;;) {
-               string::size_type const idx = keys.find(delim);
-               if (idx == string::npos) {
-                       vec.push_back(frontStrip(keys));
-                       break;
-               }
-
-               string const key = strip(frontStrip(keys.substr(0, idx)));
-               if (!key.empty())
-                       vec.push_back(key);
-
-               string::size_type const start = idx + delim.size();
-               keys = keys.substr(start);
-       }
-
-       return vec;
-}
-
 string const browseFile(LyXView * lv, string const & filename,
                        string const & title,
                        string const & pattern,
index 2252cbcc27204b9432aafe868e2113bcb5eb8bf9..eb8e77a50cd001596c34c226d57bf048cdf2b50d 100644 (file)
 #pragma interface
 #endif
 
-/** Functions to convert a string to/from a vector. */
-
-///
-string const
-getStringFromVector(std::vector<string> const & vec, string const & delim=",");
-
-///
-std::vector<string> const
-getVectorFromString(string const & str, string const & delim=",");
-
 class LyXView;
 
 /** Launch a file dialog and return the chosen file.
index f857835ac458d8cee1a55ec71165578a8c4f7e57..f7f058ed17b49433397996210bf640db734589a4 100644 (file)
@@ -1,3 +1,9 @@
+2002-04-14  Herbert Voss  <voss@perce.de>
+
+       * FormCharacter.C
+       * FormExternal.C: adding #include "support/lstrings.h"
+       for the getStringFromVector and vice versa
+
 2002-04-12  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormParagraph.C (changedParagraph): ensure that the warning message
index 371b3a91bfd4a8671cf679cdb15ebc5fd92c9e24..d9b16cea308c39564480b2e22122a6d2511ddde5 100644 (file)
@@ -23,6 +23,8 @@
 #include "combox.h"
 #include "helper_funcs.h"
 
+#include "support/lstrings.h"
+
 using std::vector;
 using std::find;
 
index 9a58f76f5e2acc1bcb5dbb14ed7d70246f8657f4..ae325b8ddf01441cde0dd0c690b74c772ffe6a86 100644 (file)
@@ -22,6 +22,8 @@
 #include "xforms_helpers.h"
 #include "helper_funcs.h"
 
+#include "support/lstrings.h"
+
 typedef FormCB<ControlExternal, FormDB<FD_form_external> > base_class;
 
 FormExternal::FormExternal(ControlExternal & c)
index 099ae47cca407780e57de3159408d77d0ed36fba..b04d48b26c6be2c065af79bb8d320c62f4d95c44 100644 (file)
@@ -1,3 +1,9 @@
+2002-04-14  Herbert Voss  <voss@perce.de>
+
+       * lstrings.[Ch]: move the getVectorFromString and the vice versa
+       from frontends/controllers/helper_funcs for better use in other
+       programs
+
 2002-04-15  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * tempname.C (make_tempfile): simplify the #ifdef block by using
index 57be367bf30d3dd81e203204585e5ab33140cb00..39594d53f1cc3957d35c42796525da811e36ddf6 100644 (file)
@@ -27,6 +27,7 @@
 
 using std::count;
 using std::transform;
+using std::vector;
 
 #ifndef CXX_GLOBAL_CSTD
 using std::tolower;
@@ -632,3 +633,45 @@ string const escape(string const & lab)
        }
        return enc;
 }
+
+
+/// gives a vector of stringparts which have the delimiter delim
+vector<string> const getVectorFromString(string const & str,
+                                        string const & delim)
+{
+    vector<string> vec;
+    if (str.empty())
+       return vec;
+    string keys(strip(str));
+    for(;;) {
+       string::size_type const idx = keys.find(delim);
+       if (idx == string::npos) {
+           vec.push_back(frontStrip(keys));
+           break;
+       }
+       string const key = strip(frontStrip(keys.substr(0, idx)));
+       if (!key.empty())
+           vec.push_back(key);
+       string::size_type const start = idx + delim.size();
+       keys = keys.substr(start);
+    }
+    return vec;
+}
+
+// the same vice versa
+string const getStringFromVector(vector<string> const & vec,
+                                string const & delim)
+{
+       string str;
+       int i = 0;
+       for (vector<string>::const_iterator it = vec.begin();
+            it != vec.end(); ++it) {
+               string item = strip(frontStrip(*it));
+               if (item.empty()) continue;
+
+               if (i++ > 0) str += delim;
+               str += item;
+       }
+       return str;
+}
+
index 7f78c374a82834b9f6ef6f328c23540cb3d21110..eccfcc9ebdbb866a2420051f85a62be8e78baed6 100644 (file)
 
 //#include <cstring>
 //#include <cctype>
+//#include <cctype>
+#include <vector>
 
 #include "Lsstream.h"
 
 #include "LString.h"
 
-
 ///
 int compare_no_case(string const & s, string const & s2);
 
@@ -250,4 +251,12 @@ string const rsplit(string const & a, string & piece, char delim);
 /// Escapes non ASCII chars
 string const escape(string const & lab);
 
+/// gives a vector of stringparts which have the delimiter delim
+std::vector<string> const getVectorFromString(string const & str,
+                                             string const & delim = ",");
+
+// the same vice versa
+string const getStringFromVector(std::vector<string> const & vec,
+                                string const & delim = ",");
+
 #endif