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

« back to all changes in this revision

Viewing changes to tools/expr/exlexname.c

  • 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
#pragma prototyped
 
2
/*
 
3
 * Glenn Fowler
 
4
 * AT&T Research
 
5
 *
 
6
 * return lex name for op[subop]
 
7
 */
 
8
 
 
9
#include "exlib.h"
 
10
#include "exop.h"
 
11
 
 
12
#define TOTNAME         3
 
13
#define MAXNAME         16
 
14
 
 
15
char*
 
16
exlexname(int op, int subop)
 
17
{
 
18
        register char*  b;
 
19
 
 
20
        static int      n;
 
21
        static char     buf[TOTNAME][MAXNAME];
 
22
 
 
23
        if (op > MINTOKEN && op < MAXTOKEN)
 
24
                return (char*)exop[op - MINTOKEN];
 
25
        if (++n > TOTNAME)
 
26
                n = 0;
 
27
        b = buf[n];
 
28
        if (op == '=')
 
29
        {
 
30
                if (subop > MINTOKEN && subop < MAXTOKEN)
 
31
                        sfsprintf(b, MAXNAME, "%s=", exop[subop - MINTOKEN]);
 
32
                else if (subop > ' ' && subop <= '~')
 
33
                        sfsprintf(b, MAXNAME, "%c=", subop);
 
34
                else sfsprintf(b, MAXNAME, "(%d)=", subop);
 
35
        }
 
36
        else if (op > ' ' && op <= '~')
 
37
                sfsprintf(b, MAXNAME, "%c", op);
 
38
        else sfsprintf(b, MAXNAME, "(%d)", op);
 
39
        return b;
 
40
}