diff options
| author | Bruce Momjian <bruce@momjian.us> | 1998-06-16 07:29:54 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 1998-06-16 07:29:54 +0000 |
| commit | cb7cbc16fa4b5933fb5d63052568e3ed6859857b (patch) | |
| tree | bed17594c4880549288373de4d400512cbe2f82d /src/bin/psql/psql.c | |
| parent | 0d8e7f6381291b85ad6264365e01143357d70a75 (diff) | |
| download | postgresql-cb7cbc16fa4b5933fb5d63052568e3ed6859857b.tar.gz | |
Hi, here are the patches to enhance existing MB handling. This time
I have implemented a framework of encoding translation between the
backend and the frontend. Also I have added a new variable setting
command:
SET CLIENT_ENCODING TO 'encoding';
Other features include:
Latin1 support more 8 bit cleaness
See doc/README.mb for more details. Note that the pacthes are
against May 30 snapshot.
Tatsuo Ishii
Diffstat (limited to 'src/bin/psql/psql.c')
| -rw-r--r-- | src/bin/psql/psql.c | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index 9f699ad8d7..1ed9e4561f 100644 --- a/src/bin/psql/psql.c +++ b/src/bin/psql/psql.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.145 1998/06/15 19:30:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.146 1998/06/16 07:29:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -639,8 +639,13 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout) } else { +#ifdef MB + for (i = 0; table[i]; i += PQmblen(table+i)) +#else for (i = 0; table[i]; i++) - if (isupper(table[i])) +#endif + if (isascii((unsigned char)table[i]) && + isupper(table[i])) table[i] = tolower(table[i]); } @@ -811,7 +816,11 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout) } else { +#ifdef MB + for (i = 0; object[i]; i += PQmblen(object+i)) +#else for (i = 0; object[i]; i++) +#endif if (isupper(object[i])) object[i] = tolower(object[i]); } @@ -2296,9 +2305,16 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) { int i; - was_bslash = false; +#ifdef MB + int mblen = 1; +#endif + was_bslash = false; +#ifdef MB + for (i = 0; i < len; mblen=PQmblen(line+i), i+=mblen) +#else for (i = 0; i < len; i++) +#endif { if (line[i] == '\\' && !in_quote) { @@ -2322,7 +2338,9 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) /* start an extended comment? */ } - if (querySent && !isspace(line[i])) + if (querySent && + isascii((unsigned char)(line[i])) && + !isspace(line[i])) { query[0] = '\0'; querySent = false; @@ -2330,7 +2348,11 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) if (was_bslash) was_bslash = false; +#ifdef MB + else if (i > 0 && line[i - mblen] == '\\') +#else else if (i > 0 && line[i - 1] == '\\') +#endif was_bslash = true; /* inside a quote? */ @@ -2339,22 +2361,42 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) else if (xcomment != NULL) /* inside an extended * comment? */ { +#ifdef MB + if (line[i] == '*' && line[i + mblen] == '/') +#else if (line[i] == '*' && line[i + 1] == '/') +#endif { xcomment = NULL; +#ifdef MB + i += mblen; +#else i++; +#endif } } /* possible backslash command? */ +#ifdef MB + else if (line[i] == '/' && line[i + mblen] == '*') +#else else if (line[i] == '/' && line[i + 1] == '*') +#endif { xcomment = line + i; +#ifdef MB + i += mblen; +#else i++; - +#endif } /* single-line comment? truncate line */ +#ifdef MB + else if ((line[i] == '-' && line[i + mblen] == '-') || + (line[i] == '/' && line[i + mblen] == '/')) +#else else if ((line[i] == '-' && line[i + 1] == '-') || (line[i] == '/' && line[i + 1] == '/')) +#endif { /* print comment at top of query */ if (pset->singleStep) |
