diff options
Diffstat (limited to 'systems/msdos/tx/src/txexpand.c')
-rw-r--r-- | systems/msdos/tx/src/txexpand.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/systems/msdos/tx/src/txexpand.c b/systems/msdos/tx/src/txexpand.c new file mode 100644 index 0000000000..a3deed7423 --- /dev/null +++ b/systems/msdos/tx/src/txexpand.c @@ -0,0 +1,64 @@ +#include "tx.h" + +int ExpandNames(char *expand,char *notexpand,int limit) +{ + int i ; + + while ( limit && (*expand = *notexpand++) != '\0' ) { + if ( *expand != SUBST_SIGN ) { + ++expand ; + --limit ; + } + else if ( !strnicmp(notexpand,WF_PATH,L_WF_PATH) ) { + for ( i=0 ; limit && (*expand = Path[i]) ; i++ , limit-- ) { +#ifdef __GO32__ + if ( *expand == SLASH ) + *expand = '\\' ; /* dos wants backslashes here */ +#endif + ++expand ; + } + if (limit && Path[--i] != BACKSLASH ) { + *expand++ = '\\' ; + --limit ; + } + if (!limit) + break ; + notexpand += L_WF_PATH ; + } + else if ( !strnicmp(notexpand,WF_SLPATH,L_WF_SLPATH) ) { + for ( i=0 ; limit && (*expand=Path[i]) ; i++ , limit-- ) { +#ifndef __GO32__ + if ( *expand == BACKSLASH ) + *expand = SLASH ; +#endif + expand++ ; + } + if (limit && Path[--i] != BACKSLASH ) { + *expand++ = SLASH ; + --limit ; + } + if (!limit) + break ; + notexpand += L_WF_SLPATH ; + } + else if ( !strnicmp(notexpand,WF_NAME,L_WF_NAME) ) { + for ( i=0 ; limit && FileName[i] ; i++ , limit-- ) + *expand++ = FileName[i] ; + if (!limit) + break ; + notexpand += L_WF_NAME ; + } + else if ( !strnicmp(notexpand,WF_EXT,L_WF_EXT) ) { + for ( i=0 ; limit && Extension[i] ; i++ , limit-- ) + *expand++ = Extension[i] ; + if (!limit) + break ; + notexpand += L_WF_EXT ; + } + } + + if ( limit ) + return 1 ; /* return 1 on successful completion */ + *(--expand) = '\0' ; /* must back up to put null */ + return 0 ; /* return 0 if limit has been reached */ +} |