View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000435 | LDMud 3.5 | Efuns | public | 2006-01-06 19:39 | 2019-09-24 08:24 |
Reporter | Assigned To | Gnomi | |||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Summary | 0000435: New efun: wcstombs() | ||||
Description | ==Edits to func_spec========================================================= string wcstombs(int|int*); ==Edits to efuns.c=========================================================== #include <wchar.h> #include <wctype.h> /*-------------------------------------------------------------------------*/ svalue_t * f_wcstombs (svalue_t * sp) /* EFUN wcstombs() * * string wcstombs(int wchar|int *wchars) * * Takes a wide character or array of wide characters and returns a multibyte string */ { char *mbdest; size_t len; wchar_t *wcdest, **wcdest_ptr; string_t *result; if(sp->type == T_POINTER) { vector_t *vec; svalue_t *svp; size_t i; vec=sp->u.vec; result=mstring_new_string(""); for(i = 0, svp = vec->item; ++i <= VEC_SIZE(vec); svp++) { if(svp->type == T_NUMBER) { if(svp->u.number==0) result=mstring_append_txt(result,"\0",1); else if(svp->u.number>0) { wcdest_ptr=xalloc(sizeof(wchar_t *)); wcdest=xalloc(sizeof(wchar_t)*2); memset(wcdest,0,sizeof(wchar_t)*2); *wcdest=(wchar_t)svp->u.number; *wcdest_ptr=wcdest; len=wcsrtombs(NULL,(const wchar_t **)wcdest_ptr,0,(mbstate_t *)NULL); if(len>0) { mbdest=xalloc(len+1); memset(mbdest,0,len+1); len=wcsrtombs(mbdest,(const wchar_t **)wcdest_ptr,len,(mbstate_t *)NULL); if(len>0) result=mstring_append_txt(result,mbdest,len); xfree(mbdest); } xfree(wcdest_ptr); xfree(wcdest); } } else if(svp->type == T_STRING) { result=mstring_append_txt(result,get_txt(svp->u.str),mstrsize(svp->u.str)); } } free_svalue(sp); put_string(sp,result); } else { result=mstring_new_string(""); if(sp->u.number==0) result=mstring_append_txt(result,"\0",1); else if(sp->u.number>0) { wcdest_ptr=xalloc(sizeof(wchar_t *)); wcdest=xalloc(sizeof(wchar_t)*2); memset(wcdest,0,sizeof(wchar_t)*2); *wcdest=(wchar_t)sp->u.number; *wcdest_ptr=wcdest; len=wcsrtombs(NULL,(const wchar_t **)wcdest_ptr,0,(mbstate_t *)NULL); if(len>0) { mbdest=xalloc(len+1); memset(mbdest,0,len+1); len=wcsrtombs(mbdest,(const wchar_t **)wcdest_ptr,len,(mbstate_t *)NULL); if(len>0) result=mstring_append_txt(result,mbdest,len); xfree(mbdest); } xfree(wcdest_ptr); xfree(wcdest); } free_svalue(sp); put_string(sp,result); } return sp; } /* f_wcstombs() */ | ||||
Tags | No tags attached. | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2006-01-06 19:39 |
|
New Issue | |
2006-01-06 19:48 |
|
Note Added: 0000466 | |
2008-07-02 01:15 | Gnomi | Project | LDMud => LDMud 3.5 |
2008-07-02 01:17 | Gnomi | Relationship added | child of 0000432 |
2019-09-24 08:24 | Gnomi | Assigned To | => Gnomi |
2019-09-24 08:24 | Gnomi | Status | new => closed |
2019-09-24 08:24 | Gnomi | Resolution | open => fixed |
2019-09-24 08:24 | Gnomi | Note Added: 0002480 |