summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2001-09-21 22:19:09 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2001-09-21 22:19:09 +0000
commit4b5d60ef385197e76a2dc6122401e2a13e177f52 (patch)
tree783165d118ff9759bcee4eab839e0d5dfb5b33cb
parent7a1b6cfa67ea6383cb94632dc46823a6f51605e0 (diff)
downloadtar-4b5d60ef385197e76a2dc6122401e2a13e177f52.tar.gz
Rewrite from scratch, as print-copyr.c.
-rw-r--r--lib/print-copyr.c77
1 files changed, 22 insertions, 55 deletions
diff --git a/lib/print-copyr.c b/lib/print-copyr.c
index 7bbb2c06..6abaccf6 100644
--- a/lib/print-copyr.c
+++ b/lib/print-copyr.c
@@ -1,4 +1,4 @@
-/* copysym.c -- Return a copyright symbol suitable for the current locale.
+/* Print a copyright notice suitable for the current locale.
Copyright (C) 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -21,65 +21,32 @@
# include <config.h>
#endif
-#include <stddef.h>
+#include "unicodeio.h"
+#include "print-copyr.h"
-#if HAVE_ICONV
-# include <iconv.h>
+#include <stdio.h>
-# if ! USE_INCLUDED_LIBINTL && HAVE_LANGINFO_CODESET
-# include <langinfo.h>
-# endif
+#define COPYRIGHT_SIGN 0x00A9
-# if HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-
-#include "copysym.h"
-
-/* Store into BUF (of size BUFSIZE) a representation of the copyright
- symbol (C-in-a-circle) that is a valid text string for the current
- locale. Return BUF if successful, and a pointer to some other
- string otherwise. */
+/* Print "(C)". */
-char const *
-copyright_symbol (char *buf, size_t bufsize)
+static int
+print_parenthesized_c (unsigned int code, void *callback_arg)
{
-#if HAVE_ICONV
- char const *outcharset = getenv ("OUTPUT_CHARSET");
-
- if (! (outcharset && *outcharset))
- {
-#if USE_INCLUDED_LIBINTL
- extern char const *locale_charset (void);
- outcharset = locale_charset ();
-#else
-# if HAVE_LANGINFO_CODESET
- outcharset = nl_langinfo (CODESET);
-# endif
-#endif
- }
-
- if (*outcharset)
- {
- iconv_t conv = iconv_open (outcharset, "UTF-8");
-
- if (conv != (iconv_t) -1)
- {
- static char const copyright_utf_8[] = "\302\251";
- char ICONV_CONST *inptr = (char ICONV_CONST *) &copyright_utf_8;
- size_t inleft = sizeof copyright_utf_8;
- char *outptr = buf;
- size_t chars = iconv (conv, &inptr, &inleft, &outptr, &bufsize);
+ FILE *stream = callback_arg;
+ return fputs ("(C)", stream);
+}
- iconv_close (conv);
+/* Print "Copyright (C) " followed by NOTICE and then a newline,
+ transliterating "(C)" to an actual copyright sign (C-in-a-circle)
+ if possible. */
- if (chars != (size_t) -1)
- return buf;
- }
- }
-#endif
-
- /* "(C)" is the best we can do in ASCII. */
- return "(C)";
+void
+print_copyright (char const *notice)
+{
+ fputs ("Copyright ", stdout);
+ unicode_to_mb (COPYRIGHT_SIGN, print_unicode_success, print_parenthesized_c,
+ stdout);
+ fputc (' ', stdout);
+ puts (notice);
}