Ignore:
Timestamp:
Nov 29, 1999, 12:23:46 AM (26 years ago)
Author:
bird
Message:

Changed some parameters to const.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/unicode.cpp

    r1838 r1871  
    1 /* $Id: unicode.cpp,v 1.15 1999-11-25 19:19:57 sandervl Exp $ */
     1/* $Id: unicode.cpp,v 1.16 1999-11-28 23:23:46 bird Exp $ */
    22
    33/*
     
    7272 */
    7373INT WINAPI MultiByteToWideChar(UINT page, DWORD flags,
    74                                  LPCSTR src, INT srclen,
     74                     LPCSTR src, INT srclen,
    7575                                 LPWSTR dst, INT dstlen)
    7676{
     
    7878
    7979    if (srclen == -1)
    80         srclen = lstrlenA(src)+1;
     80    srclen = lstrlenA(src)+1;
    8181    if (!dstlen || !dst)
    82         return srclen;
     82    return srclen;
    8383
    8484    ret = srclen;
    8585    while (srclen && dstlen) {
    86         *dst = (WCHAR)(unsigned char)*src;
    87         dst++;    src++;
    88         dstlen--; srclen--;
     86    *dst = (WCHAR)(unsigned char)*src;
     87    dst++;    src++;
     88    dstlen--; srclen--;
    8989    }
    9090    if (!dstlen && srclen) {
    91         SetLastError(ERROR_INSUFFICIENT_BUFFER);
    92         return 0;
     91    SetLastError(ERROR_INSUFFICIENT_BUFFER);
     92    return 0;
    9393    }
    9494    return ret;
     
    106106 *   dstlen [in]  Length of destination buffer
    107107 *   defchar [in] Default character to use for conversion if no exact
    108  *                  conversion can be made
     108 *          conversion can be made
    109109 *   used [out]   Set if default character was used in the conversion
    110110 *
     
    128128 */
    129129INT WIN32API WideCharToMultiByte(UINT page, DWORD flags, LPCWSTR src,
    130                                 INT srclen,LPSTR dst, INT dstlen,
    131                                 LPCSTR defchar, BOOL *used)
     130                INT srclen,LPSTR dst, INT dstlen,
     131                LPCSTR defchar, BOOL *used)
    132132{
    133133    int count = 0;
     
    137137
    138138    if ((!src) || ((!dst) && (!dont_copy)) )
    139     {   SetLastError(ERROR_INVALID_PARAMETER);
    140         return 0;
    141     }
    142    
     139    {   SetLastError(ERROR_INVALID_PARAMETER);
     140    return 0;
     141    }
     142
    143143    if (page!=GetACP() && page!=CP_OEMCP && page!=CP_ACP)
    144         dprintf(("WideCharToMultiByte, Conversion in CP %d not supported\n",page));
     144    dprintf(("WideCharToMultiByte, Conversion in CP %d not supported\n",page));
    145145#if 0
    146146    if (flags)
    147         dprintf(("WideCharToMultiByte, flags %lx not supported\n",flags));
     147    dprintf(("WideCharToMultiByte, flags %lx not supported\n",flags));
    148148#endif
    149149    if(used)
    150         *used=0;
     150    *used=0;
    151151    if (srclen == -1)
    152152      {
    153         srclen = lstrlenW(src)+1;
    154         care_for_eos=1;
     153    srclen = lstrlenW(src)+1;
     154    care_for_eos=1;
    155155      }
    156156    while(srclen && (dont_copy || dstlen))
    157157    {
    158         if(!dont_copy){
    159             if(*src<256)
    160                 *dst = *src;
    161             else
    162             {
    163                 /* ??? The WC_DEFAULTCHAR flag only gets used in
    164                 * combination with the WC_COMPOSITECHECK flag or at
    165                 * least this is what it seems from using the function
    166                 * on NT4.0 in combination with reading the documentation.
    167                 */
    168                 *dst = defchar ? *defchar : '?';
    169                 if(used)*used=1;
    170             }
    171             dstlen--;
    172             dst++;
    173         }
    174         count++;
    175         srclen--;
    176         if((!*src) && care_for_eos) {
    177             eos = 1;
    178             break;
    179         }
    180         src++;
     158    if(!dont_copy){
     159        if(*src<256)
     160        *dst = *src;
     161        else
     162        {
     163        /* ??? The WC_DEFAULTCHAR flag only gets used in
     164        * combination with the WC_COMPOSITECHECK flag or at
     165        * least this is what it seems from using the function
     166        * on NT4.0 in combination with reading the documentation.
     167        */
     168        *dst = defchar ? *defchar : '?';
     169        if(used)*used=1;
     170        }
     171        dstlen--;
     172        dst++;
     173    }
     174    count++;
     175    srclen--;
     176    if((!*src) && care_for_eos) {
     177        eos = 1;
     178        break;
     179    }
     180    src++;
    181181    }
    182182    if (dont_copy)
    183         return count;
     183    return count;
    184184
    185185    if (!eos && srclen > 0) {
    186         SetLastError(ERROR_INSUFFICIENT_BUFFER);
    187         return 0;
     186    SetLastError(ERROR_INSUFFICIENT_BUFFER);
     187    return 0;
    188188    }
    189189    return count;
     
    204204// returns string length
    205205//******************************************************************************
    206 int WIN32API UnicodeToAsciiN(WCHAR *ustring, char *astring, int unilen)
     206int WIN32API UnicodeToAsciiN(LPCWSTR ustring, char *astring, int unilen)
    207207{
    208208  int i;
     
    264264// returns length of ascii string
    265265//******************************************************************************
    266 int WIN32API UnicodeToAscii(WCHAR *ustring, char *astring)
     266int WIN32API UnicodeToAscii(LPCWSTR ustring, char *astring)
    267267{
    268268  /* forward to function with len parameter */
     
    273273// returns pointer to ascii string
    274274//******************************************************************************
    275 char * WIN32API UnicodeToAsciiString(WCHAR *ustring)
     275char * WIN32API UnicodeToAsciiString(LPCWSTR ustring)
    276276{
    277277  char *astring;
     
    285285//******************************************************************************
    286286//******************************************************************************
    287 char * WIN32API UnicodeToAsciiStringN(WCHAR *ustring, ULONG length)
     287char * WIN32API UnicodeToAsciiStringN(LPCWSTR ustring, ULONG length)
    288288{
    289289  char *astring;
     
    299299// returns pointer to unicode string
    300300//******************************************************************************
    301 WCHAR * WIN32API AsciiToUnicodeString(char *astring)
     301WCHAR * WIN32API AsciiToUnicodeString(const char *astring)
    302302{
    303303  WCHAR *ustring;
     
    322322// asciilen: max length of unicode buffer (including end 0)
    323323//******************************************************************************
    324 void WIN32API AsciiToUnicodeN(char *ascii, WCHAR *unicode, int asciilen)
     324void WIN32API AsciiToUnicodeN(const char *ascii, WCHAR *unicode, int asciilen)
    325325{
    326326  int rc;
     
    329329  size_t in_bytes_left;
    330330  size_t num_subs;
    331   UniChar * out_buf;
    332   char    * in_buf;
     331  UniChar     * out_buf;
     332  const char  * in_buf;
    333333
    334334
     
    387387// Copies the full string from ascii to unicode
    388388//******************************************************************************
    389 void WIN32API AsciiToUnicode(char *ascii, WCHAR *unicode)
     389void WIN32API AsciiToUnicode(const char *ascii, WCHAR *unicode)
    390390{
    391391  /* achimha for security, strlen might trap if garbage in */
Note: See TracChangeset for help on using the changeset viewer.