Remove support for the "command" encoder
The "command" encoder was mostly intended for use in `%rename` - most uses can be achieved using the "regex" encoder, so we recommend using that instead. The "command" encoder suffers from a number of issues - as the documentation for it admitted, "[it] is extremely slow compared to all the other [encoders] as it involves spawning a separate process and using it for many declarations is not recommended" and that it "should generally be avoided because of performance considerations". But it's also not portable. The design assumes that `/bin/sh` supports `<<<` but that's a bash-specific feature so it doesn't work on platforms where `/bin/sh` is not bash - it fails on Debian, Ubuntu and probably some other Linux distros, plus most non-Linux platforms. Microsoft Windows doesn't even have a /bin/sh as standard. Finally, no escaping of the passed string is done, so it has potential security issues (though at least with %rename the input is limited to valid C/C++ symbol names). Fixes #1806
This commit is contained in:
parent
d47970e2fd
commit
467c530e65
6 changed files with 36 additions and 56 deletions
6
Examples/test-suite/errors/swig_command_encoder.i
Normal file
6
Examples/test-suite/errors/swig_command_encoder.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%module xxx
|
||||
|
||||
// This feature was removed in SWIG 4.1.0 so check it gives an error.
|
||||
%define SedCmd "%(command:sed -e 's/\([a-z]\)/\U\\1/' -e 's/\(_\)\([a-z]\)/\U\\2/g' <<<)s" %enddef
|
||||
%rename(SedCmd) "";
|
||||
int x;
|
||||
1
Examples/test-suite/errors/swig_command_encoder.stderr
Normal file
1
Examples/test-suite/errors/swig_command_encoder.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
SWIG:1: Error: Command encoder no longer supported - use regex encoder instead.
|
||||
|
|
@ -20,18 +20,14 @@
|
|||
}
|
||||
|
||||
|
||||
%define SedCmd "%(command:sed -e 's/\([a-z]\)/\U\\1/' -e 's/\(_\)\([a-z]\)/\U\\2/g' <<<)s" %enddef
|
||||
|
||||
%rename(CamelCase1) camel_case_1;
|
||||
%rename(SedCmd) camel_case_2;
|
||||
%rename("%(camelcase)s") camel_case_2;
|
||||
%rename("%(ctitle)s") camel_case_3;
|
||||
|
||||
|
||||
%rename("%(utitle)s") CamelCase_5;
|
||||
|
||||
%define awk_cmd "%(command:awk '/^i/{print toupper($1)}' <<<)s" %enddef
|
||||
|
||||
%rename(awk_cmd) "";
|
||||
%rename("%(regex:/\\(.*i.*\\)/\\U\\1/)s") "";
|
||||
|
||||
%rename("%(title)s",regexmatch$parentNode$type="enum .*") "";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue