*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.145 2006/10/04 00:30:05 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.146 2006/10/07 22:21:38 tgl Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
while (*cp)
{
- if (*cp == '"')
+ char ch = *cp;
+
+ if (ch == '"')
{
if (inquotes && cp[1] == '"')
{
- /* emit one quote */
+ /* emit one quote, stay in inquotes mode */
appendPQExpBufferChar(&namebuf, '"');
cp++;
}
- inquotes = !inquotes;
+ else
+ inquotes = !inquotes;
cp++;
}
- else if (!inquotes && isupper((unsigned char) *cp))
+ else if (!inquotes && isupper((unsigned char) ch))
{
appendPQExpBufferChar(&namebuf,
- pg_tolower((unsigned char) *cp));
+ pg_tolower((unsigned char) ch));
cp++;
}
- else if (!inquotes && *cp == '*')
+ else if (!inquotes && ch == '*')
{
appendPQExpBuffer(&namebuf, ".*");
cp++;
}
- else if (!inquotes && *cp == '?')
+ else if (!inquotes && ch == '?')
{
appendPQExpBufferChar(&namebuf, '.');
cp++;
}
- else if (!inquotes && *cp == '.')
+ else if (!inquotes && ch == '.')
{
/* Found schema/name separator, move current pattern to schema */
resetPQExpBuffer(&schemabuf);
* that are more powerful than shell-style patterns.
*/
if ((inquotes || force_escape) &&
- strchr("|*+?()[]{}.^$\\", *cp))
+ strchr("|*+?()[]{}.^$\\", ch))
appendPQExpBufferChar(&namebuf, '\\');
i = PQmblen(cp, pset.encoding);
while (i-- && *cp)