xref: /minix3/external/bsd/flex/dist/tables_shared.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*357f1050SThomas Veerman #ifdef FLEX_SCANNER
2*357f1050SThomas Veerman /*
3*357f1050SThomas Veerman dnl   tables_shared.c - tables serialization code
4*357f1050SThomas Veerman dnl
5*357f1050SThomas Veerman dnl   Copyright (c) 1990 The Regents of the University of California.
6*357f1050SThomas Veerman dnl   All rights reserved.
7*357f1050SThomas Veerman dnl
8*357f1050SThomas Veerman dnl   This code is derived from software contributed to Berkeley by
9*357f1050SThomas Veerman dnl   Vern Paxson.
10*357f1050SThomas Veerman dnl
11*357f1050SThomas Veerman dnl   The United States Government has rights in this work pursuant
12*357f1050SThomas Veerman dnl   to contract no. DE-AC03-76SF00098 between the United States
13*357f1050SThomas Veerman dnl   Department of Energy and the University of California.
14*357f1050SThomas Veerman dnl
15*357f1050SThomas Veerman dnl   This file is part of flex.
16*357f1050SThomas Veerman dnl
17*357f1050SThomas Veerman dnl   Redistribution and use in source and binary forms, with or without
18*357f1050SThomas Veerman dnl   modification, are permitted provided that the following conditions
19*357f1050SThomas Veerman dnl   are met:
20*357f1050SThomas Veerman dnl
21*357f1050SThomas Veerman dnl   1. Redistributions of source code must retain the above copyright
22*357f1050SThomas Veerman dnl      notice, this list of conditions and the following disclaimer.
23*357f1050SThomas Veerman dnl   2. Redistributions in binary form must reproduce the above copyright
24*357f1050SThomas Veerman dnl      notice, this list of conditions and the following disclaimer in the
25*357f1050SThomas Veerman dnl      documentation and/or other materials provided with the distribution.
26*357f1050SThomas Veerman dnl
27*357f1050SThomas Veerman dnl   Neither the name of the University nor the names of its contributors
28*357f1050SThomas Veerman dnl   may be used to endorse or promote products derived from this software
29*357f1050SThomas Veerman dnl   without specific prior written permission.
30*357f1050SThomas Veerman dnl
31*357f1050SThomas Veerman dnl   THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
32*357f1050SThomas Veerman dnl   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
33*357f1050SThomas Veerman dnl   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34*357f1050SThomas Veerman dnl   PURPOSE.
35*357f1050SThomas Veerman dnl
36*357f1050SThomas Veerman */
37*357f1050SThomas Veerman 
38*357f1050SThomas Veerman /* This file is meant to be included in both the skeleton and the actual
39*357f1050SThomas Veerman  * flex code (hence the name "_shared").
40*357f1050SThomas Veerman  */
41*357f1050SThomas Veerman #ifndef yyskel_static
42*357f1050SThomas Veerman #define yyskel_static static
43*357f1050SThomas Veerman #endif
44*357f1050SThomas Veerman #else
45*357f1050SThomas Veerman #include "flexdef.h"
46*357f1050SThomas Veerman #include "tables.h"
47*357f1050SThomas Veerman #ifndef yyskel_static
48*357f1050SThomas Veerman #define yyskel_static
49*357f1050SThomas Veerman #endif
50*357f1050SThomas Veerman #endif
51*357f1050SThomas Veerman 
52*357f1050SThomas Veerman 
53*357f1050SThomas Veerman /** Get the number of integers in this table. This is NOT the
54*357f1050SThomas Veerman  *  same thing as the number of elements.
55*357f1050SThomas Veerman  *  @param td the table
56*357f1050SThomas Veerman  *  @return the number of integers in the table
57*357f1050SThomas Veerman  */
yytbl_calc_total_len(const struct yytbl_data * tbl)58*357f1050SThomas Veerman yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl)
59*357f1050SThomas Veerman {
60*357f1050SThomas Veerman 	flex_int32_t n;
61*357f1050SThomas Veerman 
62*357f1050SThomas Veerman 	/* total number of ints */
63*357f1050SThomas Veerman 	n = tbl->td_lolen;
64*357f1050SThomas Veerman 	if (tbl->td_hilen > 0)
65*357f1050SThomas Veerman 		n *= tbl->td_hilen;
66*357f1050SThomas Veerman 
67*357f1050SThomas Veerman 	if (tbl->td_id == YYTD_ID_TRANSITION)
68*357f1050SThomas Veerman 		n *= 2;
69*357f1050SThomas Veerman 	return n;
70*357f1050SThomas Veerman }
71