Commit 436a2956 authored by Bruce Momjian's avatar Bruce Momjian

Re-run pgindent, fixing a problem where comment lines after a blank

comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.
parent e196eedd
...@@ -60,9 +60,9 @@ ...@@ -60,9 +60,9 @@
typedef struct remoteConn typedef struct remoteConn
{ {
PGconn *conn; /* Hold the remote connection */ PGconn *conn; /* Hold the remote connection */
int openCursorCount; /* The number of open cursors */ int openCursorCount; /* The number of open cursors */
bool newXactForCursor; /* Opened a transaction for a cursor */ bool newXactForCursor; /* Opened a transaction for a cursor */
} remoteConn; } remoteConn;
/* /*
...@@ -85,8 +85,8 @@ static Oid get_relid_from_relname(text *relname_text); ...@@ -85,8 +85,8 @@ static Oid get_relid_from_relname(text *relname_text);
static char *generate_relation_name(Oid relid); static char *generate_relation_name(Oid relid);
/* Global */ /* Global */
static remoteConn *pconn = NULL; static remoteConn *pconn = NULL;
static HTAB *remoteConnHash = NULL; static HTAB *remoteConnHash = NULL;
/* /*
* Following is list that holds multiple remote connections. * Following is list that holds multiple remote connections.
...@@ -347,7 +347,7 @@ dblink_open(PG_FUNCTION_ARGS) ...@@ -347,7 +347,7 @@ dblink_open(PG_FUNCTION_ARGS)
else else
conn = rconn->conn; conn = rconn->conn;
/* If we are not in a transaction, start one */ /* If we are not in a transaction, start one */
if (PQtransactionStatus(conn) == PQTRANS_IDLE) if (PQtransactionStatus(conn) == PQTRANS_IDLE)
{ {
res = PQexec(conn, "BEGIN"); res = PQexec(conn, "BEGIN");
...@@ -1505,7 +1505,7 @@ get_text_array_contents(ArrayType *array, int *numitems) ...@@ -1505,7 +1505,7 @@ get_text_array_contents(ArrayType *array, int *numitems)
else else
{ {
values[i] = DatumGetCString(DirectFunctionCall1(textout, values[i] = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(ptr))); PointerGetDatum(ptr)));
ptr = att_addlength(ptr, typlen, PointerGetDatum(ptr)); ptr = att_addlength(ptr, typlen, PointerGetDatum(ptr));
ptr = (char *) att_align(ptr, typalign); ptr = (char *) att_align(ptr, typalign);
} }
...@@ -1717,7 +1717,7 @@ get_sql_update(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pka ...@@ -1717,7 +1717,7 @@ get_sql_update(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pka
key = -1; key = -1;
if (key > -1) if (key > -1)
val = tgt_pkattvals[key] ? pstrdup(tgt_pkattvals[key]) : NULL; val = tgt_pkattvals[key] ? pstrdup(tgt_pkattvals[key]) : NULL;
else else
val = SPI_getvalue(tuple, tupdesc, i + 1); val = SPI_getvalue(tuple, tupdesc, i + 1);
...@@ -1744,7 +1744,7 @@ get_sql_update(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pka ...@@ -1744,7 +1744,7 @@ get_sql_update(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pka
quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname))); quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname)));
if (tgt_pkattvals != NULL) if (tgt_pkattvals != NULL)
val = tgt_pkattvals[i] ? pstrdup(tgt_pkattvals[i]) : NULL; val = tgt_pkattvals[i] ? pstrdup(tgt_pkattvals[i]) : NULL;
else else
val = SPI_getvalue(tuple, tupdesc, pkattnum); val = SPI_getvalue(tuple, tupdesc, pkattnum);
......
...@@ -39,7 +39,7 @@ g_int_consistent(PG_FUNCTION_ARGS) ...@@ -39,7 +39,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
if (strategy == BooleanSearchStrategy) if (strategy == BooleanSearchStrategy)
PG_RETURN_BOOL(execconsistent((QUERYTYPE *) query, PG_RETURN_BOOL(execconsistent((QUERYTYPE *) query,
(ArrayType *) DatumGetPointer(entry->key), (ArrayType *) DatumGetPointer(entry->key),
GIST_LEAF(entry))); GIST_LEAF(entry)));
/* XXX are we sure it's safe to scribble on the query object here? */ /* XXX are we sure it's safe to scribble on the query object here? */
/* XXX what about toasted input? */ /* XXX what about toasted input? */
...@@ -97,7 +97,7 @@ g_int_union(PG_FUNCTION_ARGS) ...@@ -97,7 +97,7 @@ g_int_union(PG_FUNCTION_ARGS)
for (i = 0; i < entryvec->n; i++) for (i = 0; i < entryvec->n; i++)
{ {
ArrayType *ent = GETENTRY(entryvec, i); ArrayType *ent = GETENTRY(entryvec, i);
CHECKARRVALID(ent); CHECKARRVALID(ent);
totlen += ARRNELEMS(ent); totlen += ARRNELEMS(ent);
...@@ -108,8 +108,8 @@ g_int_union(PG_FUNCTION_ARGS) ...@@ -108,8 +108,8 @@ g_int_union(PG_FUNCTION_ARGS)
for (i = 0; i < entryvec->n; i++) for (i = 0; i < entryvec->n; i++)
{ {
ArrayType *ent = GETENTRY(entryvec, i); ArrayType *ent = GETENTRY(entryvec, i);
int nel; int nel;
nel = ARRNELEMS(ent); nel = ARRNELEMS(ent);
memcpy(ptr, ARRPTR(ent), nel * sizeof(int4)); memcpy(ptr, ARRPTR(ent), nel * sizeof(int4));
...@@ -143,10 +143,10 @@ g_int_compress(PG_FUNCTION_ARGS) ...@@ -143,10 +143,10 @@ g_int_compress(PG_FUNCTION_ARGS)
CHECKARRVALID(r); CHECKARRVALID(r);
PREPAREARR(r); PREPAREARR(r);
if (ARRNELEMS(r)>= 2 * MAXNUMRANGE) if (ARRNELEMS(r) >= 2 * MAXNUMRANGE)
elog(NOTICE,"Input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead", elog(NOTICE, "Input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead",
2 * MAXNUMRANGE - 1, ARRNELEMS(r)); 2 * MAXNUMRANGE - 1, ARRNELEMS(r));
retval = palloc(sizeof(GISTENTRY)); retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r), gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE); entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE);
...@@ -154,12 +154,14 @@ g_int_compress(PG_FUNCTION_ARGS) ...@@ -154,12 +154,14 @@ g_int_compress(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(retval); PG_RETURN_POINTER(retval);
} }
/* leaf entries never compress one more time, only when entry->leafkey ==true, /*
so now we work only with internal keys */ * leaf entries never compress one more time, only when entry->leafkey
* ==true, so now we work only with internal keys
*/
r = (ArrayType *) PG_DETOAST_DATUM(entry->key); r = (ArrayType *) PG_DETOAST_DATUM(entry->key);
CHECKARRVALID(r); CHECKARRVALID(r);
if (ARRISVOID(r)) if (ARRISVOID(r))
{ {
if (r != (ArrayType *) DatumGetPointer(entry->key)) if (r != (ArrayType *) DatumGetPointer(entry->key))
pfree(r); pfree(r);
......
/* /*
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.45 2005/10/29 19:38:07 tgl Exp $ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.46 2005/11/22 18:17:04 momjian Exp $
* *
* pgbench: a simple benchmark program for PostgreSQL * pgbench: a simple benchmark program for PostgreSQL
* written by Tatsuo Ishii * written by Tatsuo Ishii
...@@ -1110,7 +1110,8 @@ main(int argc, char **argv) ...@@ -1110,7 +1110,8 @@ main(int argc, char **argv)
fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n"); fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
exit(1); exit(1);
} }
#endif /* #if !(defined(__CYGWIN__) || defined(__MINGW32__)) */ #endif /* #if !(defined(__CYGWIN__) ||
* defined(__MINGW32__)) */
break; break;
case 'C': case 'C':
is_connect = 1; is_connect = 1;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.6 2005/10/15 02:49:06 momjian Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.7 2005/11/22 18:17:04 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -269,14 +269,14 @@ prefix_init(void **priv_p, void *arg, PullFilter * src) ...@@ -269,14 +269,14 @@ prefix_init(void **priv_p, void *arg, PullFilter * src)
* The original purpose of the 2-byte check was to show user a * The original purpose of the 2-byte check was to show user a
* friendly "wrong key" message. This made following possible: * friendly "wrong key" message. This made following possible:
* *
* "An Attack on CFB Mode Encryption As Used By OpenPGP" by Serge Mister * "An Attack on CFB Mode Encryption As Used By OpenPGP" by Serge
* and Robert Zuccherato * Mister and Robert Zuccherato
* *
* To avoid being 'oracle', we delay reporting, which basically means we * To avoid being 'oracle', we delay reporting, which basically means
* prefer to run into corrupt packet header. * we prefer to run into corrupt packet header.
* *
* We _could_ throw PXE_PGP_CORRUPT_DATA here, but there is possibility * We _could_ throw PXE_PGP_CORRUPT_DATA here, but there is
* of attack via timing, so we don't. * possibility of attack via timing, so we don't.
*/ */
ctx->corrupt_prefix = 1; ctx->corrupt_prefix = 1;
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.6 2005/10/15 02:49:06 momjian Exp $ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.7 2005/11/22 18:17:04 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -125,8 +125,8 @@ add_entropy(text *data1, text *data2, text *data3) ...@@ -125,8 +125,8 @@ add_entropy(text *data1, text *data2, text *data3)
/* /*
* Try to make the feeding unpredictable. * Try to make the feeding unpredictable.
* *
* Prefer data over keys, as it's rather likely that key is same in several * Prefer data over keys, as it's rather likely that key is same in
* calls. * several calls.
*/ */
/* chance: 7/8 */ /* chance: 7/8 */
......
...@@ -547,8 +547,8 @@ crosstab(PG_FUNCTION_ARGS) ...@@ -547,8 +547,8 @@ crosstab(PG_FUNCTION_ARGS)
* Get the next category item value, which is alway * Get the next category item value, which is alway
* attribute number three. * attribute number three.
* *
* Be careful to sssign the value to the array index based on * Be careful to sssign the value to the array index based
* which category we are presently processing. * on which category we are presently processing.
*/ */
values[1 + i] = SPI_getvalue(spi_tuple, spi_tupdesc, 3); values[1 + i] = SPI_getvalue(spi_tuple, spi_tupdesc, 3);
...@@ -870,8 +870,8 @@ get_crosstab_tuplestore(char *sql, ...@@ -870,8 +870,8 @@ get_crosstab_tuplestore(char *sql,
/* /*
* The provided SQL query must always return at least three columns: * The provided SQL query must always return at least three columns:
* *
* 1. rowname the label for each row - column 1 in the final result 2. * 1. rowname the label for each row - column 1 in the final result
* category the label for each value-column in the final result 3. * 2. category the label for each value-column in the final result 3.
* value the values used to populate the value-columns * value the values used to populate the value-columns
* *
* If there are more than three columns, the last two are taken as * If there are more than three columns, the last two are taken as
......
...@@ -178,7 +178,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2 ...@@ -178,7 +178,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
state->state = WAITOPERATOR; state->state = WAITOPERATOR;
return VAL; return VAL;
} }
else if ( state->state == WAITFIRSTOPERAND ) else if (state->state == WAITFIRSTOPERAND)
return END; return END;
else else
ereport(ERROR, ereport(ERROR,
...@@ -206,13 +206,13 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2 ...@@ -206,13 +206,13 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
return ERR; return ERR;
break; break;
case WAITSINGLEOPERAND: case WAITSINGLEOPERAND:
if ( *(state->buf) == '\0' ) if (*(state->buf) == '\0')
return END; return END;
*strval = state->buf; *strval = state->buf;
*lenval = strlen( state->buf ); *lenval = strlen(state->buf);
state->buf += strlen( state->buf ); state->buf += strlen(state->buf);
state->count++; state->count++;
return VAL; return VAL;
default: default:
return ERR; return ERR;
break; break;
...@@ -600,7 +600,7 @@ findoprnd(ITEM * ptr, int4 *pos) ...@@ -600,7 +600,7 @@ findoprnd(ITEM * ptr, int4 *pos)
* input * input
*/ */
static QUERYTYPE * static QUERYTYPE *
queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int cfg_id, bool isplain) queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int cfg_id, bool isplain)
{ {
QPRS_STATE state; QPRS_STATE state;
int4 i; int4 i;
...@@ -637,12 +637,13 @@ queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int c ...@@ -637,12 +637,13 @@ queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int c
/* parse query & make polish notation (postfix, but in reverse order) */ /* parse query & make polish notation (postfix, but in reverse order) */
makepol(&state, pushval); makepol(&state, pushval);
pfree(state.valstate.word); pfree(state.valstate.word);
if (!state.num) { if (!state.num)
{
elog(NOTICE, "Query doesn't contain lexem(s)"); elog(NOTICE, "Query doesn't contain lexem(s)");
query = (QUERYTYPE*)palloc( HDRSIZEQT ); query = (QUERYTYPE *) palloc(HDRSIZEQT);
query->len = HDRSIZEQT; query->len = HDRSIZEQT;
query->size = 0; query->size = 0;
return query; return query;
} }
/* make finish struct */ /* make finish struct */
...@@ -928,9 +929,9 @@ to_tsquery(PG_FUNCTION_ARGS) ...@@ -928,9 +929,9 @@ to_tsquery(PG_FUNCTION_ARGS)
str = text2char(in); str = text2char(in);
PG_FREE_IF_COPY(in, 1); PG_FREE_IF_COPY(in, 1);
query = queryin(str, pushval_morph, PG_GETARG_INT32(0),false); query = queryin(str, pushval_morph, PG_GETARG_INT32(0), false);
if ( query->size == 0 ) if (query->size == 0)
PG_RETURN_POINTER(query); PG_RETURN_POINTER(query);
res = clean_fakeval_v2(GETQUERY(query), &len); res = clean_fakeval_v2(GETQUERY(query), &len);
...@@ -984,8 +985,8 @@ plainto_tsquery(PG_FUNCTION_ARGS) ...@@ -984,8 +985,8 @@ plainto_tsquery(PG_FUNCTION_ARGS)
PG_FREE_IF_COPY(in, 1); PG_FREE_IF_COPY(in, 1);
query = queryin(str, pushval_morph, PG_GETARG_INT32(0), true); query = queryin(str, pushval_morph, PG_GETARG_INT32(0), true);
if ( query->size == 0 ) if (query->size == 0)
PG_RETURN_POINTER(query); PG_RETURN_POINTER(query);
res = clean_fakeval_v2(GETQUERY(query), &len); res = clean_fakeval_v2(GETQUERY(query), &len);
...@@ -1023,4 +1024,3 @@ plainto_tsquery_current(PG_FUNCTION_ARGS) ...@@ -1023,4 +1024,3 @@ plainto_tsquery_current(PG_FUNCTION_ARGS)
Int32GetDatum(get_currcfg()), Int32GetDatum(get_currcfg()),
PG_GETARG_DATUM(0))); PG_GETARG_DATUM(0)));
} }
...@@ -17,7 +17,7 @@ typedef struct ITEM ...@@ -17,7 +17,7 @@ typedef struct ITEM
int4 val; int4 val;
/* user-friendly value, must correlate with WordEntry */ /* user-friendly value, must correlate with WordEntry */
uint32 uint32
istrue:1, /* use for ranking in Cover */ istrue:1, /* use for ranking in Cover */
length:11, length:11,
distance:20; distance:20;
} ITEM; } ITEM;
......
This diff is collapsed.
This diff is collapsed.
...@@ -4,168 +4,188 @@ ...@@ -4,168 +4,188 @@
#include "query_util.h" #include "query_util.h"
PG_FUNCTION_INFO_V1(tsquery_numnode); PG_FUNCTION_INFO_V1(tsquery_numnode);
Datum tsquery_numnode(PG_FUNCTION_ARGS); Datum tsquery_numnode(PG_FUNCTION_ARGS);
Datum Datum
tsquery_numnode(PG_FUNCTION_ARGS) { tsquery_numnode(PG_FUNCTION_ARGS)
{
QUERYTYPE *query = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); QUERYTYPE *query = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)));
int nnode = query->size; int nnode = query->size;
PG_FREE_IF_COPY(query,0);
PG_FREE_IF_COPY(query, 0);
PG_RETURN_INT32(nnode); PG_RETURN_INT32(nnode);
} }
static QTNode* static QTNode *
join_tsqueries(QUERYTYPE *a, QUERYTYPE *b) { join_tsqueries(QUERYTYPE * a, QUERYTYPE * b)
QTNode *res=(QTNode*)palloc0( sizeof(QTNode) ); {
QTNode *res = (QTNode *) palloc0(sizeof(QTNode));
res->flags |= QTN_NEEDFREE; res->flags |= QTN_NEEDFREE;
res->valnode = (ITEM*)palloc0( sizeof(ITEM) ); res->valnode = (ITEM *) palloc0(sizeof(ITEM));
res->valnode->type = OPR; res->valnode->type = OPR;
res->child = (QTNode**)palloc0( sizeof(QTNode*)*2 ); res->child = (QTNode **) palloc0(sizeof(QTNode *) * 2);
res->child[0] = QT2QTN( GETQUERY(b), GETOPERAND(b) ); res->child[0] = QT2QTN(GETQUERY(b), GETOPERAND(b));
res->child[1] = QT2QTN( GETQUERY(a), GETOPERAND(a) ); res->child[1] = QT2QTN(GETQUERY(a), GETOPERAND(a));
res->nchild = 2; res->nchild = 2;
return res; return res;
} }
PG_FUNCTION_INFO_V1(tsquery_and); PG_FUNCTION_INFO_V1(tsquery_and);
Datum tsquery_and(PG_FUNCTION_ARGS); Datum tsquery_and(PG_FUNCTION_ARGS);
Datum Datum
tsquery_and(PG_FUNCTION_ARGS) { tsquery_and(PG_FUNCTION_ARGS)
{
QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)));
QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1))); QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1)));
QTNode *res; QTNode *res;
QUERYTYPE *query; QUERYTYPE *query;
if ( a->size == 0 ) { if (a->size == 0)
PG_FREE_IF_COPY(a,1); {
PG_FREE_IF_COPY(a, 1);
PG_RETURN_POINTER(b); PG_RETURN_POINTER(b);
} else if ( b->size == 0 ) { }
PG_FREE_IF_COPY(b,1); else if (b->size == 0)
{
PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(a); PG_RETURN_POINTER(a);
} }
res = join_tsqueries(a, b); res = join_tsqueries(a, b);
res->valnode->val = '&'; res->valnode->val = '&';
query = QTN2QT( res, PlainMemory ); query = QTN2QT(res, PlainMemory);
QTNFree(res); QTNFree(res);
PG_FREE_IF_COPY(a,0); PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b,1); PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(query); PG_RETURN_POINTER(query);
} }
PG_FUNCTION_INFO_V1(tsquery_or); PG_FUNCTION_INFO_V1(tsquery_or);
Datum tsquery_or(PG_FUNCTION_ARGS); Datum tsquery_or(PG_FUNCTION_ARGS);
Datum Datum
tsquery_or(PG_FUNCTION_ARGS) { tsquery_or(PG_FUNCTION_ARGS)
{
QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)));
QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1))); QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1)));
QTNode *res; QTNode *res;
QUERYTYPE *query; QUERYTYPE *query;
if ( a->size == 0 ) { if (a->size == 0)
PG_FREE_IF_COPY(a,1); {
PG_FREE_IF_COPY(a, 1);
PG_RETURN_POINTER(b); PG_RETURN_POINTER(b);
} else if ( b->size == 0 ) { }
PG_FREE_IF_COPY(b,1); else if (b->size == 0)
{
PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(a); PG_RETURN_POINTER(a);
} }
res = join_tsqueries(a, b); res = join_tsqueries(a, b);
res->valnode->val = '|'; res->valnode->val = '|';
query = QTN2QT( res, PlainMemory ); query = QTN2QT(res, PlainMemory);
QTNFree(res); QTNFree(res);
PG_FREE_IF_COPY(a,0); PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b,1); PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(query); PG_RETURN_POINTER(query);
} }
PG_FUNCTION_INFO_V1(tsquery_not); PG_FUNCTION_INFO_V1(tsquery_not);
Datum tsquery_not(PG_FUNCTION_ARGS); Datum tsquery_not(PG_FUNCTION_ARGS);
Datum Datum
tsquery_not(PG_FUNCTION_ARGS) { tsquery_not(PG_FUNCTION_ARGS)
{
QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)));
QTNode *res; QTNode *res;
QUERYTYPE *query; QUERYTYPE *query;
if ( a->size == 0 ) if (a->size == 0)
PG_RETURN_POINTER(a); PG_RETURN_POINTER(a);
res=(QTNode*)palloc0( sizeof(QTNode) ); res = (QTNode *) palloc0(sizeof(QTNode));
res->flags |= QTN_NEEDFREE; res->flags |= QTN_NEEDFREE;
res->valnode = (ITEM*)palloc0( sizeof(ITEM) ); res->valnode = (ITEM *) palloc0(sizeof(ITEM));
res->valnode->type = OPR; res->valnode->type = OPR;
res->valnode->val = '!'; res->valnode->val = '!';
res->child = (QTNode**)palloc0( sizeof(QTNode*) ); res->child = (QTNode **) palloc0(sizeof(QTNode *));
res->child[0] = QT2QTN( GETQUERY(a), GETOPERAND(a) ); res->child[0] = QT2QTN(GETQUERY(a), GETOPERAND(a));
res->nchild = 1; res->nchild = 1;
query = QTN2QT( res, PlainMemory ); query = QTN2QT(res, PlainMemory);
QTNFree(res); QTNFree(res);
PG_FREE_IF_COPY(a,0); PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(query); PG_RETURN_POINTER(query);
} }
static int static int
CompareTSQ( QUERYTYPE *a, QUERYTYPE *b ) { CompareTSQ(QUERYTYPE * a, QUERYTYPE * b)
if ( a->size != b->size ) { {
return ( a->size < b->size ) ? -1 : 1; if (a->size != b->size)
} else if ( a->len != b->len ) { {
return ( a->len < b->len ) ? -1 : 1; return (a->size < b->size) ? -1 : 1;
} else { }
QTNode *an = QT2QTN( GETQUERY(a), GETOPERAND(a) ); else if (a->len != b->len)
QTNode *bn = QT2QTN( GETQUERY(b), GETOPERAND(b) ); {
int res = QTNodeCompare(an, bn); return (a->len < b->len) ? -1 : 1;
}
else
{
QTNode *an = QT2QTN(GETQUERY(a), GETOPERAND(a));
QTNode *bn = QT2QTN(GETQUERY(b), GETOPERAND(b));
int res = QTNodeCompare(an, bn);
QTNFree(an); QTNFree(an);
QTNFree(bn); QTNFree(bn);
return res; return res;
} }
return 0; return 0;
} }
PG_FUNCTION_INFO_V1(tsquery_cmp); \ PG_FUNCTION_INFO_V1(tsquery_cmp);
Datum tsquery_cmp(PG_FUNCTION_ARGS); \
Datum tsquery_cmp(PG_FUNCTION_ARGS);
Datum Datum
tsquery_cmp(PG_FUNCTION_ARGS) { tsquery_cmp(PG_FUNCTION_ARGS)
{
QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0)));
QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1))); QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1)));
int res = CompareTSQ(a,b); int res = CompareTSQ(a, b);
PG_FREE_IF_COPY(a,0); PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b,1); PG_FREE_IF_COPY(b, 1);
PG_RETURN_INT32(res); PG_RETURN_INT32(res);
} }
#define CMPFUNC( NAME, ACTION ) \ #define CMPFUNC( NAME, ACTION ) \
PG_FUNCTION_INFO_V1(NAME); \ PG_FUNCTION_INFO_V1(NAME); \
Datum NAME(PG_FUNCTION_ARGS); \ Datum NAME(PG_FUNCTION_ARGS); \
\ \
Datum \ Datum \
NAME(PG_FUNCTION_ARGS) { \ NAME(PG_FUNCTION_ARGS) { \
QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); \ QUERYTYPE *a = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0))); \
QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1))); \ QUERYTYPE *b = (QUERYTYPE *) DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1))); \
int res = CompareTSQ(a,b); \ int res = CompareTSQ(a,b); \
...@@ -176,12 +196,9 @@ NAME(PG_FUNCTION_ARGS) { \ ...@@ -176,12 +196,9 @@ NAME(PG_FUNCTION_ARGS) { \
PG_RETURN_BOOL( ACTION ); \ PG_RETURN_BOOL( ACTION ); \
} }
CMPFUNC( tsquery_lt, res <0 ); CMPFUNC(tsquery_lt, res < 0);
CMPFUNC( tsquery_le, res<=0 ); CMPFUNC(tsquery_le, res <= 0);
CMPFUNC( tsquery_eq, res==0 ); CMPFUNC(tsquery_eq, res == 0);
CMPFUNC( tsquery_ge, res>=0 ); CMPFUNC(tsquery_ge, res >= 0);
CMPFUNC( tsquery_gt, res >0 ); CMPFUNC(tsquery_gt, res > 0);
CMPFUNC( tsquery_ne, res!=0 ); CMPFUNC(tsquery_ne, res != 0);
This diff is collapsed.
...@@ -6,39 +6,41 @@ ...@@ -6,39 +6,41 @@
#include "query.h" #include "query.h"
typedef struct QTNode { typedef struct QTNode
ITEM *valnode; {
uint32 flags; ITEM *valnode;
int4 nchild; uint32 flags;
char *word; int4 nchild;
uint32 sign; char *word;
struct QTNode **child; uint32 sign;
} QTNode; struct QTNode **child;
} QTNode;
#define QTN_NEEDFREE 0x01
#define QTN_NOCHANGE 0x02 #define QTN_NEEDFREE 0x01
#define QTN_WORDFREE 0x04 #define QTN_NOCHANGE 0x02
#define QTN_WORDFREE 0x04
typedef enum {
typedef enum
{
PlainMemory, PlainMemory,
SPIMemory, SPIMemory,
AggMemory AggMemory
} MemoryType; } MemoryType;
QTNode* QT2QTN( ITEM *in, char *operand ); QTNode *QT2QTN(ITEM * in, char *operand);
QUERYTYPE* QTN2QT( QTNode* in, MemoryType memtype ); QUERYTYPE *QTN2QT(QTNode * in, MemoryType memtype);
void QTNFree( QTNode* in ); void QTNFree(QTNode * in);
void QTNSort( QTNode* in ); void QTNSort(QTNode * in);
void QTNTernary( QTNode* in ); void QTNTernary(QTNode * in);
void QTNBinary( QTNode* in ); void QTNBinary(QTNode * in);
int QTNodeCompare( QTNode *an, QTNode *bn ); int QTNodeCompare(QTNode * an, QTNode * bn);
QTNode* QTNCopy( QTNode* in, MemoryType memtype); QTNode *QTNCopy(QTNode * in, MemoryType memtype);
bool QTNEq( QTNode* a, QTNode* b ); bool QTNEq(QTNode * a, QTNode * b);
extern MemoryContext AggregateContext; extern MemoryContext AggregateContext;
#define MEMALLOC(us, s) ( ((us)==SPIMemory) ? SPI_palloc(s) : ( ( (us)==PlainMemory ) ? palloc(s) : MemoryContextAlloc(AggregateContext, (s)) ) ) #define MEMALLOC(us, s) ( ((us)==SPIMemory) ? SPI_palloc(s) : ( ( (us)==PlainMemory ) ? palloc(s) : MemoryContextAlloc(AggregateContext, (s)) ) )
#define MEMFREE(us, p) ( ((us)==SPIMemory) ? SPI_pfree(p) : pfree(p) ) #define MEMFREE(us, p) ( ((us)==SPIMemory) ? SPI_pfree(p) : pfree(p) )
#endif #endif
...@@ -266,8 +266,10 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q) ...@@ -266,8 +266,10 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q)
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
float resj,wjm; float resj,
int4 jm; wjm;
int4 jm;
entry = find_wordentry(t, q, item[i]); entry = find_wordentry(t, q, item[i]);
if (!entry) if (!entry)
continue; continue;
...@@ -283,28 +285,29 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q) ...@@ -283,28 +285,29 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q)
post = POSNULL + 1; post = POSNULL + 1;
} }
resj = 0.0; resj = 0.0;
wjm = -1.0; wjm = -1.0;
jm = 0; jm = 0;
for (j = 0; j < dimt; j++) for (j = 0; j < dimt; j++)
{ {
resj = resj + wpos(post[j])/((j+1)*(j+1)); resj = resj + wpos(post[j]) / ((j + 1) * (j + 1));
if ( wpos(post[j]) > wjm ) { if (wpos(post[j]) > wjm)
wjm = wpos(post[j]); {
jm = j; wjm = wpos(post[j]);
} jm = j;
} }
/* }
limit (sum(i/i^2),i->inf) = pi^2/6 /*
resj = sum(wi/i^2),i=1,noccurence, limit (sum(i/i^2),i->inf) = pi^2/6
wi - should be sorted desc, resj = sum(wi/i^2),i=1,noccurence,
don't sort for now, just choose maximum weight. This should be corrected wi - should be sorted desc,
don't sort for now, just choose maximum weight. This should be corrected
Oleg Bartunov Oleg Bartunov
*/ */
res = res + ( wjm + resj - wjm/((jm+1)*(jm+1)))/1.64493406685; res = res + (wjm + resj - wjm / ((jm + 1) * (jm + 1))) / 1.64493406685;
} }
if ( size > 0 ) if (size > 0)
res = res /size; res = res / size;
pfree(item); pfree(item);
return res; return res;
} }
...@@ -414,7 +417,7 @@ rank_def(PG_FUNCTION_ARGS) ...@@ -414,7 +417,7 @@ rank_def(PG_FUNCTION_ARGS)
typedef struct typedef struct
{ {
ITEM **item; ITEM **item;
int16 nitem; int16 nitem;
bool needfree; bool needfree;
int32 pos; int32 pos;
...@@ -429,53 +432,59 @@ compareDocR(const void *a, const void *b) ...@@ -429,53 +432,59 @@ compareDocR(const void *a, const void *b)
} }
static bool static bool
checkcondition_ITEM(void *checkval, ITEM * val) { checkcondition_ITEM(void *checkval, ITEM * val)
return (bool)(val->istrue); {
return (bool) (val->istrue);
} }
static void static void
reset_istrue_flag(QUERYTYPE *query) { reset_istrue_flag(QUERYTYPE * query)
ITEM *item = GETQUERY(query); {
int i; ITEM *item = GETQUERY(query);
int i;
/* reset istrue flag */ /* reset istrue flag */
for(i = 0; i < query->size; i++) { for (i = 0; i < query->size; i++)
if ( item->type == VAL ) {
if (item->type == VAL)
item->istrue = 0; item->istrue = 0;
item++; item++;
} }
} }
static bool static bool
Cover(DocRepresentation * doc, int len, QUERYTYPE * query, int *pos, int *p, int *q) Cover(DocRepresentation * doc, int len, QUERYTYPE * query, int *pos, int *p, int *q)
{ {
DocRepresentation *ptr; DocRepresentation *ptr;
int lastpos = *pos; int lastpos = *pos;
int i; int i;
bool found=false; bool found = false;
reset_istrue_flag(query); reset_istrue_flag(query);
*p = 0x7fffffff; *p = 0x7fffffff;
*q = 0; *q = 0;
ptr = doc + *pos; ptr = doc + *pos;
/* find upper bound of cover from current position, move up */ /* find upper bound of cover from current position, move up */
while (ptr - doc < len) { while (ptr - doc < len)
for(i=0;i<ptr->nitem;i++) {
for (i = 0; i < ptr->nitem; i++)
ptr->item[i]->istrue = 1; ptr->item[i]->istrue = 1;
if ( TS_execute(GETQUERY(query), NULL, false, checkcondition_ITEM) ) { if (TS_execute(GETQUERY(query), NULL, false, checkcondition_ITEM))
if (ptr->pos > *q) { {
if (ptr->pos > *q)
{
*q = ptr->pos; *q = ptr->pos;
lastpos = ptr - doc; lastpos = ptr - doc;
found = true; found = true;
} }
break; break;
} }
ptr++; ptr++;
} }
if (!found) if (!found)
return false; return false;
reset_istrue_flag(query); reset_istrue_flag(query);
...@@ -483,25 +492,31 @@ Cover(DocRepresentation * doc, int len, QUERYTYPE * query, int *pos, int *p, int ...@@ -483,25 +492,31 @@ Cover(DocRepresentation * doc, int len, QUERYTYPE * query, int *pos, int *p, int
ptr = doc + lastpos; ptr = doc + lastpos;
/* find lower bound of cover from founded upper bound, move down */ /* find lower bound of cover from founded upper bound, move down */
while (ptr >= doc ) { while (ptr >= doc)
for(i=0;i<ptr->nitem;i++) {
for (i = 0; i < ptr->nitem; i++)
ptr->item[i]->istrue = 1; ptr->item[i]->istrue = 1;
if ( TS_execute(GETQUERY(query), NULL, true, checkcondition_ITEM) ) { if (TS_execute(GETQUERY(query), NULL, true, checkcondition_ITEM))
if (ptr->pos < *p) {
if (ptr->pos < *p)
*p = ptr->pos; *p = ptr->pos;
break; break;
} }
ptr--; ptr--;
} }
if ( *p <= *q ) { if (*p <= *q)
/* set position for next try to next lexeme after begining of founded cover */ {
*pos= (ptr-doc) + 1; /*
* set position for next try to next lexeme after begining of founded
* cover
*/
*pos = (ptr - doc) + 1;
return true; return true;
} }
(*pos)++; (*pos)++;
return Cover( doc, len, query, pos, p, q ); return Cover(doc, len, query, pos, p, q);
} }
static DocRepresentation * static DocRepresentation *
...@@ -550,26 +565,32 @@ get_docrep(tsvector * txt, QUERYTYPE * query, int *doclen) ...@@ -550,26 +565,32 @@ get_docrep(tsvector * txt, QUERYTYPE * query, int *doclen)
for (j = 0; j < dimt; j++) for (j = 0; j < dimt; j++)
{ {
if ( j == 0 ) { if (j == 0)
ITEM *kptr, *iptr = item+i; {
int k; ITEM *kptr,
*iptr = item + i;
int k;
doc[cur].needfree = false; doc[cur].needfree = false;
doc[cur].nitem = 0; doc[cur].nitem = 0;
doc[cur].item = (ITEM**)palloc( sizeof(ITEM*) * query->size ); doc[cur].item = (ITEM **) palloc(sizeof(ITEM *) * query->size);
for(k=0; k < query->size; k++) { for (k = 0; k < query->size; k++)
kptr = item+k; {
if ( k==i || ( item[k].type == VAL && compareITEM( &kptr, &iptr ) == 0 ) ) { kptr = item + k;
doc[cur].item[ doc[cur].nitem ] = item+k; if (k == i || (item[k].type == VAL && compareITEM(&kptr, &iptr) == 0))
{
doc[cur].item[doc[cur].nitem] = item + k;
doc[cur].nitem++; doc[cur].nitem++;
kptr->istrue = 1; kptr->istrue = 1;
} }
} }
} else { }
else
{
doc[cur].needfree = false; doc[cur].needfree = false;
doc[cur].nitem = doc[cur-1].nitem; doc[cur].nitem = doc[cur - 1].nitem;
doc[cur].item = doc[cur-1].item; doc[cur].item = doc[cur - 1].item;
} }
doc[cur].pos = WEP_GETPOS(post[j]); doc[cur].pos = WEP_GETPOS(post[j]);
cur++; cur++;
...@@ -604,7 +625,7 @@ rank_cd(PG_FUNCTION_ARGS) ...@@ -604,7 +625,7 @@ rank_cd(PG_FUNCTION_ARGS)
len, len,
cur, cur,
i, i,
doclen=0; doclen = 0;
doc = get_docrep(txt, query, &doclen); doc = get_docrep(txt, query, &doclen);
if (!doc) if (!doc)
...@@ -640,9 +661,9 @@ rank_cd(PG_FUNCTION_ARGS) ...@@ -640,9 +661,9 @@ rank_cd(PG_FUNCTION_ARGS)
elog(ERROR, "unrecognized normalization method: %d", method); elog(ERROR, "unrecognized normalization method: %d", method);
} }
for(i=0;i<doclen;i++) for (i = 0; i < doclen; i++)
if ( doc[i].needfree ) if (doc[i].needfree)
pfree( doc[i].item ); pfree(doc[i].item);
pfree(doc); pfree(doc);
PG_FREE_IF_COPY(txt, 1); PG_FREE_IF_COPY(txt, 1);
PG_FREE_IF_COPY(query, 2); PG_FREE_IF_COPY(query, 2);
...@@ -784,9 +805,9 @@ get_covers(PG_FUNCTION_ARGS) ...@@ -784,9 +805,9 @@ get_covers(PG_FUNCTION_ARGS)
VARATT_SIZEP(out) = cptr - ((char *) out); VARATT_SIZEP(out) = cptr - ((char *) out);
pfree(dw); pfree(dw);
for(i=0;i<rlen;i++) for (i = 0; i < rlen; i++)
if ( doc[i].needfree ) if (doc[i].needfree)
pfree( doc[i].item ); pfree(doc[i].item);
pfree(doc); pfree(doc);
PG_FREE_IF_COPY(txt, 0); PG_FREE_IF_COPY(txt, 0);
......
...@@ -23,7 +23,7 @@ struct SN_env ...@@ -23,7 +23,7 @@ struct SN_env
int S_size; int S_size;
int I_size; int I_size;
int B_size; int B_size;
symbol **S; symbol **S;
int *I; int *I;
symbol *B; symbol *B;
}; };
......
...@@ -28,8 +28,8 @@ static symbol s_0_1[5] = {'g', 'e', 'n', 'e', 'r'}; ...@@ -28,8 +28,8 @@ static symbol s_0_1[5] = {'g', 'e', 'n', 'e', 'r'};
static struct among a_0[2] = static struct among a_0[2] =
{ {
/* 0 */ {6, s_0_0, -1, -1, 0}, /* 0 */ {6, s_0_0, -1, -1, 0},
/* 1 */ {5, s_0_1, -1, -1, 0} /* 1 */ {5, s_0_1, -1, -1, 0}
}; };
static symbol s_1_0[1] = {'\''}; static symbol s_1_0[1] = {'\''};
...@@ -38,9 +38,9 @@ static symbol s_1_2[2] = {'\'', 's'}; ...@@ -38,9 +38,9 @@ static symbol s_1_2[2] = {'\'', 's'};
static struct among a_1[3] = static struct among a_1[3] =
{ {
/* 0 */ {1, s_1_0, -1, 1, 0}, /* 0 */ {1, s_1_0, -1, 1, 0},
/* 1 */ {3, s_1_1, 0, 1, 0}, /* 1 */ {3, s_1_1, 0, 1, 0},
/* 2 */ {2, s_1_2, -1, 1, 0} /* 2 */ {2, s_1_2, -1, 1, 0}
}; };
static symbol s_2_0[3] = {'i', 'e', 'd'}; static symbol s_2_0[3] = {'i', 'e', 'd'};
...@@ -52,12 +52,12 @@ static symbol s_2_5[2] = {'u', 's'}; ...@@ -52,12 +52,12 @@ static symbol s_2_5[2] = {'u', 's'};
static struct among a_2[6] = static struct among a_2[6] =
{ {
/* 0 */ {3, s_2_0, -1, 2, 0}, /* 0 */ {3, s_2_0, -1, 2, 0},
/* 1 */ {1, s_2_1, -1, 3, 0}, /* 1 */ {1, s_2_1, -1, 3, 0},
/* 2 */ {3, s_2_2, 1, 2, 0}, /* 2 */ {3, s_2_2, 1, 2, 0},
/* 3 */ {4, s_2_3, 1, 1, 0}, /* 3 */ {4, s_2_3, 1, 1, 0},
/* 4 */ {2, s_2_4, 1, -1, 0}, /* 4 */ {2, s_2_4, 1, -1, 0},
/* 5 */ {2, s_2_5, 1, -1, 0} /* 5 */ {2, s_2_5, 1, -1, 0}
}; };
static symbol s_3_1[2] = {'b', 'b'}; static symbol s_3_1[2] = {'b', 'b'};
...@@ -75,16 +75,16 @@ static symbol s_3_12[2] = {'i', 'z'}; ...@@ -75,16 +75,16 @@ static symbol s_3_12[2] = {'i', 'z'};
static struct among a_3[13] = static struct among a_3[13] =
{ {
/* 0 */ {0, 0, -1, 3, 0}, /* 0 */ {0, 0, -1, 3, 0},
/* 1 */ {2, s_3_1, 0, 2, 0}, /* 1 */ {2, s_3_1, 0, 2, 0},
/* 2 */ {2, s_3_2, 0, 2, 0}, /* 2 */ {2, s_3_2, 0, 2, 0},
/* 3 */ {2, s_3_3, 0, 2, 0}, /* 3 */ {2, s_3_3, 0, 2, 0},
/* 4 */ {2, s_3_4, 0, 2, 0}, /* 4 */ {2, s_3_4, 0, 2, 0},
/* 5 */ {2, s_3_5, 0, 1, 0}, /* 5 */ {2, s_3_5, 0, 1, 0},
/* 6 */ {2, s_3_6, 0, 2, 0}, /* 6 */ {2, s_3_6, 0, 2, 0},
/* 7 */ {2, s_3_7, 0, 2, 0}, /* 7 */ {2, s_3_7, 0, 2, 0},
/* 8 */ {2, s_3_8, 0, 2, 0}, /* 8 */ {2, s_3_8, 0, 2, 0},
/* 9 */ {2, s_3_9, 0, 2, 0}, /* 9 */ {2, s_3_9, 0, 2, 0},
/* 10 */ {2, s_3_10, 0, 1, 0}, /* 10 */ {2, s_3_10, 0, 1, 0},
/* 11 */ {2, s_3_11, 0, 2, 0}, /* 11 */ {2, s_3_11, 0, 2, 0},
/* 12 */ {2, s_3_12, 0, 1, 0} /* 12 */ {2, s_3_12, 0, 1, 0}
...@@ -99,12 +99,12 @@ static symbol s_4_5[5] = {'i', 'n', 'g', 'l', 'y'}; ...@@ -99,12 +99,12 @@ static symbol s_4_5[5] = {'i', 'n', 'g', 'l', 'y'};
static struct among a_4[6] = static struct among a_4[6] =
{ {
/* 0 */ {2, s_4_0, -1, 2, 0}, /* 0 */ {2, s_4_0, -1, 2, 0},
/* 1 */ {3, s_4_1, 0, 1, 0}, /* 1 */ {3, s_4_1, 0, 1, 0},
/* 2 */ {3, s_4_2, -1, 2, 0}, /* 2 */ {3, s_4_2, -1, 2, 0},
/* 3 */ {4, s_4_3, -1, 2, 0}, /* 3 */ {4, s_4_3, -1, 2, 0},
/* 4 */ {5, s_4_4, 3, 1, 0}, /* 4 */ {5, s_4_4, 3, 1, 0},
/* 5 */ {5, s_4_5, -1, 2, 0} /* 5 */ {5, s_4_5, -1, 2, 0}
}; };
static symbol s_5_0[4] = {'a', 'n', 'c', 'i'}; static symbol s_5_0[4] = {'a', 'n', 'c', 'i'};
...@@ -134,16 +134,16 @@ static symbol s_5_23[7] = {'o', 'u', 's', 'n', 'e', 's', 's'}; ...@@ -134,16 +134,16 @@ static symbol s_5_23[7] = {'o', 'u', 's', 'n', 'e', 's', 's'};
static struct among a_5[24] = static struct among a_5[24] =
{ {
/* 0 */ {4, s_5_0, -1, 3, 0}, /* 0 */ {4, s_5_0, -1, 3, 0},
/* 1 */ {4, s_5_1, -1, 2, 0}, /* 1 */ {4, s_5_1, -1, 2, 0},
/* 2 */ {3, s_5_2, -1, 13, 0}, /* 2 */ {3, s_5_2, -1, 13, 0},
/* 3 */ {2, s_5_3, -1, 16, 0}, /* 3 */ {2, s_5_3, -1, 16, 0},
/* 4 */ {3, s_5_4, 3, 12, 0}, /* 4 */ {3, s_5_4, 3, 12, 0},
/* 5 */ {4, s_5_5, 4, 4, 0}, /* 5 */ {4, s_5_5, 4, 4, 0},
/* 6 */ {4, s_5_6, 3, 8, 0}, /* 6 */ {4, s_5_6, 3, 8, 0},
/* 7 */ {5, s_5_7, 3, 14, 0}, /* 7 */ {5, s_5_7, 3, 14, 0},
/* 8 */ {6, s_5_8, 3, 15, 0}, /* 8 */ {6, s_5_8, 3, 15, 0},
/* 9 */ {5, s_5_9, 3, 10, 0}, /* 9 */ {5, s_5_9, 3, 10, 0},
/* 10 */ {5, s_5_10, 3, 5, 0}, /* 10 */ {5, s_5_10, 3, 5, 0},
/* 11 */ {5, s_5_11, -1, 8, 0}, /* 11 */ {5, s_5_11, -1, 8, 0},
/* 12 */ {6, s_5_12, -1, 12, 0}, /* 12 */ {6, s_5_12, -1, 12, 0},
...@@ -172,15 +172,15 @@ static symbol s_6_8[4] = {'n', 'e', 's', 's'}; ...@@ -172,15 +172,15 @@ static symbol s_6_8[4] = {'n', 'e', 's', 's'};
static struct among a_6[9] = static struct among a_6[9] =
{ {
/* 0 */ {5, s_6_0, -1, 4, 0}, /* 0 */ {5, s_6_0, -1, 4, 0},
/* 1 */ {5, s_6_1, -1, 6, 0}, /* 1 */ {5, s_6_1, -1, 6, 0},
/* 2 */ {5, s_6_2, -1, 3, 0}, /* 2 */ {5, s_6_2, -1, 3, 0},
/* 3 */ {5, s_6_3, -1, 4, 0}, /* 3 */ {5, s_6_3, -1, 4, 0},
/* 4 */ {4, s_6_4, -1, 4, 0}, /* 4 */ {4, s_6_4, -1, 4, 0},
/* 5 */ {6, s_6_5, -1, 1, 0}, /* 5 */ {6, s_6_5, -1, 1, 0},
/* 6 */ {7, s_6_6, 5, 2, 0}, /* 6 */ {7, s_6_6, 5, 2, 0},
/* 7 */ {3, s_6_7, -1, 5, 0}, /* 7 */ {3, s_6_7, -1, 5, 0},
/* 8 */ {4, s_6_8, -1, 5, 0} /* 8 */ {4, s_6_8, -1, 5, 0}
}; };
static symbol s_7_0[2] = {'i', 'c'}; static symbol s_7_0[2] = {'i', 'c'};
...@@ -204,16 +204,16 @@ static symbol s_7_17[5] = {'e', 'm', 'e', 'n', 't'}; ...@@ -204,16 +204,16 @@ static symbol s_7_17[5] = {'e', 'm', 'e', 'n', 't'};
static struct among a_7[18] = static struct among a_7[18] =
{ {
/* 0 */ {2, s_7_0, -1, 1, 0}, /* 0 */ {2, s_7_0, -1, 1, 0},
/* 1 */ {4, s_7_1, -1, 1, 0}, /* 1 */ {4, s_7_1, -1, 1, 0},
/* 2 */ {4, s_7_2, -1, 1, 0}, /* 2 */ {4, s_7_2, -1, 1, 0},
/* 3 */ {4, s_7_3, -1, 1, 0}, /* 3 */ {4, s_7_3, -1, 1, 0},
/* 4 */ {4, s_7_4, -1, 1, 0}, /* 4 */ {4, s_7_4, -1, 1, 0},
/* 5 */ {3, s_7_5, -1, 1, 0}, /* 5 */ {3, s_7_5, -1, 1, 0},
/* 6 */ {3, s_7_6, -1, 1, 0}, /* 6 */ {3, s_7_6, -1, 1, 0},
/* 7 */ {3, s_7_7, -1, 1, 0}, /* 7 */ {3, s_7_7, -1, 1, 0},
/* 8 */ {3, s_7_8, -1, 1, 0}, /* 8 */ {3, s_7_8, -1, 1, 0},
/* 9 */ {2, s_7_9, -1, 1, 0}, /* 9 */ {2, s_7_9, -1, 1, 0},
/* 10 */ {3, s_7_10, -1, 1, 0}, /* 10 */ {3, s_7_10, -1, 1, 0},
/* 11 */ {3, s_7_11, -1, 2, 0}, /* 11 */ {3, s_7_11, -1, 2, 0},
/* 12 */ {2, s_7_12, -1, 1, 0}, /* 12 */ {2, s_7_12, -1, 1, 0},
...@@ -229,8 +229,8 @@ static symbol s_8_1[1] = {'l'}; ...@@ -229,8 +229,8 @@ static symbol s_8_1[1] = {'l'};
static struct among a_8[2] = static struct among a_8[2] =
{ {
/* 0 */ {1, s_8_0, -1, 1, 0}, /* 0 */ {1, s_8_0, -1, 1, 0},
/* 1 */ {1, s_8_1, -1, 2, 0} /* 1 */ {1, s_8_1, -1, 2, 0}
}; };
static symbol s_9_0[7] = {'s', 'u', 'c', 'c', 'e', 'e', 'd'}; static symbol s_9_0[7] = {'s', 'u', 'c', 'c', 'e', 'e', 'd'};
...@@ -244,14 +244,14 @@ static symbol s_9_7[6] = {'o', 'u', 't', 'i', 'n', 'g'}; ...@@ -244,14 +244,14 @@ static symbol s_9_7[6] = {'o', 'u', 't', 'i', 'n', 'g'};
static struct among a_9[8] = static struct among a_9[8] =
{ {
/* 0 */ {7, s_9_0, -1, -1, 0}, /* 0 */ {7, s_9_0, -1, -1, 0},
/* 1 */ {7, s_9_1, -1, -1, 0}, /* 1 */ {7, s_9_1, -1, -1, 0},
/* 2 */ {6, s_9_2, -1, -1, 0}, /* 2 */ {6, s_9_2, -1, -1, 0},
/* 3 */ {7, s_9_3, -1, -1, 0}, /* 3 */ {7, s_9_3, -1, -1, 0},
/* 4 */ {6, s_9_4, -1, -1, 0}, /* 4 */ {6, s_9_4, -1, -1, 0},
/* 5 */ {7, s_9_5, -1, -1, 0}, /* 5 */ {7, s_9_5, -1, -1, 0},
/* 6 */ {7, s_9_6, -1, -1, 0}, /* 6 */ {7, s_9_6, -1, -1, 0},
/* 7 */ {6, s_9_7, -1, -1, 0} /* 7 */ {6, s_9_7, -1, -1, 0}
}; };
static symbol s_10_0[5] = {'a', 'n', 'd', 'e', 's'}; static symbol s_10_0[5] = {'a', 'n', 'd', 'e', 's'};
...@@ -275,16 +275,16 @@ static symbol s_10_17[4] = {'u', 'g', 'l', 'y'}; ...@@ -275,16 +275,16 @@ static symbol s_10_17[4] = {'u', 'g', 'l', 'y'};
static struct among a_10[18] = static struct among a_10[18] =
{ {
/* 0 */ {5, s_10_0, -1, -1, 0}, /* 0 */ {5, s_10_0, -1, -1, 0},
/* 1 */ {5, s_10_1, -1, -1, 0}, /* 1 */ {5, s_10_1, -1, -1, 0},
/* 2 */ {4, s_10_2, -1, -1, 0}, /* 2 */ {4, s_10_2, -1, -1, 0},
/* 3 */ {6, s_10_3, -1, -1, 0}, /* 3 */ {6, s_10_3, -1, -1, 0},
/* 4 */ {5, s_10_4, -1, 3, 0}, /* 4 */ {5, s_10_4, -1, 3, 0},
/* 5 */ {5, s_10_5, -1, 9, 0}, /* 5 */ {5, s_10_5, -1, 9, 0},
/* 6 */ {6, s_10_6, -1, 7, 0}, /* 6 */ {6, s_10_6, -1, 7, 0},
/* 7 */ {4, s_10_7, -1, -1, 0}, /* 7 */ {4, s_10_7, -1, -1, 0},
/* 8 */ {4, s_10_8, -1, 6, 0}, /* 8 */ {4, s_10_8, -1, 6, 0},
/* 9 */ {5, s_10_9, -1, 4, 0}, /* 9 */ {5, s_10_9, -1, 4, 0},
/* 10 */ {4, s_10_10, -1, -1, 0}, /* 10 */ {4, s_10_10, -1, -1, 0},
/* 11 */ {4, s_10_11, -1, 10, 0}, /* 11 */ {4, s_10_11, -1, 10, 0},
/* 12 */ {6, s_10_12, -1, 11, 0}, /* 12 */ {6, s_10_12, -1, 11, 0},
...@@ -1609,12 +1609,14 @@ lab0: ...@@ -1609,12 +1609,14 @@ lab0:
return 1; return 1;
} }
extern struct SN_env *english_ISO_8859_1_create_env(void) extern struct SN_env *
english_ISO_8859_1_create_env(void)
{ {
return SN_create_env(0, 2, 1); return SN_create_env(0, 2, 1);
} }
extern void english_ISO_8859_1_close_env(struct SN_env * z) extern void
english_ISO_8859_1_close_env(struct SN_env * z)
{ {
SN_close_env(z); SN_close_env(z);
} }
...@@ -6,10 +6,10 @@ extern "C" ...@@ -6,10 +6,10 @@ extern "C"
{ {
#endif #endif
extern struct SN_env *english_ISO_8859_1_create_env(void); extern struct SN_env *english_ISO_8859_1_create_env(void);
extern void english_ISO_8859_1_close_env(struct SN_env * z); extern void english_ISO_8859_1_close_env(struct SN_env * z);
extern int english_ISO_8859_1_stem(struct SN_env * z); extern int english_ISO_8859_1_stem(struct SN_env * z);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -30,15 +30,15 @@ static symbol s_0_8[6] = {0xD9, 0xD7, 0xDB, 0xC9, 0xD3, 0xD8}; ...@@ -30,15 +30,15 @@ static symbol s_0_8[6] = {0xD9, 0xD7, 0xDB, 0xC9, 0xD3, 0xD8};
static struct among a_0[9] = static struct among a_0[9] =
{ {
/* 0 */ {3, s_0_0, -1, 1, 0}, /* 0 */ {3, s_0_0, -1, 1, 0},
/* 1 */ {4, s_0_1, 0, 2, 0}, /* 1 */ {4, s_0_1, 0, 2, 0},
/* 2 */ {4, s_0_2, 0, 2, 0}, /* 2 */ {4, s_0_2, 0, 2, 0},
/* 3 */ {1, s_0_3, -1, 1, 0}, /* 3 */ {1, s_0_3, -1, 1, 0},
/* 4 */ {2, s_0_4, 3, 2, 0}, /* 4 */ {2, s_0_4, 3, 2, 0},
/* 5 */ {2, s_0_5, 3, 2, 0}, /* 5 */ {2, s_0_5, 3, 2, 0},
/* 6 */ {5, s_0_6, -1, 1, 0}, /* 6 */ {5, s_0_6, -1, 1, 0},
/* 7 */ {6, s_0_7, 6, 2, 0}, /* 7 */ {6, s_0_7, 6, 2, 0},
/* 8 */ {6, s_0_8, 6, 2, 0} /* 8 */ {6, s_0_8, 6, 2, 0}
}; };
static symbol s_1_0[2] = {0xC0, 0xC0}; static symbol s_1_0[2] = {0xC0, 0xC0};
...@@ -70,16 +70,16 @@ static symbol s_1_25[3] = {0xCF, 0xCD, 0xD5}; ...@@ -70,16 +70,16 @@ static symbol s_1_25[3] = {0xCF, 0xCD, 0xD5};
static struct among a_1[26] = static struct among a_1[26] =
{ {
/* 0 */ {2, s_1_0, -1, 1, 0}, /* 0 */ {2, s_1_0, -1, 1, 0},
/* 1 */ {2, s_1_1, -1, 1, 0}, /* 1 */ {2, s_1_1, -1, 1, 0},
/* 2 */ {2, s_1_2, -1, 1, 0}, /* 2 */ {2, s_1_2, -1, 1, 0},
/* 3 */ {2, s_1_3, -1, 1, 0}, /* 3 */ {2, s_1_3, -1, 1, 0},
/* 4 */ {2, s_1_4, -1, 1, 0}, /* 4 */ {2, s_1_4, -1, 1, 0},
/* 5 */ {2, s_1_5, -1, 1, 0}, /* 5 */ {2, s_1_5, -1, 1, 0},
/* 6 */ {2, s_1_6, -1, 1, 0}, /* 6 */ {2, s_1_6, -1, 1, 0},
/* 7 */ {2, s_1_7, -1, 1, 0}, /* 7 */ {2, s_1_7, -1, 1, 0},
/* 8 */ {2, s_1_8, -1, 1, 0}, /* 8 */ {2, s_1_8, -1, 1, 0},
/* 9 */ {2, s_1_9, -1, 1, 0}, /* 9 */ {2, s_1_9, -1, 1, 0},
/* 10 */ {3, s_1_10, -1, 1, 0}, /* 10 */ {3, s_1_10, -1, 1, 0},
/* 11 */ {3, s_1_11, -1, 1, 0}, /* 11 */ {3, s_1_11, -1, 1, 0},
/* 12 */ {2, s_1_12, -1, 1, 0}, /* 12 */ {2, s_1_12, -1, 1, 0},
...@@ -109,14 +109,14 @@ static symbol s_2_7[3] = {0xD5, 0xC0, 0xDD}; ...@@ -109,14 +109,14 @@ static symbol s_2_7[3] = {0xD5, 0xC0, 0xDD};
static struct among a_2[8] = static struct among a_2[8] =
{ {
/* 0 */ {2, s_2_0, -1, 1, 0}, /* 0 */ {2, s_2_0, -1, 1, 0},
/* 1 */ {2, s_2_1, -1, 1, 0}, /* 1 */ {2, s_2_1, -1, 1, 0},
/* 2 */ {2, s_2_2, -1, 1, 0}, /* 2 */ {2, s_2_2, -1, 1, 0},
/* 3 */ {3, s_2_3, 2, 2, 0}, /* 3 */ {3, s_2_3, 2, 2, 0},
/* 4 */ {3, s_2_4, 2, 2, 0}, /* 4 */ {3, s_2_4, 2, 2, 0},
/* 5 */ {1, s_2_5, -1, 1, 0}, /* 5 */ {1, s_2_5, -1, 1, 0},
/* 6 */ {2, s_2_6, 5, 1, 0}, /* 6 */ {2, s_2_6, 5, 1, 0},
/* 7 */ {3, s_2_7, 6, 2, 0} /* 7 */ {3, s_2_7, 6, 2, 0}
}; };
static symbol s_3_0[2] = {0xD3, 0xD1}; static symbol s_3_0[2] = {0xD3, 0xD1};
...@@ -124,8 +124,8 @@ static symbol s_3_1[2] = {0xD3, 0xD8}; ...@@ -124,8 +124,8 @@ static symbol s_3_1[2] = {0xD3, 0xD8};
static struct among a_3[2] = static struct among a_3[2] =
{ {
/* 0 */ {2, s_3_0, -1, 1, 0}, /* 0 */ {2, s_3_0, -1, 1, 0},
/* 1 */ {2, s_3_1, -1, 1, 0} /* 1 */ {2, s_3_1, -1, 1, 0}
}; };
static symbol s_4_0[1] = {0xC0}; static symbol s_4_0[1] = {0xC0};
...@@ -177,16 +177,16 @@ static symbol s_4_45[3] = {0xC5, 0xCE, 0xD9}; ...@@ -177,16 +177,16 @@ static symbol s_4_45[3] = {0xC5, 0xCE, 0xD9};
static struct among a_4[46] = static struct among a_4[46] =
{ {
/* 0 */ {1, s_4_0, -1, 2, 0}, /* 0 */ {1, s_4_0, -1, 2, 0},
/* 1 */ {2, s_4_1, 0, 2, 0}, /* 1 */ {2, s_4_1, 0, 2, 0},
/* 2 */ {2, s_4_2, -1, 1, 0}, /* 2 */ {2, s_4_2, -1, 1, 0},
/* 3 */ {3, s_4_3, 2, 2, 0}, /* 3 */ {3, s_4_3, 2, 2, 0},
/* 4 */ {3, s_4_4, 2, 2, 0}, /* 4 */ {3, s_4_4, 2, 2, 0},
/* 5 */ {2, s_4_5, -1, 1, 0}, /* 5 */ {2, s_4_5, -1, 1, 0},
/* 6 */ {3, s_4_6, 5, 2, 0}, /* 6 */ {3, s_4_6, 5, 2, 0},
/* 7 */ {3, s_4_7, -1, 1, 0}, /* 7 */ {3, s_4_7, -1, 1, 0},
/* 8 */ {3, s_4_8, -1, 2, 0}, /* 8 */ {3, s_4_8, -1, 2, 0},
/* 9 */ {3, s_4_9, -1, 1, 0}, /* 9 */ {3, s_4_9, -1, 1, 0},
/* 10 */ {4, s_4_10, 9, 2, 0}, /* 10 */ {4, s_4_10, 9, 2, 0},
/* 11 */ {4, s_4_11, 9, 2, 0}, /* 11 */ {4, s_4_11, 9, 2, 0},
/* 12 */ {2, s_4_12, -1, 1, 0}, /* 12 */ {2, s_4_12, -1, 1, 0},
...@@ -264,16 +264,16 @@ static symbol s_5_35[1] = {0xD9}; ...@@ -264,16 +264,16 @@ static symbol s_5_35[1] = {0xD9};
static struct among a_5[36] = static struct among a_5[36] =
{ {
/* 0 */ {1, s_5_0, -1, 1, 0}, /* 0 */ {1, s_5_0, -1, 1, 0},
/* 1 */ {2, s_5_1, 0, 1, 0}, /* 1 */ {2, s_5_1, 0, 1, 0},
/* 2 */ {2, s_5_2, 0, 1, 0}, /* 2 */ {2, s_5_2, 0, 1, 0},
/* 3 */ {1, s_5_3, -1, 1, 0}, /* 3 */ {1, s_5_3, -1, 1, 0},
/* 4 */ {1, s_5_4, -1, 1, 0}, /* 4 */ {1, s_5_4, -1, 1, 0},
/* 5 */ {2, s_5_5, 4, 1, 0}, /* 5 */ {2, s_5_5, 4, 1, 0},
/* 6 */ {2, s_5_6, 4, 1, 0}, /* 6 */ {2, s_5_6, 4, 1, 0},
/* 7 */ {2, s_5_7, -1, 1, 0}, /* 7 */ {2, s_5_7, -1, 1, 0},
/* 8 */ {2, s_5_8, -1, 1, 0}, /* 8 */ {2, s_5_8, -1, 1, 0},
/* 9 */ {3, s_5_9, 8, 1, 0}, /* 9 */ {3, s_5_9, 8, 1, 0},
/* 10 */ {1, s_5_10, -1, 1, 0}, /* 10 */ {1, s_5_10, -1, 1, 0},
/* 11 */ {2, s_5_11, 10, 1, 0}, /* 11 */ {2, s_5_11, 10, 1, 0},
/* 12 */ {2, s_5_12, 10, 1, 0}, /* 12 */ {2, s_5_12, 10, 1, 0},
...@@ -307,8 +307,8 @@ static symbol s_6_1[4] = {0xCF, 0xD3, 0xD4, 0xD8}; ...@@ -307,8 +307,8 @@ static symbol s_6_1[4] = {0xCF, 0xD3, 0xD4, 0xD8};
static struct among a_6[2] = static struct among a_6[2] =
{ {
/* 0 */ {3, s_6_0, -1, 1, 0}, /* 0 */ {3, s_6_0, -1, 1, 0},
/* 1 */ {4, s_6_1, -1, 1, 0} /* 1 */ {4, s_6_1, -1, 1, 0}
}; };
static symbol s_7_0[4] = {0xC5, 0xCA, 0xDB, 0xC5}; static symbol s_7_0[4] = {0xC5, 0xCA, 0xDB, 0xC5};
...@@ -318,10 +318,10 @@ static symbol s_7_3[3] = {0xC5, 0xCA, 0xDB}; ...@@ -318,10 +318,10 @@ static symbol s_7_3[3] = {0xC5, 0xCA, 0xDB};
static struct among a_7[4] = static struct among a_7[4] =
{ {
/* 0 */ {4, s_7_0, -1, 1, 0}, /* 0 */ {4, s_7_0, -1, 1, 0},
/* 1 */ {1, s_7_1, -1, 2, 0}, /* 1 */ {1, s_7_1, -1, 2, 0},
/* 2 */ {1, s_7_2, -1, 3, 0}, /* 2 */ {1, s_7_2, -1, 3, 0},
/* 3 */ {3, s_7_3, -1, 1, 0} /* 3 */ {3, s_7_3, -1, 1, 0}
}; };
static unsigned char g_v[] = {35, 130, 34, 18}; static unsigned char g_v[] = {35, 130, 34, 18};
...@@ -915,12 +915,14 @@ lab0: ...@@ -915,12 +915,14 @@ lab0:
return 1; return 1;
} }
extern struct SN_env *russian_KOI8_R_create_env(void) extern struct SN_env *
russian_KOI8_R_create_env(void)
{ {
return SN_create_env(0, 2, 0); return SN_create_env(0, 2, 0);
} }
extern void russian_KOI8_R_close_env(struct SN_env * z) extern void
russian_KOI8_R_close_env(struct SN_env * z)
{ {
SN_close_env(z); SN_close_env(z);
} }
...@@ -6,10 +6,10 @@ extern "C" ...@@ -6,10 +6,10 @@ extern "C"
{ {
#endif #endif
extern struct SN_env *russian_KOI8_R_create_env(void); extern struct SN_env *russian_KOI8_R_create_env(void);
extern void russian_KOI8_R_close_env(struct SN_env * z); extern void russian_KOI8_R_close_env(struct SN_env * z);
extern int russian_KOI8_R_stem(struct SN_env * z); extern int russian_KOI8_R_stem(struct SN_env * z);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -8,58 +8,64 @@ ...@@ -8,58 +8,64 @@
#if defined(TS_USE_WIDE) && defined(WIN32) #if defined(TS_USE_WIDE) && defined(WIN32)
size_t size_t
wchar2char( char *to, const wchar_t *from, size_t len ) { wchar2char(char *to, const wchar_t *from, size_t len)
if (GetDatabaseEncoding() == PG_UTF8) { {
int r, nbytes; if (GetDatabaseEncoding() == PG_UTF8)
{
if (len==0) int r,
nbytes;
if (len == 0)
return 0; return 0;
/* in any case, *to should be allocated with enough space */ /* in any case, *to should be allocated with enough space */
nbytes = WideCharToMultiByte(CP_UTF8, 0, from, len, NULL, 0, NULL, NULL); nbytes = WideCharToMultiByte(CP_UTF8, 0, from, len, NULL, 0, NULL, NULL);
if ( nbytes==0 ) if (nbytes == 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE), (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
errmsg("UTF-16 to UTF-8 translation failed: %lu", errmsg("UTF-16 to UTF-8 translation failed: %lu",
GetLastError()))); GetLastError())));
r = WideCharToMultiByte(CP_UTF8, 0, from, len, to, nbytes, r = WideCharToMultiByte(CP_UTF8, 0, from, len, to, nbytes,
NULL, NULL); NULL, NULL);
if ( r==0 ) if (r == 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE), (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
errmsg("UTF-16 to UTF-8 translation failed: %lu", errmsg("UTF-16 to UTF-8 translation failed: %lu",
GetLastError()))); GetLastError())));
return r; return r;
} }
return wcstombs(to, from, len); return wcstombs(to, from, len);
} }
size_t size_t
char2wchar( wchar_t *to, const char *from, size_t len ) { char2wchar(wchar_t *to, const char *from, size_t len)
if (GetDatabaseEncoding() == PG_UTF8) { {
int r; if (GetDatabaseEncoding() == PG_UTF8)
{
int r;
if (len==0) if (len == 0)
return 0; return 0;
r = MultiByteToWideChar(CP_UTF8, 0, from, len, to, len); r = MultiByteToWideChar(CP_UTF8, 0, from, len, to, len);
if (!r) { if (!r)
{
pg_verifymbstr(from, len, false); pg_verifymbstr(from, len, false);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE), (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
errmsg("invalid multibyte character for locale"), errmsg("invalid multibyte character for locale"),
errhint("The server's LC_CTYPE locale is probably incompatible with the database encoding."))); errhint("The server's LC_CTYPE locale is probably incompatible with the database encoding.")));
} }
Assert( r <= len ); Assert(r <= len);
return r; return r;
} }
return mbstowcs(to, from, len); return mbstowcs(to, from, len);
} }
......
...@@ -22,17 +22,15 @@ ...@@ -22,17 +22,15 @@
#ifdef WIN32 #ifdef WIN32
size_t wchar2char( char *to, const wchar_t *from, size_t len ); size_t wchar2char(char *to, const wchar_t *from, size_t len);
size_t char2wchar( wchar_t *to, const char *from, size_t len ); size_t char2wchar(wchar_t *to, const char *from, size_t len);
#else /* WIN32 */
#else /* WIN32 */
/* correct mbstowcs */ /* correct mbstowcs */
#define char2wchar mbstowcs #define char2wchar mbstowcs
#define wchar2char wcstombs #define wchar2char wcstombs
#endif /* WIN32 */
#endif /* defined(HAVE_WCSTOMBS) &&
* defined(HAVE_TOWLOWER) */
#endif /* WIN32 */ #endif /* __TSLOCALE_H__ */
#endif /* defined(HAVE_WCSTOMBS) && defined(HAVE_TOWLOWER) */
#endif /* __TSLOCALE_H__ */
This diff is collapsed.
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#include <limits.h> #include <limits.h>
#include "ts_locale.h" #include "ts_locale.h"
typedef enum { typedef enum
{
TPS_Base = 0, TPS_Base = 0,
TPS_InUWord, TPS_InUWord,
TPS_InLatWord, TPS_InLatWord,
...@@ -78,70 +79,76 @@ typedef enum { ...@@ -78,70 +79,76 @@ typedef enum {
TPS_InHDecimalPart, TPS_InHDecimalPart,
TPS_InHVersionPartFirst, TPS_InHVersionPartFirst,
TPS_InHVersionPart, TPS_InHVersionPart,
TPS_Null /* last state (fake value) */ TPS_Null /* last state (fake value) */
} TParserState; } TParserState;
/* forward declaration */ /* forward declaration */
struct TParser; struct TParser;
typedef int (*TParserCharTest)(struct TParser*); /* any p_is* functions except p_iseq */ typedef int (*TParserCharTest) (struct TParser *); /* any p_is* functions
typedef void (*TParserSpecial)(struct TParser*); /* special handler for special cases... */ * except p_iseq */
typedef void (*TParserSpecial) (struct TParser *); /* special handler for
typedef struct { * special cases... */
TParserCharTest isclass;
char c; typedef struct
uint16 flags; {
TParserState tostate; TParserCharTest isclass;
int type; char c;
TParserSpecial special; uint16 flags;
} TParserStateActionItem; TParserState tostate;
int type;
typedef struct { TParserSpecial special;
TParserState state; } TParserStateActionItem;
TParserStateActionItem *action;
} TParserStateAction; typedef struct
{
typedef struct TParserPosition { TParserState state;
int posbyte; /* position of parser in bytes */ TParserStateActionItem *action;
int poschar; /* osition of parser in characters */ } TParserStateAction;
int charlen; /* length of current char */
int lenbytelexeme; typedef struct TParserPosition
int lencharlexeme; {
TParserState state; int posbyte; /* position of parser in bytes */
struct TParserPosition *prev; int poschar; /* osition of parser in characters */
int flags; int charlen; /* length of current char */
TParserStateActionItem *pushedAtAction; int lenbytelexeme;
} TParserPosition; int lencharlexeme;
TParserState state;
typedef struct TParser { struct TParserPosition *prev;
int flags;
TParserStateActionItem *pushedAtAction;
} TParserPosition;
typedef struct TParser
{
/* string and position information */ /* string and position information */
char *str; /* multibyte string */ char *str; /* multibyte string */
int lenstr; /* length of mbstring */ int lenstr; /* length of mbstring */
wchar_t *wstr; /* wide character string */ wchar_t *wstr; /* wide character string */
int lenwstr; /* length of wsting */ int lenwstr; /* length of wsting */
/* State of parse */ /* State of parse */
int charmaxlen; int charmaxlen;
bool usewide; bool usewide;
TParserPosition *state; TParserPosition *state;
bool ignore; bool ignore;
bool wanthost; bool wanthost;
/* silly char */ /* silly char */
char c; char c;
/* out */ /* out */
char *lexeme; char *lexeme;
int lenbytelexeme; int lenbytelexeme;
int lencharlexeme; int lencharlexeme;
int type; int type;
} TParser; } TParser;
TParser* TParserInit( char *, int ); TParser *TParserInit(char *, int);
bool TParserGet( TParser* ); bool TParserGet(TParser *);
void TParserClose( TParser* ); void TParserClose(TParser *);
#endif #endif
...@@ -39,7 +39,7 @@ Datum prsd_start(PG_FUNCTION_ARGS); ...@@ -39,7 +39,7 @@ Datum prsd_start(PG_FUNCTION_ARGS);
Datum Datum
prsd_start(PG_FUNCTION_ARGS) prsd_start(PG_FUNCTION_ARGS)
{ {
PG_RETURN_POINTER(TParserInit( (char *) PG_GETARG_POINTER(0), PG_GETARG_INT32(1))); PG_RETURN_POINTER(TParserInit((char *) PG_GETARG_POINTER(0), PG_GETARG_INT32(1)));
} }
PG_FUNCTION_INFO_V1(prsd_getlexeme); PG_FUNCTION_INFO_V1(prsd_getlexeme);
...@@ -47,14 +47,14 @@ Datum prsd_getlexeme(PG_FUNCTION_ARGS); ...@@ -47,14 +47,14 @@ Datum prsd_getlexeme(PG_FUNCTION_ARGS);
Datum Datum
prsd_getlexeme(PG_FUNCTION_ARGS) prsd_getlexeme(PG_FUNCTION_ARGS)
{ {
TParser *p=(TParser*)PG_GETARG_POINTER(0); TParser *p = (TParser *) PG_GETARG_POINTER(0);
char **t = (char **) PG_GETARG_POINTER(1); char **t = (char **) PG_GETARG_POINTER(1);
int *tlen = (int *) PG_GETARG_POINTER(2); int *tlen = (int *) PG_GETARG_POINTER(2);
if ( !TParserGet(p) ) if (!TParserGet(p))
PG_RETURN_INT32(0); PG_RETURN_INT32(0);
*t = p->lexeme; *t = p->lexeme;
*tlen = p->lenbytelexeme; *tlen = p->lenbytelexeme;
PG_RETURN_INT32(p->type); PG_RETURN_INT32(p->type);
...@@ -65,8 +65,9 @@ Datum prsd_end(PG_FUNCTION_ARGS); ...@@ -65,8 +65,9 @@ Datum prsd_end(PG_FUNCTION_ARGS);
Datum Datum
prsd_end(PG_FUNCTION_ARGS) prsd_end(PG_FUNCTION_ARGS)
{ {
TParser *p=(TParser*)PG_GETARG_POINTER(0); TParser *p = (TParser *) PG_GETARG_POINTER(0);
TParserClose(p);
TParserClose(p);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.103 2005/11/20 19:49:06 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.104 2005/11/22 18:17:05 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -512,11 +512,11 @@ nocachegetattr(HeapTuple tuple, ...@@ -512,11 +512,11 @@ nocachegetattr(HeapTuple tuple,
/* /*
* Now we know that we have to walk the tuple CAREFULLY. * Now we know that we have to walk the tuple CAREFULLY.
* *
* Note - This loop is a little tricky. For each non-null attribute, we * Note - This loop is a little tricky. For each non-null attribute,
* have to first account for alignment padding before the attr, then * we have to first account for alignment padding before the attr,
* advance over the attr based on its length. Nulls have no storage * then advance over the attr based on its length. Nulls have no
* and no alignment padding either. We can use/set attcacheoff until * storage and no alignment padding either. We can use/set
* we pass either a null or a var-width attribute. * attcacheoff until we pass either a null or a var-width attribute.
*/ */
for (i = 0; i < attnum; i++) for (i = 0; i < attnum; i++)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.112 2005/10/15 02:49:08 momjian Exp $ * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.113 2005/11/22 18:17:05 momjian Exp $
* *
* NOTES * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
...@@ -49,8 +49,8 @@ CreateTemplateTupleDesc(int natts, bool hasoid) ...@@ -49,8 +49,8 @@ CreateTemplateTupleDesc(int natts, bool hasoid)
* Allocate enough memory for the tuple descriptor, including the * Allocate enough memory for the tuple descriptor, including the
* attribute rows, and set up the attribute row pointers. * attribute rows, and set up the attribute row pointers.
* *
* Note: we assume that sizeof(struct tupleDesc) is a multiple of the struct * Note: we assume that sizeof(struct tupleDesc) is a multiple of the
* pointer alignment requirement, and hence we don't need to insert * struct pointer alignment requirement, and hence we don't need to insert
* alignment padding between the struct and the array of attribute row * alignment padding between the struct and the array of attribute row
* pointers. * pointers.
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.53 2005/11/06 22:39:20 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.54 2005/11/22 18:17:05 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -396,8 +396,8 @@ gistindex_keytest(IndexTuple tuple, ...@@ -396,8 +396,8 @@ gistindex_keytest(IndexTuple tuple,
* are the index datum (as a GISTENTRY*), the comparison datum, and * are the index datum (as a GISTENTRY*), the comparison datum, and
* the comparison operator's strategy number and subtype from pg_amop. * the comparison operator's strategy number and subtype from pg_amop.
* *
* (Presently there's no need to pass the subtype since it'll always be * (Presently there's no need to pass the subtype since it'll always
* zero, but might as well pass it for possible future use.) * be zero, but might as well pass it for possible future use.)
*/ */
test = FunctionCall4(&key->sk_func, test = FunctionCall4(&key->sk_func,
PointerGetDatum(&de), PointerGetDatum(&de),
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.10 2005/11/06 22:39:20 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.11 2005/11/22 18:17:05 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -65,6 +65,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion) ...@@ -65,6 +65,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
lencompleted = 16; lencompleted = 16;
buffer = ReadBuffer(gv->index, blkno); buffer = ReadBuffer(gv->index, blkno);
/* /*
* This is only used during VACUUM FULL, so we need not bother to lock * This is only used during VACUUM FULL, so we need not bother to lock
* individual index pages * individual index pages
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment