src/share/vm/utilities/stringUtils.cpp

Thu, 19 Mar 2015 19:53:34 +0100

author
zmajo
date
Thu, 19 Mar 2015 19:53:34 +0100
changeset 7638
aefa2e84b424
parent 7089
6e0cb14ce59b
permissions
-rw-r--r--

8074869: C2 code generator can replace -0.0f with +0.0f on Linux
Summary: Instead of 'fpclass', use cast float->int and double->long to check if value is +0.0f and +0.0d, respectively.
Reviewed-by: kvn, simonis, dlong

iklam@7089 1 /*
iklam@7089 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
iklam@7089 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
iklam@7089 4 *
iklam@7089 5 * This code is free software; you can redistribute it and/or modify it
iklam@7089 6 * under the terms of the GNU General Public License version 2 only, as
iklam@7089 7 * published by the Free Software Foundation.
iklam@7089 8 *
iklam@7089 9 * This code is distributed in the hope that it will be useful, but WITHOUT
iklam@7089 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
iklam@7089 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
iklam@7089 12 * version 2 for more details (a copy is included in the LICENSE file that
iklam@7089 13 * accompanied this code).
iklam@7089 14 *
iklam@7089 15 * You should have received a copy of the GNU General Public License version
iklam@7089 16 * 2 along with this work; if not, write to the Free Software Foundation,
iklam@7089 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
iklam@7089 18 *
iklam@7089 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
iklam@7089 20 * or visit www.oracle.com if you need additional information or have any
iklam@7089 21 * questions.
iklam@7089 22 *
iklam@7089 23 */
iklam@7089 24
iklam@7089 25 #include "precompiled.hpp"
iklam@7089 26 #include "utilities/stringUtils.hpp"
iklam@7089 27
iklam@7089 28 int StringUtils::replace_no_expand(char* string, const char* from, const char* to) {
iklam@7089 29 int replace_count = 0;
iklam@7089 30 size_t from_len = strlen(from);
iklam@7089 31 size_t to_len = strlen(to);
iklam@7089 32 assert(from_len >= to_len, "must not expand input");
iklam@7089 33
iklam@7089 34 for (char* dst = string; *dst && (dst = strstr(dst, from)) != NULL;) {
iklam@7089 35 char* left_over = dst + from_len;
iklam@7089 36 memmove(dst, to, to_len); // does not copy trailing 0 of <to>
iklam@7089 37 dst += to_len; // skip over the replacement.
iklam@7089 38 memmove(dst, left_over, strlen(left_over) + 1); // copies the trailing 0 of <left_over>
iklam@7089 39 ++ replace_count;
iklam@7089 40 }
iklam@7089 41
iklam@7089 42 return replace_count;
iklam@7089 43 }

mercurial