|
Packit Service |
2723c6 |
/* Which POSIX version to conform to, for utilities.
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
Copyright (C) 2002-2006, 2009-2018 Free Software Foundation, Inc.
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
2723c6 |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
2723c6 |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
2723c6 |
(at your option) any later version.
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
2723c6 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2723c6 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
2723c6 |
GNU General Public License for more details.
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
2723c6 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
/* Written by Paul Eggert. */
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
#include <config.h>
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
#include "posixver.h"
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
#include <limits.h>
|
|
Packit Service |
2723c6 |
#include <stdlib.h>
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
#include <unistd.h>
|
|
Packit Service |
2723c6 |
#ifndef _POSIX2_VERSION
|
|
Packit Service |
2723c6 |
# define _POSIX2_VERSION 0
|
|
Packit Service |
2723c6 |
#endif
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
#ifndef DEFAULT_POSIX2_VERSION
|
|
Packit Service |
2723c6 |
# define DEFAULT_POSIX2_VERSION _POSIX2_VERSION
|
|
Packit Service |
2723c6 |
#endif
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
/* The POSIX version that utilities should conform to. The default is
|
|
Packit Service |
2723c6 |
specified by the system. */
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
int
|
|
Packit Service |
2723c6 |
posix2_version (void)
|
|
Packit Service |
2723c6 |
{
|
|
Packit Service |
2723c6 |
long int v = DEFAULT_POSIX2_VERSION;
|
|
Packit Service |
2723c6 |
char const *s = getenv ("_POSIX2_VERSION");
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
if (s && *s)
|
|
Packit Service |
2723c6 |
{
|
|
Packit Service |
2723c6 |
char *e;
|
|
Packit Service |
2723c6 |
long int i = strtol (s, &e, 10);
|
|
Packit Service |
2723c6 |
if (! *e)
|
|
Packit Service |
2723c6 |
v = i;
|
|
Packit Service |
2723c6 |
}
|
|
Packit Service |
2723c6 |
|
|
Packit Service |
2723c6 |
return v < INT_MIN ? INT_MIN : v < INT_MAX ? v : INT_MAX;
|
|
Packit Service |
2723c6 |
}
|