version up to 1.0.5
[platform/upstream/fribidi.git] / gen.tab / packtab.c
index 45f8658..af39888 100644 (file)
@@ -16,7 +16,7 @@
  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
  * Boston, MA 02110-1301, USA  
  * 
- * For licensing issues, contact <fwpg@sharif.edu>. 
+ * For licensing issues, contact <fribidi.license@gmail.com>.
  */
 
 /*
   1 <= max_depth <= 21
 */
 
-#if HAVE_CONFIG_H+0
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif /* HAVE_CONFIG_H */
 
 #include <stdio.h>
-#if STDC_HEADERS+0
+#ifdef STDC_HEADERS
 # include <stdlib.h>
 # include <stddef.h>
 #else
 #  include <stdlib.h>
 # endif
 #endif
-#if HAVE_STRING_H+0
+#ifdef HAVE_STRING_H
 # if !STDC_HEADERS && HAVE_MEMORY_H
 #  include <memory.h>
 # endif
 # include <string.h>
 #endif
-#if HAVE_STRINGS_H+0
+#ifdef HAVE_STRINGS_H
 # include <strings.h>
 #endif
 
@@ -55,7 +55,7 @@ static int n, a, max_depth, digits, tab_width, per_row;
 static long N;
 signed int def_key;
 static uni_table temp, x, perm, *tab;
-static long pow[22], cluster, cmpcluster;
+static long packtab_pow[22], cluster, cmpcluster;
 static const char *const *name, *key_type_name, *table_name, *macro_name;
 static FILE *f;
 
@@ -71,22 +71,22 @@ most_binary (
   if (min == max)
     return max;
 
-  for (i = 21; max < pow[i]; i--)
+  for (i = 21; max < packtab_pow[i]; i--)
     ;
   ii = i;
-  while (i && !((min ^ max) & pow[i]))
+  while (i && !((min ^ max) & packtab_pow[i]))
     i--;
 
   if (ii == i)
     {
       /* min is less than half of max */
-      for (i = 21 - 1; min < pow[i]; i--)
+      for (i = 21 - 1; min < packtab_pow[i]; i--)
        ;
       i++;
-      return pow[i];
+      return packtab_pow[i];
     }
 
-  return max & (pow[i] - 1);
+  return max & (packtab_pow[i] - 1);
 }
 
 static void
@@ -97,9 +97,9 @@ init (
   register int i;
 
   /* initialize powers of two */
-  pow[0] = 1;
+  packtab_pow[0] = 1;
   for (i = 1; i <= 21; i++)
-    pow[i] = pow[i - 1] << 1;
+    packtab_pow[i] = packtab_pow[i - 1] << 1;
 
   /* reduce number of elements to get a more binary number */
   {
@@ -114,13 +114,13 @@ init (
     N = most_binary (essen, N);
   }
 
-  for (n = 21; N % pow[n]; n--)
+  for (n = 21; N % packtab_pow[n]; n--)
     ;
   digits = (n + 3) / 4;
   for (i = 6; i; i--)
-    if (pow[i] * (tab_width + 1) < 80)
+    if (packtab_pow[i] * (tab_width + 1) < 80)
       break;
-  per_row = pow[i];
+  per_row = packtab_pow[i];
 }
 
 static int
@@ -180,7 +180,7 @@ bt (
   for (i = 1 - t[lev] % 2; i <= nn + (t[lev] >> nn) % 2; i++)
     {
       nn -= (p[lev] = i);
-      clusters[lev] = cluster = (i && nn >= 0) ? pow[i] : t[lev];
+      clusters[lev] = cluster = (i && nn >= 0) ? packtab_pow[i] : t[lev];
       cmpcluster = cluster + 1;
 
       t[lev + 1] = (t[lev] - 1) / cluster + 1;
@@ -305,7 +305,7 @@ write_array (
     {
       int kk, jj;
       fprintf (f, "\n#define %sLev%d_%0*lX 0x%0X", table_name,
-              best_lev - lev - 1, digits, x[i] * pow[n - nn], ofs);
+              best_lev - lev - 1, digits, x[i] * packtab_pow[n - nn], ofs);
       kk = x[i] * cluster;
       if (!lev)
        if (name)
@@ -326,9 +326,9 @@ write_array (
        for (j = 0; j < cluster; j++, kk++)
          fprintf (f, "\n  %sLev%d_%0*lX,  /* %0*lX..%0*lX */", table_name,
                   best_lev - lev, digits,
-                  tab[lev][kk] * pow[n - nn - best_p[lev]], digits,
-                  x[i] * pow[n - nn] + j * pow[n - nn - best_p[lev]], digits,
-                  x[i] * pow[n - nn] + (j + 1) * pow[n - nn - best_p[lev]] -
+                  tab[lev][kk] * packtab_pow[n - nn - best_p[lev]], digits,
+                  x[i] * packtab_pow[n - nn] + j * packtab_pow[n - nn - best_p[lev]], digits,
+                  x[i] * packtab_pow[n - nn] + (j + 1) * packtab_pow[n - nn - best_p[lev]] -
                   1);
       ofs += cluster;
       jj = i;
@@ -372,7 +372,7 @@ write_source (
       if (j != 0)
        fprintf (f, " >> %d", j);
       if (i)
-       fprintf (f, " & 0x%02lx) +", pow[best_p[best_lev - 1 - i]] - 1);
+       fprintf (f, " & 0x%02lx) +", packtab_pow[best_p[best_lev - 1 - i]] - 1);
       j += best_p[best_lev - 1 - i];
     }
   fprintf (f, ")");