diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-14 13:22:17 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-14 13:22:17 +0100 |
commit | 0a8fed6231c84e4e1b3a7dd6c0d95d3f98207fe0 (patch) | |
tree | b0545af3bfa25ced1890c33fe9c1facf1e749358 /src/misc2.c | |
parent | f2cecb6c10909184281e31a8f968200f3841562d (diff) | |
download | vim-git-0a8fed6231c84e4e1b3a7dd6c0d95d3f98207fe0.tar.gz |
patch 8.2.0256: time and timer related code is spread outv8.2.0256
Problem: Time and timer related code is spread out.
Solution: Move time and timer related code to a new file. (Yegappan
Lakshmanan, closes #5604)
Diffstat (limited to 'src/misc2.c')
-rw-r--r-- | src/misc2.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/misc2.c b/src/misc2.c index c0208de26..6ef420cab 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -4127,26 +4127,6 @@ get4c(FILE *fd) } /* - * Read 8 bytes from "fd" and turn them into a time_T, MSB first. - * Returns -1 when encountering EOF. - */ - time_T -get8ctime(FILE *fd) -{ - int c; - time_T n = 0; - int i; - - for (i = 0; i < 8; ++i) - { - c = getc(fd); - if (c == EOF) return -1; - n = (n << 8) + c; - } - return n; -} - -/* * Read a string of length "cnt" from "fd" into allocated memory. * Returns NULL when out of memory or unable to read that many bytes. */ @@ -4191,68 +4171,6 @@ put_bytes(FILE *fd, long_u nr, int len) return OK; } -#ifdef _MSC_VER -# if (_MSC_VER <= 1200) -// This line is required for VC6 without the service pack. Also see the -// matching #pragma below. - # pragma optimize("", off) -# endif -#endif - -/* - * Write time_T to file "fd" in 8 bytes. - * Returns FAIL when the write failed. - */ - int -put_time(FILE *fd, time_T the_time) -{ - char_u buf[8]; - - time_to_bytes(the_time, buf); - return fwrite(buf, (size_t)8, (size_t)1, fd) == 1 ? OK : FAIL; -} - -/* - * Write time_T to "buf[8]". - */ - void -time_to_bytes(time_T the_time, char_u *buf) -{ - int c; - int i; - int bi = 0; - time_T wtime = the_time; - - // time_T can be up to 8 bytes in size, more than long_u, thus we - // can't use put_bytes() here. - // Another problem is that ">>" may do an arithmetic shift that keeps the - // sign. This happens for large values of wtime. A cast to long_u may - // truncate if time_T is 8 bytes. So only use a cast when it is 4 bytes, - // it's safe to assume that long_u is 4 bytes or more and when using 8 - // bytes the top bit won't be set. - for (i = 7; i >= 0; --i) - { - if (i + 1 > (int)sizeof(time_T)) - // ">>" doesn't work well when shifting more bits than avail - buf[bi++] = 0; - else - { -#if defined(SIZEOF_TIME_T) && SIZEOF_TIME_T > 4 - c = (int)(wtime >> (i * 8)); -#else - c = (int)((long_u)wtime >> (i * 8)); -#endif - buf[bi++] = c; - } - } -} - -#ifdef _MSC_VER -# if (_MSC_VER <= 1200) - # pragma optimize("", on) -# endif -#endif - #endif #if defined(FEAT_QUICKFIX) || defined(FEAT_SPELL) || defined(PROTO) |