0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

Add extra floating point functions.

This commit is contained in:
Bram Moolenaar
2010-05-21 16:33:48 +02:00
parent b382ad13ca
commit db7c686ea5
7 changed files with 392 additions and 23 deletions

View File

@@ -1660,6 +1660,7 @@ See |function-list| for a list grouped by what the function is used for.
USAGE RESULT DESCRIPTION ~ USAGE RESULT DESCRIPTION ~
abs( {expr}) Float or Number absolute value of {expr} abs( {expr}) Float or Number absolute value of {expr}
acos( {expr}) Float arc cosine of {expr}
add( {list}, {item}) List append {item} to |List| {list} add( {list}, {item}) List append {item} to |List| {list}
append( {lnum}, {string}) Number append {string} below line {lnum} append( {lnum}, {string}) Number append {string} below line {lnum}
append( {lnum}, {list}) Number append lines {list} below line {lnum} append( {lnum}, {list}) Number append lines {list} below line {lnum}
@@ -1667,7 +1668,9 @@ argc() Number number of files in the argument list
argidx() Number current index in the argument list argidx() Number current index in the argument list
argv( {nr}) String {nr} entry of the argument list argv( {nr}) String {nr} entry of the argument list
argv( ) List the argument list argv( ) List the argument list
asin( {expr}) Float arc sine of {expr}
atan( {expr}) Float arc tangent of {expr} atan( {expr}) Float arc tangent of {expr}
atan2( {expr}, {expr}) Float arc tangent of {expr1} / {expr2}
browse( {save}, {title}, {initdir}, {default}) browse( {save}, {title}, {initdir}, {default})
String put up a file requester String put up a file requester
browsedir( {title}, {initdir}) String put up a directory requester browsedir( {title}, {initdir}) String put up a directory requester
@@ -1694,6 +1697,7 @@ confirm( {msg} [, {choices} [, {default} [, {type}]]])
Number number of choice picked by user Number number of choice picked by user
copy( {expr}) any make a shallow copy of {expr} copy( {expr}) any make a shallow copy of {expr}
cos( {expr}) Float cosine of {expr} cos( {expr}) Float cosine of {expr}
cosh( {expr}) Float hyperbolic cosine of {expr}
count( {list}, {expr} [, {start} [, {ic}]]) count( {list}, {expr} [, {start} [, {ic}]])
Number count how many {expr} are in {list} Number count how many {expr} are in {list}
cscope_connection( [{num} , {dbpath} [, {prepend}]]) cscope_connection( [{num} , {dbpath} [, {prepend}]])
@@ -1714,6 +1718,7 @@ executable( {expr}) Number 1 if executable {expr} exists
exists( {expr}) Number TRUE if {expr} exists exists( {expr}) Number TRUE if {expr} exists
extend( {expr1}, {expr2} [, {expr3}]) extend( {expr1}, {expr2} [, {expr3}])
List/Dict insert items of {expr2} into {expr1} List/Dict insert items of {expr2} into {expr1}
exp( {expr}) Float exponential of {expr}
expand( {expr} [, {flag}]) String expand special keywords in {expr} expand( {expr} [, {flag}]) String expand special keywords in {expr}
feedkeys( {string} [, {mode}]) Number add key sequence to typeahead buffer feedkeys( {string} [, {mode}]) Number add key sequence to typeahead buffer
filereadable( {file}) Number TRUE if {file} is a readable file filereadable( {file}) Number TRUE if {file} is a readable file
@@ -1726,6 +1731,7 @@ findfile( {name}[, {path}[, {count}]])
String find file {name} in {path} String find file {name} in {path}
float2nr( {expr}) Number convert Float {expr} to a Number float2nr( {expr}) Number convert Float {expr} to a Number
floor( {expr}) Float round {expr} down floor( {expr}) Float round {expr} down
fmod( {expr1}, {expr2}) Float remainder of {expr1} / {expr2}
fnameescape( {fname}) String escape special characters in {fname} fnameescape( {fname}) String escape special characters in {fname}
fnamemodify( {fname}, {mods}) String modify file name fnamemodify( {fname}, {mods}) String modify file name
foldclosed( {lnum}) Number first line of fold at {lnum} if closed foldclosed( {lnum}) Number first line of fold at {lnum} if closed
@@ -1805,6 +1811,7 @@ line( {expr}) Number line nr of cursor, last line or mark
line2byte( {lnum}) Number byte count of line {lnum} line2byte( {lnum}) Number byte count of line {lnum}
lispindent( {lnum}) Number Lisp indent for line {lnum} lispindent( {lnum}) Number Lisp indent for line {lnum}
localtime() Number current time localtime() Number current time
log( {expr}) Float natural logarithm (base e) of {expr}
log10( {expr}) Float logarithm of Float {expr} to base 10 log10( {expr}) Float logarithm of Float {expr} to base 10
map( {expr}, {string}) List/Dict change each item in {expr} to {expr} map( {expr}, {string}) List/Dict change each item in {expr} to {expr}
maparg( {name}[, {mode} [, {abbr}]]) maparg( {name}[, {mode} [, {abbr}]])
@@ -1887,6 +1894,7 @@ shellescape( {string} [, {special}])
command argument command argument
simplify( {filename}) String simplify filename as much as possible simplify( {filename}) String simplify filename as much as possible
sin( {expr}) Float sine of {expr} sin( {expr}) Float sine of {expr}
sinh( {expr}) Float hyperbolic sine of {expr}
sort( {list} [, {func}]) List sort {list}, using {func} to compare sort( {list} [, {func}]) List sort {list}, using {func} to compare
soundfold( {word}) String sound-fold {word} soundfold( {word}) String sound-fold {word}
spellbadword() String badly spelled word at cursor spellbadword() String badly spelled word at cursor
@@ -1923,6 +1931,8 @@ tabpagewinnr( {tabarg}[, {arg}])
taglist( {expr}) List list of tags matching {expr} taglist( {expr}) List list of tags matching {expr}
tagfiles() List tags files used tagfiles() List tags files used
tempname() String name for a temporary file tempname() String name for a temporary file
tan( {expr}) Float tangent of {expr}
tanh( {expr}) Float hyperbolic tangent of {expr}
tolower( {expr}) String the String {expr} switched to lowercase tolower( {expr}) String the String {expr} switched to lowercase
toupper( {expr}) String the String {expr} switched to uppercase toupper( {expr}) String the String {expr} switched to uppercase
tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
@@ -1958,6 +1968,20 @@ abs({expr}) *abs()*
< 4 < 4
{only available when compiled with the |+float| feature} {only available when compiled with the |+float| feature}
acos({expr}) *acos()*
Return the arc cosine of {expr} measured in radians, as a
|Float|in the range of [0, pi].
{expr} must evaluate to a|Float|or a|Number|in the range
[-1, 1].
Examples: >
:echo acos(0)
< 1.570796 >
:echo acos(-0.5)
< 2.094395
{only available when compiled with|+float|}
add({list}, {expr}) *add()* add({list}, {expr}) *add()*
Append the item {expr} to |List| {list}. Returns the Append the item {expr} to |List| {list}. Returns the
resulting |List|. Examples: > resulting |List|. Examples: >
@@ -2000,6 +2024,19 @@ argv([{nr}]) The result is the {nr}th file in the argument list of the
< Without the {nr} argument a |List| with the whole |arglist| is < Without the {nr} argument a |List| with the whole |arglist| is
returned. returned.
asin({expr}) *asin()*
Return the arc sine of {expr} measured in radians, as a|Float|
in the range of [-pi/2, pi/2].
{expr} must evaluate to a|Float|or a|Number|in the range
[-1, 1].
Examples: >
:echo asin(0.8)
< 0.927295 >
:echo asin(-0.5)
< -0.523599
{only available when compiled with|+float|}
atan({expr}) *atan()* atan({expr}) *atan()*
Return the principal value of the arc tangent of {expr}, in Return the principal value of the arc tangent of {expr}, in
the range [-pi/2, +pi/2] radians, as a |Float|. the range [-pi/2, +pi/2] radians, as a |Float|.
@@ -2011,6 +2048,19 @@ atan({expr}) *atan()*
< -1.326405 < -1.326405
{only available when compiled with the |+float| feature} {only available when compiled with the |+float| feature}
atan2({expr1}, {expr2}) *atan2()*
Return the arc tangent of {expr1} / {expr2}, measured in
radians, as a|Float|in the range [-pi, pi].
{expr1} and {expr2} must evaluate to a|Float|or a|Number|.
Examples: >
:echo atan2(-1, 1)
< -0.785398 >
:echo atan2(1, -1)
< 2.356194
{only available when compiled with|+float|}
*browse()* *browse()*
browse({save}, {title}, {initdir}, {default}) browse({save}, {title}, {initdir}, {default})
Put up a file requester. This only works when "has("browse")" Put up a file requester. This only works when "has("browse")"
@@ -2356,6 +2406,18 @@ cos({expr}) *cos()*
{only available when compiled with the |+float| feature} {only available when compiled with the |+float| feature}
cosh({expr}) *cosh()*
Return the hyperbolic cosine of {expr} as a|Float|in the range
[1, inf].
{expr} must evaluate to a|Float|or a|Number|.
Examples: >
:echo cosh(0.5)
< 1.127626 >
:echo cosh(-0.5)
< -1.127626
{only available when compiled with|+float|}
count({comp}, {expr} [, {ic} [, {start}]]) *count()* count({comp}, {expr} [, {ic} [, {start}]]) *count()*
Return the number of times an item with value {expr} appears Return the number of times an item with value {expr} appears
in |List| or |Dictionary| {comp}. in |List| or |Dictionary| {comp}.
@@ -2615,6 +2677,18 @@ exists({expr}) The result is a Number, which is non-zero if {expr} is
< This doesn't check for existence of the "bufcount" variable, < This doesn't check for existence of the "bufcount" variable,
but gets the value of "bufcount", and checks if that exists. but gets the value of "bufcount", and checks if that exists.
exp({expr}) *exp()*
Return the exponential of {expr} as a|Float|in the range
[0, inf].
{expr} must evaluate to a|Float|or a|Number|.
Examples: >
:echo exp(2)
< 7.389056 >
:echo exp(-1)
< 0.367879
{only available when compiled with|+float|}
expand({expr} [, {flag}]) *expand()* expand({expr} [, {flag}]) *expand()*
Expand wildcards and the following special keywords in {expr}. Expand wildcards and the following special keywords in {expr}.
The result is a String. The result is a String.
@@ -2847,6 +2921,23 @@ floor({expr}) *floor()*
< 4.0 < 4.0
{only available when compiled with the |+float| feature} {only available when compiled with the |+float| feature}
fmod({expr1}, {expr2}) *fmod()*
Return the remainder of {expr1} / {expr2}, even if the
division is not representable. Returns {expr1} - i * {expr2}
for some integer i such that if {expr2} is non-zero, the
result has the same sign as {expr1} and magnitude less than
the magnitude of {expr2}. If {expr2} is zero, the value
returned is zero. The value returned is a|Float|.
{expr1} and {expr2} must evaluate to a|Float|or a|Number|.
Examples: >
:echo fmod(12.33, 1.22)
< 0.13 >
:echo fmod(-12.33, 1.22)
< -0.13
{only available when compiled with|+float|}
fnameescape({string}) *fnameescape()* fnameescape({string}) *fnameescape()*
Escape {string} for use as file name command argument. All Escape {string} for use as file name command argument. All
characters that have a special meaning, such as '%' and '|' characters that have a special meaning, such as '%' and '|'
@@ -3802,6 +3893,18 @@ localtime() *localtime()*
1970. See also |strftime()| and |getftime()|. 1970. See also |strftime()| and |getftime()|.
log({expr}) *log()*
Return the natural logarithm (base e) of {expr} as a|Float|.
{expr} must evaluate to a|Float|or a|Number|in the range
(0, inf].
Examples: >
:echo log(10)
< 2.302585 >
:echo log(exp(5))
< 5.0
{only available when compiled with|+float|}
log10({expr}) *log10()* log10({expr}) *log10()*
Return the logarithm of Float {expr} to base 10 as a |Float|. Return the logarithm of Float {expr} to base 10 as a |Float|.
{expr} must evaluate to a |Float| or a |Number|. {expr} must evaluate to a |Float| or a |Number|.
@@ -5076,6 +5179,18 @@ sin({expr}) *sin()*
{only available when compiled with the |+float| feature} {only available when compiled with the |+float| feature}
sinh({expr}) *sinh()*
Return the hyperbolic sine of {expr} as a|Float|in the range
[-inf, inf].
{expr} must evaluate to a|Float|or a|Number|.
Examples: >
:echo sinh(0.5)
< 0.521095 >
:echo sinh(-0.9)
< -1.026517
{only available when compiled with|+float|}
sort({list} [, {func}]) *sort()* *E702* sort({list} [, {func}]) *sort()* *E702*
Sort the items in {list} in-place. Returns {list}. If you Sort the items in {list} in-place. Returns {list}. If you
want a list to remain unmodified make a copy first: > want a list to remain unmodified make a copy first: >
@@ -5555,6 +5670,31 @@ tempname() *tempname()* *temp-file-name*
For MS-Windows forward slashes are used when the 'shellslash' For MS-Windows forward slashes are used when the 'shellslash'
option is set or when 'shellcmdflag' starts with '-'. option is set or when 'shellcmdflag' starts with '-'.
tan({expr}) *tan()*
Return the tangent of {expr}, measured in radians, as a|Float|
in the range [-inf, inf].
{expr} must evaluate to a|Float|or a|Number|.
Examples: >
:echo tan(10)
< 0.648361 >
:echo tan(-4.01)
< -1.181502
{only available when compiled with|+float|}
tanh({expr}) *tanh()*
Return the hyperbolic tangent of {expr} as a|Float|in the
range [-1, 1].
{expr} must evaluate to a|Float|or a|Number|.
Examples: >
:echo tanh(0.5)
< 0.462117 >
:echo tanh(-1)
< -0.761594
{only available when compiled with|+float|}
tolower({expr}) *tolower()* tolower({expr}) *tolower()*
The result is a copy of the String given, with all uppercase The result is a copy of the String given, with all uppercase
characters turned into lowercase (just like applying |gu| to characters turned into lowercase (just like applying |gu| to

View File

@@ -4142,6 +4142,8 @@ E817 editing.txt /*E817*
E818 editing.txt /*E818* E818 editing.txt /*E818*
E819 editing.txt /*E819* E819 editing.txt /*E819*
E82 message.txt /*E82* E82 message.txt /*E82*
E820 editing.txt /*E820*
E821 options.txt /*E821*
E83 message.txt /*E83* E83 message.txt /*E83*
E84 windows.txt /*E84* E84 windows.txt /*E84*
E85 options.txt /*E85* E85 options.txt /*E85*
@@ -4547,6 +4549,7 @@ abandon editing.txt /*abandon*
abbreviations map.txt /*abbreviations* abbreviations map.txt /*abbreviations*
abel.vim syntax.txt /*abel.vim* abel.vim syntax.txt /*abel.vim*
abs() eval.txt /*abs()* abs() eval.txt /*abs()*
acos() eval.txt /*acos()*
active-buffer windows.txt /*active-buffer* active-buffer windows.txt /*active-buffer*
ada#Create_Tags() ft_ada.txt /*ada#Create_Tags()* ada#Create_Tags() ft_ada.txt /*ada#Create_Tags()*
ada#Jump_Tag() ft_ada.txt /*ada#Jump_Tag()* ada#Jump_Tag() ft_ada.txt /*ada#Jump_Tag()*
@@ -4611,11 +4614,13 @@ arglist-quit usr_07.txt /*arglist-quit*
argument-list editing.txt /*argument-list* argument-list editing.txt /*argument-list*
argv() eval.txt /*argv()* argv() eval.txt /*argv()*
as motion.txt /*as* as motion.txt /*as*
asin() eval.txt /*asin()*
asm.vim syntax.txt /*asm.vim* asm.vim syntax.txt /*asm.vim*
asm68k syntax.txt /*asm68k* asm68k syntax.txt /*asm68k*
asmh8300.vim syntax.txt /*asmh8300.vim* asmh8300.vim syntax.txt /*asmh8300.vim*
at motion.txt /*at* at motion.txt /*at*
atan() eval.txt /*atan()* atan() eval.txt /*atan()*
atan2() eval.txt /*atan2()*
athena-intellimouse gui.txt /*athena-intellimouse* athena-intellimouse gui.txt /*athena-intellimouse*
attr-list syntax.txt /*attr-list* attr-list syntax.txt /*attr-list*
author intro.txt /*author* author intro.txt /*author*
@@ -4938,6 +4943,7 @@ copy-move change.txt /*copy-move*
copying uganda.txt /*copying* copying uganda.txt /*copying*
copyright uganda.txt /*copyright* copyright uganda.txt /*copyright*
cos() eval.txt /*cos()* cos() eval.txt /*cos()*
cosh() eval.txt /*cosh()*
count intro.txt /*count* count intro.txt /*count*
count() eval.txt /*count()* count() eval.txt /*count()*
count-bytes tips.txt /*count-bytes* count-bytes tips.txt /*count-bytes*
@@ -5258,6 +5264,7 @@ executable() eval.txt /*executable()*
execute-menus gui.txt /*execute-menus* execute-menus gui.txt /*execute-menus*
exim starting.txt /*exim* exim starting.txt /*exim*
exists() eval.txt /*exists()* exists() eval.txt /*exists()*
exp() eval.txt /*exp()*
expand() eval.txt /*expand()* expand() eval.txt /*expand()*
expand-env options.txt /*expand-env* expand-env options.txt /*expand-env*
expand-environment-var options.txt /*expand-environment-var* expand-environment-var options.txt /*expand-environment-var*
@@ -5388,6 +5395,7 @@ float2nr() eval.txt /*float2nr()*
floating-point-format eval.txt /*floating-point-format* floating-point-format eval.txt /*floating-point-format*
floating-point-precision eval.txt /*floating-point-precision* floating-point-precision eval.txt /*floating-point-precision*
floor() eval.txt /*floor()* floor() eval.txt /*floor()*
fmod() eval.txt /*fmod()*
fname_diff-variable eval.txt /*fname_diff-variable* fname_diff-variable eval.txt /*fname_diff-variable*
fname_in-variable eval.txt /*fname_in-variable* fname_in-variable eval.txt /*fname_in-variable*
fname_new-variable eval.txt /*fname_new-variable* fname_new-variable eval.txt /*fname_new-variable*
@@ -6338,6 +6346,7 @@ locale-name mbyte.txt /*locale-name*
localtime() eval.txt /*localtime()* localtime() eval.txt /*localtime()*
location-list quickfix.txt /*location-list* location-list quickfix.txt /*location-list*
location-list-window quickfix.txt /*location-list-window* location-list-window quickfix.txt /*location-list-window*
log() eval.txt /*log()*
log10() eval.txt /*log10()* log10() eval.txt /*log10()*
long-lines version5.txt /*long-lines* long-lines version5.txt /*long-lines*
lowercase change.txt /*lowercase* lowercase change.txt /*lowercase*
@@ -7255,6 +7264,7 @@ simplify() eval.txt /*simplify()*
simulated-command vi_diff.txt /*simulated-command* simulated-command vi_diff.txt /*simulated-command*
sin() eval.txt /*sin()* sin() eval.txt /*sin()*
single-repeat repeat.txt /*single-repeat* single-repeat repeat.txt /*single-repeat*
sinh() eval.txt /*sinh()*
skeleton autocmd.txt /*skeleton* skeleton autocmd.txt /*skeleton*
slice eval.txt /*slice* slice eval.txt /*slice*
slow-fast-terminal term.txt /*slow-fast-terminal* slow-fast-terminal term.txt /*slow-fast-terminal*
@@ -7688,6 +7698,8 @@ tags-file-format tagsrch.txt /*tags-file-format*
tags-option tagsrch.txt /*tags-option* tags-option tagsrch.txt /*tags-option*
tagsrch.txt tagsrch.txt /*tagsrch.txt* tagsrch.txt tagsrch.txt /*tagsrch.txt*
tagstack tagsrch.txt /*tagstack* tagstack tagsrch.txt /*tagstack*
tan() eval.txt /*tan()*
tanh() eval.txt /*tanh()*
tar pi_tar.txt /*tar* tar pi_tar.txt /*tar*
tar-contents pi_tar.txt /*tar-contents* tar-contents pi_tar.txt /*tar-contents*
tar-copyright pi_tar.txt /*tar-copyright* tar-copyright pi_tar.txt /*tar-copyright*
@@ -8059,6 +8071,7 @@ version-6.1 version6.txt /*version-6.1*
version-6.2 version6.txt /*version-6.2* version-6.2 version6.txt /*version-6.2*
version-6.3 version6.txt /*version-6.3* version-6.3 version6.txt /*version-6.3*
version-6.4 version6.txt /*version-6.4* version-6.4 version6.txt /*version-6.4*
version-7.0 version7.txt /*version-7.0*
version-7.1 version7.txt /*version-7.1* version-7.1 version7.txt /*version-7.1*
version-7.2 version7.txt /*version-7.2* version-7.2 version7.txt /*version-7.2*
version-7.3 version7.txt /*version-7.3* version-7.3 version7.txt /*version-7.3*
@@ -8066,6 +8079,10 @@ version-variable eval.txt /*version-variable*
version4.txt version4.txt /*version4.txt* version4.txt version4.txt /*version4.txt*
version5.txt version5.txt /*version5.txt* version5.txt version5.txt /*version5.txt*
version6.txt version6.txt /*version6.txt* version6.txt version6.txt /*version6.txt*
version7.0 version7.txt /*version7.0*
version7.1 version7.txt /*version7.1*
version7.2 version7.txt /*version7.2*
version7.3 version7.txt /*version7.3*
version7.txt version7.txt /*version7.txt* version7.txt version7.txt /*version7.txt*
vi intro.txt /*vi* vi intro.txt /*vi*
vi-differences vi_diff.txt /*vi-differences* vi-differences vi_diff.txt /*vi-differences*

View File

@@ -30,8 +30,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
*known-bugs* *known-bugs*
-------------------- Known bugs and current work ----------------------- -------------------- Known bugs and current work -----------------------
Include cabal and obj syntax files. (Vincent Berthoux, 2010 May 16)
Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6) Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6)
E315 when trying to change a file in FileChangedRO autocommand event. E315 when trying to change a file in FileChangedRO autocommand event.
@@ -1087,10 +1085,15 @@ Patches to include:
- gettabvar() and settabvar() functions. (Yegappan Lakshmanan, 2010 May 14) - gettabvar() and settabvar() functions. (Yegappan Lakshmanan, 2010 May 14)
- Patch to support netbeans in Unix console Vim. (Xavier de Gaye, 2009 Apr - Patch to support netbeans in Unix console Vim. (Xavier de Gaye, 2009 Apr
26) Now with Mercurial repository (2010 Jan 2) 26) Now with Mercurial repository (2010 Jan 2)
- More float functions. (Bill McCarthy)
~/tmp/eval.diff
http://groups.google.com/group/vim_dev/browse_thread/thread/de192817983abb54
- Include conceal patch?
http://vince.negri.googlepages.com/
http://vim.wikia.com/wiki/Patch_to_conceal_parts_of_lines
- Patch for Lisp support with ECL (Mikael Jansson, 2008 Oct 25) - Patch for Lisp support with ECL (Mikael Jansson, 2008 Oct 25)
- Minor patches from Dominique Pelle, 2010 May 15 - Minor patches from Dominique Pelle, 2010 May 15
- Gvimext patch to support wide file names. (Szabolcs Horvat 2008 Sep 10) - Gvimext patch to support wide file names. (Szabolcs Horvat 2008 Sep 10)
- More float functions.
- Patch to support netbeans for Mac. (Kazuki Sakamoto, 2009 Jun 25) - Patch to support netbeans for Mac. (Kazuki Sakamoto, 2009 Jun 25)
- Patch to support clipboard for Mac terminal. (Jjgod Jiang, 2009 Aug 1) - Patch to support clipboard for Mac terminal. (Jjgod Jiang, 2009 Aug 1)
- Patch to support :browse for more commands. (Lech Lorens, 2009 Jul 18) - Patch to support :browse for more commands. (Lech Lorens, 2009 Jul 18)

View File

@@ -7184,6 +7184,9 @@ Mostly by Moshin Ahmed.
Support GDK_SUPER_MASK for GTK on Mac. (Stephan Schulz) Support GDK_SUPER_MASK for GTK on Mac. (Stephan Schulz)
More floating point functions: acos(), asin(), atan2(), cosh(), exp(), fmod(),
log(), sinh(), tan(), tanh(). (Bill McCarthy)
Fixed *fixed-7.3* Fixed *fixed-7.3*
----- -----

View File

@@ -2,6 +2,7 @@
" Language: Haskell Cabal Build file " Language: Haskell Cabal Build file
" Maintainer: Vincent Berthoux <twinside@gmail.com> " Maintainer: Vincent Berthoux <twinside@gmail.com>
" File Types: .cabal " File Types: .cabal
" Last Change: 2010 May 18
" v1.3: Updated to the last version of cabal " v1.3: Updated to the last version of cabal
" Added more highlighting for cabal function, true/false " Added more highlighting for cabal function, true/false
" and version number. Also added missing comment highlighting. " and version number. Also added missing comment highlighting.

View File

@@ -2,6 +2,7 @@
" Language: 3D wavefront's obj file " Language: 3D wavefront's obj file
" Maintainer: Vincent Berthoux <twinside@gmail.com> " Maintainer: Vincent Berthoux <twinside@gmail.com>
" File Types: .obj (used in 3D) " File Types: .obj (used in 3D)
" Last Change: 2010 May 18
" "
" For version 5.x: Clear all syntax items " For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded " For version 6.x: Quit when a syntax file was already loaded

View File

@@ -470,6 +470,7 @@ static int non_zero_arg __ARGS((typval_T *argvars));
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static void f_abs __ARGS((typval_T *argvars, typval_T *rettv)); static void f_abs __ARGS((typval_T *argvars, typval_T *rettv));
static void f_acos __ARGS((typval_T *argvars, typval_T *rettv));
#endif #endif
static void f_add __ARGS((typval_T *argvars, typval_T *rettv)); static void f_add __ARGS((typval_T *argvars, typval_T *rettv));
static void f_append __ARGS((typval_T *argvars, typval_T *rettv)); static void f_append __ARGS((typval_T *argvars, typval_T *rettv));
@@ -477,7 +478,9 @@ static void f_argc __ARGS((typval_T *argvars, typval_T *rettv));
static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv));
static void f_argv __ARGS((typval_T *argvars, typval_T *rettv)); static void f_argv __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static void f_asin __ARGS((typval_T *argvars, typval_T *rettv));
static void f_atan __ARGS((typval_T *argvars, typval_T *rettv)); static void f_atan __ARGS((typval_T *argvars, typval_T *rettv));
static void f_atan2 __ARGS((typval_T *argvars, typval_T *rettv));
#endif #endif
static void f_browse __ARGS((typval_T *argvars, typval_T *rettv)); static void f_browse __ARGS((typval_T *argvars, typval_T *rettv));
static void f_browsedir __ARGS((typval_T *argvars, typval_T *rettv)); static void f_browsedir __ARGS((typval_T *argvars, typval_T *rettv));
@@ -507,6 +510,7 @@ static void f_confirm __ARGS((typval_T *argvars, typval_T *rettv));
static void f_copy __ARGS((typval_T *argvars, typval_T *rettv)); static void f_copy __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static void f_cos __ARGS((typval_T *argvars, typval_T *rettv)); static void f_cos __ARGS((typval_T *argvars, typval_T *rettv));
static void f_cosh __ARGS((typval_T *argvars, typval_T *rettv));
#endif #endif
static void f_count __ARGS((typval_T *argvars, typval_T *rettv)); static void f_count __ARGS((typval_T *argvars, typval_T *rettv));
static void f_cscope_connection __ARGS((typval_T *argvars, typval_T *rettv)); static void f_cscope_connection __ARGS((typval_T *argvars, typval_T *rettv));
@@ -522,6 +526,9 @@ static void f_eval __ARGS((typval_T *argvars, typval_T *rettv));
static void f_eventhandler __ARGS((typval_T *argvars, typval_T *rettv)); static void f_eventhandler __ARGS((typval_T *argvars, typval_T *rettv));
static void f_executable __ARGS((typval_T *argvars, typval_T *rettv)); static void f_executable __ARGS((typval_T *argvars, typval_T *rettv));
static void f_exists __ARGS((typval_T *argvars, typval_T *rettv)); static void f_exists __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_FLOAT
static void f_exp __ARGS((typval_T *argvars, typval_T *rettv));
#endif
static void f_expand __ARGS((typval_T *argvars, typval_T *rettv)); static void f_expand __ARGS((typval_T *argvars, typval_T *rettv));
static void f_extend __ARGS((typval_T *argvars, typval_T *rettv)); static void f_extend __ARGS((typval_T *argvars, typval_T *rettv));
static void f_feedkeys __ARGS((typval_T *argvars, typval_T *rettv)); static void f_feedkeys __ARGS((typval_T *argvars, typval_T *rettv));
@@ -533,6 +540,7 @@ static void f_findfile __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static void f_float2nr __ARGS((typval_T *argvars, typval_T *rettv)); static void f_float2nr __ARGS((typval_T *argvars, typval_T *rettv));
static void f_floor __ARGS((typval_T *argvars, typval_T *rettv)); static void f_floor __ARGS((typval_T *argvars, typval_T *rettv));
static void f_fmod __ARGS((typval_T *argvars, typval_T *rettv));
#endif #endif
static void f_fnameescape __ARGS((typval_T *argvars, typval_T *rettv)); static void f_fnameescape __ARGS((typval_T *argvars, typval_T *rettv));
static void f_fnamemodify __ARGS((typval_T *argvars, typval_T *rettv)); static void f_fnamemodify __ARGS((typval_T *argvars, typval_T *rettv));
@@ -606,6 +614,7 @@ static void f_line2byte __ARGS((typval_T *argvars, typval_T *rettv));
static void f_lispindent __ARGS((typval_T *argvars, typval_T *rettv)); static void f_lispindent __ARGS((typval_T *argvars, typval_T *rettv));
static void f_localtime __ARGS((typval_T *argvars, typval_T *rettv)); static void f_localtime __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static void f_log __ARGS((typval_T *argvars, typval_T *rettv));
static void f_log10 __ARGS((typval_T *argvars, typval_T *rettv)); static void f_log10 __ARGS((typval_T *argvars, typval_T *rettv));
#endif #endif
static void f_map __ARGS((typval_T *argvars, typval_T *rettv)); static void f_map __ARGS((typval_T *argvars, typval_T *rettv));
@@ -674,6 +683,7 @@ static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv));
static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv)); static void f_simplify __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static void f_sin __ARGS((typval_T *argvars, typval_T *rettv)); static void f_sin __ARGS((typval_T *argvars, typval_T *rettv));
static void f_sinh __ARGS((typval_T *argvars, typval_T *rettv));
#endif #endif
static void f_sort __ARGS((typval_T *argvars, typval_T *rettv)); static void f_sort __ARGS((typval_T *argvars, typval_T *rettv));
static void f_soundfold __ARGS((typval_T *argvars, typval_T *rettv)); static void f_soundfold __ARGS((typval_T *argvars, typval_T *rettv));
@@ -708,6 +718,10 @@ static void f_taglist __ARGS((typval_T *argvars, typval_T *rettv));
static void f_tagfiles __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tagfiles __ARGS((typval_T *argvars, typval_T *rettv));
static void f_tempname __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tempname __ARGS((typval_T *argvars, typval_T *rettv));
static void f_test __ARGS((typval_T *argvars, typval_T *rettv)); static void f_test __ARGS((typval_T *argvars, typval_T *rettv));
#ifdef FEAT_FLOAT
static void f_tan __ARGS((typval_T *argvars, typval_T *rettv));
static void f_tanh __ARGS((typval_T *argvars, typval_T *rettv));
#endif
static void f_tolower __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tolower __ARGS((typval_T *argvars, typval_T *rettv));
static void f_toupper __ARGS((typval_T *argvars, typval_T *rettv)); static void f_toupper __ARGS((typval_T *argvars, typval_T *rettv));
static void f_tr __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tr __ARGS((typval_T *argvars, typval_T *rettv));
@@ -4840,7 +4854,7 @@ eval7(arg, rettv, evaluate, want_string)
char_u **arg; char_u **arg;
typval_T *rettv; typval_T *rettv;
int evaluate; int evaluate;
int want_string; /* after "." operator */ int want_string UNUSED; /* after "." operator */
{ {
long n; long n;
int len; int len;
@@ -7541,6 +7555,7 @@ static struct fst
{ {
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
{"abs", 1, 1, f_abs}, {"abs", 1, 1, f_abs},
{"acos", 1, 1, f_acos}, /* WJMc */
#endif #endif
{"add", 2, 2, f_add}, {"add", 2, 2, f_add},
{"append", 2, 2, f_append}, {"append", 2, 2, f_append},
@@ -7548,7 +7563,9 @@ static struct fst
{"argidx", 0, 0, f_argidx}, {"argidx", 0, 0, f_argidx},
{"argv", 0, 1, f_argv}, {"argv", 0, 1, f_argv},
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
{"asin", 1, 1, f_asin}, /* WJMc */
{"atan", 1, 1, f_atan}, {"atan", 1, 1, f_atan},
{"atan2", 2, 2, f_atan2},
#endif #endif
{"browse", 4, 4, f_browse}, {"browse", 4, 4, f_browse},
{"browsedir", 2, 2, f_browsedir}, {"browsedir", 2, 2, f_browsedir},
@@ -7581,6 +7598,7 @@ static struct fst
{"copy", 1, 1, f_copy}, {"copy", 1, 1, f_copy},
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
{"cos", 1, 1, f_cos}, {"cos", 1, 1, f_cos},
{"cosh", 1, 1, f_cosh},
#endif #endif
{"count", 2, 4, f_count}, {"count", 2, 4, f_count},
{"cscope_connection",0,3, f_cscope_connection}, {"cscope_connection",0,3, f_cscope_connection},
@@ -7596,6 +7614,9 @@ static struct fst
{"eventhandler", 0, 0, f_eventhandler}, {"eventhandler", 0, 0, f_eventhandler},
{"executable", 1, 1, f_executable}, {"executable", 1, 1, f_executable},
{"exists", 1, 1, f_exists}, {"exists", 1, 1, f_exists},
#ifdef FEAT_FLOAT
{"exp", 1, 1, f_exp},
#endif
{"expand", 1, 2, f_expand}, {"expand", 1, 2, f_expand},
{"extend", 2, 3, f_extend}, {"extend", 2, 3, f_extend},
{"feedkeys", 1, 2, f_feedkeys}, {"feedkeys", 1, 2, f_feedkeys},
@@ -7608,6 +7629,7 @@ static struct fst
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
{"float2nr", 1, 1, f_float2nr}, {"float2nr", 1, 1, f_float2nr},
{"floor", 1, 1, f_floor}, {"floor", 1, 1, f_floor},
{"fmod", 2, 2, f_fmod},
#endif #endif
{"fnameescape", 1, 1, f_fnameescape}, {"fnameescape", 1, 1, f_fnameescape},
{"fnamemodify", 2, 2, f_fnamemodify}, {"fnamemodify", 2, 2, f_fnamemodify},
@@ -7684,6 +7706,7 @@ static struct fst
{"lispindent", 1, 1, f_lispindent}, {"lispindent", 1, 1, f_lispindent},
{"localtime", 0, 0, f_localtime}, {"localtime", 0, 0, f_localtime},
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
{"log", 1, 1, f_log},
{"log10", 1, 1, f_log10}, {"log10", 1, 1, f_log10},
#endif #endif
{"map", 2, 2, f_map}, {"map", 2, 2, f_map},
@@ -7752,6 +7775,7 @@ static struct fst
{"simplify", 1, 1, f_simplify}, {"simplify", 1, 1, f_simplify},
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
{"sin", 1, 1, f_sin}, {"sin", 1, 1, f_sin},
{"sinh", 1, 1, f_sinh},
#endif #endif
{"sort", 1, 2, f_sort}, {"sort", 1, 2, f_sort},
{"soundfold", 1, 1, f_soundfold}, {"soundfold", 1, 1, f_soundfold},
@@ -7784,6 +7808,10 @@ static struct fst
{"tabpagewinnr", 1, 2, f_tabpagewinnr}, {"tabpagewinnr", 1, 2, f_tabpagewinnr},
{"tagfiles", 0, 0, f_tagfiles}, {"tagfiles", 0, 0, f_tagfiles},
{"taglist", 1, 1, f_taglist}, {"taglist", 1, 1, f_taglist},
#ifdef FEAT_FLOAT
{"tan", 1, 1, f_tan},
{"tanh", 1, 1, f_tanh},
#endif
{"tempname", 0, 0, f_tempname}, {"tempname", 0, 0, f_tempname},
{"test", 1, 1, f_test}, {"test", 1, 1, f_test},
{"tolower", 1, 1, f_tolower}, {"tolower", 1, 1, f_tolower},
@@ -8251,6 +8279,31 @@ non_zero_arg(argvars)
*/ */
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static int get_float_arg __ARGS((typval_T *argvars, float_T *f));
/*
* Get the float value of "argvars[0]" into "f".
* Returns FAIL when the argument is not a Number or Float.
*/
static int
get_float_arg(argvars, f)
typval_T *argvars;
float_T *f;
{
if (argvars[0].v_type == VAR_FLOAT)
{
*f = argvars[0].vval.v_float;
return OK;
}
if (argvars[0].v_type == VAR_NUMBER)
{
*f = (float_T)argvars[0].vval.v_number;
return OK;
}
EMSG(_("E808: Number or Float required"));
return FAIL;
}
/* /*
* "abs(expr)" function * "abs(expr)" function
*/ */
@@ -8278,6 +8331,23 @@ f_abs(argvars, rettv)
rettv->vval.v_number = -n; rettv->vval.v_number = -n;
} }
} }
/*
* "acos()" function
*/
static void
f_acos(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T f;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &f) == OK)
rettv->vval.v_float = acos(f);
else
rettv->vval.v_float = 0.0;
}
#endif #endif
/* /*
@@ -8406,29 +8476,21 @@ f_argv(argvars, rettv)
} }
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
static int get_float_arg __ARGS((typval_T *argvars, float_T *f));
/* /*
* Get the float value of "argvars[0]" into "f". * "asin()" function
* Returns FAIL when the argument is not a Number or Float.
*/ */
static int static void
get_float_arg(argvars, f) f_asin(argvars, rettv)
typval_T *argvars; typval_T *argvars;
float_T *f; typval_T *rettv;
{ {
if (argvars[0].v_type == VAR_FLOAT) float_T f;
{
*f = argvars[0].vval.v_float; rettv->v_type = VAR_FLOAT;
return OK; if (get_float_arg(argvars, &f) == OK)
} rettv->vval.v_float = asin(f);
if (argvars[0].v_type == VAR_NUMBER) else
{ rettv->vval.v_float = 0.0;
*f = (float_T)argvars[0].vval.v_number;
return OK;
}
EMSG(_("E808: Number or Float required"));
return FAIL;
} }
/* /*
@@ -8447,6 +8509,24 @@ f_atan(argvars, rettv)
else else
rettv->vval.v_float = 0.0; rettv->vval.v_float = 0.0;
} }
/*
* "atan2()" function
*/
static void
f_atan2(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T fx, fy;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &fx) == OK
&& get_float_arg(&argvars[1], &fy) == OK)
rettv->vval.v_float = atan2(fx, fy);
else
rettv->vval.v_float = 0.0;
}
#endif #endif
/* /*
@@ -9117,6 +9197,23 @@ f_cos(argvars, rettv)
else else
rettv->vval.v_float = 0.0; rettv->vval.v_float = 0.0;
} }
/*
* "cosh()" function
*/
static void
f_cosh(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T f;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &f) == OK)
rettv->vval.v_float = cosh(f);
else
rettv->vval.v_float = 0.0;
}
#endif #endif
/* /*
@@ -9593,6 +9690,25 @@ f_exists(argvars, rettv)
rettv->vval.v_number = n; rettv->vval.v_number = n;
} }
#ifdef FEAT_FLOAT
/*
* "exp()" function
*/
static void
f_exp(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T f;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &f) == OK)
rettv->vval.v_float = exp(f);
else
rettv->vval.v_float = 0.0;
}
#endif
/* /*
* "expand()" function * "expand()" function
*/ */
@@ -10140,6 +10256,24 @@ f_floor(argvars, rettv)
else else
rettv->vval.v_float = 0.0; rettv->vval.v_float = 0.0;
} }
/*
* "fmod()" function
*/
static void
f_fmod(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T fx, fy;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &fx) == OK
&& get_float_arg(&argvars[1], &fy) == OK)
rettv->vval.v_float = fmod(fx, fy);
else
rettv->vval.v_float = 0.0;
}
#endif #endif
/* /*
@@ -13004,6 +13138,23 @@ get_maparg(argvars, rettv, exact)
} }
#ifdef FEAT_FLOAT #ifdef FEAT_FLOAT
/*
* "log()" function
*/
static void
f_log(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T f;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &f) == OK)
rettv->vval.v_float = log(f);
else
rettv->vval.v_float = 0.0;
}
/* /*
* "log10()" function * "log10()" function
*/ */
@@ -15823,6 +15974,23 @@ f_sin(argvars, rettv)
else else
rettv->vval.v_float = 0.0; rettv->vval.v_float = 0.0;
} }
/*
* "sinh()" function
*/
static void
f_sinh(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T f;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &f) == OK)
rettv->vval.v_float = sinh(f);
else
rettv->vval.v_float = 0.0;
}
#endif #endif
static int static int
@@ -17077,6 +17245,42 @@ f_test(argvars, rettv)
#endif #endif
} }
#ifdef FEAT_FLOAT
/*
* "tan()" function
*/
static void
f_tan(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T f;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &f) == OK)
rettv->vval.v_float = tan(f);
else
rettv->vval.v_float = 0.0;
}
/*
* "tanh()" function
*/
static void
f_tanh(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
float_T f;
rettv->v_type = VAR_FLOAT;
if (get_float_arg(argvars, &f) == OK)
rettv->vval.v_float = tanh(f);
else
rettv->vval.v_float = 0.0;
}
#endif
/* /*
* "tolower(string)" function * "tolower(string)" function
*/ */