Skip to content
Snippets Groups Projects
Commit 6c0d4aab authored by Tom Lane's avatar Tom Lane
Browse files

Fix more fallout from line-wrap patch, to wit, arbitrarily changing

the API of PQdsplen without bothering to fix its callers.  Although
ReportSyntaxErrorPosition could probably do with more smarts about
handling control characters, for the moment I'll just get it back to
handling tabs consistently.
parent f9a726aa
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.111 2005/11/22 18:17:29 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.112 2006/02/12 03:30:21 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
...@@ -444,6 +444,7 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) ...@@ -444,6 +444,7 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
int clen, int clen,
slen, slen,
i, i,
w,
*qidx, *qidx,
*scridx, *scridx,
qoffset, qoffset,
...@@ -503,7 +504,11 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) ...@@ -503,7 +504,11 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
{ {
qidx[i] = qoffset; qidx[i] = qoffset;
scridx[i] = scroffset; scridx[i] = scroffset;
scroffset += PQdsplen(&query[qoffset], pset.encoding); w = PQdsplen(&query[qoffset], pset.encoding);
/* treat control chars as width 1; see tab hack below */
if (w <= 0)
w = 1;
scroffset += w;
qoffset += PQmblen(&query[qoffset], pset.encoding); qoffset += PQmblen(&query[qoffset], pset.encoding);
} }
qidx[i] = qoffset; qidx[i] = qoffset;
...@@ -618,7 +623,12 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) ...@@ -618,7 +623,12 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query)
*/ */
scroffset = 0; scroffset = 0;
for (i = 0; i < msg.len; i += PQmblen(&msg.data[i], pset.encoding)) for (i = 0; i < msg.len; i += PQmblen(&msg.data[i], pset.encoding))
scroffset += PQdsplen(&msg.data[i], pset.encoding); {
w = PQdsplen(&msg.data[i], pset.encoding);
if (w <= 0)
w = 1;
scroffset += w;
}
/* Finish and emit the message. */ /* Finish and emit the message. */
appendPQExpBufferStr(&msg, &wquery[qidx[ibeg]]); appendPQExpBufferStr(&msg, &wquery[qidx[ibeg]]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment