Commit 712f0535 authored by Bruce Momjian's avatar Bruce Momjian

Add sprintf support, that were were missing.

Add support for snprintf '+', 'h', and %* length settings.
parent ca667973
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.141 2005/03/11 17:20:34 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.142 2005/03/16 21:27:23 momjian Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "command.h" #include "command.h"
...@@ -1574,11 +1574,13 @@ do_shell(const char *command) ...@@ -1574,11 +1574,13 @@ do_shell(const char *command)
shellName = DEFAULT_SHELL; shellName = DEFAULT_SHELL;
sys = pg_malloc(strlen(shellName) + 16); sys = pg_malloc(strlen(shellName) + 16);
#ifndef WIN32
sprintf(sys, sprintf(sys,
/* See EDITOR handling comment for an explaination */ /* See EDITOR handling comment for an explaination */
#ifndef WIN32
"exec %s", shellName); "exec %s", shellName);
#else #else
sprintf(sys,
/* See EDITOR handling comment for an explaination */
"%s\"%s\"%s", SYSTEMQUOTE, shellName, SYSTEMQUOTE); "%s\"%s\"%s", SYSTEMQUOTE, shellName, SYSTEMQUOTE);
#endif #endif
result = system(sys); result = system(sys);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.72 2005/03/11 19:13:42 momjian Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.73 2005/03/16 21:27:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -112,6 +112,9 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args); ...@@ -112,6 +112,9 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
extern int pg_snprintf(char *str, size_t count, const char *fmt,...) extern int pg_snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(printf, 3, 4))); __attribute__((format(printf, 3, 4)));
extern int pg_sprintf(char *str, const char *fmt,...)
/* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3)));
extern int pg_fprintf(FILE *stream, const char *fmt,...) extern int pg_fprintf(FILE *stream, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(printf, 2, 3))); __attribute__((format(printf, 2, 3)));
...@@ -127,11 +130,13 @@ __attribute__((format(printf, 1, 2))); ...@@ -127,11 +130,13 @@ __attribute__((format(printf, 1, 2)));
#ifdef __GNUC__ #ifdef __GNUC__
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
#define snprintf(...) pg_snprintf(__VA_ARGS__) #define snprintf(...) pg_snprintf(__VA_ARGS__)
#define sprintf(...) pg_sprintf(__VA_ARGS__)
#define fprintf(...) pg_fprintf(__VA_ARGS__) #define fprintf(...) pg_fprintf(__VA_ARGS__)
#define printf(...) pg_printf(__VA_ARGS__) #define printf(...) pg_printf(__VA_ARGS__)
#else #else
#define vsnprintf pg_vsnprintf #define vsnprintf pg_vsnprintf
#define snprintf pg_snprintf #define snprintf pg_snprintf
#define sprintf pg_sprintf
#define fprintf pg_fprintf #define fprintf pg_fprintf
#define printf pg_printf #define printf pg_printf
#endif #endif
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment