Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
> Perhaps, but it will unnecessarily raise the running time of your semantic > patch. We come along different expectations again for the possible application of the construct “<+... … ...+>” for the semantic patch language. Should the concrete run time characteristics be clarified any more for current update candidates in known source files? Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
On Tue, 4 Feb 2020, Markus Elfring wrote: > >> @replacement@ > >> constant c; > >> identifier text; > >> statement is, es; > >> @@ > >> <+... > > > > What is thhe point of the outer <+... ...+>? > > I would like to stress the possibility that source code adjustments > can be performed multiple times. > https://github.com/coccinelle/coccinelle/blob/a549b9f0a20e14fe9c36f45990b40dc5708ef8f2/docs/manual/cocci_syntax.tex#L696 Perhaps, but it will unnecessarily raise the running time of your semantic patch. julia ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
>> @replacement@ >> constant c; >> identifier text; >> statement is, es; >> @@ >> <+... > > What is thhe point of the outer <+... ...+>? I would like to stress the possibility that source code adjustments can be performed multiple times. https://github.com/coccinelle/coccinelle/blob/a549b9f0a20e14fe9c36f45990b40dc5708ef8f2/docs/manual/cocci_syntax.tex#L696 Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
On Tue, 4 Feb 2020, Markus Elfring wrote: > > The strcmp output has to be compared to zero strcmp(src_name, > > "equalizer_input_level") == 0. > > Would you like to let the following script for the semantic patch language > perform any changes in your source files automatically? > > @replacement@ > constant c; > identifier text; > statement is, es; > @@ > <+... What is thhe point of the outer <+... ...+>? julia > if ( > +!std::strcmp( > text > +, > -== std::string( > c > ) > ) > is > else > es > ...+> > > > Regards, > Markus > ___ > Cocci mailing list > Cocci@systeme.lip6.fr > https://systeme.lip6.fr/mailman/listinfo/cocci > ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
> The strcmp output has to be compared to zero strcmp(src_name, > "equalizer_input_level") == 0. Would you like to let the following script for the semantic patch language perform any changes in your source files automatically? @replacement@ constant c; identifier text; statement is, es; @@ <+... if ( +!std::strcmp( text +, -== std::string( c ) ) is else es ...+> Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
>> @display@ >> expression X; >> identifier I; >> @@ >> *auto I = X(...); … > I think it expects a type as well. I don't know if that is a reasonable > assumption in C or in C++. How do you think about to interpret such a variable definition in the way that the omission of an other data type specification would result into the usage of “int”? Under which circumstances will the handling of “placeholder type specifiers” become relevant finally? https://en.cppreference.com/w/cpp/language/auto Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
> If you are showing a patch, then the first column is empty, > except for the - and + characters. You are right. I am sorry for my misinterpretation of the “indentation” at this place. Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
On Tue, 4 Feb 2020, Markus Elfring wrote: > >> Do you distinguish between the storage class specifier > >> and other uses of such a key word? > >> https://en.cppreference.com/w/cpp/language/auto > > > > Sorry. I know nothing about C++. > > I guess that you know something also for this programming language > according to the program option “--c++”. > https://github.com/coccinelle/coccinelle/blob/0cece3639048dc7e81c4b2cc8f2a6f7a57fd546b/docs/spatch.1.in#L434 > https://github.com/coccinelle/coccinelle/issues/1 > > > > Auto seems to be supported > > I am looking for further evolution around this software area. > > > > - I see it in both the C parser and the SmPL parser. > > How would we like to handle corresponding development challenges? > > @display@ > expression X; > identifier I; > @@ > *auto I = X(...); > > > elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci > show_variable_definition_with_auto1.cocci > init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h > minus: parse error: > File "show_variable_definition_with_auto1.cocci", line 5, column 6, charpos > = 47 > around = 'I', > whole content = *auto I = X(...); > > > Can such a source code search approach make sense also according to > the rules of the C programming language? I think it expects a type as well. I don't know if that is a reasonable assumption in C or in C++. julia___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
>> Do you distinguish between the storage class specifier >> and other uses of such a key word? >> https://en.cppreference.com/w/cpp/language/auto > > Sorry. I know nothing about C++. I guess that you know something also for this programming language according to the program option “--c++”. https://github.com/coccinelle/coccinelle/blob/0cece3639048dc7e81c4b2cc8f2a6f7a57fd546b/docs/spatch.1.in#L434 https://github.com/coccinelle/coccinelle/issues/1 > Auto seems to be supported I am looking for further evolution around this software area. > - I see it in both the C parser and the SmPL parser. How would we like to handle corresponding development challenges? @display@ expression X; identifier I; @@ *auto I = X(...); elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci show_variable_definition_with_auto1.cocci init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h minus: parse error: File "show_variable_definition_with_auto1.cocci", line 5, column 6, charpos = 47 around = 'I', whole content = *auto I = X(...); Can such a source code search approach make sense also according to the rules of the C programming language? Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
On Mon, 3 Feb 2020, Markus Elfring wrote: > > Where is the space that yoyu are concerned about? > > … > @@ -1,7 +1,7 @@ > void on_message_element … > ↑ > > How was this character added at the first column in this line > of my software test approach? I don't understand. If you are showing a patch, then the first column is empty, except for the - and + characters. julia > > > >> > >> https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6 > > > > I guess it would be fine if you put > > > > typedef auto; > > > > among the metavariables? > > Do you distinguish between the storage class specifier > and other uses of such a key word? > https://en.cppreference.com/w/cpp/language/auto > > Regards, > Markus >___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
On Mon, 3 Feb 2020, Markus Elfring wrote: > > Where is the space that yoyu are concerned about? > > … > @@ -1,7 +1,7 @@ > void on_message_element … > ↑ > > How was this character added at the first column in this line > of my software test approach? > > > >> > >> https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6 > > > > I guess it would be fine if you put > > > > typedef auto; > > > > among the metavariables? > > Do you distinguish between the storage class specifier > and other uses of such a key word? > https://en.cppreference.com/w/cpp/language/auto Sorry. I know nothing about C++. Auto seems to be supported - I see it in both the C parser and the SmPL parser. julia___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
> Where is the space that yoyu are concerned about? … @@ -1,7 +1,7 @@ void on_message_element … ↑ How was this character added at the first column in this line of my software test approach? >> >> https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6 > > I guess it would be fine if you put > > typedef auto; > > among the metavariables? Do you distinguish between the storage class specifier and other uses of such a key word? https://en.cppreference.com/w/cpp/language/auto Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
Hi! I did not have the time to look at this file. Lots of places comparing two chars indeed. The strcmp output has to be compared to zero strcmp(src_name, "equalizer_input_level") == 0. This is the result returned when the arguments are equal. Best Regards, Wellington. On Mon, Feb 3, 2020 at 5:45 PM Markus Elfring wrote: > 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 > -- Prof.° Wellington Wallace Miguel Melo CEFET/RJ Uned Nova Iguaçu ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
On Mon, 3 Feb 2020, Markus Elfring wrote: > 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. Where is the space that yoyu are concerned about? > > 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 I guess it would be fine if you put typedef auto; among the metavariables? julia___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
[Cocci] Replacing a std::string check by strcmp() with SmPL
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 Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci