allow SUSv3 syntax.

if from/to code is ommitted, auto-guess'ed from current locale.
This commit is contained in:
tnozaki 2008-03-20 11:35:44 +00:00
parent c45bfb6fd1
commit 0b9f4942b6
2 changed files with 30 additions and 10 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: iconv.1,v 1.2 2003/07/04 07:58:10 wiz Exp $
.\" $NetBSD: iconv.1,v 1.3 2008/03/20 11:35:44 tnozaki Exp $
.\"
.\" Copyright (c)2003 Citrus Project,
.\" All rights reserved.
@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd July 4, 2003
.Dd March 20, 2008
.Dt ICONV 1
.Os
.\" ----------------------------------------------------------------------
@ -41,6 +41,18 @@
.Ar to_name
.Op Ar file ...
.Nm
.Fl f
.Ar from_name
.Op Fl cs
.Op Fl t Ar to_name
.Op Ar file ...
.Nm
.Fl t
.Ar to_name
.Op Fl cs
.Op Fl f Ar from_name
.Op Ar file ...
.Nm
.Fl l
.\" ----------------------------------------------------------------------
.Sh DESCRIPTION

View File

@ -1,4 +1,4 @@
/* $NetBSD: iconv.c,v 1.11 2007/12/15 19:44:50 perry Exp $ */
/* $NetBSD: iconv.c,v 1.12 2008/03/20 11:35:44 tnozaki Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@ -28,16 +28,17 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: iconv.c,v 1.11 2007/12/15 19:44:50 perry Exp $");
__RCSID("$NetBSD: iconv.c,v 1.12 2008/03/20 11:35:44 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <err.h>
#include <errno.h>
#include <iconv.h>
#include <langinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iconv.h>
#include <unistd.h>
#include <err.h>
#include <util.h>
static void usage(void) __unused;
@ -48,8 +49,11 @@ static void do_conv(const char *, FILE *, const char *, const char *, int, int);
static void
usage(void)
{
(void)fprintf(stderr, "Usage: %s [-cs] -f <from> -t <to> [file ...]\n"
"\t%s -l\n", getprogname(), getprogname());
(void)fprintf(stderr,
"Usage:\t%1$s [-cs] -f <from_code> -t <to_code> [file ...]\n"
"\t%1$s -f <from_code> [-cs] [-t <to_code>] [file ...]\n"
"\t%1$s -t <to_code> [-cs] [-f <from_code>] [file ...]\n"
"\t%1$s -l\n", getprogname());
exit(1);
}
@ -200,8 +204,12 @@ main(int argc, char **argv)
}
show_codesets();
} else {
if (opt_f == NULL || opt_t == NULL)
usage();
if (opt_f == NULL) {
if (opt_t == NULL)
usage();
opt_f = nl_langinfo(CODESET);
} else if (opt_t == NULL)
opt_t = nl_langinfo(CODESET);
if (argc == 0)
do_conv("<stdin>", stdin, opt_f, opt_t, opt_s, opt_c);