Graphviz
14.1.2~dev.20260121.0931
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 "config.h"
19
20
#include <
ast/ast.h
>
21
#include <limits.h>
22
#include <stddef.h>
23
24
int
chrtoi
(
const
char
*
s
)
25
{
26
int
c;
27
int
x;
28
char
*p;
29
30
c = 0;
31
for
(
size_t
n = 0; n <
sizeof
(int) * CHAR_BIT; n += CHAR_BIT) {
32
switch
(x = *((
const
unsigned
char
*)
s
++)) {
33
case
'\\'
:
34
x =
chresc
(
s
- 1, &p);
35
s
= p;
36
break
;
37
case
0:
38
return
(c);
39
default
:
// nothing required
40
break
;
41
}
42
c = (c << CHAR_BIT) | x;
43
}
44
return
(c);
45
}
ast.h
chresc
int chresc(const char *, char **)
Definition
chresc.c:24
chrtoi
int chrtoi(const char *s)
Definition
chrtoi.c:24
s
Definition
grammar.c:90
lib
ast
chrtoi.c
Generated by
1.9.8