- if (ch != '\\') // Not a macro definition, so must be NAME=VALUE
- {
- wxChar settingName[100];
- settingName[0] = ch;
- BibReadWord(istr, (settingName+1));
- BibEatWhiteSpace(istr);
- istr.get(ch);
- if (ch != '=')
- {
- OnError(_T("Expected = following name: malformed tex2rtf.ini file."));
- return false;
- }
- else
- {
- wxChar settingValue[200];
- BibEatWhiteSpace(istr);
- BibReadToEOL(istr, settingValue);
- RegisterSetting(settingName, settingValue);
- }
- }
- else
- {
- BibReadWord(istr, macroName);
- BibEatWhiteSpace(istr);
- istr.get(ch);
- if (ch != '[')
- {
- OnError(_T("Expected [ followed by number of arguments: malformed tex2rtf.ini file."));
- return false;
- }
- istr >> noArgs;
- istr.get(ch);
- if (ch != ']')
- {
- OnError(_T("Expected ] following number of arguments: malformed tex2rtf.ini file."));
- return false;
- }
- BibEatWhiteSpace(istr);
- istr.get(ch);
- if (ch != '{')
- {
- OnError(_T("Expected { followed by macro body: malformed tex2rtf.ini file."));
- return false;
- }
- CustomMacro *macro = new CustomMacro(macroName, noArgs, NULL);
- BibReadValue(istr, macroBody, false, false); // Don't ignore extra braces
- if (wxStrlen(macroBody) > 0)
- macro->macroBody = copystring(macroBody);
+ CustomMacro *macro = new CustomMacro(macroName.c_str(), noArgs, NULL);
+ wxString macroBody = BibReadValue(line, false, false); // Don't ignore extra braces
+ if (!macroBody.empty())
+ macro->macroBody = copystring(macroBody.c_str());
+
+ BibEatWhiteSpace(line);
+ CustomMacroList.Append(macroName, macro);
+ AddMacroDef(ltCUSTOM_MACRO, macroName.c_str(), noArgs);
+ }