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
|
* 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...
|
* fix me when we figure out what we want to do about ANSIfication...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
#ifdef HAVE_LIMITS_H
|
#ifdef HAVE_LIMITS_H
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@ -90,10 +91,15 @@ int28in(char *intString)
|
|||||||
{
|
{
|
||||||
if (sscanf(intString, "%hd", &result[slot]) != 1)
|
if (sscanf(intString, "%hd", &result[slot]) != 1)
|
||||||
break;
|
break;
|
||||||
do
|
while (*intString && isspace(*intString))
|
||||||
|
intString++;
|
||||||
|
while (*intString && !isspace(*intString))
|
||||||
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)
|
while (slot < INDEX_MAX_KEYS)
|
||||||
result[slot++] = 0;
|
result[slot++] = 0;
|
||||||
|
|
||||||
@ -104,31 +110,36 @@ int28in(char *intString)
|
|||||||
* int28out - converts internal form to "num num ..."
|
* int28out - converts internal form to "num num ..."
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
int28out(int16 *shs)
|
int28out(int16 *int2Array)
|
||||||
{
|
{
|
||||||
int num;
|
int num, maxnum;
|
||||||
int16 *sp;
|
|
||||||
char *rp;
|
char *rp;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
if (shs == NULL)
|
if (int2Array == NULL)
|
||||||
{
|
{
|
||||||
result = (char *) palloc(2);
|
result = (char *) palloc(2);
|
||||||
result[0] = '-';
|
result[0] = '-';
|
||||||
result[1] = '\0';
|
result[1] = '\0';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
rp = result = (char *) palloc(INDEX_MAX_KEYS * 7);
|
|
||||||
/* assumes sign, 5 digits, ' ' */
|
/* find last non-zero value in vector */
|
||||||
sp = shs;
|
for (maxnum = INDEX_MAX_KEYS-1; maxnum >= 0; maxnum--)
|
||||||
for (num = INDEX_MAX_KEYS; num != 0; num--)
|
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')
|
while (*++rp != '\0')
|
||||||
;
|
;
|
||||||
*rp++ = ' ';
|
|
||||||
}
|
}
|
||||||
*--rp = '\0';
|
*rp = '\0';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,13 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 "postgres.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
@ -41,10 +42,15 @@ oid8in(char *oidString)
|
|||||||
{
|
{
|
||||||
if (sscanf(oidString, "%u", &result[slot]) != 1)
|
if (sscanf(oidString, "%u", &result[slot]) != 1)
|
||||||
break;
|
break;
|
||||||
do
|
while (*oidString && isspace(*oidString))
|
||||||
|
oidString++;
|
||||||
|
while (*oidString && !isspace(*oidString))
|
||||||
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)
|
while (slot < INDEX_MAX_KEYS)
|
||||||
result[slot++] = 0;
|
result[slot++] = 0;
|
||||||
|
|
||||||
@ -57,8 +63,7 @@ oid8in(char *oidString)
|
|||||||
char *
|
char *
|
||||||
oid8out(Oid *oidArray)
|
oid8out(Oid *oidArray)
|
||||||
{
|
{
|
||||||
int num;
|
int num, maxnum;
|
||||||
Oid *sp;
|
|
||||||
char *rp;
|
char *rp;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
@ -70,17 +75,22 @@ oid8out(Oid *oidArray)
|
|||||||
return result;
|
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, ' ' */
|
/* assumes sign, 10 digits, ' ' */
|
||||||
rp = result = (char *) palloc(INDEX_MAX_KEYS * 12);
|
rp = result = (char *) palloc(maxnum * 12 + 1);
|
||||||
sp = oidArray;
|
for (num = 0; num <= maxnum; num++)
|
||||||
for (num = INDEX_MAX_KEYS; num != 0; num--)
|
|
||||||
{
|
{
|
||||||
ltoa(*sp++, rp);
|
if (num != 0)
|
||||||
|
*rp++ = ' ';
|
||||||
|
ltoa(oidArray[num], rp);
|
||||||
while (*++rp != '\0')
|
while (*++rp != '\0')
|
||||||
;
|
;
|
||||||
*rp++ = ' ';
|
|
||||||
}
|
}
|
||||||
*--rp = '\0';
|
*rp = '\0';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
# Copyright (c) 1994, Regents of the University of California
|
# Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# 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
|
NAME= ecpg
|
||||||
SO_MAJOR_VERSION= 3
|
SO_MAJOR_VERSION= 3
|
||||||
SO_MINOR_VERSION= 0.9
|
SO_MINOR_VERSION= 1.0
|
||||||
|
|
||||||
SRCDIR= @top_srcdir@
|
SRCDIR= @top_srcdir@
|
||||||
include $(SRCDIR)/Makefile.global
|
include $(SRCDIR)/Makefile.global
|
||||||
|
@ -2,7 +2,7 @@ SRCDIR= ../../..
|
|||||||
include $(SRCDIR)/Makefile.global
|
include $(SRCDIR)/Makefile.global
|
||||||
|
|
||||||
MAJOR_VERSION=2
|
MAJOR_VERSION=2
|
||||||
MINOR_VERSION=6
|
MINOR_VERSION=7
|
||||||
PATCHLEVEL=14
|
PATCHLEVEL=14
|
||||||
|
|
||||||
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
|
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
# Makefile for pgeasy library
|
# Makefile for pgeasy library
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# 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
|
NAME= pgeasy
|
||||||
SO_MAJOR_VERSION= 2
|
SO_MAJOR_VERSION= 2
|
||||||
SO_MINOR_VERSION= 0
|
SO_MINOR_VERSION= 1
|
||||||
|
|
||||||
SRCDIR= @top_srcdir@
|
SRCDIR= @top_srcdir@
|
||||||
include $(SRCDIR)/Makefile.global
|
include $(SRCDIR)/Makefile.global
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
# Copyright (c) 1994, Regents of the University of California
|
# Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# 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
|
NAME= pgtcl
|
||||||
SO_MAJOR_VERSION= 2
|
SO_MAJOR_VERSION= 2
|
||||||
SO_MINOR_VERSION= 0
|
SO_MINOR_VERSION= 1
|
||||||
|
|
||||||
SRCDIR= @top_srcdir@
|
SRCDIR= @top_srcdir@
|
||||||
include $(SRCDIR)/Makefile.global
|
include $(SRCDIR)/Makefile.global
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
# Copyright (c) 1994, Regents of the University of California
|
# Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# 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++
|
NAME= pq++
|
||||||
SO_MAJOR_VERSION= 3
|
SO_MAJOR_VERSION= 3
|
||||||
SO_MINOR_VERSION= 0
|
SO_MINOR_VERSION= 1
|
||||||
|
|
||||||
SRCDIR= @top_srcdir@
|
SRCDIR= @top_srcdir@
|
||||||
include $(SRCDIR)/Makefile.global
|
include $(SRCDIR)/Makefile.global
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
# Copyright (c) 1994, Regents of the University of California
|
# Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# 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
|
NAME= pq
|
||||||
SO_MAJOR_VERSION= 2
|
SO_MAJOR_VERSION= 2
|
||||||
SO_MINOR_VERSION= 0
|
SO_MINOR_VERSION= 1
|
||||||
|
|
||||||
SRCDIR= @top_srcdir@
|
SRCDIR= @top_srcdir@
|
||||||
include $(SRCDIR)/Makefile.global
|
include $(SRCDIR)/Makefile.global
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
VERSION = 0.25
|
VERSION = 0.26
|
||||||
EXTVER = .0
|
EXTVER = .0
|
||||||
|
|
||||||
SO_MAJOR_VERSION = 0
|
SO_MAJOR_VERSION = 0
|
||||||
SO_MINOR_VERSION = 25
|
SO_MINOR_VERSION = 26
|
||||||
|
@ -17,3 +17,4 @@ update documentation
|
|||||||
psql help in psqlHelp.c
|
psql help in psqlHelp.c
|
||||||
man pages
|
man pages
|
||||||
sgml docs
|
sgml docs
|
||||||
|
update VERSION numbers of interfaces
|
||||||
|
Loading…
Reference in New Issue
Block a user