Changeset 697


Ignore:
Timestamp:
Mar 29, 2009, 2:45:04 PM (15 years ago)
Author:
イグトランス (egtra)
Message:

string.sbpの変換ルーチンで、ヌル終端無し文字列から有り文字列への変換でヌルを付け忘れるバグのため、常にヌル終端を付加する前の方式に戻す。GetWCStr, GetMBStr, GetTCStrを削除。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/system/string.sbp

    r671 r697  
    2323End Function
    2424
    25 
    2625Function MakeStr(psz As PSTR) As String
    2726    Return New String(psz)
     
    3837    Function GetWCStr(mbsSrc As PSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T
    3938        Dim lenWCS = MultiByteToWideChar(CP_ACP, 0, mbsSrc, (len As DWord) As Long, 0, 0)
    40         wcsDst = _System_AllocForConvertedString(SizeOf (WCHAR) * lenWCS) As PWSTR
     39        wcsDst = _System_AllocForConvertedString(SizeOf (WCHAR) * (lenWCS + 1)) As PWSTR
    4140        GetWCStr = MultiByteToWideChar(CP_ACP, 0, mbsSrc, (len As DWord) As Long, wcsDst, lenWCS)
     41        wcsDst[lenWCS] = 0
    4242    End Function
    4343
     
    4949    Function GetMBStr(wcsSrc As PWSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T
    5050        Dim lenMBS = WideCharToMultiByte(CP_ACP, 0, wcsSrc, (len As DWord) As Long, 0, 0, 0, 0)
    51         mbsDst = _System_AllocForConvertedString(SizeOf (CHAR) * lenMBS) As PSTR
     51        mbsDst = _System_AllocForConvertedString(SizeOf (CHAR) * (lenMBS + 1)) As PSTR
    5252        GetMBStr = WideCharToMultiByte(CP_ACP, 0, wcsSrc, (len As DWord) As Long, mbsDst, lenMBS, 0, 0) As SIZE_T
     53        mbsDst[lenMBS] = 0
    5354    End Function
    5455
     
    8081変換の組み合わせは、
    8182入力引数: wcsz, wcs + len, mbsz, mbs + len, str
    82 出力関数: wcs(z)出力GetStr, mbs(z)出力GetStr,
    83           GetWCStr, GetMBStr, GetTCStr,
    84           ToWCStr, ToMBStr, ToTCStr,
    85 で、5 * 8 = 40通り。
     83出力関数: wcs(z)出力GetStr, mbs(z)出力GetStr, ToWCStr, ToMBStr, ToTCStr,
     84で、5 * 5 = 25通り。
    8685*/
    8786
     
    9190        Return 0
    9291    Else
    93         Return Detail.GetWCStr(mbszSrc, (lstrlenA(mbszSrc) + 1) As SIZE_T, wcsDst)
     92        Return Detail.GetWCStr(mbszSrc, lstrlenA(mbszSrc) As SIZE_T, wcsDst)
    9493    End If
    9594End Function
     
    129128        Return 0
    130129    Else
    131         Return Detail.GetMBStr(wcszSrc, (lstrlenW(wcszSrc) + 1) As SIZE_T, mbsDst)
     130        Return Detail.GetMBStr(wcszSrc, lstrlenW(wcszSrc) As SIZE_T, mbsDst)
    132131    End If
    133132End Function
     
    178177        Return Detail.GetMBStr(strSrc.StrPtr, strSrc.Length As SIZE_T, mbsDst)
    179178    End If
    180 End Function
    181 
    182 Function GetWCStr(mbszSrc As PSTR, ByRef wcsDst As PWSTR) As SIZE_T
    183     Return GetStr(mbszSrc, wcsDst)
    184 End Function
    185 
    186 Function GetWCStr(mbsSrc As PSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T
    187     Return GetStr(mbsSrc, len, wcsDst)
    188 End Function
    189 
    190 Function GetWCStr(wcszSrc As PWSTR, ByRef wcsDst As PWSTR) As SIZE_T
    191     Return GetStr(wcszSrc, wcsDst)
    192 End Function
    193 
    194 Function GetWCStr(wcsSrc As PWSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T
    195     Return GetStr(wcsSrc, len, wcsDst)
    196 End Function
    197 
    198 Function GetWCStr(strSrc As String, ByRef wcsDst As PWSTR) As SIZE_T
    199     Return GetStr(strSrc.StrPtr, strSrc.Length As SIZE_T, wcsDst)
    200 End Function
    201 
    202 Function GetMBStr(mbszSrc As PWSTR, ByRef mbsDst As PSTR) As SIZE_T
    203     Return GetStr(mbszSrc, mbsDst)
    204 End Function
    205 
    206 Function GetMBStr(wcsSrc As PWSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T
    207     Return GetStr(wcsSrc, len, mbsDst)
    208 End Function
    209 
    210 Function GetMBStr(mbszSrc As PSTR, ByRef mbsDst As PSTR) As SIZE_T
    211     Return GetStr(mbszSrc, mbsDst)
    212 End Function
    213 
    214 Function GetMBStr(mbsSrc As PSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T
    215     Return GetStr(mbsSrc, len, mbsDst)
    216 End Function
    217 
    218 Function GetMBStr(strSrc As String, ByRef mbsDst As PSTR) As SIZE_T
    219     Return GetStr(strSrc.StrPtr, strSrc.Length As SIZE_T, mbsDst)
    220 End Function
    221 
    222 Function GetTCStr(mbszSrc As PSTR, ByRef tcsDst As PCTSTR) As SIZE_T
    223     Return GetStr(mbszSrc, tcsDst)
    224 End Function
    225 
    226 Function GetTCStr(mbsSrc As PSTR, len As SIZE_T, ByRef tcsDst As PCTSTR) As SIZE_T
    227     Return GetStr(mbsSrc, len, tcsDst)
    228 End Function
    229 
    230 Function GetTCStr(wcszSrc As PWSTR, ByRef tcsDst As PCTSTR) As SIZE_T
    231     Return GetStr(wcszSrc, tcsDst)
    232 End Function
    233 
    234 Function GetTCStr(wcsSrc As PWSTR, len As SIZE_T, ByRef tcsDst As PCTSTR) As SIZE_T
    235     Return GetStr(wcsSrc, len, tcsDst)
    236 End Function
    237 
    238 Function GetTCStr(strSrc As String, ByRef tcsDst As PCTSTR) As SIZE_T
    239     Return GetStr(strSrc.StrPtr, strSrc.Length As SIZE_T, tcsDst)
    240179End Function
    241180
Note: See TracChangeset for help on using the changeset viewer.