Changeset 10191 for trunk/src/kernel32/heapstring.cpp
- Timestamp:
- Jul 31, 2003, 5:59:49 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/heapstring.cpp
r10176 r10191 1 /* $Id: heapstring.cpp,v 1.5 3 2003-07-16 18:07:01sandervl Exp $ */1 /* $Id: heapstring.cpp,v 1.54 2003-07-31 15:59:49 sandervl Exp $ */ 2 2 /* 3 3 * Project Odin Software License can be found in LICENSE.TXT … … 486 486 //-> overwrites stack 487 487 if(ret == length) { 488 #if 1 489 lstrtrunc( astring, length ); 490 #else 488 491 astring[length-1] = 0; 492 #endif 489 493 } 490 494 else astring[ret] = 0; … … 619 623 ulen = lstrlenW( ustring ); 620 624 625 if( !IsDBCSEnv() ) return ulen; 626 621 627 ret = WideCharToMultiByte( CP_ACP, 0, ustring, ulen, 0, 0, 0, 0 ); 622 628 if(ret == 0) { … … 663 669 alen = strlen( astring ); 664 670 671 if( !IsDBCSEnv() ) return alen; 672 665 673 ret = MultiByteToWideChar( CP_ACP, 0, astring, alen, 0, 0 ); 666 674 if(ret == 0) { … … 670 678 671 679 return ret; 680 } 681 682 /***************************************************************************** 683 * NAME 684 * lstrtrunc 685 * 686 * PURPOSE 687 * truncate ansi string 688 * 689 * PARAMETERS 690 * max - max length of truncated string including null-terminator 691 * 692 * RESULT 693 * Success 694 * return the length of truncated string not including null-terminator 695 * 696 * Failure 697 * return 0. 698 * 699 * REMARK 700 * this function is not Win32 API but helper for convenient. 701 * 702 * AUTHOR : KO Myung-Hun 703 *****************************************************************************/ 704 705 int WIN32API lstrtrunc( LPSTR astring, int max ) 706 { 707 int i; 708 709 if( !astring || ( max < 1 )) 710 return 0; 711 712 astring[ max - 1 ] = 0; 713 714 if( !IsDBCSEnv() ) return max; 715 716 max = strlen( astring ); 717 for( i = 0; i < max; i++ ) 718 if( IsDBCSLeadByte( astring[ i ])) 719 i++; 720 721 if( i > max ) // broken DBCS lead byte ? 722 astring[ --max ] = 0; // then remove DBCS lead byte 723 724 return max; 672 725 } 673 726
Note:
See TracChangeset
for help on using the changeset viewer.