Switch to unified view

a/src/utils/execmd.cpp b/src/utils/execmd.cpp
...
...
31
31
32
#include <vector>
32
#include <vector>
33
#include <string>
33
#include <string>
34
#include <sstream>
34
#include <sstream>
35
#include <iostream>
35
#include <iostream>
36
37
#include "execmd.h"
38
39
#include "netcon.h"
40
#include "closefrom.h"
41
36
using namespace std;
42
using namespace std;
37
43
38
#include "execmd.h"
44
extern char **environ;
39
#include "pathut.h"
45
46
bool ExecCmd::o_useVfork = false;
47
48
#ifdef RECOLL_DATADIR
40
#include "debuglog.h"
49
#include "debuglog.h"
41
#include "smallut.h"
50
#include "smallut.h"
42
#include "netcon.h"
43
#include "closefrom.h"
44
51
45
extern char **environ;
52
#else
53
// If compiling outside of recoll, make the file as standalone as reasonable.
46
54
47
bool ExecCmd::o_useVfork = false;
55
#define LOGFATAL(X)
56
#define LOGERR(X)
57
#define LOGINFO(X)
58
#define LOGDEB(X)
59
#define LOGDEB0(X)
60
#define LOGDEB1(X)
61
#define LOGDEB2(X)
62
#define LOGDEB3(X)
63
#define LOGDEB4(X)
64
65
#ifndef MIN
66
#define MIN(A,B) ((A) < (B) ? (A) : (B))
67
#endif
68
69
static void stringToTokens(const string &s, vector<string> &tokens, 
70
                    const string &delims = " \t", bool skipinit=true);
71
72
static void stringToTokens(const string& str, vector<string>& tokens,
73
          const string& delims, bool skipinit)
74
{
75
    string::size_type startPos = 0, pos;
76
77
    // Skip initial delims, return empty if this eats all.
78
    if (skipinit && 
79
  (startPos = str.find_first_not_of(delims, 0)) == string::npos) {
80
  return;
81
    }
82
    while (startPos < str.size()) { 
83
        // Find next delimiter or end of string (end of token)
84
        pos = str.find_first_of(delims, startPos);
85
86
        // Add token to the vector and adjust start
87
  if (pos == string::npos) {
88
      tokens.push_back(str.substr(startPos));
89
      break;
90
  } else if (pos == startPos) {
91
      // Dont' push empty tokens after first
92
      if (tokens.empty())
93
      tokens.push_back(string());
94
      startPos = ++pos;
95
  } else {
96
      tokens.push_back(str.substr(startPos, pos - startPos));
97
      startPos = ++pos;
98
  }
99
    }
100
}
101
#endif // RECOLL_DATADIR
48
102
49
/* From FreeBSD's which command */
103
/* From FreeBSD's which command */
50
static bool exec_is_there(const char *candidate)
104
static bool exec_is_there(const char *candidate)
51
{
105
{
52
    struct stat fin;
106
    struct stat fin;