summaryrefslogtreecommitdiffstats
path: root/macosx/tclMacOSXFCmd.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-01-09 11:21:45 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-01-09 11:21:45 (GMT)
commit4a6ee21a80ee4a00adc8da96ed88329e7faaebf4 (patch)
tree4aa51d7f8297e2b7b5f11c316610f06e345c362d /macosx/tclMacOSXFCmd.c
parent06b98b063ae2d87532d9940f8ff0a6409fa86f58 (diff)
downloadtcl-4a6ee21a80ee4a00adc8da96ed88329e7faaebf4.zip
tcl-4a6ee21a80ee4a00adc8da96ed88329e7faaebf4.tar.gz
tcl-4a6ee21a80ee4a00adc8da96ed88329e7faaebf4.tar.bz2
Style fixes (unfouling whitespace, sorting comments, removing useless casts, etc.)
Diffstat (limited to 'macosx/tclMacOSXFCmd.c')
-rw-r--r--macosx/tclMacOSXFCmd.c134
1 files changed, 71 insertions, 63 deletions
diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c
index c902a28..d1bab28 100644
--- a/macosx/tclMacOSXFCmd.c
+++ b/macosx/tclMacOSXFCmd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclMacOSXFCmd.c,v 1.15 2008/10/26 18:50:06 dkf Exp $
+ * RCS: @(#) $Id: tclMacOSXFCmd.c,v 1.16 2009/01/09 11:21:46 dkf Exp $
*/
#include "tclInt.h"
@@ -27,19 +27,22 @@
#if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1040
/* Support for weakly importing copyfile. */
#define WEAK_IMPORT_COPYFILE
-extern int copyfile(const char *from, const char *to, copyfile_state_t state,
- copyfile_flags_t flags) WEAK_IMPORT_ATTRIBUTE;
+extern int copyfile(const char *from, const char *to,
+ copyfile_state_t state, copyfile_flags_t flags)
+ WEAK_IMPORT_ATTRIBUTE;
#endif /* HAVE_WEAK_IMPORT */
#else /* HAVE_COPYFILE_H */
-int copyfile(const char *from, const char *to, void *state, uint32_t flags);
+int copyfile(const char *from, const char *to,
+ void *state, uint32_t flags);
#define COPYFILE_ACL (1<<0)
#define COPYFILE_XATTR (1<<2)
#define COPYFILE_NOFOLLOW_SRC (1<<18)
#if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1040
/* Support for weakly importing copyfile. */
#define WEAK_IMPORT_COPYFILE
-extern int copyfile(const char *from, const char *to, void *state,
- uint32_t flags) WEAK_IMPORT_ATTRIBUTE;
+extern int copyfile(const char *from, const char *to,
+ void *state, uint32_t flags)
+ WEAK_IMPORT_ATTRIBUTE;
#endif /* HAVE_WEAK_IMPORT */
#endif /* HAVE_COPYFILE_H */
#endif /* HAVE_COPYFILE */
@@ -391,75 +394,75 @@ TclMacOSXCopyFileAttributes(
if (copyfile != NULL) {
#endif
#ifdef HAVE_COPYFILE
- if (copyfile(src, dst, NULL, COPYFILE_XATTR |
- (S_ISLNK(statBufPtr->st_mode) ? COPYFILE_NOFOLLOW_SRC :
- COPYFILE_ACL)) < 0) {
- return TCL_ERROR;
- }
- return TCL_OK;
+ if (copyfile(src, dst, NULL, COPYFILE_XATTR |
+ (S_ISLNK(statBufPtr->st_mode)
+ ? COPYFILE_NOFOLLOW_SRC : COPYFILE_ACL)) < 0) {
+ return TCL_ERROR;
+ }
+ return TCL_OK;
#endif /* HAVE_COPYFILE */
#ifdef WEAK_IMPORT_COPYFILE
} else {
#endif
#if !defined(HAVE_COPYFILE) || defined(WEAK_IMPORT_COPYFILE)
#ifdef HAVE_GETATTRLIST
- struct attrlist alist;
- fileinfobuf finfo;
- off_t *rsrcForkSize = (off_t *) &finfo.data;
-
- bzero(&alist, sizeof(struct attrlist));
- alist.bitmapcount = ATTR_BIT_MAP_COUNT;
- alist.commonattr = ATTR_CMN_FNDRINFO;
-
- if (getattrlist(src, &alist, &finfo, sizeof(fileinfobuf), 0)) {
- return TCL_ERROR;
- }
+ struct attrlist alist;
+ fileinfobuf finfo;
+ off_t *rsrcForkSize = (off_t *) &finfo.data;
- if (setattrlist(dst, &alist, &finfo.data, sizeof(finfo.data), 0)) {
- return TCL_ERROR;
- }
-
- if (!S_ISDIR(statBufPtr->st_mode)) {
- /*
- * Only copy non-empty resource fork.
- */
-
- alist.commonattr = 0;
- alist.fileattr = ATTR_FILE_RSRCLENGTH;
+ bzero(&alist, sizeof(struct attrlist));
+ alist.bitmapcount = ATTR_BIT_MAP_COUNT;
+ alist.commonattr = ATTR_CMN_FNDRINFO;
if (getattrlist(src, &alist, &finfo, sizeof(fileinfobuf), 0)) {
return TCL_ERROR;
}
- if(*rsrcForkSize > 0) {
- int result;
- Tcl_DString ds_src, ds_dst;
+ if (setattrlist(dst, &alist, &finfo.data, sizeof(finfo.data), 0)) {
+ return TCL_ERROR;
+ }
+ if (!S_ISDIR(statBufPtr->st_mode)) {
/*
- * Construct paths to resource forks.
+ * Only copy non-empty resource fork.
*/
- Tcl_DStringInit(&ds_src);
- Tcl_DStringAppend(&ds_src, src, -1);
- Tcl_DStringAppend(&ds_src, _PATH_RSRCFORKSPEC, -1);
- Tcl_DStringInit(&ds_dst);
- Tcl_DStringAppend(&ds_dst, dst, -1);
- Tcl_DStringAppend(&ds_dst, _PATH_RSRCFORKSPEC, -1);
+ alist.commonattr = 0;
+ alist.fileattr = ATTR_FILE_RSRCLENGTH;
- result = TclUnixCopyFile(Tcl_DStringValue(&ds_src),
- Tcl_DStringValue(&ds_dst), statBufPtr, 1);
+ if (getattrlist(src, &alist, &finfo, sizeof(fileinfobuf), 0)) {
+ return TCL_ERROR;
+ }
- Tcl_DStringFree(&ds_src);
- Tcl_DStringFree(&ds_dst);
+ if (*rsrcForkSize > 0) {
+ int result;
+ Tcl_DString ds_src, ds_dst;
- if (result != 0) {
- return TCL_ERROR;
+ /*
+ * Construct paths to resource forks.
+ */
+
+ Tcl_DStringInit(&ds_src);
+ Tcl_DStringAppend(&ds_src, src, -1);
+ Tcl_DStringAppend(&ds_src, _PATH_RSRCFORKSPEC, -1);
+ Tcl_DStringInit(&ds_dst);
+ Tcl_DStringAppend(&ds_dst, dst, -1);
+ Tcl_DStringAppend(&ds_dst, _PATH_RSRCFORKSPEC, -1);
+
+ result = TclUnixCopyFile(Tcl_DStringValue(&ds_src),
+ Tcl_DStringValue(&ds_dst), statBufPtr, 1);
+
+ Tcl_DStringFree(&ds_src);
+ Tcl_DStringFree(&ds_dst);
+
+ if (result != 0) {
+ return TCL_ERROR;
+ }
}
}
- }
- return TCL_OK;
+ return TCL_OK;
#else
- return TCL_ERROR;
+ return TCL_ERROR;
#endif /* HAVE_GETATTRLIST */
#endif /* !defined(HAVE_COPYFILE) || defined(WEAK_IMPORT_COPYFILE) */
#ifdef WEAK_IMPORT_COPYFILE
@@ -472,13 +475,13 @@ TclMacOSXCopyFileAttributes(
*
* TclMacOSXMatchType --
*
- * This routine is used by the globbing code to check if a file
- * matches a given mac type and/or creator code.
+ * This routine is used by the globbing code to check if a file matches a
+ * given mac type and/or creator code.
*
* Results:
- * The return value is 1, 0 or -1 indicating whether the file
- * matches the given criteria, does not match them, or an error
- * occurred (in wich case an error is left in interp).
+ * The return value is 1, 0 or -1 indicating whether the file matches the
+ * given criteria, does not match them, or an error occurred (in wich
+ * case an error is left in interp).
*
* Side effects:
* None.
@@ -510,8 +513,12 @@ TclMacOSXMatchType(
!((finder->fdFlags & kFinfoIsInvisible) || (*fileName == '.'))) {
return 0;
}
- if (S_ISDIR(statBufPtr->st_mode) && (types->macType || types->macCreator)) {
- /* Directories don't support types or creators */
+ if (S_ISDIR(statBufPtr->st_mode)
+ && (types->macType || types->macCreator)) {
+ /*
+ * Directories don't support types or creators.
+ */
+
return 0;
}
if (types->macType) {
@@ -584,7 +591,8 @@ GetOSTypeFromObj(
static Tcl_Obj *
NewOSTypeObj(
- const OSType osType) /* OSType used to initialize the new object. */
+ const OSType osType) /* OSType used to initialize the new
+ * object. */
{
Tcl_Obj *objPtr;
@@ -631,8 +639,8 @@ SetOSTypeFromAny(
} else {
OSType osType;
char string[4] = {'\0','\0','\0','\0'};
- memcpy(string, Tcl_DStringValue(&ds),
- (size_t) Tcl_DStringLength(&ds));
+
+ memcpy(string, Tcl_DStringValue(&ds), (size_t)Tcl_DStringLength(&ds));
osType = (OSType) string[0] << 24 |
(OSType) string[1] << 16 |
(OSType) string[2] << 8 |