Mercurial > vim
comparison src/misc2.c @ 2232:2e6906bbc5f4 vim73
A few more fixes for undo file. Split test in two parts so that it doesn't
fail with tiny features.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 30 May 2010 13:26:21 +0200 |
parents | aa6412cab544 |
children | 6b4879aea261 |
comparison
equal
deleted
inserted
replaced
2231:aa6412cab544 | 2232:2e6906bbc5f4 |
---|---|
6258 time_t wtime = the_time; | 6258 time_t wtime = the_time; |
6259 | 6259 |
6260 /* time_t can be up to 8 bytes in size, more than long_u, thus we | 6260 /* time_t can be up to 8 bytes in size, more than long_u, thus we |
6261 * can't use put_bytes() here. | 6261 * can't use put_bytes() here. |
6262 * Another problem is that ">>" may do an arithmetic shift that keeps the | 6262 * Another problem is that ">>" may do an arithmetic shift that keeps the |
6263 * sign. A cast to long_u may truncate if time_t is 8 bytes. So only use | 6263 * sign. This happens for large values of wtime. A cast to long_u may |
6264 * a cast when it is 4 bytes, it's safe to assume that long_u is 4 bytes | 6264 * truncate if time_t is 8 bytes. So only use a cast when it is 4 bytes, |
6265 * or more and when using 8 bytes the top bit won't be set. */ | 6265 * it's safe to assume that long_u is 4 bytes or more and when using 8 |
6266 * bytes the top bit won't be set. */ | |
6266 for (i = 7; i >= 0; --i) | 6267 for (i = 7; i >= 0; --i) |
6267 { | 6268 { |
6268 if (i + 1 > (int)sizeof(time_t)) | 6269 if (i + 1 > (int)sizeof(time_t)) |
6269 /* ">>" doesn't work well when shifting more bits than avail */ | 6270 /* ">>" doesn't work well when shifting more bits than avail */ |
6270 putc(0, fd); | 6271 putc(0, fd); |
6271 else | 6272 else |
6272 { | 6273 { |
6273 /* use "i" in condition to avoid compiler warning */ | 6274 #if defined(SIZEOF_TIME_T) && SIZEOF_TIME_T > 4 |
6274 if (i >= 0 && sizeof(time_t) > 4) | 6275 c = wtime >> (i * 8); |
6275 c = wtime >> (i * 8); | 6276 #else |
6276 else | 6277 c = (long_u)wtime >> (i * 8); |
6277 c = (long_u)wtime >> (i * 8); | 6278 #endif |
6278 putc(c, fd); | 6279 putc(c, fd); |
6279 } | 6280 } |
6280 } | 6281 } |
6281 } | 6282 } |
6282 | 6283 |