On Tue, May 05, 2015 at 06:25:29PM +0200, Silvan Jegen wrote: > Replacing the first '/' allows the 's' command name to be correctly > identified even though it is part of its own argument.
Special casing '/' seems wrong, an arbitrary delimiter can be used :s,foo,bar is perfectly valid. The end of the command name should probably be detected by isalpha(3) or similar. Hence instead of doing a strdup(...) we should probably do a malloc(strlen(...)+2) in combination with a strcpy/memcpy and then memmove(...) the arguments one position to the right and NUL-terminate the name. > This is hacky because afterwards we will add the '/' back in before > calling the 'sed' program. Relying on the fact that cmd_set was called with (i.e. that argv[0] was set to) ':s/' is wrong, it could also be ':substitute/'. With the strategy outlined above argv[1] would contain the argument (= search pattern) which could be prefixed by 's'. Furthermore if the pattern doesn't contain the delimiter at the end, it should be appended. Please send an updated patch if you think this makes sense ... -- Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0