summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-09-27 19:47:24 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-09-27 19:47:24 (GMT)
commit8d3e26a08c2d3528276032ef2b4f40949bd3d08d (patch)
tree373293868711b69f211b994cbbe5ba95905f9623
parent415263df239b3d23328d8af5672477b6d5d7c77c (diff)
downloadtcl-8d3e26a08c2d3528276032ef2b4f40949bd3d08d.zip
tcl-8d3e26a08c2d3528276032ef2b4f40949bd3d08d.tar.gz
tcl-8d3e26a08c2d3528276032ef2b4f40949bd3d08d.tar.bz2
Fix [Bug 2130726].
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclFileName.c25
2 files changed, 28 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 19043f7..4c2e048 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2008-09-27 Donal K. Fellows <dkf@users.sf.net>
+ * generic/tclFileName.c (Tcl_GetBlock*FromStat): Made this work
+ acceptably when working with OSes that don't support reporting the
+ block size from the stat() call. [Bug 2130726]
+
* generic/tclCmdIL.c (Tcl_LrepeatObjCmd): Improve the handling of the
case where the combination of number of elements and repeat count
causes the resulting list to be too large. [Bug 2130992]
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index 00c7067..9ff6c07 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclFileName.c,v 1.91 2008/09/24 09:41:20 dkf Exp $
+ * RCS: @(#) $Id: tclFileName.c,v 1.92 2008/09/27 19:47:29 dkf Exp $
*/
#include "tclInt.h"
@@ -39,6 +39,16 @@ static Tcl_Obj * SplitUnixPath(const char *path);
static int DoGlob(Tcl_Interp *interp, Tcl_Obj *resultPtr,
const char *separators, Tcl_Obj *pathPtr, int flags,
char *pattern, Tcl_GlobTypeData *types);
+
+/*
+ * When there is no support for getting the block size of a file in a stat()
+ * call, use this as a guess. Allow it to be overridden in the platform-
+ * specific files.
+ */
+
+#if (!defined(HAVE_ST_BLOCKS) && !defined(GUESSED_BLOCK_SIZE))
+#define GUESSED_BLOCK_SIZE 1024
+#endif
/*
*----------------------------------------------------------------------
@@ -2625,14 +2635,27 @@ Tcl_WideUInt
Tcl_GetBlocksFromStat(
const Tcl_StatBuf *statPtr)
{
+#ifdef HAVE_ST_BLOCKS
return (Tcl_WideUInt) statPtr->st_blocks;
+#else
+ return ((Tcl_WideUInt) statPtr->st_size
+ + (GUESSED_BLOCK_SIZE-1)) / GUESSED_BLOCK_SIZE;
+#endif
}
unsigned
Tcl_GetBlockSizeFromStat(
const Tcl_StatBuf *statPtr)
{
+#ifdef HAVE_ST_BLOCKS
return (unsigned) statPtr->st_blksize;
+#else
+ /*
+ * Not a great guess, but will do...
+ */
+
+ return GUESSED_BLOCK_SIZE;
+#endif
}
/*