This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: nl_langinfo (_NL_PAPER_HEIGHT) problem
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: nl_langinfo (_NL_PAPER_HEIGHT) problem
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Tue, 24 Apr 2001 15:39:56 +0200
- Cc: libc-alpha at sources dot redhat dot com, Werner Fink <werner at suse dot de>
- References: <hobspm1ldn.fsf@gee.suse.de>
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
On Tue, Apr 24, 2001 at 03:24:20PM +0200, Andreas Jaeger wrote:
>
> The output of the appended program is:
> gee:/tmp:[1]$ gcc -Wall -g t.c
> gee:/tmp:[0]$ ./a.out
> 297
> Segmentation fault
>
> According to the documentation and to Unix98, nl_langinfo returns a
> string - but it seems that glibc returns in this case an integer?
AFAIK, Unix98 does not speak about _NL_PAPER_HEIGHT, it is glibc extension
and glibc can do whatever it wants with it.
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>
#define NL_PAPER_GET(x) \
((union { char *string; unsigned int word; })nl_langinfo(x)).word
int main(int argc,char **argv)
{
int w, h;
setlocale (LC_PAPER, "");
w = NL_PAPER_GET (_NL_PAPER_WIDTH);
h = NL_PAPER_GET (_NL_PAPER_HEIGHT);
printf ("height: %i\nwidth: %i\n", h, w);
return 0;
}
works very well.
I assume there will be some standard interface to LC_PAPER (as well as all
other new LC_ categories) in the future.
Jakub