Edit

kc3-lang/angle/src/compiler/util.cpp

Branch :

  • Show log

    Commit

  • Author : Zhenyao Mo
    Date : 2013-09-23 14:57:10
    Hash : cc4ec64c
    Message : Use the same mechanism to process int/float literals This also fixes the float overflow errno leaking bug. BUG= R=alokp@chromium.org Review URL: https://codereview.appspot.com/13368050

  • src/compiler/util.cpp
  • //
    // Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    #include "compiler/util.h"
    
    #include <limits>
    
    #include "compiler/preprocessor/numeric_lex.h"
    
    bool atof_clamp(const char *str, float *value)
    {
        bool success = pp::numeric_lex_float(str, value);
        if (!success)
            *value = std::numeric_limits<float>::max();
        return success;
    }
    
    bool atoi_clamp(const char *str, int *value)
    {
        bool success = pp::numeric_lex_int(str, value);
        if (!success)
            *value = std::numeric_limits<int>::max();
        return success;
    }