~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to graph/triefa.cP

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This software may only be used by you under license from AT&T Corp.
 
3
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
 
4
    AT&T's Internet website having the URL:
 
5
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
 
6
    If you received this software without first entering into a license
 
7
    with AT&T, you have an infringing copy of this software and cannot use
 
8
    it without violating AT&T's intellectual property rights.
 
9
*/
 
10
#pragma prototyped
 
11
 
 
12
/* File - TrieFA.ins.c
 
13
 *
 
14
 *    This file contains code to be included in the scanner file using a
 
15
 * generated trie-based FA.
 
16
 */
 
17
 
 
18
#include "triefa.h"
 
19
 
 
20
#ifdef UNDERLINE
 
21
static long CharMask[28] = {
 
22
        0x0000001,      0x0000000,      0x0000004,      0x0000008,      
 
23
        0x0000010,      0x0000020,      0x0000040,      0x0000080,
 
24
        0x0000100,      0x0000200,      0x0000400,      0x0000800,
 
25
        0x0001000,      0x0002000,      0x0004000,      0x0008000,
 
26
        0x0010000,      0x0020000,      0x0040000,      0x0080000,
 
27
        0x0100000,      0x0200000,      0x0400000,      0x0800000,
 
28
        0x1000000,      0x2000000,  0x4000000,  0x8000000,
 
29
};
 
30
 
 
31
#define IN_MASK_RANGE(C)        (islower(C) || ((C) == '_'))
 
32
#define MASK_INDEX(C)   ((C) - '_')
 
33
 
 
34
#else
 
35
static long CharMask[26] = {
 
36
        0x0000001,      0x0000002,      0x0000004,      0x0000008,      
 
37
        0x0000010,      0x0000020,      0x0000040,      0x0000080,
 
38
        0x0000100,      0x0000200,      0x0000400,      0x0000800,
 
39
        0x0001000,      0x0002000,      0x0004000,      0x0008000,
 
40
        0x0010000,      0x0020000,      0x0040000,      0x0080000,
 
41
        0x0100000,      0x0200000,      0x0400000,      0x0800000,
 
42
        0x1000000,      0x2000000                                               
 
43
};
 
44
 
 
45
#define IN_MASK_RANGE(C)        islower(C)
 
46
#define MASK_INDEX(C)           ((C) - 'a')
 
47
 
 
48
#endif
 
49
 
 
50
static short            TFA_State;
 
51
 
 
52
/* TFA_Init:
 
53
 *
 
54
 *    Initialize the trie FA.
 
55
 */
 
56
#define TFA_Init() TFA_State = 0
 
57
 
 
58
/* TFA_Advance:
 
59
 *
 
60
 *    Advance to the next state (or -1) on the lowercase letter c.  This should be an
 
61
 * inline routine, but the C++ implementation isn't advanced enough so we use a macro.
 
62
 */
 
63
#define TFA_Advance(C)  {                                                                                                                       \
 
64
        char            c = C;                                                                                                                          \
 
65
        if (TFA_State >= 0) {                                                                                                                   \
 
66
                if (isupper(c))                                                                                                                         \
 
67
                        c = tolower(c);                                                                                                                 \
 
68
                else if (! IN_MASK_RANGE(c)) {                                                                                          \
 
69
                        TFA_State = -1;                                                                                                                 \
 
70
                        goto TFA_done;                                                                                                                  \
 
71
                }                                                                                                                                                       \
 
72
                if (TrieStateTbl[TFA_State].mask & CharMask[MASK_INDEX(c)]) {                           \
 
73
                        short           i = TrieStateTbl[TFA_State].trans_base;                                         \
 
74
                        while (TrieTransTbl[i].c != c)                                                                                  \
 
75
                                i++;                                                                                                                            \
 
76
                        TFA_State = TrieTransTbl[i].next_state;                                                                 \
 
77
                }                                                                                                                                                       \
 
78
                else                                                                                                                                            \
 
79
                        TFA_State = -1;                                                                                                                 \
 
80
        }                                                                                                                                                               \
 
81
  TFA_done:;                                                                                                                                            \
 
82
} /* end of TFA_Advance. */
 
83
 
 
84
/* TFA_Definition:
 
85
 *
 
86
 *    Return the definition (if any) associated with the current state.
 
87
 */
 
88
#define TFA_Definition() \
 
89
        ((TFA_State < 0) ? -1 : TrieStateTbl[TFA_State].def)