File: yylexhid.c

package info (click to toggle)
icmake 7.18.00-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,840 kB
  • sloc: ansic: 7,784; makefile: 3,811; sh: 319; cpp: 83
file content (50 lines) | stat: -rw-r--r-- 1,555 bytes parent folder | download | duplicates (4)
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
/*
                                Y Y L E X H I D . C

                   Function called when yylex_file() is at eof.

    If new hidden functions are defined, then the array hidden[] must be
    enlarged to contain the name of the new function.
*/

#include "iccomp.h"

static int
    hidden_idx = -1;                      /* hidden function idx */

static char
    *cp = nullstring;

int yylex_hidden(char *buf, register int max_size)
{
    register int
        result = 0;

    while (max_size)                        /* fill as much as possible */
    {
        if (!*cp)                           /* test available source */
        {
            if                              /* test if next idx will point */
            (                               /* to another hidden function */
                hidden_idx
                ==
                sizeof(hidden) / sizeof(HIDDEN_FUNCTION_) - 1
            )
                break;                      /* if not: done, return 'result' */

            hidden_idx++;                 /* next idx and next source */


            if (!hidden[hidden_idx].this)
                continue;                   /* if not called, no code */

            cp = hidden[hidden_idx].source;
        }

        result++;                           /* count a char for the return */
        max_size--;                         /* one char filled */
        *buf++ = *cp++;                     /* and copy the char           */
    }

    return (result);                        /* number of chars processed   */
}