mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-10 11:20:10 +00:00
(charmap_conversion): Pass name of output file not stream for output file. Open output file here.
This commit is contained in:
parent
f3dc3415ec
commit
5484ff515e
@ -1,5 +1,5 @@
|
|||||||
/* Convert using charmaps and possibly iconv().
|
/* Convert using charmaps and possibly iconv().
|
||||||
Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc.
|
Copyright (C) 2001, 2005, 2006, 2008 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
|
||||||
|
|
||||||
@ -94,7 +94,8 @@ static int process_file (struct convtable *tbl, FILE *input, FILE *output);
|
|||||||
int
|
int
|
||||||
charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
|
charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
|
||||||
const char *to_code, struct charmap_t *to_charmap,
|
const char *to_code, struct charmap_t *to_charmap,
|
||||||
int argc, int remaining, char *argv[], FILE *output)
|
int argc, int remaining, char *argv[],
|
||||||
|
const char *output_file)
|
||||||
{
|
{
|
||||||
struct convtable *cvtbl;
|
struct convtable *cvtbl;
|
||||||
int status = EXIT_SUCCESS;
|
int status = EXIT_SUCCESS;
|
||||||
@ -132,6 +133,17 @@ charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
|
|||||||
if (cvtbl == NULL)
|
if (cvtbl == NULL)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
/* Determine output file. */
|
||||||
|
FILE *output;
|
||||||
|
if (output_file != NULL && strcmp (output_file, "-") != 0)
|
||||||
|
{
|
||||||
|
output = fopen (output_file, "w");
|
||||||
|
if (output == NULL)
|
||||||
|
error (EXIT_FAILURE, errno, _("cannot open output file"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
output = stdout;
|
||||||
|
|
||||||
/* We can now start the conversion. */
|
/* We can now start the conversion. */
|
||||||
if (remaining == argc)
|
if (remaining == argc)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user