From 29eabaa958f595d838699d7cabdfb3405c54051c Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Sun, 20 Oct 2002 11:33:48 +0000 Subject: [PATCH] Returns exit status 1 if invalid encoding name or encoding number is given. --- src/bin/pg_encoding/pg_encoding.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_encoding/pg_encoding.c b/src/bin/pg_encoding/pg_encoding.c index f63a01b90e..ecc0c54524 100644 --- a/src/bin/pg_encoding/pg_encoding.c +++ b/src/bin/pg_encoding/pg_encoding.c @@ -7,7 +7,7 @@ * * * 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) if ((name = (char *) pg_encoding_to_char(enc))) { if (be_only && pg_valid_server_encoding(name) < 0) - exit(0); - printf("%s\n", name); + exit(1); + /* pg_encoding_to_char() returns "" if invalid encoding number is given */ + else if (strcmp("", name)) + printf("%s\n", name); + else + exit(1); } exit(0); } @@ -70,9 +74,12 @@ main(int argc, char **argv) if ((enc = pg_char_to_encoding(p)) >= 0) { if (be_only && pg_valid_server_encoding(p) < 0) - exit(0); + exit(1); printf("%d\n", enc); } + else + exit(1); + exit(0); } exit(1);