summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFile.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-08-07 20:57:08 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-08-07 20:57:08 (GMT)
commit0fe2d45ae44323638f143bf320c77a5cb6df2a01 (patch)
tree01529af3ee161f7c70fd8f14ba581054bd52155c /unix/tclUnixFile.c
parent00acd83312b7bcc144212b7bd1a47436719b0d2c (diff)
downloadtcl-0fe2d45ae44323638f143bf320c77a5cb6df2a01.zip
tcl-0fe2d45ae44323638f143bf320c77a5cb6df2a01.tar.gz
tcl-0fe2d45ae44323638f143bf320c77a5cb6df2a01.tar.bz2
Minor changes to improve style (C89 declarations, consistent indentation,
clarification of #endifs, reduction of unnecessary casts, use of array syntax for reading array elements, etc.)
Diffstat (limited to 'unix/tclUnixFile.c')
-rw-r--r--unix/tclUnixFile.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 01fc6fe..38504d9 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -470,7 +470,7 @@ NativeMatchType(
#ifndef MAC_OSX_TCL
|| ((types->perm & TCL_GLOB_PERM_HIDDEN) &&
(*nativeName != '.'))
-#endif
+#endif /* MAC_OSX_TCL */
) {
return 0;
}
@@ -488,12 +488,10 @@ NativeMatchType(
* check that here:
*/
- if (types->type & TCL_GLOB_TYPE_LINK) {
- if (TclOSlstat(nativeEntry, &buf) == 0) {
- if (S_ISLNK(buf.st_mode)) {
- return 1;
- }
- }
+ if ((types->type & TCL_GLOB_TYPE_LINK)
+ && (TclOSlstat(nativeEntry, &buf) == 0)
+ && S_ISLNK(buf.st_mode)) {
+ return 1;
}
return 0;
}
@@ -516,12 +514,10 @@ NativeMatchType(
*/
} else {
#ifdef S_ISLNK
- if (types->type & TCL_GLOB_TYPE_LINK) {
- if (TclOSlstat(nativeEntry, &buf) == 0) {
- if (S_ISLNK(buf.st_mode)) {
- goto filetypeOK;
- }
- }
+ if ((types->type & TCL_GLOB_TYPE_LINK)
+ && (TclOSlstat(nativeEntry, &buf) == 0)
+ && S_ISLNK(buf.st_mode)) {
+ goto filetypeOK;
}
#endif /* S_ISLNK */
return 0;
@@ -717,9 +713,9 @@ TclpGetNativeCwd(
if (getcwd(buffer, MAXPATHLEN+1) == NULL) { /* INTL: Native. */
return NULL;
}
-#endif
+#endif /* USEGETWD */
- if ((clientData == NULL) || strcmp(buffer, (const char*)clientData)) {
+ if ((clientData == NULL) || strcmp(buffer, (const char *) clientData)) {
char *newCd = ckalloc(strlen(buffer) + 1);
strcpy(newCd, buffer);
@@ -767,7 +763,7 @@ TclpGetCwd(
if (getwd(buffer) == NULL) /* INTL: Native. */
#else
if (getcwd(buffer, MAXPATHLEN+1) == NULL) /* INTL: Native. */
-#endif
+#endif /* USEGETWD */
{
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -823,7 +819,7 @@ TclpReadlink(
return Tcl_DStringValue(linkPtr);
#else
return NULL;
-#endif
+#endif /* !DJGPP */
}
/*
@@ -857,7 +853,7 @@ TclpObjStat(
#ifdef S_IFLNK
-Tcl_Obj*
+Tcl_Obj *
TclpObjLink(
Tcl_Obj *pathPtr,
Tcl_Obj *toPtr,
@@ -1179,10 +1175,17 @@ TclpUtime(
{
return utime(Tcl_FSGetNativePath(pathPtr), tval);
}
+
#ifdef __CYGWIN__
-int TclOSstat(const char *name, Tcl_StatBuf *statBuf) {
+
+int
+TclOSstat(
+ const char *name,
+ Tcl_StatBuf *statBuf)
+{
struct stat buf;
int result = stat(name, &buf);
+
statBuf->st_mode = buf.st_mode;
statBuf->st_ino = buf.st_ino;
statBuf->st_dev = buf.st_dev;
@@ -1196,9 +1199,15 @@ int TclOSstat(const char *name, Tcl_StatBuf *statBuf) {
statBuf->st_ctime = buf.st_ctime;
return result;
}
-int TclOSlstat(const char *name, Tcl_StatBuf *statBuf) {
+
+int
+TclOSlstat(
+ const char *name,
+ Tcl_StatBuf *statBuf)
+{
struct stat buf;
int result = lstat(name, &buf);
+
statBuf->st_mode = buf.st_mode;
statBuf->st_ino = buf.st_ino;
statBuf->st_dev = buf.st_dev;
@@ -1212,7 +1221,7 @@ int TclOSlstat(const char *name, Tcl_StatBuf *statBuf) {
statBuf->st_ctime = buf.st_ctime;
return result;
}
-#endif
+#endif /* CYGWIN */
/*
* Local Variables: