From 3a036b826b15a1427f96c4cd6560fd656ba29f6d Mon Sep 17 00:00:00 2001 From: "David G. Holm" Date: Sat, 16 Oct 1999 04:15:29 +0000 Subject: [PATCH] See ChangeLog entry 19991016-00:00 EDT David G. Holm --- harbour/ChangeLog | 6 ++++++ harbour/source/rtl/set.c | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9727f2ed75..fa72373df6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +19991016-00:00 EDT David G. Holm + + * source/rtl/set.c + ! HB_DEFPATH() (and consequently HB___DEFPATH()) now append a drive + or path delimiter if the default path does not have one at the end. + 19991015-23:25 EDT Paul Tucker * source/compiler/harbour.c + || defined(_MSC_VER) around isatty() diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index f89dd7a03e..56cfcaa96e 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -1093,14 +1093,39 @@ void hb_setRelease( void ) hb_set.HB_SET_TYPEAHEAD = -1; hb_inkeyReset( TRUE ); /* Free keyboard typeahead buffer */ } -/* TOFIX: Clipper appends a slash after the path in this function */ - HARBOUR HB_DEFPATH( void ) { + char buffer[ _POSIX_PATH_MAX ]; + char delimiter[ 2 ] = ":"; + int size = 0; + if( hb_set.HB_SET_DEFAULT ) - hb_retc( hb_set.HB_SET_DEFAULT ); - else - hb_retc( "" ); + { + /* Leave enough space to append a path delimiter */ + strncpy( buffer, hb_set.HB_SET_DEFAULT, sizeof( buffer ) - 1 ); + size = sizeof( buffer ) - 2; + } + buffer[ size ] = '\0'; + size = strlen( buffer ); +/* + Debug code: + +printf( "\nHB_DEFPATH: buffer is '%s', size is %d, last char is '%c',", buffer, size, buffer[ size - 1] ); +printf( " OS_PATH_DELIMITER is '%c', and OS_PATH_LIST_SEPARATOR is '%c'.", OS_PATH_DELIMITER, OS_PATH_LIST_SEPARATOR ); +*/ + /* If the path is not empty and it doesn't end with a drive or path + delimiter, then add the appropriate separator. Use ':' if the size + of the path is 1 and the list separator is not ':', otherwise use + the path delimiter. This allows the use of a drive letter delimiter + for DOS compatible operating systems while preventing it from being + with a Unix compatible OS. */ + if( size && buffer[ size - 1 ] != ':' && buffer[ size - 1 ] != OS_PATH_DELIMITER ) + { + if( size > 1 || OS_PATH_LIST_SEPARATOR == ':' ) + delimiter[ 0 ] = OS_PATH_DELIMITER; + strcat( buffer, delimiter ); + } + hb_retc( buffer ); } HARBOUR HB___DEFPATH( void )