comparison mercurial/mpatch.c @ 38191:b8b253aec953 stable

mpatch: introduce a safesub() helper as well Same reason as safeadd().
author Augie Fackler <augie@google.com>
date Thu, 03 May 2018 12:54:20 -0400
parents 1ec4cb8cbc87
children 0b208c13781c
comparison
equal deleted inserted replaced
38190:1ec4cb8cbc87 38191:b8b253aec953
83 return false; 83 return false;
84 } 84 }
85 } 85 }
86 } 86 }
87 *dest += src; 87 *dest += src;
88 return true;
89 }
90
91 /* subtract src from dest and store result in dest */
92 static inline bool safesub(int src, int *dest)
93 {
94 if (((src > 0) && (*dest < INT_MIN + src)) ||
95 ((src < 0) && (*dest > INT_MAX + src))) {
96 return false;
97 }
98 *dest -= src;
88 return true; 99 return true;
89 } 100 }
90 101
91 /* move hunks in source that are less cut to dest, compensating 102 /* move hunks in source that are less cut to dest, compensating
92 for changes in offset. the last hunk may be split if necessary. 103 for changes in offset. the last hunk may be split if necessary.