Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb79a718

Browse files
committed
Must count '*' characters as potential arguments.
1 parent055467d commitb79a718

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

‎src/port/snprintf.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
* causing nasty effects.
6363
**************************************************************/
6464

65-
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.26 2005/03/20 13:54:53 momjian Exp $";*/
65+
/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.27 2005/04/14 20:53:09 tgl Exp $";*/
6666

6767
staticvoiddopr(char*buffer,constchar*format,va_listargs,char*end);
6868

@@ -194,7 +194,7 @@ dopr(char *buffer, const char *format, va_list args, char *end)
194194
intprecision;
195195
intposition;
196196
char*output;
197-
intpercents=1;
197+
intnargs=1;
198198
constchar*p;
199199
structfmtpar
200200
{
@@ -220,18 +220,22 @@ dopr(char *buffer, const char *format, va_list args, char *end)
220220
intlonglongflag;
221221
}*fmtpar,**fmtparptr;
222222

223-
/* Create enough structures to hold all arguments */
223+
/*
224+
* Create enough structures to hold all arguments. This overcounts,
225+
* eg not all '*' characters are necessarily arguments, but it's not
226+
* worth being exact.
227+
*/
224228
for (p=format;*p!='\0';p++)
225-
if (*p=='%')/* counts %% as two, so overcounts */
226-
percents++;
229+
if (*p=='%'||*p=='*')
230+
nargs++;
227231

228232
/* Need to use malloc() because memory system might not be started yet. */
229-
if ((fmtpar=malloc(sizeof(structfmtpar)*percents))==NULL)
233+
if ((fmtpar=malloc(sizeof(structfmtpar)*nargs))==NULL)
230234
{
231235
fprintf(stderr,_("out of memory\n"));
232236
exit(1);
233237
}
234-
if ((fmtparptr=malloc(sizeof(structfmtpar*)*percents))==NULL)
238+
if ((fmtparptr=malloc(sizeof(structfmtpar*)*nargs))==NULL)
235239
{
236240
fprintf(stderr,_("out of memory\n"));
237241
exit(1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp