1# $Header: /home/yav/xpx/RCS/xbmsize.awk,v 1.2 1996/03/26 12:32:17 yav Exp $
2# pick up bitmap size section from X11 bitmap files
3# written by yav (UHD98984@pcvan.or.jp)
4#
5# input:
6# |#define foo_width 48
7# |#define foo_height 48
8# |static char foo_bits[] = {
9# |   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70,
10# |	:
11# |   0x00, 0xff, 0xff, 0xff, 0xff, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30};
12#
13# output:
14# |{48, 48, foo_bits},
15#
16# input:
17# |#define foo_width 48
18# |#define foo_height 48
19# |#define foo_x_hot 20
20# |#define foo_y_hot 27
21# |static unsigned char foo_bits[] = {
22# |   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70,
23# |	:
24# |   0x00, 0xff, 0xff, 0xff, 0xff, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30};
25#
26# output:
27# |{48, 48, 20, 27, foo_bits},
28#
29BEGIN {x = y = -1;}
30
31/\#define .*_width/ {w = $3;}
32/\#define .*_height/ {h = $3;}
33/\#define .*_x_hot/ {x = $3;}
34/\#define .*_y_hot/ {y = $3;}
35
36/static.* char .*_bits\[\]/ {
37  printf("{%d, %d, ", w, h);
38  if (x >= 0 && y >= 0)
39    printf("%d, %d, ", x, y);
40  if ($2 == "unsigned")
41    name = $4;
42  else
43    name = $3;
44  split(name, a, "[");		# foo_bits[] -> foo_bits
45  printf("%s},\n", a[1]);
46  w = h = 0;
47  x = y = -1;
48}
49