Statistics
| Revision:

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

History | View | Annotate | Download (675 Bytes)

1
/*
2
 * $Id: val.cpp 1652 2014-02-17 07:41:34Z johnoel $
3
 *
4
 * Author: David Fournier
5
 * Copyright (c) 2008-2012 Regents of the University of California
6
 */
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
    z = sscanf((const char*)s, "%x", &v);
15
  else
16
    z = sscanf((const char*)s, "%d", &v);
17

    
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
    z = sscanf((const char*)s, "%x", &v);
31
  else
32
    z = sscanf((const char*)s, "%d", &v);
33

    
34
  if (z != 1)
35
    code = 1;
36
  else
37
    code = 0;
38
  return v;
39
}