bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add getlimits utility for use in tests


From: Jim Meyering
Subject: Re: [PATCH] Add getlimits utility for use in tests
Date: Thu, 20 Nov 2008 13:41:14 +0100

Pádraig Brady <address@hidden> wrote:
> Pádraig Brady wrote:
>> First pass of tool to be used in test scripts
>> internal to the coreutils project.
>
> Take 2. Previous one added erroneous '-' chars to
> output depending on what was in memory.
...
> +#include <ctype.h>

Thanks!

Just a few nits...

How about
#include "c-ctype.h>
and then use c_isdigit instead of isdigit?

Also, please filter it all through "indent --no-tabs".

> +#include <sys/types.h>
> +
> +#include "system.h"
> +#include "error.h"
> +#include "long-options.h"
> +
> +#define PROGRAM_NAME "getlimits"
> +
> +#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
> +
> +#ifndef TIME_T_MAX
> +# define TIME_T_MAX TYPE_MAXIMUM (time_t)
> +#endif
> +
> +#ifndef TIME_T_MIN
> +# define TIME_T_MIN TYPE_MINIMUM (time_t)
> +#endif
> +
> +#ifndef SSIZE_MIN
> +#  define SSIZE_MIN TYPE_MINIMUM(ssize_t)

Use consistent, one-space indentation.
You can use cppi to automate this check.

> +#endif
...
> +#define print_int(TYPE) \
> +  snprintf(limit, sizeof(limit), "%"PRIuMAX, (uintmax_t)TYPE##_MAX); \
> +  if ((oflow = decimal_ascii_add(limit, "1"))) { \

in case indent doesn't deal with this, you should:
  - put each opening curly brace on a line by itself
  - make most of the backslashes line up: it's more readable that way
  - add spaces around operators, after ",", and before each opening parenthesis

     if ((oflow = decimal_ascii_add (limit, "1")))      \
       {                                                \
         printf (#TYPE"_MAX=%s\n", limit);              \
         ...

> +   printf(#TYPE"_MAX=%s\n", limit); \
> +   printf(#TYPE"_OFLOW=%s\n", oflow); \
> +   free(oflow); \
> +  } \
> +  if (TYPE##_MIN) { \
> +   snprintf(limit, sizeof(limit), "%"PRIdMAX, (intmax_t)TYPE##_MIN); \
> +   if ((oflow = decimal_ascii_add(limit, "-1"))) { \
> +    printf(#TYPE"_MIN=%s\n", limit); \
> +    printf(#TYPE"_UFLOW=%s\n", oflow); \
> +    free(oflow); \
> +   } \
> +  }
> +
> +  /* Variable sized ints */
> +  print_int(CHAR);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]