+ vector<string> options;
+ string option;
+ Parser p(input);
+ while (p.good()) {
+ Token const & t = p.get_token();
+ if (t.asInput() == ",") {
+ options.push_back(option);
+ option.erase();
+ } else if (t.asInput() == "=") {
+ option += '=';
+ p.skip_spaces(true);
+ if (p.next_token().asInput() == "{")
+ option += '{' + p.getArg('{', '}') + '}';
+ } else if (t.cat() != catSpace)
+ option += t.asInput();
+ }
+
+ if (!option.empty())
+ options.push_back(option);
+
+ return options;
+}
+
+
+/*!
+ * Add package \p name with options \p options to used_packages.
+ * Remove options from \p options that we don't want to output.
+ */
+void add_package(string const & name, vector<string> & options)
+{
+ // every package inherits the global options
+ if (used_packages.find(name) == used_packages.end())
+ used_packages[name] = split_options(h_options);
+
+ vector<string> & v = used_packages[name];
+ v.insert(v.end(), options.begin(), options.end());
+ if (name == "jurabib") {
+ // Don't output the order argument (see the cite command
+ // handling code in text.C).
+ vector<string>::iterator end =
+ remove(options.begin(), options.end(), "natbiborder");
+ end = remove(options.begin(), end, "jurabiborder");
+ options.erase(end, options.end());
+ }
+}
+
+
+void handle_package(string const & name, string const & opts)
+{
+ vector<string> options = split_options(opts);
+ add_package(name, options);
+