* [Cocci] [PATCH] parsing_c: Add space for tokens after *
@ 2020-01-16 5:18 Jaskaran Singh
2020-01-16 9:09 ` Julia Lawall
2020-01-16 10:44 ` [Cocci] [PATCH 0/2] cocci: " Jaskaran Singh
0 siblings, 2 replies; 11+ messages in thread
From: Jaskaran Singh @ 2020-01-16 5:18 UTC (permalink / raw)
To: cocci; +Cc: linux-kernel-mentees
In certain cases, there is no space added after the Pointer type.
Examples of such cases are * const, * __attr and * const *.
In the Pointer case of pp_type_with_ident_rest and pp_type_left, if
the * is followed by anything within the type, add a space after the
printing.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
parsing_c/pretty_print_c.ml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/parsing_c/pretty_print_c.ml b/parsing_c/pretty_print_c.ml
index ccf8214d..a2e35588 100644
--- a/parsing_c/pretty_print_c.ml
+++ b/parsing_c/pretty_print_c.ml
@@ -806,6 +806,8 @@ and pp_string_format (e,ii) =
(* bug: pp_type_with_ident_rest None t; print_ident ident *)
pr_elem i;
iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
+ if iiqu <> [] || get_comments_after i <> []
+ then pr_space();
pp_type_with_ident_rest ident t attrs Ast_c.noattr;
(* ugly special case ... todo? maybe sufficient in practice *)
@@ -885,6 +887,8 @@ and pp_string_format (e,ii) =
| (Pointer t, [i]) ->
pr_elem i;
iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
+ if iiqu <> [] || get_comments_after i <> []
+ then pr_space();
pp_type_left t
| (Array (eopt, t), [i1;i2]) -> pp_type_left t
--
2.21.1
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Cocci] [PATCH] parsing_c: Add space for tokens after *
2020-01-16 5:18 [Cocci] [PATCH] parsing_c: Add space for tokens after * Jaskaran Singh
@ 2020-01-16 9:09 ` Julia Lawall
2020-01-16 10:44 ` [Cocci] [PATCH 0/2] cocci: " Jaskaran Singh
1 sibling, 0 replies; 11+ messages in thread
From: Julia Lawall @ 2020-01-16 9:09 UTC (permalink / raw)
To: Jaskaran Singh; +Cc: linux-kernel-mentees, cocci
On Thu, 16 Jan 2020, Jaskaran Singh wrote:
> In certain cases, there is no space added after the Pointer type.
> Examples of such cases are * const, * __attr and * const *.
>
> In the Pointer case of pp_type_with_ident_rest and pp_type_left, if
> the * is followed by anything within the type, add a space after the
> printing.
Thank for the patch. Could you add in a test case as well?
thanks,
julia
>
> Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
> ---
> parsing_c/pretty_print_c.ml | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/parsing_c/pretty_print_c.ml b/parsing_c/pretty_print_c.ml
> index ccf8214d..a2e35588 100644
> --- a/parsing_c/pretty_print_c.ml
> +++ b/parsing_c/pretty_print_c.ml
> @@ -806,6 +806,8 @@ and pp_string_format (e,ii) =
> (* bug: pp_type_with_ident_rest None t; print_ident ident *)
> pr_elem i;
> iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
> + if iiqu <> [] || get_comments_after i <> []
> + then pr_space();
> pp_type_with_ident_rest ident t attrs Ast_c.noattr;
>
> (* ugly special case ... todo? maybe sufficient in practice *)
> @@ -885,6 +887,8 @@ and pp_string_format (e,ii) =
> | (Pointer t, [i]) ->
> pr_elem i;
> iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
> + if iiqu <> [] || get_comments_after i <> []
> + then pr_space();
> pp_type_left t
>
> | (Array (eopt, t), [i1;i2]) -> pp_type_left t
> --
> 2.21.1
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Cocci] [PATCH 0/2] cocci: Add space for tokens after *
2020-01-16 5:18 [Cocci] [PATCH] parsing_c: Add space for tokens after * Jaskaran Singh
2020-01-16 9:09 ` Julia Lawall
@ 2020-01-16 10:44 ` Jaskaran Singh
2020-01-16 10:44 ` [Cocci] [PATCH 1/2] parsing_c: " Jaskaran Singh
2020-01-16 10:44 ` [Cocci] [PATCH 2/2] tests: Add test case for * const * Jaskaran Singh
1 sibling, 2 replies; 11+ messages in thread
From: Jaskaran Singh @ 2020-01-16 10:44 UTC (permalink / raw)
To: cocci; +Cc: linux-kernel-mentees
The Pointer cases in pp_type_with_ident_rest and pp_type_left of
pretty_print_c.ml sometimes do not add a necessary space, if there
exist tokens after the *.
Create changes necessary for adding this space and add a test case
for * const *.
parsing_c/pretty_print_c.ml | 4 ++++
tests/ptrconstptr.c | 3 +++
tests/ptrconstptr.cocci | 7 +++++++
tests/ptrconstptr.res | 3 +++
4 files changed, 17 insertions(+)
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Cocci] [PATCH 1/2] parsing_c: Add space for tokens after *
2020-01-16 10:44 ` [Cocci] [PATCH 0/2] cocci: " Jaskaran Singh
@ 2020-01-16 10:44 ` Jaskaran Singh
2020-01-16 10:44 ` [Cocci] [PATCH 2/2] tests: Add test case for * const * Jaskaran Singh
1 sibling, 0 replies; 11+ messages in thread
From: Jaskaran Singh @ 2020-01-16 10:44 UTC (permalink / raw)
To: cocci; +Cc: linux-kernel-mentees
In certain cases, there is no space added after the Pointer type.
Examples of such cases are * const, * __attr and * const *.
In the Pointer case of pp_type_with_ident_rest and pp_type_left, if
the * is followed by anything within the type, add a space after the
printing.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
parsing_c/pretty_print_c.ml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/parsing_c/pretty_print_c.ml b/parsing_c/pretty_print_c.ml
index ccf8214d..a2e35588 100644
--- a/parsing_c/pretty_print_c.ml
+++ b/parsing_c/pretty_print_c.ml
@@ -806,6 +806,8 @@ and pp_string_format (e,ii) =
(* bug: pp_type_with_ident_rest None t; print_ident ident *)
pr_elem i;
iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
+ if iiqu <> [] || get_comments_after i <> []
+ then pr_space();
pp_type_with_ident_rest ident t attrs Ast_c.noattr;
(* ugly special case ... todo? maybe sufficient in practice *)
@@ -885,6 +887,8 @@ and pp_string_format (e,ii) =
| (Pointer t, [i]) ->
pr_elem i;
iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
+ if iiqu <> [] || get_comments_after i <> []
+ then pr_space();
pp_type_left t
| (Array (eopt, t), [i1;i2]) -> pp_type_left t
--
2.21.1
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Cocci] [PATCH 2/2] tests: Add test case for * const *
2020-01-16 10:44 ` [Cocci] [PATCH 0/2] cocci: " Jaskaran Singh
2020-01-16 10:44 ` [Cocci] [PATCH 1/2] parsing_c: " Jaskaran Singh
@ 2020-01-16 10:44 ` Jaskaran Singh
2020-01-16 15:36 ` Julia Lawall
1 sibling, 1 reply; 11+ messages in thread
From: Jaskaran Singh @ 2020-01-16 10:44 UTC (permalink / raw)
To: cocci; +Cc: linux-kernel-mentees
Previously, a space would not be added after the * const. Add
a test case for testing spacing with use of the type.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
tests/ptrconstptr.c | 3 +++
tests/ptrconstptr.cocci | 7 +++++++
tests/ptrconstptr.res | 3 +++
3 files changed, 13 insertions(+)
create mode 100644 tests/ptrconstptr.c
create mode 100644 tests/ptrconstptr.cocci
create mode 100644 tests/ptrconstptr.res
diff --git a/tests/ptrconstptr.c b/tests/ptrconstptr.c
new file mode 100644
index 00000000..a2a3cf71
--- /dev/null
+++ b/tests/ptrconstptr.c
@@ -0,0 +1,3 @@
+void main() {
+ const char * const * x;
+}
diff --git a/tests/ptrconstptr.cocci b/tests/ptrconstptr.cocci
new file mode 100644
index 00000000..030bc024
--- /dev/null
+++ b/tests/ptrconstptr.cocci
@@ -0,0 +1,7 @@
+@@
+type t;
+@@
+void main() {
+- t x;
++ t y;
+}
diff --git a/tests/ptrconstptr.res b/tests/ptrconstptr.res
new file mode 100644
index 00000000..f5b2210c
--- /dev/null
+++ b/tests/ptrconstptr.res
@@ -0,0 +1,3 @@
+void main() {
+ const char *const *y;
+}
--
2.21.1
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Cocci] [PATCH 2/2] tests: Add test case for * const *
2020-01-16 10:44 ` [Cocci] [PATCH 2/2] tests: Add test case for * const * Jaskaran Singh
@ 2020-01-16 15:36 ` Julia Lawall
0 siblings, 0 replies; 11+ messages in thread
From: Julia Lawall @ 2020-01-16 15:36 UTC (permalink / raw)
To: Jaskaran Singh; +Cc: linux-kernel-mentees, cocci
On Thu, 16 Jan 2020, Jaskaran Singh wrote:
> Previously, a space would not be added after the * const. Add
> a test case for testing spacing with use of the type.
>
> Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
Applied, thanks.
julia
> ---
> tests/ptrconstptr.c | 3 +++
> tests/ptrconstptr.cocci | 7 +++++++
> tests/ptrconstptr.res | 3 +++
> 3 files changed, 13 insertions(+)
> create mode 100644 tests/ptrconstptr.c
> create mode 100644 tests/ptrconstptr.cocci
> create mode 100644 tests/ptrconstptr.res
>
> diff --git a/tests/ptrconstptr.c b/tests/ptrconstptr.c
> new file mode 100644
> index 00000000..a2a3cf71
> --- /dev/null
> +++ b/tests/ptrconstptr.c
> @@ -0,0 +1,3 @@
> +void main() {
> + const char * const * x;
> +}
> diff --git a/tests/ptrconstptr.cocci b/tests/ptrconstptr.cocci
> new file mode 100644
> index 00000000..030bc024
> --- /dev/null
> +++ b/tests/ptrconstptr.cocci
> @@ -0,0 +1,7 @@
> +@@
> +type t;
> +@@
> +void main() {
> +- t x;
> ++ t y;
> +}
> diff --git a/tests/ptrconstptr.res b/tests/ptrconstptr.res
> new file mode 100644
> index 00000000..f5b2210c
> --- /dev/null
> +++ b/tests/ptrconstptr.res
> @@ -0,0 +1,3 @@
> +void main() {
> + const char *const *y;
> +}
> --
> 2.21.1
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cocci] [PATCH] parsing_c: Add space for tokens after *
2020-01-16 11:31 ` Jaskaran Singh
@ 2020-01-16 11:36 ` Jaskaran Singh
0 siblings, 0 replies; 11+ messages in thread
From: Jaskaran Singh @ 2020-01-16 11:36 UTC (permalink / raw)
To: Jaskaran Singh; +Cc: linux-kernel-mentees, Markus Elfring, cocci
On Thu, 2020-01-16 at 17:01 +0530, Jaskaran Singh wrote:
> On Thu, 2020-01-16 at 11:59 +0100, Julia Lawall wrote:
> > On Thu, 16 Jan 2020, Jaskaran Singh wrote:
> >
> > > On Thu, 2020-01-16 at 11:40 +0100, Markus Elfring wrote:
> > > > > In certain cases, there is no space added after the Pointer
> > > > > type.
> > > >
> > > > Will such a pretty-printing detail matter also for the
> > > > clarification
> > > > of
> > > > a topic like “Make change influence configurable for coding
> > > > style
> > > > rules”?
> > > > https://github.com/coccinelle/coccinelle/issues/37
> > > >
> > >
> > > Not sure what you mean. If you mean to say that the result should
> > > conform to the Linux coding style (i.e. the result should be
> > > "const
> > > char * const * y" with spaces et al intact), that seems like
> > > something
> > > for a different patch, right? Whether you want Coccinelle to
> > > conform to
> > > Linux coding style or not, the space should be added either way.
> >
> > The option --smpl-spacing should address this issue, by preservign
> > the
> > spacing illustrated in the semantic patch. I don't know if it does
> > that
> > in this case.
> >
>
> Hm, can't say that it does. Here's what I get with --smpl-spacing on
> case https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06696.html
>
Whoops, incorrect link
https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06695.html
Cheers,
Jaskaran.
> before:
>
> void main() {
> - const char * const * x;
> + const char *const*y ;
> }
>
> after:
>
> void main() {
> - const char * const * x;
> + const char *const *y ;
> }
>
> Cheers,
> Jaskaran.
>
> > julia
> >
> > > Cheers,
> > > Jaskaran.
> > >
> > > > 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cocci] [PATCH] parsing_c: Add space for tokens after *
2020-01-16 10:59 ` Julia Lawall
@ 2020-01-16 11:31 ` Jaskaran Singh
2020-01-16 11:36 ` Jaskaran Singh
0 siblings, 1 reply; 11+ messages in thread
From: Jaskaran Singh @ 2020-01-16 11:31 UTC (permalink / raw)
To: Julia Lawall; +Cc: linux-kernel-mentees, Markus Elfring, cocci
On Thu, 2020-01-16 at 11:59 +0100, Julia Lawall wrote:
>
> On Thu, 16 Jan 2020, Jaskaran Singh wrote:
>
> > On Thu, 2020-01-16 at 11:40 +0100, Markus Elfring wrote:
> > > > In certain cases, there is no space added after the Pointer
> > > > type.
> > >
> > > Will such a pretty-printing detail matter also for the
> > > clarification
> > > of
> > > a topic like “Make change influence configurable for coding style
> > > rules”?
> > > https://github.com/coccinelle/coccinelle/issues/37
> > >
> >
> > Not sure what you mean. If you mean to say that the result should
> > conform to the Linux coding style (i.e. the result should be "const
> > char * const * y" with spaces et al intact), that seems like
> > something
> > for a different patch, right? Whether you want Coccinelle to
> > conform to
> > Linux coding style or not, the space should be added either way.
>
> The option --smpl-spacing should address this issue, by preservign
> the
> spacing illustrated in the semantic patch. I don't know if it does
> that
> in this case.
>
Hm, can't say that it does. Here's what I get with --smpl-spacing on
case https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06696.html
before:
void main() {
- const char * const * x;
+ const char *const*y ;
}
after:
void main() {
- const char * const * x;
+ const char *const *y ;
}
Cheers,
Jaskaran.
> julia
>
> > Cheers,
> > Jaskaran.
> >
> > > 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cocci] [PATCH] parsing_c: Add space for tokens after *
2020-01-16 10:56 ` Jaskaran Singh
@ 2020-01-16 10:59 ` Julia Lawall
2020-01-16 11:31 ` Jaskaran Singh
0 siblings, 1 reply; 11+ messages in thread
From: Julia Lawall @ 2020-01-16 10:59 UTC (permalink / raw)
To: Jaskaran Singh; +Cc: linux-kernel-mentees, Markus Elfring, cocci
[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]
On Thu, 16 Jan 2020, Jaskaran Singh wrote:
> On Thu, 2020-01-16 at 11:40 +0100, Markus Elfring wrote:
> > > In certain cases, there is no space added after the Pointer type.
> >
> > Will such a pretty-printing detail matter also for the clarification
> > of
> > a topic like “Make change influence configurable for coding style
> > rules”?
> > https://github.com/coccinelle/coccinelle/issues/37
> >
>
> Not sure what you mean. If you mean to say that the result should
> conform to the Linux coding style (i.e. the result should be "const
> char * const * y" with spaces et al intact), that seems like something
> for a different patch, right? Whether you want Coccinelle to conform to
> Linux coding style or not, the space should be added either way.
The option --smpl-spacing should address this issue, by preservign the
spacing illustrated in the semantic patch. I don't know if it does that
in this case.
julia
>
> Cheers,
> Jaskaran.
>
> > Regards,
> > Markus
>
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
[-- Attachment #2: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cocci] [PATCH] parsing_c: Add space for tokens after *
2020-01-16 10:40 [Cocci] [PATCH] parsing_c: Add space for tokens after * Markus Elfring
@ 2020-01-16 10:56 ` Jaskaran Singh
2020-01-16 10:59 ` Julia Lawall
0 siblings, 1 reply; 11+ messages in thread
From: Jaskaran Singh @ 2020-01-16 10:56 UTC (permalink / raw)
To: Markus Elfring; +Cc: linux-kernel-mentees, cocci
On Thu, 2020-01-16 at 11:40 +0100, Markus Elfring wrote:
> > In certain cases, there is no space added after the Pointer type.
>
> Will such a pretty-printing detail matter also for the clarification
> of
> a topic like “Make change influence configurable for coding style
> rules”?
> https://github.com/coccinelle/coccinelle/issues/37
>
Not sure what you mean. If you mean to say that the result should
conform to the Linux coding style (i.e. the result should be "const
char * const * y" with spaces et al intact), that seems like something
for a different patch, right? Whether you want Coccinelle to conform to
Linux coding style or not, the space should be added either way.
Cheers,
Jaskaran.
> Regards,
> Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Cocci] [PATCH] parsing_c: Add space for tokens after *
@ 2020-01-16 10:40 Markus Elfring
2020-01-16 10:56 ` Jaskaran Singh
0 siblings, 1 reply; 11+ messages in thread
From: Markus Elfring @ 2020-01-16 10:40 UTC (permalink / raw)
To: Jaskaran Singh, cocci; +Cc: linux-kernel-mentees
> In certain cases, there is no space added after the Pointer type.
Will such a pretty-printing detail matter also for the clarification of
a topic like “Make change influence configurable for coding style rules”?
https://github.com/coccinelle/coccinelle/issues/37
Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-01-16 15:36 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 5:18 [Cocci] [PATCH] parsing_c: Add space for tokens after * Jaskaran Singh
2020-01-16 9:09 ` Julia Lawall
2020-01-16 10:44 ` [Cocci] [PATCH 0/2] cocci: " Jaskaran Singh
2020-01-16 10:44 ` [Cocci] [PATCH 1/2] parsing_c: " Jaskaran Singh
2020-01-16 10:44 ` [Cocci] [PATCH 2/2] tests: Add test case for * const * Jaskaran Singh
2020-01-16 15:36 ` Julia Lawall
2020-01-16 10:40 [Cocci] [PATCH] parsing_c: Add space for tokens after * Markus Elfring
2020-01-16 10:56 ` Jaskaran Singh
2020-01-16 10:59 ` Julia Lawall
2020-01-16 11:31 ` Jaskaran Singh
2020-01-16 11:36 ` Jaskaran Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).