File: mkmodelist.sh

package info (click to toggle)
vflib3 3.6.14.dfsg-3+nmu3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 11,536 kB
  • ctags: 3,710
  • sloc: ansic: 35,811; sh: 10,357; asm: 3,290; makefile: 962; lisp: 123; perl: 109; awk: 43
file content (91 lines) | stat: -rwxr-xr-x 1,681 bytes parent folder | download | duplicates (9)
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
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh

k_dev=$1


MODES_MF=`kpsewhich modes.mf`

if [ x-${MODES_MF} = x- ] 
then
  echo "Not found: modes.mf" >&2
  exit;
fi

if [ ! -f ${MODES_MF} ] 
then
  echo "Not found: modes.mf" >&2
  exit;
fi



cat ${MODES_MF} \
| awk -v DEVNAME=${k_dev} '

BEGIN {
  DEVDPI = "";
} 

END {
  if (DEVDPI == ""){
    printf("-1\n");  # not found
    exit 1;
  }
  printf("%s\n", DEVDPI);
  exit 0;
} 

# Line: e.g.,  mode_def ljfour =                       % 600dpi HP LaserJet 4
/^mode_def/ { 
  mode=$2; 
  ppi=-1; 
  ppiv=-1; 
  asp=1.0;
  i=index($0, "%");
  x=substr($0, i);
  desc=substr($0, i + match(x, "[a-zA-Z0-9]") - 1);
}

# Line: e.g.,     mode_param (pixels_per_inch, 600);
/^[ \t]*mode_param[ \t]*\([ \t]*pixels_per_inch, [ \t]*[0-9.]+\);/ {
  match($3, "[0-9.]*");
  ppi=substr($3, 1, RLENGTH);
  ppiv=-1; 
}

# Line: e.g.,     mode_param (aspect_ratio, 4/3);
# Currently, aspect ratio must be 1
/^[ \t]*mode_param[ \t]*\([ \t]*aspect_ratio[ \t]*,[ \t]*[0-9./]+[ \t]*);/ {
  i=match($0, ",[ \t]*");
  s0=i+RLENGTH;
  x=substr($0, s0);
  len=match(x, ")");
  asp=substr($0, s0, len-1);
  ppiv=asp*ppi;
  ppi=-1; ### ignore this entry.
}

# Line: e.g.,   mode_param (aspect_ratio, 180 / pixels_per_inch);
/^[ \t]*mode_param[ \t]*\([ \t]*aspect_ratio, [ \t]*.*\/[ \t]*pixels_per_inch)/ {
  i=match($0, ",[ \t]*[0-9.]");
  x=substr($0, i+RLENGTH-1);
  s0=i+RLENGTH-1;
  match(x, "[ \t]*/");
  ppiv=substr($0, s0, RSTART-1);
  asp=ppi/ppiv;
  ppi=-1; ### ignore this entry.
}

# Line: e.g., enddef;
/^enddef/ {
  if ((mode != "") && (ppi > 0)){
    if ((ppiv < 0) && (mode == DEVNAME)){
      DEVDPI=ppi;
    }
    mode=""; 
    ppi=-1; 
    ppiv=-1; 
    desc="";
  }
}  
'