View Issue Details

IDProjectCategoryView StatusLast Update
0000439LDMud 3.5Efunspublic2019-09-24 08:22
Reporteriago3Assigned ToGnomi  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Summary0000439: Modified efun: lower_case()
Description==Edits to efuns.c===========================================================

#include <wchar.h>
#include <wctype.h>

    size_t orig_len;
    wchar_t *wcdest, *current_wchar, **wcdest_ptr;
    char *orig_txt, *tmp_txt, *mbdest, **orig_txt_ptr;
    size_t len, wcdest_len, conv_len, i;
    string_t *result;
    orig_len=mstrsize(sp->u.str);
    orig_txt=get_txt(sp->u.str);
    orig_txt_ptr=xalloc(sizeof(char *));
    *orig_txt_ptr=orig_txt;
    wcdest=xalloc((orig_len+1)*sizeof(wchar_t));
    wcdest_ptr=xalloc(sizeof(wchar_t *));
    *wcdest_ptr=wcdest;
    memset(wcdest,0,(orig_len+1)*sizeof(wchar_t));
    len=0;
    wcdest_len=0;
    tmp_txt=orig_txt;
    while(len<orig_len) {
        wcdest_len+=mbsrtowcs(wcdest+wcdest_len, (const char **)orig_txt_ptr, orig_len-len, (mbstate_t *)NULL);
        len+=strlen(tmp_txt);
        if(len<orig_len) {
            len++;
            wcdest_len++;
            tmp_txt=orig_txt+len;
            *orig_txt_ptr=tmp_txt;
        }
    }
    current_wchar=wcdest;
    for(i=0;i<wcdest_len;i++) {
        if(iswupper(*current_wchar)) {
            *(current_wchar)=towlower(*current_wchar);
        }
        current_wchar++;
    }
    conv_len=0;
    result=mstring_new_string("");
    current_wchar=wcdest;
    while(conv_len<wcdest_len) {
        len=wcsrtombs(NULL,(const wchar_t **)wcdest_ptr,0,(mbstate_t *)NULL);
        mbdest=xalloc(len+1);
        memset(mbdest,0,len+1);
        wcsrtombs(mbdest,(const wchar_t **)wcdest_ptr,len,(mbstate_t *)NULL);
        conv_len+=wcslen(current_wchar);
        result=mstring_append_txt(result,mbdest,len);
        if(conv_len<wcdest_len) {
            conv_len++;
            current_wchar=wcdest+conv_len;
            *wcdest_ptr=current_wchar;
            result=mstring_append_txt(result,"\0",1);
        }
        xfree(mbdest);
    }
    xfree(wcdest);
    xfree(orig_txt_ptr);
    xfree(wcdest_ptr);
    free_string_svalue(sp);
    put_string(sp, result);
    return sp;
TagsNo tags attached.

Relationships

child of 0000432 resolvedGnomi LDMud 3.6 Add string efuns with multibyte character support 

Activities

iago3

2006-01-06 19:49

reporter   ~0000470

Explainer: This bug is desinged to add support for multibyte character sets to string efuns, as designed in bug#432

Issue History

Date Modified Username Field Change
2006-01-06 19:45 iago3 New Issue
2006-01-06 19:49 iago3 Note Added: 0000470
2008-07-02 01:15 Gnomi Project LDMud => LDMud 3.5
2008-07-02 01:16 Gnomi Relationship added child of 0000432
2019-09-24 08:22 Gnomi Assigned To => Gnomi
2019-09-24 08:22 Gnomi Status new => closed
2019-09-24 08:22 Gnomi Resolution open => fixed