summaryrefslogtreecommitdiff
path: root/dviware/dvi2bitmap/DviError.cc
blob: ba5b126d3f6853451b26ca08fbbe3dbe48f629e0 (plain)
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 dvi2bitmap; see README for copyrights and licence */

#include <config.h>

#ifdef HAVE_CSTD_INCLUDE
#include <cstdio>
#include <cstdarg>
#include <cstring>		// for strlen
#else
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#endif
#include <string>
#include <iostream>

#include "DviError.h"

DviError::DviError(const char *fmt,...)
{
    char *p = new char[2*STD::strlen(fmt)];
    va_list ap;
    va_start(ap,fmt);
    STD::vsprintf (p, fmt, ap);
    va_end(ap);
    problem_ = p;
    delete[] p;
}

void DviError::print() const {
    STD::cerr << "DVI error: " << problem_ << STD::endl; }
void DviBug::print() const {
    STD::cerr << "BUG: " << problem_ << STD::endl; }

DviBug::DviBug(const char *fmt,...)
{
    char *p = new char[2*STD::strlen(fmt)];
    va_list ap;
    va_start(ap,fmt);
    vsprintf (p, fmt, ap);
    va_end(ap);
    problem_ = p;
    delete[] p;
}