Hello,
I have tried the following small script variant out for
the semantic patch language.
@replacement@
constant c;
identifier text;
expression x;
statement is, es;
@@
char* text = x(...);
if (
+ strcmp(
text
+ ,
- == std::string(
c
)
)
is
else
es
A corresponding transformation result from the software
“Coccinelle 1.0.8-00029-ga549b9f0” looks promising (in principle).
elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --c++
replace_std_string_check_by_strcmp2.cocci
PulseEffects-source_output_effects-excerpt2.cpp
…
@@ -1,7 +1,7 @@
void on_message_element(const GstBus* gst_bus, GstMessage* message,
SourceOutputEffects* soe) {
char* src_name = GST_OBJECT_NAME(message->src);
- if (src_name == std::string("equalizer_input_level")) {
+ if (strcmp(src_name, "equalizer_input_level")) {
soe->equalizer_input_level.emit(soe->get_peak(message));
// Deleted part
} else if (src_name == std::string("webrtc_output_level")) {
1. But I wonder about an additional space character at the beginning
of the shown function in the generated patch.
2. Will it become possible to achieve a similar change
if the specification “auto” would be used instead of
the data type “char*”?
https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci