X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_slkset.c;h=ca66266855eaec884ecb1e094750405a81a53626;hp=47ef3823797d08e7ed74316601d70a20e3ae3680;hb=98d8891f42d8acac5c2ade39d163f386057a22e4;hpb=55ccd2b959766810cf7db8d1c4462f338ce0afc8 diff --git a/ncurses/base/lib_slkset.c b/ncurses/base/lib_slkset.c index 47ef3823..ca662668 100644 --- a/ncurses/base/lib_slkset.c +++ b/ncurses/base/lib_slkset.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -39,15 +39,17 @@ #include #if USE_WIDEC_SUPPORT +#if HAVE_WCTYPE_H #include #endif +#endif -MODULE_ID("$Id: lib_slkset.c,v 1.15 2005/04/16 17:47:34 tom Exp $") +MODULE_ID("$Id: lib_slkset.c,v 1.22 2011/10/22 16:58:26 tom Exp $") NCURSES_EXPORT(int) -slk_set(int i, const char *astr, int format) +NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format) { - SLK *slk = SP->_slk; + SLK *slk; int offset; int numchrs; int numcols; @@ -55,15 +57,20 @@ slk_set(int i, const char *astr, int format) const char *str = astr; const char *p; - T((T_CALLED("slk_set(%d, \"%s\", %d)"), i, str, format)); + T((T_CALLED("slk_set(%p, %d, \"%s\", %d)"), (void *) SP_PARM, i, str, format)); - if (slk == NULL || i < 1 || i > slk->labcnt || format < 0 || format > 2) + if (SP_PARM == 0 + || (slk = SP_PARM->_slk) == 0 + || i < 1 + || i > slk->labcnt + || format < 0 + || format > 2) returnCode(ERR); - if (str == NULL) + if (str == 0) str = ""; --i; /* Adjust numbering of labels */ - limit = MAX_SKEY_LEN(SP->slk_format); + limit = MAX_SKEY_LEN(SP_PARM->slk_format); while (isspace(UChar(*str))) str++; /* skip over leading spaces */ p = str; @@ -87,12 +94,12 @@ slk_set(int i, const char *astr, int format) numcols += wcwidth(wc); p += need; } - numchrs = (p - str); + numchrs = (int) (p - str); #else while (isprint(UChar(*p))) p++; /* The first non-print stops */ - numcols = (p - str); + numcols = (int) (p - str); if (numcols > limit) numcols = limit; numchrs = numcols; @@ -104,8 +111,8 @@ slk_set(int i, const char *astr, int format) slk->ent[i].ent_text[numchrs] = '\0'; if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text, - (unsigned) (limit + - numchrs + 1)) + (size_t) (limit + + numchrs + 1)) ) == 0) returnCode(ERR); @@ -124,19 +131,27 @@ slk_set(int i, const char *astr, int format) if (offset <= 0) offset = 0; else - memset(slk->ent[i].form_text, ' ', (unsigned) offset); + memset(slk->ent[i].form_text, ' ', (size_t) offset); memcpy(slk->ent[i].form_text + offset, slk->ent[i].ent_text, - (unsigned) numchrs); + (size_t) numchrs); if (offset < limit) { memset(slk->ent[i].form_text + offset + numchrs, ' ', - (unsigned) (limit - (offset + numcols))); + (size_t) (limit - (offset + numcols))); } slk->ent[i].form_text[numchrs - numcols + limit] = 0; slk->ent[i].dirty = TRUE; returnCode(OK); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +slk_set(int i, const char *astr, int format) +{ + return NCURSES_SP_NAME(slk_set) (CURRENT_SCREEN, i, astr, format); +} +#endif