File: common.cpp

package info (click to toggle)
fityk 0.4.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,472 kB
  • ctags: 2,617
  • sloc: cpp: 19,705; sh: 5,965; xml: 2,325; yacc: 356; makefile: 183; lex: 178
file content (45 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
45
// This file is part of fityk program. Copyright (C) Marcin Wojdyr 
#include "common.h"
RCSID ("$Id: common.cpp,v 1.7 2004/10/27 13:06:46 wojdyr Exp $")

#include <string>
#include <time.h>
#include "ui.h"
#include "other.h"

using namespace std;

int smooth_limit = 0; //TODO use it in GUI version
volatile bool user_interrupt = false;
const vector<fp> fp_v0; //just empty vector
const vector<int> int_v0; //just empty vector

const fp INF = 1e99; //almost ininity. floating points limits are about:
                     // double: 10^+308, float: 10^+38, long double: 10^+4932

const char* fityk_version_line = "# Fityk script. Fityk version: " VERSION;

vector<int> range_vector (int l, int u)
{
    vector<int> v(u - l);
    for (int i = l; i < u; i++)
        v[i - l] = i;
    return v;
}

std::string time_now ()
{
    const time_t t = time(0);
    return ctime (&t);
}

bool is_double (string s) {
    if (s.empty()) return false;
    const char *c = s.c_str();
    char *endptr;
    strtod(c, &endptr);
    while (isspace(*endptr))
        endptr++;
    return (*endptr == 0); 
}