Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
8ebdac0e
Commit
8ebdac0e
authored
Sep 22, 2001
by
Tatsuo Ishii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove test drivers
Also fix comment in conv.c.
parent
6bbdd7a9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
3 additions
and
405 deletions
+3
-405
src/backend/utils/mb/Makefile
src/backend/utils/mb/Makefile
+1
-12
src/backend/utils/mb/conv.c
src/backend/utils/mb/conv.c
+2
-3
src/backend/utils/mb/liketest.c
src/backend/utils/mb/liketest.c
+0
-271
src/backend/utils/mb/palloc.c
src/backend/utils/mb/palloc.c
+0
-25
src/backend/utils/mb/sjistest.c
src/backend/utils/mb/sjistest.c
+0
-41
src/backend/utils/mb/utftest.c
src/backend/utils/mb/utftest.c
+0
-53
No files found.
src/backend/utils/mb/Makefile
View file @
8ebdac0e
...
...
@@ -4,7 +4,7 @@
# Makefile for utils/mb
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.1
6 2001/09/06 04:57:29
ishii Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.1
7 2001/09/22 08:44:47
ishii Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -19,17 +19,6 @@ all: SUBSYS.o
SUBSYS.o
:
$(OBJS)
$(LD)
$(LDREL)
$(LDOUT)
SUBSYS.o
$(OBJS)
utftest.o
:
utftest.c conv.c wchar.c mbutils.c
sjistest
:
sjistest.o palloc.o encnames.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o
$(CC)
$(CFLAGS)
$(LDFLAGS)
$^
$(LIBS)
-o
$@
liketest
:
liketest.o palloc.o $(OBJS)
$(CC)
$(CFLAGS)
$(LDFLAGS)
$^
$(LIBS)
-o
$@
utftest
:
utftest.o palloc.o encnames.o wstrcmp.o wstrncmp.o big5.o
$(CC)
$(CFLAGS)
$(LDFLAGS)
$^
$(LIBS)
-o
$@
depend dep
:
$(CC)
-MM
$(CFLAGS)
*
.c
>
depend
...
...
src/backend/utils/mb/conv.c
View file @
8ebdac0e
...
...
@@ -6,7 +6,7 @@
* WIN1250 client encoding support contributed by Pavel Behal
* SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
*
* $Id: conv.c,v 1.2
8 2001/09/11 04:50:36
ishii Exp $
* $Id: conv.c,v 1.2
9 2001/09/22 08:44:48
ishii Exp $
*
*
*/
...
...
@@ -63,8 +63,7 @@
/*
* convert bogus chars that cannot be represented in the current
encoding
* system.
* encoding system.
*/
static
void
printBogusChar
(
unsigned
char
**
mic
,
unsigned
char
**
p
)
...
...
src/backend/utils/mb/liketest.c
deleted
100644 → 0
View file @
6bbdd7a9
#include "postgres_fe.h"
#include <ctype.h>
#include "mb/pg_wchar.h"
#define LIKE_FALSE 0
#define LIKE_TRUE 1
#define LIKE_ABORT 2
#define PG_CHAR unsigned char
#define UCHARMAX 0xff
/*----------------------------------------------------------------*/
static
int
wchareq
(
unsigned
char
*
p1
,
unsigned
char
*
p2
)
{
int
l
;
l
=
pg_mblen
(
p1
);
if
(
pg_mblen
(
p2
)
!=
l
)
return
(
0
);
while
(
l
--
)
{
if
(
*
p1
++
!=
*
p2
++
)
return
(
0
);
}
return
(
1
);
}
static
int
iwchareq
(
unsigned
char
*
p1
,
unsigned
char
*
p2
)
{
int
c1
,
c2
;
int
l
;
/*
* short cut. if *p1 and *p2 is lower than UCHARMAX, then we assume
* they are ASCII
*/
if
(
*
p1
<
UCHARMAX
&&
*
p2
<
UCHARMAX
)
return
(
tolower
(
*
p1
)
==
tolower
(
*
p2
));
if
(
*
p1
<
UCHARMAX
)
c1
=
tolower
(
*
p1
);
else
{
l
=
pg_mblen
(
p1
);
(
void
)
pg_mb2wchar_with_len
(
p1
,
(
pg_wchar
*
)
&
c1
,
l
);
c1
=
tolower
(
c1
);
}
if
(
*
p2
<
UCHARMAX
)
c2
=
tolower
(
*
p2
);
else
{
l
=
pg_mblen
(
p2
);
(
void
)
pg_mb2wchar_with_len
(
p2
,
(
pg_wchar
*
)
&
c2
,
l
);
c2
=
tolower
(
c2
);
}
return
(
c1
==
c2
);
}
#ifdef MULTIBYTE
#define CHAREQ(p1, p2) wchareq(p1, p2)
#define ICHAREQ(p1, p2) iwchareq(p1, p2)
#define NextChar(p, plen) {int __l = pg_mblen(p); (p) +=__l; (plen) -=__l;}
#else
#define CHAREQ(p1, p2) (*(p1) == *(p2))
#define ICHAREQ(p1, p2) (tolower(*(p1)) == tolower(*(p2)))
#define NextChar(p, plen) (p)++, (plen)--
#endif
static
int
MatchText
(
PG_CHAR
*
t
,
int
tlen
,
PG_CHAR
*
p
,
int
plen
,
char
*
e
)
{
/*
* Fast path for match-everything pattern Include weird case of escape
* character as a percent sign or underscore, when presumably that
* wildcard character becomes a literal.
*/
if
((
plen
==
1
)
&&
(
*
p
==
'%'
)
&&
!
((
e
!=
NULL
)
&&
(
*
e
==
'%'
)))
return
LIKE_TRUE
;
while
((
tlen
>
0
)
&&
(
plen
>
0
))
{
/*
* If an escape character was specified and we find it here in the
* pattern, then we'd better have an exact match for the next
* character.
*/
if
((
e
!=
NULL
)
&&
CHAREQ
(
p
,
e
))
{
NextChar
(
p
,
plen
);
if
((
plen
<=
0
)
||
!
CHAREQ
(
t
,
p
))
return
LIKE_FALSE
;
}
else
if
(
*
p
==
'%'
)
{
/* %% is the same as % according to the SQL standard */
/* Advance past all %'s */
while
((
plen
>
0
)
&&
(
*
p
==
'%'
))
NextChar
(
p
,
plen
);
/* Trailing percent matches everything. */
if
(
plen
<=
0
)
return
LIKE_TRUE
;
/*
* Otherwise, scan for a text position at which we can match
* the rest of the pattern.
*/
while
(
tlen
>
0
)
{
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
*/
if
(
CHAREQ
(
t
,
p
)
||
(
*
p
==
'_'
)
||
((
e
!=
NULL
)
&&
CHAREQ
(
p
,
e
)))
{
int
matched
=
MatchText
(
t
,
tlen
,
p
,
plen
,
e
);
if
(
matched
!=
LIKE_FALSE
)
return
matched
;
/* TRUE or ABORT */
}
NextChar
(
t
,
tlen
);
}
/*
* End of text with no match, so no point in trying later
* places to start matching this pattern.
*/
return
LIKE_ABORT
;
}
else
if
((
*
p
!=
'_'
)
&&
!
CHAREQ
(
t
,
p
))
{
/*
* Not the single-character wildcard and no explicit match?
* Then time to quit...
*/
return
LIKE_FALSE
;
}
NextChar
(
t
,
tlen
);
NextChar
(
p
,
plen
);
}
if
(
tlen
>
0
)
return
LIKE_FALSE
;
/* end of pattern, but not of text */
/* End of input string. Do we have matching pattern remaining? */
while
((
plen
>
0
)
&&
(
*
p
==
'%'
))
/* allow multiple %'s at end of
* pattern */
NextChar
(
p
,
plen
);
if
(
plen
<=
0
)
return
LIKE_TRUE
;
/*
* End of text with no match, so no point in trying later places to
* start matching this pattern.
*/
return
LIKE_ABORT
;
}
/* MatchText() */
static
int
MatchTextLower
(
PG_CHAR
*
t
,
int
tlen
,
PG_CHAR
*
p
,
int
plen
,
char
*
e
)
{
/*
* Fast path for match-everything pattern Include weird case of escape
* character as a percent sign or underscore, when presumably that
* wildcard character becomes a literal.
*/
if
((
plen
==
1
)
&&
(
*
p
==
'%'
)
&&
!
((
e
!=
NULL
)
&&
(
*
e
==
'%'
)))
return
LIKE_TRUE
;
while
((
tlen
>
0
)
&&
(
plen
>
0
))
{
/*
* If an escape character was specified and we find it here in the
* pattern, then we'd better have an exact match for the next
* character.
*/
if
((
e
!=
NULL
)
&&
ICHAREQ
(
p
,
e
))
{
NextChar
(
p
,
plen
);
if
((
plen
<=
0
)
||
!
ICHAREQ
(
t
,
p
))
return
LIKE_FALSE
;
}
else
if
(
*
p
==
'%'
)
{
/* %% is the same as % according to the SQL standard */
/* Advance past all %'s */
while
((
plen
>
0
)
&&
(
*
p
==
'%'
))
NextChar
(
p
,
plen
);
/* Trailing percent matches everything. */
if
(
plen
<=
0
)
return
LIKE_TRUE
;
/*
* Otherwise, scan for a text position at which we can match
* the rest of the pattern.
*/
while
(
tlen
>
0
)
{
/*
* Optimization to prevent most recursion: don't recurse
* unless first pattern char might match this text char.
*/
if
(
ICHAREQ
(
t
,
p
)
||
(
*
p
==
'_'
)
||
((
e
!=
NULL
)
&&
ICHAREQ
(
p
,
e
)))
{
int
matched
=
MatchText
(
t
,
tlen
,
p
,
plen
,
e
);
if
(
matched
!=
LIKE_FALSE
)
return
matched
;
/* TRUE or ABORT */
}
NextChar
(
t
,
tlen
);
}
/*
* End of text with no match, so no point in trying later
* places to start matching this pattern.
*/
return
LIKE_ABORT
;
}
else
if
((
*
p
!=
'_'
)
&&
!
ICHAREQ
(
t
,
p
))
return
LIKE_FALSE
;
NextChar
(
t
,
tlen
);
NextChar
(
p
,
plen
);
}
if
(
tlen
>
0
)
return
LIKE_FALSE
;
/* end of pattern, but not of text */
/* End of input string. Do we have matching pattern remaining? */
while
((
plen
>
0
)
&&
(
*
p
==
'%'
))
/* allow multiple %'s at end of
* pattern */
NextChar
(
p
,
plen
);
if
(
plen
<=
0
)
return
LIKE_TRUE
;
/*
* End of text with no match, so no point in trying later places to
* start matching this pattern.
*/
return
LIKE_ABORT
;
}
/* MatchTextLower() */
main
()
{
unsigned
char
*
t
=
"Z01"
;
unsigned
char
*
p
=
"_Z%"
;
int
tlen
,
plen
;
tlen
=
strlen
(
t
);
plen
=
strlen
(
p
);
printf
(
"%d
\n
"
,
MatchTextLower
(
t
,
tlen
,
p
,
plen
,
"
\\
"
));
}
src/backend/utils/mb/palloc.c
deleted
100644 → 0
View file @
6bbdd7a9
#include "postgres.h"
#include "utils/memutils.h"
void
elog
(
int
lev
,
const
char
*
fmt
,...)
{
printf
(
fmt
);
}
MemoryContext
CurrentMemoryContext
;
void
*
MemoryContextAlloc
(
MemoryContext
context
,
Size
size
)
{
}
void
pfree
(
void
*
pointer
)
{
}
void
*
repalloc
(
void
*
pointer
,
Size
size
)
{
}
src/backend/utils/mb/sjistest.c
deleted
100644 → 0
View file @
6bbdd7a9
/*
* testing for sjis2mic() and mic2sjis()
*/
#include "conv.c"
int
main
()
{
unsigned
char
eucbuf
[
1024
];
unsigned
char
sjisbuf
[
1024
];
unsigned
char
sjis
[]
=
{
0x81
,
0x40
,
0xa1
,
0xf0
,
0x40
,
0xf0
,
0x9e
,
0xf5
,
0x40
,
0xfa
,
0x40
,
0xfa
,
0x54
,
0xfa
,
0x7b
,
0x00
};
int
i
;
sjis2mic
(
sjis
,
eucbuf
,
1024
);
for
(
i
=
0
;
i
<
1024
;
i
++
)
{
if
(
eucbuf
[
i
])
printf
(
"%02x "
,
eucbuf
[
i
]);
else
{
printf
(
"
\n
"
);
break
;
}
}
mic2sjis
(
eucbuf
,
sjisbuf
,
1024
);
for
(
i
=
0
;
i
<
1024
;
i
++
)
{
if
(
sjisbuf
[
i
])
printf
(
"%02x "
,
sjisbuf
[
i
]);
else
{
printf
(
"
\n
"
);
break
;
}
}
return
(
0
);
}
src/backend/utils/mb/utftest.c
deleted
100644 → 0
View file @
6bbdd7a9
/*
* $Id: utftest.c,v 1.5 2001/03/22 04:00:05 momjian Exp $
*/
#include "conv.c"
#include "wchar.c"
#include "mbutils.c"
int
main
()
{
/* Example 1 from RFC2044 */
char
utf1
[]
=
{
0x41
,
0xe2
,
0x89
,
0xa2
,
0xce
,
0x91
,
0x2e
,
0
};
/* Example 2 from RFC2044 */
char
utf2
[]
=
{
0x48
,
0x69
,
0x20
,
0x4d
,
0x6f
,
0x6d
,
0x20
,
0xe2
,
0x98
,
0xba
,
0x21
,
0
};
/* Example 3 from RFC2044 */
char
utf3
[]
=
{
0xe6
,
0x97
,
0xa5
,
0xe6
,
0x9c
,
0xac
,
0xe8
,
0xaa
,
0x9e
,
0
};
char
*
utf
[]
=
{
utf1
,
utf2
,
utf3
};
pg_wchar
ucs
[
128
];
pg_wchar
*
p
;
unsigned
char
iso
[
1024
];
int
i
;
/* UTF8-->ISO8859-2 test */
unsigned
char
utf_iso8859_2
[]
=
{
0x01
,
0x00
,
0x01
,
0x02
,
0x01
,
0x55
,
0x02
,
0xdd
,
0x00
};
printf
(
"===== testing of pg_utf2wchar_with_len =====
\n
"
);
for
(
i
=
0
;
i
<
sizeof
(
utf
)
/
sizeof
(
char
*
);
i
++
)
{
pg_utf2wchar_with_len
(
utf
[
i
],
ucs
,
128
);
p
=
ucs
;
while
(
*
p
)
{
printf
(
"%04x "
,
*
p
);
p
++
;
}
printf
(
"
\n
"
);
}
printf
(
"===== testing of utf_to_latin2 =====
\n
"
);
utf_to_latin
(
utf_iso8859_2
,
iso
,
LATIN2
,
128
);
for
(
i
=
0
;
i
<
sizeof
(
iso
)
/
sizeof
(
char
*
);
i
++
)
{
printf
(
"%04x "
,
iso
[
i
]);
if
(
iso
[
i
]
==
0x00
)
break
;
}
printf
(
"
\n
"
);
return
(
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment