|
| 1 | +/* Copyright 2015 Samsung Electronics Co., Ltd. |
| 2 | + * |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +/** \addtogroup ecma ECMA |
| 17 | + * @{ |
| 18 | + * |
| 19 | + * \addtogroup ecmahelpers Helpers for operations with ECMA characters |
| 20 | + * @{ |
| 21 | + */ |
| 22 | + |
| 23 | +#include "ecma-globals.h" |
| 24 | +#include "ecma-helpers.h" |
| 25 | + |
| 26 | +/** |
| 27 | + * Check if specified character is the newline character |
| 28 | + * |
| 29 | + * @return true - if the character is "<LF>" character according to ECMA-262 v5, Table 3, |
| 30 | + * false - otherwise. |
| 31 | + */ |
| 32 | +bool |
| 33 | +ecma_char_is_new_line (ecma_char_t c) /**< character value */ |
| 34 | +{ |
| 35 | + return (c == '\x0D'); |
| 36 | +} /* ecma_char_is_new_line */ |
| 37 | + |
| 38 | +/** |
| 39 | + * Check if specified character the carriage return character |
| 40 | + * |
| 41 | + * @return true - if the character is "<CR>" character according to ECMA-262 v5, Table 3, |
| 42 | + * false - otherwise. |
| 43 | + */ |
| 44 | +bool |
| 45 | +ecma_char_is_carriage_return (ecma_char_t c) /**< character value */ |
| 46 | +{ |
| 47 | + return (c == '\x0A'); |
| 48 | +} /* ecma_char_is_carriage_return */ |
| 49 | + |
| 50 | +/** |
| 51 | + * Check if specified character is one of LineTerminator (ECMA-262 v5, Table 3) characters |
| 52 | + * |
| 53 | + * @return true - if the character is one of LineTerminator characters, |
| 54 | + * false - otherwise. |
| 55 | + */ |
| 56 | +bool |
| 57 | +ecma_char_is_line_terminator (ecma_char_t c) /**< character value */ |
| 58 | +{ |
| 59 | + /* FIXME: Handle <LS> and <PS> (ECMA-262 v5, 7.3, Table 3) when Unicode would be supported */ |
| 60 | + |
| 61 | + return (ecma_char_is_carriage_return (c) |
| 62 | + || ecma_char_is_new_line (c)); |
| 63 | +} /* ecma_char_is_line_terminator */ |
| 64 | + |
| 65 | +/** |
| 66 | + * @} |
| 67 | + * @} |
| 68 | + */ |
0 commit comments