Mercurial > hg > nnchat
comparison main.c @ 509:942eea564b15 dev-1_1_0
Fix backbuffer offset manipulation, prevents a segfault.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 03 Jun 2012 06:32:55 +0300 |
parents | 12939e665e49 |
children | 291e3caa91a0 |
comparison
equal
deleted
inserted
replaced
508:f71c59cbc5a7 | 509:942eea564b15 |
---|---|
1074 { | 1074 { |
1075 BOOL result; | 1075 BOOL result; |
1076 char *tmp; | 1076 char *tmp; |
1077 | 1077 |
1078 // Trim right side | 1078 // Trim right side |
1079 if (bufLen > 0) buf[--bufLen] = 0; | |
1080 while (bufLen > 0 && th_isspace(buf[bufLen - 1])) | 1079 while (bufLen > 0 && th_isspace(buf[bufLen - 1])) |
1081 buf[--bufLen] = 0; | 1080 buf[--bufLen] = 0; |
1082 | 1081 |
1083 if (buf[0] == 0) | 1082 if (buf[0] == 0) |
1084 return 1; | 1083 return 1; |
1770 | 1769 |
1771 histPos = 0; | 1770 histPos = 0; |
1772 histBuf[1] = nn_editbuf_copy(editBuf); | 1771 histBuf[1] = nn_editbuf_copy(editBuf); |
1773 if (histMax < SET_MAX_HISTORY) histMax++; | 1772 if (histMax < SET_MAX_HISTORY) histMax++; |
1774 | 1773 |
1775 nn_editbuf_insert(editBuf, editBuf->len, 0); | |
1776 result = nn_handle_input(conn, editBuf->data, editBuf->len); | 1774 result = nn_handle_input(conn, editBuf->data, editBuf->len); |
1777 | 1775 |
1778 nn_editbuf_clear(editBuf); | 1776 nn_editbuf_clear(editBuf); |
1779 | 1777 |
1780 if (result < 0) | 1778 if (result < 0) |
1893 case KEY_NPAGE: | 1891 case KEY_NPAGE: |
1894 case KEY_PPAGE: | 1892 case KEY_PPAGE: |
1895 // Page Up / Page Down | 1893 // Page Up / Page Down |
1896 if (currWin != NULL) | 1894 if (currWin != NULL) |
1897 { | 1895 { |
1898 int oldPos = currWin->pos; | 1896 int oldPos = currWin->pos, page = scrHeight - 4; |
1899 | 1897 |
1900 currWin->pos += (c == KEY_NPAGE) ? -10 : +10; | 1898 currWin->pos += (c == KEY_NPAGE) ? - page : page; |
1901 | 1899 |
1900 if (currWin->pos >= currWin->data->n - page) | |
1901 currWin->pos = currWin->data->n - page; | |
1902 if (currWin->pos < 0) | 1902 if (currWin->pos < 0) |
1903 currWin->pos = 0; | 1903 currWin->pos = 0; |
1904 else if (currWin->pos >= currWin->data->n - 10) | |
1905 currWin->pos = currWin->data->n - 10; | |
1906 | 1904 |
1907 if (oldPos != currWin->pos) | 1905 if (oldPos != currWin->pos) |
1908 update = TRUE; | 1906 update = TRUE; |
1909 } | 1907 } |
1910 break; | 1908 break; |