# vim: vim-7.2-floating_point.patch

File vim-7.2-floating_point.patch, 7.1 KB (added by , 14 years ago) |
---|

Line | |
---|---|

1 | *** src/eval.c.bram Sat Aug 09 11:28:58 2008 |

2 | --- src/eval.c Sat Aug 09 23:50:33 2008 |

3 | *************** |

4 | *** 466,471 **** |

5 | --- 466,486 ---- |

6 | |

7 | #ifdef FEAT_FLOAT |

8 | static void f_abs __ARGS((typval_T *argvars, typval_T *rettv)); |

9 | + |

10 | + /* Below are the 10 added FP functions - I've kept then together */ |

11 | + /* here and in their definitions later on. Because the funtion[] */ |

12 | + /* table must be in ASCII order, they are scattered there - WJMc */ |

13 | + |

14 | + static void f_acos __ARGS((typval_T *argvars, typval_T *rettv)); |

15 | + static void f_asin __ARGS((typval_T *argvars, typval_T *rettv)); |

16 | + static void f_atan2 __ARGS((typval_T *argvars, typval_T *rettv)); /* 2 args */ |

17 | + static void f_cosh __ARGS((typval_T *argvars, typval_T *rettv)); |

18 | + static void f_exp __ARGS((typval_T *argvars, typval_T *rettv)); |

19 | + static void f_fmod __ARGS((typval_T *argvars, typval_T *rettv)); /* 2 args */ |

20 | + static void f_log __ARGS((typval_T *argvars, typval_T *rettv)); |

21 | + static void f_sinh __ARGS((typval_T *argvars, typval_T *rettv)); |

22 | + static void f_tan __ARGS((typval_T *argvars, typval_T *rettv)); |

23 | + static void f_tanh __ARGS((typval_T *argvars, typval_T *rettv)); |

24 | #endif |

25 | static void f_add __ARGS((typval_T *argvars, typval_T *rettv)); |

26 | static void f_append __ARGS((typval_T *argvars, typval_T *rettv)); |

27 | *************** |

28 | *** 7421,7426 **** |

29 | --- 7436,7442 ---- |

