9 #if defined(__CYGWIN__)
10 #include <sys/cygwin.h>
18 char *x =
new char[size];
19 for(
int i = 0; i < n; i++) {
20 char *a = &
array[i * size];
22 for(
int c = 0;
c < size;
c++) a[size - 1 -
c] = x[
c];
29 char *
c = strstr((
char *)str,
"\"");
32 for(
int i = 1; i < len; i++) {
33 if(
c[i] ==
'"' ||
c[i] == EOF ||
c[i] ==
'\n' ||
c[i] ==
'\r')
break;
43 if(strstr(in,
"$") || strstr(in,
"\\"))
return std::string(in);
47 if(equation) out.push_back(
'$');
50 char bad[8] = {
'%',
'^',
'#',
'%',
'&',
'_',
'{',
'}'};
52 for(std::size_t i = 0; i <
sizeof(bad); i++) {
61 if(equation) out.push_back(
'$');
67 #if defined(__CYGWIN__)
70 cygwin_conv_path(CCP_POSIX_TO_WIN_A, in.c_str(), tmp, 1024);
71 return std::string(tmp);
79 if(in.empty())
return "";
81 if(in[0] ==
'/' || in[0] ==
'\\' ||
82 (in.size() > 3 && in[1] ==
':' && (in[2] ==
'/' || in[2] ==
'\\'))) {
97 std::vector<std::string> s;
101 int idot = (int)fileName.find_last_of(
'.');
102 int islash = (int)fileName.find_last_of(
"/\\");
103 if(idot == (
int)std::string::npos) idot = -1;
104 if(islash == (
int)std::string::npos) islash = -1;
105 if(idot > 0) s[2] = fileName.substr(idot);
106 if(islash > 0) s[0] = fileName.substr(0, islash + 1);
108 fileName.substr(s[0].size(), fileName.size() - s[0].size() - s[2].size());
121 FILE *fp =
Fopen(fileName.c_str(),
"r");
125 while(!feof(fp) && fgets(str,
sizeof(str), fp)) out += str;
134 int pos = (int)str.find(olds.c_str());
135 if(pos == (
int)std::string::npos)
break;
136 str.replace(pos, olds.size(), news.c_str());
141 const std::string &str)
143 std::string
copy(str);
157 std::string &name,
int &index)
159 std::string::size_type d = fullName.find_first_of(
'.');
160 if(d == std::string::npos) {
164 category = fullName.substr(0, d);
165 std::string::size_type
b1 = fullName.find_first_of(
'[');
166 std::string::size_type b2 = fullName.find_last_of(
']');
167 if(
b1 != std::string::npos && b2 != std::string::npos) {
168 std::string
id = fullName.substr(
b1 + 1, b2 -
b1 - 1);
169 index = atoi(
id.c_str());
170 category = fullName.substr(0,
b1);
171 name = fullName.substr(d + 1,
b1 - d);
175 name = fullName.substr(d + 1);
177 Msg::Debug(
"Decoded option name '%s' . '%s' (index %d)", category.c_str(),
178 name.c_str(), index);
184 std::regex r(
"\\s+");
185 return std::regex_replace(s, r,
"");
189 std::string::size_type &first,
192 if(first == std::string::npos)
return "";
193 std::string::size_type last = msg.find_first_of(separator, first);
194 std::string next(
"");
195 if(last == std::string::npos) {
196 next = msg.substr(first);
199 else if(first == last) {
204 next = msg.substr(first, last - first);
210 std::vector<std::string>
SplitString(
const std::string &msg,
char separator,
211 bool removeWhiteSpace)
213 std::vector<std::string> out;
214 std::string::size_type first = 0;
215 while(first != std::string::npos) {
227 std::string::size_type n = name.find(
'/');
228 if(name.empty() || n == std::string::npos)
return false;
230 if(name.size() > 1 && name[0] ==
'/')
231 cleanName = name.substr(1);