diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-10-15 05:45:36 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-10-15 05:45:36 +0000 |
commit | 0f38926bbb8f61974f71662cfb90af18d05c1f1b (patch) | |
tree | 7a5b2d85b0a39dcd62d43abba1c89d98a56ecd96 /win32 | |
parent | 95136addeff6f7c87c13a96a62f5eaafb9bafdcf (diff) | |
download | perl-0f38926bbb8f61974f71662cfb90af18d05c1f1b.tar.gz |
various little goofs in change#4385
p4raw-link: @4385 on //depot/perl: 95136addeff6f7c87c13a96a62f5eaafb9bafdcf
p4raw-id: //depot/perl@4386
Diffstat (limited to 'win32')
-rw-r--r-- | win32/include/dirent.h | 2 | ||||
-rw-r--r-- | win32/win32.c | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/win32/include/dirent.h b/win32/include/dirent.h index d6eb7ea0d9..a66901234f 100644 --- a/win32/include/dirent.h +++ b/win32/include/dirent.h @@ -26,7 +26,7 @@ typedef struct direct { long d_ino; /* inode number (not used by MS-DOS) */ long d_namlen; /* name length */ - char *d_name; /* file name */ + char d_name[257]; /* file name */ } _DIRECT; /* structure for dir operations */ diff --git a/win32/win32.c b/win32/win32.c index 71a959ae81..bbf85e6967 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -774,11 +774,11 @@ win32_readdir(DIR *dirp) if (dirp->curr) { /* first set up the structure to return */ len = strlen(dirp->curr); - dirp->dirstr.d_name = dirp->curr; + strcpy(dirp->dirstr.d_name, dirp->curr); dirp->dirstr.d_namlen = len; /* Fake an inode */ - dirp->dirstr.d_ino = (long)dirp->curr; + dirp->dirstr.d_ino = dirp->curr - dirp->start; /* Now set up for the next call to readdir */ dirp->curr += len + 1; @@ -792,8 +792,6 @@ win32_readdir(DIR *dirp) /* finding the next file that matches the wildcard * (which should be all of them in this directory!). - * the variable idx should point one past the null terminator - * of the previous string found. */ if (USING_WIDE()) { res = FindNextFileW(dirp->handle, &wFindData); @@ -808,15 +806,18 @@ win32_readdir(DIR *dirp) ptr = aFindData.cFileName; } if (res) { - len = strlen(ptr)+1; + long endpos = dirp->end - dirp->start; + long newsize = endpos + strlen(ptr) + 1; /* bump the string table size by enough for the * new name and it's null terminator */ - while (dirp->end + len > dirp->start + dirp->size) { + while (newsize > dirp->size) { + long curpos = dirp->curr - dirp->start; dirp->size *= 2; Renew(dirp->start, dirp->size, char); + dirp->curr = dirp->start + curpos; } - strcpy(dirp->end, ptr); - dirp->end += idx; + strcpy(dirp->start + endpos, ptr); + dirp->end = dirp->start + newsize; dirp->nfiles++; } else @@ -858,7 +859,7 @@ win32_closedir(DIR *dirp) { dTHXo; if (dirp->handle != INVALID_HANDLE_VALUE) - FindClose(p->handle); + FindClose(dirp->handle); Safefree(dirp->start); Safefree(dirp); return 1; |