diff options
Diffstat (limited to 'win32/stdio.c')
-rw-r--r-- | win32/stdio.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/win32/stdio.c b/win32/stdio.c index 2fa3fc66869aa..47d977f76c4ac 100644 --- a/win32/stdio.c +++ b/win32/stdio.c @@ -1,4 +1,4 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/stdio.c,v 1.10 2010/05/27 04:00:23 amold Exp $*/ +/*$Header: /p/tcsh/cvsroot/tcsh/win32/stdio.c,v 1.11 2012/03/05 14:03:23 christos Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -420,18 +420,18 @@ int nt_stat(const char *filename, struct stat *stbuf) { return _stat("C:/",(struct _stat *)stbuf); } else { - char *last = (char*)filename + strlen(filename) -1; - int rc = 0; - BOOL lastslash = (*last == '/'); + size_t len = strlen(filename); + char *last = (char*)filename + len - 1; + int rc; + /* Possible X: and X:/ strings */ + BOOL root = (len <= 3 && *(filename + 1) == ':'); + /* exclude X:/ strings */ + BOOL lastslash = ((*last == '/') && !root); if(lastslash) - { - *last = 0; - } - rc = _stat(filename,(struct _stat *)stbuf); + *last = '\0'; + rc = _stat(filename,(struct _stat *)stbuf); if(lastslash) - { *last = '/'; - } return rc; } } |