On 5/25/07, John Beckett <[EMAIL PROTECTED]> wrote:
A.J.Mechelynck wrote:
> What about a different function to return, say, the number of
> 1K blocks (or the number of times 2^n bytes, with a parameter
> passed to the function) that a file uses?

Yes, that's a much more general and better idea.

Since there's probably not much need for this, I think that
simplicity would be good. That is, have the function work in a
fixed way with no options.

Re Dr.Chip's LargeFile script: It occurs to me that another
workaround would be to use system() to capture the output of
'ls -l file' or 'dir file' (need an option for which).

Then do some funky editing to calculate the number of digits in
the file length. If more than 9, treat file as large.

9-digit number can still be larger than 2^32-1, or than 2^31-1. It's
possible to compare large numbers safely with the following method:
(1) right-align them to fixed with (say, to width 20 to be on the
safe side), then
(2) prepend non-ditit  character on the left to prevent vim from terating them
     as string and getting numeric overflow, then
(3) compare them as strings.
Like this:

bignum1="987654321"
bignum2="876543210"
x=printf("x%20s", bignum1) " do not use %d to avoid overflow, use %s
y=printf("x%20s", bignum2) " do not use %d to avoid overflow, use %s
if x > y
  "bignum1 is bigger than bignum2
endif

Yakov

Reply via email to