diff options
Diffstat (limited to 'src/port')
-rw-r--r-- | src/port/dirent.c | 46 | ||||
-rw-r--r-- | src/port/getaddrinfo.c | 5 | ||||
-rw-r--r-- | src/port/isinf.c | 3 | ||||
-rw-r--r-- | src/port/open.c | 12 | ||||
-rw-r--r-- | src/port/path.c | 16 | ||||
-rw-r--r-- | src/port/pgsleep.c | 4 | ||||
-rw-r--r-- | src/port/qsort_arg.c | 4 | ||||
-rw-r--r-- | src/port/snprintf.c | 39 | ||||
-rw-r--r-- | src/port/sprompt.c | 4 | ||||
-rw-r--r-- | src/port/strlcpy.c | 23 | ||||
-rw-r--r-- | src/port/strtol.c | 2 |
11 files changed, 85 insertions, 73 deletions
diff --git a/src/port/dirent.c b/src/port/dirent.c index 18e8d84f698..b267896639e 100644 --- a/src/port/dirent.c +++ b/src/port/dirent.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/dirent.c,v 1.2 2006/06/26 12:58:17 momjian Exp $ + * $PostgreSQL: pgsql/src/port/dirent.c,v 1.3 2006/10/04 00:30:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,20 +17,22 @@ #include <dirent.h> -struct DIR { - char *dirname; - struct dirent ret; /* Used to return to caller */ - HANDLE handle; +struct DIR +{ + char *dirname; + struct dirent ret; /* Used to return to caller */ + HANDLE handle; }; -DIR* opendir(const char *dirname) +DIR * +opendir(const char *dirname) { - DWORD attr; - DIR *d; + DWORD attr; + DIR *d; /* Make sure it is a directory */ attr = GetFileAttributes(dirname); - if (attr == INVALID_FILE_ATTRIBUTES) + if (attr == INVALID_FILE_ATTRIBUTES) { errno = ENOENT; return NULL; @@ -47,7 +49,7 @@ DIR* opendir(const char *dirname) errno = ENOMEM; return NULL; } - d->dirname = malloc(strlen(dirname)+4); + d->dirname = malloc(strlen(dirname) + 4); if (!d->dirname) { errno = ENOMEM; @@ -55,18 +57,20 @@ DIR* opendir(const char *dirname) return NULL; } strcpy(d->dirname, dirname); - if (d->dirname[strlen(d->dirname)-1] != '/' && - d->dirname[strlen(d->dirname)-1] != '\\') - strcat(d->dirname,"\\"); /* Append backslash if not already there */ - strcat(d->dirname,"*"); /* Search for entries named anything */ + if (d->dirname[strlen(d->dirname) - 1] != '/' && + d->dirname[strlen(d->dirname) - 1] != '\\') + strcat(d->dirname, "\\"); /* Append backslash if not already + * there */ + strcat(d->dirname, "*"); /* Search for entries named anything */ d->handle = INVALID_HANDLE_VALUE; - d->ret.d_ino = 0; /* no inodes on win32 */ - d->ret.d_reclen = 0; /* not used on win32 */ + d->ret.d_ino = 0; /* no inodes on win32 */ + d->ret.d_reclen = 0; /* not used on win32 */ return d; } -struct dirent* readdir(DIR * d) +struct dirent * +readdir(DIR *d) { WIN32_FIND_DATA fd; @@ -79,7 +83,7 @@ struct dirent* readdir(DIR * d) return NULL; } } - else + else { if (!FindNextFile(d->handle, &fd)) { @@ -93,12 +97,14 @@ struct dirent* readdir(DIR * d) return NULL; } } - strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */ + strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH + * long */ d->ret.d_namlen = strlen(d->ret.d_name); return &d->ret; } -int closedir(DIR *d) +int +closedir(DIR *d) { if (d->handle != INVALID_HANDLE_VALUE) FindClose(d->handle); diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c index 6ebfdc926a7..b25db737a14 100644 --- a/src/port/getaddrinfo.c +++ b/src/port/getaddrinfo.c @@ -16,7 +16,7 @@ * Copyright (c) 2003-2006, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.25 2006/07/16 20:28:01 tgl Exp $ + * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.26 2006/10/04 00:30:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -329,7 +329,8 @@ gai_strerror(int errcode) return "Not enough memory"; #endif #ifdef EAI_NODATA -#ifndef WIN32_ONLY_COMPILER /* MSVC complains because another case has the same value */ +#ifndef WIN32_ONLY_COMPILER /* MSVC complains because another case has the + * same value */ case EAI_NODATA: return "No host data of that type was found"; #endif diff --git a/src/port/isinf.c b/src/port/isinf.c index d08e99c6453..809361b55d2 100644 --- a/src/port/isinf.c +++ b/src/port/isinf.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/isinf.c,v 1.9 2006/03/05 15:59:10 momjian Exp $ + * $PostgreSQL: pgsql/src/port/isinf.c,v 1.10 2006/10/04 00:30:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,4 +73,5 @@ isinf(double x) return 0; } #endif + #endif diff --git a/src/port/open.c b/src/port/open.c index 125cad05503..83fc1ca2818 100644 --- a/src/port/open.c +++ b/src/port/open.c @@ -6,7 +6,7 @@ * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/open.c,v 1.16 2006/10/03 20:44:18 momjian Exp $ + * $PostgreSQL: pgsql/src/port/open.c,v 1.17 2006/10/04 00:30:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -108,7 +108,7 @@ pgwin32_open(const char *fileName, int fileFlags,...) if ((fd = _open_osfhandle((long) h, fileFlags & O_APPEND)) < 0) CloseHandle(h); /* will not affect errno */ else if (fileFlags & (O_TEXT | O_BINARY) && - _setmode(fd, fileFlags & (O_TEXT | O_BINARY)) < 0) + _setmode(fd, fileFlags & (O_TEXT | O_BINARY)) < 0) { _close(fd); return -1; @@ -120,9 +120,9 @@ pgwin32_open(const char *fileName, int fileFlags,...) FILE * pgwin32_fopen(const char *fileName, const char *mode) { - int openmode = 0; - int fd; - + int openmode = 0; + int fd; + if (strstr(mode, "r+")) openmode |= O_RDWR; else if (strchr(mode, 'r')) @@ -138,7 +138,7 @@ pgwin32_fopen(const char *fileName, const char *mode) openmode |= O_BINARY; if (strchr(mode, 't')) openmode |= O_TEXT; - + fd = pgwin32_open(fileName, openmode); if (fd == -1) return NULL; diff --git a/src/port/path.c b/src/port/path.c index a7d5ec7c452..28608e979cf 100644 --- a/src/port/path.c +++ b/src/port/path.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/path.c,v 1.69 2006/09/27 18:40:10 tgl Exp $ + * $PostgreSQL: pgsql/src/port/path.c,v 1.70 2006/10/04 00:30:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -388,8 +388,8 @@ path_is_prefix_of_path(const char *path1, const char *path2) const char * get_progname(const char *argv0) { - const char *nodir_name; - char *progname; + const char *nodir_name; + char *progname; nodir_name = last_dir_separator(argv0); if (nodir_name) @@ -398,20 +398,20 @@ get_progname(const char *argv0) nodir_name = skip_drive(argv0); /* - * Make a copy in case argv[0] is modified by ps_status. - * Leaks memory, but called only once. + * Make a copy in case argv[0] is modified by ps_status. Leaks memory, but + * called only once. */ progname = strdup(nodir_name); if (progname == NULL) { fprintf(stderr, "%s: out of memory\n", nodir_name); - exit(1); /* This could exit the postmaster */ + exit(1); /* This could exit the postmaster */ } #if defined(__CYGWIN__) || defined(WIN32) /* strip ".exe" suffix, regardless of case */ if (strlen(progname) > sizeof(EXE) - 1 && - pg_strcasecmp(progname + strlen(progname) - (sizeof(EXE) - 1), EXE) == 0) + pg_strcasecmp(progname + strlen(progname) - (sizeof(EXE) - 1), EXE) == 0) progname[strlen(progname) - (sizeof(EXE) - 1)] = '\0'; #endif @@ -502,7 +502,7 @@ make_relative_path(char *ret_path, const char *target_path, */ tail_start = (int) strlen(ret_path) - tail_len; if (tail_start > 0 && - IS_DIR_SEP(ret_path[tail_start-1]) && + IS_DIR_SEP(ret_path[tail_start - 1]) && dir_strcmp(ret_path + tail_start, bin_path + prefix_len) == 0) { ret_path[tail_start] = '\0'; diff --git a/src/port/pgsleep.c b/src/port/pgsleep.c index b003d3494db..595812b3567 100644 --- a/src/port/pgsleep.c +++ b/src/port/pgsleep.c @@ -6,7 +6,7 @@ * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.8 2006/07/16 20:17:04 tgl Exp $ + * $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.9 2006/10/04 00:30:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,4 +47,4 @@ pg_usleep(long microsec) } } -#endif /* defined(FRONTEND) || !defined(WIN32) */ +#endif /* defined(FRONTEND) || !defined(WIN32) */ diff --git a/src/port/qsort_arg.c b/src/port/qsort_arg.c index ac7b149b5ff..9e69462f0ad 100644 --- a/src/port/qsort_arg.c +++ b/src/port/qsort_arg.c @@ -9,7 +9,7 @@ * * CAUTION: if you change this file, see also qsort.c * - * $PostgreSQL: pgsql/src/port/qsort_arg.c,v 1.1 2006/10/03 22:18:23 tgl Exp $ + * $PostgreSQL: pgsql/src/port/qsort_arg.c,v 1.2 2006/10/04 00:30:14 momjian Exp $ */ /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */ @@ -47,7 +47,7 @@ static char *med3(char *a, char *b, char *c, - qsort_arg_comparator cmp, void *arg); + qsort_arg_comparator cmp, void *arg); static void swapfunc(char *, char *, size_t, int); #define min(a, b) ((a) < (b) ? (a) : (b)) diff --git a/src/port/snprintf.c b/src/port/snprintf.c index dffe0fe359b..e4472e5bdb4 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -31,7 +31,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/port/snprintf.c,v 1.31 2005/12/05 21:57:00 tgl Exp $ + * $PostgreSQL: pgsql/src/port/snprintf.c,v 1.32 2006/10/04 00:30:14 momjian Exp $ */ #include "c.h" @@ -70,7 +70,7 @@ * platforms. This implementation is compatible with the Single Unix Spec: * * 1. -1 is returned only if processing is abandoned due to an invalid - * parameter, such as incorrect format string. (Although not required by + * parameter, such as incorrect format string. (Although not required by * the spec, this happens only when no characters have yet been transmitted * to the destination.) * @@ -146,7 +146,7 @@ static int dopr(PrintfTarget *target, const char *format, va_list args); int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args) { - PrintfTarget target; + PrintfTarget target; if (str == NULL || count == 0) return 0; @@ -179,7 +179,7 @@ pg_snprintf(char *str, size_t count, const char *fmt,...) static int pg_vsprintf(char *str, const char *fmt, va_list args) { - PrintfTarget target; + PrintfTarget target; if (str == NULL) return 0; @@ -212,7 +212,7 @@ pg_sprintf(char *str, const char *fmt,...) static int pg_vfprintf(FILE *stream, const char *fmt, va_list args) { - PrintfTarget target; + PrintfTarget target; char buffer[1024]; /* size is arbitrary */ if (stream == NULL) @@ -262,7 +262,7 @@ pg_printf(const char *fmt,...) static void flushbuffer(PrintfTarget *target) { - size_t nc = target->bufptr - target->bufstart; + size_t nc = target->bufptr - target->bufstart; if (nc > 0) target->nchars += fwrite(target->bufstart, 1, nc, target->stream); @@ -278,8 +278,8 @@ static void fmtint(int64 value, char type, int forcesign, PrintfTarget *target); static void fmtchar(int value, int leftjust, int minlen, PrintfTarget *target); static void fmtfloat(double value, char type, int forcesign, - int leftjust, int minlen, int zpad, int precision, int pointflag, - PrintfTarget *target); + int leftjust, int minlen, int zpad, int precision, int pointflag, + PrintfTarget *target); static void dostr(const char *str, int slen, PrintfTarget *target); static void dopr_outch(int c, PrintfTarget *target); static int adjust_sign(int is_negative, int forcesign, int *signvalue); @@ -317,8 +317,8 @@ dopr(PrintfTarget *target, const char *format, va_list args) double fvalue; char *strvalue; int i; - PrintfArgType argtypes[NL_ARGMAX+1]; - PrintfArgValue argvalues[NL_ARGMAX+1]; + PrintfArgType argtypes[NL_ARGMAX + 1]; + PrintfArgValue argvalues[NL_ARGMAX + 1]; /* * Parse the format string to determine whether there are %n$ format @@ -335,7 +335,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) longflag = longlongflag = pointflag = 0; fmtpos = accum = 0; afterstar = false; - nextch1: +nextch1: ch = *format++; if (ch == '\0') break; /* illegal, but we don't complain */ @@ -362,7 +362,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) goto nextch1; case '*': if (afterstar) - have_non_dollar = true; /* multiple stars */ + have_non_dollar = true; /* multiple stars */ afterstar = true; accum = 0; goto nextch1; @@ -462,6 +462,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) case '%': break; } + /* * If we finish the spec with afterstar still set, there's a * non-dollar star in there. @@ -516,7 +517,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) longflag = longlongflag = pointflag = 0; fmtpos = accum = 0; have_star = afterstar = false; - nextch2: +nextch2: ch = *format++; if (ch == '\0') break; /* illegal, but we don't complain */ @@ -561,7 +562,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) else { /* fetch and process value now */ - int starval = va_arg(args, int); + int starval = va_arg(args, int); if (pointflag) { @@ -586,7 +587,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) if (afterstar) { /* fetch and process star value */ - int starval = argvalues[accum].i; + int starval = argvalues[accum].i; if (pointflag) { @@ -854,7 +855,7 @@ fmtint(int64 value, char type, int forcesign, int leftjust, else { /* make integer string */ - uint64 uvalue = (uint64) value; + uint64 uvalue = (uint64) value; do { @@ -932,17 +933,17 @@ dostr(const char *str, int slen, PrintfTarget *target) { while (slen > 0) { - int avail; + int avail; if (target->bufend != NULL) avail = target->bufend - target->bufptr; - else + else avail = slen; if (avail <= 0) { /* buffer full, can we dump to stream? */ if (target->stream == NULL) - return; /* no, lose the data */ + return; /* no, lose the data */ flushbuffer(target); continue; } diff --git a/src/port/sprompt.c b/src/port/sprompt.c index eff3fa5ad13..8681fb20dce 100644 --- a/src/port/sprompt.c +++ b/src/port/sprompt.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/sprompt.c,v 1.17 2006/06/14 16:49:03 tgl Exp $ + * $PostgreSQL: pgsql/src/port/sprompt.c,v 1.18 2006/10/04 00:30:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) termout = fopen(DEVTTY, "w"); if (!termin || !termout #ifdef WIN32 - /* See DEVTTY comment for msys */ + /* See DEVTTY comment for msys */ || (getenv("OSTYPE") && strcmp(getenv("OSTYPE"), "msys") == 0) #endif ) diff --git a/src/port/strlcpy.c b/src/port/strlcpy.c index aef53da2fac..00738bfef85 100644 --- a/src/port/strlcpy.c +++ b/src/port/strlcpy.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/strlcpy.c,v 1.2 2006/10/02 23:58:59 momjian Exp $ + * $PostgreSQL: pgsql/src/port/strlcpy.c,v 1.3 2006/10/04 00:30:14 momjian Exp $ * * This file was taken from OpenBSD and is used on platforms that don't * provide strlcpy(). The OpenBSD copyright terms follow. @@ -36,33 +36,36 @@ /* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. * Function creation history: http://www.gratisoft.us/todd/papers/strlcpy.html */ size_t strlcpy(char *dst, const char *src, size_t siz) { - char *d = dst; + char *d = dst; const char *s = src; - size_t n = siz; + size_t n = siz; /* Copy as many bytes as will fit */ - if (n != 0) { - while (--n != 0) { + if (n != 0) + { + while (--n != 0) + { if ((*d++ = *s++) == '\0') break; } } /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { + if (n == 0) + { if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ + *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } - return(s - src - 1); /* count does not include NUL */ + return (s - src - 1); /* count does not include NUL */ } diff --git a/src/port/strtol.c b/src/port/strtol.c index 0a9a4e71347..2f4fac1fd63 100644 --- a/src/port/strtol.c +++ b/src/port/strtol.c @@ -52,7 +52,7 @@ static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; * before calling this function, and then errno != 0 can be tested * after the function completes. */ - + /* * Convert a string to a long integer. * |