pg_indent run
authorTeodor Sigaev <teodor@sigaev.ru>
Thu, 23 Nov 2017 15:18:12 +0000 (18:18 +0300)
committerTeodor Sigaev <teodor@sigaev.ru>
Thu, 23 Nov 2017 15:18:12 +0000 (18:18 +0300)
Alexey Chernyshov <a.chernyshov@postgrespro.ru>

decode.c
decode.h
pg_filedump.c
pg_filedump.h
pg_lzcompress.c
stringinfo.c

index 7afa273b978e0f571284efe5da58b003ac65ebb7..89a17b31695538aed393eb37f82e405d369121e1 100644 (file)
--- a/decode.c
+++ b/decode.c
 
 #define ATTRTYPES_STR_MAX_LEN (1024-1)
 
-typedef int (*decode_callback_t)(const char* buffer, unsigned int buff_size,
-                                                                unsigned int* out_size);
+typedef int (*decode_callback_t) (const char *buffer, unsigned int buff_size,
+                                                                 unsigned int *out_size);
 
 static int
-decode_smallint(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_smallint(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_int(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_int(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_bigint(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_bigint(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_time(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_time(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_timetz(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_timetz(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_date(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_date(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_timestamp(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_timestamp(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_float4(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_float4(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_float8(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_float8(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_bool(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_bool(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_uuid(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_uuid(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_macaddr(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_macaddr(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_string(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_string(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_char(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_char(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_name(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_name(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
 static int
-decode_ignore(const char* buffer, unsigned int buff_size, unsigned int* out_size);
+decode_ignore(const char *buffer, unsigned int buff_size, unsigned int *out_size);
 
-static int ncallbacks = 0;
-static decode_callback_t callbacks[ATTRTYPES_STR_MAX_LEN / 2] = { NULL };
+static int     ncallbacks = 0;
+static decode_callback_t callbacks[ATTRTYPES_STR_MAX_LEN / 2] =
+{
+       NULL
+};
 
-typedef struct {
-       char* name;
+typedef struct
+{
+       char       *name;
        decode_callback_t callback;
-} ParseCallbackTableItem;
-
-static ParseCallbackTableItem callback_table[] = {
-       { "smallserial", &decode_smallint },
-       { "smallint", &decode_smallint },
-       { "int", &decode_int },
-       { "oid", &decode_int },
-       { "xid", &decode_int },
-       { "serial", &decode_int },
-       { "bigint", &decode_bigint },
-       { "bigserial", &decode_bigint },
-       { "time", &decode_time },
-       { "timetz", &decode_timetz },
-       { "date", &decode_date },
-       { "timestamp", &decode_timestamp },
-       { "real", &decode_float4 },
-       { "float4", &decode_float4 },
-       { "float8", &decode_float8 },
-       { "float", &decode_float8 },
-       { "bool", &decode_bool },
-       { "uuid", &decode_uuid },
-       { "macaddr", &decode_macaddr },
-       { "name", &decode_name },
-       { "char", &decode_char },
-       { "~", &decode_ignore },
+}                      ParseCallbackTableItem;
+
+static ParseCallbackTableItem callback_table[] =
+{
+       {
+               "smallserial", &decode_smallint
+       },
+       {
+               "smallint", &decode_smallint
+       },
+       {
+               "int", &decode_int
+       },
+       {
+               "oid", &decode_int
+       },
+       {
+               "xid", &decode_int
+       },
+       {
+               "serial", &decode_int
+       },
+       {
+               "bigint", &decode_bigint
+       },
+       {
+               "bigserial", &decode_bigint
+       },
+       {
+               "time", &decode_time
+       },
+       {
+               "timetz", &decode_timetz
+       },
+       {
+               "date", &decode_date
+       },
+       {
+               "timestamp", &decode_timestamp
+       },
+       {
+               "real", &decode_float4
+       },
+       {
+               "float4", &decode_float4
+       },
+       {
+               "float8", &decode_float8
+       },
+       {
+               "float", &decode_float8
+       },
+       {
+               "bool", &decode_bool
+       },
+       {
+               "uuid", &decode_uuid
+       },
+       {
+               "macaddr", &decode_macaddr
+       },
+       {
+               "name", &decode_name
+       },
+       {
+               "char", &decode_char
+       },
+       {
+               "~", &decode_ignore
+       },
 
        /* internally all string types are stored the same way */
-       { "charN", &decode_string },
-       { "varchar", &decode_string },
-       { "varcharN", &decode_string },
-       { "text", &decode_string },
-       { "json", &decode_string },
-       { "xml", &decode_string },
-       { NULL, NULL},
+       {
+               "charN", &decode_string
+       },
+       {
+               "varchar", &decode_string
+       },
+       {
+               "varcharN", &decode_string
+       },
+       {
+               "text", &decode_string
+       },
+       {
+               "json", &decode_string
+       },
+       {
+               "xml", &decode_string
+       },
+       {
+               NULL, NULL
+       },
 };
 
 static StringInfoData copyString;
@@ -115,7 +178,7 @@ static bool copyStringInitDone = false;
  * this limit. Unfortunately there is no way to know how much memory user
  * is willing to allocate.
  */
-static char decompress_tmp_buff[64*1024];
+static char decompress_tmp_buff[64 * 1024];
 
 /* Used by some PostgreSQL macro definitions */
 void
@@ -125,28 +188,28 @@ ExceptionalCondition(const char *conditionName,
                                         int lineNumber)
 {
        printf("Exceptional condition: name = %s, type = %s, fname = %s, line = %d\n",
-               conditionName ? conditionName : "(NULL)",
-               errorType ? errorType : "(NULL)",
-               fileName ? fileName : "(NULL)",
-               lineNumber);
+                  conditionName ? conditionName : "(NULL)",
+                  errorType ? errorType : "(NULL)",
+                  fileName ? fileName : "(NULL)",
+                  lineNumber);
        exit(1);
 }
 
 /* Append given string to current COPY line */
 static void
-CopyAppend(const charstr)
+CopyAppend(const char *str)
 {
-       if(!copyStringInitDone)
+       if (!copyStringInitDone)
        {
                initStringInfo(&copyString);
                copyStringInitDone = true;
        }
 
        /* Caller probably wanted just to init copyString */
-       if(str == NULL)
+       if (str == NULL)
                return;
 
-       if(copyString.data[0] != '\0')
+       if (copyString.data[0] != '\0')
                appendStringInfoString(&copyString, "\t");
 
        appendStringInfoString(&copyString, str);
@@ -157,65 +220,66 @@ CopyAppend(const char* str)
  * like \r, \n, \t and \\.
  */
 static void
-CopyAppendEncode(const charstr, int orig_len)
+CopyAppendEncode(const char *str, int orig_len)
 {
        /*
         * Should be enough in most cases. If it's not user can manually change
         * this limit. Unfortunately there is no way to know how much memory user
         * is willing to allocate.
         */
-       static char tmp_buff[64*1024];
+       static char tmp_buff[64 * 1024];
+
        /* Reserve one byte for a trailing zero. */
-       const int max_offset = sizeof(tmp_buff) - 2;
-       int curr_offset = 0;
-       int len = orig_len;
+       const int       max_offset = sizeof(tmp_buff) - 2;
+       int                     curr_offset = 0;
+       int                     len = orig_len;
 
-       while(len > 0)
+       while (len > 0)
        {
                /*
-                * Make sure there is enough free space for at least one special symbol
-                * and a trailing zero.
+                * Make sure there is enough free space for at least one special
+                * symbol and a trailing zero.
                 */
-               if(curr_offset > max_offset - 2)
+               if (curr_offset > max_offset - 2)
                {
                        printf("ERROR: Unable to properly encode a string since it's too "
-                               "large (%d bytes). Try to increase tmp_buff size in CopyAppendEncode "
-                               "procedure.\n", orig_len);
+                                  "large (%d bytes). Try to increase tmp_buff size in CopyAppendEncode "
+                                  "procedure.\n", orig_len);
                        exit(1);
                }
 
                /*
-                * Since we are working with potentially corrupted data we can encounter
-                * \0 as well.
+                * Since we are working with potentially corrupted data we can
+                * encounter \0 as well.
                 */
-               if(*str == '\0')
+               if (*str == '\0')
                {
                        tmp_buff[curr_offset] = '\\';
-                       tmp_buff[curr_offset+1] = '0';
+                       tmp_buff[curr_offset + 1] = '0';
                        curr_offset += 2;
                }
-               else if(*str == '\r')
+               else if (*str == '\r')
                {
                        tmp_buff[curr_offset] = '\\';
-                       tmp_buff[curr_offset+1] = 'r';
+                       tmp_buff[curr_offset + 1] = 'r';
                        curr_offset += 2;
                }
-               else if(*str == '\n')
+               else if (*str == '\n')
                {
                        tmp_buff[curr_offset] = '\\';
-                       tmp_buff[curr_offset+1] = 'n';
+                       tmp_buff[curr_offset + 1] = 'n';
                        curr_offset += 2;
                }
-               else if(*str == '\t')
+               else if (*str == '\t')
                {
                        tmp_buff[curr_offset] = '\\';
-                       tmp_buff[curr_offset+1] = 'r';
+                       tmp_buff[curr_offset + 1] = 'r';
                        curr_offset += 2;
                }
-               else if(*str == '\\')
+               else if (*str == '\\')
                {
                        tmp_buff[curr_offset] = '\\';
-                       tmp_buff[curr_offset+1] = '\\';
+                       tmp_buff[curr_offset + 1] = '\\';
                        curr_offset += 2;
                }
                else
@@ -272,16 +336,16 @@ CopyFlush(void)
  *     < 0        - invalid type name
  */
 static int
-AddTypeCallback(const chartype)
+AddTypeCallback(const char *type)
 {
-       int idx = 0;
+       int                     idx = 0;
 
-       if(*type == '\0') /* ignore empty strings */
+       if (*type == '\0')                      /* ignore empty strings */
                return 0;
 
-       while(callback_table[idx].name != NULL)
+       while (callback_table[idx].name != NULL)
        {
-               if(strcmp(callback_table[idx].name, type) == 0)
+               if (strcmp(callback_table[idx].name, type) == 0)
                {
                        callbacks[ncallbacks] = callback_table[idx].callback;
                        ncallbacks++;
@@ -293,7 +357,7 @@ AddTypeCallback(const char* type)
        printf("Error: type <%s> doesn't exist or is not currently supported\n", type);
        printf("Full list of known types: ");
        idx = 0;
-       while(callback_table[idx].name != NULL)
+       while (callback_table[idx].name != NULL)
        {
                printf("%s ", callback_table[idx].name);
                idx++;
@@ -312,34 +376,36 @@ AddTypeCallback(const char* type)
  *     < 0        - if string is invalid
  */
 int
-ParseAttributeTypesString(const charstr)
+ParseAttributeTypesString(const char *str)
 {
-       char *curr_type, *next_type;
-       char attrtypes[ATTRTYPES_STR_MAX_LEN+1];
-       int i, len = strlen(str);
+       char       *curr_type,
+                          *next_type;
+       char            attrtypes[ATTRTYPES_STR_MAX_LEN + 1];
+       int                     i,
+                               len = strlen(str);
 
-       if(len > ATTRTYPES_STR_MAX_LEN)
+       if (len > ATTRTYPES_STR_MAX_LEN)
        {
                printf("Error: attribute types string is longer then %u characters!\n",
-                       ATTRTYPES_STR_MAX_LEN);
+                          ATTRTYPES_STR_MAX_LEN);
                return -1;
        }
 
        strcpy(attrtypes, str);
-       for(i = 0; i < len; i++)
+       for (i = 0; i < len; i++)
                attrtypes[i] = tolower(attrtypes[i]);
 
        curr_type = attrtypes;
-       while(curr_type)
+       while (curr_type)
        {
                next_type = strstr(curr_type, ",");
-               if(next_type)
+               if (next_type)
                {
                        *next_type = '\0';
                        next_type++;
                }
 
-               if(AddTypeCallback(curr_type) < 0)
+               if (AddTypeCallback(curr_type) < 0)
                        return -1;
 
                curr_type = next_type;
@@ -358,7 +424,7 @@ j2date(int jd, int *year, int *month, int *day)
        unsigned int julian;
        unsigned int quad;
        unsigned int extra;
-       int              y;
+       int                     y;
 
        julian = jd;
        julian += 32044;
@@ -379,21 +445,21 @@ j2date(int jd, int *year, int *month, int *day)
 
 /* Decode a smallint type */
 static int
-decode_smallint(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_smallint(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int16), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int16), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(int16))
+       if (buff_size < sizeof(int16))
                return -2;
 
-       CopyAppendFmt("%d", (int)(*(int16*)buffer));
+       CopyAppendFmt("%d", (int) (*(int16 *) buffer));
        *out_size = sizeof(int16) + delta;
        return 0;
 }
@@ -401,125 +467,131 @@ decode_smallint(const char* buffer, unsigned int buff_size, unsigned int* out_si
 
 /* Decode an int type */
 static int
-decode_int(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_int(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int32), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int32), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(int32))
+       if (buff_size < sizeof(int32))
                return -2;
 
-       CopyAppendFmt("%d", *(int32*)buffer);
+       CopyAppendFmt("%d", *(int32 *) buffer);
        *out_size = sizeof(int32) + delta;
        return 0;
 }
 
 /* Decode a bigint type */
 static int
-decode_bigint(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_bigint(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int64), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int64), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(int64))
+       if (buff_size < sizeof(int64))
                return -2;
 
-       CopyAppendFmt("%ld", *(int64*)buffer);
+       CopyAppendFmt("%ld", *(int64 *) buffer);
        *out_size = sizeof(int64) + delta;
        return 0;
 }
 
 /* Decode a time type */
 static int
-decode_time(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_time(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int64), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
-       int64 timestamp, timestamp_sec;
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int64), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
+       int64           timestamp,
+                               timestamp_sec;
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(int64))
+       if (buff_size < sizeof(int64))
                return -2;
 
-       timestamp = *(int64*)buffer;
+       timestamp = *(int64 *) buffer;
        timestamp_sec = timestamp / 1000000;
        *out_size = sizeof(int64) + delta;
 
        CopyAppendFmt("%02ld:%02ld:%02ld.%06ld",
-               timestamp_sec / 60 / 60, (timestamp_sec / 60) % 60, timestamp_sec % 60,
-               timestamp % 1000000);
+                                 timestamp_sec / 60 / 60, (timestamp_sec / 60) % 60, timestamp_sec % 60,
+                                 timestamp % 1000000);
 
        return 0;
 }
 
 /* Decode a timetz type */
 static int
-decode_timetz(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_timetz(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int64), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
-       int64 timestamp, timestamp_sec;
-       int32 tz_sec, tz_min;
-
-       if(buff_size < delta)
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int64), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
+       int64           timestamp,
+                               timestamp_sec;
+       int32           tz_sec,
+                               tz_min;
+
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < (sizeof(int64) + sizeof(int32)))
+       if (buff_size < (sizeof(int64) + sizeof(int32)))
                return -2;
 
-       timestamp = *(int64*)buffer;
-       tz_sec = *(int32*)(buffer + sizeof(int64));
+       timestamp = *(int64 *) buffer;
+       tz_sec = *(int32 *) (buffer + sizeof(int64));
        timestamp_sec = timestamp / 1000000;
-       tz_min = - (tz_sec / 60);
+       tz_min = -(tz_sec / 60);
        *out_size = sizeof(int64) + sizeof(int32) + delta;
 
        CopyAppendFmt("%02ld:%02ld:%02ld.%06ld%c%02d:%02d",
-               timestamp_sec / 60 / 60, (timestamp_sec / 60) % 60, timestamp_sec % 60,
-               timestamp % 1000000, (tz_min > 0 ? '+' : '-'), abs(tz_min / 60), abs(tz_min % 60));
+                                 timestamp_sec / 60 / 60, (timestamp_sec / 60) % 60, timestamp_sec % 60,
+                                 timestamp % 1000000, (tz_min > 0 ? '+' : '-'), abs(tz_min / 60), abs(tz_min % 60));
 
        return 0;
 }
 
 /* Decode a date type */
 static int
-decode_date(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_date(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int32), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
-       int32 jd, year, month, day;
-
-       if(buff_size < delta)
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int32), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
+       int32           jd,
+                               year,
+                               month,
+                               day;
+
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(int32))
+       if (buff_size < sizeof(int32))
                return -2;
 
        *out_size = sizeof(int32) + delta;
 
-       jd = *(int32*)buffer + POSTGRES_EPOCH_JDATE;
+       jd = *(int32 *) buffer + POSTGRES_EPOCH_JDATE;
        j2date(jd, &year, &month, &day);
 
        CopyAppendFmt("%04d-%02d-%02d%s", (year <= 0) ? -year + 1 : year, month, day, (year <= 0) ? " BC" : "");
@@ -529,24 +601,28 @@ decode_date(const char* buffer, unsigned int buff_size, unsigned int* out_size)
 
 /* Decode a timestamp type */
 static int
-decode_timestamp(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_timestamp(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int64), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
-       int64 timestamp, timestamp_sec;
-       int32 jd, year, month, day;
-
-       if(buff_size < delta)
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int64), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
+       int64           timestamp,
+                               timestamp_sec;
+       int32           jd,
+                               year,
+                               month,
+                               day;
+
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(int64))
+       if (buff_size < sizeof(int64))
                return -2;
 
        *out_size = sizeof(int64) + delta;
-       timestamp = *(int64*)buffer;
+       timestamp = *(int64 *) buffer;
 
        jd = timestamp / USECS_PER_DAY;
        if (jd != 0)
@@ -565,69 +641,69 @@ decode_timestamp(const char* buffer, unsigned int buff_size, unsigned int* out_s
        timestamp_sec = timestamp / 1000000;
 
        CopyAppendFmt("%04d-%02d-%02d %02ld:%02ld:%02ld.%06ld%s",
-               (year <= 0) ? -year + 1 : year, month, day,
-               timestamp_sec / 60 / 60, (timestamp_sec / 60) % 60, timestamp_sec % 60,
-               timestamp % 1000000,
-               (year <= 0) ? " BC" : "");
+                                 (year <= 0) ? -year + 1 : year, month, day,
+                                 timestamp_sec / 60 / 60, (timestamp_sec / 60) % 60, timestamp_sec % 60,
+                                 timestamp % 1000000,
+                                 (year <= 0) ? " BC" : "");
 
        return 0;
 }
 
 /* Decode a float4 type */
 static int
-decode_float4(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_float4(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(float), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(float), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(float))
+       if (buff_size < sizeof(float))
                return -2;
 
-       CopyAppendFmt("%.12f", *(float*)buffer);
+       CopyAppendFmt("%.12f", *(float *) buffer);
        *out_size = sizeof(float) + delta;
        return 0;
 }
 
 /* Decode a float8 type */
 static int
-decode_float8(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_float8(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(double), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(double), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(double))
+       if (buff_size < sizeof(double))
                return -2;
 
-       CopyAppendFmt("%.12lf", *(double*)buffer);
+       CopyAppendFmt("%.12lf", *(double *) buffer);
        *out_size = sizeof(double) + delta;
        return 0;
 }
 
 /* Decode an uuid type */
 static int
-decode_uuid(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_uuid(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
        unsigned char uuid[16];
 
-       if(buff_size < sizeof(uuid))
+       if (buff_size < sizeof(uuid))
                return -1;
 
        memcpy(uuid, buffer, sizeof(uuid));
        CopyAppendFmt("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-                       uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
-                       uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]
+                                 uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
+                                 uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]
                );
        *out_size = sizeof(uuid);
        return 0;
@@ -635,24 +711,24 @@ decode_uuid(const char* buffer, unsigned int buff_size, unsigned int* out_size)
 
 /* Decode a macaddr type */
 static int
-decode_macaddr(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_macaddr(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
        unsigned char macaddr[6];
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(int32), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(int32), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < sizeof(macaddr))
+       if (buff_size < sizeof(macaddr))
                return -2;
 
        memcpy(macaddr, buffer, sizeof(macaddr));
        CopyAppendFmt("%02x:%02x:%02x:%02x:%02x:%02x",
-                       macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]
+                                 macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]
                );
        *out_size = sizeof(macaddr) + delta;
        return 0;
@@ -660,30 +736,30 @@ decode_macaddr(const char* buffer, unsigned int buff_size, unsigned int* out_siz
 
 /* Decode a bool type */
 static int
-decode_bool(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_bool(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       if(buff_size < sizeof(bool))
+       if (buff_size < sizeof(bool))
                return -1;
 
-       CopyAppend(*(bool*)buffer ? "t" : "f");
+       CopyAppend(*(bool *) buffer ? "t" : "f");
        *out_size = sizeof(bool);
        return 0;
 }
 
 /* Decode a name type (used mostly in catalog tables) */
 static int
-decode_name(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_name(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       const char* new_buffer = (const char*)TYPEALIGN(sizeof(uint32), (uintptr_t)buffer);
-       unsigned int delta = (unsigned int)( (uintptr_t)new_buffer - (uintptr_t)buffer );
+       const char *new_buffer = (const char *) TYPEALIGN(sizeof(uint32), (uintptr_t) buffer);
+       unsigned int delta = (unsigned int) ((uintptr_t) new_buffer - (uintptr_t) buffer);
 
-       if(buff_size < delta)
+       if (buff_size < delta)
                return -1;
 
        buff_size -= delta;
        buffer = new_buffer;
 
-       if(buff_size < NAMEDATALEN)
+       if (buff_size < NAMEDATALEN)
                return -2;
 
        CopyAppendEncode(buffer, strnlen(buffer, NAMEDATALEN));
@@ -693,9 +769,9 @@ decode_name(const char* buffer, unsigned int buff_size, unsigned int* out_size)
 
 /* Decode a char type */
 static int
-decode_char(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_char(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       if(buff_size < sizeof(char))
+       if (buff_size < sizeof(char))
                return -2;
 
        CopyAppendEncode(buffer, 1);
@@ -705,7 +781,7 @@ decode_char(const char* buffer, unsigned int buff_size, unsigned int* out_size)
 
 /* Ignore all data left */
 static int
-decode_ignore(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_ignore(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
        *out_size = buff_size;
        return 0;
@@ -713,14 +789,14 @@ decode_ignore(const char* buffer, unsigned int buff_size, unsigned int* out_size
 
 /* Decode char(N), varchar(N), text, json or xml types */
 static int
-decode_string(const char* buffer, unsigned int buff_size, unsigned int* out_size)
+decode_string(const char *buffer, unsigned int buff_size, unsigned int *out_size)
 {
-       int padding = 0;
+       int                     padding = 0;
 
        /* Skip padding bytes. */
-       while(*buffer == 0x00)
+       while (*buffer == 0x00)
        {
-               if(buff_size == 0)
+               if (buff_size == 0)
                        return -1;
 
                buff_size--;
@@ -728,14 +804,15 @@ decode_string(const char* buffer, unsigned int buff_size, unsigned int* out_size
                padding++;
        }
 
-       if(VARATT_IS_1B_E(buffer))
+       if (VARATT_IS_1B_E(buffer))
        {
                /*
                 * 00000001 1-byte length word, unaligned, TOAST pointer
                 */
-               uint8 tag = VARTAG_1B_E(buffer);
-               uint32 len = VARTAG_SIZE(tag);
-               if(len > buff_size)
+               uint8           tag = VARTAG_1B_E(buffer);
+               uint32          len = VARTAG_SIZE(tag);
+
+               if (len > buff_size)
                        return -1;
 
                CopyAppend("(TOASTED)");
@@ -743,14 +820,15 @@ decode_string(const char* buffer, unsigned int buff_size, unsigned int* out_size
                return 0;
        }
 
-       if(VARATT_IS_1B(buffer))
+       if (VARATT_IS_1B(buffer))
        {
                /*
-                * xxxxxxx1 1-byte length word, unaligned, uncompressed data (up to 126b)
-                * xxxxxxx is 1 + string length
+                * xxxxxxx1 1-byte length word, unaligned, uncompressed data (up to
+                * 126b) xxxxxxx is 1 + string length
                 */
-               uint8 len = VARSIZE_1B(buffer);
-               if(len > buff_size)
+               uint8           len = VARSIZE_1B(buffer);
+
+               if (len > buff_size)
                        return -1;
 
                CopyAppendEncode(buffer + 1, len - 1);
@@ -758,13 +836,14 @@ decode_string(const char* buffer, unsigned int buff_size, unsigned int* out_size
                return 0;
        }
 
-       if(VARATT_IS_4B_U(buffer) && buff_size >= 4)
+       if (VARATT_IS_4B_U(buffer) && buff_size >= 4)
        {
                /*
                 * xxxxxx00 4-byte length word, aligned, uncompressed data (up to 1G)
                 */
-               uint32 len = VARSIZE_4B(buffer);
-               if(len > buff_size)
+               uint32          len = VARSIZE_4B(buffer);
+
+               if (len > buff_size)
                        return -1;
 
                CopyAppendEncode(buffer + 4, len - 4);
@@ -772,32 +851,32 @@ decode_string(const char* buffer, unsigned int buff_size, unsigned int* out_size
                return 0;
        }
 
-       if(VARATT_IS_4B_C(buffer) && buff_size >= 8)
+       if (VARATT_IS_4B_C(buffer) && buff_size >= 8)
        {
                /*
                 * xxxxxx10 4-byte length word, aligned, *compressed* data (up to 1G)
                 */
-               int decompress_ret;
-               uint32 len = VARSIZE_4B(buffer);
-               uint32 decompressed_len = VARRAWSIZE_4B_C(buffer);
+               int                     decompress_ret;
+               uint32          len = VARSIZE_4B(buffer);
+               uint32          decompressed_len = VARRAWSIZE_4B_C(buffer);
 
-               if(len > buff_size)
+               if (len > buff_size)
                        return -1;
 
-               if(decompressed_len > sizeof(decompress_tmp_buff))
+               if (decompressed_len > sizeof(decompress_tmp_buff))
                {
                        printf("WARNING: Unable to decompress a string since it's too "
-                               "large (%d bytes after decompressing). Consider increasing "
-                               "decompress_tmp_buff size.\n", decompressed_len);
+                                  "large (%d bytes after decompressing). Consider increasing "
+                                  "decompress_tmp_buff size.\n", decompressed_len);
 
                        CopyAppend("(COMPRESSED)");
                        *out_size = padding + len;
                        return 0;
                }
 
-               decompress_ret = pglz_decompress(VARDATA_4B_C(buffer), len - 2*sizeof(uint32),
-                                                       decompress_tmp_buff, decompressed_len);
-               if((decompress_ret != decompressed_len) || (decompress_ret < 0))
+               decompress_ret = pglz_decompress(VARDATA_4B_C(buffer), len - 2 * sizeof(uint32),
+                                                                                decompress_tmp_buff, decompressed_len);
+               if ((decompress_ret != decompressed_len) || (decompress_ret < 0))
                {
                        printf("WARNING: Unable to decompress a string. Data is corrupted.\n");
                        CopyAppend("(COMPRESSED)");
@@ -821,38 +900,38 @@ decode_string(const char* buffer, unsigned int buff_size, unsigned int* out_size
  *   tupleSize   - tuple size in bytes
  */
 void
-FormatDecode(const chartupleData, unsigned int tupleSize)
+FormatDecode(const char *tupleData, unsigned int tupleSize)
 {
-       HeapTupleHeader header = (HeapTupleHeader)tupleData;
-       const chardata = tupleData + header->t_hoff;
+       HeapTupleHeader header = (HeapTupleHeader) tupleData;
+       const char *data = tupleData + header->t_hoff;
        unsigned int size = tupleSize - header->t_hoff;
-       int curr_attr;
+       int                     curr_attr;
 
        CopyClear();
 
-       for(curr_attr = 0; curr_attr < ncallbacks; curr_attr++)
+       for (curr_attr = 0; curr_attr < ncallbacks; curr_attr++)
        {
-               int ret;
+               int                     ret;
                unsigned int processed_size = 0;
 
-               if( (header->t_infomask & HEAP_HASNULL) && att_isnull(curr_attr, header->t_bits) )
+               if ((header->t_infomask & HEAP_HASNULL) && att_isnull(curr_attr, header->t_bits))
                {
                        CopyAppend("\\N");
                        continue;
                }
 
-               if(size <= 0)
+               if (size <= 0)
                {
                        printf("Error: unable to decode a tuple, no more bytes left. Partial data: %s\n",
-                               copyString.data);
+                                  copyString.data);
                        return;
                }
 
-               ret = callbacks[curr_attr](data, size, &processed_size);
-               if(ret < 0)
+               ret = callbacks[curr_attr] (data, size, &processed_size);
+               if (ret < 0)
                {
                        printf("Error: unable to decode a tuple, callback #%d returned %d. Partial data: %s\n",
-                                curr_attr+1, ret, copyString.data);
+                                  curr_attr + 1, ret, copyString.data);
                        return;
                }
 
@@ -860,10 +939,10 @@ FormatDecode(const char* tupleData, unsigned int tupleSize)
                data += processed_size;
        }
 
-       if(size != 0)
+       if (size != 0)
        {
                printf("Error: unable to decode a tuple, %d bytes left, 0 expected. Partial data: %s\n",
-                       size, copyString.data);
+                          size, copyString.data);
                return;
        }
 
index a91b88338f8a11f7cbe9ffef9aeb4b34dafbae52..5fec45fb34ba333aeee139d652c533d377dd74e8 100644 (file)
--- a/decode.h
+++ b/decode.h
@@ -2,9 +2,9 @@
 #define _PG_FILEDUMP_DECODE_H_
 
 int
-ParseAttributeTypesString(const charstr);
+ParseAttributeTypesString(const char *str);
 
 void
-FormatDecode(const chartupleData, unsigned int tupleSize);
+FormatDecode(const char *tupleData, unsigned int tupleSize);
 
 #endif
index e704214f4875c2c57c9be63865756e5d172ef170..7c41b1d6f91f21e1c6801ef3b0d63d1ace19dab9 100644 (file)
@@ -34,7 +34,7 @@
 #include "storage/checksum_impl.h"
 #include "decode.h"
 
-/***
+/*
  * Global variables for ease of use mostly
  */
 
@@ -69,9 +69,9 @@ static unsigned int bytesToFormat = 0;
 static unsigned int blockVersion = 0;
 
 /* Program exit code */
-static int exitCode = 0;
+static int     exitCode = 0;
 
-/***
+/*
  * Function Prototypes
  */
 static void DisplayOptions(unsigned int validOptions);
@@ -93,7 +93,7 @@ static void DumpBinaryBlock();
 static void DumpFileContents();
 
 
-/*     Send properly formed usage information to the user. */
+/* Send properly formed usage information to the user. */
 static void
 DisplayOptions(unsigned int validOptions)
 {
@@ -148,30 +148,30 @@ DisplayOptions(unsigned int validOptions)
  * name is /path/to/xxxx.7 procedure returns 7. Default return value is 0.
  */
 static unsigned int
-GetSegmentNumberFromFileName(const charfileName)
+GetSegmentNumberFromFileName(const char *fileName)
 {
-       int segnumOffset = strlen(fileName) - 1;
+       int                     segnumOffset = strlen(fileName) - 1;
 
-       if(segnumOffset < 0)
+       if (segnumOffset < 0)
                return 0;
 
-       while(isdigit(fileName[segnumOffset]))
+       while (isdigit(fileName[segnumOffset]))
        {
                segnumOffset--;
-               if(segnumOffset < 0)
+               if (segnumOffset < 0)
                        return 0;
        }
 
-       if(fileName[segnumOffset] != '.')
+       if (fileName[segnumOffset] != '.')
                return 0;
 
-    return atoi(&fileName[segnumOffset+1]);
+       return atoi(&fileName[segnumOffset + 1]);
 }
 
-/*     Iterate through the provided options and set the option flags. */
-/*     An error will result in a positive rc and will force a display */
-/*     of the usage information.  This routine returns enum */
-/*     optionReturnCode values. */
+/*     Iterate through the provided options and set the option flags.
+ *     An error will result in a positive rc and will force a display
+ *     of the usage information.  This routine returns enum
+ *     optionReturnCode values. */
 static unsigned int
 ConsumeOptions(int numOptions, char **options)
 {
@@ -186,8 +186,8 @@ ConsumeOptions(int numOptions, char **options)
                optionString = options[x];
                optionStringLength = strlen(optionString);
 
-               /* Range is a special case where we have to consume the next 1 or 2 */
-               /* parameters to mark the range start and end */
+               /* Range is a special case where we have to consume the next 1 or 2
+                * parameters to mark the range start and end */
                if ((optionStringLength == 2) && (strcmp(optionString, "-R") == 0))
                {
                        int                     range = 0;
@@ -208,9 +208,8 @@ ConsumeOptions(int numOptions, char **options)
 
                        /*
                         * Mark that we have the range and advance the option to what
-                        * should
-                        */
-                       /* be the range start. Check the value of the next parameter */
+                        * should be the range start. Check the value of the next
+                        * parameter */
                        optionString = options[++x];
                        if ((range = GetOptionValue(optionString)) < 0)
                        {
@@ -224,10 +223,10 @@ ConsumeOptions(int numOptions, char **options)
                        /* The default is to dump only one block */
                        blockStart = blockEnd = (unsigned int) range;
 
-                       /* We have our range start marker, check if there is an end */
-                       /* marker on the option line.  Assume that the last option */
-                       /* is the file we are dumping, so check if there are options */
-                       /* range start marker and the file */
+                       /* We have our range start marker, check if there is an end
+                        * marker on the option line.  Assume that the last option
+                        * is the file we are dumping, so check if there are options
+                        * range start marker and the file */
                        if (x <= (numOptions - 3))
                        {
                                if ((range = GetOptionValue(options[x + 1])) >= 0)
@@ -249,9 +248,9 @@ ConsumeOptions(int numOptions, char **options)
                                }
                        }
                }
-               /* Check for the special case where the user forces a block size */
-               /* instead of having the tool determine it.  This is useful if */
-               /* the header of block 0 is corrupt and gives a garbage block size */
+               /* Check for the special case where the user forces a block size
+                * instead of having the tool determine it.  This is useful if
+                * the header of block 0 is corrupt and gives a garbage block size */
                else if ((optionStringLength == 2)
                                 && (strcmp(optionString, "-S") == 0))
                {
@@ -317,8 +316,8 @@ ConsumeOptions(int numOptions, char **options)
                        }
                }
                /* Check for the special case where the user forces tuples decoding. */
-               else if((optionStringLength == 2)
-                               && (strcmp(optionString, "-D") == 0))
+               else if ((optionStringLength == 2)
+                                && (strcmp(optionString, "-D") == 0))
                {
                        SET_OPTION(blockOptions, BLOCK_DECODE, 'D');
                        /* Only accept the decode option once */
@@ -337,7 +336,7 @@ ConsumeOptions(int numOptions, char **options)
                        /* Next option encountered must be attribute types string */
                        optionString = options[++x];
 
-                       if(ParseAttributeTypesString(optionString) < 0)
+                       if (ParseAttributeTypesString(optionString) < 0)
                        {
                                rc = OPT_RC_INVALID;
                                printf("Error: Invalid attribute types string <%s>.\n",
@@ -346,8 +345,8 @@ ConsumeOptions(int numOptions, char **options)
                                break;
                        }
                }
-               /* Check for the special case where the user forces a segment number */
-               /* instead of having the tool determine it by file name. */
+               /* Check for the special case where the user forces a segment number
+                * instead of having the tool determine it by file name. */
                else if ((optionStringLength == 2)
                                 && (strcmp(optionString, "-n") == 0))
                {
@@ -390,7 +389,7 @@ ConsumeOptions(int numOptions, char **options)
                                if (fp)
                                {
                                        fileName = options[x];
-                                       if(!(segmentOptions & SEGMENT_NUMBER_FORCED))
+                                       if (!(segmentOptions & SEGMENT_NUMBER_FORCED))
                                                segmentNumber = GetSegmentNumberFromFileName(fileName);
                                }
                                else
@@ -403,8 +402,8 @@ ConsumeOptions(int numOptions, char **options)
                        }
                        else
                        {
-                               /* Could be the case where the help flag is used without a */
-                               /* filename. Otherwise, the last option isn't a file */
+                               /* Could be the case where the help flag is used without a
+                                * filename. Otherwise, the last option isn't a file */
                                if (strcmp(optionString, "-h") == 0)
                                        rc = OPT_RC_COPYRIGHT;
                                else
@@ -429,8 +428,8 @@ ConsumeOptions(int numOptions, char **options)
                                break;
                        }
 
-                       /* Iterate through the singular option string, throw out */
-                       /* garbage, duplicates and set flags to be used in formatting */
+                       /* Iterate through the singular option string, throw out
+                        * garbage, duplicates and set flags to be used in formatting */
                        for (y = 1; y < optionStringLength; y++)
                        {
                                switch (optionString[y])
@@ -457,9 +456,7 @@ ConsumeOptions(int numOptions, char **options)
 
                                                /*
                                                 * Format the contents of the block with
-                                                * interpretation
-                                                */
-                                               /* of the headers */
+                                                * interpretation of the headers */
                                        case 'f':
                                                SET_OPTION(blockOptions, BLOCK_FORMAT, 'f');
                                                break;
@@ -522,9 +519,9 @@ ConsumeOptions(int numOptions, char **options)
                exitCode = 1;
        }
 
-       /* If the user requested a control file dump, a pure binary */
-       /* block dump or a non-interpreted formatted dump, mask off */
-       /* all other block level options (with a few exceptions) */
+       /* If the user requested a control file dump, a pure binary
+        * block dump or a non-interpreted formatted dump, mask off
+        * all other block level options (with a few exceptions) */
        if (rc == OPT_RC_VALID)
        {
                /* The user has requested a control file dump, only -f and */
@@ -546,15 +543,15 @@ ConsumeOptions(int numOptions, char **options)
                                blockOptions = itemOptions = 0;
                        }
                }
-               /* The user has requested a binary block dump... only -R and */
-               /* -f are honoured */
+               /* The user has requested a binary block dump... only -R and -f
+                * are honoured */
                else if (blockOptions & BLOCK_BINARY)
                {
                        blockOptions &= (BLOCK_BINARY | BLOCK_RANGE | BLOCK_FORCED);
                        itemOptions = 0;
                }
-               /* The user has requested a non-interpreted dump... only -a, */
-               /* -R and -f are honoured */
+               /* The user has requested a non-interpreted dump... only -a, -R
+                * and -f are honoured */
                else if (blockOptions & BLOCK_NO_INTR)
                {
                        blockOptions &=
@@ -566,8 +563,8 @@ ConsumeOptions(int numOptions, char **options)
        return (rc);
 }
 
-/*     Given the index into the parameter list, convert and return the */
-/*     current string to a number if possible */
+/* Given the index into the parameter list, convert and return the
+ * current string to a number if possible */
 static int
 GetOptionValue(char *optionString)
 {
@@ -587,9 +584,9 @@ GetOptionValue(char *optionString)
        return (value);
 }
 
-/*     Read the page header off of block 0 to determine the block size */
-/*     used in this file.  Can be overridden using the -S option.  The */
-/*     returned value is the block size of block 0 on disk */
+/* Read the page header off of block 0 to determine the block size
+ * used in this file.  Can be overridden using the -S option. The
+ * returned value is the block size of block 0 on disk */
 static unsigned int
 GetBlockSize()
 {
@@ -614,8 +611,8 @@ GetBlockSize()
        return (localSize);
 }
 
-/*     Determine the contents of the special section on the block and */
-/*     return this enum value */
+/* Determine the contents of the special section on the block and
+ * return this enum value */
 static unsigned int
 GetSpecialSectionType(Page page)
 {
@@ -625,14 +622,14 @@ GetSpecialSectionType(Page page)
        unsigned int specialValue;
        PageHeader      pageHeader = (PageHeader) page;
 
-       /* If this is not a partial header, check the validity of the */
-       /* special section offset and contents */
+       /* If this is not a partial header, check the validity of the
+        * special section offset and contents */
        if (bytesToFormat > sizeof(PageHeaderData))
        {
                specialOffset = (unsigned int) pageHeader->pd_special;
 
-               /* Check that the special offset can remain on the block or */
-               /* the partial block */
+               /* Check that the special offset can remain on the block or
+                * the partial block */
                if ((specialOffset == 0) ||
                        (specialOffset > blockSize) || (specialOffset > bytesToFormat))
                        rc = SPEC_SECT_ERROR_BOUNDARY;
@@ -643,16 +640,16 @@ GetSpecialSectionType(Page page)
 
                        specialSize = blockSize - specialOffset;
 
-                       /* If there is a special section, use its size to guess its */
-                       /* contents, checking the last 2 bytes of the page in cases */
-                       /* that are ambiguous.  Note we don't attempt to dereference */
-                       /* the pointers without checking bytesToFormat == blockSize. */
+                       /* If there is a special section, use its size to guess its
+                        * contents, checking the last 2 bytes of the page in cases
+                        * that are ambiguous.  Note we don't attempt to dereference
+                        * the pointers without checking bytesToFormat == blockSize. */
                        if (specialSize == 0)
                                rc = SPEC_SECT_NONE;
                        else if (specialSize == MAXALIGN(sizeof(uint32)))
                        {
-                               /* If MAXALIGN is 8, this could be either a sequence or */
-                               /* SP-GiST or GIN. */
+                               /* If MAXALIGN is 8, this could be either a sequence or
+                                * SP-GiST or GIN. */
                                if (bytesToFormat == blockSize)
                                {
                                        specialValue = *((int *) (buffer + specialOffset));
@@ -669,8 +666,8 @@ GetSpecialSectionType(Page page)
                                else
                                        rc = SPEC_SECT_ERROR_UNKNOWN;
                        }
-                       /* SP-GiST and GIN have same size special section, so check */
-                       /* the page ID bytes first. */
+                       /* SP-GiST and GIN have same size special section, so check
+                        * the page ID bytes first. */
                        else if (specialSize == MAXALIGN(sizeof(SpGistPageOpaqueData)) &&
                                         bytesToFormat == blockSize &&
                                         *ptype == SPGIST_PAGE_ID)
@@ -679,9 +676,9 @@ GetSpecialSectionType(Page page)
                                rc = SPEC_SECT_INDEX_GIN;
                        else if (specialSize > 2 && bytesToFormat == blockSize)
                        {
-                               /* As of 8.3, BTree, Hash, and GIST all have the same size */
-                               /* special section, but the last two bytes of the section */
-                               /* can be checked to determine what's what. */
+                               /* As of 8.3, BTree, Hash, and GIST all have the same size
+                                * special section, but the last two bytes of the section
+                                * can be checked to determine what's what. */
                                if (*ptype <= MAX_BT_CYCLE_ID &&
                                        specialSize == MAXALIGN(sizeof(BTPageOpaqueData)))
                                        rc = SPEC_SECT_INDEX_BTREE;
@@ -724,8 +721,8 @@ IsBtreeMetaPage(Page page)
        return false;
 }
 
-/*     Display a header for the dump so we know the file name, the options */
-/*     used and the time the dump was taken */
+/* Display a header for the dump so we know the file name, the options
+ * used and the time the dump was taken */
 static void
 CreateDumpFileHeader(int numOptions, char **options)
 {
@@ -733,8 +730,8 @@ CreateDumpFileHeader(int numOptions, char **options)
        char            optionBuffer[52] = "\0";
        time_t          rightNow = time(NULL);
 
-       /* Iterate through the options and cache them. */
-       /* The maximum we can display is 50 option characters + spaces. */
+       /* Iterate through the options and cache them.
+        * The maximum we can display is 50 option characters + spaces. */
        for (x = 1; x < (numOptions - 1); x++)
        {
                if ((strlen(optionBuffer) + strlen(options[x])) > 50)
@@ -750,7 +747,7 @@ CreateDumpFileHeader(int numOptions, char **options)
                 "* File: %s\n"
                 "* Options used: %s\n*\n"
                 "* Dump created on: %s"
-        "*******************************************************************\n",
+                "*******************************************************************\n",
                 FD_VERSION, fileName, (strlen(optionBuffer)) ? optionBuffer : "None",
                 ctime(&rightNow));
 }
@@ -765,8 +762,8 @@ FormatHeader(Page page, BlockNumber blkno)
 
        printf("<Header> -----\n");
 
-       /* Only attempt to format the header if the entire header (minus the item */
-       /* array) is available */
+       /* Only attempt to format the header if the entire header (minus the item
+        * array) is available */
        if (bytesToFormat < offsetof(PageHeaderData, pd_linp[0]))
        {
                headerBytes = bytesToFormat;
@@ -781,8 +778,8 @@ FormatHeader(Page page, BlockNumber blkno)
                headerBytes = offsetof(PageHeaderData, pd_linp[0]);
                blockVersion = (unsigned int) PageGetPageLayoutVersion(page);
 
-               /* The full header exists but we have to check that the item array */
-               /* is available or how far we can index into it */
+               /* The full header exists but we have to check that the item array
+                * is available or how far we can index into it */
                if (maxOffset > 0)
                {
                        unsigned int itemsLength = maxOffset * sizeof(ItemIdData);
@@ -809,7 +806,7 @@ FormatHeader(Page page, BlockNumber blkno)
                /* Interpret the content of the header */
                printf
                        (" Block Offset: 0x%08x         Offsets: Lower    %4u (0x%04hx)\n"
-                 " Block: Size %4d  Version %4u            Upper    %4u (0x%04hx)\n"
+                        " Block: Size %4d  Version %4u            Upper    %4u (0x%04hx)\n"
                         " LSN:  logid %6d recoff 0x%08x      Special  %4u (0x%04hx)\n"
                         " Items: %4d                      Free Space: %4u\n"
                         " Checksum: 0x%04x  Prune XID: 0x%08x  Flags: 0x%04x (%s)\n"
@@ -838,8 +835,8 @@ FormatHeader(Page page, BlockNumber blkno)
                        headerBytes += sizeof(BTMetaPageData);
                }
 
-               /* Eye the contents of the header and alert the user to possible */
-               /* problems. */
+               /* Eye the contents of the header and alert the user to possible 
+                * problems. */
                if ((maxOffset < 0) ||
                        (maxOffset > blockSize) ||
                        (blockVersion != PG_PAGE_LAYOUT_VERSION) || /* only one we support */
@@ -857,8 +854,8 @@ FormatHeader(Page page, BlockNumber blkno)
 
                if (blockOptions & BLOCK_CHECKSUMS)
                {
-                       uint32  delta = (segmentSize/blockSize)*segmentNumber;
-                       uint16  calc_checksum = pg_checksum_page(page, delta + blkno);
+                       uint32          delta = (segmentSize / blockSize) * segmentNumber;
+                       uint16          calc_checksum = pg_checksum_page(page, delta + blkno);
 
                        if (calc_checksum != pageHeader->pd_checksum)
                        {
@@ -869,8 +866,8 @@ FormatHeader(Page page, BlockNumber blkno)
                }
        }
 
-       /* If we have reached the end of file while interpreting the header, let */
-       /* the user know about it */
+       /* If we have reached the end of file while interpreting the header, let
+        * the user know about it */
        if (rc == EOF_ENCOUNTERED)
        {
                printf
@@ -879,9 +876,9 @@ FormatHeader(Page page, BlockNumber blkno)
                exitCode = 1;
        }
 
-       /* A request to dump the formatted binary of the block (header, */
-       /* items and special section).  It's best to dump even on an error */
-       /* so the user can see the raw image. */
+       /* A request to dump the formatted binary of the block (header,
+        * items and special section).  It's best to dump even on an error
+        * so the user can see the raw image. */
        if (blockOptions & BLOCK_FORMAT)
                FormatBinary(headerBytes, 0);
 
@@ -899,16 +896,16 @@ FormatItemBlock(Page page)
        ItemId          itemId;
        int                     maxOffset = PageGetMaxOffsetNumber(page);
 
-       /* If it's a btree meta page, the meta block is where items would normally */
-       /* be; don't print garbage. */
+       /* If it's a btree meta page, the meta block is where items would normally
+        * be; don't print garbage. */
        if (IsBtreeMetaPage(page))
                return;
 
        printf("<Data> ------ \n");
 
-       /* Loop through the items on the block.  Check if the block is */
-       /* empty and has a sensible item array listed before running */
-       /* through each item */
+       /* Loop through the items on the block.  Check if the block is
+        * empty and has a sensible item array listed before running
+        * through each item */
        if (maxOffset == 0)
                printf(" Empty block - no items listed \n\n");
        else if ((maxOffset < 0) || (maxOffset > blockSize))
@@ -922,8 +919,8 @@ FormatItemBlock(Page page)
                int                     formatAs;
                char            textFlags[16];
 
-               /* First, honour requests to format items a special way, then */
-               /* use the special section to determine the format style */
+               /* First, honour requests to format items a special way, then
+                * use the special section to determine the format style */
                if (itemOptions & ITEM_INDEX)
                        formatAs = ITEM_INDEX;
                else if (itemOptions & ITEM_HEAP)
@@ -985,20 +982,20 @@ FormatItemBlock(Page page)
                                   "  Flags: %s\n", x, itemSize, itemOffset, itemOffset,
                                   textFlags);
 
-                       /* Make sure the item can physically fit on this block before */
-                       /* formatting */
+                       /* Make sure the item can physically fit on this block before
+                        * formatting */
                        if ((itemOffset + itemSize > blockSize) ||
                                (itemOffset + itemSize > bytesToFormat))
                        {
                                printf("  Error: Item contents extend beyond block.\n"
-                                  "         BlockSize<%d> Bytes Read<%d> Item Start<%d>.\n",
+                                          "         BlockSize<%d> Bytes Read<%d> Item Start<%d>.\n",
                                           blockSize, bytesToFormat, itemOffset + itemSize);
                                exitCode = 1;
                        }
                        else
                        {
-                               /* If the user requests that the items be interpreted as */
-                               /* heap or index items... */
+                               /* If the user requests that the items be interpreted as
+                                * heap or index items... */
                                if (itemOptions & ITEM_DETAIL)
                                        FormatItem(itemSize, itemOffset, formatAs);
 
@@ -1007,7 +1004,7 @@ FormatItemBlock(Page page)
                                        FormatBinary(itemSize, itemOffset);
 
                                /* Decode tuple data */
-                               if((blockOptions & BLOCK_DECODE) && (itemFlags == LP_NORMAL))
+                               if ((blockOptions & BLOCK_DECODE) && (itemFlags == LP_NORMAL))
                                        FormatDecode(&buffer[itemOffset], itemSize);
 
                                if (x == maxOffset)
@@ -1017,8 +1014,8 @@ FormatItemBlock(Page page)
        }
 }
 
-/*     Interpret the contents of the item based on whether it has a special */
-/*     section and/or the user has hinted */
+/* Interpret the contents of the item based on whether it has a special
+ * section and/or the user has hinted */
 static void
 FormatItem(unsigned int numBytes, unsigned int startIndex,
                   unsigned int formatAs)
@@ -1057,7 +1054,7 @@ FormatItem(unsigned int numBytes, unsigned int startIndex,
                        if (numBytes != IndexTupleSize(itup))
                        {
                                printf("  Error: Item size difference. Given <%u>, "
-                                  "Internal <%d>.\n", numBytes, (int) IndexTupleSize(itup));
+                                          "Internal <%d>.\n", numBytes, (int) IndexTupleSize(itup));
                                exitCode = 1;
                        }
                }
@@ -1200,14 +1197,14 @@ FormatItem(unsigned int numBytes, unsigned int startIndex,
                                           HeapTupleHeaderGetOid(htup));
 
                        printf("\n"
-                         "  Block Id: %u  linp Index: %u   Attributes: %d   Size: %d\n",
+                                  "  Block Id: %u  linp Index: %u   Attributes: %d   Size: %d\n",
                                   ((uint32)
                                        ((htup->t_ctid.ip_blkid.bi_hi << 16) | (uint16) htup->
                                         t_ctid.ip_blkid.bi_lo)), htup->t_ctid.ip_posid,
                                   localNatts, htup->t_hoff);
 
-                       /* Place readable versions of the tuple info mask into a buffer. */
-                       /* Assume that the string can not expand beyond 256. */
+                       /* Place readable versions of the tuple info mask into a buffer.
+                        * Assume that the string can not expand beyond 256. */
                        flagString[0] = '\0';
                        if (infoMask & HEAP_HASNULL)
                                strcat(flagString, "HASNULL|");
@@ -1254,8 +1251,8 @@ FormatItem(unsigned int numBytes, unsigned int startIndex,
 
                        printf("  infomask: 0x%04x (%s) \n", infoMask, flagString);
 
-                       /* As t_bits is a variable length array, determine the length of */
-                       /* the header proper */
+                       /* As t_bits is a variable length array, determine the length of
+                        * the header proper */
                        if (infoMask & HEAP_HASNULL)
                                bitmapLength = BITMAPLEN(localNatts);
                        else
@@ -1267,10 +1264,8 @@ FormatItem(unsigned int numBytes, unsigned int startIndex,
                        computedLength =
                                MAXALIGN(localBitOffset + bitmapLength + oidLength);
 
-                       /*
-                        * Inform the user of a header size mismatch or dump the t_bits
-                        * array
-                        */
+                       /* Inform the user of a header size mismatch or dump the t_bits
+                        * array */
                        if (computedLength != localHoff)
                        {
                                printf
@@ -1297,8 +1292,8 @@ FormatItem(unsigned int numBytes, unsigned int startIndex,
 }
 
 
-/*     On blocks that have special sections, print the contents */
-/*     according to previously determined special section type */
+/* On blocks that have special sections, print the contents
+ * according to previously determined special section type */
 static void
 FormatSpecial()
 {
@@ -1381,7 +1376,7 @@ FormatSpecial()
                                           "  Blocks: Previous (%d)  Next (%d)\n\n",
                                           hashSection->hasho_flag, flagString,
                                           hashSection->hasho_bucket,
-                                hashSection->hasho_prevblkno, hashSection->hasho_nextblkno);
+                                          hashSection->hasho_prevblkno, hashSection->hasho_nextblkno);
                        }
                        break;
 
@@ -1503,16 +1498,16 @@ FormatBlock(BlockNumber blkno)
                   (bytesToFormat ==
                        blockSize) ? "***************" : " PARTIAL BLOCK ");
 
-       /* Either dump out the entire block in hex+acsii fashion or */
-       /* interpret the data based on block structure */
+       /* Either dump out the entire block in hex+acsii fashion or
+        * interpret the data based on block structure */
        if (blockOptions & BLOCK_NO_INTR)
                FormatBinary(bytesToFormat, 0);
        else
        {
                int                     rc;
 
-               /* Every block contains a header, items and possibly a special */
-               /* section.  Beware of partial block reads though */
+               /* Every block contains a header, items and possibly a special
+                * section.  Beware of partial block reads though */
                rc = FormatHeader(page, blkno);
 
                /* If we didn't encounter a partial read in the header, carry on... */
@@ -1603,16 +1598,16 @@ FormatControl()
                           "            System Identifier: " UINT64_FORMAT "\n"
                           "                        State: %s\n"
                           "                Last Mod Time: %s"
-                        "       Last Checkpoint Record: Log File (%u) Offset (0x%08x)\n"
-                        "   Previous Checkpoint Record: Log File (%u) Offset (0x%08x)\n"
-                        "  Last Checkpoint Record Redo: Log File (%u) Offset (0x%08x)\n"
+                          "       Last Checkpoint Record: Log File (%u) Offset (0x%08x)\n"
+                          "   Previous Checkpoint Record: Log File (%u) Offset (0x%08x)\n"
+                          "  Last Checkpoint Record Redo: Log File (%u) Offset (0x%08x)\n"
                           "             |-    TimeLineID: %u\n"
                           "             |-      Next XID: %u/%u\n"
                           "             |-      Next OID: %u\n"
                           "             |-    Next Multi: %u\n"
                           "             |- Next MultiOff: %u\n"
                           "             |-          Time: %s"
-                        "       Minimum Recovery Point: Log File (%u) Offset (0x%08x)\n"
+                          "       Minimum Recovery Point: Log File (%u) Offset (0x%08x)\n"
                           "       Maximum Data Alignment: %u\n"
                           "        Floating-Point Sample: %.7g%s\n"
                           "          Database Block Size: %u\n"
@@ -1623,7 +1618,7 @@ FormatControl()
                           "           Maximum Index Keys: %u\n"
                           "             TOAST Chunk Size: %u\n\n",
                           EQ_CRC32C(crcLocal,
-                                               controlData->crc) ? "Correct" : "Not Correct",
+                                                controlData->crc) ? "Correct" : "Not Correct",
                           controlData->pg_control_version,
                           (controlData->pg_control_version == PG_CONTROL_VERSION ?
                                "" : " (Not Correct!)"),
@@ -1658,8 +1653,8 @@ FormatControl()
                           "        Size: Correct <%u>  Received <%u>.\n\n",
                           controlFileSize, bytesToFormat);
 
-               /* If we have an error, force a formatted dump so we can see */
-               /* where things are going wrong */
+               /* If we have an error, force a formatted dump so we can see
+                * where things are going wrong */
                controlOptions |= CONTROL_FORMAT;
 
                exitCode = 1;
@@ -1674,8 +1669,8 @@ FormatControl()
        }
 }
 
-/*     Dump out the contents of the block in hex and ascii. */
-/*     BYTES_PER_LINE bytes are formatted in each line. */
+/* Dump out the contents of the block in hex and ascii.
+ * BYTES_PER_LINE bytes are formatted in each line. */
 static void
 FormatBinary(unsigned int numBytes, unsigned int startIndex)
 {
@@ -1686,8 +1681,8 @@ FormatBinary(unsigned int numBytes, unsigned int startIndex)
 
        if (numBytes)
        {
-               /* Iterate through a printable row detailing the current */
-               /* address, the hex and ascii values */
+               /* Iterate through a printable row detailing the current
+                * address, the hex and ascii values */
                for (index = startIndex; index < lastByte; index += BYTES_PER_LINE)
                {
                        stopIndex = index + BYTES_PER_LINE;
@@ -1724,7 +1719,7 @@ FormatBinary(unsigned int numBytes, unsigned int startIndex)
        }
 }
 
-/*     Dump the binary image of the block */
+/* Dump the binary image of the block */
 static void
 DumpBinaryBlock()
 {
@@ -1734,15 +1729,15 @@ DumpBinaryBlock()
                putchar(buffer[x]);
 }
 
-/*     Control the dumping of the blocks within the file */
+/* Control the dumping of the blocks within the file */
 static void
 DumpFileContents()
 {
        unsigned int initialRead = 1;
        unsigned int contentsToDump = 1;
 
-       /* If the user requested a block range, seek to the correct position */
-       /* within the file for the start block. */
+       /* If the user requested a block range, seek to the correct position
+        * within the file for the start block. */
        if (blockOptions & BLOCK_RANGE)
        {
                unsigned int position = blockSize * blockStart;
@@ -1758,16 +1753,16 @@ DumpFileContents()
                        currentBlock = blockStart;
        }
 
-       /* Iterate through the blocks in the file until you reach the end or */
-       /* the requested range end */
+       /* Iterate through the blocks in the file until you reach the end or
+        * the requested range end */
        while (contentsToDump)
        {
                bytesToFormat = fread(buffer, 1, blockSize, fp);
 
                if (bytesToFormat == 0)
                {
-                       /* fseek() won't pop an error if you seek passed eof.  The next */
-                       /* subsequent read gets the error. */
+                       /* fseek() won't pop an error if you seek passed eof. The next
+                        * subsequent read gets the error. */
                        if (initialRead)
                                printf("Error: Premature end of file encountered.\n");
                        else if (!(blockOptions & BLOCK_BINARY))
@@ -1809,8 +1804,8 @@ DumpFileContents()
        }
 }
 
-/*     Consume the options and iterate through the given file, formatting as */
-/*     requested. */
+/* Consume the options and iterate through the given file, formatting as
+ * requested. */
 int
 main(int argv, char **argc)
 {
@@ -1819,8 +1814,8 @@ main(int argv, char **argc)
 
        validOptions = (argv < 2) ? OPT_RC_COPYRIGHT : ConsumeOptions(argv, argc);
 
-       /* Display valid options if no parameters are received or invalid options */
-       /* where encountered */
+       /* Display valid options if no parameters are received or invalid options
+        * where encountered */
        if (validOptions != OPT_RC_VALID)
                DisplayOptions(validOptions);
        else
@@ -1829,8 +1824,8 @@ main(int argv, char **argc)
                if (!(blockOptions & BLOCK_BINARY))
                        CreateDumpFileHeader(argv, argc);
 
-               /* If the user has not forced a block size, use the size of the */
-               /* control file data or the information from the block 0 header */
+               /* If the user has not forced a block size, use the size of the
+                * control file data or the information from the block 0 header */
                if (controlOptions)
                {
                        if (!(controlOptions & CONTROL_FORCED))
@@ -1839,8 +1834,8 @@ main(int argv, char **argc)
                else if (!(blockOptions & BLOCK_FORCED))
                        blockSize = GetBlockSize();
 
-               /* On a positive block size, allocate a local buffer to store */
-               /* the subsequent blocks */
+               /* On a positive block size, allocate a local buffer to store
+                * the subsequent blocks */
                if (blockSize > 0)
                {
                        buffer = (char *) malloc(blockSize);
index 2e6007f225d5fb6e3c59fa0276cd16b5ba82fb62..0e91f89fa78678c9ec36d1838717fa1558cc8a23 100644 (file)
@@ -62,8 +62,8 @@ static unsigned int segmentOptions = 0;
 typedef enum segmentSwitches
 {
        SEGMENT_SIZE_FORCED = 0x00000001,       /* -s: Segment size forced */
-       SEGMENT_NUMBER_FORCED = 0x00000002,     /* -n: Segment number forced */
-} segmentSwitches;
+       SEGMENT_NUMBER_FORCED = 0x00000002, /* -n: Segment number forced */
+}                      segmentSwitches;
 
 /* -R[start]:Block range start */
 static int     blockStart = -1;
@@ -89,8 +89,8 @@ static unsigned int controlOptions = 0;
 typedef enum controlSwitches
 {
        CONTROL_DUMP = 0x00000001,      /* -c: Dump control file */
-       CONTROL_FORMAT = BLOCK_FORMAT,          /* -f: Formatted dump of control file */
-       CONTROL_FORCED = BLOCK_FORCED           /* -S: Block size forced */
+       CONTROL_FORMAT = BLOCK_FORMAT,  /* -f: Formatted dump of control file */
+       CONTROL_FORCED = BLOCK_FORCED   /* -S: Block size forced */
 } controlSwitches;
 
 /* Possible value types for the Special Section */
@@ -105,13 +105,13 @@ typedef enum specialSectionTypes
        SPEC_SECT_INDEX_SPGIST,         /* SP - GIST index info in special section */
        SPEC_SECT_ERROR_UNKNOWN,        /* Unknown error */
        SPEC_SECT_ERROR_BOUNDARY        /* Boundary error */
-}      specialSectionTypes;
+}                      specialSectionTypes;
 
 static unsigned int specialType = SPEC_SECT_NONE;
 
-/*     Possible return codes from option validation routine. */
-/*     pg_filedump doesn't do much with them now but maybe in */
-/*     the future... */
+/* Possible return codes from option validation routine.
+ * pg_filedump doesn't do much with them now but maybe in
+ * the future... */
 typedef enum optionReturnCodes
 {
        OPT_RC_VALID,                           /* All options are valid */
@@ -119,10 +119,10 @@ typedef enum optionReturnCodes
        OPT_RC_FILE,                            /* File problems */
        OPT_RC_DUPLICATE,                       /* Duplicate option encountered */
        OPT_RC_COPYRIGHT                        /* Copyright should be displayed */
-}      optionReturnCodes;
+}                      optionReturnCodes;
 
-/*     Simple macro to check for duplicate options and then set */
-/*     an option flag for later consumption */
+/* Simple macro to check for duplicate options and then set
+ * an option flag for later consumption */
 #define SET_OPTION(_x,_y,_z) if (_x & _y)                              \
                                                           {                                            \
                                                                 rc = OPT_RC_DUPLICATE; \
index 5ec93ec7a6ba1a2498d7e82bdd85047cda98d83f..67f570c3624e97f44a53c1cf2e33631b8be54c63 100644 (file)
@@ -752,7 +752,7 @@ pglz_decompress(const char *source, int32 slen, char *dest,
                                 * An unset control bit means LITERAL BYTE. So we just copy
                                 * one from INPUT to OUTPUT.
                                 */
-                               if (dp >= destend)              /* check for buffer overrun */
+                               if (dp >= destend)      /* check for buffer overrun */
                                        break;          /* do not clobber memory */
 
                                *dp++ = *sp++;
index 4cdc8c581b9d62061ad9aa1bc6f6229b7506d478..8d54bee47517d67bdc714d94c057cda610813889 100644 (file)
@@ -36,7 +36,7 @@
 void
 initStringInfo(StringInfo str)
 {
-       int              size = 1024;   /* initial default buffer size */
+       int                     size = 1024;    /* initial default buffer size */
 
        str->data = (char *) malloc(size);
        str->maxlen = size;
@@ -111,7 +111,7 @@ enlargeStringInfo(StringInfo str, int needed)
 {
        Size            newlen;
        Size            limit;
-       charold_data;
+       char       *old_data;
 
        limit = MaxAllocSize;
 
@@ -119,7 +119,7 @@ enlargeStringInfo(StringInfo str, int needed)
         * Guard against out-of-range "needed" values.  Without this, we can get
         * an overflow or infinite loop in the following.
         */
-       if (needed < 0)                  /* should not happen */
+       if (needed < 0)                         /* should not happen */
        {
                printf("Error: invalid string enlargement request size: %d", needed);
                exit(1);
@@ -128,16 +128,16 @@ enlargeStringInfo(StringInfo str, int needed)
        if (((Size) needed) >= (limit - (Size) str->len))
        {
                printf("Error: cannot enlarge string buffer containing %d bytes by %d more bytes.",
-                       str->len, needed);
+                          str->len, needed);
                exit(1);
        }
 
-       needed += str->len + 1;  /* total space required now */
+       needed += str->len + 1;         /* total space required now */
 
        /* Because of the above test, we now have needed <= limit */
 
        if (needed <= str->maxlen)
-               return;                          /* got enough space already */
+               return;                                 /* got enough space already */
 
        /*
         * We don't want to allocate just a little more space with each append;
@@ -158,7 +158,7 @@ enlargeStringInfo(StringInfo str, int needed)
 
        old_data = str->data;
        str->data = (char *) realloc(str->data, (Size) newlen);
-       if(str->data == NULL)
+       if (str->data == NULL)
        {
                free(old_data);
                printf("Error: realloc() failed!\n");
@@ -167,4 +167,3 @@ enlargeStringInfo(StringInfo str, int needed)
 
        str->maxlen = newlen;
 }
-