On Wed, Nov 28, 2007 at 06:24:51PM +0100, Remko van der Vossen wrote:
> On Wed, Nov 28, 2007 at 11:26:39AM -0500, John E. Davis wrote:
> >
> > Does a C version of you code show the same problems?
>
> I will strip the c++ from my test program and see if that yields the same
> results and let you know about it.
I stripped the c++ from the test program I have and it seems a c program
exhibits exactly the same problem, the c code is enclosed below.
Regards,
Remko van der Vossen
---
#include <slang.h>
#include <signal.h>
#include <malloc.h>
#define MAXSTRLEN 1000
#define MAXNSTR 1000
int main() {
int not_done = 1;
//SLutf8_enable(-1);
//SLsmg_utf8_enable(1);
SLtt_get_terminfo();
SLkp_init();
SLang_init_tty(-1, 0, 0);
SLang_set_abort_signal(0);
SLtt_get_screen_size();
SLsmg_init_smg();
SLtt_Use_Ansi_Colors = 1;
SLtt_set_color(1, 0, "black", "white");
SLtt_set_cursor_visibility(-1);
char* strings = (char*)malloc(MAXSTRLEN * MAXNSTR);
if (strings == NULL)
return 1;
char* cursor = strings;
size_t nstrings = 0;
while (rand()%40 && nstrings < MAXNSTR) {
char* p = cursor;
while (rand()%50 && p - cursor - 1 < MAXSTRLEN) {
*p++ = 0x20 + rand()%0x60;
}
p = 0;
cursor += MAXSTRLEN;
}
cursor = strings;
while (not_done) {
char* i = cursor;
size_t j;
for (j = SLtt_Screen_Rows/2; i != strings && 0 < j; --j)
i -= MAXSTRLEN;
size_t r;
for (r = 0; r < SLtt_Screen_Rows; ++r) {
SLsmg_gotorc(r, 0);
if (i == strings + MAXSTRLEN * MAXNSTR) {
SLsmg_set_color(0);
SLsmg_write_nstring(0, SLtt_Screen_Cols);
continue;
}
SLsmg_set_color(i == cursor ? 1 : 0);
//XSLANG const_cast because of s-lang const api issue
SLsmg_write_nstring(i, SLtt_Screen_Cols);
i += MAXSTRLEN;
}
SLsmg_refresh();
while (SLang_input_pending(1)) {
switch(SLkp_getkey()) {
case 'q':
not_done = 0;
break;
case 'j':
if ((cursor += MAXSTRLEN) == strings + MAXSTRLEN * MAXNSTR)
cursor -= MAXSTRLEN;
break;
case 'k':
if (cursor != strings)
cursor -= MAXSTRLEN;
break;
}
}
}
SLsmg_reset_smg();
SLang_reset_tty();
free(strings);
return 0;
}
Attachment:
smime.p7s
Description: S/MIME cryptographic signature