diff options
| author | Peter Eisentraut | 2004-11-09 15:57:57 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2004-11-09 15:57:57 +0000 |
| commit | e9c05281b5991ad5937cc14579dfff79499d6786 (patch) | |
| tree | a03b8a046cf3727660f450f8b538aafa9b4ab63c /src/interfaces | |
| parent | 960f545041bc3c6a7536d4ee8328c087c52616b3 (diff) | |
Get rid of perror(), substitute some better phrased error messages.
malloc() doesn't set errno, so most uses were buggy anyway.
Diffstat (limited to 'src/interfaces')
| -rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.c | 11 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-auth.c | 4 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-print.c | 14 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 9d0648289cf..d106928d58b 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.90 2004/08/29 05:07:00 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.91 2004/11/09 15:57:55 petere Exp $ */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ @@ -154,7 +154,8 @@ main(int argc, char *const argv[]) yyout = fopen(optarg, PG_BINARY_W); if (yyout == NULL) - perror(optarg); + fprintf(stderr, "%s: could not open file \"%s\": %s\n", + progname, optarg, strerror(errno)); else out_option = 1; break; @@ -304,7 +305,8 @@ main(int argc, char *const argv[]) yyout = fopen(output_filename, PG_BINARY_W); if (yyout == NULL) { - perror(output_filename); + fprintf(stderr, "%s: could not open file \"%s\": %s\n", + progname, output_filename, strerror(errno)); free(output_filename); free(input_filename); continue; @@ -313,7 +315,8 @@ main(int argc, char *const argv[]) } if (yyin == NULL) - perror(argv[fnr]); + fprintf(stderr, "%s: could not open file \"%s\": %s\n", + progname, argv[fnr], strerror(errno)); else { struct cursor *ptr; diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 84477563ef5..fa586ce5b86 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.94 2004/10/16 03:10:17 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.95 2004/11/09 15:57:57 petere Exp $ * *------------------------------------------------------------------------- */ @@ -527,7 +527,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq) if (!(crypt_pwd = malloc(MD5_PASSWD_LEN + 1)) || !(crypt_pwd2 = malloc(MD5_PASSWD_LEN + 1))) { - perror("malloc"); + fprintf(stderr, libpq_gettext("out of memory\n")); return STATUS_ERROR; } if (!EncryptMD5(password, conn->pguser, diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index bd89e825c77..832af2b3ac0 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -10,7 +10,7 @@ * didn't really belong there. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.54 2004/08/29 05:07:00 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.55 2004/11/09 15:57:57 petere Exp $ * *------------------------------------------------------------------------- */ @@ -110,17 +110,17 @@ PQprint(FILE *fout, nTups = PQntuples(res); if (!(fieldNames = (const char **) calloc(nFields, sizeof(char *)))) { - perror("calloc"); + fprintf(stderr, libpq_gettext("out of memory\n")); exit(1); } if (!(fieldNotNum = (unsigned char *) calloc(nFields, 1))) { - perror("calloc"); + fprintf(stderr, libpq_gettext("out of memory\n")); exit(1); } if (!(fieldMax = (int *) calloc(nFields, sizeof(int)))) { - perror("calloc"); + fprintf(stderr, libpq_gettext("out of memory\n")); exit(1); } for (numFieldName = 0; @@ -205,7 +205,7 @@ PQprint(FILE *fout, { if (!(fields = (char **) calloc(nFields * (nTups + 1), sizeof(char *)))) { - perror("calloc"); + fprintf(stderr, libpq_gettext("out of memory\n")); exit(1); } } @@ -392,7 +392,7 @@ do_field(const PQprintOpt *po, const PGresult *res, fieldMax[j] = plen; if (!(fields[i * nFields + j] = (char *) malloc(plen + 1))) { - perror("malloc"); + fprintf(stderr, libpq_gettext("out of memory\n")); exit(1); } strcpy(fields[i * nFields + j], pval); @@ -463,7 +463,7 @@ do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax, border = malloc(tot + 1); if (!border) { - perror("malloc"); + fprintf(stderr, libpq_gettext("out of memory\n")); exit(1); } p = border; |
