All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Adding metavariable types for the handling of string literals?
@ 2022-03-25 21:18 Markus Elfring
  2022-03-25 21:23 ` Julia Lawall
  2022-03-26 19:26 ` Markus Elfring
  0 siblings, 2 replies; 12+ messages in thread
From: Markus Elfring @ 2022-03-25 21:18 UTC (permalink / raw)
  To: cocci

Hello,

The metavariable type “constant” is supported by the semantic patch language.
Thus some data processing can be performed for literals.

I would appreciate the support for metavariable types which will match only
string literals.
https://en.cppreference.com/w/c/language/string_literal

I guess that such a kind of metavariable would include also the enclosing
quotation characters.
But if captured data should be passed for further processing to another
scripting language, it would occasionally be more helpful to omit the double
quotes there.
Additional programming interfaces can also help to handle data parts better,
can't they?

Would you like to work with another metavariable variant for this purpose?

How will the chances evolve to extend the Coccinelle software accordingly?

Regards,
Markus


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-25 21:18 [cocci] Adding metavariable types for the handling of string literals? Markus Elfring
@ 2022-03-25 21:23 ` Julia Lawall
  2022-03-25 21:33   ` Markus Elfring
                     ` (2 more replies)
  2022-03-26 19:26 ` Markus Elfring
  1 sibling, 3 replies; 12+ messages in thread
From: Julia Lawall @ 2022-03-25 21:23 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 935 bytes --]



On Fri, 25 Mar 2022, Markus Elfring wrote:

> Hello,
>
> The metavariable type “constant” is supported by the semantic patch language.
> Thus some data processing can be performed for literals.
>
> I would appreciate the support for metavariable types which will match only
> string literals.
> https://en.cppreference.com/w/c/language/string_literal

constant char[] x; ?

julia


>
> I guess that such a kind of metavariable would include also the enclosing
> quotation characters.
> But if captured data should be passed for further processing to another
> scripting language, it would occasionally be more helpful to omit the double
> quotes there.
> Additional programming interfaces can also help to handle data parts better,
> can't they?
>
> Would you like to work with another metavariable variant for this purpose?
>
> How will the chances evolve to extend the Coccinelle software accordingly?
>
> Regards,
> Markus
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-25 21:23 ` Julia Lawall
@ 2022-03-25 21:33   ` Markus Elfring
  2022-03-25 21:36     ` Julia Lawall
  2022-03-26  7:09   ` Markus Elfring
  2022-03-27 11:31   ` Markus Elfring
  2 siblings, 1 reply; 12+ messages in thread
From: Markus Elfring @ 2022-03-25 21:33 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

>> https://en.cppreference.com/w/c/language/string_literal
> constant char[] x; ?

Does this SmPL source code search approach include also the enclosing quotation characters?

How do you think about to improve the data processing for captured parts
(together with supported scripting languages)?

Should it be avoided to repeat any data format checks according to string literals
by SmPL script rules?

Regards,
Markus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-25 21:33   ` Markus Elfring
@ 2022-03-25 21:36     ` Julia Lawall
  2022-03-25 21:40       ` Markus Elfring
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2022-03-25 21:36 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci



On Fri, 25 Mar 2022, Markus Elfring wrote:

> >> https://en.cppreference.com/w/c/language/string_literal
> > constant char[] x; ?
>
> Does this SmPL source code search approach include also the enclosing quotation characters?

If you say

- x
+ x

the quotes will still be there.

julia


>
> How do you think about to improve the data processing for captured parts
> (together with supported scripting languages)?
>
> Should it be avoided to repeat any data format checks according to string literals
> by SmPL script rules?
>
> Regards,
> Markus
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-25 21:36     ` Julia Lawall
@ 2022-03-25 21:40       ` Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: Markus Elfring @ 2022-03-25 21:40 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci


> If you say
>
> - x
> + x
>
> the quotes will still be there.

Would you like to take situations better into account where repeated checks
for double quotation characters should be avoided?

Regards,
Markus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-25 21:23 ` Julia Lawall
  2022-03-25 21:33   ` Markus Elfring
@ 2022-03-26  7:09   ` Markus Elfring
  2022-03-27 11:31   ` Markus Elfring
  2 siblings, 0 replies; 12+ messages in thread
From: Markus Elfring @ 2022-03-26  7:09 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci


> constant char[] x; ?


I suggest to improve the software documentation for the safe application

of such metavariable variants.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/248a2742e76ceab620d67967a537fc5cb9282405/docs/manual/cocci_syntax.tex#L236
https://github.com/coccinelle/coccinelle/blob/ae337fce1512ff15aabc3ad5b6d2e537f97ab62a/docs/manual/cocci_syntax.tex#L236

How good does the data type “char[]” (an array or pointer?) fit to the hint “ctype”
in the SmPL manual?

