Changeset 37 for trunk/Lucide/SOURCE


Ignore:
Timestamp:
Jun 3, 2006, 9:53:58 AM (15 years ago)
Author:
Eugene Romanenko
Message:

fixed crash on copying large block of text to clipboard

Location:
trunk/Lucide/SOURCE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/gui/clipbrd.cpp

    r35 r37  
    3939#include <string.h>
    4040#include <malloc.h>
     41#include <stdio.h>
    4142#include "cpconv.h"
    4243
     
    7475
    7576        // place to clipboard as unicode
    76         if ( DosAllocSharedMem( &memuni, NULL, olen ,
    77                                 PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE ) == 0 )
     77        if ( DosAllocSharedMem( &memuni, NULL, olen, fALLOCSHR ) == 0 )
    7878        {
    7979            memset( memuni, 0, olen );
    8080            void *tmem = memuni;
    8181
    82             //cpconv c( 1208, 1200 );
    8382            tsav = text;
    84             //c.conv( &text, &len, (char **)&memuni, &olen );
    8583            cnvUTF8ToUni( &text, &len, (char **)&memuni, &olen );
    8684            text = tsav;
     
    9593
    9694        // place to clipboard as current codepage
    97         if ( DosAllocSharedMem( &memcp, NULL, olen ,
    98                                 PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE ) == 0 )
     95        if ( DosAllocSharedMem( &memcp, NULL, olen, fALLOCSHR ) == 0 )
    9996        {
    10097            memset( memcp, 0, olen );
    10198            void *tmem = memcp;
    10299
    103             //cpconv c( 1208 );
    104100            tsav = text;
    105             //c.conv( &text, &len, (char **)&memcp, &olen );
    106101            cnvUTF8ToSys( &text, &len, (char **)&memcp, &olen );
    107102                        text = tsav;
  • trunk/Lucide/SOURCE/plugins/ludoc/cpconv.cpp

    r35 r37  
    141141}
    142142
     143// convert one char
    143144int cpconv::conv( int chfrom )
    144145{
     
    181182
    182183    sl =  *in_left;
    183     ucs = (UniChar *) alloca(sl * sizeof(UniChar));
     184    ucs = new UniChar[ sl ];
    184185    orig_ucs = ucs;
    185186
    186     rc = UniUconvToUcs(objtoucs, (void **)in, in_left, &ucs, &sl, &retval);
    187     if (rc) {
    188         goto error;
    189     }
     187    rc = UniUconvToUcs( objtoucs, (void **)in, in_left, &ucs, &sl, &retval );
     188    if ( rc != 0 ) {
     189        delete ucs;
     190        err = 1;
     191        return -1;
     192    }
     193
    190194    sl = ucs - orig_ucs;
    191195    ucs = orig_ucs;
    192     rc = UniUconvFromUcs(objfromucs, &ucs, &sl, (void **)out, out_left, &nonid);
    193     if (rc) {
    194         goto error;
    195     }
     196    rc = UniUconvFromUcs( objfromucs, &ucs, &sl, (void **)out, out_left, &nonid );
     197    delete ucs;
     198
     199    if ( rc != 0 ) {
     200        err = 1;
     201        return -1;
     202    }
     203
    196204    retval += nonid;
    197205    return 0;
    198 
    199 error:
    200     err = 1;
    201     return -1;
    202206}
    203207
     
    224228
    225229
     230// Converts special non-ascii chars to suitable ascii chars
    226231static void convSpchars( UniChar *uni )
    227232{
    228233    while ( *uni )
    229234    {
    230 //printf( ":%x:", *uni );
    231235        switch ( *uni )
    232236        {
     
    248252        *uni++;
    249253    }
    250 //printf( "\n" );
    251254}
    252255
     
    317320    unsigned in_len = strlen( testutf8 );
    318321    unsigned out_len = sizeof( buf );
    319    
     322
    320323    cnvUTF8ToUCS4( &testutf8, &in_len, &buf1, &out_len );
    321    
     324
    322325    for ( int i = 0; i<100; i++ )
    323326    {
Note: See TracChangeset for help on using the changeset viewer.