[tz] [PROPOSED 2/5] Improve #if indenting
Paul Eggert
eggert at cs.ucla.edu
Tue Jul 12 16:14:04 UTC 2022
In preparing the recent zic.c patch I found it hard to follow
the inconsistent indenting within #if and #ifdef blocks.
Make it more consistent. This changes only white space.
---
asctime.c | 8 ++++----
date.c | 8 ++++----
localtime.c | 26 +++++++++++++-------------
private.h | 48 ++++++++++++++++++++++++------------------------
strftime.c | 10 +++++-----
tzfile.h | 14 +++++++-------
zdump.c | 10 +++++-----
zic.c | 12 ++++++------
8 files changed, 68 insertions(+), 68 deletions(-)
diff --git a/asctime.c b/asctime.c
index 56c54b3..68fbb80 100644
--- a/asctime.c
+++ b/asctime.c
@@ -35,9 +35,9 @@
** but many implementations pad anyway; most likely the standards are buggy.
*/
#ifdef __GNUC__
-#define ASCTIME_FMT "%s %s%3d %2.2d:%2.2d:%2.2d %-4s\n"
+# define ASCTIME_FMT "%s %s%3d %2.2d:%2.2d:%2.2d %-4s\n"
#else /* !defined __GNUC__ */
-#define ASCTIME_FMT "%s %s%3d %02.2d:%02.2d:%02.2d %-4s\n"
+# define ASCTIME_FMT "%s %s%3d %02.2d:%02.2d:%02.2d %-4s\n"
#endif /* !defined __GNUC__ */
/*
** For years that are more than four digits we put extra spaces before the year
@@ -46,9 +46,9 @@
** that no output is better than wrong output).
*/
#ifdef __GNUC__
-#define ASCTIME_FMT_B "%s %s%3d %2.2d:%2.2d:%2.2d %s\n"
+# define ASCTIME_FMT_B "%s %s%3d %2.2d:%2.2d:%2.2d %s\n"
#else /* !defined __GNUC__ */
-#define ASCTIME_FMT_B "%s %s%3d %02.2d:%02.2d:%02.2d %s\n"
+# define ASCTIME_FMT_B "%s %s%3d %02.2d:%02.2d:%02.2d %s\n"
#endif /* !defined __GNUC__ */
#define STD_ASCTIME_BUF_SIZE 26
diff --git a/date.c b/date.c
index b04d3f2..4c72b21 100644
--- a/date.c
+++ b/date.c
@@ -36,11 +36,11 @@
*/
#ifndef TM_YEAR_BASE
-#define TM_YEAR_BASE 1900
+# define TM_YEAR_BASE 1900
#endif /* !defined TM_YEAR_BASE */
#ifndef SECSPERMIN
-#define SECSPERMIN 60
+# define SECSPERMIN 60
#endif /* !defined SECSPERMIN */
#if !HAVE_POSIX_DECLS
@@ -70,9 +70,9 @@ main(const int argc, char *argv[])
setlocale(LC_ALL, "");
#endif /* defined(LC_ALL) */
#if HAVE_GETTEXT
-#ifdef TZ_DOMAINDIR
+# ifdef TZ_DOMAINDIR
bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
-#endif /* defined(TEXTDOMAINDIR) */
+# endif /* defined(TEXTDOMAINDIR) */
textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
t = time(NULL);
diff --git a/localtime.c b/localtime.c
index 3db7821..6380146 100644
--- a/localtime.c
+++ b/localtime.c
@@ -29,16 +29,16 @@ static void unlock(void) { }
#endif
#ifndef TZ_ABBR_MAX_LEN
-#define TZ_ABBR_MAX_LEN 16
+# define TZ_ABBR_MAX_LEN 16
#endif /* !defined TZ_ABBR_MAX_LEN */
#ifndef TZ_ABBR_CHAR_SET
-#define TZ_ABBR_CHAR_SET \
+# define TZ_ABBR_CHAR_SET \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._"
#endif /* !defined TZ_ABBR_CHAR_SET */
#ifndef TZ_ABBR_ERR_CHAR
-#define TZ_ABBR_ERR_CHAR '_'
+# define TZ_ABBR_ERR_CHAR '_'
#endif /* !defined TZ_ABBR_ERR_CHAR */
/*
@@ -46,10 +46,10 @@ static void unlock(void) { }
*/
#ifdef O_BINARY
-#define OPEN_MODE (O_RDONLY | O_BINARY)
+# define OPEN_MODE (O_RDONLY | O_BINARY)
#endif /* defined O_BINARY */
#ifndef O_BINARY
-#define OPEN_MODE O_RDONLY
+# define OPEN_MODE O_RDONLY
#endif /* !defined O_BINARY */
#ifndef WILDABBR
@@ -72,7 +72,7 @@ static void unlock(void) { }
** manual page of what this "time zone abbreviation" means (doing this so
** that tzname[0] has the "normal" length of three characters).
*/
-#define WILDABBR " "
+# define WILDABBR " "
#endif /* !defined WILDABBR */
static const char wildabbr[] = WILDABBR;
@@ -86,7 +86,7 @@ static const char gmt[] = "GMT";
** for historical reasons, US rules are a common default.
*/
#ifndef TZDEFRULESTRING
-#define TZDEFRULESTRING ",M3.2.0,M11.1.0"
+# define TZDEFRULESTRING ",M3.2.0,M11.1.0"
#endif
struct ttinfo { /* time type information */
@@ -112,10 +112,10 @@ static char const UNSPEC[] = "-00";
enum { CHARS_EXTRA = max(sizeof UNSPEC, 2) - 1 };
#ifdef TZNAME_MAX
-#define MY_TZNAME_MAX TZNAME_MAX
+# define MY_TZNAME_MAX TZNAME_MAX
#endif /* defined TZNAME_MAX */
#ifndef TZNAME_MAX
-#define MY_TZNAME_MAX 255
+# define MY_TZNAME_MAX 255
#endif /* !defined TZNAME_MAX */
struct state {
@@ -171,12 +171,12 @@ static struct state * gmtptr;
#ifndef ALL_STATE
static struct state lclmem;
static struct state gmtmem;
-#define lclptr (&lclmem)
-#define gmtptr (&gmtmem)
+# define lclptr (&lclmem)
+# define gmtptr (&gmtmem)
#endif /* State Farm */
#ifndef TZ_STRLEN_MAX
-#define TZ_STRLEN_MAX 255
+# define TZ_STRLEN_MAX 255
#endif /* !defined TZ_STRLEN_MAX */
static char lcl_TZname[TZ_STRLEN_MAX + 1];
@@ -1860,7 +1860,7 @@ ctime_r(const time_t *timep, char *buf)
*/
#ifndef WRONG
-#define WRONG (-1)
+# define WRONG (-1)
#endif /* !defined WRONG */
/*
diff --git a/private.h b/private.h
index b083c1b..ff98608 100644
--- a/private.h
+++ b/private.h
@@ -36,7 +36,7 @@
*/
#ifndef HAVE_DECL_ASCTIME_R
-#define HAVE_DECL_ASCTIME_R 1
+# define HAVE_DECL_ASCTIME_R 1
#endif
#if !defined HAVE_GENERIC && defined __has_extension
@@ -55,51 +55,51 @@
#endif
#ifndef HAVE_GETTEXT
-#define HAVE_GETTEXT 0
+# define HAVE_GETTEXT 0
#endif /* !defined HAVE_GETTEXT */
#ifndef HAVE_INCOMPATIBLE_CTIME_R
-#define HAVE_INCOMPATIBLE_CTIME_R 0
+# define HAVE_INCOMPATIBLE_CTIME_R 0
#endif
#ifndef HAVE_LINK
-#define HAVE_LINK 1
+# define HAVE_LINK 1
#endif /* !defined HAVE_LINK */
#ifndef HAVE_MALLOC_ERRNO
-#define HAVE_MALLOC_ERRNO 1
+# define HAVE_MALLOC_ERRNO 1
#endif
#ifndef HAVE_POSIX_DECLS
-#define HAVE_POSIX_DECLS 1
+# define HAVE_POSIX_DECLS 1
#endif
#ifndef HAVE_STDBOOL_H
-#define HAVE_STDBOOL_H (199901 <= __STDC_VERSION__)
+# define HAVE_STDBOOL_H (199901 <= __STDC_VERSION__)
#endif
#ifndef HAVE_STRDUP
-#define HAVE_STRDUP 1
+# define HAVE_STRDUP 1
#endif
#ifndef HAVE_STRTOLL
-#define HAVE_STRTOLL 1
+# define HAVE_STRTOLL 1
#endif
#ifndef HAVE_SYMLINK
-#define HAVE_SYMLINK 1
+# define HAVE_SYMLINK 1
#endif /* !defined HAVE_SYMLINK */
#ifndef HAVE_SYS_STAT_H
-#define HAVE_SYS_STAT_H 1
+# define HAVE_SYS_STAT_H 1
#endif /* !defined HAVE_SYS_STAT_H */
#ifndef HAVE_UNISTD_H
-#define HAVE_UNISTD_H 1
+# define HAVE_UNISTD_H 1
#endif /* !defined HAVE_UNISTD_H */
#ifndef HAVE_UTMPX_H
-#define HAVE_UTMPX_H 1
+# define HAVE_UTMPX_H 1
#endif /* !defined HAVE_UTMPX_H */
#ifndef NETBSD_INSPIRED
@@ -107,8 +107,8 @@
#endif
#if HAVE_INCOMPATIBLE_CTIME_R
-#define asctime_r _incompatible_asctime_r
-#define ctime_r _incompatible_ctime_r
+# define asctime_r _incompatible_asctime_r
+# define ctime_r _incompatible_ctime_r
#endif /* HAVE_INCOMPATIBLE_CTIME_R */
/* Enable tm_gmtoff, tm_zone, and environ on GNUish systems. */
@@ -182,11 +182,11 @@
#endif
#if HAVE_GETTEXT
-#include <libintl.h>
+# include <libintl.h>
#endif /* HAVE_GETTEXT */
#if HAVE_UNISTD_H
-#include <unistd.h> /* for R_OK, and other POSIX goodness */
+# include <unistd.h> /* for R_OK, and other POSIX goodness */
#endif /* HAVE_UNISTD_H */
#ifndef HAVE_STRFTIME_L
@@ -222,7 +222,7 @@
#endif
#ifndef R_OK
-#define R_OK 4
+# define R_OK 4
#endif /* !defined R_OK */
/*
@@ -232,14 +232,14 @@
** stdint.h, even with pre-C99 compilers.
*/
#ifndef HAVE_STDINT_H
-#define HAVE_STDINT_H \
+# define HAVE_STDINT_H \
(199901 <= __STDC_VERSION__ \
- || 2 < __GLIBC__ + (1 <= __GLIBC_MINOR__) \
+ || 2 < __GLIBC__ + (1 <= __GLIBC_MINOR__) \
|| __CYGWIN__ || INTMAX_MAX)
#endif /* !defined HAVE_STDINT_H */
#if HAVE_STDINT_H
-#include <stdint.h>
+# include <stdint.h>
#endif /* !HAVE_STDINT_H */
#ifndef HAVE_INTTYPES_H
@@ -358,14 +358,14 @@ typedef unsigned long uintmax_t;
#endif
#ifndef INT32_MAX
-#define INT32_MAX 0x7fffffff
+# define INT32_MAX 0x7fffffff
#endif /* !defined INT32_MAX */
#ifndef INT32_MIN
-#define INT32_MIN (-1 - INT32_MAX)
+# define INT32_MIN (-1 - INT32_MAX)
#endif /* !defined INT32_MIN */
#ifndef SIZE_MAX
-#define SIZE_MAX ((size_t) -1)
+# define SIZE_MAX ((size_t) -1)
#endif
#if 3 <= __GNUC__
diff --git a/strftime.c b/strftime.c
index 56e762b..7425a64 100644
--- a/strftime.c
+++ b/strftime.c
@@ -113,7 +113,7 @@ static char * _fmt(const char *, const struct tm *, char *, const char *,
static char * _yconv(int, int, bool, bool, char *, char const *);
#ifndef YEAR_2000_NAME
-#define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS"
+# define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS"
#endif /* !defined YEAR_2000_NAME */
#if HAVE_STRFTIME_L
@@ -551,15 +551,15 @@ label:
# endif
negative = diff < 0;
if (diff == 0) {
-#ifdef TM_ZONE
+# ifdef TM_ZONE
negative = t->TM_ZONE[0] == '-';
-#else
+# else
negative = t->tm_isdst < 0;
-# if HAVE_TZNAME
+# if HAVE_TZNAME
if (tzname[t->tm_isdst != 0][0] == '-')
negative = true;
+# endif
# endif
-#endif
}
if (negative) {
sign = "-";
diff --git a/tzfile.h b/tzfile.h
index 9c3ea4e..6b18d6b 100644
--- a/tzfile.h
+++ b/tzfile.h
@@ -22,15 +22,15 @@
*/
#ifndef TZDIR
-#define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
+# define TZDIR "/usr/share/zoneinfo" /* Time zone object file directory */
#endif /* !defined TZDIR */
#ifndef TZDEFAULT
-#define TZDEFAULT "/etc/localtime"
+# define TZDEFAULT "/etc/localtime"
#endif /* !defined TZDEFAULT */
#ifndef TZDEFRULES
-#define TZDEFRULES "posixrules"
+# define TZDEFRULES "posixrules"
#endif /* !defined TZDEFRULES */
@@ -103,21 +103,21 @@ struct tzhead {
*/
#ifndef TZ_MAX_TIMES
-#define TZ_MAX_TIMES 2000
+# define TZ_MAX_TIMES 2000
#endif /* !defined TZ_MAX_TIMES */
#ifndef TZ_MAX_TYPES
/* This must be at least 17 for Europe/Samara and Europe/Vilnius. */
-#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
+# define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
#endif /* !defined TZ_MAX_TYPES */
#ifndef TZ_MAX_CHARS
-#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
+# define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
/* (limited by what unsigned chars can hold) */
#endif /* !defined TZ_MAX_CHARS */
#ifndef TZ_MAX_LEAPS
-#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
+# define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
#endif /* !defined TZ_MAX_LEAPS */
#endif /* !defined TZFILE_H */
diff --git a/zdump.c b/zdump.c
index b10f574..b153812 100644
--- a/zdump.c
+++ b/zdump.c
@@ -35,11 +35,11 @@
#endif
#ifndef ZDUMP_LO_YEAR
-#define ZDUMP_LO_YEAR (-500)
+# define ZDUMP_LO_YEAR (-500)
#endif /* !defined ZDUMP_LO_YEAR */
#ifndef ZDUMP_HI_YEAR
-#define ZDUMP_HI_YEAR 2500
+# define ZDUMP_HI_YEAR 2500
#endif /* !defined ZDUMP_HI_YEAR */
#define SECSPERNYEAR (SECSPERDAY * DAYSPERNYEAR)
@@ -72,7 +72,7 @@ enum { SECSPER400YEARS_FITS = SECSPERLYEAR <= INTMAX_MAX / 400 };
#endif
#if HAVE_GETTEXT
-#include <locale.h> /* for setlocale */
+# include <locale.h> /* for setlocale */
#endif /* HAVE_GETTEXT */
#if ! HAVE_LOCALTIME_RZ
@@ -450,9 +450,9 @@ main(int argc, char *argv[])
cuthitime = absolute_max_time;
#if HAVE_GETTEXT
setlocale(LC_ALL, "");
-#ifdef TZ_DOMAINDIR
+# ifdef TZ_DOMAINDIR
bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
-#endif /* defined TEXTDOMAINDIR */
+# endif /* defined TEXTDOMAINDIR */
textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
progname = argv[0];
diff --git a/zic.c b/zic.c
index e081c3d..7742422 100644
--- a/zic.c
+++ b/zic.c
@@ -29,7 +29,7 @@ typedef int_fast64_t zic_t;
#define SCNdZIC SCNdFAST64
#ifndef ZIC_MAX_ABBR_LEN_WO_WARN
-#define ZIC_MAX_ABBR_LEN_WO_WARN 6
+# define ZIC_MAX_ABBR_LEN_WO_WARN 6
#endif /* !defined ZIC_MAX_ABBR_LEN_WO_WARN */
#ifdef HAVE_DIRECT_H
@@ -40,12 +40,12 @@ typedef int_fast64_t zic_t;
#endif
#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
+# include <sys/stat.h>
#endif
#ifdef S_IRUSR
-#define MKDIR_UMASK (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
+# define MKDIR_UMASK (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
#else
-#define MKDIR_UMASK 0755
+# define MKDIR_UMASK 0755
#endif
/* The maximum ptrdiff_t value, for pre-C99 platforms. */
@@ -765,9 +765,9 @@ main(int argc, char **argv)
#endif
#if HAVE_GETTEXT
setlocale(LC_ALL, "");
-#ifdef TZ_DOMAINDIR
+# ifdef TZ_DOMAINDIR
bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
-#endif /* defined TEXTDOMAINDIR */
+# endif /* defined TEXTDOMAINDIR */
textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
progname = argv[0];
--
2.34.1
More information about the tz
mailing list