summaryrefslogtreecommitdiff
path: root/contrib/string
diff options
context:
space:
mode:
authorBruce Momjian2000-02-13 18:59:53 +0000
committerBruce Momjian2000-02-13 18:59:53 +0000
commita2226ad2373dcea5063fb8dafee1d52487be15cd (patch)
tree1b69a17c51bb0338af72f7a19f9ebee05cf11af6 /contrib/string
parent77d31cf3c17070c38b6536fc8b8f264525930cda (diff)
contrib-array.patch
this is an old patch which I have already submitted and never seen in the sources. It corrects the datatype oids used in some iterator functions. This bug has been reported to me by many other people. contrib-datetime.patch some code contributed by Reiner Dassing <[email protected]> contrib-makefiles.patch fixes all my contrib makefiles which don't work with some compilers, as reported to me by another user. contrib-miscutil.patch an old patch for one of my old contribs. contrib-string.patch a small change to the c-like text output functions. Now the '{' is escaped only at the beginning of the string to distinguish it from arrays, and the '}' is no more escaped. elog-lineno.patch adds the current lineno of CopyFrom to elog messages. This is very useful when you load a 1 million tuples table from an external file and there is a bad value somehere. Currently you get an error message but you can't know where is the bad data. The patch uses a variable which was declared static in copy.c. The variable is now exported and initialized to 0. It is always cleared at the end of the copy or at the first elog message or when the copy is canceled. I know this is very ugly but I can't find any better way of knowing where the copy fails and I have this problem quite often. plperl-makefile.patch fixes a typo in a makefile, but the error must be elsewhere because it is a file generated automatically. Please have a look. tprintf-timestamp.patch restores the original 2-digit year format, assuming that the two century digits don't carry much information and that '000202' is easier to read than 20000202. Being only a log file it shouldn't break anything. Please apply the patches before the next scheduled code freeze. I also noticed that some of the contribs don't compile correcly. Should we ask people to fix their code or rename their makefiles so that they are ignored by the top makefile? -- Massimo Dal Zotto
Diffstat (limited to 'contrib/string')
-rw-r--r--contrib/string/Makefile8
-rw-r--r--contrib/string/string_io.c37
-rw-r--r--contrib/string/string_io.h19
3 files changed, 35 insertions, 29 deletions
diff --git a/contrib/string/Makefile b/contrib/string/Makefile
index b77ace937c..dd8f0e6f2a 100644
--- a/contrib/string/Makefile
+++ b/contrib/string/Makefile
@@ -11,10 +11,10 @@ SRCDIR = $(PGDIR)/src
include $(SRCDIR)/Makefile.global
-INCLUDE_OPT = -I ./ \
- -I $(SRCDIR)/ \
- -I $(SRCDIR)/include \
- -I $(SRCDIR)/port/$(PORTNAME)
+INCLUDE_OPT = -I./ \
+ -I$(SRCDIR)/ \
+ -I$(SRCDIR)/include \
+ -I$(SRCDIR)/port/$(PORTNAME)
CFLAGS += $(INCLUDE_OPT) $(CFLAGS_SL)
diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c
index e1fc867497..9407e6a21b 100644
--- a/contrib/string/string_io.c
+++ b/contrib/string/string_io.c
@@ -50,8 +50,8 @@
* representation of data.
*/
-char *
-string_output(char *data, int size)
+unsigned char *
+string_output(unsigned char *data, int size)
{
register unsigned char c,
*p,
@@ -79,8 +79,6 @@ string_output(char *data, int size)
{
case '\\':
case '"':
- case '{':
- case '}':
case '\b':
case '\f':
case '\n':
@@ -89,6 +87,12 @@ string_output(char *data, int size)
case '\v':
len++;
break;
+ case '{':
+ /* Escape beginning of string, to distinguish from arrays */
+ if (p == data) {
+ len++;
+ }
+ break;
default:
if (NOTPRINTABLE(*p))
len += 3;
@@ -104,8 +108,6 @@ string_output(char *data, int size)
{
case '\\':
case '"':
- case '{':
- case '}':
*r++ = '\\';
*r++ = c;
break;
@@ -133,6 +135,13 @@ string_output(char *data, int size)
*r++ = '\\';
*r++ = 'v';
break;
+ case '{':
+ /* Escape beginning of string, to distinguish from arrays */
+ if (p == data) {
+ *r++ = '\\';
+ }
+ *r++ = c;
+ break;
default:
if (NOTPRINTABLE(c))
{
@@ -180,8 +189,8 @@ string_output(char *data, int size)
* a pointer to the new string or the header.
*/
-char *
-string_input(char *str, int size, int hdrsize, int *rtn_size)
+unsigned char *
+string_input(unsigned char *str, int size, int hdrsize, int *rtn_size)
{
register unsigned char *p,
*r;
@@ -285,7 +294,7 @@ string_input(char *str, int size, int hdrsize, int *rtn_size)
return ((char *) result);
}
-char *
+unsigned char *
c_charout(int32 c)
{
char str[2];
@@ -300,7 +309,7 @@ c_charout(int32 c)
* This can be used for SET, bytea, text and unknown data types
*/
-char *
+unsigned char *
c_textout(struct varlena * vlena)
{
int len = 0;
@@ -318,8 +327,8 @@ c_textout(struct varlena * vlena)
* This can be used for varchar and bpchar strings
*/
-char *
-c_varcharout(char *s)
+unsigned char *
+c_varcharout(unsigned char *s)
{
int len = 0;
@@ -333,7 +342,7 @@ c_varcharout(char *s)
#if 0
struct varlena *
-c_textin(char *str)
+c_textin(unsigned char *str)
{
struct varlena *result;
int len;
@@ -348,7 +357,7 @@ c_textin(char *str)
}
int32 *
-c_charin(char *str)
+c_charin(unsigned char *str)
{
return (string_input(str, 1, 0, NULL));
}
diff --git a/contrib/string/string_io.h b/contrib/string/string_io.h
index b1d2b7e2c2..e79d7fd28f 100644
--- a/contrib/string/string_io.h
+++ b/contrib/string/string_io.h
@@ -1,19 +1,16 @@
#ifndef STRING_IO_H
#define STRING_IO_H
-char *string_output(char *data, int size);
-char *string_input(char *str, int size, int hdrsize, int *rtn_size);
-char *c_charout(int32 c);
-char *c_char2out(uint16 s);
-char *c_char4out(uint32 s);
-char *c_char8out(char *s);
-char *c_char16out(char *s);
-char *c_textout(struct varlena * vlena);
-char *c_varcharout(char *s);
+unsigned char* string_output(unsigned char *data, int size);
+unsigned char* string_input(unsigned char *str, int size, int hdrsize,
+ int *rtn_size);
+unsigned char* c_charout(int32 c);
+unsigned char* c_textout(struct varlena * vlena);
+unsigned char* c_varcharout(unsigned char *s);
#if 0
-struct varlena *c_textin(char *str);
-char *c_char16in(char *str);
+struct varlena* c_textin(unsigned char *str);
+int32* c_charin(unsigned char *str)
#endif
#endif