aboutsummaryrefslogtreecommitdiffstats
path: root/math/gcalctool/files/patch-gcalctool::get.c
diff options
context:
space:
mode:
Diffstat (limited to 'math/gcalctool/files/patch-gcalctool::get.c')
-rw-r--r--math/gcalctool/files/patch-gcalctool::get.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/math/gcalctool/files/patch-gcalctool::get.c b/math/gcalctool/files/patch-gcalctool::get.c
new file mode 100644
index 000000000000..2c91de180eac
--- /dev/null
+++ b/math/gcalctool/files/patch-gcalctool::get.c
@@ -0,0 +1,46 @@
+--- gcalctool/get.c.orig Thu Nov 27 05:29:52 2003
++++ gcalctool/get.c Sat Dec 6 17:50:52 2003
+@@ -125,7 +125,6 @@
+ {
+ char *radix_char;
+
+- setlocale(LC_NUMERIC, "");
+ radix_char = nl_langinfo(RADIXCHAR);
+
+ return(radix_char[0]);
+@@ -220,8 +219,9 @@
+ {
+ char *tsep_char;
+
+- setlocale(LC_NUMERIC, "");
+ tsep_char = nl_langinfo(THOUSEP);
++ if (!*tsep_char)
++ return ' ';
+
+ return(tsep_char[0]);
+ }
+@@ -231,6 +231,7 @@
+ init_vars() /* Setup default values for various variables. */
+ {
+ int acc, i, n, size;
++ char lrc;
+
+ v->accuracy = 9; /* Initial accuracy. */
+ v->show_zeroes = FALSE; /* Don't show trailing zeroes. */
+@@ -253,6 +254,8 @@
+
+ read_str(&v->iconlabel, _("calculator")); /* Default icon label. */
+
++ lrc = v->radix_char;
++ v->radix_char = '.';
+ MPstr_to_num("0.621", DEC, v->MPcon_vals[0]); /* kms/hr <=> miles/hr. */
+ MPstr_to_num("1.4142135623", DEC, v->MPcon_vals[1]); /* square root of 2 */
+ MPstr_to_num("2.7182818284", DEC, v->MPcon_vals[2]); /* e */
+@@ -263,6 +266,7 @@
+ MPstr_to_num("0.0353", DEC, v->MPcon_vals[7]); /* grams <=> ounce. */
+ MPstr_to_num("0.948", DEC, v->MPcon_vals[8]); /* Kjoules <=> BTU's. */
+ MPstr_to_num("0.0610", DEC, v->MPcon_vals[9]); /* cms3 <=> inches3. */
++ v->radix_char = lrc;
+
+ n = 0;
+ for (i = 0; i < MAXREGS; i++) {
, core/*, params: metropolis preparation refactor' href='/~lantw44/cgit/go-tangerine/commit/consensus/ethash/consensus_test.go?h=origin&id=10a57fc3d45cbc59d6c8eeb0f7f2b93a71e8f4c9'>10a57fc3d
af401d03a
10a57fc3d

09777952e




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86





















                                                                                  
                       


                                                     
                                                    
































                                                                           
                                                                                                             
                       
                           









                                                                          
 

                                                                                  

                                                                                    
                                                         

                                                          




                                                                                                         
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package ethash

import (
    "encoding/json"
    "math/big"
    "os"
    "path/filepath"
    "testing"

    "github.com/ethereum/go-ethereum/common/math"
    "github.com/ethereum/go-ethereum/core/types"
    "github.com/ethereum/go-ethereum/params"
)

type diffTest struct {
    ParentTimestamp    uint64
    ParentDifficulty   *big.Int
    CurrentTimestamp   uint64
    CurrentBlocknumber *big.Int
    CurrentDifficulty  *big.Int
}

func (d *diffTest) UnmarshalJSON(b []byte) (err error) {
    var ext struct {
        ParentTimestamp    string
        ParentDifficulty   string
        CurrentTimestamp   string
        CurrentBlocknumber string
        CurrentDifficulty  string
    }
    if err := json.Unmarshal(b, &ext); err != nil {
        return err
    }

    d.ParentTimestamp = math.MustParseUint64(ext.ParentTimestamp)
    d.ParentDifficulty = math.MustParseBig256(ext.ParentDifficulty)
    d.CurrentTimestamp = math.MustParseUint64(ext.CurrentTimestamp)
    d.CurrentBlocknumber = math.MustParseBig256(ext.CurrentBlocknumber)
    d.CurrentDifficulty = math.MustParseBig256(ext.CurrentDifficulty)

    return nil
}

func TestCalcDifficulty(t *testing.T) {
    file, err := os.Open(filepath.Join("..", "..", "tests", "testdata", "BasicTests", "difficulty.json"))
    if err != nil {
        t.Skip(err)
    }
    defer file.Close()

    tests := make(map[string]diffTest)
    err = json.NewDecoder(file).Decode(&tests)
    if err != nil {
        t.Fatal(err)
    }

    config := &params.ChainConfig{HomesteadBlock: big.NewInt(1150000)}

    for name, test := range tests {
        number := new(big.Int).Sub(test.CurrentBlocknumber, big.NewInt(1))
        diff := CalcDifficulty(config, test.CurrentTimestamp, &types.Header{
            Number:     number,
            Time:       test.ParentTimestamp,
            Difficulty: test.ParentDifficulty,
        })
        if diff.Cmp(test.CurrentDifficulty) != 0 {
            t.Error(name, "failed. Expected", test.CurrentDifficulty, "and calculated", diff)
        }
    }
}