+void LaTeX::scanAuxFile(string const & file, Aux_Info & aux_info)
+{
+ lyxerr[Debug::LATEX] << "Scanning aux file: " << file << endl;
+
+ ifstream ifs(file.c_str());
+ string token;
+ regex reg1("\\\\citation\\{([^}]+)\\}");
+ regex reg2("\\\\bibdata\\{([^}]+)\\}");
+ regex reg3("\\\\bibstyle\\{([^}]+)\\}");
+ regex reg4("\\\\@input\\{([^}]+)\\}");
+
+ while (getline(ifs, token)) {
+ token = rtrim(token, "\r");
+#ifndef USE_INCLUDED_STRING
+ smatch sub;
+#else
+ cmatch sub;
+#endif
+ if (regex_match(STRCONV(token), sub, reg1)) {
+ string data = STRCONV(sub.str(1));
+ while (!data.empty()) {
+ string citation;
+ data = split(data, citation, ',');
+ lyxerr[Debug::LATEX] << "Citation: "
+ << citation << endl;
+ aux_info.citations.insert(citation);
+ }
+ } else if (regex_match(STRCONV(token), sub, reg2)) {
+ string data = sub.STRCONV(str(1));
+ // data is now all the bib files separated by ','
+ // get them one by one and pass them to the helper
+ while (!data.empty()) {
+ string database;
+ data = split(data, database, ',');
+ database = ChangeExtension(database, "bib");
+ lyxerr[Debug::LATEX] << "BibTeX database: `"
+ << database << '\'' << endl;
+ aux_info.databases.insert(database);
+ }
+ } else if (regex_match(STRCONV(token), sub, reg3)) {
+ string style = STRCONV(sub.str(1));
+ // token is now the style file
+ // pass it to the helper
+ style = ChangeExtension(style, "bst");
+ lyxerr[Debug::LATEX] << "BibTeX style: `"
+ << style << '\'' << endl;
+ aux_info.styles.insert(style);
+ } else if (regex_match(STRCONV(token), sub, reg4)) {
+ string const file2 = STRCONV(sub.str(1));
+ scanAuxFile(file2, aux_info);