From 8d3e26a08c2d3528276032ef2b4f40949bd3d08d Mon Sep 17 00:00:00 2001 From: dkf Date: Sat, 27 Sep 2008 19:47:24 +0000 Subject: Fix [Bug 2130726]. --- ChangeLog | 4 ++++ generic/tclFileName.c | 25 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 19043f7..4c2e048 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-09-27 Donal K. Fellows + * 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 } /* -- cgit v0.12