Skip to content

Commit 129f1a3

Browse files
committed
Back out to_ascii patch from Karel.
1 parent 403e522 commit 129f1a3

File tree

4 files changed

+3
-195
lines changed

4 files changed

+3
-195
lines changed

src/backend/utils/adt/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile for utils/adt
33
#
4-
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.42 2000/08/04 15:45:07 momjian Exp $
4+
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.43 2000/08/04 20:46:43 momjian Exp $
55
#
66

77
subdir = src/backend/utils/adt
@@ -23,8 +23,7 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o \
2323
regexp.o regproc.o ruleutils.o selfuncs.o sets.o \
2424
tid.o timestamp.o varbit.o varchar.o varlena.o version.o \
2525
network.o mac.o inet_net_ntop.o inet_net_pton.o \
26-
ri_triggers.o pg_lzcompress.o pg_locale.o formatting.o \
27-
ascii.o
26+
ri_triggers.o pg_lzcompress.o pg_locale.o formatting.o
2827

2928
all: SUBSYS.o
3029

src/backend/utils/adt/ascii.c

Lines changed: 0 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +0,0 @@
1-
2-
/* -----------------------------------------------------------------------
3-
* ascii.c
4-
*
5-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.1 2000/08/04 20:22:51 momjian Exp $
6-
*
7-
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc
8-
*
9-
*
10-
* TO_ASCII()
11-
*
12-
* The PostgreSQL routine for string to ascii conversion.
13-
*
14-
* -----------------------------------------------------------------------
15-
*/
16-
17-
#include "postgres.h"
18-
#include "utils/builtins.h"
19-
#include "mb/pg_wchar.h"
20-
#include "utils/ascii.h"
21-
22-
static text *encode_to_ascii(text *data, int enc);
23-
24-
/* ----------
25-
* to_ascii
26-
* ----------
27-
*/
28-
char *
29-
pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int enc)
30-
{
31-
unsigned char *x = NULL;
32-
unsigned char *ascii = NULL ;
33-
int range = 0;
34-
35-
/*
36-
* relevant start for an encoding
37-
*/
38-
#define RANGE_128 128
39-
#define RANGE_160 160
40-
41-
42-
if (enc == LATIN1)
43-
{
44-
/* ----------
45-
* ISO-8859-1 <range: 160 -- 255>
46-
* ----------
47-
*/
48-
ascii = " cL Y \"Ca -R 'u ., ?AAAAAAACEEEEIIII NOOOOOxOUUUUYTBaaaaaaaceeeeiiii nooooo/ouuuuyty";
49-
range = RANGE_160;
50-
}
51-
else if (enc == LATIN2)
52-
{
53-
/* ----------
54-
* ISO-8859-2 <range: 160 -- 255>
55-
* ----------
56-
*/
57-
ascii = " A L LS \"SSTZ-ZZ a,l'ls ,sstz\"zzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTBraaaalccceeeeiiddnnoooo/ruuuuyt.";
58-
range = RANGE_160;
59-
}
60-
else if (enc == WIN1250)
61-
{
62-
/* ----------
63-
* Window CP1250 <range: 128 -- 255>
64-
* ----------
65-
*/
66-
ascii = " ' \" %S<STZZ `'\"\".-- s>stzz L A \"CS -RZ ,l'u .,as L\"lzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTBraaaalccceeeeiiddnnoooo/ruuuuyt ";
67-
range = RANGE_128;
68-
}
69-
else
70-
{
71-
elog(ERROR, "pg_to_ascii(): unsupported encoding from %s",
72-
pg_encoding_to_char(enc));
73-
}
74-
75-
/* ----------
76-
* Encode
77-
* ----------
78-
*/
79-
for (x = src; x <= src_end; x++)
80-
{
81-
if (*x < 128)
82-
*desc++ = *x;
83-
else if (*x < range)
84-
*desc++ = ' '; /* bogus 128 to 'range' */
85-
else
86-
*desc++ = ascii[*x - range];
87-
}
88-
89-
return desc;
90-
}
91-
92-
/* ----------
93-
* encode text
94-
* ----------
95-
*/
96-
static text *
97-
encode_to_ascii(text *data, int enc)
98-
{
99-
pg_to_ascii(
100-
(unsigned char *) VARDATA(data), /* src */
101-
VARDATA(data) + VARSIZE(data), /* src end */
102-
(unsigned char *) VARDATA(data), /* desc */
103-
enc); /* encoding */
104-
105-
return data;
106-
}
107-
108-
/* ----------
109-
* convert to ASCII - enc is set as 'name' arg.
110-
* ----------
111-
*/
112-
Datum
113-
to_ascii_encname(PG_FUNCTION_ARGS)
114-
{
115-
PG_RETURN_TEXT_P
116-
(
117-
encode_to_ascii
118-
(
119-
PG_GETARG_TEXT_P_COPY(0),
120-
pg_char_to_encoding( NameStr(*PG_GETARG_NAME(1)) )
121-
)
122-
);
123-
}
124-
125-
/* ----------
126-
* convert to ASCII - enc is set as int4
127-
* ----------
128-
*/
129-
Datum
130-
to_ascii_enc(PG_FUNCTION_ARGS)
131-
{
132-
PG_RETURN_TEXT_P
133-
(
134-
encode_to_ascii
135-
(
136-
PG_GETARG_TEXT_P_COPY(0),
137-
PG_GETARG_INT32(1)
138-
)
139-
);
140-
}
141-
142-
/* ----------
143-
* convert to ASCII - current enc is DatabaseEncoding
144-
* ----------
145-
*/
146-
Datum
147-
to_ascii_default(PG_FUNCTION_ARGS)
148-
{
149-
PG_RETURN_TEXT_P
150-
(
151-
encode_to_ascii
152-
(
153-
PG_GETARG_TEXT_P_COPY(0),
154-
GetDatabaseEncoding()
155-
)
156-
);
157-
}
158-
159-

