Skip to content

Commit 712f053

Browse files
committed
Add sprintf support, that were were missing.
Add support for snprintf '+', 'h', and %* length settings.
1 parent ca66797 commit 712f053

File tree

3 files changed

+118
-49
lines changed

3 files changed

+118
-49
lines changed

src/bin/psql/command.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.141 2005/03/11 17:20:34 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.142 2005/03/16 21:27:23 momjian Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "command.h"
@@ -1574,11 +1574,13 @@ do_shell(const char *command)
15741574
shellName = DEFAULT_SHELL;
15751575

15761576
sys = pg_malloc(strlen(shellName) + 16);
1577+
#ifndef WIN32
15771578
sprintf(sys,
15781579
/* See EDITOR handling comment for an explaination */
1579-
#ifndef WIN32
15801580
"exec %s", shellName);
15811581
#else
1582+
sprintf(sys,
1583+
/* See EDITOR handling comment for an explaination */
15821584
"%s\"%s\"%s", SYSTEMQUOTE, shellName, SYSTEMQUOTE);
15831585
#endif
15841586
result = system(sys);

src/include/port.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.72 2005/03/11 19:13:42 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.73 2005/03/16 21:27:23 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -112,6 +112,9 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
112112
extern int pg_snprintf(char *str, size_t count, const char *fmt,...)
113113
/* This extension allows gcc to check the format string */
114114
__attribute__((format(printf, 3, 4)));
115+
extern int pg_sprintf(char *str, const char *fmt,...)
116+
/* This extension allows gcc to check the format string */
117+
__attribute__((format(printf, 2, 3)));
115118
extern int pg_fprintf(FILE *stream, const char *fmt,...)
116119
/* This extension allows gcc to check the format string */
117120
__attribute__((format(printf, 2, 3)));
@@ -127,11 +130,13 @@ __attribute__((format(printf, 1, 2)));
127130
#ifdef __GNUC__
128131
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
129132
#define snprintf(...) pg_snprintf(__VA_ARGS__)
133+
#define sprintf(...) pg_sprintf(__VA_ARGS__)
130134
#define fprintf(...) pg_fprintf(__VA_ARGS__)
131135
#define printf(...) pg_printf(__VA_ARGS__)
132136
#else
133137
#define vsnprintf pg_vsnprintf
134138
#define snprintf pg_snprintf
139+
#define sprintf pg_sprintf
135140
#define fprintf pg_fprintf
136141
#define printf pg_printf
137142
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy