Cleanup: Use ELEM Macro
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user