1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2014-2020. All rights reserved. 3 * Licensed under Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 8 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 9 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 * Description: By defining data type for UNICODE string and including "input.inl", 12 * this file generates real underlying function used by scanf family API. 13 * Author: lishunda 14 * Create: 2014-02-25 15 */ 16 17 /* If some platforms don't have wchar.h, dont't include it */ 18 #if !(defined(SECUREC_VXWORKS_PLATFORM)) 19 /* If there is no macro below, it will cause vs2010 compiling alarm */ 20 #if defined(_MSC_VER) && (_MSC_VER >= 1400) 21 #ifndef __STDC_WANT_SECURE_LIB__ 22 /* The order of adjustment is to eliminate alarm of Duplicate Block */ 23 #define __STDC_WANT_SECURE_LIB__ 0 24 #endif 25 #ifndef _CRTIMP_ALTERNATIVE 26 #define _CRTIMP_ALTERNATIVE /* Comment microsoft *_s function */ 27 #endif 28 #endif 29 #include <wchar.h> 30 #endif 31 32 /* fix redefined */ 33 #undef SECUREC_ENABLE_WCHAR_FUNC 34 /* Disable wchar func to clear vs warning */ 35 #define SECUREC_ENABLE_WCHAR_FUNC 0 36 #define SECUREC_FORMAT_OUTPUT_INPUT 1 37 38 #ifndef SECUREC_FOR_WCHAR 39 #define SECUREC_FOR_WCHAR 40 #endif 41 42 #include "secinput.h" 43 44 #include "input.inl" 45 SecWcharHighBits(SecInt ch)46SECUREC_INLINE unsigned int SecWcharHighBits(SecInt ch) 47 { 48 /* Convert int to unsigned int clear 571 */ 49 return ((unsigned int)(int)ch & (~0xffU)); 50 } 51 SecWcharLowByte(SecInt ch)52SECUREC_INLINE unsigned char SecWcharLowByte(SecInt ch) 53 { 54 /* Convert int to unsigned int clear 571 */ 55 return (unsigned char)((unsigned int)(int)ch & 0xffU); 56 } 57 SecIsDigit(SecInt ch)58SECUREC_INLINE int SecIsDigit(SecInt ch) 59 { 60 if (SecWcharHighBits(ch) != 0) { 61 return 0; /* Same as isdigit */ 62 } 63 return isdigit((int)SecWcharLowByte(ch)); 64 } 65 SecIsXdigit(SecInt ch)66SECUREC_INLINE int SecIsXdigit(SecInt ch) 67 { 68 if (SecWcharHighBits(ch) != 0) { 69 return 0; /* Same as isxdigit */ 70 } 71 return isxdigit((int)SecWcharLowByte(ch)); 72 } 73 SecIsSpace(SecInt ch)74SECUREC_INLINE int SecIsSpace(SecInt ch) 75 { 76 return iswspace((wint_t)(int)(ch)); 77 } 78 79