Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
9bf2ac2a
Commit
9bf2ac2a
authored
Feb 10, 2006
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up signedness warnings and 64-bit bugs in recent psql printing
patch. Martijn van Oosterhout and Tom Lane
parent
fc9c20eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
27 deletions
+35
-27
src/bin/psql/mbprint.c
src/bin/psql/mbprint.c
+12
-13
src/bin/psql/print.c
src/bin/psql/print.c
+23
-14
No files found.
src/bin/psql/mbprint.c
View file @
9bf2ac2a
...
...
@@ -3,7 +3,7 @@
*
* 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"
...
...
@@ -158,11 +158,11 @@ pg_wcswidth(const unsigned char *pwcs, size_t len, int encoding)
{
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
;
...
...
@@ -191,10 +191,10 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
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 */
{
...
...
@@ -256,15 +256,14 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
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 */
{
...
...
@@ -282,13 +281,13 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
}
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
;
}
...
...
@@ -301,13 +300,13 @@ pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
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
;
...
...
src/bin/psql/print.c
View file @
9bf2ac2a
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.8
1 2006/02/10 15:48:05 momjian
Exp $
* $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.8
2 2006/02/10 22:29:06 tgl
Exp $
*/
#include "postgres_fe.h"
#include "common.h"
...
...
@@ -357,8 +357,8 @@ print_aligned_text(const char *title, const char *const * headers,
{
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
;
...
...
@@ -583,17 +583,22 @@ print_aligned_text(const char *title, const char *const * headers,
{
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
,
...
...
@@ -665,13 +670,13 @@ print_aligned_vertical(const char *title, const char *const * headers,
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
;
...
...
@@ -823,11 +828,12 @@ print_aligned_vertical(const char *title, const char *const * headers,
{
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
...
...
@@ -1753,7 +1759,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout, FILE *f
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
;
...
...
@@ -1764,7 +1771,9 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout, FILE *f
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 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment