comparison src/register.c @ 26083:a677aa897843 v8.2.3575

patch 8.2.3575: overflow check still fails when sizeof(int) == sizeof(long) Commit: https://github.com/vim/vim/commit/e551ccfb9311eea5252d1c3106ff7a53c762d994 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 2 23:11:00 2021 +0000 patch 8.2.3575: overflow check still fails when sizeof(int) == sizeof(long) Problem: Overflow check still fails when sizeof(int) == sizeof(long). Solution: Use a float to check the result.
author Bram Moolenaar <Bram@vim.org>
date Wed, 03 Nov 2021 00:15:04 +0100
parents 6b6163d42b22
children 14a55d1520f2
comparison
equal deleted inserted replaced
26082:b09f70b14a30 26083:a677aa897843
2009 getvcol(curwin, &pos, NULL, &vcol, NULL); 2009 getvcol(curwin, &pos, NULL, &vcol, NULL);
2010 } 2010 }
2011 } 2011 }
2012 2012
2013 do { 2013 do {
2014 #ifdef FEAT_FLOAT
2015 double multlen = (double)count * (double)yanklen;
2016
2017 totlen = count * yanklen;
2018 if ((double)totlen != multlen)
2019 #else
2014 long multlen = count * yanklen; 2020 long multlen = count * yanklen;
2015 2021
2022 // this only works when sizeof(int) != sizeof(long)
2016 totlen = multlen; 2023 totlen = multlen;
2017 if (count != 0 && yanklen != 0 2024 if (totlen != multlen)
2018 && (totlen != multlen || totlen / count != yanklen 2025 #endif
2019 || totlen / yanklen != count))
2020 { 2026 {
2021 emsg(_(e_resulting_text_too_long)); 2027 emsg(_(e_resulting_text_too_long));
2022 break; 2028 break;
2023 } 2029 }
2024 else if (totlen > 0) 2030 else if (totlen > 0)