From e6739ed91d5c4f34f6fbac88734ee1ba71bc6b6f Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 5 Nov 2020 11:32:04 +0100 Subject: Fix T82407: Negative number input gives syntax error for velocities and accelerations Caused by rB45dbc38a8b15. Above commit would place parentheses surrounding a block until the next operator was found. For velocities and accelerations though, the '/' in 'm/s' or 'ft/s' should not be considered an operator. Maniphest Tasks: T82407 Differential Revision: https://developer.blender.org/D9467 --- source/blender/blenkernel/intern/unit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index a5418b8b8c5..73bf149bf2a 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -815,6 +815,12 @@ static char *find_next_op(const char *str, char *remaining_str, int len_max) /* Make sure we don't look backwards before the start of the string. */ if (remaining_str != str && i != 0) { + /* Check for velocity or acceleration (e.g. '/' in 'ft/s' is not an op). */ + if ((remaining_str[i] == '/') && ELEM(remaining_str[i - 1], 't', 'T', 'm', 'M') && + ELEM(remaining_str[i + 1], 's', 'S')) { + continue; + } + /* Check for scientific notation. */ if (remaining_str[i - 1] == 'e' || remaining_str[i - 1] == 'E') { scientific_notation = true; -- cgit v1.2.3