|
a/src/smallut.cpp |
|
b/src/smallut.cpp |
|
... |
|
... |
12 |
* You should have received a copy of the GNU General Public License
|
12 |
* You should have received a copy of the GNU General Public License
|
13 |
* along with this program; if not, write to the
|
13 |
* along with this program; if not, write to the
|
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#ifdef BUILDING_RECOLL
|
|
|
18 |
#include "autoconfig.h"
|
|
|
19 |
#else
|
|
|
20 |
#include "config.h"
|
|
|
21 |
#endif
|
|
|
22 |
|
|
|
23 |
#include <stdio.h>
|
17 |
#include <stdio.h>
|
24 |
#include <stdlib.h>
|
18 |
#include <stdlib.h>
|
25 |
#include <time.h>
|
19 |
#include <time.h>
|
26 |
#include <ctype.h>
|
20 |
#include <ctype.h>
|
27 |
#include <errno.h>
|
21 |
#include <errno.h>
|
|
... |
|
... |
521 |
// Escape things that would look like markup
|
515 |
// Escape things that would look like markup
|
522 |
string escapeHtml(const string& in)
|
516 |
string escapeHtml(const string& in)
|
523 |
{
|
517 |
{
|
524 |
string out;
|
518 |
string out;
|
525 |
for (string::size_type pos = 0; pos < in.length(); pos++) {
|
519 |
for (string::size_type pos = 0; pos < in.length(); pos++) {
|
526 |
switch (in.at(pos)) {
|
520 |
switch(in.at(pos)) {
|
527 |
case '<':
|
521 |
case '<': out += "<"; break;
|
528 |
out += "<";
|
522 |
case '>': out += ">"; break;
|
529 |
break;
|
523 |
case '&': out += "&"; break;
|
530 |
case '&':
|
524 |
case '"': out += """; break;
|
531 |
out += "&";
|
525 |
default: out += in.at(pos); break;
|
532 |
break;
|
526 |
}
|
533 |
default:
|
|
|
534 |
out += in.at(pos);
|
|
|
535 |
}
|
|
|
536 |
}
|
527 |
}
|
537 |
return out;
|
528 |
return out;
|
538 |
}
|
529 |
}
|
539 |
|
530 |
|
540 |
string escapeShell(const string& in)
|
531 |
string escapeShell(const string& in)
|
|
... |
|
... |
1321 |
bool SimpleRegexp::operator() (const string& val) const
|
1312 |
bool SimpleRegexp::operator() (const string& val) const
|
1322 |
{
|
1313 |
{
|
1323 |
return simpleMatch(val);
|
1314 |
return simpleMatch(val);
|
1324 |
}
|
1315 |
}
|
1325 |
|
1316 |
|
|
|
1317 |
string flagsToString(const vector<CharFlags>& flags, unsigned int val)
|
|
|
1318 |
{
|
|
|
1319 |
const char *s;
|
|
|
1320 |
string out;
|
|
|
1321 |
for (auto& flag : flags) {
|
|
|
1322 |
if ((val & flag.value) == flag.value) {
|
|
|
1323 |
s = flag.yesname;
|
|
|
1324 |
} else {
|
|
|
1325 |
s = flag.noname;
|
|
|
1326 |
}
|
|
|
1327 |
if (s && *s) {
|
|
|
1328 |
/* We have something to write */
|
|
|
1329 |
if (out.length()) {
|
|
|
1330 |
// If not first, add '|' separator
|
|
|
1331 |
out.append("|");
|
|
|
1332 |
}
|
|
|
1333 |
out.append(s);
|
|
|
1334 |
}
|
|
|
1335 |
}
|
|
|
1336 |
return out;
|
|
|
1337 |
}
|
|
|
1338 |
|
|
|
1339 |
string valToString(const vector<CharFlags>& flags, unsigned int val)
|
|
|
1340 |
{
|
|
|
1341 |
string out;
|
|
|
1342 |
for (auto& flag : flags) {
|
|
|
1343 |
if (flag.value == val) {
|
|
|
1344 |
out = flag.yesname;
|
|
|
1345 |
return out;
|
|
|
1346 |
}
|
|
|
1347 |
}
|
|
|
1348 |
{
|
|
|
1349 |
char mybuf[100];
|
|
|
1350 |
sprintf(mybuf, "Unknown Value 0x%x", val);
|
|
|
1351 |
out = mybuf;
|
|
|
1352 |
}
|
|
|
1353 |
return out;
|
|
|
1354 |
}
|
|
|
1355 |
|
|
|
1356 |
unsigned int stringToFlags(const vector<CharFlags>& flags,
|
|
|
1357 |
const string& input, const char *sep)
|
|
|
1358 |
{
|
|
|
1359 |
unsigned int out = 0;
|
|
|
1360 |
|
|
|
1361 |
vector<string> toks;
|
|
|
1362 |
stringToTokens(input, toks, sep);
|
|
|
1363 |
for (auto& tok: toks) {
|
|
|
1364 |
trimstring(tok);
|
|
|
1365 |
for (auto& flag : flags) {
|
|
|
1366 |
if (!tok.compare(flag.yesname)) {
|
|
|
1367 |
/* Note: we don't break: the same name could conceivably
|
|
|
1368 |
set several flags. */
|
|
|
1369 |
out |= flag.value;
|
|
|
1370 |
}
|
|
|
1371 |
}
|
|
|
1372 |
}
|
|
|
1373 |
return out;
|
|
|
1374 |
}
|
|
|
1375 |
|
|
|
1376 |
|
1326 |
// Initialization for static stuff to be called from main thread before going
|
1377 |
// Initialization for static stuff to be called from main thread before going
|
1327 |
// multiple
|
1378 |
// multiple
|
1328 |
void smallut_init_mt()
|
1379 |
void smallut_init_mt()
|
1329 |
{
|
1380 |
{
|
1330 |
// Init langtocode() static table
|
1381 |
// Init langtocode() static table
|