Geeksltd / GCop

GCop packages
https://geeksltd.github.io/GCop/
24 stars 8 forks source link

GCop178 does not disappear #288

Open sungam3r opened 5 years ago

sungam3r commented 5 years ago
     public static string ReplaceUnaryMinus(string formula)
        {
            var newFormula = new StringBuilder();
            string prev = formula[0].ToString();
            for (int i = 0; i < formula.Length; i++)
            {
                char symbol = formula[i];
                if (symbol == '-' && (prev != ")" && definedOperators.ContainsKey(prev) || prev == "=")) // GCop178
                {
                    newFormula.Append(UNARY_MINUS);
                }
                else
                {
                    newFormula.Append(symbol);
                }

                prev = symbol.ToString();
            }

            return newFormula.ToString();
        }

After quick fix:

 public static string ReplaceUnaryMinus(string formula)
        {
            var newFormula = new StringBuilder();
            string prev = formula[0].ToString();
            for (int i = 0; i < formula.Length; i++)
            {
                char symbol = formula[i];
                if (symbol == '-' && ((prev != ")" && definedOperators.ContainsKey(prev)) || prev == "=")) // still GCop178
                {
                    newFormula.Append(UNARY_MINUS);
                }
                else
                {
                    newFormula.Append(symbol);
                }

                prev = symbol.ToString();
            }

            return newFormula.ToString();
        }