Switch to unified view

a/HelperStructs/Style.cpp b/HelperStructs/Style.cpp
...
...
25
#include "upadapt/upputils.h"
25
#include "upadapt/upputils.h"
26
#include "utils/smallut.h"
26
#include "utils/smallut.h"
27
27
28
#include <iostream>
28
#include <iostream>
29
#include <string>
29
#include <string>
30
#if __GNUC__ > 4
30
#include <regex>
31
#include <regex>
32
#endif
31
#include <array>
33
#include <array>
32
#include <math.h>
34
#include <math.h>
33
35
34
using namespace std;
36
using namespace std;
35
37
...
...
60
62
61
/* font-size: 10pt; */
63
/* font-size: 10pt; */
62
static const string fntsz_exp(
64
static const string fntsz_exp(
63
    R"((\s*font-size\s*:\s*)([0-9]+)(pt\s*;\s*))"
65
    R"((\s*font-size\s*:\s*)([0-9]+)(pt\s*;\s*))"
64
    );
66
    );
65
static regex fntsz_regex(fntsz_exp);
66
67
67
/* body {margin: 20px 0px 0px 0px;}*/
68
/* body {margin: 20px 0px 0px 0px;}*/
68
static const string bdmrg_exp(
69
static const string bdmrg_exp(
69
    R"((\s*body\s*\{\s*margin:\s*)([0-9]+)(px\s*[0-9]+px\s*[0-9]+px\s*[0-9]+px\s*;\s*\}))"
70
    R"((\s*body\s*\{\s*margin:\s*)([0-9]+)(px\s*[0-9]+px\s*[0-9]+px\s*[0-9]+px\s*;\s*\}))"
70
    );
71
    );
72
#if __GNUC__ > 4
73
// Programs built with gcc 4.8.4 (e.g.: Ubuntu Trusty), crash at
74
// startup while building these (and also crash if we make them non-static).
75
static regex fntsz_regex(fntsz_exp);
71
static regex bdmrg_regex(bdmrg_exp);
76
static regex bdmrg_regex(bdmrg_exp);
77
#endif
72
78
73
string Style::scale_fonts(const string& style, float multiplier)
79
string Style::scale_fonts(const string& style, float multiplier)
74
{
80
{
75
    vector<string> lines;
81
    vector<string> lines;
76
    stringToTokens(style, lines, "\n");
82
    stringToTokens(style, lines, "\n");
83
#if __GNUC__ > 4
77
    for (unsigned int ln = 0; ln < lines.size(); ln++) {
84
    for (unsigned int ln = 0; ln < lines.size(); ln++) {
78
        const string& line = lines[ln];
85
        const string& line = lines[ln];
79
        smatch m;
86
        smatch m;
80
        if (regex_match(line, m, fntsz_regex) && m.size() == 4) {
87
        if (regex_match(line, m, fntsz_regex) && m.size() == 4) {
81
            //cerr << "Got match (sz " << m.size() << ") for " << line << endl;
88
            //cerr << "Got match (sz " << m.size() << ") for " << line << endl;
...
...
95
            snprintf(buf, 20, "%d", nfs);
102
            snprintf(buf, 20, "%d", nfs);
96
            lines[ln] = m[1].str() + buf + m[3].str();
103
            lines[ln] = m[1].str() + buf + m[3].str();
97
            //cerr << "New line: [" << lines[ln] << "]\n";
104
            //cerr << "New line: [" << lines[ln] << "]\n";
98
        }
105
        }
99
    }
106
    }
100
    
107
#endif    
101
    string nstyle = string();
108
    string nstyle = string();
102
    for (auto& ln : lines) {
109
    for (auto& ln : lines) {
103
        nstyle += ln + "\n";
110
        nstyle += ln + "\n";
104
    }
111
    }
105
    return nstyle;
112
    return nstyle;