Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
excontext.c
Go to the documentation of this file.
1
/*************************************************************************
2
* Copyright (c) 2011 AT&T Intellectual Property
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* https://www.eclipse.org/legal/epl-v10.html
7
*
8
* Contributors: Details at https://graphviz.org
9
*************************************************************************/
10
11
/*
12
* Glenn Fowler
13
* AT&T Research
14
*
15
* expression library
16
*/
17
18
#include <
expr/exlib.h
>
19
#include <
util/gv_ctype.h
>
20
21
/*
22
* copy input token error context into buf of n chars and reset the context
23
* end of buf returned
24
*/
25
26
char
*
27
excontext
(
Expr_t
* p,
char
* buf,
int
n)
28
{
29
char
*
s
;
30
char
* t;
31
char
* e;
32
33
s
= buf;
34
if
(p->linep > p->line || p->linewrap)
35
{
36
e = buf + n - 5;
37
if
(p->linewrap)
38
{
39
t = p->linep + 1;
40
while
(t < &p->line[
sizeof
(p->line)] &&
gv_isspace
(*t))
41
t++;
42
if
((n = (
sizeof
(p->line) - (t - (p->linep + 1))) - (e -
s
)) > 0)
43
{
44
if
(n > &p->line[
sizeof
(p->line)] - t)
45
t = &p->line[
sizeof
(p->line)];
46
else
t += n;
47
}
48
while
(t < &p->line[
sizeof
(p->line)])
49
*
s
++ = *t++;
50
}
51
t = p->line;
52
if
(p->linewrap)
53
p->linewrap = 0;
54
else
while
(t < p->linep &&
gv_isspace
(*t))
55
t++;
56
if
((n = (p->linep - t) - (e -
s
)) > 0)
57
t += n;
58
while
(t < p->linep)
59
*
s
++ = *t++;
60
p->linep = p->line;
61
t =
"<<< "
;
62
while
((*
s
= *t++))
63
s
++;
64
}
65
*
s
= 0;
66
return
s
;
67
}
excontext
char * excontext(Expr_t *p, char *buf, int n)
Definition
excontext.c:27
exlib.h
gv_ctype.h
replacements for ctype.h functions
gv_isspace
static bool gv_isspace(int c)
Definition
gv_ctype.h:55
Expr_s
Definition
expr.h:200
s
Definition
grammar.c:93
lib
expr
excontext.c
Generated by
1.9.8