Mercurial > hg > octave-thorsten
changeset 6120:ba9db42a1fe0
[project @ 2006-10-28 02:45:48 by jwe]
author | jwe |
---|---|
date | Sat, 28 Oct 2006 02:45:48 +0000 |
parents | fabb1be5fd84 |
children | 483176585b84 |
files | src/ChangeLog src/pr-output.cc |
diffstat | 2 files changed, 33 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2006-10-27 John W. Eaton <jwe@octave.org> + * pr-output.cc (SPECIALIZE_UABS): New macro. + Use it to generate specializations of abs for unsigned int types. + Instantiate abs for signed int types. + * load-path.cc (load_path::do_initialize): Use dir_path::path_sep_str instead of ":". Don't append ":::" to xpath when calling do_set.
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -2205,19 +2205,41 @@ } } +// FIXME -- all this mess with abs is an attempt to avoid seeing +// +// warning: comparison of unsigned expression < 0 is always false +// +// from GCC. Isn't there a better way + template <class T> /* static */ inline T abs (T x) { - return x; + return x < 0 ? -x : x; } -#define INSTANTIATE_ABS(T) template /* static */ inline T abs (T x) - -INSTANTIATE_ABS (unsigned int); -INSTANTIATE_ABS (unsigned short); -INSTANTIATE_ABS (unsigned long); -INSTANTIATE_ABS (unsigned long long); +#define INSTANTIATE_ABS(T) \ + template /* static */ inline T abs (T) + +INSTANTIATE_ABS(signed char); +INSTANTIATE_ABS(short); +INSTANTIATE_ABS(int); +INSTANTIATE_ABS(long); +INSTANTIATE_ABS(long long); + +#define SPECIALIZE_UABS(T) \ + template <> \ + /* static */ inline unsigned T \ + abs (unsigned T x) \ + { \ + return x; \ + } + +SPECIALIZE_UABS(char) +SPECIALIZE_UABS(short) +SPECIALIZE_UABS(int) +SPECIALIZE_UABS(long) +SPECIALIZE_UABS(long long) template <class T> void