diff options
author | Bruce Momjian <bruce@momjian.us> | 2007-11-15 21:14:46 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2007-11-15 21:14:46 +0000 |
commit | fdf5a5efb7b28c13085fe7313658de8d7b9914f6 (patch) | |
tree | a75cf1422fa1eef4e801cf502b148d8ce1b5dfe7 /contrib/test_parser/test_parser.c | |
parent | 3adc760fb92eab1a8720337a8bf9b66486609eb3 (diff) | |
download | postgresql-fdf5a5efb7b28c13085fe7313658de8d7b9914f6.tar.gz postgresql-fdf5a5efb7b28c13085fe7313658de8d7b9914f6.zip |
pgindent run for 8.3.
Diffstat (limited to 'contrib/test_parser/test_parser.c')
-rw-r--r-- | contrib/test_parser/test_parser.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/contrib/test_parser/test_parser.c b/contrib/test_parser/test_parser.c index 728bf4098fe..784d2d43ad0 100644 --- a/contrib/test_parser/test_parser.c +++ b/contrib/test_parser/test_parser.c @@ -6,7 +6,7 @@ * Copyright (c) 2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/test_parser/test_parser.c,v 1.1 2007/10/15 21:36:50 tgl Exp $ + * $PostgreSQL: pgsql/contrib/test_parser/test_parser.c,v 1.2 2007/11/15 21:14:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,40 +22,44 @@ PG_MODULE_MAGIC; */ /* self-defined type */ -typedef struct { - char * buffer; /* text to parse */ - int len; /* length of the text in buffer */ - int pos; /* position of the parser */ -} ParserState; +typedef struct +{ + char *buffer; /* text to parse */ + int len; /* length of the text in buffer */ + int pos; /* position of the parser */ +} ParserState; /* copy-paste from wparser.h of tsearch2 */ -typedef struct { - int lexid; - char *alias; - char *descr; -} LexDescr; +typedef struct +{ + int lexid; + char *alias; + char *descr; +} LexDescr; /* * prototypes */ PG_FUNCTION_INFO_V1(testprs_start); -Datum testprs_start(PG_FUNCTION_ARGS); +Datum testprs_start(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(testprs_getlexeme); -Datum testprs_getlexeme(PG_FUNCTION_ARGS); +Datum testprs_getlexeme(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(testprs_end); -Datum testprs_end(PG_FUNCTION_ARGS); +Datum testprs_end(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(testprs_lextype); -Datum testprs_lextype(PG_FUNCTION_ARGS); +Datum testprs_lextype(PG_FUNCTION_ARGS); /* * functions */ -Datum testprs_start(PG_FUNCTION_ARGS) +Datum +testprs_start(PG_FUNCTION_ARGS) { ParserState *pst = (ParserState *) palloc0(sizeof(ParserState)); + pst->buffer = (char *) PG_GETARG_POINTER(0); pst->len = PG_GETARG_INT32(1); pst->pos = 0; @@ -63,15 +67,16 @@ Datum testprs_start(PG_FUNCTION_ARGS) PG_RETURN_POINTER(pst); } -Datum testprs_getlexeme(PG_FUNCTION_ARGS) +Datum +testprs_getlexeme(PG_FUNCTION_ARGS) { - ParserState *pst = (ParserState *) PG_GETARG_POINTER(0); - char **t = (char **) PG_GETARG_POINTER(1); - int *tlen = (int *) PG_GETARG_POINTER(2); + ParserState *pst = (ParserState *) PG_GETARG_POINTER(0); + char **t = (char **) PG_GETARG_POINTER(1); + int *tlen = (int *) PG_GETARG_POINTER(2); int type; *tlen = pst->pos; - *t = pst->buffer + pst->pos; + *t = pst->buffer + pst->pos; if ((pst->buffer)[pst->pos] == ' ') { @@ -81,7 +86,9 @@ Datum testprs_getlexeme(PG_FUNCTION_ARGS) while ((pst->buffer)[pst->pos] == ' ' && pst->pos < pst->len) (pst->pos)++; - } else { + } + else + { /* word type */ type = 3; /* go to the next white-space character */ @@ -94,28 +101,29 @@ Datum testprs_getlexeme(PG_FUNCTION_ARGS) /* we are finished if (*tlen == 0) */ if (*tlen == 0) - type=0; + type = 0; PG_RETURN_INT32(type); } -Datum testprs_end(PG_FUNCTION_ARGS) +Datum +testprs_end(PG_FUNCTION_ARGS) { ParserState *pst = (ParserState *) PG_GETARG_POINTER(0); + pfree(pst); PG_RETURN_VOID(); } -Datum testprs_lextype(PG_FUNCTION_ARGS) +Datum +testprs_lextype(PG_FUNCTION_ARGS) { /* - * Remarks: - * - we have to return the blanks for headline reason - * - we use the same lexids like Teodor in the default - * word parser; in this way we can reuse the headline - * function of the default word parser. + * Remarks: - we have to return the blanks for headline reason - we use + * the same lexids like Teodor in the default word parser; in this way we + * can reuse the headline function of the default word parser. */ - LexDescr *descr = (LexDescr *) palloc(sizeof(LexDescr) * (2+1)); + LexDescr *descr = (LexDescr *) palloc(sizeof(LexDescr) * (2 + 1)); /* there are only two types in this parser */ descr[0].lexid = 3; |