Commit 29eabaa9 authored by Tatsuo Ishii's avatar Tatsuo Ishii

Returns exit status 1 if invalid encoding name or

encoding number is given.
parent c918be6a
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.10 2001/10/25 05:49:53 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.11 2002/10/20 11:33:48 ishii Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,8 +57,12 @@ main(int argc, char **argv) ...@@ -57,8 +57,12 @@ main(int argc, char **argv)
if ((name = (char *) pg_encoding_to_char(enc))) if ((name = (char *) pg_encoding_to_char(enc)))
{ {
if (be_only && pg_valid_server_encoding(name) < 0) if (be_only && pg_valid_server_encoding(name) < 0)
exit(0); exit(1);
printf("%s\n", name); /* pg_encoding_to_char() returns "" if invalid encoding number is given */
else if (strcmp("", name))
printf("%s\n", name);
else
exit(1);
} }
exit(0); exit(0);
} }
...@@ -70,9 +74,12 @@ main(int argc, char **argv) ...@@ -70,9 +74,12 @@ main(int argc, char **argv)
if ((enc = pg_char_to_encoding(p)) >= 0) if ((enc = pg_char_to_encoding(p)) >= 0)
{ {
if (be_only && pg_valid_server_encoding(p) < 0) if (be_only && pg_valid_server_encoding(p) < 0)
exit(0); exit(1);
printf("%d\n", enc); printf("%d\n", enc);
} }
else
exit(1);
exit(0); exit(0);
} }
exit(1); exit(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment