From bf06b5d8410b3feb3994ab15512a6de0fff9bdb0 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Mon, 10 Sep 2001 20:23:35 +0000 Subject: builtins.c (c_getstr): Correct thinko in last change and further cleanup. * builtins.c (c_getstr): Correct thinko in last change and further cleanup. From-SVN: r45519 --- gcc/ChangeLog | 5 +++++ gcc/builtins.c | 21 +++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5ae299..e656e9b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 10 16:26:44 2001 Richard Kenner + + * builtins.c (c_getstr): Correct thinko in last change and further + cleanup. + 2001-09-10 Tim Freeman * dwarf2out.c (incomplete_types, decl_scope_table): Make them diff --git a/gcc/builtins.c b/gcc/builtins.c index 9adbf96..7cd7e89 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -296,29 +296,22 @@ c_getstr (src) { tree offset_node; HOST_WIDE_INT offset; - int max; - const char *ptr; src = string_constant (src, &offset_node); if (src == 0) return 0; - max = TREE_STRING_LENGTH (src) - 1; - ptr = TREE_STRING_POINTER (src); - - if (offset_node == 0 || !host_integerp (offset_node, 0)) - return ptr; - - offset = tree_low_cst (offset_node, 0); - if (offset < 0 || offset > max) + if (offset_node == 0) + return TREE_STRING_POINTER (src); + else if (!host_integerp (offset_node, 1) + || compare_tree_int (offset_node, TREE_STRING_LENGTH (src) - 1) > 0) return 0; - return ptr + offset; + return TREE_STRING_POINTER (src) + tree_low_cst (offset_node, 1); } -/* Return a CONST_INT or CONST_DOUBLE corresponding to target - reading GET_MODE_BITSIZE (MODE) bits from string constant - STR. */ +/* Return a CONST_INT or CONST_DOUBLE corresponding to target reading + GET_MODE_BITSIZE (MODE) bits from string constant STR. */ static rtx c_readstr (str, mode) -- cgit v1.1