This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: nl_langinfo (_NL_PAPER_HEIGHT) problem


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]