]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - Ada95/gen/gen.c
ncurses 5.7 - patch 20100612
[ncurses.git] / Ada95 / gen / gen.c
index 86cfd0e11fb7fe781f11cc372752b9b8f3a7832f..3ab2b5e1d31e6b86baf065a66da78d6b71660cfa 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2005,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998,2009,2010 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +32,7 @@
 
 /*
     Version Control
-    $Id: gen.c,v 1.47 2007/04/07 22:29:23 tom Exp $
+    $Id: gen.c,v 1.53 2010/05/01 17:08:30 tom Exp $
   --------------------------------------------------------------------------*/
 /*
   This program generates various record structures and constants from the
   to produce the real source.
   */
 
+#ifdef HAVE_CONFIG_H
 #include <ncurses_cfg.h>
+#else
+#include <ncurses.h>
+#define HAVE_USE_DEFAULT_COLORS 1
+#endif
 
 #include <stdlib.h>
 #include <stddef.h>
@@ -71,7 +76,7 @@ find_pos(char *s, unsigned len, int *low, int *high)
   int l = 0;
 
   *high = -1;
-  *low = 8 * len;
+  *low = (int)(8 * len);
 
   for (i = 0; i < len; i++, s++)
     {
@@ -90,9 +95,13 @@ find_pos(char *s, unsigned len, int *low, int *high)
                }
              l++;
              if (little_endian)
-               *s >>= 1;
+               {
+                 *s >>= 1;
+               }
              else
-               *s <<= 1;
+               {
+                 *s = (char)(*s << 1);
+               }
            }
        }
       else
@@ -108,11 +117,11 @@ find_pos(char *s, unsigned len, int *low, int *high)
  * bit size, i.e. they fit into an (u)int or a (u)short.
  */
 static void
-  gen_reps
-  (const name_attribute_pair * nap,    /* array of name_attribute_pair records */
-   const char *name,           /* name of the represented record type  */
-   int len,                    /* size of the record in bytes          */
-   int bias)
+gen_reps(
+         const name_attribute_pair * nap,      /* array of name_attribute_pair records */
+         const char *name,     /* name of the represented record type  */
+         int len,              /* size of the record in bytes          */
+         int bias)
 {
   int i, n, l, cnt = 0, low, high;
   int width = strlen(RES_NAME) + 3;
@@ -124,7 +133,7 @@ static void
   for (i = 0; nap[i].name != (char *)0; i++)
     {
       cnt++;
-      l = strlen(nap[i].name);
+      l = (int)strlen(nap[i].name);
       if (l > width)
        width = l;
     }
@@ -162,7 +171,7 @@ static void
 static void
 chtype_rep(const char *name, attr_t mask)
 {
-  attr_t x = -1;
+  attr_t x = (attr_t)-1;
   attr_t t = x & mask;
   int low, high;
   int l = find_pos((char *)&t, sizeof(t), &low, &high);
@@ -219,7 +228,7 @@ gen_mrep_rep(const char *name)
   mrep_rep("Z", &x);
 
   memset(&x, 0, sizeof(x));
-  x.bstate = -1;
+  x.bstate = (mmask_t) - 1;
   mrep_rep("Bstate", &x);
 
   printf("      end record;\n");
@@ -285,11 +294,12 @@ gen_attr_set(const char *name)
   chtype attr = A_ATTRIBUTES & ~A_COLOR;
   int start = -1;
   int len = 0;
-  int i, set;
+  int i;
+  chtype set;
   for (i = 0; i < (int)(8 * sizeof(chtype)); i++)
 
     {
-      set = attr & 1;
+      set = (attr & 1);
       if (set)
        {
          if (start < 0)
@@ -775,10 +785,12 @@ gen_acs(void)
 {
   printf("   type C_ACS_Map is array (Character'Val (0) .. Character'Val (127))\n");
   printf("        of Attributed_Character;\n");
-#if USE_REENTRANT
+#if USE_REENTRANT || BROKEN_LINKER
   printf("   type C_ACS_Ptr is access C_ACS_Map;\n");
   printf("   function ACS_Map return C_ACS_Ptr;\n");
-  printf("   pragma Import (C, ACS_Map, \"_nc_acs_map\");\n");
+  printf("   pragma Import (C, ACS_Map, \""
+        NCURSES_WRAP_PREFIX
+        "acs_map\");\n");
 #else
   printf("   ACS_Map : C_ACS_Map;\n");
   printf("   pragma Import (C, ACS_Map, \"acs_map\");\n");
@@ -1034,7 +1046,7 @@ wrap_one_var(const char *c_var,
   printf("   function %s return %s\n", ada_func, ada_type);
   printf("   is\n");
   printf("      function Result return %s;\n", c_type);
-  printf("      pragma Import (C, Result, \"_nc_%s\");\n", c_var);
+  printf("      pragma Import (C, Result, \"" NCURSES_WRAP_PREFIX "%s\");\n", c_var);
   printf("   begin\n");
   if (strcmp(c_type, ada_type))
     printf("      return %s (Result);\n", ada_type);
@@ -1147,15 +1159,13 @@ color_def(const char *name, int value)
   printf("   %-16s : constant Color_Number := %d;\n", name, value);
 }
 
-#define HAVE_USE_DEFAULT_COLORS 1
-
 /*
  * Generate all color definitions
  */
 static void
 gen_color(void)
 {
-#ifdef HAVE_USE_DEFAULT_COLORS
+#if HAVE_USE_DEFAULT_COLORS
   color_def("Default_Color", -1);
 #endif
 #ifdef COLOR_BLACK
@@ -1243,7 +1253,7 @@ eti_gen(char *buf, int code, const char *name, int *etimin, int *etimax)
     *etimin = code;
   if (code > *etimax)
     *etimax = code;
-  return strlen(buf);
+  return (int)strlen(buf);
 }
 
 static void
@@ -1485,7 +1495,7 @@ main(int argc, char *argv[])
              }
            printf("   subtype Eti_Error is C_Int range %d .. %d;\n\n",
                   etimin, etimax);
-           printf(buf);
+           printf("%s", buf);
          }
          break;
        default: