From: <ny...@us...> - 2006-12-24 01:56:05
|
Revision: 193 http://svn.sourceforge.net/pmplib/?rev=193&view=rev Author: nyaochi Date: 2006-12-23 17:56:05 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Make the source compatible with Win32 (MSVC): - Win32 does not have TTY support. Introduced HAVE_TTY but I haven't changed configure.in yet. - MSVC does not support array definitions with variable length: char hoge[strlen(str)+1]; must be char *hoge = alloca(sizeof(*str) + (strlen(str)+1)); Modified Paths: -------------- trunk/pmplib/frontend/easypmp/cui/util.c Modified: trunk/pmplib/frontend/easypmp/cui/util.c =================================================================== --- trunk/pmplib/frontend/easypmp/cui/util.c 2006-12-24 01:35:06 UTC (rev 192) +++ trunk/pmplib/frontend/easypmp/cui/util.c 2006-12-24 01:56:05 UTC (rev 193) @@ -114,14 +114,16 @@ */ void display_init() { +#ifdef HAVE_TTY int i; for(i = 0; i <= POSSIBLE_TTYS; ++i) fd_is_tty[i] = isatty(i); -#if CAN_GET_WIN_SIZE +#if CAN_GET_WIN_SIZE signal(SIGWINCH,window_size_changed); window_size_changed(0); #endif/*CAN_GET_WIN_SIZE*/ +#endif/*HAVE_TTY*/ } /** @@ -160,6 +162,9 @@ void display_line(FILE *fp, const ucs2char_t* const line, unsigned int min_width) { + unsigned int length = ucs2len(line); + const ucs2char_t* line_to_print; + int writing_to_tty; /* Check if writing to a terminal. If so, clear the current line. */ int fd = fileno(fp); @@ -170,9 +175,6 @@ writing_to_tty = 0; } - unsigned int length = ucs2len(line); - const ucs2char_t* line_to_print; - if(!writing_to_tty) { /* Write the whole line to the file, add \n. */ fprints(fp, "%s\r\n", line); @@ -187,8 +189,7 @@ /* Length of string we actually will display: */ const size_t trunc_length = MIN(max_trunc_length, length); - ucs2char_t truncated_line[trunc_length+1]; - truncated_line[trunc_length]=0; + ucs2char_t *truncated_line = ucs2calloc(sizeof(ucs2char_t) * (trunc_length+1)); ucs2ncpy(truncated_line, line, trunc_length); fprints(fp, "%s\r", truncated_line); } @@ -217,9 +218,9 @@ // Numeric part, plus associated punctuation const int prefix_length = 16; - char fmt[prefix_length + 1]; + char *fmt = alloca(sizeof(char) * prefix_length + 1); - ucs2char_t line[ucs2len(msg) + prefix_length + 1]; + ucs2char_t *line = alloca(sizeof(ucs2char_t) * (ucs2len(msg) + prefix_length + 1)); ucs2char_t *fmt_ucs2; // Build the numeric part... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |