Statistics
| Revision:

root / trunk / src / tools99 / val.cpp @ 1652

History | View | Annotate | Download (675 Bytes)

1 417 arnima
/*
2
 * $Id$
3
 *
4
 * Author: David Fournier
5 1106 johnoel
 * Copyright (c) 2008-2012 Regents of the University of California
6 417 arnima
 */
7
#include <fvar.hpp>
8
#include <stdio.h>
9
10
void val(const adstring& s, int& v, int& code)
11
{
12
  int z;
13
  if ( (s.size() > 2) && (s(1,2) == adstring("0x") ))
14 436 johnoel
    z = sscanf((const char*)s, "%x", &v);
15 417 arnima
  else
16 1652 johnoel
    z = sscanf((const char*)s, "%d", &v);
17 417 arnima
18
  if (z != 1)
19
    code = 1;
20
  else
21
    code = 0;
22
}
23
24
int val(const adstring& s)
25
{
26
  int code;
27
  int v;
28
  int z;
29
  if ( (s.size() > 2) && (s(1,2) == adstring("0x") ))
30 436 johnoel
    z = sscanf((const char*)s, "%x", &v);
31 417 arnima
  else
32 1652 johnoel
    z = sscanf((const char*)s, "%d", &v);
33 417 arnima
34
  if (z != 1)
35
    code = 1;
36
  else
37
    code = 0;
38 1106 johnoel
  return v;
39 417 arnima
}