From c3ee1111f98b491e24f715972d76597043ccad17 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 12 May 2023 03:54:19 +0300 Subject: [PATCH] Fix double negative signs in mask/paste margin overrides. (cherry picked from commit efbd360440b730260060f8648bd578bdde3ecadc) --- .githooks/pre-commit | 50 +++++++++++++++++++++++++++++++++- common/widgets/unit_binder.cpp | 4 +-- 2 files changed, 51 insertions(+), 3 deletions(-) mode change 120000 => 100644 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 120000 index 84d936b2f1..0000000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1 +0,0 @@ -hook-chain \ No newline at end of file diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000000..dacab7579a --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# Git "hook chain", used to execute multiple scripts per hook. +# To use: +# * create a directory called .d +# * add scripts to this directory (executable) +# * ln -s hook-chain +# +# Now the scripts in that directory should be called in order. +# +# Set $HOOKCHAIN_DEBUG to see the names of invoked scripts. +# +# Based on script by Oliver Reflalo: +# https://stackoverflow.com/questions/8730514/chaining-git-hooks +# + +hookname=`basename $0` + +# Temp file for stdin, cleared at exit +FILE=`mktemp` +trap 'rm -f $FILE' EXIT +cat - > $FILE + +# Git hooks directory (this dir) +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +# Execute hooks in the directory one by one +for hook in $DIR/$hookname.d/*; +do + if [ -x "$hook" ]; then + + if [ "$HOOKCHAIN_DEBUG" ]; then + echo "Running hook $hook" + fi + + cat $FILE | $hook "$@" + status=$? + + if [ $status -ne 0 ]; then + echo "Hook $hook failed with error code $status" + echo "To commit anyway, use --no-verify" + exit $status + else + if [ "$HOOKCHAIN_DEBUG" ]; then + echo "Hook passed: $hook" + fi + fi + fi +done diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index ec0b72ac76..732e667a4f 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -361,7 +361,7 @@ void UNIT_BINDER::SetDoubleValue( double aValue ) setPrecision( displayValue, false ), false, m_dataType ); - if( displayValue == 0 && m_negativeZero ) + if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero ) SetValue( wxT( "-" ) + textValue ); else SetValue( textValue ); @@ -424,7 +424,7 @@ void UNIT_BINDER::ChangeDoubleValue( double aValue ) setPrecision( displayValue, false ), false, m_dataType ); - if( displayValue == 0 && m_negativeZero ) + if( displayValue == 0 && !std::signbit( displayValue ) && m_negativeZero ) ChangeValue( wxT( "-" ) + textValue ); else ChangeValue( textValue );