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