Handle multiple target events before commit resume
[deliverable/binutils-gdb.git] / binutils / resrc.c
index f0cacd16b1a7117db1af35125969f08ca54aacdc..59f182837563135246686f5852f8e8f12e87122b 100644 (file)
@@ -1,5 +1,5 @@
 /* resrc.c -- read and write Windows rc files.
-   Copyright (C) 1997-2015 Free Software Foundation, Inc.
+   Copyright (C) 1997-2019 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
    Rewritten by Kai Tietz, Onevision.
 
@@ -215,7 +215,7 @@ run_cmd (char *cmd, const char *redir)
       i++;
 
   i++;
-  argv = alloca (sizeof (char *) * (i + 3));
+  argv = xmalloc (sizeof (char *) * (i + 3));
   i = 0;
   s = cmd;
 
@@ -266,6 +266,7 @@ run_cmd (char *cmd, const char *redir)
 
   pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base,
                  &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH);
+  free (argv);
 
   /* Restore stdout to its previous setting.  */
   dup2 (stdout_save, STDOUT_FILENO);
@@ -2275,7 +2276,7 @@ write_rc_resource (FILE *e, const rc_res_id *type,
            default:
     res_id_print (e, *type, 0);
              break;
-       
+
            PRINT_RT_NAME(RT_MANIFEST);
            PRINT_RT_NAME(RT_ANICURSOR);
            PRINT_RT_NAME(RT_ANIICON);
@@ -2777,7 +2778,7 @@ write_rc_toolbar (FILE *e, const rc_toolbar *tb)
     indent (e, 2);
     if (it->id.u.id == 0)
       fprintf (e, "SEPARATOR\n");
-    else 
+    else
       fprintf (e, "BUTTON %d\n", (int) it->id.u.id);
     it = it->next;
   }
@@ -2892,7 +2893,7 @@ test_rc_datablock_text (rc_uint_type length, const bfd_byte *data)
   int has_nl;
   rc_uint_type c;
   rc_uint_type i;
-  
+
   if (length <= 1)
     return 0;
 
@@ -2923,6 +2924,7 @@ write_rc_messagetable (FILE *e, rc_uint_type length, const bfd_byte *data)
 {
   int has_error = 0;
   const struct bin_messagetable *mt;
+
   fprintf (e, "BEGIN\n");
 
   write_rc_datablock (e, length, data, 0, 0, 0);
@@ -2952,6 +2954,7 @@ write_rc_messagetable (FILE *e, rc_uint_type length, const bfd_byte *data)
            low = windres_get_32 (&wrtarget, mt->items[i].lowid, 4);
            high = windres_get_32 (&wrtarget, mt->items[i].highid, 4);
            offset = windres_get_32 (&wrtarget, mt->items[i].offset, 4);
+
            while (low <= high)
              {
                rc_uint_type elen, flags;
@@ -2971,16 +2974,20 @@ write_rc_messagetable (FILE *e, rc_uint_type length, const bfd_byte *data)
                wr_printcomment (e, "MessageId = 0x%x", low);
                wr_printcomment (e, "");
 
-               /* PR 17512: file: 5c3232dc.  */
-               if (elen)
+               if ((flags & MESSAGE_RESOURCE_UNICODE) == MESSAGE_RESOURCE_UNICODE)
                  {
-                   if ((flags & MESSAGE_RESOURCE_UNICODE) == MESSAGE_RESOURCE_UNICODE)
+                   /* PR 17512: file: 5c3232dc.  */
+                   if (elen > BIN_MESSAGETABLE_ITEM_SIZE * 2)
                      unicode_print (e, (const unichar *) mti->data,
                                     (elen - BIN_MESSAGETABLE_ITEM_SIZE) / 2);
-                   else
+                 }
+               else
+                 {
+                   if (elen > BIN_MESSAGETABLE_ITEM_SIZE)
                      ascii_print (e, (const char *) mti->data,
                                   (elen - BIN_MESSAGETABLE_ITEM_SIZE));
                  }
+
                wr_printcomment (e,"");
                ++low;
                offset += elen;
@@ -3005,7 +3012,7 @@ write_rc_datablock (FILE *e, rc_uint_type length, const bfd_byte *data, int has_
     fprintf (e, "BEGIN\n");
 
   if (show_comment == -1)
-         {
+    {
       if (test_rc_datablock_text(length, data))
        {
          rc_uint_type i, c;
@@ -3018,12 +3025,12 @@ write_rc_datablock (FILE *e, rc_uint_type length, const bfd_byte *data, int has_
                ;
              if (i < length && data[i] == '\n')
                ++i, ++c;
-             ascii_print (e, (const char *) &data[i - c], c);
+             ascii_print(e, (const char *) &data[i - c], c);
            fprintf (e, "\"");
              if (i < length)
                fprintf (e, "\n");
            }
-          
+
          if (i == 0)
              {
              indent (e, 2);
@@ -3046,7 +3053,7 @@ write_rc_datablock (FILE *e, rc_uint_type length, const bfd_byte *data, int has_
              u = (const unichar *) &data[i];
              indent (e, 2);
          fprintf (e, "L\"");
-         
+
              for (c = 0; i < length && c < 160 && u[c] != '\n'; c++, i += 2)
                ;
              if (i < length && u[c] == '\n')
@@ -3084,9 +3091,9 @@ write_rc_datablock (FILE *e, rc_uint_type length, const bfd_byte *data, int has_
                  {
          rc_uint_type k;
          rc_uint_type comment_start;
-         
+
          comment_start = i;
-         
+
          if (! first)
            indent (e, 2);
 
This page took 0.036875 seconds and 4 git commands to generate.