Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
chrtoi.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 Bell Laboratories
14
*
15
* convert a 0 terminated character constant string to an int
16
*/
17
18
#include <
ast/ast.h
>
19
#include <limits.h>
20
#include <stddef.h>
21
22
int
chrtoi
(
const
char
*
s
)
23
{
24
int
c;
25
int
x;
26
char
*p;
27
28
c = 0;
29
for
(
size_t
n = 0; n <
sizeof
(int) * CHAR_BIT; n += CHAR_BIT) {
30
switch
(x = *((
const
unsigned
char
*)
s
++)) {
31
case
'\\'
:
32
x =
chresc
(
s
- 1, &p);
33
s
= p;
34
break
;
35
case
0:
36
return
(c);
37
default
:
// nothing required
38
break
;
39
}
40
c = (c << CHAR_BIT) | x;
41
}
42
return
(c);
43
}
ast.h
chresc
int chresc(const char *, char **)
Definition
chresc.c:22
chrtoi
int chrtoi(const char *s)
Definition
chrtoi.c:22
s
Definition
grammar.c:93
lib
ast
chrtoi.c
Generated by
1.9.8