builtins.c (c_getstr): Correct thinko in last change and further cleanup.
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Mon, 10 Sep 2001 20:23:35 +0000 (20:23 +0000)
committerRichard Kenner <kenner@gcc.gnu.org>
Mon, 10 Sep 2001 20:23:35 +0000 (16:23 -0400)
* builtins.c (c_getstr): Correct thinko in last change and further
cleanup.

From-SVN: r45519

gcc/ChangeLog
gcc/builtins.c

index c5ae29961469e6f4cfb024cafac05fec9640c1fc..e656e9b025acbaf8fd7ad837a44bbdbff0a3f6ac 100644 (file)
@@ -1,3 +1,8 @@
+Mon Sep 10 16:26:44 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+       * builtins.c (c_getstr): Correct thinko in last change and further
+       cleanup.
+
 2001-09-10  Tim Freeman <tim@fungibole.com>
 
        * dwarf2out.c (incomplete_types, decl_scope_table): Make them
index 9adbf96153c276e86a761674f7ef5bfac262ef11..7cd7e899113d1e8109f91af07d1a039c174e231b 100644 (file)
@@ -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)