1 To: [email protected] |
|
2 Subject: Patch 7.2.011 |
|
3 Fcc: outbox |
|
4 From: Bram Moolenaar <[email protected]> |
|
5 Mime-Version: 1.0 |
|
6 Content-Type: text/plain; charset=ISO-8859-1 |
|
7 Content-Transfer-Encoding: 8bit |
|
8 ------------ |
|
9 |
|
10 Patch 7.2.011 |
|
11 Problem: Get an error when inserting a float value from the expression |
|
12 register. |
|
13 Solution: Convert the Float to a String automatically in the same place |
|
14 where a List would be converted to a String. |
|
15 Files: src/eval.c |
|
16 |
|
17 |
|
18 *** ../vim-7.2.010/src/eval.c Mon Aug 25 04:48:21 2008 |
|
19 --- src/eval.c Sun Sep 7 13:50:38 2008 |
|
20 *************** |
|
21 *** 1256,1278 **** |
|
22 |
|
23 /* |
|
24 * Top level evaluation function, returning a string. |
|
25 * Return pointer to allocated memory, or NULL for failure. |
|
26 */ |
|
27 char_u * |
|
28 ! eval_to_string(arg, nextcmd, dolist) |
|
29 char_u *arg; |
|
30 char_u **nextcmd; |
|
31 ! int dolist; /* turn List into sequence of lines */ |
|
32 { |
|
33 typval_T tv; |
|
34 char_u *retval; |
|
35 garray_T ga; |
|
36 |
|
37 if (eval0(arg, &tv, nextcmd, TRUE) == FAIL) |
|
38 retval = NULL; |
|
39 else |
|
40 { |
|
41 ! if (dolist && tv.v_type == VAR_LIST) |
|
42 { |
|
43 ga_init2(&ga, (int)sizeof(char), 80); |
|
44 if (tv.vval.v_list != NULL) |
|
45 --- 1256,1281 ---- |
|
46 |
|
47 /* |
|
48 * Top level evaluation function, returning a string. |
|
49 + * When "convert" is TRUE convert a List into a sequence of lines and convert |
|
50 + * a Float to a String. |
|
51 * Return pointer to allocated memory, or NULL for failure. |
|
52 */ |
|
53 char_u * |
|
54 ! eval_to_string(arg, nextcmd, convert) |
|
55 char_u *arg; |
|
56 char_u **nextcmd; |
|
57 ! int convert; |
|
58 { |
|
59 typval_T tv; |
|
60 char_u *retval; |
|
61 garray_T ga; |
|
62 + char_u numbuf[NUMBUFLEN]; |
|
63 |
|
64 if (eval0(arg, &tv, nextcmd, TRUE) == FAIL) |
|
65 retval = NULL; |
|
66 else |
|
67 { |
|
68 ! if (convert && tv.v_type == VAR_LIST) |
|
69 { |
|
70 ga_init2(&ga, (int)sizeof(char), 80); |
|
71 if (tv.vval.v_list != NULL) |
|
72 *************** |
|
73 *** 1280,1285 **** |
|
74 --- 1283,1295 ---- |
|
75 ga_append(&ga, NUL); |
|
76 retval = (char_u *)ga.ga_data; |
|
77 } |
|
78 + #ifdef FEAT_FLOAT |
|
79 + else if (convert && tv.v_type == VAR_FLOAT) |
|
80 + { |
|
81 + vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv.vval.v_float); |
|
82 + retval = vim_strsave(numbuf); |
|
83 + } |
|
84 + #endif |
|
85 else |
|
86 retval = vim_strsave(get_tv_string(&tv)); |
|
87 clear_tv(&tv); |
|
88 *** ../vim-7.2.010/src/version.c Sat Sep 6 16:44:06 2008 |
|
89 --- src/version.c Sun Sep 7 13:52:00 2008 |
|
90 *************** |
|
91 *** 678,679 **** |
|
92 --- 678,681 ---- |
|
93 { /* Add new patch number below this line */ |
|
94 + /**/ |
|
95 + 11, |
|
96 /**/ |
|
97 |
|
98 -- |
|
99 hundred-and-one symptoms of being an internet addict: |
|
100 34. You laugh at people with 14400 baud modems. |
|
101 |
|
102 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ |
|
103 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
|
104 \\\ download, build and distribute -- http://www.A-A-P.org /// |
|
105 \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |
|