Re: [PATCH wayland] scanner: Fix oddities in copyright printing

2016-02-04 Thread Bryce Harrington
On Tue, Feb 02, 2016 at 01:23:01PM -0800, Jon A. Cruz wrote:
> On 02/02/2016 12:56 PM, Derek Foreman wrote:
> >Some copyright strings could result in broken generated header files with
> >unmatched */
> >
> >This change:
> >Runs the loop long enough so the copyright[i] == 0 test can actually
> >happen. (if there was no \n no copyright text was printed, */ still was)
> >
> >Prints the opening /* even if there was whitespace at the start of
> >the very first line.
> >
> >Only emits a */ if a /* was printed.
> >
> >Signed-off-by: Derek Foreman 
> 
> Looks good to me:
> Reviewed-by: Jon A. Cruz 
 
Thanks, pushed:
To ssh://git.freedesktop.org/git/wayland/wayland
   816a0ae..369b646  master -> master



> >---
> >  src/scanner.c | 16 ++--
> >  1 file changed, 10 insertions(+), 6 deletions(-)
> >
> >diff --git a/src/scanner.c b/src/scanner.c
> >index dda5473..d3e2328 100644
> >--- a/src/scanner.c
> >+++ b/src/scanner.c
> >@@ -1284,25 +1284,29 @@ emit_structs(struct wl_list *message_list, struct 
> >interface *interface, enum sid
> >  static void
> >  format_copyright(const char *copyright)
> >  {
> >-int bol = 1, start = 0, i;
> >+int bol = 1, start = 0, i, length;
> >+bool comment_started = false;
> >-for (i = 0; copyright[i]; i++) {
> >+length = strlen(copyright);
> >+for (i = 0; i <= length; i++) {
> > if (bol && (copyright[i] == ' ' || copyright[i] == '\t')) {
> > continue;
> > } else if (bol) {
> > bol = 0;
> > start = i;
> > }
> >-
> >-if (copyright[i] == '\n' || copyright[i] == '\0') {
> >+if (copyright[i] == '\n' ||
> >+(copyright[i] == '\0' && !(start == i))) {
> > printf("%s%s%.*s\n",
> >-   i == 0 ? "/*" : " *",
> >+   comment_started ? " *" : "/*",
> >i > start ? " " : "",
> >i - start, copyright + start);
> > bol = 1;
> >+comment_started = true;
> > }
> > }
> >-printf(" */\n\n");
> >+if (comment_started)
> >+printf(" */\n\n");
> >  }
> >  static void
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland] scanner: Fix oddities in copyright printing

2016-02-04 Thread Bryce Harrington
On Tue, Feb 02, 2016 at 02:56:57PM -0600, Derek Foreman wrote:
> Some copyright strings could result in broken generated header files with
> unmatched */
> 
> This change:
> Runs the loop long enough so the copyright[i] == 0 test can actually
> happen. (if there was no \n no copyright text was printed, */ still was)
> 
> Prints the opening /* even if there was whitespace at the start of
> the very first line.
> 
> Only emits a */ if a /* was printed.
> 
> Signed-off-by: Derek Foreman 
Reviewed-by: Bryce Harrington 

> ---
>  src/scanner.c | 16 ++--
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/src/scanner.c b/src/scanner.c
> index dda5473..d3e2328 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -1284,25 +1284,29 @@ emit_structs(struct wl_list *message_list, struct 
> interface *interface, enum sid
>  static void
>  format_copyright(const char *copyright)
>  {
> - int bol = 1, start = 0, i;
> + int bol = 1, start = 0, i, length;
> + bool comment_started = false;
>  
> - for (i = 0; copyright[i]; i++) {
> + length = strlen(copyright);
> + for (i = 0; i <= length; i++) {
>   if (bol && (copyright[i] == ' ' || copyright[i] == '\t')) {
>   continue;
>   } else if (bol) {
>   bol = 0;
>   start = i;
>   }
> -
> - if (copyright[i] == '\n' || copyright[i] == '\0') {
> + if (copyright[i] == '\n' ||
> + (copyright[i] == '\0' && !(start == i))) {
>   printf("%s%s%.*s\n",
> -i == 0 ? "/*" : " *",
> +comment_started ? " *" : "/*",
>  i > start ? " " : "",
>  i - start, copyright + start);
>   bol = 1;
> + comment_started = true;
>   }
>   }
> - printf(" */\n\n");
> + if (comment_started)
> + printf(" */\n\n");
>  }
>  
>  static void
> -- 
> 2.7.0
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland] scanner: Fix oddities in copyright printing

