Commit f3af1368 authored by Bruce Momjian's avatar Bruce Momjian

Rename strNcpy to StrNCpy, and change third parameter.

parent 8b53f6e5
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.26 1997/09/18 20:19:38 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.27 1997/10/25 01:08:45 momjian Exp $
* *
* NOTES * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
...@@ -489,7 +489,7 @@ BuildDescForRelation(List *schema, char *relname) ...@@ -489,7 +489,7 @@ BuildDescForRelation(List *schema, char *relname)
} }
else else
{ {
strNcpy(typename, entry->typename->name, NAMEDATALEN - 1); StrNCpy(typename, entry->typename->name, NAMEDATALEN);
attdim = 0; attdim = 0;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.20 1997/09/12 04:07:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.21 1997/10/25 01:08:49 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -488,7 +488,7 @@ Async_Listen(char *relname, int pid) ...@@ -488,7 +488,7 @@ Async_Listen(char *relname, int pid)
* unlisten prior to dying. * unlisten prior to dying.
*/ */
relnamei = malloc(NAMEDATALEN); /* persists to process exit */ relnamei = malloc(NAMEDATALEN); /* persists to process exit */
strNcpy(relnamei, relname, NAMEDATALEN - 1); StrNCpy(relnamei, relname, NAMEDATALEN);
on_exitpg(Async_UnlistenOnExit, (caddr_t) relnamei); on_exitpg(Async_UnlistenOnExit, (caddr_t) relnamei);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.17 1997/09/08 21:42:33 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.18 1997/10/25 01:08:51 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -65,7 +65,7 @@ DefineRelation(CreateStmt *stmt) ...@@ -65,7 +65,7 @@ DefineRelation(CreateStmt *stmt)
if (strlen(stmt->relname) >= NAMEDATALEN) if (strlen(stmt->relname) >= NAMEDATALEN)
elog(WARN, "the relation name %s is >= %d characters long", stmt->relname, elog(WARN, "the relation name %s is >= %d characters long", stmt->relname,
NAMEDATALEN); NAMEDATALEN);
strNcpy(relname, stmt->relname, NAMEDATALEN - 1); /* make full length for StrNCpy(relname, stmt->relname, NAMEDATALEN); /* make full length for
* copy */ * copy */
/* ---------------- /* ----------------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.9 1997/09/08 21:42:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.10 1997/10/25 01:08:54 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1344,7 +1344,7 @@ replaceTeeScans(Plan *plan, Query *parsetree, TeeInfo * teeInfo) ...@@ -1344,7 +1344,7 @@ replaceTeeScans(Plan *plan, Query *parsetree, TeeInfo * teeInfo)
if ((strlen(rte->refname) < 4) || if ((strlen(rte->refname) < 4) ||
(strcmp(rte->relname, rte->refname) != 0)) (strcmp(rte->relname, rte->refname) != 0))
continue; continue;
strNcpy(prefix, rte->refname, 4); StrNCpy(prefix, rte->refname, 5);
if (strcmp(prefix, "tee_") == 0) if (strcmp(prefix, "tee_") == 0)
{ {
/* okay, we found a tee node entry in the range table */ /* okay, we found a tee node entry in the range table */
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.27 1997/10/12 07:09:02 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.28 1997/10/25 01:09:01 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -330,9 +330,9 @@ ExecCheckPerms(CmdType operation, ...@@ -330,9 +330,9 @@ ExecCheckPerms(CmdType operation,
if (!HeapTupleIsValid(htp)) if (!HeapTupleIsValid(htp))
elog(WARN, "ExecCheckPerms: bogus RT relid: %d", elog(WARN, "ExecCheckPerms: bogus RT relid: %d",
relid); relid);
strNcpy(rname.data, StrNCpy(rname.data,
((Form_pg_class) GETSTRUCT(htp))->relname.data, ((Form_pg_class) GETSTRUCT(htp))->relname.data,
NAMEDATALEN - 1); NAMEDATALEN);
if (i == resultRelation) if (i == resultRelation)
{ /* this is the result relation */ { /* this is the result relation */
qvars = pull_varnos(parseTree->qual); qvars = pull_varnos(parseTree->qual);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.19 1997/09/18 20:20:35 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.20 1997/10/25 01:09:10 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -514,7 +514,7 @@ ExecSetTypeInfo(int index, ...@@ -514,7 +514,7 @@ ExecSetTypeInfo(int index,
att->attrelid = 0; /* dummy value */ att->attrelid = 0; /* dummy value */
if (attName != (char *) NULL) if (attName != (char *) NULL)
strNcpy(att->attname.data, attName, NAMEDATALEN - 1); StrNCpy(att->attname.data, attName, NAMEDATALEN);
else else
MemSet(att->attname.data, 0, NAMEDATALEN); MemSet(att->attname.data, 0, NAMEDATALEN);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.15 1997/09/08 21:43:41 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.16 1997/10/25 01:09:16 momjian Exp $
* *
* NOTES * NOTES
* This should be moved to a more appropriate place. It is here * This should be moved to a more appropriate place. It is here
...@@ -269,7 +269,7 @@ lo_import(text *filename) ...@@ -269,7 +269,7 @@ lo_import(text *filename)
/* /*
* open the file to be read in * open the file to be read in
*/ */
strNcpy(fnamebuf, VARDATA(filename), VARSIZE(filename) - VARHDRSZ); StrNCpy(fnamebuf, VARDATA(filename), VARSIZE(filename) - VARHDRSZ + 1);
fd = open(fnamebuf, O_RDONLY, 0666); fd = open(fnamebuf, O_RDONLY, 0666);
if (fd < 0) if (fd < 0)
{ /* error */ { /* error */
...@@ -343,7 +343,7 @@ lo_export(Oid lobjId, text *filename) ...@@ -343,7 +343,7 @@ lo_export(Oid lobjId, text *filename)
* open the file to be written to * open the file to be written to
*/ */
oumask = umask((mode_t) 0); oumask = umask((mode_t) 0);
strNcpy(fnamebuf, VARDATA(filename), VARSIZE(filename) - VARHDRSZ); StrNCpy(fnamebuf, VARDATA(filename), VARSIZE(filename) - VARHDRSZ + 1);
fd = open(fnamebuf, O_CREAT | O_WRONLY, 0666); fd = open(fnamebuf, O_CREAT | O_WRONLY, 0666);
umask(oumask); umask(oumask);
if (fd < 0) if (fd < 0)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.7 1997/09/08 21:43:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.8 1997/10/25 01:09:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -241,7 +241,7 @@ strmake(char *str, int len) ...@@ -241,7 +241,7 @@ strmake(char *str, int len)
len = strlen(str); len = strlen(str);
newstr = (char *) palloc((unsigned) len + 1); newstr = (char *) palloc((unsigned) len + 1);
strNcpy(newstr, str, len); StrNCpy(newstr, str, len+1);
newstr[len] = (char) 0; newstr[len] = (char) 0;
return newstr; return newstr;
} }
......
...@@ -90,7 +90,7 @@ verify_password(char *user, char *password, Port *port, ...@@ -90,7 +90,7 @@ verify_password(char *user, char *password, Port *port,
if (test_pw[strlen(test_pw) - 1] == '\n') if (test_pw[strlen(test_pw) - 1] == '\n')
test_pw[strlen(test_pw) - 1] = '\0'; test_pw[strlen(test_pw) - 1] = '\0';
strNcpy(salt, test_pw, 2); StrNCpy(salt, test_pw, 3);
if (strcmp(user, test_user) == 0) if (strcmp(user, test_user) == 0)
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.9 1997/09/08 21:43:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.10 1997/10/25 01:09:21 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -154,7 +154,7 @@ PQpnames(char **pnames, int rule_p) ...@@ -154,7 +154,7 @@ PQpnames(char **pnames, int rule_p)
{ {
if (!rule_p || portals[i]->portal->rule_p) if (!rule_p || portals[i]->portal->rule_p)
{ {
strncpy(pnames[cur_pname], portals[i]->name, PortalNameLength); strncpy(pnames[cur_pname], portals[i]->name, PortalNameLength+1);
++cur_pname; ++cur_pname;
} }
} }
...@@ -730,7 +730,7 @@ PQappendNotify(char *relname, int pid) ...@@ -730,7 +730,7 @@ PQappendNotify(char *relname, int pid)
pqNotifyList = DLNewList(); pqNotifyList = DLNewList();
p = (PQNotifyList *) pbuf_alloc(sizeof(PQNotifyList)); p = (PQNotifyList *) pbuf_alloc(sizeof(PQNotifyList));
strNcpy(p->relname, relname, NAMEDATALEN - 1); StrNCpy(p->relname, relname, NAMEDATALEN);
p->be_pid = pid; p->be_pid = pid;
p->valid = 1; p->valid = 1;
DLAddTail(pqNotifyList, DLNewElem(p)); DLAddTail(pqNotifyList, DLNewElem(p));
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.7 1997/09/08 21:43:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.8 1997/10/25 01:09:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -384,7 +384,7 @@ void ...@@ -384,7 +384,7 @@ void
pbuf_setportalinfo(PortalEntry *entry, char *pname) pbuf_setportalinfo(PortalEntry *entry, char *pname)
{ {
if (entry) if (entry)
strNcpy(entry->name, pname, PortalNameLength - 1); StrNCpy(entry->name, pname, PortalNameLength);
} }
/* -------------------------------- /* --------------------------------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.9 1997/09/08 21:44:10 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.10 1997/10/25 01:09:28 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -391,14 +391,14 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label) ...@@ -391,14 +391,14 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
RangeTblEntry *rte; RangeTblEntry *rte;
rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable); rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable);
strNcpy(extraInfo, rte->relname, NAMEDATALEN - 1); StrNCpy(extraInfo, rte->relname, NAMEDATALEN);
} }
else if (IsA(p, IndexScan)) else if (IsA(p, IndexScan))
{ {
strNcpy(extraInfo, StrNCpy(extraInfo,
((RangeTblEntry *) (nth(((IndexScan *) p)->scan.scanrelid - 1, ((RangeTblEntry *) (nth(((IndexScan *) p)->scan.scanrelid - 1,
parsetree->rtable)))->relname, parsetree->rtable)))->relname,
NAMEDATALEN - 1); NAMEDATALEN);
} }
else else
extraInfo[0] = '\0'; extraInfo[0] = '\0';
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.9 1997/09/08 21:44:11 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.10 1997/10/25 01:09:30 momjian Exp $
* *
* NOTES * NOTES
* Most of the read functions for plan nodes are tested. (In fact, they * Most of the read functions for plan nodes are tested. (In fact, they
...@@ -92,7 +92,7 @@ _readQuery() ...@@ -92,7 +92,7 @@ _readQuery()
NotifyStmt *n = makeNode(NotifyStmt); NotifyStmt *n = makeNode(NotifyStmt);
n->relname = palloc(length + 1); n->relname = palloc(length + 1);
strNcpy(n->relname, token, length); StrNCpy(n->relname, token, length+1);
local_node->utilityStmt = (Node *) n; local_node->utilityStmt = (Node *) n;
} }
...@@ -111,7 +111,7 @@ _readQuery() ...@@ -111,7 +111,7 @@ _readQuery()
else else
{ {
local_node->uniqueFlag = palloc(length + 1); local_node->uniqueFlag = palloc(length + 1);
strNcpy(local_node->uniqueFlag, token, length); StrNCpy(local_node->uniqueFlag, token, length+1);
} }
token = lsptok(NULL, &length); /* skip :targetlist */ token = lsptok(NULL, &length); /* skip :targetlist */
...@@ -1067,7 +1067,7 @@ _readAggreg() ...@@ -1067,7 +1067,7 @@ _readAggreg()
token = lsptok(NULL, &length); /* eat :aggname */ token = lsptok(NULL, &length); /* eat :aggname */
token = lsptok(NULL, &length); /* get aggname */ token = lsptok(NULL, &length); /* get aggname */
local_node->aggname = (char *) palloc(length + 1); local_node->aggname = (char *) palloc(length + 1);
strNcpy(local_node->aggname, token, length); StrNCpy(local_node->aggname, token, length+1);
token = lsptok(NULL, &length); /* eat :basetype */ token = lsptok(NULL, &length); /* eat :basetype */
token = lsptok(NULL, &length); /* get basetype */ token = lsptok(NULL, &length); /* get basetype */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.46 1997/10/16 06:58:38 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.47 1997/10/25 01:09:35 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1150,7 +1150,7 @@ makeTargetNames(ParseState *pstate, List *cols) ...@@ -1150,7 +1150,7 @@ makeTargetNames(ParseState *pstate, List *cols)
Ident *id = makeNode(Ident); Ident *id = makeNode(Ident);
id->name = palloc(NAMEDATALEN); id->name = palloc(NAMEDATALEN);
strNcpy(id->name, attr[i]->attname.data, NAMEDATALEN - 1); StrNCpy(id->name, attr[i]->attname.data, NAMEDATALEN);
id->indirection = NIL; id->indirection = NIL;
id->isRel = false; id->isRel = false;
if (tl == NIL) if (tl == NIL)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.56 1997/10/09 05:43:59 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.57 1997/10/25 01:09:41 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -3117,7 +3117,7 @@ opt_id: Id { $$ = $1; } ...@@ -3117,7 +3117,7 @@ opt_id: Id { $$ = $1; }
relation_name: SpecialRuleRelation relation_name: SpecialRuleRelation
{ {
$$ = $1; $$ = $1;
strNcpy(saved_relname, $1, NAMEDATALEN-1); StrNCpy(saved_relname, $1, NAMEDATALEN);
} }
| ColId | ColId
{ {
...@@ -3129,7 +3129,7 @@ relation_name: SpecialRuleRelation ...@@ -3129,7 +3129,7 @@ relation_name: SpecialRuleRelation
elog(WARN,"%s cannot be accessed by users",$1); elog(WARN,"%s cannot be accessed by users",$1);
else else
$$ = $1; $$ = $1;
strNcpy(saved_relname, $1, NAMEDATALEN-1); StrNCpy(saved_relname, $1, NAMEDATALEN);
} }
; ;
......
...@@ -537,7 +537,7 @@ readExports(ModulePtr mp) ...@@ -537,7 +537,7 @@ readExports(ModulePtr mp)
* first SYMNMLEN chars and make sure we have a zero byte at * first SYMNMLEN chars and make sure we have a zero byte at
* the end. * the end.
*/ */
strNcpy(tmpsym, ls->l_name, SYMNMLEN); StrNCpy(tmpsym, ls->l_name, SYMNMLEN+1);
symname = tmpsym; symname = tmpsym;
} }
ep->name = strdup(symname); ep->name = strdup(symname);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.58 1997/09/18 20:21:08 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.59 1997/10/25 01:09:55 momjian Exp $
* *
* NOTES * NOTES
* *
...@@ -717,7 +717,7 @@ ConnStartup(Port *port, int *status, ...@@ -717,7 +717,7 @@ ConnStartup(Port *port, int *status,
msgType = (MsgType) ntohl(port->buf.msgtype); msgType = (MsgType) ntohl(port->buf.msgtype);
strNcpy(namebuf, sp.user, NAMEDATALEN - 1); StrNCpy(namebuf, sp.user, NAMEDATALEN);
if (!namebuf[0]) if (!namebuf[0])
{ {
strncpy(errormsg, strncpy(errormsg,
...@@ -1232,15 +1232,15 @@ DoExec(StartupInfo *packet, int portFd) ...@@ -1232,15 +1232,15 @@ DoExec(StartupInfo *packet, int portFd)
sprintf(portbuf, "-P%d", portFd); sprintf(portbuf, "-P%d", portFd);
av[ac++] = portbuf; av[ac++] = portbuf;
strNcpy(argbuf, packet->options, ARGV_SIZE); StrNCpy(argbuf, packet->options, ARGV_SIZE);
strncat(argbuf, ExtraOptions, ARGV_SIZE); strncat(argbuf, ExtraOptions, ARGV_SIZE);
argbuf[(2 * ARGV_SIZE)] = '\0'; argbuf[(2 * ARGV_SIZE)] = '\0';
split_opts(av, &ac, argbuf); split_opts(av, &ac, argbuf);
if (packet->database[0]) if (packet->database[0])
strNcpy(dbbuf, packet->database, ARGV_SIZE); StrNCpy(dbbuf, packet->database, ARGV_SIZE);
else else
strNcpy(dbbuf, packet->user, NAMEDATALEN - 1); StrNCpy(dbbuf, packet->user, NAMEDATALEN);
av[ac++] = dbbuf; av[ac++] = dbbuf;
av[ac] = (char *) NULL; av[ac] = (char *) NULL;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.22 1997/09/18 20:21:45 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.23 1997/10/25 01:10:04 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -172,7 +172,7 @@ mdunlink(Relation reln) ...@@ -172,7 +172,7 @@ mdunlink(Relation reln)
* do this. * do this.
*/ */
strNcpy(fname, RelationGetRelationName(reln)->data, NAMEDATALEN - 1); StrNCpy(fname, RelationGetRelationName(reln)->data, NAMEDATALEN);
if (FileNameUnlink(fname) < 0) if (FileNameUnlink(fname) < 0)
return (SM_FAIL); return (SM_FAIL);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.49 1997/09/18 20:22:03 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.50 1997/10/25 01:10:16 momjian Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -1088,7 +1088,7 @@ PostgresMain(int argc, char *argv[]) ...@@ -1088,7 +1088,7 @@ PostgresMain(int argc, char *argv[])
* o - send output (stdout and stderr) to the given file * o - send output (stdout and stderr) to the given file
* ---------------- * ----------------
*/ */
strNcpy(OutputFileName, optarg, MAXPGPATH); StrNCpy(OutputFileName, optarg, MAXPGPATH);
break; break;
case 'p': /* started by postmaster */ case 'p': /* started by postmaster */
...@@ -1391,7 +1391,7 @@ PostgresMain(int argc, char *argv[]) ...@@ -1391,7 +1391,7 @@ PostgresMain(int argc, char *argv[])
if (IsUnderPostmaster == false) if (IsUnderPostmaster == false)
{ {
puts("\nPOSTGRES backend interactive interface"); puts("\nPOSTGRES backend interactive interface");
puts("$Revision: 1.49 $ $Date: 1997/09/18 20:22:03 $"); puts("$Revision: 1.50 $ $Date: 1997/10/25 01:10:16 $");
} }
/* ---------------- /* ----------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Routines for handling of 'SET var TO', 'SHOW var' and 'RESET var' * Routines for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements. * statements.
* *
* $Id: variable.c,v 1.16 1997/09/08 21:47:59 momjian Exp $ * $Id: variable.c,v 1.17 1997/10/25 01:10:22 momjian Exp $
* *
*/ */
...@@ -73,7 +73,7 @@ get_token(char **tok, char **val, const char *str) ...@@ -73,7 +73,7 @@ get_token(char **tok, char **val, const char *str)
} }
*tok = (char *) PALLOC(len + 1); *tok = (char *) PALLOC(len + 1);
strNcpy(*tok, start, len); StrNCpy(*tok, start, len+1);
/* skip white spaces */ /* skip white spaces */
while (isspace(*str)) while (isspace(*str))
...@@ -119,7 +119,7 @@ get_token(char **tok, char **val, const char *str) ...@@ -119,7 +119,7 @@ get_token(char **tok, char **val, const char *str)
} }
*val = (char *) PALLOC(len + 1); *val = (char *) PALLOC(len + 1);
strNcpy(*val, start, len); StrNCpy(*val, start, len+1);
/* skip white spaces */ /* skip white spaces */
while (isspace(*str)) while (isspace(*str))
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.6 1997/09/08 21:48:01 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.7 1997/10/25 01:10:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -108,7 +108,7 @@ first character\n", ARRAY_LEFT_DELIM); ...@@ -108,7 +108,7 @@ first character\n", ARRAY_LEFT_DELIM);
* extra character for \0 * extra character for \0
* anyway */ * anyway */
word = (char *) malloc(nextlen); word = (char *) malloc(nextlen);
strNcpy(word, beginQuote + 1, nextlen - 1); StrNCpy(word, beginQuote + 1, nextlen);
addArr_TgString(result, (TgString *) & word); addArr_TgString(result, (TgString *) & word);
free(word); free(word);
str = endQuote + 1; str = endQuote + 1;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.11 1997/09/08 21:48:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.12 1997/10/25 01:10:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -124,7 +124,7 @@ char16out(char *s) ...@@ -124,7 +124,7 @@ char16out(char *s)
result[1] = '\0'; result[1] = '\0';
} }
else else
strNcpy(result, s, 16); StrNCpy(result, s, 16);
return (result); return (result);
} }
...@@ -282,7 +282,7 @@ char2out(uint16 s) ...@@ -282,7 +282,7 @@ char2out(uint16 s)
{ {
char *result = (char *) palloc(3); char *result = (char *) palloc(3);
strNcpy(result, (char *) &s, 2); StrNCpy(result, (char *) &s, 3);
return (result); return (result);
} }
...@@ -349,7 +349,7 @@ uint32 s; ...@@ -349,7 +349,7 @@ uint32 s;
{ {
char *result = (char *) palloc(5); char *result = (char *) palloc(5);
strNcpy(result, (char *) &s, 4); StrNCpy(result, (char *) &s, 5);
return (result); return (result);
} }
...@@ -421,7 +421,7 @@ char8out(char *s) ...@@ -421,7 +421,7 @@ char8out(char *s)
result[1] = '\0'; result[1] = '\0';
} }
else else
strNcpy(result, s, 8); StrNCpy(result, s, 9);
return (result); return (result);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.10 1997/09/08 02:30:40 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.11 1997/10/25 01:10:36 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -59,7 +59,7 @@ filename_in(char *file) ...@@ -59,7 +59,7 @@ filename_in(char *file)
else else
{ {
/* Someone else's directory */ /* Someone else's directory */
char name[16], char name[17],
*p; *p;
struct passwd *pw; struct passwd *pw;
int len; int len;
...@@ -72,7 +72,7 @@ filename_in(char *file) ...@@ -72,7 +72,7 @@ filename_in(char *file)
else else
{ {
len = (p - file) - 1; len = (p - file) - 1;
strNcpy(name, file + 1, len); StrNCpy(name, file + 1, len+1);
} }
/* printf("name: %s\n"); */ /* printf("name: %s\n"); */
if ((pw = getpwnam(name)) == NULL) if ((pw = getpwnam(name)) == NULL)
...@@ -102,7 +102,7 @@ filename_in(char *file) ...@@ -102,7 +102,7 @@ filename_in(char *file)
else else
{ {
len = (p - file) - 1; len = (p - file) - 1;
strNcpy(environment, file + 1, len); StrNCpy(environment, file + 1, len+1);
} }
envirp = getenv(environment); envirp = getenv(environment);
if (envirp) if (envirp)
......
...@@ -48,7 +48,7 @@ fixedlen_like(char *s, struct varlena * p, int charlen) ...@@ -48,7 +48,7 @@ fixedlen_like(char *s, struct varlena * p, int charlen)
/* be sure sterm is null-terminated */ /* be sure sterm is null-terminated */
sterm = (char *) palloc(charlen + 1); sterm = (char *) palloc(charlen + 1);
strNcpy(sterm, s, charlen); StrNCpy(sterm, s, charlen+1);
/* /*
* p is a text = varlena, not a string so we have to make a string * p is a text = varlena, not a string so we have to make a string
...@@ -150,7 +150,7 @@ textnlike(struct varlena * s, struct varlena * p) ...@@ -150,7 +150,7 @@ textnlike(struct varlena * s, struct varlena * p)
} }
/* $Revision: 1.9 $ /* $Revision: 1.10 $
** "like.c" A first attempt at a LIKE operator for Postgres95. ** "like.c" A first attempt at a LIKE operator for Postgres95.
** **
** Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. ** Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.9 1997/09/08 21:48:33 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.10 1997/10/25 01:10:40 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -41,7 +41,7 @@ namein(char *s) ...@@ -41,7 +41,7 @@ namein(char *s)
return (NULL); return (NULL);
result = (NameData *) palloc(NAMEDATALEN); result = (NameData *) palloc(NAMEDATALEN);
/* always keep it null-padded */ /* always keep it null-padded */
strNcpy(result->data, s, NAMEDATALEN - 1); StrNCpy(result->data, s, NAMEDATALEN);
return (result); return (result);
} }
...@@ -159,7 +159,7 @@ namestrcpy(Name name, char *str) ...@@ -159,7 +159,7 @@ namestrcpy(Name name, char *str)
{ {
if (!name || !str) if (!name || !str)
return (-1); return (-1);
strNcpy(name->data, str, NAMEDATALEN - 1); StrNCpy(name->data, str, NAMEDATALEN);
return (0); return (0);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.8 1997/09/18 20:22:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.9 1997/10/25 01:10:41 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -37,7 +37,7 @@ oidnamein(char *inStr) ...@@ -37,7 +37,7 @@ oidnamein(char *inStr)
oc->id = (Oid) pg_atoi(inStr, sizeof(Oid), ','); oc->id = (Oid) pg_atoi(inStr, sizeof(Oid), ',');
/* copy one less to ensure null-padding */ /* copy one less to ensure null-padding */
++inptr; ++inptr;
strNcpy(oc->name.data, inptr, NAMEDATALEN - 1); StrNCpy(oc->name.data, inptr, NAMEDATALEN);
} }
else else
elog(WARN, "Bad input data for type oidname"); elog(WARN, "Bad input data for type oidname");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.10 1997/09/08 21:48:40 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.11 1997/10/25 01:10:44 momjian Exp $
* *
* Alistair Crooks added the code for the regex caching * Alistair Crooks added the code for the regex caching
* agc - cached the regular expressions used - there's a good chance * agc - cached the regular expressions used - there's a good chance
...@@ -189,7 +189,7 @@ fixedlen_regexeq(char *s, struct varlena * p, int charlen, int cflags) ...@@ -189,7 +189,7 @@ fixedlen_regexeq(char *s, struct varlena * p, int charlen, int cflags)
/* be sure sterm is null-terminated */ /* be sure sterm is null-terminated */
sterm = (char *) palloc(charlen + 1); sterm = (char *) palloc(charlen + 1);
strNcpy(sterm, s, charlen); StrNCpy(sterm, s, charlen+1);
result = RE_compile_and_execute(p, sterm, cflags); result = RE_compile_and_execute(p, sterm, cflags);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.7 1997/09/08 02:30:58 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.8 1997/10/25 01:10:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -133,7 +133,7 @@ regprocout(RegProcedure proid) ...@@ -133,7 +133,7 @@ regprocout(RegProcedure proid)
RelationGetTupleDescriptor(proc), &isnull); RelationGetTupleDescriptor(proc), &isnull);
if (!isnull) if (!isnull)
{ {
strNcpy(result, s, 16); StrNCpy(result, s, 16);
break; break;
} }
elog(FATAL, "regprocout: null procedure %d", proid); elog(FATAL, "regprocout: null procedure %d", proid);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.10 1997/09/08 02:31:05 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.11 1997/10/25 01:10:50 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -106,7 +106,7 @@ bpcharout(char *s) ...@@ -106,7 +106,7 @@ bpcharout(char *s)
{ {
len = *(int32 *) s - 4; len = *(int32 *) s - 4;
result = (char *) palloc(len + 1); result = (char *) palloc(len + 1);
strNcpy(result, s + 4, len); /* these are blank-padded */ StrNCpy(result, s + 4, len+1); /* these are blank-padded */
} }
return (result); return (result);
} }
...@@ -145,7 +145,7 @@ varcharin(char *s, int dummy, int typlen) ...@@ -145,7 +145,7 @@ varcharin(char *s, int dummy, int typlen)
result = (char *) palloc(typlen); result = (char *) palloc(typlen);
*(int32 *) result = typlen; *(int32 *) result = typlen;
strncpy(result + 4, s, len); strncpy(result + 4, s, len+1);
return (result); return (result);
} }
...@@ -166,7 +166,7 @@ varcharout(char *s) ...@@ -166,7 +166,7 @@ varcharout(char *s)
{ {
len = *(int32 *) s - 4; len = *(int32 *) s - 4;
result = (char *) palloc(len + 1); result = (char *) palloc(len + 1);
strNcpy(result, s + 4, len); StrNCpy(result, s + 4, len+1);
} }
return (result); return (result);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.26 1997/10/15 06:36:08 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.27 1997/10/25 01:10:52 momjian Exp $
* *
* NOTES * NOTES
* Sorts the first relation into the second relation. * Sorts the first relation into the second relation.
...@@ -1006,7 +1006,7 @@ gettape() ...@@ -1006,7 +1006,7 @@ gettape()
* now, copy template with final null into palloc'd space * now, copy template with final null into palloc'd space
*/ */
strNcpy(tp->tl_name, uniqueName, MAXPGPATH-1); StrNCpy(tp->tl_name, uniqueName, MAXPGPATH);
file = AllocateFile(tp->tl_name, "w+"); file = AllocateFile(tp->tl_name, "w+");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: c.h,v 1.22 1997/09/18 18:48:32 momjian Exp $ * $Id: c.h,v 1.23 1997/10/25 01:10:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* 5) IsValid macros for system types * 5) IsValid macros for system types
* 6) offsetof, lengthof, endof * 6) offsetof, lengthof, endof
* 7) exception handling definitions, Assert, Trap, etc macros * 7) exception handling definitions, Assert, Trap, etc macros
* 8) Min, Max, Abs, strNcpy macros * 8) Min, Max, Abs, StrNCpy macros
* 9) externs * 9) externs
* 10) Berkeley-specific defs * 10) Berkeley-specific defs
* 11) system-specific hacks * 11) system-specific hacks
...@@ -686,11 +686,15 @@ typedef struct Exception ...@@ -686,11 +686,15 @@ typedef struct Exception
#define Abs(x) ((x) >= 0 ? (x) : -(x)) #define Abs(x) ((x) >= 0 ? (x) : -(x))
/* /*
* strNcpy -- * StrNCpy --
* Does string copy, and forces terminating NULL * Does string copy, and forces terminating NULL
*/ */
/* we do this so if the macro is used in an if action, it will work */ /* we do this so if the macro is used in an if action, it will work */
#define strNcpy(dst,src,len) (strncpy((dst),(src),(len)),*((dst)+(len))='\0') #define StrNCpy(dst,src,len) do { \
strncpy((dst),(src),(len)); \
if (len > 0) \
*((dst)+(len)-1)='\0'; \
} while (0)
/* Get a bit mask of the bits set in non-int32 aligned addresses */ /* Get a bit mask of the bits set in non-int32 aligned addresses */
#define INT_ALIGN_MASK (sizeof(int32) - 1) #define INT_ALIGN_MASK (sizeof(int32) - 1)
......
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