1/* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2014-2021. 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 * Create: 2014-02-25 14 */ 15 16/* If some platforms don't have wchar.h, don't include it */ 17#if !(defined(SECUREC_VXWORKS_PLATFORM)) 18/* If there is no macro below, it will cause vs2010 compiling alarm */ 19#if defined(_MSC_VER) && (_MSC_VER >= 1400) 20#ifndef __STDC_WANT_SECURE_LIB__ 21/* The order of adjustment is to eliminate alarm of Duplicate Block */ 22#define __STDC_WANT_SECURE_LIB__ 0 23#endif 24#ifndef _CRTIMP_ALTERNATIVE 25#define _CRTIMP_ALTERNATIVE /* Comment microsoft *_s function */ 26#endif 27#endif 28#include <wchar.h> 29#endif 30 31/* fix redefined */ 32#undef SECUREC_ENABLE_WCHAR_FUNC 33/* Disable wchar func to clear vs warning */ 34#define SECUREC_ENABLE_WCHAR_FUNC 0 35#define SECUREC_FORMAT_OUTPUT_INPUT 1 36 37#ifndef SECUREC_FOR_WCHAR 38#define SECUREC_FOR_WCHAR 39#endif 40 41#include "secinput.h" 42 43#include "input.inl" 44 45SECUREC_INLINE unsigned int SecWcharHighBits(SecInt ch) 46{ 47 /* Convert int to unsigned int clear 571 */ 48 return ((unsigned int)(int)ch & (~0xffU)); 49} 50 51SECUREC_INLINE unsigned char SecWcharLowByte(SecInt ch) 52{ 53 /* Convert int to unsigned int clear 571 */ 54 return (unsigned char)((unsigned int)(int)ch & 0xffU); 55} 56 57SECUREC_INLINE int SecIsDigit(SecInt ch) 58{ 59 if (SecWcharHighBits(ch) != 0) { 60 return 0; /* Same as isdigit */ 61 } 62 return isdigit((int)SecWcharLowByte(ch)); 63} 64 65SECUREC_INLINE int SecIsXdigit(SecInt ch) 66{ 67 if (SecWcharHighBits(ch) != 0) { 68 return 0; /* Same as isxdigit */ 69 } 70 return isxdigit((int)SecWcharLowByte(ch)); 71} 72 73SECUREC_INLINE int SecIsSpace(SecInt ch) 74{ 75 return iswspace((wint_t)(int)(ch)); 76} 77 78