scanflags.c revision 250875
1228072Sbapt/* scanflags - flags used by scanning. */ 2228072Sbapt 3228072Sbapt/* Copyright (c) 1990 The Regents of the University of California. */ 4228072Sbapt/* All rights reserved. */ 5228072Sbapt 6228072Sbapt/* This code is derived from software contributed to Berkeley by */ 7228072Sbapt/* Vern Paxson. */ 8228072Sbapt 9228072Sbapt/* The United States Government has rights in this work pursuant */ 10228072Sbapt/* to contract no. DE-AC03-76SF00098 between the United States */ 11228072Sbapt/* Department of Energy and the University of California. */ 12228072Sbapt 13228072Sbapt/* This file is part of flex. */ 14228072Sbapt 15228072Sbapt/* Redistribution and use in source and binary forms, with or without */ 16228072Sbapt/* modification, are permitted provided that the following conditions */ 17228072Sbapt/* are met: */ 18228072Sbapt 19228072Sbapt/* 1. Redistributions of source code must retain the above copyright */ 20228072Sbapt/* notice, this list of conditions and the following disclaimer. */ 21228072Sbapt/* 2. Redistributions in binary form must reproduce the above copyright */ 22228072Sbapt/* notice, this list of conditions and the following disclaimer in the */ 23228072Sbapt/* documentation and/or other materials provided with the distribution. */ 24228072Sbapt 25228072Sbapt/* Neither the name of the University nor the names of its contributors */ 26228072Sbapt/* may be used to endorse or promote products derived from this software */ 27228072Sbapt/* without specific prior written permission. */ 28228072Sbapt 29228072Sbapt/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */ 30228072Sbapt/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ 31228072Sbapt/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ 32228072Sbapt/* PURPOSE. */ 33228072Sbapt 34228072Sbapt#include "flexdef.h" 35228072Sbapt 36228072Sbaptscanflags_t* _sf_stk = NULL; 37228072Sbaptsize_t _sf_top_ix=0, _sf_max=0; 38228072Sbapt 39228072Sbaptvoid 40228072Sbaptsf_push (void) 41228072Sbapt{ 42228072Sbapt if (_sf_top_ix + 1 >= _sf_max) 43228072Sbapt _sf_stk = (scanflags_t*) flex_realloc ( (void*) _sf_stk, sizeof(scanflags_t) * (_sf_max += 32)); 44228072Sbapt 45228072Sbapt // copy the top element 46228072Sbapt _sf_stk[_sf_top_ix + 1] = _sf_stk[_sf_top_ix]; 47228072Sbapt ++_sf_top_ix; 48228072Sbapt} 49228072Sbapt 50228072Sbaptvoid 51228072Sbaptsf_pop (void) 52228072Sbapt{ 53228072Sbapt assert(_sf_top_ix > 0); 54228072Sbapt --_sf_top_ix; 55228072Sbapt} 56228072Sbapt 57228072Sbapt/* one-time initialization. Should be called before any sf_ functions. */ 58228072Sbaptvoid 59228072Sbaptsf_init (void) 60228072Sbapt{ 61228072Sbapt assert(_sf_stk == NULL); 62228072Sbapt _sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32)); 63250125Sjkim if (!_sf_stk) 64250125Sjkim lerrsf_fatal(_("Unable to allocate %ld of stack"), 65250875Sjkim (void *)(uintptr_t)sizeof(scanflags_t)); 66228072Sbapt _sf_stk[_sf_top_ix] = 0; 67228072Sbapt} 68228072Sbapt 69228072Sbapt/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */ 70