* ldexp.c (exp_print_tree): Print function-like binary nodes as
authorAlan Modra <amodra@gmail.com>
Wed, 28 Jul 2010 06:43:32 +0000 (06:43 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 28 Jul 2010 06:43:32 +0000 (06:43 +0000)
functions rather than in-fix operators.  Use fputs and fputc
where appropriate.

ld/ChangeLog
ld/ldexp.c

index 7635da40d920cad05a86f948594e951670c5e917..fb1804bf1eca9470169b35826aea9613ec9cf32b 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-28  Alan Modra  <amodra@gmail.com>
+
+       * ldexp.c (exp_print_tree): Print function-like binary nodes as
+       functions rather than in-fix operators.  Use fputs and fputc
+       where appropriate.
+
 2010-07-23  Naveen.H.S  <naveen.S@kpitcummins.com>
            Ina Pandit  <ina.pandit@kpitcummins.com>
 
index c0ca818247a66a18aa08fc175dcf801cc0494706..aae94c65c2b7b2e799626b0bf79e930c690ea165 100644 (file)
@@ -1002,6 +1002,8 @@ exp_assert (etree_type *exp, const char *message)
 void
 exp_print_tree (etree_type *tree)
 {
+  bfd_boolean function_like;
+
   if (config.map_file == NULL)
     config.map_file = stderr;
 
@@ -1022,7 +1024,7 @@ exp_print_tree (etree_type *tree)
       minfo ("%s+0x%v", tree->rel.section->name, tree->rel.value);
       return;
     case etree_assign:
-      fprintf (config.map_file, "%s", tree->assign.dst);
+      fputs (tree->assign.dst, config.map_file);
       exp_print_token (tree->type.node_code, TRUE);
       exp_print_tree (tree->assign.src);
       break;
@@ -1030,20 +1032,38 @@ exp_print_tree (etree_type *tree)
     case etree_provided:
       fprintf (config.map_file, "PROVIDE (%s, ", tree->assign.dst);
       exp_print_tree (tree->assign.src);
-      fprintf (config.map_file, ")");
+      fputc (')', config.map_file);
       break;
     case etree_binary:
-      fprintf (config.map_file, "(");
+      function_like = FALSE;
+      switch (tree->type.node_code)
+       {
+       case MAX_K:
+       case MIN_K:
+       case ALIGN_K:
+       case DATA_SEGMENT_ALIGN:
+       case DATA_SEGMENT_RELRO_END:
+         function_like = TRUE;
+       }
+      if (function_like)
+       {
+         exp_print_token (tree->type.node_code, FALSE);
+         fputc (' ', config.map_file);
+       }
+      fputc ('(', config.map_file);
       exp_print_tree (tree->binary.lhs);
-      exp_print_token (tree->type.node_code, TRUE);
+      if (function_like)
+       fprintf (config.map_file, ", ");
+      else
+       exp_print_token (tree->type.node_code, TRUE);
       exp_print_tree (tree->binary.rhs);
-      fprintf (config.map_file, ")");
+      fputc (')', config.map_file);
       break;
     case etree_trinary:
       exp_print_tree (tree->trinary.cond);
-      fprintf (config.map_file, "?");
+      fputc ('?', config.map_file);
       exp_print_tree (tree->trinary.lhs);
-      fprintf (config.map_file, ":");
+      fputc (':', config.map_file);
       exp_print_tree (tree->trinary.rhs);
       break;
     case etree_unary:
@@ -1052,7 +1072,7 @@ exp_print_tree (etree_type *tree)
        {
          fprintf (config.map_file, " (");
          exp_print_tree (tree->unary.child);
-         fprintf (config.map_file, ")");
+         fputc (')', config.map_file);
        }
       break;
 
@@ -1064,9 +1084,7 @@ exp_print_tree (etree_type *tree)
 
     case etree_name:
       if (tree->type.node_code == NAME)
-       {
-         fprintf (config.map_file, "%s", tree->name.name);
-       }
+       fputs (tree->name.name, config.map_file);
       else
        {
          exp_print_token (tree->type.node_code, FALSE);