Angus Leeming wrote:
> When inputting converters in the preferences dialog (xforms) the little
> helper message says:
>
> "The conversion command. $$i is the input file name, "
> "$$b is the file name without its extension and $$o is "
> "the name of the output file. $$s can be used as path to "
> "LyX's own collection of conversion scripts."
>
> The problem is that this is untrue. $$s is currently unused.
Ok, I coded up my preferred option. This cleans up LibScriptSearch
internally to make it search for "$$s/" and replace this with the path to
the script. If the script is not found, the "$$s/" string is removed.
It means that converter definitions like this
\converter "fig" "pdftex" "sh $$s/fig2pdftex.sh $$i $$o" ""
work perfectly.
Ok to apply?
--
Angus
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.172
diff -u -p -r1.172 ChangeLog
--- src/support/ChangeLog 22 May 2003 10:47:30 -0000 1.172
+++ src/support/ChangeLog 30 May 2003 16:47:45 -0000
@@ -1,3 +1,9 @@
+2003-05-30 Angus Leeming <[EMAIL PROTECTED]>
+
+ * filetools.C (LibScriptSearch): make it search for "$$s/" and replace
+ this with the path to the script. If the script is not found, the "$$s/"
+ string is removed.
+
2003-05-22 Lars Gullik Bjønnes <[EMAIL PROTECTED]>
* lstrings.[Ch] (prefixIs,suffixIs,subst): remove variants taking
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.151
diff -u -p -r1.151 filetools.C
--- src/support/filetools.C 13 May 2003 14:36:24 -0000 1.151
+++ src/support/filetools.C 30 May 2003 16:47:46 -0000
@@ -333,18 +333,35 @@ i18nLibFileSearch(string const & dir, st
}
-string const LibScriptSearch(string const & command)
+string const LibScriptSearch(string const & command_in)
{
- string script;
- string args = command;
- args = split(args, script, ' ');
- script = LibFileSearch("scripts", script);
- if (script.empty())
+ string const token_scriptpath("$$s/");
+
+ string command = command_in;
+ // Find the starting position of "$$s/"
+ string::size_type const pos1 = command.find(token_scriptpath);
+ if (pos1 == string::npos)
return command;
- else if (args.empty())
- return script;
- else
- return script + ' ' + args;
+ // Find the end of the "$$s/some_script" word within command
+ string::size_type const start_script = pos1 + 4;
+ string::size_type const pos2 = command.find(' ', start_script);
+ string::size_type const size_script = pos2 == string::npos?
+ (command.size() - start_script) : pos2 - start_script;
+
+ // Does this script file exist?
+ string const script =
+ LibFileSearch("scripts", command.substr(start_script, size_script));
+
+ if (script.empty()) {
+ // Replace "$$s/" with ""
+ command.erase(pos1, 4);
+ } else {
+ // Replace "$$s/some_script" with "$LYX_SCRIPT_PATH/some_script"
+ string::size_type const size_replace = size_script + 4;
+ command.replace(pos1, size_replace, script);
+ }
+
+ return command;
}