Deleted Added
sdiff udiff text old ( 261551 ) new ( 286798 )
full compact
1/*-
2 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/teken/teken.c 261551 2014-02-06 13:28:06Z ray $
27 */
28
29#include <sys/cdefs.h>
30#if defined(__FreeBSD__) && defined(_KERNEL)
31#include <sys/param.h>
32#include <sys/lock.h>
33#include <sys/systm.h>
34#define teken_assert(x) MPASS(x)
35#else /* !(__FreeBSD__ && _KERNEL) */
36#include <sys/types.h>
37#include <assert.h>
38#include <stdint.h>
39#include <stdio.h>
40#include <string.h>
41#define teken_assert(x) assert(x)
42#endif /* __FreeBSD__ && _KERNEL */
43
44/* debug messages */
45#define teken_printf(x,...)

--- 354 unchanged lines hidden (view full) ---

400
401static int
402teken_state_numbers(teken_t *t, teken_char_t c)
403{
404
405 teken_assert(t->t_curnum < T_NUMSIZE);
406
407 if (c >= '0' && c <= '9') {
408 /*
409 * Don't do math with the default value of 1 when a
410 * custom number is inserted.
411 */
412 if (t->t_stateflags & TS_FIRSTDIGIT) {
413 t->t_stateflags &= ~TS_FIRSTDIGIT;
414 t->t_nums[t->t_curnum] = 0;
415 } else {
416 t->t_nums[t->t_curnum] *= 10;
417 }
418
419 t->t_nums[t->t_curnum] += c - '0';
420 return (1);
421 } else if (c == ';') {
422 if (t->t_stateflags & TS_FIRSTDIGIT)
423 t->t_nums[t->t_curnum] = 0;
424
425 /* Only allow a limited set of arguments. */
426 if (++t->t_curnum == T_NUMSIZE) {
427 teken_state_switch(t, teken_state_init);

--- 131 unchanged lines hidden ---