File: basetoc.c

package info (click to toggle)
xbmc 2%3A11.0~git20120510.82388d5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 154,860 kB
  • sloc: ansic: 620,873; cpp: 546,403; xml: 145,609; sh: 46,565; python: 9,623; pascal: 9,138; makefile: 8,185; asm: 5,787; cs: 5,212; objc: 4,721; java: 1,686; ada: 1,681; perl: 1,514; yacc: 1,315; tcl: 1,048; lisp: 499; awk: 222; lex: 148; sed: 139; ruby: 126
file content (37 lines) | stat: -rw-r--r-- 744 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <ctype.h>

#define mytoupper(x) (islower(x) ? toupper(x) : (x))

int
main(int argc, char *argv[])
{
  unsigned int weights[0x100];
  unsigned int i, j;
  unsigned char c;

  for (i = 0; i < 0x100; i++)
    weights[i] = 0;

  while (scanf("%c %u\n", &c, &j) == 2)
    weights[c] = j;

  puts("/* THIS IS A GENERATED TABLE, see data/basetoc.c. */");
  printf("static const unsigned short int RAW_");
  for (i = 0; argv[1][i]; i++)
    printf("%c", mytoupper(argv[1][i]));
  puts("[] = {");

  for (i = 0; i < 0x100; i++) {
    if (i % 8 == 0)
      printf("  ");
    printf("%4u", weights[i]);
    if (i % 8 == 7)
      printf(",  /* 0x%02x */\n", i-7);
    else
      printf(", ");
  }
  puts("};\n");

  return 0;
}