[6bec10c] | 1 | /* cavernlog.cc |
---|
| 2 | * Run cavern inside an Aven window |
---|
| 3 | * |
---|
[76bc864f] | 4 | * Copyright (C) 2005-2022 Olly Betts |
---|
[6bec10c] | 5 | * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 19 | */ |
---|
| 20 | |
---|
[4c83f84] | 21 | #include <config.h> |
---|
[6bec10c] | 22 | |
---|
| 23 | #include "aven.h" |
---|
| 24 | #include "cavernlog.h" |
---|
| 25 | #include "filename.h" |
---|
[fb5887c] | 26 | #include "mainfrm.h" |
---|
[6bec10c] | 27 | #include "message.h" |
---|
[4b40a9c] | 28 | #include "osalloc.h" |
---|
[6bec10c] | 29 | |
---|
[baeae66] | 30 | #include <errno.h> |
---|
[6bec10c] | 31 | #include <stdio.h> |
---|
[a90632c] | 32 | #include <stdlib.h> |
---|
[6bec10c] | 33 | |
---|
| 34 | // For select(): |
---|
| 35 | #ifdef HAVE_SYS_SELECT_H |
---|
| 36 | #include <sys/select.h> |
---|
| 37 | #endif |
---|
| 38 | #include <sys/time.h> |
---|
| 39 | #include <sys/types.h> |
---|
| 40 | #include <unistd.h> |
---|
| 41 | |
---|
[15ba0b5] | 42 | #include <wx/process.h> |
---|
| 43 | |
---|
[cc2d7ad] | 44 | #define GVIM_COMMAND "gvim +'call cursor($l,$c)' $f" |
---|
| 45 | #define VIM_COMMAND "x-terminal-emulator -e vim +'call cursor($l,$c)' $f" |
---|
[81d94a4] | 46 | #define NVIM_COMMAND "x-terminal-emulator -e nvim +'call cursor($l,$c)' $f" |
---|
[cc2d7ad] | 47 | #define GEDIT_COMMAND "gedit $f +$l:$c" |
---|
| 48 | // Pluma currently ignores the column, but include it assuming some future |
---|
| 49 | // version will add support. |
---|
| 50 | #define PLUMA_COMMAND "pluma +$l:$c $f" |
---|
| 51 | #define EMACS_COMMAND "x-terminal-emulator -e emacs +$l:$c $f" |
---|
| 52 | #define NANO_COMMAND "x-terminal-emulator -e nano +$l,$c $f" |
---|
| 53 | #define JED_COMMAND "x-terminal-emulator -e jed $f -g $l" |
---|
| 54 | #define KATE_COMMAND "kate -l $l -c $c $f" |
---|
| 55 | |
---|
| 56 | #ifdef __WXMSW__ |
---|
| 57 | # define DEFAULT_EDITOR_COMMAND "notepad $f" |
---|
| 58 | #elif defined __WXMAC__ |
---|
| 59 | # define DEFAULT_EDITOR_COMMAND "open -t $f" |
---|
| 60 | #else |
---|
| 61 | # define DEFAULT_EDITOR_COMMAND VIM_COMMAND |
---|
| 62 | #endif |
---|
| 63 | |
---|
[0e81a88] | 64 | enum { LOG_REPROCESS = 1234, LOG_SAVE = 1235 }; |
---|
[fb5887c] | 65 | |
---|
[e768f29] | 66 | static const wxString badutf8_html( |
---|
| 67 | wxT("<span style=\"color:white;background-color:red;\">�</span>")); |
---|
| 68 | static const wxString badutf8(wxUniChar(0xfffd)); |
---|
| 69 | |
---|
[fc626ae] | 70 | // New event type for passing a chunk of cavern output from the worker thread |
---|
[15ba0b5] | 71 | // to the main thread (or from the idle event handler if we're not using |
---|
| 72 | // threads). |
---|
[fc626ae] | 73 | class CavernOutputEvent; |
---|
| 74 | |
---|
| 75 | wxDEFINE_EVENT(wxEVT_CAVERN_OUTPUT, CavernOutputEvent); |
---|
| 76 | |
---|
| 77 | class CavernOutputEvent : public wxEvent { |
---|
| 78 | public: |
---|
| 79 | char buf[1000]; |
---|
| 80 | int len; |
---|
| 81 | CavernOutputEvent() : wxEvent(0, wxEVT_CAVERN_OUTPUT), len(0) { } |
---|
| 82 | |
---|
| 83 | wxEvent * Clone() const { |
---|
| 84 | CavernOutputEvent * e = new CavernOutputEvent(); |
---|
| 85 | e->len = len; |
---|
| 86 | if (len > 0) memcpy(e->buf, buf, len); |
---|
| 87 | return e; |
---|
| 88 | } |
---|
| 89 | }; |
---|
| 90 | |
---|
[15ba0b5] | 91 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 92 | class CavernThread : public wxThread { |
---|
| 93 | protected: |
---|
| 94 | virtual ExitCode Entry(); |
---|
| 95 | |
---|
| 96 | CavernLogWindow *handler; |
---|
| 97 | |
---|
[15ba0b5] | 98 | wxInputStream * in; |
---|
[fc626ae] | 99 | |
---|
| 100 | public: |
---|
[15ba0b5] | 101 | CavernThread(CavernLogWindow *handler_, wxInputStream * in_) |
---|
| 102 | : wxThread(wxTHREAD_DETACHED), handler(handler_), in(in_) { } |
---|
[fc626ae] | 103 | |
---|
| 104 | ~CavernThread() { |
---|
| 105 | wxCriticalSectionLocker enter(handler->thread_lock); |
---|
| 106 | handler->thread = NULL; |
---|
| 107 | } |
---|
| 108 | }; |
---|
| 109 | |
---|
| 110 | wxThread::ExitCode |
---|
| 111 | CavernThread::Entry() |
---|
| 112 | { |
---|
[15ba0b5] | 113 | while (true) { |
---|
| 114 | CavernOutputEvent * e = new CavernOutputEvent(); |
---|
| 115 | in->Read(e->buf, sizeof(e->buf)); |
---|
| 116 | size_t n = in->LastRead(); |
---|
| 117 | if (n == 0 || TestDestroy()) { |
---|
| 118 | delete e; |
---|
| 119 | return (wxThread::ExitCode)0; |
---|
| 120 | } |
---|
| 121 | if (n == 1 && e->buf[0] == '\n') { |
---|
| 122 | // Don't send an event with just a blank line in. |
---|
| 123 | in->Read(e->buf + 1, sizeof(e->buf) - 1); |
---|
| 124 | n += in->LastRead(); |
---|
| 125 | if (TestDestroy()) { |
---|
| 126 | delete e; |
---|
| 127 | return (wxThread::ExitCode)0; |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | e->len = n; |
---|
| 131 | handler->QueueEvent(e); |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | #else |
---|
| 136 | |
---|
| 137 | void |
---|
| 138 | CavernLogWindow::OnIdle(wxIdleEvent& event) |
---|
| 139 | { |
---|
| 140 | if (cavern_out == NULL) return; |
---|
| 141 | |
---|
| 142 | wxInputStream * in = cavern_out->GetInputStream(); |
---|
| 143 | |
---|
| 144 | if (!in->CanRead()) { |
---|
| 145 | // Avoid a tight busy-loop on idle events. |
---|
| 146 | wxMilliSleep(10); |
---|
| 147 | } |
---|
| 148 | if (in->CanRead()) { |
---|
[fc626ae] | 149 | CavernOutputEvent * e = new CavernOutputEvent(); |
---|
[15ba0b5] | 150 | in->Read(e->buf, sizeof(e->buf)); |
---|
| 151 | size_t n = in->LastRead(); |
---|
| 152 | if (n == 0) { |
---|
[fc626ae] | 153 | delete e; |
---|
[15ba0b5] | 154 | return; |
---|
[fc626ae] | 155 | } |
---|
[15ba0b5] | 156 | e->len = n; |
---|
| 157 | QueueEvent(e); |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | event.RequestMore(); |
---|
[fc626ae] | 161 | } |
---|
| 162 | #endif |
---|
| 163 | |
---|
[fb5887c] | 164 | BEGIN_EVENT_TABLE(CavernLogWindow, wxHtmlWindow) |
---|
[81e1aa4] | 165 | EVT_BUTTON(LOG_REPROCESS, CavernLogWindow::OnReprocess) |
---|
[0e81a88] | 166 | EVT_BUTTON(LOG_SAVE, CavernLogWindow::OnSave) |
---|
[fb5887c] | 167 | EVT_BUTTON(wxID_OK, CavernLogWindow::OnOK) |
---|
[15ba0b5] | 168 | EVT_COMMAND(wxID_ANY, wxEVT_CAVERN_OUTPUT, CavernLogWindow::OnCavernOutput) |
---|
[0415bac] | 169 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 170 | EVT_CLOSE(CavernLogWindow::OnClose) |
---|
| 171 | #else |
---|
[8991d7f] | 172 | EVT_IDLE(CavernLogWindow::OnIdle) |
---|
[fc626ae] | 173 | #endif |
---|
[15ba0b5] | 174 | EVT_END_PROCESS(wxID_ANY, CavernLogWindow::OnEndProcess) |
---|
[fb5887c] | 175 | END_EVENT_TABLE() |
---|
| 176 | |
---|
[549eb37] | 177 | wxString escape_for_shell(wxString s, bool protect_dash) |
---|
[6bec10c] | 178 | { |
---|
| 179 | #ifdef __WXMSW__ |
---|
[faf83be] | 180 | // Correct quoting rules are insane: |
---|
| 181 | // |
---|
[764fe32] | 182 | // http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx |
---|
[faf83be] | 183 | // |
---|
| 184 | // Thankfully wxExecute passes the command string to CreateProcess(), so |
---|
| 185 | // at least we don't need to quote for cmd.exe too. |
---|
| 186 | if (s.empty() || s.find_first_of(wxT(" \"\t\n\v")) != s.npos) { |
---|
| 187 | // Need to quote. |
---|
| 188 | s.insert(0, wxT('"')); |
---|
| 189 | for (size_t p = 1; p < s.size(); ++p) { |
---|
| 190 | size_t backslashes = 0; |
---|
| 191 | while (s[p] == wxT('\\')) { |
---|
| 192 | ++backslashes; |
---|
| 193 | if (++p == s.size()) { |
---|
| 194 | // Escape all the backslashes, since they're before |
---|
| 195 | // the closing quote we add below. |
---|
| 196 | s.append(backslashes, wxT('\\')); |
---|
| 197 | goto done; |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | if (s[p] == wxT('"')) { |
---|
| 202 | // Escape any preceding backslashes and this quote. |
---|
| 203 | s.insert(p, backslashes + 1, wxT('\\')); |
---|
| 204 | p += backslashes + 1; |
---|
[eff69a7] | 205 | } |
---|
[6bec10c] | 206 | } |
---|
[faf83be] | 207 | done: |
---|
| 208 | s.append(wxT('"')); |
---|
[6bec10c] | 209 | } |
---|
| 210 | #else |
---|
[faf83be] | 211 | size_t p = 0; |
---|
[6bec10c] | 212 | if (protect_dash && !s.empty() && s[0u] == '-') { |
---|
| 213 | // If the filename starts with a '-', protect it from being |
---|
| 214 | // treated as an option by prepending "./". |
---|
[5627cbb] | 215 | s.insert(0, wxT("./")); |
---|
[6bec10c] | 216 | p = 2; |
---|
| 217 | } |
---|
| 218 | while (p < s.size()) { |
---|
| 219 | // Exclude a few safe characters which are common in filenames |
---|
[8adbe49] | 220 | if (!isalnum((unsigned char)s[p]) && strchr("/._-", s[p]) == NULL) { |
---|
[6baad4a] | 221 | s.insert(p, 1, wxT('\\')); |
---|
[6bec10c] | 222 | ++p; |
---|
| 223 | } |
---|
| 224 | ++p; |
---|
| 225 | } |
---|
| 226 | #endif |
---|
| 227 | return s; |
---|
| 228 | } |
---|
| 229 | |
---|
[549eb37] | 230 | wxString get_command_path(const wxChar * command_name) |
---|
| 231 | { |
---|
| 232 | #ifdef __WXMSW__ |
---|
| 233 | wxString cmd; |
---|
| 234 | { |
---|
| 235 | DWORD len = 256; |
---|
| 236 | wchar_t *buf = NULL; |
---|
| 237 | while (1) { |
---|
| 238 | DWORD got; |
---|
| 239 | buf = (wchar_t*)osrealloc(buf, len * 2); |
---|
| 240 | got = GetModuleFileNameW(NULL, buf, len); |
---|
| 241 | if (got < len) break; |
---|
| 242 | len += len; |
---|
| 243 | } |
---|
| 244 | /* Strange Win32 nastiness - strip prefix "\\?\" if present */ |
---|
| 245 | wchar_t *start = buf; |
---|
| 246 | if (wcsncmp(start, L"\\\\?\\", 4) == 0) start += 4; |
---|
| 247 | wchar_t * slash = wcsrchr(start, L'\\'); |
---|
| 248 | if (slash) { |
---|
| 249 | cmd.assign(start, slash - start + 1); |
---|
| 250 | } |
---|
| 251 | osfree(buf); |
---|
| 252 | } |
---|
| 253 | #else |
---|
| 254 | wxString cmd = wxString(msg_exepth(), wxConvUTF8); |
---|
| 255 | #endif |
---|
| 256 | cmd += command_name; |
---|
| 257 | return cmd; |
---|
| 258 | } |
---|
| 259 | |
---|
[d7b53e3] | 260 | CavernLogWindow::CavernLogWindow(MainFrm * mainfrm_, const wxString & survey_, wxWindow * parent) |
---|
[b004e36] | 261 | : wxHtmlWindow(parent), |
---|
[76bc864f] | 262 | mainfrm(mainfrm_), |
---|
| 263 | end(buf), survey(survey_) |
---|
[fb5887c] | 264 | { |
---|
[93ff5cc] | 265 | int fsize = parent->GetFont().GetPointSize(); |
---|
| 266 | int sizes[7] = { fsize, fsize, fsize, fsize, fsize, fsize, fsize }; |
---|
[5627cbb] | 267 | SetFonts(wxString(), wxString(), sizes); |
---|
[93ff5cc] | 268 | } |
---|
| 269 | |
---|
[8991d7f] | 270 | CavernLogWindow::~CavernLogWindow() |
---|
| 271 | { |
---|
[15ba0b5] | 272 | #ifdef CAVERNLOG_USE_THREADS |
---|
| 273 | if (thread) stop_thread(); |
---|
| 274 | #endif |
---|
[c1144fe] | 275 | if (cavern_out) { |
---|
| 276 | wxEndBusyCursor(); |
---|
[15ba0b5] | 277 | cavern_out->Detach(); |
---|
[c1144fe] | 278 | } |
---|
[8991d7f] | 279 | } |
---|
| 280 | |
---|
[0415bac] | 281 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 282 | void |
---|
| 283 | CavernLogWindow::stop_thread() |
---|
| 284 | { |
---|
[15ba0b5] | 285 | // Killing the subprocess by its pid is theoretically racy, but in practice |
---|
| 286 | // it's not going to cause issues, and it's all the wxProcess API seems to |
---|
| 287 | // allow us to do. If we don't kill the subprocess, we need to wait for it |
---|
| 288 | // to write out some output - there seems to be no way to do the equivalent |
---|
[b4ae834] | 289 | // of select() with a timeout on a wxInputStream. |
---|
[15ba0b5] | 290 | // |
---|
| 291 | // The only alternative to this seems to be to do: |
---|
| 292 | // |
---|
| 293 | // while (!s.CanRead()) { |
---|
| 294 | // if (TestDestroy()) return (wxThread::ExitCode)0; |
---|
| 295 | // wxMilliSleep(N); |
---|
| 296 | // } |
---|
| 297 | // |
---|
| 298 | // But that makes the log window update sluggishly, and we're using a |
---|
| 299 | // worker thread precisely to try to avoid having to do dumb stuff like |
---|
| 300 | // this. |
---|
| 301 | wxProcess::Kill(cavern_out->GetPid()); |
---|
| 302 | |
---|
[fc626ae] | 303 | { |
---|
| 304 | wxCriticalSectionLocker enter(thread_lock); |
---|
| 305 | if (thread) { |
---|
[2a00719] | 306 | wxThreadError res; |
---|
| 307 | res = thread->Delete(NULL, wxTHREAD_WAIT_BLOCK); |
---|
| 308 | if (res != wxTHREAD_NO_ERROR) { |
---|
[fc626ae] | 309 | // FIXME |
---|
| 310 | } |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | // Wait for thread to complete. |
---|
| 315 | while (true) { |
---|
| 316 | { |
---|
| 317 | wxCriticalSectionLocker enter(thread_lock); |
---|
| 318 | if (!thread) break; |
---|
| 319 | } |
---|
| 320 | wxMilliSleep(1); |
---|
| 321 | } |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | void |
---|
| 325 | CavernLogWindow::OnClose(wxCloseEvent &) |
---|
| 326 | { |
---|
| 327 | if (thread) stop_thread(); |
---|
| 328 | Destroy(); |
---|
| 329 | } |
---|
| 330 | #endif |
---|
| 331 | |
---|
[6bec10c] | 332 | void |
---|
| 333 | CavernLogWindow::OnLinkClicked(const wxHtmlLinkInfo &link) |
---|
| 334 | { |
---|
| 335 | wxString href = link.GetHref(); |
---|
| 336 | wxString title = link.GetTarget(); |
---|
[544a46c] | 337 | size_t colon2 = href.rfind(wxT(':')); |
---|
| 338 | if (colon2 == wxString::npos) |
---|
| 339 | return; |
---|
| 340 | size_t colon = href.rfind(wxT(':'), colon2 - 1); |
---|
[3d3fb6c] | 341 | if (colon == wxString::npos) |
---|
| 342 | return; |
---|
[cc2d7ad] | 343 | wxString cmd; |
---|
[b8ba399] | 344 | wxChar * p = wxGetenv(wxT("SURVEXEDITOR")); |
---|
[3d3fb6c] | 345 | if (p) { |
---|
[b8ba399] | 346 | cmd = p; |
---|
[3d3fb6c] | 347 | if (!cmd.find(wxT("$f"))) { |
---|
| 348 | cmd += wxT(" $f"); |
---|
[6bec10c] | 349 | } |
---|
[cc2d7ad] | 350 | } else { |
---|
| 351 | p = wxGetenv(wxT("VISUAL")); |
---|
| 352 | if (!p) p = wxGetenv(wxT("EDITOR")); |
---|
| 353 | if (!p) { |
---|
| 354 | cmd = wxT(DEFAULT_EDITOR_COMMAND); |
---|
| 355 | } else { |
---|
| 356 | cmd = p; |
---|
| 357 | if (cmd == "gvim") { |
---|
| 358 | cmd = wxT(GVIM_COMMAND); |
---|
| 359 | } else if (cmd == "vim") { |
---|
| 360 | cmd = wxT(VIM_COMMAND); |
---|
[81d94a4] | 361 | } else if (cmd == "nvim") { |
---|
| 362 | cmd = wxT(NVIM_COMMAND); |
---|
[cc2d7ad] | 363 | } else if (cmd == "gedit") { |
---|
| 364 | cmd = wxT(GEDIT_COMMAND); |
---|
| 365 | } else if (cmd == "pluma") { |
---|
| 366 | cmd = wxT(PLUMA_COMMAND); |
---|
| 367 | } else if (cmd == "emacs") { |
---|
| 368 | cmd = wxT(EMACS_COMMAND); |
---|
| 369 | } else if (cmd == "nano") { |
---|
| 370 | cmd = wxT(NANO_COMMAND); |
---|
| 371 | } else if (cmd == "jed") { |
---|
| 372 | cmd = wxT(JED_COMMAND); |
---|
| 373 | } else if (cmd == "kate") { |
---|
| 374 | cmd = wxT(KATE_COMMAND); |
---|
| 375 | } else { |
---|
| 376 | // Escape any $. |
---|
| 377 | cmd.Replace(wxT("$"), wxT("$$")); |
---|
| 378 | cmd += wxT(" $f"); |
---|
| 379 | } |
---|
| 380 | } |
---|
[3d3fb6c] | 381 | } |
---|
| 382 | size_t i = 0; |
---|
| 383 | while ((i = cmd.find(wxT('$'), i)) != wxString::npos) { |
---|
| 384 | if (++i >= cmd.size()) break; |
---|
| 385 | switch ((int)cmd[i]) { |
---|
| 386 | case wxT('$'): |
---|
| 387 | cmd.erase(i, 1); |
---|
| 388 | break; |
---|
| 389 | case wxT('f'): { |
---|
| 390 | wxString f = escape_for_shell(href.substr(0, colon), true); |
---|
| 391 | cmd.replace(i - 1, 2, f); |
---|
| 392 | i += f.size() - 1; |
---|
| 393 | break; |
---|
| 394 | } |
---|
| 395 | case wxT('t'): { |
---|
| 396 | wxString t = escape_for_shell(title); |
---|
| 397 | cmd.replace(i - 1, 2, t); |
---|
| 398 | i += t.size() - 1; |
---|
| 399 | break; |
---|
| 400 | } |
---|
| 401 | case wxT('l'): { |
---|
| 402 | wxString l = escape_for_shell(href.substr(colon + 1, colon2 - colon - 1)); |
---|
| 403 | cmd.replace(i - 1, 2, l); |
---|
| 404 | i += l.size() - 1; |
---|
| 405 | break; |
---|
[1d71195] | 406 | } |
---|
[3d3fb6c] | 407 | case wxT('c'): { |
---|
| 408 | wxString l; |
---|
[b2b852d] | 409 | if (colon2 >= href.size() - 1) |
---|
[3d3fb6c] | 410 | l = wxT("0"); |
---|
| 411 | else |
---|
| 412 | l = escape_for_shell(href.substr(colon2 + 1)); |
---|
| 413 | cmd.replace(i - 1, 2, l); |
---|
| 414 | i += l.size() - 1; |
---|
| 415 | break; |
---|
| 416 | } |
---|
| 417 | default: |
---|
| 418 | ++i; |
---|
[6bec10c] | 419 | } |
---|
[3d3fb6c] | 420 | } |
---|
[faf83be] | 421 | |
---|
| 422 | if (wxExecute(cmd, wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER) >= 0) |
---|
[3d3fb6c] | 423 | return; |
---|
[faf83be] | 424 | |
---|
[3d3fb6c] | 425 | wxString m; |
---|
[736f7df] | 426 | // TRANSLATORS: %s is replaced by the command we attempted to run. |
---|
[3d3fb6c] | 427 | m.Printf(wmsg(/*Couldn’t run external command: “%s”*/17), cmd.c_str()); |
---|
| 428 | m += wxT(" ("); |
---|
| 429 | m += wxString(strerror(errno), wxConvUTF8); |
---|
| 430 | m += wxT(')'); |
---|
| 431 | wxGetApp().ReportError(m); |
---|
[6bec10c] | 432 | } |
---|
| 433 | |
---|
[8991d7f] | 434 | void |
---|
[6bec10c] | 435 | CavernLogWindow::process(const wxString &file) |
---|
| 436 | { |
---|
[00f4e69] | 437 | SetPage(wxString()); |
---|
[0415bac] | 438 | #ifdef CAVERNLOG_USE_THREADS |
---|
[fc626ae] | 439 | if (thread) stop_thread(); |
---|
| 440 | #endif |
---|
[c1144fe] | 441 | if (cavern_out) { |
---|
[15ba0b5] | 442 | cavern_out->Detach(); |
---|
[15033fd] | 443 | cavern_out = NULL; |
---|
[c1144fe] | 444 | } else { |
---|
| 445 | wxBeginBusyCursor(); |
---|
| 446 | } |
---|
| 447 | |
---|
[fb5887c] | 448 | SetFocus(); |
---|
| 449 | filename = file; |
---|
| 450 | |
---|
[76bc864f] | 451 | info_count = 0; |
---|
[8991d7f] | 452 | link_count = 0; |
---|
| 453 | cur.resize(0); |
---|
[0e81a88] | 454 | log_txt.resize(0); |
---|
| 455 | |
---|
[6bec10c] | 456 | #ifdef __WXMSW__ |
---|
[15322f2] | 457 | SetEnvironmentVariable(wxT("SURVEX_UTF8"), wxT("1")); |
---|
[6bec10c] | 458 | #else |
---|
[06b1227] | 459 | setenv("SURVEX_UTF8", "1", 1); |
---|
[6bec10c] | 460 | #endif |
---|
[93ff5cc] | 461 | |
---|
[6bec10c] | 462 | wxString escaped_file = escape_for_shell(file, true); |
---|
[549eb37] | 463 | wxString cmd = get_command_path(L"cavern"); |
---|
[9e50f755] | 464 | cmd = escape_for_shell(cmd, false); |
---|
[5627cbb] | 465 | cmd += wxT(" -o "); |
---|
[6bec10c] | 466 | cmd += escaped_file; |
---|
[5627cbb] | 467 | cmd += wxT(' '); |
---|
[6bec10c] | 468 | cmd += escaped_file; |
---|
| 469 | |
---|
[15ba0b5] | 470 | cavern_out = wxProcess::Open(cmd); |
---|
[6bec10c] | 471 | if (!cavern_out) { |
---|
[5627cbb] | 472 | wxString m; |
---|
[3d3fb6c] | 473 | m.Printf(wmsg(/*Couldn’t run external command: “%s”*/17), cmd.c_str()); |
---|
[5627cbb] | 474 | m += wxT(" ("); |
---|
[2e4b8cd] | 475 | m += wxString(strerror(errno), wxConvUTF8); |
---|
[5627cbb] | 476 | m += wxT(')'); |
---|
[6bec10c] | 477 | wxGetApp().ReportError(m); |
---|
[8991d7f] | 478 | return; |
---|
[6bec10c] | 479 | } |
---|
| 480 | |
---|
[15ba0b5] | 481 | // We want to receive the wxProcessEvent when cavern exits. |
---|
| 482 | cavern_out->SetNextHandler(this); |
---|
[40b02e8] | 483 | |
---|
[0415bac] | 484 | #ifdef CAVERNLOG_USE_THREADS |
---|
[15ba0b5] | 485 | thread = new CavernThread(this, cavern_out->GetInputStream()); |
---|
[fc626ae] | 486 | if (thread->Run() != wxTHREAD_NO_ERROR) { |
---|
| 487 | wxGetApp().ReportError(wxT("Thread failed to start")); |
---|
| 488 | delete thread; |
---|
| 489 | thread = NULL; |
---|
| 490 | } |
---|
[15ba0b5] | 491 | #endif |
---|
[fc626ae] | 492 | } |
---|
| 493 | |
---|
| 494 | void |
---|
| 495 | CavernLogWindow::OnCavernOutput(wxCommandEvent & e_) |
---|
| 496 | { |
---|
| 497 | CavernOutputEvent & e = (CavernOutputEvent&)e_; |
---|
| 498 | |
---|
| 499 | if (e.len > 0) { |
---|
| 500 | ssize_t n = e.len; |
---|
[27222f8] | 501 | if (size_t(n) > sizeof(buf) - (end - buf)) abort(); |
---|
[fc626ae] | 502 | memcpy(end, e.buf, n); |
---|
[330cb03] | 503 | log_txt.append((const char *)end, n); |
---|
| 504 | end += n; |
---|
[b3ee5f5] | 505 | |
---|
| 506 | const unsigned char * p = buf; |
---|
| 507 | |
---|
| 508 | while (p != end) { |
---|
[5605a4b] | 509 | int ch = *p; |
---|
[b3ee5f5] | 510 | if (ch >= 0x80) { |
---|
| 511 | // Decode multi-byte UTF-8 sequence. |
---|
| 512 | if (ch < 0xc0) { |
---|
[184d6d4] | 513 | // Invalid UTF-8 sequence. |
---|
| 514 | goto bad_utf8; |
---|
[b3ee5f5] | 515 | } else if (ch < 0xe0) { |
---|
| 516 | /* 2 byte sequence */ |
---|
[5605a4b] | 517 | if (end - p < 2) { |
---|
[b3ee5f5] | 518 | // Incomplete UTF-8 sequence - try to read more. |
---|
| 519 | break; |
---|
| 520 | } |
---|
[5605a4b] | 521 | int ch1 = *++p; |
---|
[b3ee5f5] | 522 | if ((ch1 & 0xc0) != 0x80) { |
---|
[184d6d4] | 523 | // Invalid UTF-8 sequence. |
---|
| 524 | goto bad_utf8; |
---|
[b3ee5f5] | 525 | } |
---|
| 526 | ch = ((ch & 0x1f) << 6) | (ch1 & 0x3f); |
---|
| 527 | } else if (ch < 0xf0) { |
---|
| 528 | /* 3 byte sequence */ |
---|
[5605a4b] | 529 | if (end - p < 3) { |
---|
[b3ee5f5] | 530 | // Incomplete UTF-8 sequence - try to read more. |
---|
| 531 | break; |
---|
| 532 | } |
---|
[5605a4b] | 533 | int ch1 = *++p; |
---|
[b3ee5f5] | 534 | ch = ((ch & 0x1f) << 12) | ((ch1 & 0x3f) << 6); |
---|
| 535 | if ((ch1 & 0xc0) != 0x80) { |
---|
[184d6d4] | 536 | // Invalid UTF-8 sequence. |
---|
| 537 | goto bad_utf8; |
---|
[b3ee5f5] | 538 | } |
---|
[5605a4b] | 539 | int ch2 = *++p; |
---|
[b3ee5f5] | 540 | if ((ch2 & 0xc0) != 0x80) { |
---|
[184d6d4] | 541 | // Invalid UTF-8 sequence. |
---|
| 542 | goto bad_utf8; |
---|
[b3ee5f5] | 543 | } |
---|
| 544 | ch |= (ch2 & 0x3f); |
---|
[6bec10c] | 545 | } else { |
---|
[184d6d4] | 546 | // Overlong UTF-8 sequence. |
---|
| 547 | goto bad_utf8; |
---|
[6bec10c] | 548 | } |
---|
| 549 | } |
---|
[5605a4b] | 550 | ++p; |
---|
[6bec10c] | 551 | |
---|
[e768f29] | 552 | if (false) { |
---|
| 553 | bad_utf8: |
---|
| 554 | // Resync to next byte which starts a UTF-8 sequence. |
---|
| 555 | while (p != end) { |
---|
| 556 | if (*p < 0x80 || (*p >= 0xc0 && *p < 0xf0)) break; |
---|
| 557 | ++p; |
---|
| 558 | } |
---|
| 559 | cur += badutf8_html; |
---|
| 560 | continue; |
---|
| 561 | } |
---|
| 562 | |
---|
[b3ee5f5] | 563 | switch (ch) { |
---|
| 564 | case '\r': |
---|
| 565 | // Ignore. |
---|
| 566 | break; |
---|
| 567 | case '\n': { |
---|
| 568 | if (cur.empty()) continue; |
---|
[99865c9] | 569 | if (cur[0] == ' ') { |
---|
| 570 | if (source_line.empty()) { |
---|
| 571 | // Source line shown for context. Store it so we |
---|
| 572 | // can use the caret line to highlight it. |
---|
| 573 | swap(source_line, cur); |
---|
| 574 | } else { |
---|
| 575 | size_t caret = cur.rfind('^'); |
---|
| 576 | if (caret != wxString::npos) { |
---|
| 577 | size_t tilde = cur.rfind('~'); |
---|
| 578 | if (tilde == wxString::npos || tilde < caret) { |
---|
| 579 | tilde = caret; |
---|
| 580 | } |
---|
| 581 | cur = " "; |
---|
| 582 | // FIXME: Need to count each & entity as one character... |
---|
| 583 | cur.append(source_line, 1, caret - 1); |
---|
[7ffb1c5] | 584 | if (caret < source_line.size()) { |
---|
| 585 | cur.append("<b>"); |
---|
[76bc864f] | 586 | cur.append(highlight ? highlight : wxT("<span \"color:blue\">")); |
---|
[7ffb1c5] | 587 | cur.append(source_line, caret, tilde + 1 - caret); |
---|
| 588 | cur.append("</span></b>"); |
---|
| 589 | } |
---|
[816eae6] | 590 | if (tilde + 1 < source_line.size()) { |
---|
| 591 | cur.append(source_line, tilde + 1, wxString::npos); |
---|
| 592 | } |
---|
[99865c9] | 593 | } else { |
---|
[f207751] | 594 | // No caret in second line - just output both. |
---|
| 595 | source_line.replace(0, 1, " "); |
---|
| 596 | source_line += "<br>\n "; |
---|
| 597 | source_line.append(cur, 1, wxString::npos); |
---|
[99865c9] | 598 | swap(cur, source_line); |
---|
| 599 | } |
---|
| 600 | cur += "<br>\n"; |
---|
| 601 | AppendToPage(cur); |
---|
| 602 | cur.clear(); |
---|
| 603 | source_line.clear(); |
---|
| 604 | } |
---|
| 605 | continue; |
---|
| 606 | } |
---|
[f207751] | 607 | |
---|
| 608 | if (!source_line.empty()) { |
---|
| 609 | // Previous line was a source line without column info |
---|
| 610 | // so just show it. |
---|
| 611 | source_line.replace(0, 1, " "); |
---|
| 612 | source_line += "<br>\n"; |
---|
| 613 | AppendToPage(source_line); |
---|
| 614 | source_line.clear(); |
---|
| 615 | } |
---|
[a07ee70] | 616 | #ifndef __WXMSW__ |
---|
[b3ee5f5] | 617 | size_t colon = cur.find(':'); |
---|
[a07ee70] | 618 | #else |
---|
[b3ee5f5] | 619 | // If the path is "C:\path\to\file.svx" then don't split at the |
---|
| 620 | // : after the drive letter! FIXME: better to look for ": "? |
---|
| 621 | size_t colon = cur.find(':', 2); |
---|
[6bec10c] | 622 | #endif |
---|
[b3ee5f5] | 623 | if (colon != wxString::npos && colon < cur.size() - 2) { |
---|
| 624 | ++colon; |
---|
| 625 | size_t i = colon; |
---|
| 626 | while (i < cur.size() - 2 && |
---|
| 627 | cur[i] >= wxT('0') && cur[i] <= wxT('9')) { |
---|
| 628 | ++i; |
---|
| 629 | } |
---|
| 630 | if (i > colon && cur[i] == wxT(':') ) { |
---|
[da96015] | 631 | colon = i; |
---|
[b3ee5f5] | 632 | // Check for column number. |
---|
| 633 | while (++i < cur.size() - 2 && |
---|
| 634 | cur[i] >= wxT('0') && cur[i] <= wxT('9')) { } |
---|
[f9f0f0c] | 635 | bool have_column = (i > colon + 1 && cur[i] == wxT(':')); |
---|
| 636 | if (have_column) { |
---|
[b3ee5f5] | 637 | colon = i; |
---|
[544a46c] | 638 | } else { |
---|
| 639 | // If there's no colon, include a trailing ':' |
---|
| 640 | // so that we can unambiguously split the href |
---|
| 641 | // value up into filename, line and column. |
---|
| 642 | ++colon; |
---|
[b3ee5f5] | 643 | } |
---|
| 644 | wxString tag = wxT("<a href=\""); |
---|
| 645 | tag.append(cur, 0, colon); |
---|
| 646 | while (cur[++i] == wxT(' ')) { } |
---|
| 647 | tag += wxT("\" target=\""); |
---|
[e768f29] | 648 | wxString target(cur, i, wxString::npos); |
---|
| 649 | target.Replace(badutf8_html, badutf8); |
---|
| 650 | tag += target; |
---|
[b3ee5f5] | 651 | tag += wxT("\">"); |
---|
| 652 | cur.insert(0, tag); |
---|
[40b02e8] | 653 | size_t offset = colon + tag.size(); |
---|
| 654 | cur.insert(offset, wxT("</a>")); |
---|
| 655 | offset += 4 + 2; |
---|
[8991d7f] | 656 | |
---|
[f9f0f0c] | 657 | if (!have_column) --offset; |
---|
| 658 | |
---|
[8991d7f] | 659 | static const wxString & error_marker = wmsg(/*error*/93) + ":"; |
---|
| 660 | static const wxString & warning_marker = wmsg(/*warning*/4) + ":"; |
---|
[76bc864f] | 661 | static const wxString & info_marker = wmsg(/*info*/485) + ":"; |
---|
[8991d7f] | 662 | |
---|
[40b02e8] | 663 | if (cur.substr(offset, error_marker.size()) == error_marker) { |
---|
| 664 | // Show "error" marker in red. |
---|
[99865c9] | 665 | highlight = wxT("<span style=\"color:red\">"); |
---|
| 666 | cur.insert(offset, highlight); |
---|
[58055e11] | 667 | offset += 24 + error_marker.size() - 1; |
---|
[40b02e8] | 668 | cur.insert(offset, wxT("</span>")); |
---|
| 669 | } else if (cur.substr(offset, warning_marker.size()) == warning_marker) { |
---|
| 670 | // Show "warning" marker in orange. |
---|
[99865c9] | 671 | highlight = wxT("<span style=\"color:orange\">"); |
---|
| 672 | cur.insert(offset, highlight); |
---|
[58055e11] | 673 | offset += 27 + warning_marker.size() - 1; |
---|
[40b02e8] | 674 | cur.insert(offset, wxT("</span>")); |
---|
[76bc864f] | 675 | } else if (cur.substr(offset, info_marker.size()) == info_marker) { |
---|
| 676 | // Show "info" marker in blue. |
---|
| 677 | ++info_count; |
---|
| 678 | highlight = wxT("<span style=\"color:blue\">"); |
---|
| 679 | cur.insert(offset, highlight); |
---|
| 680 | offset += 25 + info_marker.size() - 1; |
---|
| 681 | cur.insert(offset, wxT("</span>")); |
---|
[99865c9] | 682 | } else { |
---|
| 683 | highlight = NULL; |
---|
[40b02e8] | 684 | } |
---|
| 685 | |
---|
[b3ee5f5] | 686 | ++link_count; |
---|
[da96015] | 687 | } |
---|
[6bec10c] | 688 | } |
---|
[93ff5cc] | 689 | |
---|
[b3ee5f5] | 690 | // Save the scrollbar positions. |
---|
| 691 | int scroll_x = 0, scroll_y = 0; |
---|
| 692 | GetViewStart(&scroll_x, &scroll_y); |
---|
[93ff5cc] | 693 | |
---|
[b3ee5f5] | 694 | cur += wxT("<br>\n"); |
---|
| 695 | AppendToPage(cur); |
---|
[93ff5cc] | 696 | |
---|
[b3ee5f5] | 697 | if (!link_count) { |
---|
[8991d7f] | 698 | // Auto-scroll the window until we've reported a |
---|
| 699 | // warning or error. |
---|
[b3ee5f5] | 700 | int x, y; |
---|
| 701 | GetVirtualSize(&x, &y); |
---|
| 702 | int xs, ys; |
---|
| 703 | GetClientSize(&xs, &ys); |
---|
| 704 | y -= ys; |
---|
| 705 | int xu, yu; |
---|
| 706 | GetScrollPixelsPerUnit(&xu, &yu); |
---|
| 707 | Scroll(scroll_x, y / yu); |
---|
| 708 | } else { |
---|
| 709 | // Restore the scrollbar positions. |
---|
| 710 | Scroll(scroll_x, scroll_y); |
---|
| 711 | } |
---|
[a75f5a1] | 712 | |
---|
[b3ee5f5] | 713 | cur.clear(); |
---|
| 714 | break; |
---|
[6bec10c] | 715 | } |
---|
[b3ee5f5] | 716 | case '<': |
---|
| 717 | cur += wxT("<"); |
---|
| 718 | break; |
---|
| 719 | case '>': |
---|
| 720 | cur += wxT(">"); |
---|
| 721 | break; |
---|
| 722 | case '&': |
---|
| 723 | cur += wxT("&"); |
---|
| 724 | break; |
---|
| 725 | case '"': |
---|
[bc9c09a] | 726 | cur += wxT("""); |
---|
[b3ee5f5] | 727 | continue; |
---|
| 728 | default: |
---|
[aef136e] | 729 | #ifdef wxUSE_UNICODE |
---|
| 730 | cur += wxChar(ch); |
---|
| 731 | #else |
---|
| 732 | // This approach means that highlighting of "error" or |
---|
| 733 | // "warning" won't work in translations where they contain |
---|
| 734 | // non-ASCII characters, but wxWidgets >= 3.0 in always |
---|
| 735 | // Unicode, so this corner case is already very uncommon, |
---|
| 736 | // and will become irrelevant with time. |
---|
[b3ee5f5] | 737 | if (ch >= 128) { |
---|
| 738 | cur += wxString::Format(wxT("&#%u;"), ch); |
---|
| 739 | } else { |
---|
| 740 | cur += (char)ch; |
---|
| 741 | } |
---|
[aef136e] | 742 | #endif |
---|
[b3ee5f5] | 743 | } |
---|
[6bec10c] | 744 | } |
---|
[b3ee5f5] | 745 | |
---|
| 746 | size_t left = end - p; |
---|
| 747 | end = buf + left; |
---|
| 748 | if (left) memmove(buf, p, left); |
---|
[8991d7f] | 749 | Update(); |
---|
| 750 | return; |
---|
[6bec10c] | 751 | } |
---|
[8991d7f] | 752 | |
---|
[f207751] | 753 | if (!source_line.empty()) { |
---|
| 754 | // Previous line was a source line without column info |
---|
| 755 | // so just show it. |
---|
| 756 | source_line.replace(0, 1, " "); |
---|
| 757 | source_line += "<br>\n"; |
---|
| 758 | AppendToPage(source_line); |
---|
| 759 | source_line.clear(); |
---|
| 760 | } |
---|
| 761 | |
---|
[15ba0b5] | 762 | if (e.len <= 0 && buf != end) { |
---|
[184d6d4] | 763 | // Truncated UTF-8 sequence. |
---|
[e768f29] | 764 | cur += badutf8_html; |
---|
[fc626ae] | 765 | } |
---|
[f207751] | 766 | if (!cur.empty()) { |
---|
| 767 | cur += "<br>\n"; |
---|
| 768 | AppendToPage("<hr>" + cur); |
---|
| 769 | } |
---|
[fb5887c] | 770 | |
---|
[0e81a88] | 771 | /* TRANSLATORS: Label for button in aven’s cavern log window which |
---|
| 772 | * allows the user to save the log to a file. */ |
---|
| 773 | AppendToPage(wxString::Format(wxT("<avenbutton id=%d name=\"%s\">"), |
---|
| 774 | (int)LOG_SAVE, |
---|
[9cd0657] | 775 | wmsg(/*&Save Log*/446).c_str())); |
---|
[c1144fe] | 776 | wxEndBusyCursor(); |
---|
[15ba0b5] | 777 | delete cavern_out; |
---|
[8991d7f] | 778 | cavern_out = NULL; |
---|
[15ba0b5] | 779 | if (e.len < 0) { |
---|
| 780 | /* Negative length indicates non-zero exit status from cavern. */ |
---|
[736f7df] | 781 | /* TRANSLATORS: Label for button in aven’s cavern log window which |
---|
| 782 | * causes the survey data to be reprocessed. */ |
---|
[bbed692] | 783 | AppendToPage(wxString::Format(wxT("<avenbutton default id=%d name=\"%s\">"), |
---|
| 784 | (int)LOG_REPROCESS, |
---|
[9cd0657] | 785 | wmsg(/*&Reprocess*/184).c_str())); |
---|
[8991d7f] | 786 | return; |
---|
[6bec10c] | 787 | } |
---|
[bbed692] | 788 | AppendToPage(wxString::Format(wxT("<avenbutton id=%d name=\"%s\">"), |
---|
| 789 | (int)LOG_REPROCESS, |
---|
[9cd0657] | 790 | wmsg(/*&Reprocess*/184).c_str())); |
---|
[d7b53e3] | 791 | AppendToPage(wxString::Format(wxT("<avenbutton default id=%d>"), (int)wxID_OK)); |
---|
| 792 | Update(); |
---|
| 793 | init_done = false; |
---|
[fb5887c] | 794 | |
---|
[15ba0b5] | 795 | { |
---|
| 796 | wxString file3d(filename, 0, filename.length() - 3); |
---|
| 797 | file3d.append(wxT("3d")); |
---|
| 798 | if (!mainfrm->LoadData(file3d, survey)) { |
---|
| 799 | return; |
---|
| 800 | } |
---|
[d7b53e3] | 801 | } |
---|
[15ba0b5] | 802 | |
---|
[76bc864f] | 803 | // Don't stay on log if there there are only "info" diagnostics. |
---|
| 804 | if (link_count == info_count) { |
---|
[8991d7f] | 805 | wxCommandEvent dummy; |
---|
| 806 | OnOK(dummy); |
---|
[fb5887c] | 807 | } |
---|
[15ba0b5] | 808 | } |
---|
| 809 | |
---|
| 810 | void |
---|
| 811 | CavernLogWindow::OnEndProcess(wxProcessEvent & evt) |
---|
| 812 | { |
---|
| 813 | CavernOutputEvent * e = new CavernOutputEvent(); |
---|
| 814 | // Zero length indicates successful exit, negative length unsuccessful exit. |
---|
| 815 | e->len = (evt.GetExitCode() == 0 ? 0 : -1); |
---|
| 816 | QueueEvent(e); |
---|
[fb5887c] | 817 | } |
---|
| 818 | |
---|
[0e81a88] | 819 | void |
---|
[330cb03] | 820 | CavernLogWindow::OnReprocess(wxCommandEvent &) |
---|
[8991d7f] | 821 | { |
---|
| 822 | process(filename); |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | void |
---|
[0e81a88] | 826 | CavernLogWindow::OnSave(wxCommandEvent &) |
---|
| 827 | { |
---|
| 828 | wxString filelog(filename, 0, filename.length() - 3); |
---|
| 829 | filelog += wxT("log"); |
---|
| 830 | #ifdef __WXMOTIF__ |
---|
| 831 | wxString ext(wxT("*.log")); |
---|
| 832 | #else |
---|
[bb71423] | 833 | /* TRANSLATORS: Log files from running cavern (extension .log) */ |
---|
[0e81a88] | 834 | wxString ext = wmsg(/*Log files*/447); |
---|
| 835 | ext += wxT("|*.log"); |
---|
| 836 | #endif |
---|
| 837 | wxFileDialog dlg(this, wmsg(/*Select an output filename*/319), |
---|
| 838 | wxString(), filelog, ext, |
---|
| 839 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
| 840 | if (dlg.ShowModal() != wxID_OK) return; |
---|
| 841 | filelog = dlg.GetPath(); |
---|
[3206c12] | 842 | FILE * fh_log = wxFopen(filelog, wxT("w")); |
---|
[0e81a88] | 843 | if (!fh_log) { |
---|
| 844 | wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), filelog.c_str())); |
---|
| 845 | return; |
---|
| 846 | } |
---|
| 847 | fwrite(log_txt.data(), log_txt.size(), 1, fh_log); |
---|
| 848 | fclose(fh_log); |
---|
| 849 | } |
---|
| 850 | |
---|
[fb5887c] | 851 | void |
---|
| 852 | CavernLogWindow::OnOK(wxCommandEvent &) |
---|
| 853 | { |
---|
[d7b53e3] | 854 | if (init_done) { |
---|
| 855 | mainfrm->HideLog(this); |
---|
| 856 | } else { |
---|
[5e0b9f9d] | 857 | mainfrm->InitialiseAfterLoad(filename, survey); |
---|
[d7b53e3] | 858 | init_done = true; |
---|
| 859 | } |
---|
[fb5887c] | 860 | } |
---|