Skip to content

Commit

Permalink
getopt/*, regex/*: Add _GETOPT/REGEX*_STANDALONE configurations.
Browse files Browse the repository at this point in the history
Makefile.am, os_win32/vc14/smart*.vcxproj*: Set *_STANDALONE.  Add new files.

git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools@4759 4ea69e1a-61f1-4043-bf83-b5c94c648137
  • Loading branch information
chrfranke committed Aug 19, 2018
1 parent 5b60de2 commit 7fb9e05
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 19 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ $Id$
2018-08-19 Christian Franke <[email protected]>

getopt/*, regex/*: Replace with current version from glibc 2.28
(2018-08-01).
(2018-08-01). Add _GETOPT/REGEX*_STANDALONE configurations.
Makefile.am, os_win32/vc14/smart*.vcxproj*: Set *_STANDALONE.
Add new files.

examplescripts/README: Update mailing list address.
os_solaris_ata.s: Remove old mailing list address.
Expand Down
14 changes: 10 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ if OS_WIN32_MINGW
AM_CPPFLAGS += -I$(srcdir)/os_win32
endif
if NEED_GETOPT_LONG
AM_CPPFLAGS += -I$(srcdir)/getopt -DHAVE_GETOPT_LONG -D__GNU_LIBRARY__
AM_CPPFLAGS += -I$(srcdir)/getopt -D_GETOPT_STANDALONE -DHAVE_GETOPT_LONG
endif
if NEED_REGEX
AM_CPPFLAGS += -I$(srcdir)/regex
AM_CPPFLAGS += -I$(srcdir)/regex -D_REGEX_STANDALONE
endif

sbin_PROGRAMS = \
Expand Down Expand Up @@ -209,12 +209,18 @@ if NEED_GETOPT_LONG
smartctl_SOURCES += \
getopt/getopt.c \
getopt/getopt.h \
getopt/getopt1.c
getopt/getopt1.c \
getopt/getopt_int.h \
getopt/bits/getopt_core.h \
getopt/bits/getopt_ext.h

smartd_SOURCES += \
getopt/getopt.c \
getopt/getopt.h \
getopt/getopt1.c
getopt/getopt1.c \
getopt/getopt_int.h \
getopt/bits/getopt_core.h \
getopt/bits/getopt_ext.h

endif

Expand Down
16 changes: 15 additions & 1 deletion getopt/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _LIBC
#if !defined(_LIBC) && !defined(_GETOPT_STANDALONE)
# include <config.h>
#endif

Expand All @@ -26,7 +26,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef _GETOPT_STANDALONE
#include <unistd.h>
#endif

#ifdef _LIBC
/* When used as part of glibc, error printing must be done differently
Expand All @@ -41,8 +43,12 @@
# define flockfile(fp) _IO_flockfile (fp)
# define funlockfile(fp) _IO_funlockfile (fp)
#else
#ifndef _GETOPT_STANDALONE
# include "gettext.h"
# define _(msgid) gettext (msgid)
#else
# define _(msgid) (msgid)
#endif
/* When used standalone, flockfile and funlockfile might not be
available. */
# ifndef _POSIX_THREAD_SAFE_FUNCTIONS
Expand Down Expand Up @@ -374,6 +380,14 @@ process_long_option (int argc, char **argv, const char *optstring,
return pfound->val;
}

#ifndef _GL_UNUSED
# ifdef __GNUC__
# define _GL_UNUSED __attribute__((__unused__))
# else
# define _GL_UNUSED
# endif
#endif

/* Initialize internal data upon the first call to getopt. */

static const char *
Expand Down
29 changes: 29 additions & 0 deletions getopt/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,36 @@
#ifndef _GETOPT_H
#define _GETOPT_H 1

#ifndef _GETOPT_STANDALONE
#include <features.h>
#endif

// From <sys/cdefs.h>:
#ifndef __BEGIN_DECLS
# ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
# else
# define __BEGIN_DECLS
# define __END_DECLS
# endif
#endif
#ifndef __THROW
# ifdef __cplusplus
# define __THROW throw()
# elif defined(__GNUC__)
# define __THROW __attribute__ ((__nothrow__))
# else
# define __THROW
# endif
#endif
#ifndef __nonnull
# ifdef __GNUC__
# define __nonnull(x) __attribute__ ((__nonnull__ x))
# else
# define __nonnull(x)
# endif
#endif

