*
* 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 "common.h"
int clen,
slen,
i,
+ w,
*qidx,
*scridx,
qoffset,
{
qidx[i] = qoffset;
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);
}
qidx[i] = qoffset;
*/
scroffset = 0;
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. */
appendPQExpBufferStr(&msg, &wquery[qidx[ibeg]]);