diff mbox

[2/6] utilities: kernelscan: tidy up the formatting of output messages.

Message ID 1351875517-19128-3-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Nov. 2, 2012, 4:58 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Just make the output look more appealing

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/utilities/kernelscan.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Keng-Yu Lin Nov. 7, 2012, 2:11 a.m. UTC | #1
On Sat, Nov 3, 2012 at 12:58 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Just make the output look more appealing
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/utilities/kernelscan.c |   15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 7569079..9133ce9 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -386,6 +386,8 @@ static int skip_comments(parser *p)
>
>                                 if (ch == '/')
>                                         return PARSER_COMMENT_FOUND;
> +
> +                               unget_next(p, ch);
>                         }
>                 }
>         }
> @@ -760,10 +762,10 @@ static int parse_kernel_message(parser *p, token *t)
>
>         printk = (strcmp(t->token, "printk") == 0);
>
> -       if (strcmp(t->token, "dev_err") == 0) {
> +       if (strcmp(t->token, "dev_err") == 0)
>                 emit = true;
> -               line = strdupcat(line, "dev_err");
> -       }
> +
> +       line = strdupcat(line, t->token);
>         token_clear(t);
>
>         for (;;) {
> @@ -795,9 +797,10 @@ static int parse_kernel_message(parser *p, token *t)
>                     (t->type == TOKEN_IDENTIFIER) &&
>                     (prev_token_type == TOKEN_PAREN_OPENED) &&
>                     (strcmp(t->token, "KERN_ERR") == 0)) {
> -                       line = strdupcat(line, "printk( ");
> +                       emit = true;
>                 }
>
> +
>                 if (t->type == TOKEN_LITERAL_STRING) {
>                         literal_strip_quotes(t);
>                         str = strdupcat(str, t->token);
> @@ -820,6 +823,10 @@ static int parse_kernel_message(parser *p, token *t)
>                 }
>
>                 line = strdupcat(line, t->token);
> +
> +               if (t->type == TOKEN_IDENTIFIER && prev_token_type != TOKEN_COMMA)
> +                       line = strdupcat(line, " ");
> +
>                 if (t->type == TOKEN_COMMA)
>                         line = strdupcat(line, " ");
>
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung Nov. 21, 2012, 5:50 a.m. UTC | #2
On 11/03/2012 12:58 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Just make the output look more appealing
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/utilities/kernelscan.c |   15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 7569079..9133ce9 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -386,6 +386,8 @@ static int skip_comments(parser *p)
>
>   				if (ch == '/')
>   					return PARSER_COMMENT_FOUND;
> +
> +				unget_next(p, ch);
>   			}
>   		}
>   	}
> @@ -760,10 +762,10 @@ static int parse_kernel_message(parser *p, token *t)
>
>   	printk = (strcmp(t->token, "printk") == 0);
>
> -	if (strcmp(t->token, "dev_err") == 0) {
> +	if (strcmp(t->token, "dev_err") == 0)
>   		emit = true;
> -		line = strdupcat(line, "dev_err");
> -	}
> +
> +	line = strdupcat(line, t->token);
>   	token_clear(t);
>
>   	for (;;) {
> @@ -795,9 +797,10 @@ static int parse_kernel_message(parser *p, token *t)
>   		    (t->type == TOKEN_IDENTIFIER) &&
>   		    (prev_token_type == TOKEN_PAREN_OPENED) &&
>   		    (strcmp(t->token, "KERN_ERR") == 0)) {
> -			line = strdupcat(line, "printk( ");
> +			emit = true;
>   		}
>
> +
>   		if (t->type == TOKEN_LITERAL_STRING) {
>   			literal_strip_quotes(t);
>   			str = strdupcat(str, t->token);
> @@ -820,6 +823,10 @@ static int parse_kernel_message(parser *p, token *t)
>   		}
>
>   		line = strdupcat(line, t->token);
> +
> +		if (t->type == TOKEN_IDENTIFIER && prev_token_type != TOKEN_COMMA)
> +			line = strdupcat(line, " ");
> +
>   		if (t->type == TOKEN_COMMA)
>   			line = strdupcat(line, " ");
>
>
Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox

Patch

diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
index 7569079..9133ce9 100644
--- a/src/utilities/kernelscan.c
+++ b/src/utilities/kernelscan.c
@@ -386,6 +386,8 @@  static int skip_comments(parser *p)
 
 				if (ch == '/')
 					return PARSER_COMMENT_FOUND;
+
+				unget_next(p, ch);
 			}
 		}
 	}
@@ -760,10 +762,10 @@  static int parse_kernel_message(parser *p, token *t)
 
 	printk = (strcmp(t->token, "printk") == 0);
 
-	if (strcmp(t->token, "dev_err") == 0) {
+	if (strcmp(t->token, "dev_err") == 0)
 		emit = true;
-		line = strdupcat(line, "dev_err");
-	}
+
+	line = strdupcat(line, t->token);
 	token_clear(t);
 
 	for (;;) {
@@ -795,9 +797,10 @@  static int parse_kernel_message(parser *p, token *t)
 		    (t->type == TOKEN_IDENTIFIER) &&
 		    (prev_token_type == TOKEN_PAREN_OPENED) &&
 		    (strcmp(t->token, "KERN_ERR") == 0)) {
-			line = strdupcat(line, "printk( ");
+			emit = true;
 		}
 
+
 		if (t->type == TOKEN_LITERAL_STRING) {
 			literal_strip_quotes(t);
 			str = strdupcat(str, t->token);
@@ -820,6 +823,10 @@  static int parse_kernel_message(parser *p, token *t)
 		}
 
 		line = strdupcat(line, t->token);
+
+		if (t->type == TOKEN_IDENTIFIER && prev_token_type != TOKEN_COMMA)
+			line = strdupcat(line, " ");
+
 		if (t->type == TOKEN_COMMA)
 			line = strdupcat(line, " ");