/* The type of the 'argv' argument to getopt_long and getopt_long_only
is properly 'char **', since both functions may write to the array
Expand Down
2 changes: 1 addition & 1 deletion getopt/getopt1.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#ifndef _LIBC
#if !defined(_LIBC) && !defined(_GETOPT_STANDALONE)
# include <config.h>
#endif

Expand Down
11 changes: 7 additions & 4 deletions os_win32/vc14/smartctl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Expand All @@ -102,7 +102,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
Expand All @@ -119,7 +119,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>.;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
Expand All @@ -138,7 +138,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>.;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
Expand Down Expand Up @@ -284,6 +284,9 @@
<ClInclude Include="..\..\ataidentify.h" />
<ClInclude Include="..\..\dev_areca.h" />
<ClInclude Include="..\..\dev_intelliprop.h" />
<ClInclude Include="..\..\getopt\bits\getopt_core.h" />
<ClInclude Include="..\..\getopt\bits\getopt_ext.h" />
<ClInclude Include="..\..\getopt\getopt_int.h" />
<ClInclude Include="..\..\json.h" />
<ClInclude Include="..\..\nvmecmds.h" />
<ClInclude Include="..\..\nvmeprint.h" />
Expand Down
9 changes: 9 additions & 0 deletions os_win32/vc14/smartctl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@
<ClInclude Include="..\..\nvmeprint.h" />
<ClInclude Include="..\..\dev_intelliprop.h" />
<ClInclude Include="..\..\json.h" />
<ClInclude Include="..\..\getopt\getopt_int.h">
<Filter>getopt</Filter>
</ClInclude>
<ClInclude Include="..\..\getopt\bits\getopt_core.h">
<Filter>getopt</Filter>
</ClInclude>
<ClInclude Include="..\..\getopt\bits\getopt_ext.h">
<Filter>getopt</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\installer.nsi">
Expand Down
11 changes: 7 additions & 4 deletions os_win32/vc14/smartd.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Expand All @@ -102,7 +102,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;..;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
Expand All @@ -119,7 +119,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>.;..;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_USE_32BIT_TIME_T;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
Expand All @@ -138,7 +138,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>.;..;..\..\getopt;..\..\regex;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_GETOPT_STANDALONE;_REGEX_STANDALONE;HAVE_CONFIG_H;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
Expand Down Expand Up @@ -298,6 +298,9 @@
</ClInclude>
<ClInclude Include="..\..\dev_areca.h" />
<ClInclude Include="..\..\dev_intelliprop.h" />
<ClInclude Include="..\..\getopt\bits\getopt_core.h" />
<ClInclude Include="..\..\getopt\bits\getopt_ext.h" />
<ClInclude Include="..\..\getopt\getopt_int.h" />
<ClInclude Include="..\..\nvmecmds.h" />
<ClInclude Include="..\..\nvmeprint.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
Expand Down
9 changes: 9 additions & 0 deletions os_win32/vc14/smartd.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@
<ClInclude Include="..\..\nvmecmds.h" />
<ClInclude Include="..\..\nvmeprint.h" />
<ClInclude Include="..\..\dev_intelliprop.h" />
<ClInclude Include="..\..\getopt\getopt_int.h">
<Filter>getopt</Filter>
</ClInclude>
<ClInclude Include="..\..\getopt\bits\getopt_core.h">
<Filter>getopt</Filter>
</ClInclude>
<ClInclude Include="..\..\getopt\bits\getopt_ext.h">
<Filter>getopt</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\installer.nsi">
Expand Down
4 changes: 3 additions & 1 deletion regex/regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ static reg_errcode_t
init_dfa (re_dfa_t *dfa, size_t pat_len)
{
__re_size_t table_size;
#ifndef _LIBC
#if !defined(_LIBC) && !defined(_REGEX_STANDALONE)
const char *codeset_name;
#endif
#ifdef RE_ENABLE_I18N
Expand Down Expand Up @@ -886,12 +886,14 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII)
!= 0);
#else
# if !defined(_REGEX_STANDALONE)
codeset_name = nl_langinfo (CODESET);
if ((codeset_name[0] == 'U' || codeset_name[0] == 'u')
&& (codeset_name[1] == 'T' || codeset_name[1] == 't')
&& (codeset_name[2] == 'F' || codeset_name[2] == 'f')
&& strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0)
dfa->is_utf8 = 1;
# endif

/* We check exhaustively in the loop below if this charset is a
superset of ASCII. */
Expand Down
2 changes: 1 addition & 1 deletion regex/regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */

#ifndef _LIBC
#if !defined(_LIBC) && !defined(_REGEX_STANDALONE)
# include <config.h>

# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
Expand Down
2 changes: 1 addition & 1 deletion regex/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {

/* Define __USE_GNU to declare GNU extensions that violate the
POSIX name space rules. */
#ifdef _GNU_SOURCE
#if defined(_GNU_SOURCE) || defined(_REGEX_STANDALONE)
# define __USE_GNU 1
#endif

Expand Down
8 changes: 7 additions & 1 deletion regex/regex_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <stdlib.h>
#include <string.h>

#ifndef _REGEX_STANDALONE
#include <langinfo.h>
#endif
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
Expand All @@ -35,7 +37,7 @@

/* Properties of integers. Although Gnulib has intprops.h, glibc does
without for now. */
#ifndef _LIBC
#if !defined(_LIBC) && !defined(_REGEX_STANDALONE)
# include "intprops.h"
#else
/* True if the real type T is signed. */
Expand Down Expand Up @@ -132,7 +134,11 @@
# define RE_ENABLE_I18N
#endif

#ifdef __GNUC__
#define BE(expr, val) __builtin_expect (expr, val)
#else
#define BE(expr, val) (expr)
#endif

/* Number of ASCII characters. */
#define ASCII_CHARS 0x80
Expand Down

0 comments on commit 7fb9e05

Please sign in to comment.