summaryrefslogtreecommitdiff
path: root/Build/source/utils/t1utils/t1utils-1.39/t1asmhelp.h
blob: c974fc7999f41af94e8e6f9226cde19f493c74d5 (plain)
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
#ifndef T1ASMHELP_H
#define T1ASMHELP_H

static int lenIV = 4;

/* If the line contains an entry of the form `/lenIV <num>' then set the global
   lenIV to <num>.  This indicates the number of random bytes at the beginning
   of each charstring. */

static void
set_lenIV(const char* line)
{
  char *p = strstr(line, "/lenIV ");

  /* Allow lenIV to be negative. Thanks to Tom Kacvinsky <tjk@ams.org> */
  if (p && (isdigit((unsigned char) p[7]) || p[7] == '+' || p[7] == '-')) {
    lenIV = atoi(p + 7);
  }
}


static const char* cs_start = "";

static void
set_cs_start(const char* line)
{
    static int cs_start_set = 0;
    char *p, *q, *r;

    if ((p = strstr(line, "string currentfile"))
        && strstr(line, "readstring")) {
        /* locate the name of the charstring start command */
        for (q = p; q != line && q[-1] != '/'; --q)
            /* nada */;
        if (q != line) {
            for (r = q; r != p && !isspace((unsigned char) *r) && *r != '{'; ++r)
                /* nada */;
            if (cs_start_set)
                free((char*) cs_start);
            cs_start = p = malloc(r - q + 1);
            memcpy(p, q, r - q);
            p[r - q] = 0;
            cs_start_set = 1;
        }
    }
}

#endif