src/include/catalog/pg_proc.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_proc.h,v 1.158 2000/08/04 15:45:12 momjian Exp $
10+
* $Id: pg_proc.h,v 1.159 2000/08/04 20:46:43 momjian Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2442,14 +2442,6 @@ DESCR("aggregate transition function");
24422442
DATA(insert OID = 1844 ( interval_avg PGUID 12 f t t t 1 f 1186 "1187" 100 0 0 100 interval_avg - ));
24432443
DESCR("AVG aggregate final function");
24442444

2445-
/* To ASCII conversion */
2446-
DATA(insert OID = 1845 ( to_ascii PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 to_ascii_default - ));
2447-
DESCR("encode text from DB encoding to ASCII text");
2448-
DATA(insert OID = 1846 ( to_ascii PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 to_ascii_enc - ));
2449-
DESCR("encode text from encoding to ASCII text");
2450-
DATA(insert OID = 1847 ( to_ascii PGUID 12 f t t t 2 f 25 "25 19" 100 0 0 100 to_ascii_encname - ));
2451-
DESCR("encode text from encoding to ASCII text");
2452-
24532445
DATA(insert OID = 1850 ( int28eq PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28eq - ));
24542446
DESCR("equal");
24552447
DATA(insert OID = 1851 ( int28ne PGUID 12 f t t t 2 f 16 "21 20" 100 0 0 100 int28ne - ));

src/include/utils/ascii.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +0,0 @@
1-
2-
/* -----------------------------------------------------------------------
3-
* ascii.h
4-
*
5-
* $Id: ascii.h,v 1.1 2000/08/04 20:22:52 momjian Exp $
6-
*
7-
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc
8-
*
9-
* -----------------------------------------------------------------------
10-
*/
11-
12-
#ifndef _ASCII_H_
13-
#define _ASCII_H_
14-
15-
#include "fmgr.h"
16-
17-
extern Datum to_ascii_encname(PG_FUNCTION_ARGS);
18-
extern Datum to_ascii_enc(PG_FUNCTION_ARGS);
19-
extern Datum to_ascii_default(PG_FUNCTION_ARGS);
20-
21-
extern char *pg_to_ascii(unsigned char *src, unsigned char *src_end,
22-
unsigned char *desc, int enc);
23-
24-
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy