scanflags.c revision 303975
1262569Simp/* scanflags - flags used by scanning. */ 2262569Simp 3262569Simp/* Copyright (c) 1990 The Regents of the University of California. */ 4262569Simp/* All rights reserved. */ 5262569Simp 6262569Simp/* This code is derived from software contributed to Berkeley by */ 7262569Simp/* Vern Paxson. */ 8262569Simp 9262569Simp/* The United States Government has rights in this work pursuant */ 10262569Simp/* to contract no. DE-AC03-76SF00098 between the United States */ 11270864Simp/* Department of Energy and the University of California. */ 12262569Simp 13262569Simp/* This file is part of flex. */ 14262569Simp 15262569Simp/* Redistribution and use in source and binary forms, with or without */ 16270864Simp/* modification, are permitted provided that the following conditions */ 17270864Simp/* are met: */ 18270864Simp 19270864Simp/* 1. Redistributions of source code must retain the above copyright */ 20262569Simp/* notice, this list of conditions and the following disclaimer. */ 21262569Simp/* 2. Redistributions in binary form must reproduce the above copyright */ 22262569Simp/* notice, this list of conditions and the following disclaimer in the */ 23262569Simp/* documentation and/or other materials provided with the distribution. */ 24262569Simp 25262569Simp/* Neither the name of the University nor the names of its contributors */ 26262569Simp/* may be used to endorse or promote products derived from this software */ 27262569Simp/* without specific prior written permission. */ 28262569Simp 29262569Simp/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */ 30262569Simp/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ 31262569Simp/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */ 32262569Simp/* PURPOSE. */ 33270864Simp 34284090Sian#include "flexdef.h" 35270864Simp 36262569Simpscanflags_t* _sf_stk = NULL; 37270864Simpsize_t _sf_top_ix=0, _sf_max=0; 38270864Simp 39270864Simpvoid 40270864Simpsf_push (void) 41270864Simp{ 42270864Simp if (_sf_top_ix + 1 >= _sf_max) 43270864Simp _sf_stk = (scanflags_t*) flex_realloc ( (void*) _sf_stk, sizeof(scanflags_t) * (_sf_max += 32)); 44270864Simp 45262569Simp // copy the top element 46270864Simp _sf_stk[_sf_top_ix + 1] = _sf_stk[_sf_top_ix]; 47270864Simp ++_sf_top_ix; 48270864Simp} 49270864Simp 50270864Simpvoid 51262569Simpsf_pop (void) 52262569Simp{ 53262569Simp assert(_sf_top_ix > 0); 54262569Simp --_sf_top_ix; 55262569Simp} 56262569Simp 57262569Simp/* one-time initialization. Should be called before any sf_ functions. */ 58262569Simpvoid 59262569Simpsf_init (void) 60262569Simp{ 61262569Simp assert(_sf_stk == NULL); 62262569Simp _sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32)); 63262569Simp if (!_sf_stk) 64262569Simp lerrsf_fatal(_("Unable to allocate %ld of stack"), 65262569Simp (void *)(uintptr_t)sizeof(scanflags_t)); 66262569Simp _sf_stk[_sf_top_ix] = 0; 67262569Simp} 68262569Simp 69262569Simp/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */ 70262569Simp