Reactos
at master 76 lines 2.0 kB view raw
1/*** 2*mbsinc.c - Move MBCS string pointer ahead one charcter. 3* 4* Copyright (c) Microsoft Corporation. All rights reserved. 5* 6*Purpose: 7* Move MBCS string pointer ahead one character. 8* 9*******************************************************************************/ 10#ifndef _MBCS 11 #error This file should only be compiled with _MBCS defined 12#endif 13 14#include <corecrt_internal.h> 15#include <corecrt_internal_mbstring.h> 16#include <stddef.h> 17 18#pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018 19 20/*** 21*_mbsinc - Move MBCS string pointer ahead one charcter. 22* 23*Purpose: 24* Move the supplied string pointer ahead by one 25* character. MBCS characters are handled correctly. 26* 27*Entry: 28* const unsigned char *current = current char pointer (legal MBCS boundary) 29* 30*Exit: 31* Returns pointer after moving it. 32* 33*Exceptions: 34* Input parameters are validated. Refer to the validation section of the function. 35* 36*******************************************************************************/ 37 38extern "C" unsigned char * __cdecl _mbsinc_l( 39 const unsigned char *current, 40 _locale_t plocinfo 41 ) 42{ 43 if ( (_ismbblead_l)(*(current++),plocinfo)) 44 { 45 /* don't move forward two if we get leadbyte, EOS 46 also don't assert here as we are too low level 47 */ 48 if(*current!='\0') 49 { 50 current++; 51 } 52 } 53 54 return (unsigned char *)current; 55} 56 57extern "C" unsigned char * (__cdecl _mbsinc)( 58 const unsigned char *current 59 ) 60{ 61 /* validation section */ 62 _VALIDATE_RETURN(current != nullptr, EINVAL, nullptr); 63 64 if ( _ismbblead(*(current++))) 65 { 66 /* don't move forward two if we get leadbyte, EOS 67 also don't assert here as we are too low level 68 */ 69 if(*current!='\0') 70 { 71 current++; 72 } 73 } 74 75 return (unsigned char *)current; 76}