comparison src/eval.c @ 24780:7bc92a651472 v8.2.2928

patch 8.2.2928: the evalfunc.c file is too big Commit: https://github.com/vim/vim/commit/01c798c31a94a50ad0c4a022fc21c1a31553be21 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jun 2 17:07:18 2021 +0200 patch 8.2.2928: the evalfunc.c file is too big Problem: The evalfunc.c file is too big. Solution: Move float related functionality to a separate file. (Yegappan Lakshmanan, closes #8287)
author Bram Moolenaar <Bram@vim.org>
date Wed, 02 Jun 2021 17:15:03 +0200
parents e75971b83263
children 8fdf839af1f4
comparison
equal deleted inserted replaced
24779:3675d97a795e 24780:7bc92a651472
5153 *r++ = NUL; 5153 *r++ = NUL;
5154 } 5154 }
5155 return s; 5155 return s;
5156 } 5156 }
5157 5157
5158 #if defined(FEAT_FLOAT) || defined(PROTO)
5159 /*
5160 * Convert the string "text" to a floating point number.
5161 * This uses strtod(). setlocale(LC_NUMERIC, "C") has been used to make sure
5162 * this always uses a decimal point.
5163 * Returns the length of the text that was consumed.
5164 */
5165 int
5166 string2float(
5167 char_u *text,
5168 float_T *value) // result stored here
5169 {
5170 char *s = (char *)text;
5171 float_T f;
5172
5173 // MS-Windows does not deal with "inf" and "nan" properly.
5174 if (STRNICMP(text, "inf", 3) == 0)
5175 {
5176 *value = INFINITY;
5177 return 3;
5178 }
5179 if (STRNICMP(text, "-inf", 3) == 0)
5180 {
5181 *value = -INFINITY;
5182 return 4;
5183 }
5184 if (STRNICMP(text, "nan", 3) == 0)
5185 {
5186 *value = NAN;
5187 return 3;
5188 }
5189 f = strtod(s, &s);
5190 *value = f;
5191 return (int)((char_u *)s - text);
5192 }
5193 #endif
5194
5195 /* 5158 /*
5196 * Convert the specified byte index of line 'lnum' in buffer 'buf' to a 5159 * Convert the specified byte index of line 'lnum' in buffer 'buf' to a
5197 * character index. Works only for loaded buffers. Returns -1 on failure. 5160 * character index. Works only for loaded buffers. Returns -1 on failure.
5198 * The index of the first byte and the first character is zero. 5161 * The index of the first byte and the first character is zero.
5199 */ 5162 */