File: doit.sh

package info (click to toggle)
enca 1.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,948 kB
  • sloc: ansic: 10,297; sh: 5,858; xml: 2,132; makefile: 700; perl: 261
file content (79 lines) | stat: -rwxr-xr-x 1,605 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /bin/bash
charsets="$@"
base=$1
language=$(basename $(pwd))
target=$language.h

xlate () {
  ../xlt ../maps/$1.map ../maps/$2.map
}

# This is a recursive call.
if test -z "$base"; then
  for d in `ls */doit.sh | cut -d/ -f1`; do
    echo '[ '$d' ]'
    cd ./$d >/dev/null
    ./doit.sh
    cd .. >/dev/null
  done
  exit 0
fi

# Counts
for cs in $charsets; do
  echo '+'$cs...
  if test "$cs" != "$base"; then
    if test -s $cs.xbase; then
      mv -f $cs.xbase $cs.base
    else
      rm -f $cs.xbase 2>/dev/null
      xlate $base $cs <$base.base >$cs.base
      if test ! -s $cs.base; then
        echo "Cannot create $cs.base" 2>&1
        exit 1
      fi
    fi
  fi
  ../basetoc $cs <$cs.base >$cs.c
done

# Pairs
if test -f paircounts.$base; then
  if test `echo $charsets | wc -w` -gt 8; then
    echo '*** Warning: more than 8 charsets.  Expect coredumps... ***' 1>&2
  fi
  for cs in $charsets; do
    echo '++'$cs...
    if test -f paircounts.$cs; then
      cp paircounts.$cs $cs.pair
    else
      xlate $base $cs <$base.pair >$cs.pair
    fi
    if test ! -s $cs.pair; then
      echo "Cannot create $cs.pair" 2>&1
      exit 1
    fi
    ../pairtoc $cs ../letters/$cs.letters <$cs.pair >$cs.p.c
  done
fi

# Totals
echo =totals...
../totals.pl $charsets
if test ! -s totals.c; then
  echo "Cannot create totals.c" 2>&1
  exit 1
fi

echo '>'$target...
echo "/*****  THIS IS A GENERATED FILE.  DO NOT TOUCH!  *****/" >$target
for cs in $charsets; do
  cat $cs.c >>$target
  if test -s $cs.p.c; then
    cat $cs.p.c >>$target
  fi
  echo >>$target
done
cat totals.c >>$target

echo done.