2016-02-02 Thread Jon A. Cruz

On 02/02/2016 12:56 PM, Derek Foreman wrote:

Some copyright strings could result in broken generated header files with
unmatched */

This change:
Runs the loop long enough so the copyright[i] == 0 test can actually
happen. (if there was no \n no copyright text was printed, */ still was)

Prints the opening /* even if there was whitespace at the start of
the very first line.

Only emits a */ if a /* was printed.

Signed-off-by: Derek Foreman 


Looks good to me:
Reviewed-by: Jon A. Cruz 



---
  src/scanner.c | 16 ++--
  1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index dda5473..d3e2328 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1284,25 +1284,29 @@ emit_structs(struct wl_list *message_list, struct 
interface *interface, enum sid
  static void
  format_copyright(const char *copyright)
  {
-   int bol = 1, start = 0, i;
+   int bol = 1, start = 0, i, length;
+   bool comment_started = false;
  
-	for (i = 0; copyright[i]; i++) {

+   length = strlen(copyright);
+   for (i = 0; i <= length; i++) {
if (bol && (copyright[i] == ' ' || copyright[i] == '\t')) {
continue;
} else if (bol) {
bol = 0;
start = i;
}
-
-   if (copyright[i] == '\n' || copyright[i] == '\0') {
+   if (copyright[i] == '\n' ||
+   (copyright[i] == '\0' && !(start == i))) {
printf("%s%s%.*s\n",
-  i == 0 ? "/*" : " *",
+  comment_started ? " *" : "/*",
   i > start ? " " : "",
   i - start, copyright + start);
bol = 1;
+   comment_started = true;
}
}
-   printf(" */\n\n");
+   if (comment_started)
+   printf(" */\n\n");
  }
  
  static void


___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland] scanner: Fix oddities in copyright printing

2016-02-02 Thread Derek Foreman
Some copyright strings could result in broken generated header files with
unmatched */

This change:
Runs the loop long enough so the copyright[i] == 0 test can actually
happen. (if there was no \n no copyright text was printed, */ still was)

Prints the opening /* even if there was whitespace at the start of
the very first line.

Only emits a */ if a /* was printed.

Signed-off-by: Derek Foreman 
---
 src/scanner.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index dda5473..d3e2328 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1284,25 +1284,29 @@ emit_structs(struct wl_list *message_list, struct 
interface *interface, enum sid
 static void
 format_copyright(const char *copyright)
 {
-   int bol = 1, start = 0, i;
+   int bol = 1, start = 0, i, length;
+   bool comment_started = false;
 
-   for (i = 0; copyright[i]; i++) {
+   length = strlen(copyright);
+   for (i = 0; i <= length; i++) {
if (bol && (copyright[i] == ' ' || copyright[i] == '\t')) {
continue;
} else if (bol) {
bol = 0;
start = i;
}
-
-   if (copyright[i] == '\n' || copyright[i] == '\0') {
+   if (copyright[i] == '\n' ||
+   (copyright[i] == '\0' && !(start == i))) {
printf("%s%s%.*s\n",
-  i == 0 ? "/*" : " *",
+  comment_started ? " *" : "/*",
   i > start ? " " : "",
   i - start, copyright + start);
bol = 1;
+   comment_started = true;
}
}
-   printf(" */\n\n");
+   if (comment_started)
+   printf(" */\n\n");
 }
 
 static void
-- 
2.7.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel