Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / diffutils / lib / posixver.c
blobc2799247fe0926cef421d32c634698c22bce45b8
1 /* $NetBSD$ */
3 /* Which POSIX version to conform to, for utilities.
5 Copyright (C) 2002 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Library General Public License as published
9 by the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 USA. */
22 /* Written by Paul Eggert. */
24 #if HAVE_CONFIG_H
25 # include <config.h>
26 #endif
28 #include <limits.h>
30 #include <stdlib.h>
31 #if !HAVE_DECL_GETENV && !defined getenv
32 char *getenv ();
33 #endif
35 #if HAVE_UNISTD_H
36 # include <unistd.h>
37 #endif
38 #ifndef _POSIX2_VERSION
39 # define _POSIX2_VERSION 0
40 #endif
42 /* The POSIX version that utilities should conform to. The default is
43 specified by the system. */
45 int
46 posix2_version (void)
48 long int v = _POSIX2_VERSION;
49 char const *s = getenv ("_POSIX2_VERSION");
51 if (s && *s)
53 char *e;
54 long int i = strtol (s, &e, 10);
55 if (! *e)
56 v = i;
59 return v < INT_MIN ? INT_MIN : v < INT_MAX ? v : INT_MAX;