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