X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2Fprint-copyr.c;h=2b6a13ecf7cae77998e2114162c142de5acbdee3;hb=e496c1b52955887eb0a7544eb621e896c989c6ac;hp=1ec02efa2cddac199ca6dc3107ff28a7e3756e39;hpb=792f26898871105ea39ddaac9be25bc39956d9e4;p=chaz%2Ftar diff --git a/lib/print-copyr.c b/lib/print-copyr.c index 1ec02ef..2b6a13e 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,53 +21,37 @@ # include #endif -#if HAVE_ICONV -# include +#include "print-copyr.h" +#include -# if HAVE_STDLIB_H -# include -# endif +#if ENABLE_NLS +# include "unicodeio.h" +#else +# define unicode_to_mb(code, callback, error_callback, callback_arg) \ + error_callback (code, callback_arg) #endif -#include "copysym.h" +#define COPYRIGHT_SIGN 0x00A9 -/* 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)) - { - extern char const *locale_charset (void); - outcharset = locale_charset (); - } - - 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 *) ©right_utf_8; - size_t inleft = sizeof copyright_utf_8; - char *outptr = buf; - size_t chars = iconv (conv, &inptr, &inleft, &outptr, &bufsize); - - iconv_close (conv); + FILE *stream = callback_arg; + return fputs ("(C)", stream); +} - if (chars != (size_t) -1) - return buf; - } - } -#endif +/* Print "Copyright (C) " followed by NOTICE and then a newline, + transliterating "(C)" to an actual copyright sign (C-in-a-circle) + if possible. */ - /* "(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_char, print_parenthesized_c, + stdout); + fputc (' ', stdout); + puts (notice); }