1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-07-01 19:37:46 +02:00

small bug fix and formatting

This commit is contained in:
Jfreegman 2013-10-25 00:29:40 -04:00
parent b9b3487581
commit 3f7e60eaf4
3 changed files with 7 additions and 8 deletions

View File

@ -50,7 +50,7 @@ void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv
on_friendadded(m, friendnum);
}
memset(&pending_frnd_requests[num], 0, sizeof(TOX_CLIENT_ID_SIZE));
memset(&pending_frnd_requests[num], 0, TOX_CLIENT_ID_SIZE);
int i;

View File

@ -59,17 +59,17 @@ int string_is_empty(char *string)
/* convert wide characters to null terminated string */
uint8_t *wcs_to_char(wchar_t *string)
{
size_t len = 0;
uint8_t *ret = NULL;
size_t len = wcstombs(NULL, string, 0);
len = wcstombs(NULL, string, 0);
if (len != (size_t) -1) {
len++;
ret = malloc(len);
ret = malloc(len+1);
if (ret != NULL)
wcstombs(ret, string, len);
} else {
ret = malloc(2);
if (ret != NULL) {
ret[0] = ' ';
ret[1] = '\0';
@ -88,10 +88,9 @@ uint8_t *wcs_to_char(wchar_t *string)
/* convert a wide char to null terminated string */
char *wc_to_char(wchar_t ch)
{
int len = 0;
static char ret[MB_LEN_MAX + 1];
int len = wctomb(ret, ch);
len = wctomb(ret, ch);
if (len == -1) {
ret[0] = ' ';
ret[1] = '\0';

View File

@ -136,7 +136,7 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
/* Add printable characters to line */
else if (isprint(key)) {
if (prompt_buf_pos < (MAX_STR_SIZE-1)) {
if (prompt_buf_pos <= MAX_STR_SIZE) {
mvwaddch(self->window, y, x, key);
prompt_buf[prompt_buf_pos++] = key;
prompt_buf[prompt_buf_pos] = '\0';