1
// Copyright (C) 2002-2005 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2002-11-29
5
// Last changed: 2005-12-21
8
#include <dolfin/dolfin_log.h>
9
#include <dolfin/utils.h>
11
using namespace dolfin;
13
//-----------------------------------------------------------------------------
14
bool dolfin::suffix(const char *string, const char *suffix)
16
// Step to end of string
18
for (; string[i]; i++);
20
// Step to end of suffix
22
for (; suffix[j]; j++);
24
// String can not be shorter than suffix
29
for (unsigned int k = i-j; k < i; k++)
30
if ( string[k] != suffix[k-i+j] )
35
//-----------------------------------------------------------------------------
36
void dolfin::remove_newline(char *string)
38
for (unsigned int i = 0; string[i]; i++)
39
if ( string[i] == '\n' ){
44
//-----------------------------------------------------------------------------
45
int dolfin::length(const char *string)
48
for (; string[n]; n++);
51
//-----------------------------------------------------------------------------
52
void dolfin::delay(real seconds)
56
warning("Delay must be positive.");
61
req.tv_sec = (int) floor(seconds);
62
req.tv_nsec = (int) (1000000000.0 * (seconds - floor(seconds)));
66
//-----------------------------------------------------------------------------
67
std::string dolfin::date()
71
std::string current_date(ctime(&t));
73
// Remove trailing newline
74
if ( current_date[current_date.length() - 1] == '\n' )
75
current_date.erase(current_date.length() - 1);
79
//-----------------------------------------------------------------------------