Стандарт языка Си С99 TC (1113411), страница 40
Текст из файла (страница 40)
If no conversion could beperformed, zero is returned. If the correct value is outside the range of representablevalues, INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX is returned (according to thereturn type and sign of the value, if any), and the value of the macro ERANGE is stored inerrno.Forward references: the wcstol, wcstoll, wcstoul, and wcstoull functions(7.24.4.1.2).§7.8.2.4Library201ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.9 Alternative spellings <iso646.h>1The header <iso646.h> defines the following eleven macros (on the left) that expandto the corresponding tokens (on the right):andand_eqbitandbitorcomplnotnot_eqoror_eqxorxor_eq202&&&=&|~!!=|||=^^=Library§7.9WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.10 Sizes of integer types <limits.h>1The header <limits.h> defines several macros that expand to various limits andparameters of the standard integer types.2The macros, their meanings, and the constraints (or restrictions) on their values are listedin 5.2.4.2.1.§7.10Library203ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.11 Localization <locale.h>1The header <locale.h> declares two functions, one type, and defines several macros.2The type isstruct lconvwhich contains members related to the formatting of numeric values.
The structure shallcontain at least the following members, in any order. The semantics of the members andtheir normal ranges are explained in 7.11.2.1. In the "C" locale, the members shall havethe values specified in the comments.charcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharchar204*decimal_point;*thousands_sep;*grouping;*mon_decimal_point;*mon_thousands_sep;*mon_grouping;*positive_sign;*negative_sign;*currency_symbol;frac_digits;p_cs_precedes;n_cs_precedes;p_sep_by_space;n_sep_by_space;p_sign_posn;n_sign_posn;*int_curr_symbol;int_frac_digits;int_p_cs_precedes;int_n_cs_precedes;int_p_sep_by_space;int_n_sep_by_space;int_p_sign_posn;int_n_sign_posn;////////////////////////////////////////////////Library"."""""""""""""""""CHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAX""CHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAXCHAR_MAX§7.11WG14/N12563Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3The macros defined are NULL (described in 7.17); andLC_ALLLC_COLLATELC_CTYPELC_MONETARYLC_NUMERICLC_TIMEwhich expand to integer constant expressions with distinct values, suitable for use as thefirst argument to the setlocale function.194) Additional macro definitions, beginningwith the characters LC_ and an uppercase letter,195) may also be specified by theimplementation.7.11.1 Locale control7.11.1.1 The setlocale functionSynopsis1#include <locale.h>char *setlocale(int category, const char *locale);Description2The setlocale function selects the appropriate portion of the program’s locale asspecified by the category and locale arguments.
The setlocale function may beused to change or query the program’s entire current locale or portions thereof. The valueLC_ALL for category names the program’s entire locale; the other values forcategory name only a portion of the program’s locale. LC_COLLATE affects thebehavior of the strcoll and strxfrm functions. LC_CTYPE affects the behavior ofthe character handling functions196) and the multibyte and wide character functions.LC_MONETARY affects the monetary formatting information returned by thelocaleconv function. LC_NUMERIC affects the decimal-point character for theformatted input/output functions and the string conversion functions, as well as thenonmonetary formatting information returned by the localeconv function.
LC_TIMEaffects the behavior of the strftime and wcsftime functions.3A value of "C" for locale specifies the minimal environment for C translation; a valueof "" for locale specifies the locale-specific native environment. Otherimplementation-defined strings may be passed as the second argument to setlocale.194) ISO/IEC 9945−2 specifies locale and charmap formats that may be used to specify locales for C.195) See ‘‘future library directions’’ (7.26.5).196) The only functions in 7.4 whose behavior is not affected by the current locale are isdigit andisxdigit.§7.11.1.1Library205ISO/IEC 9899:TC34Committee Draft — Septermber 7, 2007WG14/N1256At program startup, the equivalent ofsetlocale(LC_ALL, "C");is executed.5The implementation shall behave as if no library function calls the setlocale function.Returns6If a pointer to a string is given for locale and the selection can be honored, thesetlocale function returns a pointer to the string associated with the specifiedcategory for the new locale.
If the selection cannot be honored, the setlocalefunction returns a null pointer and the program’s locale is not changed.7A null pointer for locale causes the setlocale function to return a pointer to thestring associated with the category for the program’s current locale; the program’slocale is not changed.197)8The pointer to string returned by the setlocale function is such that a subsequent callwith that string value and its associated category will restore that part of the program’slocale.
The string pointed to shall not be modified by the program, but may beoverwritten by a subsequent call to the setlocale function.Forward references: formatted input/output functions (7.19.6), multibyte/widecharacter conversion functions (7.20.7), multibyte/wide string conversion functions(7.20.8), numeric conversion functions (7.20.1), the strcoll function (7.21.4.3), thestrftime function (7.23.3.5), the strxfrm function (7.21.4.5).7.11.2 Numeric formatting convention inquiry7.11.2.1 The localeconv functionSynopsis1#include <locale.h>struct lconv *localeconv(void);Description2The localeconv function sets the components of an object with type struct lconvwith values appropriate for the formatting of numeric quantities (monetary and otherwise)according to the rules of the current locale.3The members of the structure with type char * are pointers to strings, any of which(except decimal_point) can point to "", to indicate that the value is not available inthe current locale or is of zero length.
Apart from grouping and mon_grouping, the197) The implementation shall arrange to encode in a string the various categories due to a heterogeneouslocale when category has the value LC_ALL.206Library§7.11.2.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3strings shall start and end in the initial shift state. The members with type char arenonnegative numbers, any of which can be CHAR_MAX to indicate that the value is notavailable in the current locale. The members include the following:char *decimal_pointThe decimal-point character used to format nonmonetary quantities.char *thousands_sepThe character used to separate groups of digits before the decimal-pointcharacter in formatted nonmonetary quantities.char *groupingA string whose elements indicate the size of each group of digits informatted nonmonetary quantities.char *mon_decimal_pointThe decimal-point used to format monetary quantities.char *mon_thousands_sepThe separator for groups of digits before the decimal-point in formattedmonetary quantities.char *mon_groupingA string whose elements indicate the size of each group of digits informatted monetary quantities.char *positive_signThe string used to indicate a nonnegative-valued formatted monetaryquantity.char *negative_signThe string used to indicate a negative-valued formatted monetary quantity.char *currency_symbolThe local currency symbol applicable to the current locale.char frac_digitsThe number of fractional digits (those after the decimal-point) to bedisplayed in a locally formatted monetary quantity.char p_cs_precedesSet to 1 or 0 if the currency_symbol respectively precedes orsucceeds the value for a nonnegative locally formatted monetary quantity.char n_cs_precedesSet to 1 or 0 if the currency_symbol respectively precedes orsucceeds the value for a negative locally formatted monetary quantity.§7.11.2.1Library207ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256char p_sep_by_spaceSet to a value indicating the separation of the currency_symbol, thesign string, and the value for a nonnegative locally formatted monetaryquantity.char n_sep_by_spaceSet to a value indicating the separation of the currency_symbol, thesign string, and the value for a negative locally formatted monetaryquantity.char p_sign_posnSet to a value indicating the positioning of the positive_sign for anonnegative locally formatted monetary quantity.char n_sign_posnSet to a value indicating the positioning of the negative_sign for anegative locally formatted monetary quantity.char *int_curr_symbolThe international currency symbol applicable to the current locale.
Thefirst three characters contain the alphabetic international currency symbolin accordance with those specified in ISO 4217. The fourth character(immediately preceding the null character) is the character used to separatethe international currency symbol from the monetary quantity.char int_frac_digitsThe number of fractional digits (those after the decimal-point) to bedisplayed in an internationally formatted monetary quantity.char int_p_cs_precedesSet to 1 or 0 if the int_curr_symbol respectively precedes orsucceeds the value for a nonnegative internationally formatted monetaryquantity.char int_n_cs_precedesSet to 1 or 0 if the int_curr_symbol respectively precedes orsucceeds the value for a negative internationally formatted monetaryquantity.char int_p_sep_by_spaceSet to a value indicating the separation of the int_curr_symbol, thesign string, and the value for a nonnegative internationally formattedmonetary quantity.208Library§7.11.2.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3char int_n_sep_by_spaceSet to a value indicating the separation of the int_curr_symbol, thesign string, and the value for a negative internationally formatted monetaryquantity.char int_p_sign_posnSet to a value indicating the positioning of the positive_sign for anonnegative internationally formatted monetary quantity.char int_n_sign_posnSet to a value indicating the positioning of the negative_sign for anegative internationally formatted monetary quantity.45The elements of grouping and mon_grouping are interpreted according to thefollowing:CHAR_MAXNo further grouping is to be performed.0The previous element is to be repeatedly used for the remainder of thedigits.otherThe integer value is the number of digits that compose the current group.The next element is examined to determine the size of the next group ofdigits before the current group.The values of p_sep_by_space, n_sep_by_space, int_p_sep_by_space,and int_n_sep_by_space are interpreted according to the following:0No space separates the currency symbol and value.1If the currency symbol and sign string are adjacent, a space separates them from thevalue; otherwise, a space separates the currency symbol from the value.If the currency symbol and sign string are adjacent, a space separates them;otherwise, a space separates the sign string from the value.For int_p_sep_by_space and int_n_sep_by_space, the fourth character ofint_curr_symbol is used instead of a space.26The values of p_sign_posn, n_sign_posn, int_p_sign_posn,int_n_sign_posn are interpreted according to the following:0Parentheses surround the quantity and currency symbol.1The sign string precedes the quantity and currency symbol.2The sign string succeeds the quantity and currency symbol.3The sign string immediately precedes the currency symbol.4The sign string immediately succeeds the currency symbol.§7.11.2.1Libraryand209ISO/IEC 9899:TC37Committee Draft — Septermber 7, 2007WG14/N1256The implementation shall behave as if no library function calls the localeconvfunction.Returns8The localeconv function returns a pointer to the filled-in object.