blob: 9ac70ddb256961648b229c3c16f087f9088d453c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <lexnum.h>
# QP_CTOI -- Decode an integer token from the input string, advancing the
# input pointer the the first character following the decoded number, and
# returning the number of numeric characters decoded as the function value.
# This is equivalent to the standard CTOI except that it calls LEXNUM first
# to determine the radix of the input number, hence can deals with hex and
# octal numbers as well as decimal.
int procedure qp_ctoi (str, ip, ival)
char str[ARB] #I input string
int ip #U pointer into input string
int ival #O integer value
int ip_save, base, nchars
int gctol(), lexnum()
begin
ip_save = ip
switch (lexnum (str, ip, nchars)) {
case LEX_OCTAL:
base = 8
case LEX_HEX:
base = 16
default:
base = 10
}
ip = ip_save
return (gctol (str, ip, ival, base))
end
|