mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
Update int28out and out8out and _in_ functions to handle trailing zeros
properly.
This commit is contained in:
parent
752314eb26
commit
3f03f74f36
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.29 2000/01/10 05:23:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.30 2000/01/10 15:41:26 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -29,6 +29,7 @@
|
||||
* fix me when we figure out what we want to do about ANSIfication...
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include "postgres.h"
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
@ -90,10 +91,15 @@ int28in(char *intString)
|
||||
{
|
||||
if (sscanf(intString, "%hd", &result[slot]) != 1)
|
||||
break;
|
||||
do
|
||||
while (*intString && isspace(*intString))
|
||||
intString++;
|
||||
while (*intString && !isspace(*intString))
|
||||
intString++;
|
||||
while (*intString && *intString != ' ')
|
||||
}
|
||||
while (*intString && isspace(*intString))
|
||||
intString++;
|
||||
if (*intString)
|
||||
elog(ERROR,"int28 value has too many values");
|
||||
while (slot < INDEX_MAX_KEYS)
|
||||
result[slot++] = 0;
|
||||
|
||||
@ -104,31 +110,36 @@ int28in(char *intString)
|
||||
* int28out - converts internal form to "num num ..."
|
||||
*/
|
||||
char *
|
||||
int28out(int16 *shs)
|
||||
int28out(int16 *int2Array)
|
||||
{
|
||||
int num;
|
||||
int16 *sp;
|
||||
int num, maxnum;
|
||||
char *rp;
|
||||
char *result;
|
||||
|
||||
if (shs == NULL)
|
||||
if (int2Array == NULL)
|
||||
{
|
||||
result = (char *) palloc(2);
|
||||
result[0] = '-';
|
||||
result[1] = '\0';
|
||||
return result;
|
||||
}
|
||||
rp = result = (char *) palloc(INDEX_MAX_KEYS * 7);
|
||||
/* assumes sign, 5 digits, ' ' */
|
||||
sp = shs;
|
||||
for (num = INDEX_MAX_KEYS; num != 0; num--)
|
||||
|
||||
/* find last non-zero value in vector */
|
||||
for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
|
||||
if (int2Array[maxnum] != 0)
|
||||
break;
|
||||
|
||||
/* assumes sign, 5 digits, ' ' */
|
||||
rp = result = (char *) palloc(maxnum * 7 + 1);
|
||||
for (num = 0; num <= maxnum; num++)
|
||||
{
|
||||
itoa(*sp++, rp);
|
||||
if (num != 0)
|
||||
*rp++ = ' ';
|
||||
ltoa(int2Array[num], rp);
|
||||
while (*++rp != '\0')
|
||||
;
|
||||
*rp++ = ' ';
|
||||
}
|
||||
*--rp = '\0';
|
||||
*rp = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -7,12 +7,13 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.30 2000/01/10 05:23:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.31 2000/01/10 15:41:26 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include <ctype.h>
|
||||
#include "postgres.h"
|
||||
#include "utils/builtins.h"
|
||||
|
||||
@ -41,10 +42,15 @@ oid8in(char *oidString)
|
||||
{
|
||||
if (sscanf(oidString, "%u", &result[slot]) != 1)
|
||||
break;
|
||||
do
|
||||
while (*oidString && isspace(*oidString))
|
||||
oidString++;
|
||||
while (*oidString && !isspace(*oidString))
|
||||
oidString++;
|
||||
while (*oidString && *oidString != ' ')
|
||||
}
|
||||
while (*oidString && isspace(*oidString))
|
||||
oidString++;
|
||||
if (*oidString)
|
||||
elog(ERROR,"oid8 value has too many values");
|
||||
while (slot < INDEX_MAX_KEYS)
|
||||
result[slot++] = 0;
|
||||
|
||||
@ -57,8 +63,7 @@ oid8in(char *oidString)
|
||||
char *
|
||||
oid8out(Oid *oidArray)
|
||||
{
|
||||
int num;
|
||||
Oid *sp;
|
||||
int num, maxnum;
|
||||
char *rp;
|
||||
char *result;
|
||||
|
||||
@ -70,17 +75,22 @@ oid8out(Oid *oidArray)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* find last non-zero value in vector */
|
||||
for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
|
||||
if (oidArray[maxnum] != 0)
|
||||
break;
|
||||
|
||||
/* assumes sign, 10 digits, ' ' */
|
||||
rp = result = (char *) palloc(INDEX_MAX_KEYS * 12);
|
||||
sp = oidArray;
|
||||
for (num = INDEX_MAX_KEYS; num != 0; num--)
|
||||
rp = result = (char *) palloc(maxnum * 12 + 1);
|
||||
for (num = 0; num <= maxnum; num++)
|
||||
{
|
||||
ltoa(*sp++, rp);
|
||||
if (num != 0)
|
||||
*rp++ = ' ';
|
||||
ltoa(oidArray[num], rp);
|
||||
while (*++rp != '\0')
|
||||
;
|
||||
*rp++ = ' ';
|
||||
}
|
||||
*--rp = '\0';
|
||||
*rp = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.54 1999/12/16 06:53:10 meskes Exp $
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.55 2000/01/10 15:41:27 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
NAME= ecpg
|
||||
SO_MAJOR_VERSION= 3
|
||||
SO_MINOR_VERSION= 0.9
|
||||
SO_MINOR_VERSION= 1.0
|
||||
|
||||
SRCDIR= @top_srcdir@
|
||||
include $(SRCDIR)/Makefile.global
|
||||
|
@ -2,7 +2,7 @@ SRCDIR= ../../..
|
||||
include $(SRCDIR)/Makefile.global
|
||||
|
||||
MAJOR_VERSION=2
|
||||
MINOR_VERSION=6
|
||||
MINOR_VERSION=7
|
||||
PATCHLEVEL=14
|
||||
|
||||
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
|
||||
|
@ -4,13 +4,13 @@
|
||||
# Makefile for pgeasy library
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpgeasy/Attic/Makefile.in,v 1.4 1999/12/16 01:25:16 momjian Exp $
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpgeasy/Attic/Makefile.in,v 1.5 2000/01/10 15:41:28 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
NAME= pgeasy
|
||||
SO_MAJOR_VERSION= 2
|
||||
SO_MINOR_VERSION= 0
|
||||
SO_MINOR_VERSION= 1
|
||||
|
||||
SRCDIR= @top_srcdir@
|
||||
include $(SRCDIR)/Makefile.global
|
||||
|
@ -6,13 +6,13 @@
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.37 1999/12/16 01:25:17 momjian Exp $
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile.in,v 1.38 2000/01/10 15:41:29 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
NAME= pgtcl
|
||||
SO_MAJOR_VERSION= 2
|
||||
SO_MINOR_VERSION= 0
|
||||
SO_MINOR_VERSION= 1
|
||||
|
||||
SRCDIR= @top_srcdir@
|
||||
include $(SRCDIR)/Makefile.global
|
||||
|
@ -6,13 +6,13 @@
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.19 1999/12/16 01:25:20 momjian Exp $
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.20 2000/01/10 15:41:31 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
NAME= pq++
|
||||
SO_MAJOR_VERSION= 3
|
||||
SO_MINOR_VERSION= 0
|
||||
SO_MINOR_VERSION= 1
|
||||
|
||||
SRCDIR= @top_srcdir@
|
||||
include $(SRCDIR)/Makefile.global
|
||||
|
@ -6,13 +6,13 @@
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.50 1999/12/16 01:25:19 momjian Exp $
|
||||
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.51 2000/01/10 15:41:30 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
NAME= pq
|
||||
SO_MAJOR_VERSION= 2
|
||||
SO_MINOR_VERSION= 0
|
||||
SO_MINOR_VERSION= 1
|
||||
|
||||
SRCDIR= @top_srcdir@
|
||||
include $(SRCDIR)/Makefile.global
|
||||
|
@ -1,5 +1,5 @@
|
||||
VERSION = 0.25
|
||||
VERSION = 0.26
|
||||
EXTVER = .0
|
||||
|
||||
SO_MAJOR_VERSION = 0
|
||||
SO_MINOR_VERSION = 25
|
||||
SO_MINOR_VERSION = 26
|
||||
|
@ -17,3 +17,4 @@ update documentation
|
||||
psql help in psqlHelp.c
|
||||
man pages
|
||||
sgml docs
|
||||
update VERSION numbers of interfaces
|
||||
|
Loading…
Reference in New Issue
Block a user