/* Which POSIX version to conform to, for utilities.12Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.34This program is free software; you can redistribute it and/or modify5it under the terms of the GNU General Public License as published by6the Free Software Foundation; either version 2, or (at your option)7any later version.89This program is distributed in the hope that it will be useful,10but WITHOUT ANY WARRANTY; without even the implied warranty of11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12GNU General Public License for more details.1314You should have received a copy of the GNU General Public License along15with this program; if not, write to the Free Software Foundation,16Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */1718/* Written by Paul Eggert. */1920#if HAVE_CONFIG_H21# include <config.h>22#endif2324#include "posixver.h"2526#include <limits.h>27#include <stdlib.h>2829#if HAVE_UNISTD_H30# include <unistd.h>31#endif32#ifndef _POSIX2_VERSION33# define _POSIX2_VERSION 034#endif3536#ifndef DEFAULT_POSIX2_VERSION37# define DEFAULT_POSIX2_VERSION _POSIX2_VERSION38#endif3940/* The POSIX version that utilities should conform to. The default is41specified by the system. */4243int44posix2_version (void)45{46long int v = DEFAULT_POSIX2_VERSION;47char const *s = getenv ("_POSIX2_VERSION");4849if (s && *s)50{51char *e;52long int i = strtol (s, &e, 10);53if (! *e)54v = i;55}5657return v < INT_MIN ? INT_MIN : v < INT_MAX ? v : INT_MAX;58}596061