diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-01-22 18:05:44 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-01-22 18:05:44 +0000 |
commit | 60f2d7affbed31873a1a7f9f69bd67c2582ccf6a (patch) | |
tree | d4f2c58bfa6e8412716c926750cff59e7485c99c /lib/libcurses/base | |
parent | 7fe795010750d2e2889d7085abeaa1ee0926c69b (diff) |
Missed changes in ncurses-5.2-20010114 commit
Diffstat (limited to 'lib/libcurses/base')
-rw-r--r-- | lib/libcurses/base/lib_slkset.c | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/lib/libcurses/base/lib_slkset.c b/lib/libcurses/base/lib_slkset.c index 9014957a5d6..a8360d60f49 100644 --- a/lib/libcurses/base/lib_slkset.c +++ b/lib/libcurses/base/lib_slkset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_slkset.c,v 1.2 2001/01/22 18:01:46 millert Exp $ */ +/* $OpenBSD: lib_slkset.c,v 1.3 2001/01/22 18:05:43 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,2000 Free Software Foundation, Inc. * @@ -40,57 +40,59 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$From: lib_slkset.c,v 1.3 1998/02/11 12:13:56 tom Exp $") +MODULE_ID("$From: lib_slkset.c,v 1.6 2000/12/10 02:43:27 tom Exp $") -int +NCURSES_EXPORT(int) slk_set(int i, const char *astr, int format) { -SLK *slk = SP->_slk; -size_t len; -const char *str = astr; -const char *p; + SLK *slk = SP->_slk; + size_t len; + const char *str = astr; + const char *p; - T((T_CALLED("slk_set(%d, \"%s\", %d)"), i, str, format)); + T((T_CALLED("slk_set(%d, \"%s\", %d)"), i, str, format)); - if (slk == NULL || i < 1 || i > slk->labcnt || format < 0 || format > 2) - returnCode(ERR); - if (str == NULL) - str = ""; + if (slk == NULL || i < 1 || i > slk->labcnt || format < 0 || format > 2) + returnCode(ERR); + if (str == NULL) + str = ""; - while (isspace(*str)) str++; /* skip over leading spaces */ - p = str; - while (isprint(*p)) p++; /* The first non-print stops */ + while (isspace(CharOf(*str))) + str++; /* skip over leading spaces */ + p = str; + while (isprint(CharOf(*p))) + p++; /* The first non-print stops */ - --i; /* Adjust numbering of labels */ + --i; /* Adjust numbering of labels */ - len = (size_t)(p - str); - if (len > (unsigned)slk->maxlen) - len = slk->maxlen; - if (len==0) - slk->ent[i].text[0] = 0; - else - (void) strlcpy(slk->ent[i].text, str, len+1); - memset(slk->ent[i].form_text,' ', (unsigned)slk->maxlen); - /* len = strlen(slk->ent[i].text); */ + len = (size_t) (p - str); + if (len > (unsigned) slk->maxlen) + len = slk->maxlen; + if (len == 0) + slk->ent[i].text[0] = 0; + else + (void) strlcpy(slk->ent[i].text, str, len+1); + memset(slk->ent[i].form_text, ' ', (unsigned) slk->maxlen); + /* len = strlen(slk->ent[i].text); */ - switch(format) { - case 0: /* left-justified */ - memcpy(slk->ent[i].form_text, - slk->ent[i].text, - len); - break; - case 1: /* centered */ - memcpy(slk->ent[i].form_text+(slk->maxlen - len)/2, - slk->ent[i].text, - len); - break; - case 2: /* right-justified */ - memcpy(slk->ent[i].form_text+ slk->maxlen - len, - slk->ent[i].text, - len); - break; - } - slk->ent[i].form_text[slk->maxlen] = 0; - slk->ent[i].dirty = TRUE; - returnCode(OK); + switch (format) { + case 0: /* left-justified */ + memcpy(slk->ent[i].form_text, + slk->ent[i].text, + len); + break; + case 1: /* centered */ + memcpy(slk->ent[i].form_text + (slk->maxlen - len) / 2, + slk->ent[i].text, + len); + break; + case 2: /* right-justified */ + memcpy(slk->ent[i].form_text + slk->maxlen - len, + slk->ent[i].text, + len); + break; + } + slk->ent[i].form_text[slk->maxlen] = 0; + slk->ent[i].dirty = TRUE; + returnCode(OK); } |