*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.19 2006/02/10 00:39:04 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.20 2006/02/10 22:29:06 tgl Exp $
*/
#include "postgres_fe.h"
{
int chlen, chwidth;
- chlen = PQmblen(pwcs, encoding);
+ chlen = PQmblen((const char*) pwcs, encoding);
if (chlen > len)
break; /* Invalid string */
- chwidth = PQdsplen(pwcs, encoding);
+ chwidth = PQdsplen((const char *) pwcs, encoding);
if (chwidth > 0)
width += chwidth;
for (; *pwcs && len > 0; pwcs += chlen)
{
- chlen = PQmblen(pwcs, encoding);
+ chlen = PQmblen((char *) pwcs, encoding);
if (len < (size_t)chlen)
break;
- w = PQdsplen(pwcs, encoding);
+ w = PQdsplen((char *) pwcs, encoding);
if (chlen == 1) /* ASCII char */
{
int w,
chlen = 0;
int linewidth = 0;
-
- char *ptr = lines->ptr; /* Pointer to data area */
+ unsigned char *ptr = lines->ptr; /* Pointer to data area */
for (; *pwcs && len > 0; pwcs += chlen)
{
- chlen = PQmblen(pwcs,encoding);
+ chlen = PQmblen((char *) pwcs,encoding);
if (len < (size_t)chlen)
break;
- w = PQdsplen(pwcs,encoding);
+ w = PQdsplen((char *) pwcs,encoding);
if (chlen == 1) /* single byte char char */
{
}
else if (*pwcs == '\r') /* Linefeed */
{
- strcpy(ptr, "\\r");
+ strcpy((char *) ptr, "\\r");
linewidth += 2;
ptr += 2;
}
else if (w <= 0) /* Other control char */
{
- sprintf(ptr, "\\x%02X", *pwcs);
+ sprintf((char *) ptr, "\\x%02X", *pwcs);
linewidth += 4;
ptr += 4;
}
else if (w <= 0) /* Non-ascii control char */
{
if (encoding == PG_UTF8)
- sprintf(ptr, "\\u%04X", utf2ucs(pwcs));
+ sprintf((char *) ptr, "\\u%04X", utf2ucs(pwcs));
else
/* This case cannot happen in the current
* code because only UTF-8 signals multibyte
* control characters. But we may need to
* support it at some stage */
- sprintf(ptr, "\\u????");
+ sprintf((char *) ptr, "\\u????");
ptr += 6;
linewidth += 6;
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.81 2006/02/10 15:48:05 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.82 2006/02/10 22:29:06 tgl Exp $
*/
#include "postgres_fe.h"
#include "common.h"
{
unsigned int col_count = 0;
unsigned int cell_count = 0;
- unsigned int i,
- tmp;
+ unsigned int i;
+ int tmp;
unsigned int *widths,
total_w;
unsigned int *heights;
{
if (opt_numeric_locale)
{
- /* Assumption: This code used only on strings
+ /*
+ * Assumption: This code used only on strings
* without multibyte characters, otherwise
* this_line->width < strlen(this_ptr) and we
- * get an overflow */
-
- char *my_cell = format_numeric_locale(this_line->ptr);
- fprintf(fout, "%*s%s", widths[i % col_count] - strlen(my_cell), "", my_cell);
+ * get an overflow
+ */
+ char *my_cell = format_numeric_locale((char *) this_line->ptr);
+ fprintf(fout, "%*s%s",
+ (int) (widths[i % col_count] - strlen(my_cell)), "",
+ my_cell);
free(my_cell);
}
else
- fprintf(fout, "%*s%s", widths[j] - this_line->width, "", this_line->ptr);
+ fprintf(fout, "%*s%s",
+ widths[j] - this_line->width, "",
+ this_line->ptr);
}
else
fprintf(fout, "%-s%*s", this_line->ptr,
unsigned int record = 1;
const char *const * ptr;
unsigned int i,
- tmp = 0,
hwidth = 0,
dwidth = 0,
hheight = 1,
dheight = 1,
hformatsize = 0,
dformatsize = 0;
+ int tmp = 0;
char *divider;
unsigned int cell_count = 0;
struct lineptr *hlineptr, *dlineptr;
{
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
{
- char *my_cell = format_numeric_locale(dlineptr[line_count].ptr);
+ char *my_cell = format_numeric_locale((char *) dlineptr[line_count].ptr);
if (opt_border < 2)
fprintf(fout, "%s\n", my_cell);
else
- fprintf(fout, "%-s%*s |\n", my_cell, dwidth - strlen(my_cell), "");
+ fprintf(fout, "%-s%*s |\n", my_cell,
+ (int) (dwidth - strlen(my_cell)), "");
free(my_cell);
}
else
headers = pg_local_calloc(nfields + 1, sizeof(*headers));
for (i = 0; i < nfields; i++)
- headers[i] = mbvalidate(PQfname(result, i), opt->topt.encoding);
+ headers[i] = (char*) mbvalidate((unsigned char *) PQfname(result, i),
+ opt->topt.encoding);
/* set cells */
ncells = PQntuples(result) * nfields;
if (PQgetisnull(result, i / nfields, i % nfields))
cells[i] = opt->nullPrint ? opt->nullPrint : "";
else
- cells[i] = mbvalidate(PQgetvalue(result, i / nfields, i % nfields), opt->topt.encoding);
+ cells[i] = (char*)
+ mbvalidate((unsigned char*) PQgetvalue(result, i / nfields, i % nfields),
+ opt->topt.encoding);
}
/* set footers */