Regards,
Markus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-25 21:18 [cocci] Adding metavariable types for the handling of string literals? Markus Elfring
  2022-03-25 21:23 ` Julia Lawall
@ 2022-03-26 19:26 ` Markus Elfring
  1 sibling, 0 replies; 12+ messages in thread
From: Markus Elfring @ 2022-03-26 19:26 UTC (permalink / raw)
  To: cocci

> Additional programming interfaces can also help to handle data parts better,
> can't they?


Will the chances eventually grow also for the clarification of previous feature requests?

Examples:
* 2016-01-06
  Support for string literals by another metavariable type
  https://github.com/coccinelle/coccinelle/issues/55

* 2020-08-21
  Object-orientation for metavariables
  https://github.com/coccinelle/coccinelle/issues/212

Regards,
Markus


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-25 21:23 ` Julia Lawall
  2022-03-25 21:33   ` Markus Elfring
  2022-03-26  7:09   ` Markus Elfring
@ 2022-03-27 11:31   ` Markus Elfring
  2022-03-27 11:53     ` Julia Lawall
  2 siblings, 1 reply; 12+ messages in thread
From: Markus Elfring @ 2022-03-27 11:31 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci


> constant char[] x; ?


How would you like to handle the following software development challenge
according to another SmPL script variant?


@display@
constant char[] text1, text2;
@@
*text1 text2

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci show_string_literal_usage3.cocci
…
minus: parse error:
  File "show_string_literal_usage3.cocci", line 4, column 7, charpos = 50
  around = 'text2',
  whole content = *text1 text2


Regards,
Markus

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-27 11:31   ` Markus Elfring
@ 2022-03-27 11:53     ` Julia Lawall
  2022-03-27 12:04       ` Markus Elfring
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2022-03-27 11:53 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]



On Sun, 27 Mar 2022, Markus Elfring wrote:

>
> > constant char[] x; ?
>
>
> How would you like to handle the following software development challenge
> according to another SmPL script variant?
>
>
> @display@
> constant char[] text1, text2;
> @@
> *text1 text2
>
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci show_string_literal_usage3.cocci

SmPL doesn't support that.  If you just match text1, it will match the
whole thing, and you can use python to extract the pieces.

julia

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-27 11:53     ` Julia Lawall
@ 2022-03-27 12:04       ` Markus Elfring
  2022-03-27 12:51         ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: Markus Elfring @ 2022-03-27 12:04 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

>> @display@
>> constant char[] text1, text2;
>> @@
>> *text1 text2
>>
>> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci show_string_literal_usage3.cocci
> SmPL doesn't support that.


I hope that the affected software can be improved further somehow.



> If you just match text1, it will match the whole thing,


I would occasionally like to match only a single string literal
so that subsequent string literals can be handled separately.



> and you can use python to extract the pieces.


I am still looking for ways to avoid undesirable side effects
in this data processing area.

Regards,
Markus


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-27 12:04       ` Markus Elfring
@ 2022-03-27 12:51         ` Julia Lawall
  2022-03-27 14:12           ` Markus Elfring
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2022-03-27 12:51 UTC (permalink / raw)
  To: Markus Elfring; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 797 bytes --]



On Sun, 27 Mar 2022, Markus Elfring wrote:

> >> @display@
> >> constant char[] text1, text2;
> >> @@
> >> *text1 text2
> >>
> >> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci show_string_literal_usage3.cocci
> > SmPL doesn't support that.
>
>
> I hope that the affected software can be improved further somehow.
>
>
>
> > If you just match text1, it will match the whole thing,
>
>
> I would occasionally like to match only a single string literal
> so that subsequent string literals can be handled separately.
>
>
>
> > and you can use python to extract the pieces.
>
>
> I am still looking for ways to avoid undesirable side effects
> in this data processing area.

OK, but as compard to situations where there is no solution at all, this
is not a priority.

julia

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [cocci] Adding metavariable types for the handling of string literals?
  2022-03-27 12:51         ` Julia Lawall
@ 2022-03-27 14:12           ` Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: Markus Elfring @ 2022-03-27 14:12 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci

>> I am still looking for ways to avoid undesirable side effects
>> in this data processing area.
> OK, but as compard to situations where there is no solution at all,


It is obvious that some open issues are waiting on corresponding solutions.



> this is not a priority.


I am curious how the affected software components will evolve further.

Regards,
Markus


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-27 14:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 21:18 [cocci] Adding metavariable types for the handling of string literals? Markus Elfring
2022-03-25 21:23 ` Julia Lawall
2022-03-25 21:33   ` Markus Elfring
2022-03-25 21:36     ` Julia Lawall
2022-03-25 21:40       ` Markus Elfring
2022-03-26  7:09   ` Markus Elfring
2022-03-27 11:31   ` Markus Elfring
2022-03-27 11:53     ` Julia Lawall
2022-03-27 12:04       ` Markus Elfring
2022-03-27 12:51         ` Julia Lawall
2022-03-27 14:12           ` Markus Elfring
2022-03-26 19:26 ` Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.