Initial revision
This commit is contained in:
73
lib/print-copyr.c
Normal file
73
lib/print-copyr.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/* copysym.c -- Return a copyright symbol suitable for the current locale.
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ICONV
|
||||
# include <iconv.h>
|
||||
|
||||
# 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. */
|
||||
|
||||
char const *
|
||||
copyright_symbol (char *buf, size_t bufsize)
|
||||
{
|
||||
#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);
|
||||
|
||||
if (chars != (size_t) -1)
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* "(C)" is the best we can do in ASCII. */
|
||||
return "(C)";
|
||||
}
|
||||
9
lib/print-copyr.h
Normal file
9
lib/print-copyr.h
Normal file
@@ -0,0 +1,9 @@
|
||||
# ifndef PARAMS
|
||||
# if PROTOTYPES || (defined (__STDC__) && __STDC__)
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
char const *copyright_symbol PARAMS((char *, size_t));
|
||||
Reference in New Issue
Block a user