]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.2.x/2.2.7-fpformat.patch
Move
[bacula/bacula] / bacula / patches / 2.2.x / 2.2.7-fpformat.patch
1
2  This patch fixes a float point editing bug introduced in 2.2.7 (I think)
3  causing the rate fields to be formated incorrectly (actually trunctated).
4  This fixes bug #1036.
5
6  Apply it to version 2.2.7 with:
7
8  cd <bacula-source>
9  patch -p0 <2.2.7-fpformat.patch
10  ./configure <your-options>
11  make
12  ...
13  make install
14
15
16 Index: src/lib/bsnprintf.c
17 ===================================================================
18 --- src/lib/bsnprintf.c (revision 6183)
19 +++ src/lib/bsnprintf.c (working copy)
20 @@ -16,7 +16,7 @@
21  /*
22     Bacula® - The Network Backup Solution
23  
24 -   Copyright (C) 2005-2007 Free Software Foundation Europe e.V.
25 +   Copyright (C) 2005-2008 Free Software Foundation Europe e.V.
26  
27     The main author of Bacula is Kern Sibbald, with contributions from
28     many others, a complete list can be found in the file AUTHORS.
29 @@ -566,11 +566,11 @@
30     return result;
31  }
32  
33 -static long round(LDOUBLE value)
34 +static int64_t round(LDOUBLE value)
35  {
36 -   long intpart;
37 +   int64_t intpart;
38  
39 -   intpart = (long)value;
40 +   intpart = (int64_t)value;
41     value = value - intpart;
42     if (value >= 0.5)
43        intpart++;
44 @@ -584,8 +584,8 @@
45     int signvalue = 0;
46     LDOUBLE ufvalue;
47  #ifndef HAVE_FCVT
48 -   char iconvert[25];
49 -   char fconvert[25];
50 +   char iconvert[311];
51 +   char fconvert[311];
52  #else
53     char iconvert[311];
54     char fconvert[311];
55 @@ -602,6 +602,7 @@
56     int caps = 0;
57     int64_t intpart;
58     int64_t fracpart;
59 +   const char *cvt_str;
60  
61     /* 
62      * AIX manpage says the default is 0, but Solaris says the default
63 @@ -625,7 +626,7 @@
64  #endif
65  
66  #ifndef HAVE_FCVT
67 -   intpart = (long)ufvalue;
68 +   intpart = (int64_t)ufvalue;
69  
70     /* 
71      * Sorry, we only support 9 digits past the decimal because of our 
72 @@ -645,28 +646,30 @@
73     }
74  
75  #ifdef DEBUG_SNPRINTF
76 -   printf("fmtfp: %g %d.%d min=%d max=%d\n",
77 +   printf("fmtfp: %g %lld.%lld min=%d max=%d\n",
78            (double)fvalue, intpart, fracpart, min, max);
79  #endif
80  
81     /* Convert integer part */
82 +   cvt_str = caps ? "0123456789ABCDEF" : "0123456789abcdef";
83     do {
84 -      iconvert[iplace++] =
85 -         (caps ? "0123456789ABCDEF" : "0123456789abcdef")[intpart % 10];
86 +      iconvert[iplace++] = cvt_str[(int)(intpart % 10)];
87        intpart = (intpart / 10);
88 -   } while (intpart && (iplace < (int)sizeof(iplace)));
89 -   if (iplace == (int)sizeof(iplace)) {
90 +   } while (intpart && (iplace < (int)sizeof(iconvert)));
91 +
92 +   if (iplace == (int)sizeof(fconvert)) {
93        iplace--;
94     }
95     iconvert[iplace] = 0;
96  
97     /* Convert fractional part */
98 +   cvt_str = caps ? "0123456789ABCDEF" : "0123456789abcdef";
99     do {
100 -      fconvert[fplace++] =
101 -         (caps ? "0123456789ABCDEF" : "0123456789abcdef")[fracpart % 10];
102 +      fconvert[fplace++] = cvt_str[fracpart % 10];
103        fracpart = (fracpart / 10);
104 -   } while (fracpart && (fplace < (int)sizeof(fplace)));
105 -   if (fplace == (int)sizeof(fplace)) {
106 +   } while (fracpart && (fplace < (int)sizeof(fconvert)));
107 +
108 +   if (fplace == (int)sizeof(fconvert)) {
109        fplace--;
110     }
111     fconvert[fplace] = 0;
112 @@ -825,7 +828,7 @@
113        NULL
114     };
115     double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
116 -      0.9996, 1.996, 4.136, 6442452944.1234, 0
117 +      0.9996, 1.996, 4.136, 6442452944.1234, 0, 23365.5
118     };
119  #endif
120     char *int_fmt[] = {