File: getident.c

package info (click to toggle)
icmake 7.12.5-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,776 kB
  • ctags: 1,494
  • sloc: ansic: 7,785; makefile: 3,724; sh: 302; cpp: 95
file content (37 lines) | stat: -rw-r--r-- 970 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
/*
\funcref{getident}{void getident(\params)}
    {
        {char} {*buf} {buffer to store identifier}
    }
    {}
    {error()}
    {lexer()}
    {getident.c}
    {
        {\em getident()} is called from {\em lexer()} when an underscore
        character or a {\em[a-zA-Z]} character is read. {\em lexer()} pushes
        the character back onto the input file and calls {\em getident()} to
        read an identifier.

        Identifiers are defined as starting with {\em[\_a-zA-Z]} followed by
        zero or more {\em[\_a-zA-Z0-9]}.

        {\em getident()} performs no checking of the identifier length. The
        buffer where the identifier is stored is assumed to be large enough to
        hold the name.
    }
*/

#include "icm-pp.h"

void getident(STRING_ *str)
{
    register int ch;

    skipblanks();
    str->len = 0;
    while ((ch = nextchar()) == '_' || isalpha(ch))
        string_append(str, ch);
    pushback(ch);
    string_append(str, 0);
}