Changeset 2702 in kBuild for trunk/src/kmk
- Timestamp:
- Nov 21, 2013 12:11:08 AM (11 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.kmk
r2667 r2702 130 130 w32/subproc/sub_proc.c \ 131 131 w32/subproc/w32err.c \ 132 w32/compat/dirent.c \133 132 w32/pathstuff.c \ 134 133 w32/imagecache.c -
trunk/src/kmk/config.h.win
r2592 r2702 273 273 274 274 /* Define to 1 if you have the <sys/stat.h> header file. */ 275 /* #define HAVE_SYS_STAT_H 1 */ 275 #define HAVE_SYS_STAT_H 1 276 276 277 277 /* Define to 1 if you have the <sys/timeb.h> header file. */ … … 384 384 385 385 /* Define if struct stat contains a nanoseconds field */ 386 /* #undef ST_MTIM_NSEC */ 386 #define ST_MTIM_NSEC tv_nsec 387 387 388 388 /* Define to 1 on System V Release 4. */ … … 523 523 #endif 524 524 525 /* bird hacks - similar in mscfakes.h */ 526 #include <sys/stat.h> 525 /* bird stat hacks. */ 527 526 #include <io.h> 528 527 #include <direct.h> 529 #ifndef STAT_REDEFINED_ALREADY 530 # define STAT_REDEFINED_ALREADY 531 # undef stat 532 # define stat(_path, _st) bird_w32_stat(_path, _st) 533 extern int bird_w32_stat(const char *, struct stat *); 534 #endif 528 #include "nt/ntstat.h" 529 530 /* bird dirent hack. */ 531 #define _DIRENT_H /* see w32/dirent.h */ 532 #include "nt/ntdir.h" 533 #define _DIRENT_HAVE_D_NAMLEN 1 534 #define _DIRENT_HAVE_D_TYPE 1 535 535 536 536 537 /* cygwin sucks to much in one end or the other. */ -
trunk/src/kmk/dir.c
r2591 r2702 121 121 122 122 #ifdef WINDOWS32 123 #include <Windows.h> 123 124 #include "pathstuff.h" 124 125 #endif … … 244 245 # define FS_NTFS 0x2 245 246 # define FS_UNKNOWN 0x4 247 # ifdef KMK 248 time_t last_updated; /**< The last time the directory was re-read. */ 249 # endif 246 250 #else 247 251 # ifdef VMS … … 611 615 dc->ctime = st.st_ctime; 612 616 dc->mtime = st.st_mtime; 617 # ifdef KMK 618 dc->last_updated = time(NULL); 619 # endif 613 620 614 621 /* … … 691 698 struct dirent *d; 692 699 #ifdef WINDOWS32 700 # ifndef KMK 693 701 struct stat st; 702 # endif 694 703 int rehash = 0; 695 704 #endif … … 745 754 if (dir->dirstream == 0) 746 755 { 747 #if def WINDOWS32756 #if defined(WINDOWS32) && !defined(KMK) 748 757 /* 749 758 * Check to see if directory has changed since last read. FAT … … 751 760 * on directories (ugh!). 752 761 */ 762 # ifdef KMK 763 if (dir->path_key && time(NULL) > dc->last_updated + 2) /* KMK: Only recheck every 2 seconds. */ 764 # else 753 765 if (dir->path_key) 766 # endif 754 767 { 755 768 if ((dir->fs_flags & FS_FAT) != 0) … … 758 771 rehash = 1; 759 772 } 773 # ifdef KMK 774 else if ( birdStatModTimeOnly (dir->path_key, &st.st_mtim, 1) == 0 775 && st.st_mtime > dir->mtime) 776 # else 760 777 else if (stat (dir->path_key, &st) == 0 && st.st_mtime > dir->mtime) 778 # endif 761 779 { 762 780 /* reset date stamp to show most recent re-process. */ … … 765 783 } 766 784 785 767 786 /* If it has been already read in, all done. */ 768 787 if (!rehash) … … 773 792 if (!dir->dirstream) 774 793 return 0; 794 # ifdef KMK 795 dc->last_updated = time(NULL); 796 # endif 775 797 } 776 798 else … … 1400 1422 #endif 1401 1423 1424 #ifdef KMK 1425 static int dir_exists_p (const char *dirname) 1426 { 1427 if (file_exists_p (dirname)) 1428 { 1429 struct directory *dir = find_directory (dirname); 1430 if (dir != NULL && dir->contents && dir->contents->dirfiles.ht_vec != NULL) 1431 return 1; 1432 } 1433 return 0; 1434 } 1435 #endif 1436 1402 1437 void 1403 1438 dir_setup_glob (glob_t *gl) … … 1409 1444 #ifdef __EMX__ /* The FreeBSD implementation actually uses gl_lstat!! */ 1410 1445 gl->gl_lstat = local_stat; 1446 #endif 1447 #ifdef KMK 1448 gl->gl_exists = file_exists_p; 1449 gl->gl_isdir = dir_exists_p; 1411 1450 #endif 1412 1451 /* We don't bother setting gl_lstat, since glob never calls it. … … 1436 1475 #endif /* CONFIG_WITH_ALLOC_CACHES */ 1437 1476 } 1477 -
trunk/src/kmk/function.c
r2698 r2702 4438 4438 const char *src = comp; 4439 4439 const char *end = strchr (comp, PATH_SEPARATOR_CHAR); 4440 size_t comp_len = end ? (size_t)(end - comp) : strlen (comp);4441 if (! comp_len)4440 size_t src_len = end ? (size_t)(end - comp) : strlen (comp); 4441 if (!src_len) 4442 4442 { 4443 comp_len = 1;4443 src_len = 1; 4444 4444 src = "."; 4445 4445 } 4446 if (len + comp_len + 2 + 4 < GET_PATH_MAX) /* +4 for .exe */4446 if (len + src_len + 2 + 4 < GET_PATH_MAX) /* +4 for .exe */ 4447 4447 { 4448 memcpy (buf, comp, comp_len);4449 buf [ comp_len] = '/';4450 memcpy (&buf[ comp_len + 1], cur, len);4451 buf[ comp_len + 1 + len] = '\0';4448 memcpy (buf, src, src_len); 4449 buf [src_len] = '/'; 4450 memcpy (&buf[src_len + 1], cur, len); 4451 buf[src_len + 1 + len] = '\0'; 4452 4452 4453 4453 if (func_which_test_x (buf)) -
trunk/src/kmk/glob/glob.c
r2591 r2702 807 807 /* Return the directory if we don't check for error or if it exists. */ 808 808 if ((flags & GLOB_NOCHECK) 809 #ifdef KMK 810 || (flags & GLOB_ALTDIRFUNC 811 ? (*pglob->gl_isdir) (dirname) 812 : __stat (dirname, &st) == 0 && S_ISDIR (st.st_mode)) 813 #else 809 814 || (((flags & GLOB_ALTDIRFUNC) 810 815 ? (*pglob->gl_stat) (dirname, &st) 811 816 : __stat (dirname, &st)) == 0 812 && S_ISDIR (st.st_mode))) 817 && S_ISDIR (st.st_mode)) 818 #endif 819 ) 813 820 { 814 821 pglob->gl_pathv … … 954 961 955 962 /* First check whether this really is a directory. */ 963 #ifdef KMK 964 if (flags & GLOB_ALTDIRFUNC 965 ? !pglob->gl_isdir (dir) 966 : __stat (dir, &st) != 0 || !S_ISDIR (st.st_mode)) 967 #else 956 968 if (((flags & GLOB_ALTDIRFUNC) 957 969 ? (*pglob->gl_stat) (dir, &st) : __stat (dir, &st)) != 0 958 970 || !S_ISDIR (st.st_mode)) 971 #endif 959 972 /* No directory, ignore this entry. */ 960 973 continue; … … 1029 1042 struct stat st; 1030 1043 for (i = oldcount; i < pglob->gl_pathc; ++i) 1044 #ifdef KMK 1045 if (flags & GLOB_ALTDIRFUNC 1046 ? pglob->gl_isdir (pglob->gl_pathv[i]) 1047 : __stat (pglob->gl_pathv[i], &st) == 0 && S_ISDIR (st.st_mode) ) 1048 #else 1031 1049 if (((flags & GLOB_ALTDIRFUNC) 1032 1050 ? (*pglob->gl_stat) (pglob->gl_pathv[i], &st) 1033 1051 : __stat (pglob->gl_pathv[i], &st)) == 0 1034 1052 && S_ISDIR (st.st_mode)) 1053 #endif 1035 1054 { 1036 1055 size_t len = strlen (pglob->gl_pathv[i]) + 2; … … 1262 1281 memcpy (&fullname[dirlen + 1], pattern, patlen + 1); 1263 1282 # endif 1283 # ifdef KMK 1284 if (flags & GLOB_ALTDIRFUNC ? pglob->gl_exists (fullname) : __stat (fullname, &st) == 0) 1285 # else 1264 1286 if (((flags & GLOB_ALTDIRFUNC) 1265 1287 ? (*pglob->gl_stat) (fullname, &st) 1266 1288 : __stat (fullname, &st)) == 0) 1289 # endif 1267 1290 /* We found this file to be existing. Now tell the rest 1268 1291 of the function to copy this name into the result. */ -
trunk/src/kmk/glob/glob.h
r1993 r2702 137 137 int (*gl_stat) __PMT ((__const char *, struct stat *)); 138 138 #endif 139 #ifdef KMK 140 int (*gl_exists) __PMT ((__const char *)); 141 int (*gl_isdir) __PMT ((__const char *)); 142 #endif 139 143 } glob_t; 140 144 -
trunk/src/kmk/kmkbuiltin/cp.c
r2466 r2702 83 83 84 84 #if defined(_MSC_VER) || defined(__gnu_linux__) || defined(__linux__) 85 extern char *strlcpy(char *, const char *, size_t);85 extern size_t strlcpy(char *, const char *, size_t); 86 86 #endif 87 87 -
trunk/src/kmk/kmkbuiltin/mscfakes.c
r2645 r2702 109 109 110 110 111 staticint112 msc_set_errno(DWORD dwErr)111 int 112 birdSetErrno(DWORD dwErr) 113 113 { 114 114 switch (dwErr) … … 184 184 DWORD fAttr = GetFileAttributes(pszPath); 185 185 if (fAttr == INVALID_FILE_ATTRIBUTES) 186 rc = msc_set_errno(GetLastError());186 rc = birdSetErrno(GetLastError()); 187 187 else if (fMustBeDir & !(fAttr & FILE_ATTRIBUTE_DIRECTORY)) 188 188 { … … 200 200 fAttr |= FILE_ATTRIBUTE_READONLY; 201 201 if (!SetFileAttributes(pszPath, fAttr)) 202 rc = msc_set_errno(GetLastError());202 rc = birdSetErrno(GetLastError()); 203 203 } 204 204 … … 224 224 DWORD fAttr = GetFileAttributes(pszPath); 225 225 if (fAttr == INVALID_FILE_ATTRIBUTES) 226 rc = msc_set_errno(GetLastError());226 rc = birdSetErrno(GetLastError()); 227 227 else if (fMustBeDir & !(fAttr & FILE_ATTRIBUTE_DIRECTORY)) 228 228 { … … 245 245 fAttr |= FILE_ATTRIBUTE_READONLY; 246 246 if (!SetFileAttributes(pszPath, fAttr)) 247 rc = msc_set_errno(GetLastError());247 rc = birdSetErrno(GetLastError()); 248 248 } 249 249 … … 283 283 if (s_pfnCreateHardLinkA(pszLink, pszDst, NULL)) 284 284 return 0; 285 return msc_set_errno(GetLastError());285 return birdSetErrno(GetLastError()); 286 286 } 287 287 … … 535 535 536 536 537 /*538 * Workaround for directory names with trailing slashes.539 */540 #undef stat541 int542 bird_w32_stat(const char *path, struct stat *st)543 {544 int rc = stat(path, st);545 if ( rc != 0546 && errno == ENOENT547 && *path != '\0')548 {549 char *slash = strchr(path, '\0') - 1;550 if (*slash == '/' || *slash == '\\')551 {552 size_t len_path = slash - path + 1;553 char *tmp = alloca(len_path + 4);554 memcpy(tmp, path, len_path);555 tmp[len_path] = '.';556 tmp[len_path + 1] = '\0';557 errno = 0;558 rc = stat(tmp, st);559 if ( rc == 0560 && !S_ISDIR(st->st_mode))561 {562 errno = ENOTDIR;563 rc = -1;564 }565 }566 }567 #ifdef KMK_PRF568 {569 int err = errno;570 fprintf(stderr, "stat(%s,) -> %d/%d\n", path, rc, errno);571 errno = err;572 }573 #endif574 return rc;575 }576 -
trunk/src/kmk/kmkbuiltin/mscfakes.h
r2592 r2702 39 39 #include <io.h> 40 40 #include <direct.h> 41 #include "nt/ntstat.h" 41 42 #if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */ 42 43 # define off_t __int64 43 # undef stat44 # define stat _stat6445 # define fstat _fstat6446 44 # define lseek _lseeki64 47 #else48 # ifndef STAT_REDEFINED_ALREADY49 # define STAT_REDEFINED_ALREADY50 # undef stat51 # define stat(_path, _st) bird_w32_stat(_path, _st)52 extern int bird_w32_stat(const char *, struct stat *);53 # endif54 45 #endif 55 56 #ifndef S_ISDIR57 # define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)58 #endif59 #ifndef S_ISREG60 # define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)61 #endif62 #define S_ISLNK(m) 063 #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)64 #define S_IXUSR _S_IEXEC65 #define S_IWUSR _S_IWRITE66 #define S_IRUSR _S_IREAD67 #define S_IRWXG 000007068 #define S_IRGRP 000004069 #define S_IWGRP 000002070 #define S_IXGRP 000001071 #define S_IRWXO 000000772 #define S_IROTH 000000473 #define S_IWOTH 000000274 #define S_IXOTH 000000175 #define S_ISUID 000400076 #define S_ISGID 000200077 #define ALLPERMS 000077778 46 79 47 #undef PATH_MAX … … 141 109 #define geteuid() 0 142 110 #define getegid() 0 143 #define lstat(path, s) stat(path, s)144 111 int lchmod(const char *path, mode_t mode); 145 112 int msc_chmod(const char *path, mode_t mode); … … 172 139 int writev(int fd, const struct iovec *vector, int count); 173 140 141 142 143 /* 144 * MSC fake internals / helpers. 145 */ 146 int birdSetErrno(unsigned dwErr); 147 174 148 #endif /* _MSC_VER */ 175 149 #endif -
trunk/src/kmk/kmkbuiltin/rm.c
r2546 r2702 499 499 rval = undelete(f); 500 500 operation = "undelete"; 501 #ifndef _MSC_VER 501 502 } else if (S_ISDIR(sb.st_mode)) { 503 #else 504 } else if (S_ISDIR(sb.st_mode) || sb.st_dirsymlink) { 505 #endif 502 506 rval = rmdir(f); 503 507 operation = "rmdir"; -
trunk/src/kmk/w32/include/dirent.h
r2591 r2702 18 18 #ifndef _DIRENT_H 19 19 #define _DIRENT_H 20 21 #ifdef KMK 22 # include <windows.h> 23 # include "nt/ntdir.h" 24 25 #else /* !KMK */ 20 26 21 27 #ifdef __MINGW32__ … … 58 64 59 65 #endif /* !__MINGW32__ */ 66 #endif /* !KMK */ 60 67 #endif
Note:
See TracChangeset
for help on using the changeset viewer.