From b2694c7ef681ded1d54cacaa8b8e1ad38da01351 Mon Sep 17 00:00:00 2001 From: Keith Marshall Date: Sun, 20 Mar 2016 22:13:10 +0000 Subject: [PATCH] Factor out vs. duplicate declarations. --- mingwrt/ChangeLog | 17 ++++++ mingwrt/include/locale.h | 150 +++++++++++++++++++++++++++++------------------ mingwrt/include/wchar.h | 13 ++-- 3 files changed, 119 insertions(+), 61 deletions(-) diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog index a600cd0..f2d9fa6 100644 --- a/mingwrt/ChangeLog +++ b/mingwrt/ChangeLog @@ -1,3 +1,20 @@ +2016-03-20 Keith Marshall + + Factor out vs. duplicate declarations. + + * include/locale.h: Assert copyright; tidy layout. + (_LOCALE_H_): Rename multiple inclusion guard macro, to... + (_LOCALE_H): ...this; do not define it when... + [__WCHAR_H_SOURCED__]: ...this applies; restrict declarations... + (_wsetlocale): ...to just this one visible function prototype. + [!__WCHAR_H_SOURCED__] (_LOCALE_H): Define it; expose all content. + (_WLOCALE_DEFINED): Do not define it; delete all references. + (pragma GCC system_header): Declare it. + + * include/wchar.h (_wsetlocale): Delete prototype; maintain its + visibility by selective inclusion of instead. + (_WLOCALE_DEFINED): Delete all references. + 2016-03-18 Keith Marshall Resolve some "implicit function declaration" warnings. diff --git a/mingwrt/include/locale.h b/mingwrt/include/locale.h index 31c6df2..b756a19 100644 --- a/mingwrt/include/locale.h +++ b/mingwrt/include/locale.h @@ -1,28 +1,51 @@ /* * locale.h - * This file has no copyright assigned and is placed in the Public Domain. - * This file is a part of the mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within the package. * * Functions and types for localization (ie. changing the appearance of - * output based on the standards of a certain country). + * output based on the standards of a certain country, or region). + * + * $Id$ + * + * Written by Rob Savoye + * Copyright (C) 1997, 1999-2001, 2003, 2004, 2007, 2016, MinGW.org Project. + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice, this permission notice, and the following + * disclaimer shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS IN THE SOFTWARE. * */ +#ifndef _LOCALE_H +#pragma GCC system_header -#ifndef _LOCALE_H_ -#define _LOCALE_H_ - -/* All the headers include this file. */ -#include <_mingw.h> +/* Content from is selectively shared with ; + * defer definition of the normal repeat inclusion guard, until... + */ +#ifndef __WCHAR_H_SOURCED__ + /* ...we have confirmed that this inclusion is NOT the + * selective request. + */ +#define _LOCALE_H -/* - * NOTE: I have tried to test this, but I am limited by my knowledge of - * locale issues. The structure does not bomb if you look at the - * values, and 'decimal_point' even seems to be correct. But the - * rest of the values are, by default, not particularly useful - * (read meaningless and not related to the international settings - * of the system). +/* All MinGW headers should include <_mingw.h>; do so only when NOT + * sourced by , (which should have included it already). */ +#include <_mingw.h> #define LC_ALL 0 #define LC_COLLATE 1 @@ -34,55 +57,70 @@ #define LC_MAX LC_TIME #ifndef RC_INVOKED - -/* According to C89 std, NULL is defined in locale.h too. */ +/* Both ISO-C and POSIX stipulate that should reproduce the + * definition of NULL, from ; although not required by either + * standard, we also require wchar_t, to support our declaration of the + * Microsoft specific _wsetlocale() function, below. + */ #define __need_NULL +#define __need_wchar_t #include -/* - * The structure returned by 'localeconv'. - */ struct lconv -{ - char* decimal_point; - char* thousands_sep; - char* grouping; - char* int_curr_symbol; - char* currency_symbol; - char* mon_decimal_point; - char* mon_thousands_sep; - char* mon_grouping; - char* positive_sign; - char* negative_sign; - char int_frac_digits; - char frac_digits; - char p_cs_precedes; - char p_sep_by_space; - char n_cs_precedes; - char n_sep_by_space; - char p_sign_posn; - char n_sign_posn; +{ /* The structure returned by the localeconv() function. + * + * AUTHOR'S NOTE: + * I have tried to test this, but I am limited by my knowledge of + * locale issues. The structure does not bomb if you look at the + * values, and 'decimal_point' even seems to be correct, but the + * rest of the values may, by default, not be particularly useful; + * indeed, they may even be meaningless, and in no way related to + * the international settings of the system. + */ + char *decimal_point; + char *thousands_sep; + char *grouping; + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; }; -#ifdef __cplusplus -extern "C" { -#endif +#endif /* ! RC_INVOKED */ +#endif /* !__WCHAR_H_SOURCED__ */ + +#ifndef RC_INVOKED -_CRTIMP char* __cdecl __MINGW_NOTHROW setlocale (int, const char*); -_CRTIMP struct lconv* __cdecl __MINGW_NOTHROW localeconv (void); +_BEGIN_C_DECLS -#ifndef _WLOCALE_DEFINED /* also declared in wchar.h */ -# define __need_wchar_t -# include - _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wsetlocale(int, const wchar_t*); -# define _WLOCALE_DEFINED -#endif /* ndef _WLOCALE_DEFINED */ +#ifdef _LOCALE_H + /* The following pair of function prototypes are to be declared + * only when including in its own right, (i.e. when NOT + * sourced by )... + */ +_CRTIMP __cdecl __MINGW_NOTHROW char *setlocale (int, const char *); +_CRTIMP __cdecl __MINGW_NOTHROW struct lconv *localeconv (void); -#ifdef __cplusplus -} #endif + /* ...whereas, this must be declared in either case; (note that it + * not necessary to guard against a possible repeat declaration, as + * the compiler should accept this, without complaint, provided any + * prior declaration is consistent). + */ +_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wsetlocale (int, const wchar_t *); -#endif /* Not RC_INVOKED */ - -#endif /* Not _LOCALE_H_ */ +_END_C_DECLS +#endif /* ! RC_INVOKED */ +#endif /* !_LOCALE_H: $RCSfile$: end of file */ diff --git a/mingwrt/include/wchar.h b/mingwrt/include/wchar.h index 3b2f385..0828853 100644 --- a/mingwrt/include/wchar.h +++ b/mingwrt/include/wchar.h @@ -209,6 +209,14 @@ * _wctime() itself, as an in-line alias for its corresponding * replacement library function. * + * + * Also, from... + */ +#include +/* ...we obtain the declaration for: + * + * wchar_t *_wsetlocale (int, const wchar_t *); + * */ _BEGIN_C_DECLS @@ -639,11 +647,6 @@ _CRTALIAS int __cdecl __MINGW_NOTHROW _wstati64 (const wchar_t* _v1, struct _sta #define _WSTAT_DEFINED #endif /* ! _WSTAT_DEFIND */ -#ifndef _WLOCALE_DEFINED /* also declared in locale.h */ -_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wsetlocale (int, const wchar_t*); -#define _WLOCALE_DEFINED -#endif - #ifndef _WPROCESS_DEFINED /* Also declared in process.h; FIXME: to be factored out. */ -- 2.11.0