Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <3AAF7F68.60785E60@salomon.at> Date: Wed, 14 Mar 2001 15:25:44 +0100 From: Michael Haubenwallner X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.18 i686) X-Accept-Language: de-AT, en MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: 1.1.8: stat() (ntsec) clears reentrant-buffer for strtok() Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi there! This is my problem with stat() and strtok() on 1.1.8: stat() seems to clear the reentrant-buffer for strtok() if ntsec is set in the CYGWIN environment-variable. So i found _REENT->_new._reent._strtok_last in the strtok-source, and my test-program included here uses this to see what happens (hope you can reproduce). Yes, i know it may be better to use strtok_r(), but my program already works on HP-UX, AIX, Linux, SunOS and Win32 using MSVC 5.0 too. I noticed this strange behaviour both on WinNT 4.0 and Win2K, everywhere using only NTFS as the local filesystem, using $ `gcc -v` Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/specs gcc version 2.95.2-6 19991024 (cygwin experimental) You may try my test-program with and without ntsec set in your CYGWIN-var to see what i mean. Thank you for the great thing making a complete Unix-environment possible on Windows! -- haubi Michael Haubenwallner F&E S a l o m o n Automationstechnik GmbH Friesachstr. 15, 8114 Friesach b. Graz, Austria Phone: (++43) 3127 200-308 Fax: 200-22 mailto:haubi AT salomon DOT at http://www.salomon.at 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< 8< #include #include #include #include int main(int argc, char **argv) { char origpath[]="/check/this/path/for/existance"; char path[1024] = "/"; struct stat statbuf; int rv; char *ptr; ptr = strtok(origpath, "/"); while(ptr != NULL) { strcat(path, ptr); printf("_REENT->_new._reent._strtok_last is %p (%s)\n", _REENT->_new._reent._strtok_last, (_REENT->_new._reent._strtok_last) ? _REENT->_new._reent._strtok_last : ""); rv = stat(path, &statbuf); printf("_REENT->_new._reent._strtok_last is %p (%s)\n", _REENT->_new._reent._strtok_last, (_REENT->_new._reent._strtok_last) ? _REENT->_new._reent._strtok_last : ""); if (rv < 0) { rv = mkdir(path, 0777); if (rv < 0) { fprintf(stderr, "can't create '%s': %s\n", path, strerror(errno)); break; } else { printf("created: '%s'\n", path); } } else { printf("exists: '%s'\n", path); } strcat(path, "/"); ptr = strtok(NULL, "/"); } return rv; } >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 >8 -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple