malloc() doesn't set errno, so most uses were buggy anyway.
if (chmod(pg_data, 0700) != 0)
{
- perror(pg_data);
+ fprintf(stderr, _("%s: could not change permissions of directory »%s«: %s\n"),
+ progname, pg_data, strerror(errno));
exit_nicely();
}
else
default:
/* Trouble accessing directory */
- perror(pg_data);
+ fprintf(stderr, _("%s: could not access directory »%s«: %s\n"),
+ progname, pg_data, strerror(errno));
exit_nicely();
}
widths = calloc(col_count, sizeof(*widths));
if (!widths)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
head_w = calloc(col_count, sizeof(*head_w));
if (!head_w)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
}
cell_w = calloc(cell_count, sizeof(*cell_w));
if (!cell_w)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
}
head_w = calloc(col_count, sizeof(*head_w));
if (!head_w)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
}
cell_w = calloc(cell_count, sizeof(*cell_w));
if (!cell_w)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
}
divider = malloc(hwidth + dwidth + 10);
if (!divider)
{
- perror("malloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
divider[0] = '\0';
if (!record_str)
{
- perror("malloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
if (!div_copy)
{
- perror("malloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
headers = calloc(nfields + 1, sizeof(*headers));
if (!headers)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
cells = calloc(ncells + 1, sizeof(*cells));
if (!cells)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
footers = calloc(2, sizeof(*footers));
if (!footers)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
footers[0] = malloc(100);
if (!footers[0])
{
- perror("malloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
if (PQntuples(result) == 1)
align = calloc(nfields + 1, sizeof(*align));
if (!align)
{
- perror("calloc");
+ fprintf(stderr, gettext("out of memory\n"));
exit(EXIT_FAILURE);
}
pw = getpwuid(getuid());
if (!pw)
{
- perror(progname);
+ fprintf(stderr, _("%s: could not obtain information about current user: %s"),
+ progname, strerror(errno));
exit(1);
}
return pw->pw_name;
if (!GetUserName(username, &len))
{
- perror(progname);
+ fprintf(stderr, _("%s: could not get current user name: %s"),
+ progname, strerror(errno));
exit(1);
}
return username;
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;
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;
}
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;
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,
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;
{
if (!(fields = (char **) calloc(nFields * (nTups + 1), sizeof(char *))))
{
- perror("calloc");
+ fprintf(stderr, libpq_gettext("out of memory\n"));
exit(1);
}
}
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);
border = malloc(tot + 1);
if (!border)
{
- perror("malloc");
+ fprintf(stderr, libpq_gettext("out of memory\n"));
exit(1);
}
p = border;