2002-02-10 Daniel Jacobowitz <drow@mvista.com>
[deliverable/binutils-gdb.git] / binutils / resrc.c
index b38c75d207aab56d7290a44790ac6a75f19f7270..eb7db96cd7ec3d73aacc3edd3315aebc883ceac9 100644 (file)
@@ -1,5 +1,5 @@
 /* resrc.c -- read and write Windows rc files.
-   Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of GNU Binutils.
 #include "bfd.h"
 #include "bucomm.h"
 #include "libiberty.h"
+#include "safe-ctype.h"
 #include "windres.h"
 
 #include <assert.h>
-#include <ctype.h>
 #include <errno.h>
 #include <sys/stat.h>
 #ifdef HAVE_UNISTD_H
@@ -67,7 +67,6 @@
 #endif /* defined (_WIN32) && ! defined (__CYGWIN__) */
 #endif /* ! HAVE_SYS_WAIT_H */
 
-#if defined (_WIN32) && ! defined (__CYGWIN32__)
 #ifndef STDOUT_FILENO
 #define STDOUT_FILENO 1
 #endif
@@ -79,7 +78,7 @@
 
 /* The default preprocessor.  */
 
-#define DEFAULT_PREPROCESSOR "gcc -E -xc-header -DRC_INVOKED"
+#define DEFAULT_PREPROCESSOR "gcc -E -xc -DRC_INVOKED"
 
 /* We read the directory entries in a cursor or icon file into
    instances of this structure.  */
@@ -499,9 +498,6 @@ read_rc_file (filename, preprocessor, preprocargs, language, use_temp_file)
 static void
 close_input_stream ()
 {
-  if (cpp_pipe != NULL)
-    pclose (cpp_pipe);
-  
   if (istream_type == ISTREAM_FILE)
     {
       if (cpp_pipe != NULL)
@@ -845,19 +841,42 @@ define_control (text, id, x, y, width, height, class, style, exstyle)
   n->height = height;
   n->class.named = 0;
   n->class.u.id = class;
-  if (text != NULL)
-    res_string_to_id (&n->text, text);
-  else
-    {
-      n->text.named = 0;
-      n->text.u.id = 0;
-    }
+  if (text == NULL)
+    text = "";
+  res_string_to_id (&n->text, text);
   n->data = NULL;
   n->help = 0;
 
   return n;
 }
 
+struct dialog_control *
+define_icon_control (iid, id, x, y, style, exstyle, help, data, ex)
+     struct res_id iid;
+     unsigned long id;
+     unsigned long x;
+     unsigned long y;
+     unsigned long style;
+     unsigned long exstyle;
+     unsigned long help;
+     struct rcdata_item *data;
+     struct dialog_ex *ex;
+{
+  struct dialog_control *n;
+  if (style == 0)
+    style = SS_ICON | WS_CHILD | WS_VISIBLE;
+  n = define_control (0, id, x, y, 0, 0, CTL_STATIC, style, exstyle);
+  n->text = iid;
+  if (help && !ex)
+    rcparse_warning (_("help ID requires DIALOGEX"));
+  if (data && !ex)
+    rcparse_warning (_("control data requires DIALOGEX"));
+  n->help = help;
+  n->data = data;
+
+  return n;
+}
+
 /* Define a font resource.  */
 
 void
@@ -1870,8 +1889,8 @@ write_rc_resource (e, type, name, res, language)
       if (res->res_info.language != 0 && res->res_info.language != *language)
        fprintf (e, "%sLANGUAGE %d, %d\n",
                 modifiers ? "// " : "",
-                res->res_info.language & 0xff,
-                (res->res_info.language >> 8) & 0xff);
+                res->res_info.language & ((1<<SUBLANG_SHIFT)-1),
+                (res->res_info.language >> SUBLANG_SHIFT) & 0xff);
       if (res->res_info.characteristics != 0)
        fprintf (e, "%sCHARACTERISTICS %lu\n",
                 modifiers ? "// " : "",
@@ -1957,7 +1976,7 @@ write_rc_accelerators (e, accelerators)
       fprintf (e, "  ");
 
       if ((acc->key & 0x7f) == acc->key
-         && isprint ((unsigned char) acc->key)
+         && ISPRINT (acc->key)
          && (acc->flags & ACC_VIRTKEY) == 0)
        {
          fprintf (e, "\"%c\"", acc->key);
@@ -2364,7 +2383,7 @@ write_rc_rcdata (e, rcdata, ind)
            s = ri->u.string.s;
            for (i = 0; i < ri->u.string.length; i++)
              {
-               if (isprint ((unsigned char) *s))
+               if (ISPRINT (*s))
                  putc (*s, e);
                else
                  fprintf (e, "\\%03o", *s);
@@ -2402,7 +2421,7 @@ write_rc_rcdata (e, rcdata, ind)
                if (i + 4 < ri->u.buffer.length || ri->next != NULL)
                  fprintf (e, ",");
                for (j = 0; j < 4; ++j)
-                 if (! isprint (ri->u.buffer.data[i + j])
+                 if (! ISPRINT (ri->u.buffer.data[i + j])
                      && ri->u.buffer.data[i + j] != 0)
                    break;
                if (j >= 4)
@@ -2410,7 +2429,7 @@ write_rc_rcdata (e, rcdata, ind)
                    fprintf (e, "\t// ");
                    for (j = 0; j < 4; ++j)
                      {
-                       if (! isprint (ri->u.buffer.data[i + j]))
+                       if (! ISPRINT (ri->u.buffer.data[i + j]))
                          fprintf (e, "\\%03o", ri->u.buffer.data[i + j]);
                        else
                          {
@@ -2436,7 +2455,7 @@ write_rc_rcdata (e, rcdata, ind)
                if (i + 2 < ri->u.buffer.length || ri->next != NULL)
                  fprintf (e, ",");
                for (j = 0; j < 2; ++j)
-                 if (! isprint (ri->u.buffer.data[i + j])
+                 if (! ISPRINT (ri->u.buffer.data[i + j])
                      && ri->u.buffer.data[i + j] != 0)
                    break;
                if (j >= 2)
@@ -2444,7 +2463,7 @@ write_rc_rcdata (e, rcdata, ind)
                    fprintf (e, "\t// ");
                    for (j = 0; j < 2; ++j)
                      {
-                       if (! isprint (ri->u.buffer.data[i + j]))
+                       if (! ISPRINT (ri->u.buffer.data[i + j]))
                          fprintf (e, "\\%03o", ri->u.buffer.data[i + j]);
                        else
                          {
@@ -2464,7 +2483,7 @@ write_rc_rcdata (e, rcdata, ind)
                if (! first)
                  indent (e, ind + 2);
                if ((ri->u.buffer.data[i] & 0x7f) == ri->u.buffer.data[i]
-                   && isprint (ri->u.buffer.data[i]))
+                   && ISPRINT (ri->u.buffer.data[i]))
                  fprintf (e, "\"%c\"", ri->u.buffer.data[i]);
                else
                  fprintf (e, "\"\\%03o\"", ri->u.buffer.data[i]);
This page took 0.025022 seconds and 4 git commands to generate.