Skip to content

Commit c775b42

Browse files
committed
Fix unportable usages in new pgbench code (strndup, ctype macros)
1 parent 9b19abd commit c775b42

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

contrib/pgbench/pgbench.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.37 2005/09/29 13:44:25 ishii Exp $
2+
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.38 2005/09/29 16:18:26 tgl Exp $
33
*
44
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -21,8 +21,6 @@
2121

2222
#include "libpq-fe.h"
2323

24-
#include <errno.h>
25-
2624
#ifdef WIN32
2725
#include "win32.h"
2826
#else
@@ -275,14 +273,17 @@ assignVariables(CState * st, char *sql)
275273
while ((p = strchr(&sql[i], ':')) != NULL)
276274
{
277275
i = j = p - sql;
278-
do
276+
do {
279277
i++;
280-
while (isalnum(sql[i]) != 0 || sql[i] == '_');
278+
} while (isalnum((unsigned char) sql[i]) || sql[i] == '_');
281279
if (i == j + 1)
282280
continue;
283281

284-
if ((name = strndup(&sql[j + 1], i - (j + 1))) == NULL)
282+
name = malloc(i - j);
283+
if (name == NULL)
285284
return NULL;
285+
memcpy(name, &sql[j + 1], i - (j + 1));
286+
name[i - (j + 1)] = '\0';
286287
val = getVariable(st, name);
287288
free(name);
288289
if (val == NULL)
@@ -966,7 +967,7 @@ process_file(char *filename)
966967
if ((p = strchr(buf, '\n')) != NULL)
967968
*p = '\0';
968969
p = buf;
969-
while (isspace(*p))
970+
while (isspace((unsigned char) *p))
970971
p++;
971972
if (*p == '\0' || strncmp(p, "--", 2) == 0)
972973
{

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