30 | { |

31 | #ifdef FEAT_FLOAT |

32 | {"abs", 1, 1, f_abs}, |

33 | + {"acos", 1, 1, f_acos}, /* WJMc */ |

34 | #endif |

35 | {"add", 2, 2, f_add}, |

36 | {"append", 2, 2, f_append}, |

37 | *************** |

38 | *** 7428,7434 **** |

39 | --- 7444,7452 ---- |

40 | {"argidx", 0, 0, f_argidx}, |

41 | {"argv", 0, 1, f_argv}, |

42 | #ifdef FEAT_FLOAT |

43 | + {"asin", 1, 1, f_asin}, /* WJMc */ |

44 | {"atan", 1, 1, f_atan}, |

45 | + {"atan2", 2, 2, f_atan2}, /* WJMc */ |

46 | #endif |

47 | {"browse", 4, 4, f_browse}, |

48 | {"browsedir", 2, 2, f_browsedir}, |

49 | *************** |

50 | *** 7461,7466 **** |

51 | --- 7479,7485 ---- |

52 | {"copy", 1, 1, f_copy}, |

53 | #ifdef FEAT_FLOAT |

54 | {"cos", 1, 1, f_cos}, |

55 | + {"cosh", 1, 1, f_cosh}, /* WJMc */ |

56 | #endif |

57 | {"count", 2, 4, f_count}, |

58 | {"cscope_connection",0,3, f_cscope_connection}, |

59 | *************** |

60 | *** 7476,7481 **** |

61 | --- 7495,7503 ---- |

62 | {"eventhandler", 0, 0, f_eventhandler}, |

63 | {"executable", 1, 1, f_executable}, |

64 | {"exists", 1, 1, f_exists}, |

65 | + #ifdef FEAT_FLOAT |

66 | + {"exp", 1, 1, f_exp}, /* WJMc */ |

67 | + #endif |

68 | {"expand", 1, 2, f_expand}, |

69 | {"extend", 2, 3, f_extend}, |

70 | {"feedkeys", 1, 2, f_feedkeys}, |

71 | *************** |

72 | *** 7488,7493 **** |

73 | --- 7510,7516 ---- |

74 | #ifdef FEAT_FLOAT |

75 | {"float2nr", 1, 1, f_float2nr}, |

76 | {"floor", 1, 1, f_floor}, |

77 | + {"fmod", 2, 2, f_fmod}, /* WJMc */ |

78 | #endif |

79 | {"fnameescape", 1, 1, f_fnameescape}, |

80 | {"fnamemodify", 2, 2, f_fnamemodify}, |

81 | *************** |

82 | *** 7564,7569 **** |

83 | --- 7587,7593 ---- |

84 | {"lispindent", 1, 1, f_lispindent}, |

85 | {"localtime", 0, 0, f_localtime}, |

86 | #ifdef FEAT_FLOAT |

87 | + {"log", 1, 1, f_log}, /* WJMc */ |

88 | {"log10", 1, 1, f_log10}, |

89 | #endif |

90 | {"map", 2, 2, f_map}, |

91 | *************** |

92 | *** 7629,7634 **** |

93 | --- 7653,7659 ---- |

94 | {"simplify", 1, 1, f_simplify}, |

95 | #ifdef FEAT_FLOAT |

96 | {"sin", 1, 1, f_sin}, |

97 | + {"sinh", 1, 1, f_sinh}, /* WJMc */ |

98 | #endif |

99 | {"sort", 1, 2, f_sort}, |

100 | {"soundfold", 1, 1, f_soundfold}, |

101 | *************** |

102 | *** 7661,7666 **** |

103 | --- 7686,7693 ---- |

104 | {"tabpagewinnr", 1, 2, f_tabpagewinnr}, |

105 | {"tagfiles", 0, 0, f_tagfiles}, |

106 | {"taglist", 1, 1, f_taglist}, |

107 | + {"tan", 1, 1, f_tan}, /* WJMc */ |

108 | + {"tanh", 1, 1, f_tanh}, /* WJMc */ |

109 | {"tempname", 0, 0, f_tempname}, |

110 | {"test", 1, 1, f_test}, |

111 | {"tolower", 1, 1, f_tolower}, |

112 | *************** |

113 | *** 8127,8132 **** |

114 | --- 8154,8160 ---- |

115 | */ |

116 | |

117 | #ifdef FEAT_FLOAT |

118 | + |

119 | /* |

120 | * "abs(expr)" function |

121 | */ |

122 | *************** |

123 | *** 8309,8314 **** |

124 | --- 8337,8518 ---- |

125 | EMSG(_("E808: Number or Float required")); |

126 | return FAIL; |

127 | } |

128 | + |

129 | + /* The 10 added FP functions are defined immediately before atan() - WJMc */ |

130 | + |

131 | + /* |

132 | + * "acos()" function |

133 | + */ |

134 | + static void |

135 | + f_acos(argvars, rettv) |

136 | + typval_T *argvars; |

137 | + typval_T *rettv; |

138 | + { |

139 | + float_T f; |

140 | + |

141 | + rettv->v_type = VAR_FLOAT; |

142 | + if (get_float_arg(argvars, &f) == OK) |

143 | + rettv->vval.v_float = acos(f); |

144 | + else |

145 | + rettv->vval.v_float = 0.0; |

146 | + } |

147 | + |

148 | + /* |

149 | + * "asin()" function |

150 | + */ |

151 | + static void |

152 | + f_asin(argvars, rettv) |

153 | + typval_T *argvars; |

154 | + typval_T *rettv; |

155 | + { |

156 | + float_T f; |

157 | + |

158 | + rettv->v_type = VAR_FLOAT; |

159 | + if (get_float_arg(argvars, &f) == OK) |

160 | + rettv->vval.v_float = asin(f); |

161 | + else |

162 | + rettv->vval.v_float = 0.0; |

163 | + } |

164 | + |

165 | + /* |

166 | + * "atan2()" function |

167 | + */ |

168 | + static void |

169 | + f_atan2(argvars, rettv) |

170 | + typval_T *argvars; |

171 | + typval_T *rettv; |

172 | + { |

173 | + float_T fx, fy; |

174 | + |

175 | + rettv->v_type = VAR_FLOAT; |

176 | + if (get_float_arg(argvars, &fx) == OK |

177 | + && get_float_arg(&argvars[1], &fy) == OK) |

178 | + rettv->vval.v_float = atan2(fx, fy); |

179 | + else |

180 | + rettv->vval.v_float = 0.0; |

181 | + } |

