From 34b7c959d45e2753e478df3d792b773bfa389a8c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 14 Aug 2009 07:35:18 +0000 Subject: [PATCH] 2009-08-14 09:34 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/rtl/gtsln/gtsln.c ! Fixed linux/gcc warning. Now write() retval is checked. * config/global.cf ! Fixed wrong autodetection due to recent change. (HB_COMPILER needs to be checked against empty value) --- harbour/ChangeLog | 8 +++ harbour/config/global.cf | 20 +++--- harbour/source/rtl/gtsln/gtsln.c | 105 ++++++++++++++++--------------- 3 files changed, 73 insertions(+), 60 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fdb5f322f0..895a1b6d0e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-08-14 09:34 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * source/rtl/gtsln/gtsln.c + ! Fixed linux/gcc warning. Now write() retval is checked. + + * config/global.cf + ! Fixed wrong autodetection due to recent change. + (HB_COMPILER needs to be checked against empty value) + 2009-08-14 08:41 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * INSTALL * make_gnu.bat diff --git a/harbour/config/global.cf b/harbour/config/global.cf index c44b3a2735..7131fe0c18 100644 --- a/harbour/config/global.cf +++ b/harbour/config/global.cf @@ -421,20 +421,22 @@ endif HB_ARCH_AUTO := ifeq ($(HB_ARCHITECTURE),) HB_ARCHITECTURE := $(HB_HOST_ARCH) - ifeq ($(HB_COMPILER),msvcarm) - HB_ARCHITECTURE := wce - else - ifeq ($(HB_COMPILER),mingwarm) + ifneq ($(HB_COMPILER),) + ifeq ($(HB_COMPILER),msvcarm) HB_ARCHITECTURE := wce else - ifeq ($(HB_COMPILER),poccarm) + ifeq ($(HB_COMPILER),mingwarm) HB_ARCHITECTURE := wce else - ifeq ($(HB_COMPILER),djgpp) - HB_ARCHITECTURE := dos + ifeq ($(HB_COMPILER),poccarm) + HB_ARCHITECTURE := wce else - ifeq ($(findstring $(HB_COMPILER),mingw mingw64 msvc msvc64 msvcia64 bcc xcc pocc pocc64),) - HB_ARCHITECTURE := win + ifeq ($(HB_COMPILER),djgpp) + HB_ARCHITECTURE := dos + else + ifeq ($(findstring $(HB_COMPILER),mingw mingw64 msvc msvc64 msvcia64 bcc xcc pocc pocc64),) + HB_ARCHITECTURE := win + endif endif endif endif diff --git a/harbour/source/rtl/gtsln/gtsln.c b/harbour/source/rtl/gtsln/gtsln.c index d1aecc600c..2e00a8736f 100644 --- a/harbour/source/rtl/gtsln/gtsln.c +++ b/harbour/source/rtl/gtsln/gtsln.c @@ -538,71 +538,74 @@ static int hb_sln_isUTF8( int iStdOut, int iStdIn ) if( isatty( iStdOut ) && isatty( iStdIn ) ) { const char * szBuf = "\r\303\255\033[6n \r"; - char rdbuf[ 64 ]; - int i, j, n, d, y, x; - HB_ULONG end_timer, time; + int len = strlen( szBuf ); - write( iStdOut, szBuf, strlen( szBuf ) ); - - n = j = x = y = 0; - /* wait up to 2 seconds for answer */ - end_timer = hb_dateMilliSeconds() + 2000; - for( ; ; ) + if( write( iStdOut, szBuf, len ) == len ) { - /* loking for cursor position in "\033[%d;%dR" */ - while( j < n && rdbuf[ j ] != '\033' ) - ++j; - if( n - j >= 6 ) + char rdbuf[ 64 ]; + int i, j, n, d, y, x; + HB_ULONG end_timer, time; + + n = j = x = y = 0; + /* wait up to 2 seconds for answer */ + end_timer = hb_dateMilliSeconds() + 2000; + for( ; ; ) { - i = j + 1; - if( rdbuf[ i ] == '[' ) + /* loking for cursor position in "\033[%d;%dR" */ + while( j < n && rdbuf[ j ] != '\033' ) + ++j; + if( n - j >= 6 ) { - y = 0; - d = ++i; - while( i < n && rdbuf[ i ] >= '0' && rdbuf[ i ] <= '9' ) - y = y * 10 + ( rdbuf[ i++ ] - '0' ); - if( i < n && i > d && rdbuf[ i ] == ';' ) + i = j + 1; + if( rdbuf[ i ] == '[' ) { - x = 0; + y = 0; d = ++i; while( i < n && rdbuf[ i ] >= '0' && rdbuf[ i ] <= '9' ) - x = x * 10 + ( rdbuf[ i++ ] - '0' ); - if( i < n && i > d && rdbuf[ i ] == 'R' ) + y = y * 10 + ( rdbuf[ i++ ] - '0' ); + if( i < n && i > d && rdbuf[ i ] == ';' ) { - return x == 2 ? 1 : 0; + x = 0; + d = ++i; + while( i < n && rdbuf[ i ] >= '0' && rdbuf[ i ] <= '9' ) + x = x * 10 + ( rdbuf[ i++ ] - '0' ); + if( i < n && i > d && rdbuf[ i ] == 'R' ) + { + return x == 2 ? 1 : 0; + } } } + if( i < n ) + { + j = i; + continue; + } } - if( i < n ) + if( n == sizeof( rdbuf ) ) + break; + time = hb_dateMilliSeconds(); + if( time > end_timer ) + break; + else { - j = i; - continue; + struct timeval tv; + fd_set rdfds; + int iMilliSec; + + FD_ZERO( &rdfds ); + FD_SET( iStdIn, &rdfds ); + iMilliSec = ( int ) ( end_timer - time ); + tv.tv_sec = iMilliSec / 1000; + tv.tv_usec = ( iMilliSec % 1000 ) * 1000; + + if( select( iStdIn + 1, &rdfds, NULL, NULL, &tv ) <= 0 ) + break; + i = read( iStdIn, rdbuf + n, sizeof( rdbuf ) - n ); + if( i <= 0 ) + break; + n += i; } } - if( n == sizeof( rdbuf ) ) - break; - time = hb_dateMilliSeconds(); - if( time > end_timer ) - break; - else - { - struct timeval tv; - fd_set rdfds; - int iMilliSec; - - FD_ZERO( &rdfds ); - FD_SET( iStdIn, &rdfds ); - iMilliSec = ( int ) ( end_timer - time ); - tv.tv_sec = iMilliSec / 1000; - tv.tv_usec = ( iMilliSec % 1000 ) * 1000; - - if( select( iStdIn + 1, &rdfds, NULL, NULL, &tv ) <= 0 ) - break; - i = read( iStdIn, rdbuf + n, sizeof( rdbuf ) - n ); - if( i <= 0 ) - break; - n += i; - } } } return -1;