[Bf-blender-cvs] [a4e0bccb87b] master: Cleanup: Use ELEM Macro

Hans Goudey noreply at git.blender.org
Wed Jun 3 19:34:31 CEST 2020


Commit: a4e0bccb87bbcc6ff6f36a428aa402576de5f9ec
Author: Hans Goudey
Date:   Wed Jun 3 13:34:24 2020 -0400
Branches: master
https://developer.blender.org/rBa4e0bccb87bbcc6ff6f36a428aa402576de5f9ec

Cleanup: Use ELEM Macro

===================================================================

M	source/blender/blenkernel/intern/unit.c

===================================================================

diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index bb895304b84..a8136dd7932 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -728,7 +728,7 @@ static char *find_next_negative(const char *str, const char *remaining_str)
   }
 
   /* Don't use the "-" from scientific notation, but make sure we can look backwards first. */
-  if ((str_found != str) && (*(str_found - 1) == 'e' || *(str_found - 1) == 'E')) {
+  if ((str_found != str) && ELEM(*(str_found - 1), 'e', 'E')) {
     return find_next_negative(str, str_found + 1);
   }
 
@@ -803,13 +803,13 @@ static bool unit_distribute_negatives(char *str, const int len_max)
     changed = true;
 
     /* Add '(', shift the following characters to the right to make space. */
-    memmove(remaining_str + 1, remaining_str, remaining_str_len - 1);
+    memmove(remaining_str + 1, remaining_str, remaining_str_len - 2);
     *remaining_str = '(';
 
     /* Add the ')' before the next operation or at the end. */
     remaining_str = find_next_op(str, remaining_str + 1, remaining_str_len);
     remaining_str_len = len_max - (int)(remaining_str - str);
-    memmove(remaining_str + 1, remaining_str, remaining_str_len - 1);
+    memmove(remaining_str + 1, remaining_str, remaining_str_len - 2);
     *remaining_str = ')';
 
     /* Only move forward by 1 even though we added two characters. Minus signs need to be able to
@@ -1005,6 +1005,7 @@ bool bUnit_ReplaceString(
 
   /* Fix cases like "-1m50cm" which would evaluate to -0.5m without this. */
   changed |= unit_distribute_negatives(str, len_max);
+  printf("%s\n", str);
 
   /* Try to find a default unit from current or previous string. */
   default_unit = unit_detect_from_str(usys, str, str_prev);



More information about the Bf-blender-cvs mailing list