~ubuntu-branches/ubuntu/edgy/k3d/edgy-proposed

« back to all changes in this revision

Viewing changes to modules/javascript/js/src/jsnum.c

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2004-10-06 00:49:35 UTC
  • Revision ID: james.westby@ubuntu.com-20041006004935-54auamz54ve7kwf8
Tags: 0.4.3.0-3
_Really_ apply patch from #274172 (closes: #274172). Sorry. :-(

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
2
 *
3
 
 * The contents of this file are subject to the Netscape Public
4
 
 * License Version 1.1 (the "License"); you may not use this file
5
 
 * except in compliance with the License. You may obtain a copy of
6
 
 * the License at http://www.mozilla.org/NPL/
7
 
 *
8
 
 * Software distributed under the License is distributed on an "AS
9
 
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
 
 * implied. See the License for the specific language governing
11
 
 * rights and limitations under the License.
 
3
 * ***** BEGIN LICENSE BLOCK *****
 
4
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
5
 *
 
6
 * The contents of this file are subject to the Mozilla Public License Version
 
7
 * 1.1 (the "License"); you may not use this file except in compliance with
 
8
 * the License. You may obtain a copy of the License at
 
9
 * http://www.mozilla.org/MPL/
 
10
 *
 
11
 * Software distributed under the License is distributed on an "AS IS" basis,
 
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
13
 * for the specific language governing rights and limitations under the
 
14
 * License.
12
15
 *
13
16
 * The Original Code is Mozilla Communicator client code, released
14
17
 * March 31, 1998.
15
18
 *
16
 
 * The Initial Developer of the Original Code is Netscape
17
 
 * Communications Corporation.  Portions created by Netscape are
18
 
 * Copyright (C) 1998 Netscape Communications Corporation. All
19
 
 * Rights Reserved.
 
19
 * The Initial Developer of the Original Code is
 
20
 * Netscape Communications Corporation.
 
21
 * Portions created by the Initial Developer are Copyright (C) 1998
 
22
 * the Initial Developer. All Rights Reserved.
20
23
 *
21
24
 * Contributor(s):
22
 
 *
23
 
 * Alternatively, the contents of this file may be used under the
24
 
 * terms of the GNU Public License (the "GPL"), in which case the
25
 
 * provisions of the GPL are applicable instead of those above.
26
 
 * If you wish to allow use of your version of this file only
27
 
 * under the terms of the GPL and not to allow others to use your
28
 
 * version of this file under the NPL, indicate your decision by
29
 
 * deleting the provisions above and replace them with the notice
30
 
 * and other provisions required by the GPL.  If you do not delete
31
 
 * the provisions above, a recipient may use your version of this
32
 
 * file under either the NPL or the GPL.
33
 
 *
34
 
 * This Original Code has been modified by IBM Corporation.
35
 
 * Modifications made by IBM described herein are
36
 
 * Copyright (c) International Business Machines
37
 
 * Corporation, 2000
38
 
 *
39
 
 * Modifications to Mozilla code or documentation
40
 
 * identified per MPL Section 3.3
41
 
 *
42
 
 * Date         Modified by     Description of modification
43
 
 * 05/15/2000  IBM Corp.       Modified OS/2 floating point init.
44
 
 */
 
25
 *   IBM Corp.
 
26
 *
 
27
 * Alternatively, the contents of this file may be used under the terms of
 
28
 * either of the GNU General Public License Version 2 or later (the "GPL"),
 
29
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
30
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
31
 * of those above. If you wish to allow use of your version of this file only
 
32
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
33
 * use your version of this file under the terms of the MPL, indicate your
 
34
 * decision by deleting the provisions above and replace them with the notice
 
35
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
36
 * the provisions above, a recipient may use your version of this file under
 
37
 * the terms of any one of the MPL, the GPL or the LGPL.
 
38
 *
 
39
 * ***** END LICENSE BLOCK ***** */
45
40
 
46
41
/*
47
42
 * JS number type and wrapper class.
48
43
 */
49
44
#include "jsstddef.h"
50
 
#ifdef XP_PC
 
45
#if defined(XP_WIN) || defined(XP_OS2)
51
46
#include <float.h>
52
47
#endif
53
48
#include <math.h>
68
63
#include "jsprf.h"
69
64
#include "jsstr.h"
70
65
 
71
 
union dpun {
72
 
    struct {
73
 
#ifdef IS_LITTLE_ENDIAN
74
 
        uint32 lo, hi;
75
 
#else
76
 
        uint32 hi, lo;
77
 
#endif
78
 
    } s;
79
 
    jsdouble d;
80
 
};
81
 
 
82
66
static JSBool
83
67
num_isNaN(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
84
68
{
425
409
/*
426
410
 * Some to most C compilers forbid spelling these at compile time, or barf
427
411
 * if you try, so all but MAX_VALUE are set up by js_InitRuntimeNumberState
428
 
 * using union dpun.
 
412
 * using union jsdpun.
429
413
 */
430
414
static JSConstDoubleSpec number_constants[] = {
431
415
    {0,                         js_NaN_str,          0,{0,0,0}},
438
422
 
439
423
static jsdouble NaN;
440
424
 
441
 
#if !defined __MWERKS__ && !defined __MINGW32__ && defined XP_PC && (defined _M_IX86 || defined __GNUC__)
 
425
 
 
426
#if (defined XP_WIN || defined XP_OS2) &&                                     \
 
427
    !defined __MWERKS__ &&                                                    \
 
428
    (defined _M_IX86 ||                                                       \
 
429
     (defined __GNUC__ && !defined __MINGW32__))
442
430
 
443
431
/*
444
432
 * Set the exception mask to mask all exceptions and set the FPU precision
457
445
js_InitRuntimeNumberState(JSContext *cx)
458
446
{
459
447
    JSRuntime *rt;
460
 
    union dpun u;
 
448
    jsdpun u;
461
449
 
462
450
    rt = cx->runtime;
463
451
    JS_ASSERT(!rt->jsNaN);
954
942
     */
955
943
    start = s1; /* Mark - if string is empty, we return NaN. */
956
944
    value = 0.0;
957
 
    while (1) {
 
945
    for (;;) {
958
946
        uintN digit;
959
947
        jschar c = *s1;
960
948
        if ('0' <= c && c <= '9')