On Sun, Mar 20, 2016 at 11:12:08AM +0530, Jay Joshi wrote:
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -49,6 +49,7 @@ libtests_a_SOURCES = \
>       tail_alloc.c \
>       tests.h \
>       tprintf.c \
> +     print_quoted_string.c \
>       # end of libtests_a_SOURCES

Please keep the list sorted.

> --- /dev/null
> +++ b/tests/print_quoted_string.c
> @@ -0,0 +1,61 @@
> +#include "tests.h"
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +/* Modified from string_quote() from util.c.
> + * Assumes str is NUL-terminated.
> + */
> +
> +void
> +print_quoted_string(const char *str)
> +{
> +     unsigned int i=0;
> +     int c;

Shouldn't "c" have type "unsigned char", or, alternatively,
shouldn't "str" be cast to "const unsigned char *", to avoid sign
extension?

> +
> +     while (c = str[i++]) {

Wouldn't it be better without "i" iterator at all?  e.g.
        while ((c = *(str++))) {

> +                     default:
> +                             if (c >= ' ' && c <= 0x7e)
> +                                     putchar(c);
> +                             else {
> +                                     printf("\\");

Wouldn't putchar(c) in cases like this look simpler? 

> +                                     if (str[i + 1] >= '0' && str[i + 1] <= 
> '9') {

This check is not correct because "i" already points to the next
character.


-- 
ldv

Attachment: pgppXEDt5NzD9.pgp
Description: PGP signature

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to