Changeset 20727


Ignore:
Timestamp:
Jul 31, 2003, 5:59:49 PM (22 years ago)
Author:
sandervl
Message:

export DBCS environment variable; updated special DBCS string functions to behave differently in SBCS environments

Location:
tags/trunk/src/kernel32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/kernel32/codepage.c

    r19486 r20727  
    1 /* $Id: codepage.c,v 1.2 2002-07-30 12:55:05 sandervl Exp $
     1/* $Id: codepage.c,v 1.3 2003-07-31 15:59:49 sandervl Exp $
    22 *
    33 * Code page functions
     
    2828#define DBG_LOCALLOG    DBG_codepage
    2929#include "dbglocal.h"
     30
     31BOOL fIsDBCSEnv = FALSE;
     32
    3033#endif
    3134
     
    102105#ifdef __WIN32OS2__
    103106    dprintf(("Language %s", getenv("LANG")));
     107
     108    if(ansi_cptable->info.char_size == 2) {
     109        fIsDBCSEnv = TRUE;
     110    }
    104111#endif
    105112}
  • TabularUnified tags/trunk/src/kernel32/heapstring.cpp

    r20712 r20727  
    1 /* $Id: heapstring.cpp,v 1.53 2003-07-16 18:07:01 sandervl Exp $ */
     1/* $Id: heapstring.cpp,v 1.54 2003-07-31 15:59:49 sandervl Exp $ */
    22/*
    33 * Project Odin Software License can be found in LICENSE.TXT
     
    486486    //-> overwrites stack
    487487    if(ret == length) {
     488#if 1
     489         lstrtrunc( astring, length );
     490#else
    488491         astring[length-1] = 0;
     492#endif
    489493    }
    490494    else astring[ret] = 0;
     
    619623        ulen = lstrlenW( ustring );
    620624
     625    if( !IsDBCSEnv() ) return ulen;
     626
    621627    ret = WideCharToMultiByte( CP_ACP, 0, ustring, ulen, 0, 0, 0, 0 );
    622628    if(ret == 0) {
     
    663669        alen = strlen( astring );
    664670
     671    if( !IsDBCSEnv() ) return alen;
     672
    665673    ret = MultiByteToWideChar( CP_ACP, 0, astring, alen, 0, 0 );
    666674    if(ret == 0) {
     
    670678
    671679    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
     705int 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;
    672725}
    673726
  • TabularUnified tags/trunk/src/kernel32/kernel32.def

    r20712 r20727  
    1 ; $Id: kernel32.def,v 1.155 2003-07-16 18:06:59 sandervl Exp $
     1; $Id: kernel32.def,v 1.156 2003-07-31 15:59:48 sandervl Exp $
    22
    33;Basis is Windows95 KERNEL32
     
    978978    lstrlenAtoW                = _lstrlenAtoW@8              @890
    979979    lstrlenWtoA                = _lstrlenWtoA@8              @891
     980    lstrtrunc                  = _lstrtrunc@8                @892
    980981
    981982    GetLongPathNameA           = _GetLongPathNameA@12        @900
     
    12121213    OSLibDosDevIOCtl                                              @2026 NONAME
    12131214
     1215    fIsDBCSEnv                                                    @2103 NONAME
     1216
    12141217    vsnprintfW                            @2030 NONAME
    12151218    snprintfW                             @2031 NONAME
  • TabularUnified tags/trunk/src/kernel32/kernel32dbg.def

    r20712 r20727  
    1 ; $Id: kernel32dbg.def,v 1.30 2003-07-16 18:07:01 sandervl Exp $
     1; $Id: kernel32dbg.def,v 1.31 2003-07-31 15:59:49 sandervl Exp $
    22
    33;Basis is Windows95 KERNEL32
     
    978978    lstrlenAtoW                = _DbglstrlenAtoW@8              @890
    979979    lstrlenWtoA                = _DbglstrlenWtoA@8              @891
     980    lstrtrunc                  = _Dbglstrtrunc@8                @892
    980981
    981982    GetLongPathNameA           = _DbgGetLongPathNameA@12        @900
     
    12121213    OSLibDosDevIOCtl                                              @2026 NONAME
    12131214
     1215    fIsDBCSEnv                                                    @2103 NONAME
     1216
    12141217    vsnprintfW                            @2030 NONAME
    12151218    snprintfW                             @2031 NONAME
Note: See TracChangeset for help on using the changeset viewer.