The multiline matching resulted in a large performance regression due to
the indiscriminate use of the dotall (?s) flag. Change the regex
selection process to use only the flag when probably needed.
* reject 'i', 'I', 'm', 'M' and 'E' when --posix flag is set
* add test for issue 401
* formatting
* add a test for 'm' flag in test_posix_reject_flags
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update compiler.rs
* cargo fmt
* add a const variable with the err msg
* Update compiler.rs
* cargo fmt
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* feat: introduce e substituion for sed
When the s command is requested for sed, the e substitution flag enables execution of the result of substitution as a shell command. It matches the GNU sed behavior.
On src/sed/command.rs, add 'execute' field to 'Substitution' structure.
On src/sed/compiler.rs, handle 'e' in 'compile_subst_flags' and reject it if --posix or --sandbox flag is used in sed.
On src/sed/processor.rs, spawn /bin/sh with -c flag for a successful match and replace the pattern space with the command's standard output stream.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* chore: comply with rustfmt
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* chore: support for Windows command-line
Instead of calling bourne shell, define a new function: shell_command() with two definitions; conditionally compiling to UNIX-like and Windows. On UNIX-like, executes the bourne shell, whereas command prompt is executed on Windows.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* chore: check newline for Windows
Unix-like system only uses the newline character whereas Windows uses the carriage return as well as newline. Hence, when working on Windows, we need to truncate the last two characters.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* add: 'e' flag tests
Nine new tests have been introduced in regards to new 'e' substitution option. 'test_subst_e_flag_multiline_outuput' is conditionally compiled as printf command is not guaranteed to be present on all Windows systems.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* chore: fallback for shell_command
Executing a shell or a command prompt requires appropriate platforms. WASM does not currently support it.
Also fix a linting issue.
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* chore: linting cleanup
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
---------
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* feat: support zero-address file insertion
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
* Polish the handling of 0r
- Use common constant for error message.
- Simplify command check at compile and runtime.
- Separate runtime handling into a function.
---------
Signed-off-by: PranavRJoshi <pranavrjoshi1@gmail.com>
Co-authored-by: PranavRJoshi <pranavrjoshi1@gmail.com>