This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Ensure that constant folding runs with IN_PERL_RUNTIME true, by copying
[perl5.git] / generate_uudmap.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 static const char PL_uuemap[]
5 = "`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
6
7 typedef unsigned char U8;
8
9 /* This will ensure it is all zeros.  */
10 static char PL_uudmap[256];
11
12 int main() {
13   size_t i;
14   char *p;
15
16   for (i = 0; i < sizeof(PL_uuemap) - 1; ++i)
17     PL_uudmap[(U8)PL_uuemap[i]] = i;
18   /*
19    * Because ' ' and '`' map to the same value,
20    * we need to decode them both the same.
21    */
22   PL_uudmap[(U8)' '] = 0;
23
24   i = sizeof(PL_uudmap);
25   p = PL_uudmap;
26
27   fputs("{\n    ", stdout);
28   while (i--) {
29     printf("%d", *p);
30     p++;
31     if (i) {
32       fputs(", ", stdout);
33       if (!(i & 15)) {
34         fputs("\n    ", stdout);
35       }
36     }
37   }
38   puts("\n}");
39
40   return 0;
41 }
42
43