Commit c775b423 authored by Tom Lane's avatar Tom Lane

Fix unportable usages in new pgbench code (strndup, ctype macros)

parent 9b19abd7
/* /*
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.37 2005/09/29 13:44:25 ishii Exp $ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.38 2005/09/29 16:18:26 tgl Exp $
* *
* pgbench: a simple TPC-B like benchmark program for PostgreSQL * pgbench: a simple TPC-B like benchmark program for PostgreSQL
* written by Tatsuo Ishii * written by Tatsuo Ishii
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "libpq-fe.h" #include "libpq-fe.h"
#include <errno.h>
#ifdef WIN32 #ifdef WIN32
#include "win32.h" #include "win32.h"
#else #else
...@@ -275,14 +273,17 @@ assignVariables(CState * st, char *sql) ...@@ -275,14 +273,17 @@ assignVariables(CState * st, char *sql)
while ((p = strchr(&sql[i], ':')) != NULL) while ((p = strchr(&sql[i], ':')) != NULL)
{ {
i = j = p - sql; i = j = p - sql;
do do {
i++; i++;
while (isalnum(sql[i]) != 0 || sql[i] == '_'); } while (isalnum((unsigned char) sql[i]) || sql[i] == '_');
if (i == j + 1) if (i == j + 1)
continue; continue;
if ((name = strndup(&sql[j + 1], i - (j + 1))) == NULL) name = malloc(i - j);
if (name == NULL)
return NULL; return NULL;
memcpy(name, &sql[j + 1], i - (j + 1));
name[i - (j + 1)] = '\0';
val = getVariable(st, name); val = getVariable(st, name);
free(name); free(name);
if (val == NULL) if (val == NULL)
...@@ -966,7 +967,7 @@ process_file(char *filename) ...@@ -966,7 +967,7 @@ process_file(char *filename)
if ((p = strchr(buf, '\n')) != NULL) if ((p = strchr(buf, '\n')) != NULL)
*p = '\0'; *p = '\0';
p = buf; p = buf;
while (isspace(*p)) while (isspace((unsigned char) *p))
p++; p++;
if (*p == '\0' || strncmp(p, "--", 2) == 0) if (*p == '\0' || strncmp(p, "--", 2) == 0)
{ {
......
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