182 | + |

183 | + /* |

184 | + * "cosh()" function |

185 | + */ |

186 | + static void |

187 | + f_cosh(argvars, rettv) |

188 | + typval_T *argvars; |

189 | + typval_T *rettv; |

190 | + { |

191 | + float_T f; |

192 | + |

193 | + rettv->v_type = VAR_FLOAT; |

194 | + if (get_float_arg(argvars, &f) == OK) |

195 | + rettv->vval.v_float = cosh(f); |

196 | + else |

197 | + rettv->vval.v_float = 0.0; |

198 | + } |

199 | + |

200 | + /* |

201 | + * "exp()" function |

202 | + */ |

203 | + static void |

204 | + f_exp(argvars, rettv) |

205 | + typval_T *argvars; |

206 | + typval_T *rettv; |

207 | + { |

208 | + float_T f; |

209 | + |

210 | + rettv->v_type = VAR_FLOAT; |

211 | + if (get_float_arg(argvars, &f) == OK) |

212 | + rettv->vval.v_float = exp(f); |

213 | + else |

214 | + rettv->vval.v_float = 0.0; |

215 | + } |

216 | + |

217 | + /* |

218 | + * "fmod()" function |

219 | + */ |

220 | + static void |

221 | + f_fmod(argvars, rettv) |

222 | + typval_T *argvars; |

223 | + typval_T *rettv; |

224 | + { |

225 | + float_T fx, fy; |

226 | + |

227 | + rettv->v_type = VAR_FLOAT; |

228 | + if (get_float_arg(argvars, &fx) == OK |

229 | + && get_float_arg(&argvars[1], &fy) == OK) |

230 | + rettv->vval.v_float = fmod(fx, fy); |

231 | + else |

232 | + rettv->vval.v_float = 0.0; |

233 | + } |

234 | + |

235 | + /* |

236 | + * "log()" function |

237 | + */ |

238 | + static void |

239 | + f_log(argvars, rettv) |

240 | + typval_T *argvars; |

241 | + typval_T *rettv; |

242 | + { |

243 | + float_T f; |

244 | + |

245 | + rettv->v_type = VAR_FLOAT; |

246 | + if (get_float_arg(argvars, &f) == OK) |

247 | + rettv->vval.v_float = log(f); |

248 | + else |

249 | + rettv->vval.v_float = 0.0; |

250 | + } |

251 | + |

252 | + /* |

253 | + * "sinh()" function |

254 | + */ |

255 | + static void |

256 | + f_sinh(argvars, rettv) |

257 | + typval_T *argvars; |

258 | + typval_T *rettv; |

259 | + { |

260 | + float_T f; |

261 | + |

262 | + rettv->v_type = VAR_FLOAT; |

263 | + if (get_float_arg(argvars, &f) == OK) |

264 | + rettv->vval.v_float = sinh(f); |

265 | + else |

266 | + rettv->vval.v_float = 0.0; |

267 | + } |

268 | + |

269 | + /* |

270 | + * "tan()" function |

271 | + */ |

272 | + static void |

273 | + f_tan(argvars, rettv) |

274 | + typval_T *argvars; |

275 | + typval_T *rettv; |

276 | + { |

277 | + float_T f; |

278 | + |

279 | + rettv->v_type = VAR_FLOAT; |

280 | + if (get_float_arg(argvars, &f) == OK) |

281 | + rettv->vval.v_float = tan(f); |

282 | + else |

283 | + rettv->vval.v_float = 0.0; |

284 | + } |

285 | + |

286 | + /* |

287 | + * "tanh()" function |

288 | + */ |

289 | + static void |

290 | + f_tanh(argvars, rettv) |

291 | + typval_T *argvars; |

292 | + typval_T *rettv; |

293 | + { |

294 | + float_T f; |

295 | + |

296 | + rettv->v_type = VAR_FLOAT; |

297 | + if (get_float_arg(argvars, &f) == OK) |

298 | + rettv->vval.v_float = tanh(f); |

299 | + else |

300 | + rettv->vval.v_float = 0.0; |

301 | + } |

302 | + |

303 | + /* End of the 10 added FP functions - WJMc */ |

304 | |

305 | /* |

306 | * "atan()" function |