Skip to content

Commit 57a8bf6

Browse files
committed
Use standard function declaration style instead of K&R in libbcmath
Fixes [-Wstrict-prototypes] warnings.
1 parent a6a95e3 commit 57a8bf6

File tree

5 files changed

+36
-76
lines changed

5 files changed

+36
-76
lines changed

ext/bcmath/libbcmath/src/bcmath.h

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -88,66 +88,51 @@ typedef struct bc_struct
8888

8989
/* Function Prototypes */
9090

91-
/* Define the _PROTOTYPE macro if it is needed. */
91+
void bc_init_numbers(void);
9292

93-
#ifndef _PROTOTYPE
94-
#if defined(__STDC__) || defined(PHP_WIN32) && defined(__clang__)
95-
#define _PROTOTYPE(func, args) func args
96-
#else
97-
#define _PROTOTYPE(func, args) func()
98-
#endif
99-
#endif
100-
101-
_PROTOTYPE(void bc_init_numbers, (void));
102-
103-
_PROTOTYPE(bc_num _bc_new_num_ex, (int length, int scale, int persistent));
93+
bc_num _bc_new_num_ex(int length, int scale, int persistent);
10494

105-
_PROTOTYPE(void _bc_free_num_ex, (bc_num *num, int persistent));
95+
void _bc_free_num_ex(bc_num *num, int persistent);
10696

107-
_PROTOTYPE(bc_num bc_copy_num, (bc_num num));
97+
bc_num bc_copy_num(bc_num num);
10898

109-
_PROTOTYPE(void bc_init_num, (bc_num *num));
99+
void bc_init_num(bc_num *num);
110100

111-
_PROTOTYPE(int bc_str2num, (bc_num *num, char *str, int scale));
101+
int bc_str2num(bc_num *num, char *str, int scale);
112102

113-
_PROTOTYPE(zend_string *bc_num2str_ex, (bc_num num, int scale));
103+
zend_string *bc_num2str_ex(bc_num num, int scale);
114104

115-
_PROTOTYPE(void bc_int2num, (bc_num *num, int val));
105+
void bc_int2num(bc_num *num, int val);
116106

117-
_PROTOTYPE(long bc_num2long, (bc_num num));
107+
long bc_num2long(bc_num num);
118108

119-
_PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2));
109+
int bc_compare(bc_num n1, bc_num n2);
120110

121-
_PROTOTYPE(char bc_is_zero, (bc_num num));
111+
char bc_is_zero(bc_num num);
122112

123-
_PROTOTYPE(char bc_is_near_zero, (bc_num num, int scale));
113+
char bc_is_near_zero(bc_num num, int scale);
124114

125-
_PROTOTYPE(char bc_is_neg, (bc_num num));
115+
char bc_is_neg(bc_num num);
126116

127-
_PROTOTYPE(void bc_add, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
117+
void bc_add(bc_num n1, bc_num n2, bc_num *result, int scale_min);
128118

129-
_PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result, int scale_min));
119+
void bc_sub(bc_num n1, bc_num n2, bc_num *result, int scale_min);
130120

131-
_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale));
121+
void bc_multiply(bc_num n1, bc_num n2, bc_num *prod, int scale);
132122

133-
_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale));
123+
int bc_divide(bc_num n1, bc_num n2, bc_num *quot, int scale);
134124

135-
_PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result,
136-
int scale));
125+
int bc_modulo(bc_num num1, bc_num num2, bc_num *resul, int scale);
137126

138-
_PROTOTYPE(int bc_divmod, (bc_num num1, bc_num num2, bc_num *quot,
139-
bc_num *rem, int scale));
127+
int bc_divmod(bc_num num1, bc_num num2, bc_num *quo, bc_num *rem, int scale);
140128

141-
_PROTOTYPE(int bc_raisemod, (bc_num base, bc_num expo, bc_num mod,
142-
bc_num *result, int scale));
129+
int bc_raisemod(bc_num base, bc_num expo, bc_num mo, bc_num *result, int scale);
143130

144-
_PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result,
145-
int scale));
131+
void bc_raise(bc_num num1, bc_num num2, bc_num *resul, int scale);
146132

147-
_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale));
133+
int bc_sqrt(bc_num *num, int scale);
148134

149-
_PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int),
150-
int leading_zero));
135+
void bc_out_num(bc_num num, int o_base, void (* out_char)(char), int leading_zero);
151136

