blob: d6e5eeed91f8f5a592e53273f09a878f54b860ef [file] [log] [blame]
daniel@transgaming.com91ed1492010-10-29 03:11:43 +00001//
2// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
Zhenyao Mocc4ec642013-09-23 14:57:10 -04007#include "compiler/util.h"
daniel@transgaming.com91ed1492010-10-29 03:11:43 +00008
Zhenyao Mof1d723c2013-09-23 14:57:07 -04009#include <limits>
10
Zhenyao Mocc4ec642013-09-23 14:57:10 -040011#include "compiler/preprocessor/numeric_lex.h"
daniel@transgaming.com91ed1492010-10-29 03:11:43 +000012
Zhenyao Mof1d723c2013-09-23 14:57:07 -040013bool atof_clamp(const char *str, float *value)
daniel@transgaming.com91ed1492010-10-29 03:11:43 +000014{
Zhenyao Mocc4ec642013-09-23 14:57:10 -040015 bool success = pp::numeric_lex_float(str, value);
Zhenyao Mof1d723c2013-09-23 14:57:07 -040016 if (!success)
17 *value = std::numeric_limits<float>::max();
18 return success;
daniel@transgaming.com91ed1492010-10-29 03:11:43 +000019}
Zhenyao Mof1d723c2013-09-23 14:57:07 -040020
21bool atoi_clamp(const char *str, int *value)
22{
Zhenyao Mocc4ec642013-09-23 14:57:10 -040023 bool success = pp::numeric_lex_int(str, value);
24 if (!success)
Zhenyao Mof1d723c2013-09-23 14:57:07 -040025 *value = std::numeric_limits<int>::max();
Zhenyao Mocc4ec642013-09-23 14:57:10 -040026 return success;
Zhenyao Mof1d723c2013-09-23 14:57:07 -040027}
28