Mail Archives: cygwin/2001/03/14/09:31:00
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 <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
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 : "<nil>");
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 : "<nil>");
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
- Raw text -