152137
/* Prototypes needed for external utility routines. */
153138
#define bc_new_num(length, scale) _bc_new_num_ex((length), (scale), 0)

ext/bcmath/libbcmath/src/debug.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,21 @@
3939

4040
/* pn prints the number NUM in base 10. */
4141

42-
static void
43-
out_char (int c)
42+
static void out_char (char c)
4443
{
4544
putchar(c);
4645
}
4746

4847

49-
void
50-
pn (bc_num num)
48+
void pn (bc_num num)
5149
{
52-
bc_out_num (num, 10, out_char, 0);
50+
bc_out_num(num, 10, out_char, 0);
5351
out_char ('\n');
5452
}
5553

5654

5755
/* pv prints a character array as if it was a string of bcd digits. */
58-
void
59-
pv (name, num, len)
60-
char *name;
61-
unsigned char *num;
62-
int len;
56+
void pv (char *name, unsigned char *num, int len)
6357
{
6458
int i;
6559
printf ("%s=", name);

ext/bcmath/libbcmath/src/div.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@
4343
placed into RESULT. It is written so that NUM and RESULT can be
4444
the same pointers. */
4545

46-
static void
47-
_one_mult (num, size, digit, result)
48-
unsigned char *num;
49-
int size, digit;
50-
unsigned char *result;
46+
static void _one_mult (unsigned char *num, int size, int digit, unsigned char *result)
5147
{
5248
int carry, value;
5349
unsigned char *nptr, *rptr;

ext/bcmath/libbcmath/src/output.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,10 @@ static char ref_str[] = "0123456789ABCDEF";
5656
non-zero, we must output one space before the number. OUT_CHAR
5757
is the actual routine for writing the characters. */
5858

59-
void
60-
bc_out_long (val, size, space, out_char)
61-
long val;
62-
int size, space;
63-
#ifdef __STDC__
64-
void (*out_char)(int);
65-
#else
66-
void (*out_char)();
67-
#endif
59+
void bc_out_long (long val, size_t size, bool space, void (*out_char)(char) )
6860
{
6961
char digits[40];
70-
int len, ix;
62+
size_t len, ix;
7163

7264
if (space) (*out_char) (' ');
7365
snprintf(digits, sizeof(digits), "%ld", val);
@@ -84,15 +76,11 @@ bc_out_long (val, size, space, out_char)
8476
/* Output of a bcd number. NUM is written in base O_BASE using OUT_CHAR
8577
as the routine to do the actual output of the characters. */
8678

87-
void
88-
#ifdef __STDC__
89-
bc_out_num (bc_num num, int o_base, void (*out_char)(int), int leading_zero)
90-
#else
91-
bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero)
92-
#endif
79+
void bc_out_num (bc_num num, int o_base, void (*out_char)(char), int leading_zero)
9380
{
9481
char *nptr;
95-
int index, fdigit, pre_space;
82+
int index, fdigit;
83+
bool pre_space;
9684
stk_rec *digits, *temp;
9785
bc_num int_part, frac_part, base, cur_dig, t_num, max_o_digit;
9886

@@ -178,7 +166,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero)
178166
if (num->n_scale > 0)
179167
{
180168
(*out_char) ('.');
181-
pre_space = 0;
169+
pre_space = false;
182170
t_num = bc_copy_num (BCG(_one_));
183171
while (t_num->n_len <= num->n_scale) {
184172
bc_multiply (frac_part, base, &frac_part, num->n_scale);
@@ -189,7 +177,7 @@ bc_out_num (bc_num num, int o_base, void (*out_char)(), int leading_zero)
189177
(*out_char) (ref_str[fdigit]);
190178
else {
191179
bc_out_long (fdigit, max_o_digit->n_len, pre_space, out_char);
192-
pre_space = 1;
180+
pre_space = true;
193181
}
194182
bc_multiply (t_num, base, &t_num, 0);
195183
}

ext/bcmath/libbcmath/src/recmul.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ int mul_base_digits = MUL_BASE_DIGITS;
5050

5151
/* Multiply utility routines */
5252

53-
static bc_num
54-
new_sub_num (length, scale, value)
55-
int length, scale;
56-
char *value;
53+
static bc_num new_sub_num(int length, int scale, char *value)
5754
{
5855
bc_num temp;
5956

0 commit comments

Comments
 (0)