Graphviz
14.1.2~dev.20260123.1158
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 "config.h"
19
20
#include <
expr/exlib.h
>
21
#include <
util/gv_ctype.h
>
22
23
/*
24
* copy input token error context into buf of n chars and reset the context
25
* end of buf returned
26
*/
27
28
char
*
29
excontext
(
Expr_t
* p,
char
* buf,
int
n)
30
{
31
char
*
s
;
32
char
* t;
33
char
* e;
34
35
s
= buf;
36
if
(p->linep > p->line || p->linewrap)
37
{
38
e = buf + n - 5;
39
if
(p->linewrap)
40
{
41
t = p->linep + 1;
42
while
(t < &p->line[
sizeof
(p->line)] &&
gv_isspace
(*t))
43
t++;
44
if
((n = (
sizeof
(p->line) - (t - (p->linep + 1))) - (e -
s
)) > 0)
45
{
46
if
(n > &p->line[
sizeof
(p->line)] - t)
47
t = &p->line[
sizeof
(p->line)];
48
else
t += n;
49
}
50
while
(t < &p->line[
sizeof
(p->line)])
51
*
s
++ = *t++;
52
}
53
t = p->line;
54
if
(p->linewrap)
55
p->linewrap = 0;
56
else
while
(t < p->linep &&
gv_isspace
(*t))
57
t++;
58
if
((n = (p->linep - t) - (e -
s
)) > 0)
59
t += n;
60
while
(t < p->linep)
61
*
s
++ = *t++;
62
p->linep = p->line;
63
t =
"<<< "
;
64
while
((*
s
= *t++))
65
s
++;
66
}
67
*
s
= 0;
68
return
s
;
69
}
excontext
char * excontext(Expr_t *p, char *buf, int n)
Definition
excontext.c:29
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:218
s
Definition
grammar.c:90
lib
expr
excontext.c
Generated by
1.9.8