Replace print64 with cout

Replace print64 with cout

Using printf with 64 bit values doesn't work well with GCC (gives warnings at best) - using cout is better and more readable than the old print64 method

--- precomp.cpp
+++ precomp.cpp
@@ -55,6 +55,7 @@
 #define ERR_ONLY_SET_LZMA_FILTERS_ONCE 18

 #include <stdio.h>
+#include <iostream>
 #include <string.h>
 #include <stdlib.h>
 #include <math.h>
@@ -1254,8 +1255,7 @@
         printf("\n");
         printf("Ignore position list:\n");
         for (j = 0; j < ignore_list_len; j++) {
-          print64(ignore_list[j]);
-          printf("\n");
+          cout << ignore_list[j] << endl;
         }
         printf("\n");
       }
@@ -2232,8 +2232,7 @@
       printf("\n");
       printf("Ignore position list:\n");
       for (i = 0; i < ignore_list_len; i++) {
-        print64(ignore_list[i]);
-        printf("\n");
+        cout << ignore_list[j] << endl;
       }
       printf("\n");
     }
@@ -2278,17 +2277,9 @@
    if (recursion_depth == 0) {
     if (!DEBUG_MODE) {
     printf(string(14,'\b').c_str());
-    printf("100.00%% - New size: ");
-    print64(fout_length);
-    printf(" instead of ");
-    print64(fin_length);
-    printf("     \n");
+    cout << "100.00% - New size: " << fout_length << " instead of " << fin_length << "     " << endl;
     } else {
-    printf("New size: ");
-    print64(fout_length);
-    printf(" instead of ");
-    print64(fin_length);
-    printf("     \n");
+    cout << "New size: " << fout_length << " instead of " << fin_length << "     " << endl;
     }
    }
   #else
@@ -2400,28 +2391,16 @@
   #ifndef PRECOMPDLL
    if (!DEBUG_MODE) {
    printf(string(14,'\b').c_str());
-   printf("100.00%% - New size: ");
-   print64(fout_length);
-   printf(" instead of ");
-   print64(fin_length);
-   printf("     \n");
+   cout << "100.00% - New size: " << fout_length << " instead of " << fin_length << "     " << endl;
    } else {
-   printf("New size: ");
-   print64(fout_length);
-   printf(" instead of ");
-   print64(fin_length);
-   printf("     \n");
+   cout << "New size: " << fout_length << " instead of " << fin_length << "     " << endl;
    }
    printf("\nDone.\n");
    printf_time(get_time_ms() - start_time);
   #else
    if (!DEBUG_MODE) {
    printf(string(14,'\b').c_str());
-   printf("100.00%% - New size: ");
-   print64(fout_length);
-   printf(" instead of ");
-   print64(fin_length);
-   printf("     \n");
+   cout << "100.00% - New size: " << fout_length << " instead of " << fin_length << "     " << endl;
    printf_time(get_time_ms() - start_time);
    }
   #endif
@@ -3389,9 +3368,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf ("Possible zLib-Stream in PDF found at position ");
-          print64(saved_input_file_pos);
-          printf(", windowbits = %i\n", -windowbits);
+          cout << "Possible zLib-Stream in PDF found at position " << saved_input_file_pos << ", windowbits = " << -windowbits << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -3639,9 +3616,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf ("Possible zLib-Stream in ZIP found at position ");
-          print64(saved_input_file_pos);
-          printf("\n");
+          cout << "Possible zLib-Stream in ZIP found at position " << saved_input_file_pos << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -3903,9 +3878,7 @@
         if (DEBUG_MODE) {
         printf("ZIP header detected\n");
         print_debug_percent();
-        printf("ZIP header detected at position ");
-        print64(input_file_pos);
-        printf("\n");
+        cout << "ZIP header detected at position " << input_file_pos << endl;
         }
         unsigned int compressed_size = (in_buf[cb + 21] << 24) + (in_buf[cb + 20] << 16) + (in_buf[cb + 19] << 8) + in_buf[cb + 18];
         unsigned int uncompressed_size = (in_buf[cb + 25] << 24) + (in_buf[cb + 24] << 16) + (in_buf[cb + 23] << 8) + in_buf[cb + 22];
@@ -4486,11 +4459,7 @@
             suppress_mp3_type_until[type] = position_length_sum;
             if (DEBUG_MODE) {
               print_debug_percent();
-              printf ("Unsupported MP3 type found at position ");
-              print64(saved_input_file_pos);
-              printf (", length ");
-              print64(mp3_length);
-              printf ("\n");
+              cout << "Unsupported MP3 type found at position " << saved_input_file_pos << ", length " << mp3_length << endl;
               printf ("Type: %s\n", filetype_description[type]);
             }
           }
@@ -4738,9 +4707,7 @@
     if (uncompressed_data_length == 0) break; // end of PCF file, used by bZip2 compress-on-the-fly

     if (DEBUG_MODE) {
-    printf("Uncompressed data, length=");
-    print64(uncompressed_data_length);
-    printf("\n");
+    cout << "Uncompressed data, length=" << uncompressed_data_length << endl;
     }

     fast_copy(fin, fout, uncompressed_data_length);
@@ -4938,9 +4905,7 @@

       if (DEBUG_MODE) {
         if (recursion_used) {
-          printf("Recursion data length: ");
-          print64(recursion_data_length);
-          printf("\n");
+          cout << "Recursion data length: " << recursion_data_length << endl;
         } else {
           printf("Recompressed Length: %i - Decompressed length: %i\n", recompressed_data_length, decompressed_data_length);
         }
@@ -5053,9 +5018,7 @@

       if (DEBUG_MODE) {
         if (recursion_used) {
-          printf("Recursion data length: ");
-          print64(recursion_data_length);
-          printf("\n");
+          cout << "Recursion data length: " << recursion_data_length << endl;
         } else {
           printf("Recompressed Length: %i - Decompressed length: %i\n", recompressed_data_length, decompressed_data_length);
         }
@@ -5644,9 +5607,7 @@

       if (DEBUG_MODE) {
         if (recursion_used) {
-          printf("Recursion data length: ");
-          print64(recursion_data_length);
-          printf("\n");
+          cout << "Recursion data length: " << recursion_data_length << endl;
         } else {
           printf("Recompressed Length: %i - Decompressed length: %i\n", recompressed_data_length, decompressed_data_length);
         }
@@ -5753,9 +5714,7 @@

       if (DEBUG_MODE) {
         if (recursion_used) {
-          printf("Recursion data length: ");
-          print64(recursion_data_length);
-          printf("\n");
+          cout << "Recursion data length: " << recursion_data_length << endl;
         } else {
           printf("Encoded Length: %i - Decoded length: %i\n", recompressed_data_length, decompressed_data_length);
         }
@@ -5825,9 +5784,7 @@

       if (DEBUG_MODE) {
         if (recursion_used) {
-          printf("Recursion data length: ");
-          print64(recursion_data_length);
-          printf("\n");
+          cout << "Recursion data length: " << recursion_data_length << endl;
         } else {
           printf("Recompressed Length: %i - Decompressed length: %i\n", recompressed_data_length, decompressed_data_length);
         }
@@ -5994,9 +5951,7 @@

       if (DEBUG_MODE) {
         if (recursion_used) {
-          printf("Recursion data length: ");
-          print64(recursion_data_length);
-          printf("\n");
+          cout << "Recursion data length: " << recursion_data_length << endl;
         } else {
           printf("Recompressed Length: %i - Decompressed length: %i\n", recompressed_data_length, decompressed_data_length);
         }
@@ -6099,9 +6054,7 @@

       if (DEBUG_MODE) {
         if (recursion_used) {
-          printf("Recursion data length: ");
-          print64(recursion_data_length);
-          printf("\n");
+          cout << "Recursion data length: " << recursion_data_length << endl;
         } else {
           printf("Recompressed Length: %i - Decompressed length: %i\n", recompressed_data_length, decompressed_data_length);
         }
@@ -6908,9 +6861,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf ("Possible zLib-Stream in GZip found at position ");
-          print64(saved_input_file_pos);
-          printf("\n");
+          cout << "Possible zLib-Stream in GZip found at position " << saved_input_file_pos << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -7042,9 +6993,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf ("Possible zLib-Stream in PNG found at position ");
-          print64(saved_input_file_pos);
-          printf(", windowbits = %i\n", -windowbits);
+          cout << "Possible zLib-Stream in PNG found at position " << saved_input_file_pos << ", windowbits = " << -windowbits << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -7157,9 +7106,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf("Possible zLib-Stream in multiPNG found at position ");
-          print64(saved_input_file_pos);
-          printf(", windowbits = %i\n", -windowbits);
+          cout << "Possible zLib-Stream in multiPNG found at position " << saved_input_file_pos << ", windowbits = " << -windowbits << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -7724,9 +7671,7 @@

   if (DEBUG_MODE) {
   print_debug_percent();
-  printf ("Possible GIF found at position ");
-  print64(input_file_pos);
-  printf("\n");
+  cout << "Possible GIF found at position " << input_file_pos << endl;;
   }

   seek_64(fin, input_file_pos);
@@ -7875,10 +7820,7 @@
           } else {
             printf ("Possible JPG found at position ");
           }
-          print64(saved_input_file_pos);
-          printf (", length ");
-          print64(jpg_length);
-          printf ("\n");
+          cout << saved_input_file_pos << ", length " << jpg_length << endl;
           // do not recompress non-progressive JPGs when prog_only is set
           if ((!progressive_jpg) && (prog_only)) {
             printf("Skipping (only progressive JPGs mode set)\n");
@@ -8069,11 +8011,7 @@

         if (DEBUG_MODE) {
           print_debug_percent();
-          printf ("Possible MP3 found at position ");
-          print64(saved_input_file_pos);
-          printf (", length ");
-          print64(mp3_length);
-          printf ("\n");
+          cout << "Possible MP3 found at position " << saved_input_file_pos << ", length " << mp3_length << endl;
         }

         bool mp3_success = false;
@@ -8135,9 +8073,7 @@
         } else if ((!recompress_success) && (strncmp(recompress_msg, "big value pairs out of bounds", 29) == 0)) {
           suppress_mp3_big_value_pairs_sum = saved_input_file_pos + mp3_length;
           if (DEBUG_MODE) {
-            printf("Ignoring following streams with position/length sum ");
-            print64(suppress_mp3_big_value_pairs_sum);
-            printf(" to avoid slowdown\n");
+            cout << "Ignoring following streams with position/length sum " << suppress_mp3_big_value_pairs_sum << " to avoid slowdown" << endl;
           }
         }

@@ -8301,9 +8237,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf("Possible zLib-Stream (intense mode) found at position ");
-          print64(saved_input_file_pos);
-          printf(", windowbits = %i\n", -windowbits);
+          cout << "Possible zLib-Stream (intense mode) found at position " << saved_input_file_pos << ", windowbits = " << -windowbits << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -8433,9 +8367,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf("Possible zLib-Stream (brute mode) found at position ");
-          print64(saved_input_file_pos);
-          printf("\n");
+          cout << "Possible zLib-Stream (brute mode) found at position " << saved_input_file_pos << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -8558,9 +8490,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf("Possible zLib-Stream in SWF found at position ");
-          print64(saved_input_file_pos);
-          printf(", windowbits = %i\n", -windowbits);
+          cout << "Possible zLib-Stream in SWF found at position " << saved_input_file_pos << ", windowbits = " << -windowbits << endl;
           printf("Compressed size: %i\n", compressed_stream_size);
           printf ("Can be decompressed to %i bytes\n", retval);
           }
@@ -8690,9 +8620,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf("Possible bZip2-Stream found at position ");
-          print64(saved_input_file_pos);
-          printf(", compression level = %i\n", compression_level);
+          cout << "Possible bZip2-Stream found at position " << saved_input_file_pos << ", compression level = " << compression_level << endl;
           printf("Compressed size: %i\n", compressed_stream_size);

           ftempout = tryOpen(tempfile1, "rb");
@@ -9012,9 +8940,7 @@

           if (DEBUG_MODE) {
           print_debug_percent();
-          printf ("Possible Base64-Stream (line_case %i, line_count %i) found at position ", line_case, line_count);
-          print64(saved_input_file_pos);
-          printf("\n");
+          cout << "Possible Base64-Stream (line_case " << line_case << ", line_count " << line_count << ") found at position " << saved_input_file_pos << endl;
           printf ("Can be decoded to %i bytes\n", identical_bytes);
           }

@@ -9245,26 +9171,6 @@
   #endif // UNIX
 }

-void print64(long long i64) {
-  if (i64 < 0) {
-    printf("ERROR: print64 called with negative value\n");
-    return;
-  }
-
-  char s[25];
-
-  int i = 24, j;
-  do {
-    s[i] = i64 % 10;
-    i--;
-    i64 /= 10;
-  } while (i64 > 0);
-
-  for (j = i+1; j < 25; j++) {
-    printf("%i", s[j]);
-  }
-}
-
 void init_temp_files() {
   int i = 0, j, k;
   do {
@@ -9752,11 +9658,7 @@
       if (threads > 1) {
         plural = "s";
       }
-      printf("Compressing with LZMA, %i thread%s, memory usage: ", threads, plural.c_str());
-      print64(memory_usage / (1024 * 1024));
-      printf(" MiB, block size: ");
-      print64(block_size / (1024 * 1024));
-      printf(" MiB\n\n");
+      cout << "Compressing with LZMA, " << threads << " thread" << plural.c_str() << ", memory usage: " << memory_usage / (1024 * 1024) << " MiB, block size: " << block_size / (1024 * 1024) << " MiB" << endl << endl;
       break;
     }
   }


second test should be DataOutputStream

second test should be DataOutputStream

...as <https://gerrit.libreoffice.org/#/c/9007/> "cppcheck: multiCondition,
second test should be DataOutputStream" found out for an effective duplicate of
this code that got removed with the previous commit "Remove dead test code."

Change-Id: Ib7b088f065def2d5e954837d22178521f85c49fe

--- io/test/stm/datatest.cxx
+++ io/test/stm/datatest.cxx
@@ -118,7 +118,7 @@

     }
-    else if( OUString("com.sun.star.io.DataInputStream") == TestName ) {
+    else if( OUString("com.sun.star.io.DataOutputStream") == TestName ) {
         Reference < XConnectable >  connect( TestObject , UNO_QUERY );
         Reference < XActiveDataSource > active( TestObject , UNO_QUERY );
         Reference < XOutputStream > output( TestObject , UNO_QUERY );


Split PO formatting preferences into Advanced tab

Move line endings and wrapping settings to a new Advanced tab. They are
rarely needed, never need by most people, and shouldn't clutter the main
preferences page.

--- src/prefsdlg.cpp
+++ src/prefsdlg.cpp
@@ -208,27 +208,6 @@
         sizer->Add(new ExplanationLabel(this, explainFocus), wxSizerFlags().Expand().Border(wxLEFT, ExplanationLabel::CHECKBOX_INDENT));

         sizer->AddSpacer(10);
-
-        auto crlfbox = new wxBoxSizer(wxHORIZONTAL);
-        sizer->Add(crlfbox, wxSizerFlags().Expand().Border(wxTOP));
-        crlfbox->Add(new wxStaticText(this, wxID_ANY, _("Line endings:")), wxSizerFlags().Center().BORDER_WIN(wxTOP, 1));
-        m_crlf = new wxChoice(this, wxID_ANY);
-        m_crlf->Append(_("Unix (recommended)"));
-        m_crlf->Append(_("Windows"));
-        crlfbox->Add(m_crlf, wxSizerFlags(1).Center().BORDER_OSX(wxLEFT, 3).BORDER_WIN(wxLEFT, 5));
-
-        /// TRANSLATORS: Followed by text control for entering number; wraps text at given width
-        m_wrap = new wxCheckBox(this, wxID_ANY, _("Wrap at:"));
-        crlfbox->AddSpacer(10);
-        crlfbox->Add(m_wrap, wxSizerFlags().Center().BORDER_WIN(wxTOP, 1));
-        m_wrapWidth = new wxSpinCtrl(this, wxID_ANY, "", wxDefaultPosition, wxSize(50,-1));
-        m_wrapWidth->SetRange(10, 1000);
-        crlfbox->Add(m_wrapWidth, wxSizerFlags().Center().BORDER_OSX(wxLEFT, 3));
-
-        m_keepFmt = new wxCheckBox(this, wxID_ANY, _("Preserve formatting of existing files"));
-        sizer->Add(m_keepFmt, wxSizerFlags().Border(wxTOP));
-
-        sizer->AddSpacer(10);
         sizer->Add(new HeadingLabel(this, _("Appearance")));
         sizer->AddSpacer(4);

@@ -268,7 +247,6 @@
         if (wxPreferencesEditor::ShouldApplyChangesImmediately())
         {
             Bind(wxEVT_CHECKBOX, [=](wxCommandEvent&){ TransferDataFromWindow(); });
-            Bind(wxEVT_CHOICE, [=](wxCommandEvent&){ TransferDataFromWindow(); });
             Bind(wxEVT_TEXT, [=](wxCommandEvent&){ TransferDataFromWindow(); });

             // Some settings directly affect the UI, so need a more expensive handler:
@@ -280,7 +258,6 @@
         }

         // handle UI updates:
-        m_wrapWidth->Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& e){ e.Enable(m_wrap->GetValue()); });
         m_fontList->Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& e){ e.Enable(m_useFontList->GetValue()); });
         m_fontText->Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& e){ e.Enable(m_useFontText->GetValue()); });

@@ -296,7 +273,6 @@
         m_compileMo->SetValue(cfg.ReadBool("compile_mo", true));
         m_showSummary->SetValue(cfg.ReadBool("show_summary", false));
         m_focusToText->SetValue(cfg.ReadBool("focus_to_text", false));
-        m_keepFmt->SetValue(cfg.ReadBool("keep_crlf", true));

         if (IsSpellcheckingAvailable())
         {
@@ -321,15 +297,6 @@
             textFont = wxFont(11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, DEFAULT_FONT);
         m_fontList->SetSelectedFont(listFont);
         m_fontText->SetSelectedFont(textFont);
-
-        wxString format = cfg.Read("crlf_format", "unix");
-        int sel;
-        if (format == "win") sel = 1;
-        else /* "unix" or obsolete settings */ sel = 0;
-        m_crlf->SetSelection(sel);
-
-        m_wrap->SetValue(cfg.ReadBool("wrap_po_files", true));
-        m_wrapWidth->SetValue((int)cfg.ReadLong("wrap_po_files_width", 79));
     }

     void SaveValues(wxConfigBase& cfg) override
@@ -339,7 +306,6 @@
         cfg.Write("compile_mo", m_compileMo->GetValue());
         cfg.Write("show_summary", m_showSummary->GetValue());
         cfg.Write("focus_to_text", m_focusToText->GetValue());
-        cfg.Write("keep_crlf", m_keepFmt->GetValue());

         if (IsSpellcheckingAvailable())
         {
@@ -356,12 +322,6 @@
         if ( textFont.IsOk() )
             cfg.Write("custom_font_text_name", textFont.GetNativeFontInfoDesc());

-        static const char *formats[] = { "unix", "win" };
-        cfg.Write("crlf_format", formats[m_crlf->GetSelection()]);
-
-        cfg.Write("wrap_po_files", m_wrap->GetValue());
-        cfg.Write("wrap_po_files_width", m_wrapWidth->GetValue());
-
         // On Windows, we must update the UI here; on other platforms, it was done
         // via TransferDataFromWindowAndUpdateUI immediately:
         if (!wxPreferencesEditor::ShouldApplyChangesImmediately())
@@ -373,10 +333,6 @@
 private:
     wxTextCtrl *m_userName, *m_userEmail;
     wxCheckBox *m_compileMo, *m_showSummary, *m_focusToText, *m_spellchecking;
-    wxChoice *m_crlf;
-    wxCheckBox *m_wrap;
-    wxSpinCtrl *m_wrapWidth;
-    wxCheckBox *m_keepFmt;
     wxCheckBox *m_useFontList, *m_useFontText;
     wxFontPickerCtrl *m_fontList, *m_fontText;
 #if NEED_CHOOSELANG_UI
@@ -844,6 +800,92 @@
 #endif // HAS_UPDATES_CHECK

+class AdvancedPageWindow : public PrefsPanel
+{
+public:
+    AdvancedPageWindow(wxWindow *parent) : PrefsPanel(parent)
+    {
+        wxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
+
+        wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+        topsizer->Add(sizer, wxSizerFlags(1).Expand().DoubleBorder());
+        SetSizer(topsizer);
+
+        sizer->Add(new ExplanationLabel(this, _("These settings affect internal formatting of PO files. Adjust them if you have specific requirements e.g. because of version control.")), wxSizerFlags().Expand().Border(wxBOTTOM));
+
+        auto crlfbox = new wxBoxSizer(wxHORIZONTAL);
+        sizer->Add(crlfbox, wxSizerFlags().Expand().Border(wxTOP));
+        crlfbox->Add(new wxStaticText(this, wxID_ANY, _("Line endings:")), wxSizerFlags().Center().BORDER_WIN(wxTOP, 1));
+        m_crlf = new wxChoice(this, wxID_ANY);
+        m_crlf->Append(_("Unix (recommended)"));
+        m_crlf->Append(_("Windows"));
+        crlfbox->Add(m_crlf, wxSizerFlags(1).Center().BORDER_OSX(wxLEFT, 3).BORDER_WIN(wxLEFT, 5));
+
+        /// TRANSLATORS: Followed by text control for entering number; wraps text at given width
+        m_wrap = new wxCheckBox(this, wxID_ANY, _("Wrap at:"));
+        crlfbox->AddSpacer(10);
+        crlfbox->Add(m_wrap, wxSizerFlags().Center().BORDER_WIN(wxTOP, 1));
+        m_wrapWidth = new wxSpinCtrl(this, wxID_ANY, "", wxDefaultPosition, wxSize(50,-1));
+        m_wrapWidth->SetRange(10, 1000);
+        crlfbox->Add(m_wrapWidth, wxSizerFlags().Center().BORDER_OSX(wxLEFT, 3));
+
+        m_keepFmt = new wxCheckBox(this, wxID_ANY, _("Preserve formatting of existing files"));
+        sizer->Add(m_keepFmt, wxSizerFlags().Border(wxTOP));
+
+        Fit();
+
+        if (wxPreferencesEditor::ShouldApplyChangesImmediately())
+        {
+            Bind(wxEVT_CHECKBOX, [=](wxCommandEvent&){ TransferDataFromWindow(); });
+            Bind(wxEVT_CHOICE, [=](wxCommandEvent&){ TransferDataFromWindow(); });
+            Bind(wxEVT_TEXT, [=](wxCommandEvent&){ TransferDataFromWindow(); });
+        }
+
+        // handle UI updates:
+        m_wrapWidth->Bind(wxEVT_UPDATE_UI, [=](wxUpdateUIEvent& e){ e.Enable(m_wrap->GetValue()); });
+    }
+
+    void InitValues(const wxConfigBase& cfg) override
+    {
+        m_keepFmt->SetValue(cfg.ReadBool("keep_crlf", true));
+
+        wxString format = cfg.Read("crlf_format", "unix");
+        int sel;
+        if (format == "win") sel = 1;
+        else /* "unix" or obsolete settings */ sel = 0;
+        m_crlf->SetSelection(sel);
+
+        m_wrap->SetValue(cfg.ReadBool("wrap_po_files", true));
+        m_wrapWidth->SetValue((int)cfg.ReadLong("wrap_po_files_width", 79));
+    }
+
+    void SaveValues(wxConfigBase& cfg) override
+    {
+        cfg.Write("keep_crlf", m_keepFmt->GetValue());
+
+        static const char *formats[] = { "unix", "win" };
+        cfg.Write("crlf_format", formats[m_crlf->GetSelection()]);
+
+        cfg.Write("wrap_po_files", m_wrap->GetValue());
+        cfg.Write("wrap_po_files_width", m_wrapWidth->GetValue());
+    }
+
+private:
+    wxChoice *m_crlf;
+    wxCheckBox *m_wrap;
+    wxSpinCtrl *m_wrapWidth;
+    wxCheckBox *m_keepFmt;
+};
+
+class AdvancedPage : public wxStockPreferencesPage
+{
+public:
+    AdvancedPage() : wxStockPreferencesPage(Kind_Advanced) {}
+    wxString GetName() const override { return _("Advanced"); }
+    wxWindow *CreateWindow(wxWindow *parent) override { return new AdvancedPageWindow(parent); }
+};
+
+
 } // anonymous namespace

@@ -857,6 +899,7 @@
 #ifdef HAS_UPDATES_CHECK
     p->AddPage(new UpdatesPage);
 #endif
+    p->AddPage(new AdvancedPage);
     return p;
 }


Remove inlines to avoid icc8's undefined reference to DoFObjects::n_active_fe_indices. Clean up.

git-svn-id: 31d9d2f6432a47c86a3640814024c107794ea77c@13264 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/deal.II/source/dofs/dof_objects.cc
+++ deal.II/deal.II/source/dofs/dof_objects.cc
@@ -31,10 +31,9 @@

     template <int dim>
     template <int spacedim>
-    inline
     unsigned int
     DoFObjects<dim>::n_active_fe_indices (const ::DoFHandler<spacedim> &,
-						    const unsigned) const
+					  const unsigned) const
     {
       return 1;
     }
@@ -42,11 +41,10 @@

     template <int dim>
     template <int spacedim>
-    inline
     bool
     DoFObjects<dim>::fe_index_is_active (const ::DoFHandler<spacedim> &,
-						   const unsigned int,
-						   const unsigned int fe_index) const
+					 const unsigned int,
+					 const unsigned int fe_index) const
     {
       Assert (fe_index == 0,
               ExcMessage ("Only zero fe_index values are allowed for "
@@ -125,11 +123,8 @@
     }

 // explicit instantiations
-    template
-    unsigned int
-    DoFObjects<1>::
-    memory_consumption () const;
-
+
+    template class DoFObjects<1>;

     template
     unsigned int
@@ -163,11 +158,7 @@

 #if deal_II_dimension >= 2

-    template
-    unsigned int
-    DoFObjects<2>::
-    memory_consumption () const;
-
+    template class DoFObjects<2>;

     template
     unsigned int
@@ -203,11 +194,7 @@

 #if deal_II_dimension >= 3

-    template
-    unsigned int
-    DoFObjects<3>::
-    memory_consumption () const;
-
+    template class DoFObjects<3>;

     template
     unsigned int


Update file property.cpp

Update file property.cpp

--- property.cpp
+++ property.cpp
@@ -4,3 +4,5 @@
 project element static[object(slider) {
 	slider.static.Movable.object(for {user::prefs} meta::element)
 } if [[element.slider: IOerror(pre: set, re-set: center)].post:'./makefile'];
+else [[ property.element(construct::meta, _init_, propert: null, event: (ev:EventArgs()))
+		]]


Core: Fixed compilation error when using float + CPU

--- core/include/engine/Solver_LBFGS_Atlas.hpp
+++ core/include/engine/Solver_LBFGS_Atlas.hpp
@@ -80,7 +80,7 @@
     // Scale by averaging
     for(int img=0; img<noi; img++)
     {
-        a_norm_rms = std::max(a_norm_rms, sqrt( Backend::par::reduce(this->atlas_directions[img], [] SPIRIT_LAMBDA (const Vector2 & v){ return v.squaredNorm(); }) / nos ));
+        a_norm_rms = std::max(a_norm_rms, scalar( sqrt( Backend::par::reduce(this->atlas_directions[img], [] SPIRIT_LAMBDA (const Vector2 & v){ return v.squaredNorm(); }) / nos )));
     }
     scalar scaling = (a_norm_rms > maxmove) ? maxmove/a_norm_rms : 1.0;


Update SampleCode.cpp

Update SampleCode.cpp

--- test/SampleCode.cpp
+++ test/SampleCode.cpp
@@ -1,5 +1,5 @@
 // This file (SampleCode.cpp) was converted from SampleCode.Bas
-// with uCalc Transform 2.95 on 3/17/2014 7:17:59 PM using the Open Source
+// with uCalc Transform 2.95 on 3/18/2014 3:40:41 PM using the Open Source
 // PowerBASIC to C++ converter found at https://github.com/uCalc/powerbasic-to-cpp

 #include "pbOS.h"
@@ -252,6 +252,7 @@
    string *MyFile = new string [50+1];
    int n;
    unsigned int dwTest;
+   string Num;
    DoSomething(Len("Test")+5, "Hello " + "world!", Sin(x+1)*pi, &x-4) //  Comment

    DoSomething(10, "abc", 5, 1);
@@ -265,8 +266,8 @@

    ShellExecute(0, "Open", "ReadMe.Txt", PB_NUL, PB_NUL, SW_ShowNormal);

-   dwTest = PB_CVDWD(MyString, 1);
-   dwTest = PB_CVDWD(MyString, 3);
+   dwTest = PB_CvDwd(MyString, 1);
+   dwTest = PB_CvDwd(MyString, 3);

    BinFile = 1;
    InFile  = 2;
@@ -288,6 +289,10 @@
    file_1.read(&MyString[0], 500);
    file_1.write(&MyString[0], MyString.size());

+   file_3 << PB_CvByt(Num, n) << endl;
+   file_3 << PB_Cvd(Num, 1) << endl;
+   file_3 << PB_Cvi(Num, 4) << endl;
+   file_3 << PB_Cvl(Num, 1) << endl;
    file_3 << endl;
    file_3 << "This is a test" << endl;
    file_3 << "This is a test";


console-server: Apply fcntl workaround to linux also.

	* src/console-server.cc: Replace macos check to !win32.

--- src/console-server.cc
+++ src/console-server.cc
@@ -125,7 +125,7 @@
     // mode too.  This is not what we want.  So set it to blocking
     // just the time to issue the message.  See the libport
     // documentation for details.
-#if defined __APPLE__
+#if !defined WIN32
     // Save and set.
     int flags = fcntl(STDOUT_FILENO, F_GETFL);
     if (flags == -1)
@@ -133,7 +133,7 @@
     ERRNO_RUN(fcntl, STDOUT_FILENO, F_SETFL, flags & ~O_NONBLOCK);
 #endif
     std::cout << t;
-#if defined __APPLE__
+#if !defined WIN32
     // Restore.
     ERRNO_RUN(fcntl, STDOUT_FILENO, F_SETFL, flags);
 #endif


add some comment.

add some comment.

--- predict.cpp
+++ predict.cpp
@@ -89,7 +89,7 @@

 	int K = prob->K;
 	cout << "constructing factors...";
-	vector<UniFactor*> x;
+	vector<UniFactor*> x;	//x is the permutation matrix sliced depend on rows.
 	for (int i = 0; i < K; i++){
 		UniFactor* x_i = new UniFactor(K, prob->node_score_vecs[i], param);
 		x.push_back(x_i);


Include typedef FunctionMap into VectorTools. This will be replaced by a globalized FunctionMap later. Include missing explicite templatizations.

git-svn-id: 31d9d2f6432a47c86a3640814024c107794ea77c@4381 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/deal.II/source/numerics/vectors.cc
+++ deal.II/deal.II/source/numerics/vectors.cc
@@ -383,7 +383,7 @@
 					 // the different boundary parts. We want the
 					 // @p{function} to hold on all parts of the
 					 // boundary
-	std::map<unsigned char,const Function<dim>*> boundary_functions;
+	FMap<dim>::FunctionMap boundary_functions;
 	for (unsigned char c=0; c<255; ++c)
 	  boundary_functions[c] = &function;
 	project_boundary_values (dof, boundary_functions, q_boundary,
@@ -750,7 +750,7 @@
 void
 VectorTools::project_boundary_values (const Mapping<dim>       &mapping,
 				      const DoFHandler<dim>    &dof,
-				      const std::map<unsigned char,const Function<dim>*> &boundary_functions,
+				      const FMap<dim>::FunctionMap &boundary_functions,
 				      const Quadrature<dim-1>  &q,
 				      std::map<unsigned int,double> &boundary_values)
 {
@@ -765,8 +765,7 @@

   std::vector<unsigned int> dof_to_boundary_mapping;
   std::set<unsigned char> selected_boundary_components;
-  for (typename std::map<unsigned char,const Function<dim>*>::const_iterator
-	 i=boundary_functions.begin();
+  for (typename FMap<dim>::FunctionMap::const_iterator i=boundary_functions.begin();
        i!=boundary_functions.end(); ++i)
     selected_boundary_components.insert (i->first);

@@ -843,7 +842,7 @@
 template <int dim>
 void
 VectorTools::project_boundary_values (const DoFHandler<dim>    &dof,
-				      const std::map<unsigned char,const Function<dim>*> &boundary_functions,
+				      const FMap<dim>::FunctionMap &boundary_functions,
 				      const Quadrature<dim-1>  &q,
 				      std::map<unsigned int,double> &boundary_values)
 {
@@ -1268,6 +1267,15 @@
 			      const Vector<double>     &,
 			      Vector<double>           &);
 template
+void VectorTools::project (const DoFHandler<deal_II_dimension>   &,
+			   const ConstraintMatrix                &,
+			   const Quadrature<deal_II_dimension>   &,
+			   const Function<deal_II_dimension>     &,
+			   Vector<double>                        &,
+			   const bool,
+			   const Quadrature<deal_II_dimension-1> &,
+			   const bool);
+template
 void VectorTools::create_right_hand_side (const Mapping<deal_II_dimension>    &,
 					  const DoFHandler<deal_II_dimension> &,
 					  const Quadrature<deal_II_dimension> &,
@@ -1278,6 +1286,12 @@
 					  const Quadrature<deal_II_dimension> &,
 					  const Function<deal_II_dimension>   &,
 					  Vector<double>                      &);
+template
+void VectorTools::interpolate_boundary_values (const DoFHandler<deal_II_dimension> &,
+					       const unsigned char,
+					       const Function<deal_II_dimension>   &,
+					       std::map<unsigned int,double>       &,
+					       const std::vector<bool>    &);
 template
 void VectorTools::integrate_difference (const Mapping<deal_II_dimension>    &,
 					const DoFHandler<deal_II_dimension> &,
@@ -1296,8 +1310,14 @@
 					const NormType                      &,
 					const Function<deal_II_dimension>   *);
 template
+void VectorTools::project_boundary_values (const Mapping<deal_II_dimension>     &,
+					   const DoFHandler<deal_II_dimension>  &,
+					   const FMap<deal_II_dimension>::FunctionMap &,
+					   const Quadrature<deal_II_dimension-1>&,
+					   std::map<unsigned int,double>        &);
+template
 void VectorTools::project_boundary_values (const DoFHandler<deal_II_dimension>  &,
-					   const std::map<unsigned char,const Function<deal_II_dimension>*>&,
+					   const FMap<deal_II_dimension>::FunctionMap &,
 					   const Quadrature<deal_II_dimension-1>&,
 					   std::map<unsigned int,double>        &);
 template
@@ -1324,13 +1344,8 @@
 					       std::map<unsigned int,double>       &,
 					       const std::vector<bool>    &);
 template
-void VectorTools::interpolate_boundary_values (const DoFHandler<deal_II_dimension> &,
-					       const unsigned char,
-					       const Function<deal_II_dimension>   &,
-					       std::map<unsigned int,double>       &,
-					       const std::vector<bool>    &);
-template
-void VectorTools::project (const DoFHandler<deal_II_dimension>   &,
+void VectorTools::project (const Mapping<deal_II_dimension>      &,
+			   const DoFHandler<deal_II_dimension>   &,
 			   const ConstraintMatrix                &,
 			   const Quadrature<deal_II_dimension>   &,
 			   const Function<deal_II_dimension>     &,


Export the list of parent types to templates

--- printer.cpp
+++ printer.cpp
@@ -170,15 +170,23 @@
         for (const auto& type: model.types)
         {
             object mType { { "classname", type.first } };
-            list mFields;
-            for (const auto& f: type.second.fields)
-            {
-                object fieldDef { { "name", f.name }
-                                , { "datatype", renderType(f.type) } };
-                dumpFieldAttrs(f, fieldDef);
-                mFields.emplace_back(move(fieldDef));
-            }
-            setList(&mType, "vars", move(mFields));
+            {
+                list mParents;
+                for (const auto& t: type.second.parentTypes)
+                    mParents.emplace_back(renderType(t));
+                setList(&mType, "parents", move(mParents));
+            }
+            {
+                list mFields;
+                for (const auto& f: type.second.fields)
+                {
+                    object fieldDef { { "name",     f.name },
+                                      { "datatype", renderType(f.type) } };
+                    dumpFieldAttrs(f, fieldDef);
+                    mFields.emplace_back(move(fieldDef));
+                }
+                setList(&mType, "vars", move(mFields));
+            }
             mTypes.emplace_back(object { { "model", move(mType) } });
         }
         if (!mTypes.empty())


Fix ConstraintSet::isSatisfied

Fix ConstraintSet::isSatisfied

  - the error vector was not filled when constraint was satisfied.

--- src/constraint-set.cc
+++ src/constraint-set.cc
@@ -146,10 +146,10 @@
       for (Constraints_t::iterator itConstraint = constraints_.begin ();
 	   itConstraint != constraints_.end (); ++itConstraint) {
 	if (!(*itConstraint)->isSatisfied (configuration, localError)) {
-	  error.conservativeResize (error.size () + localError.size ());
-	  error.tail (localError.size ()) = localError;
 	  result = false;
 	}
+	error.conservativeResize (error.size () + localError.size ());
+	error.tail (localError.size ()) = localError;
       }
       return result;
     }


Fixed bug with GetSubString being able to go past end of buffer in TestString class.

--- test/TestString.hpp
+++ test/TestString.hpp
@@ -180,21 +180,24 @@
                       bool remove = false)
     {
         sub_str.Clear();
-        TestStringUtility::SafeReallocCopy(sub_str.m_string,
-                                           sub_str.m_length,
-                                           m_string + start,
-                                           count);
-        if (remove)
-        {
-            if (sub_str.m_length < m_length)
+        if (start + count <= m_length)
+        {
+            TestStringUtility::SafeReallocCopy(sub_str.m_string,
+                                               sub_str.m_length,
+                                               m_string + start,
+                                               count);
+            if (remove)
             {
-                size_type chars_remaining = m_length - sub_str.m_length;
-                ::memmove(m_string, m_string + sub_str.m_length, chars_remaining);
-                *(m_string + chars_remaining) = '\0';
-                m_length = chars_remaining;
+                if (sub_str.m_length < m_length)
+                {
+                    size_type chars_remaining = m_length - sub_str.m_length;
+                    ::memmove(m_string, m_string + sub_str.m_length, chars_remaining);
+                    *(m_string + chars_remaining) = '\0';
+                    m_length = chars_remaining;
+                }
+                else
+                    Clear();
             }
-            else
-                Clear();
         }
     }


Another size reduction for positional paramsful version

--- printf-c.cc
+++ printf-c.cc
@@ -522,9 +522,7 @@
         }
     };

-    //unsigned read_int(const char*& fmt, unsigned def) NOINLINE;
-    inline unsigned read_int(const char*& fmt, unsigned def) VERYINLINE;
-    inline unsigned read_int(const char*& fmt, unsigned def)
+    unsigned read_int(const char*& fmt, unsigned def)
     {
         if(*fmt >= '0' && *fmt <= '9')
         {
@@ -534,8 +532,9 @@
         }
         return def;
     }
-    unsigned read_param_index(const char*& fmt) NOINLINE;
-    unsigned read_param_index(const char*& fmt)
+
+    inline unsigned read_param_index(const char*& fmt) VERYINLINE;
+    inline unsigned read_param_index(const char*& fmt)
     {
         const char* bkup = fmt;
         unsigned index = read_int(fmt, 0);
@@ -715,6 +714,7 @@
                         param_index = min_width;
                         min_width   = 0;
                         fmt_flags   &= ~fmt_zeropad;
+                        //fmt_flags = 0; set_sizebase(base_decimal, int);
                         goto moreflags1;
                     } else goto got_unk;

@@ -809,7 +809,7 @@
                     case 'x': {                                     set_base(base_hex);   goto got_int; }
                     case 'o': {                                     set_base(base_octal); goto got_int; }
                     case 'b': if_constexpr(!SUPPORT_BINARY_FORMAT) goto got_unk; else { set_base(base_binary); goto got_int; }
-                    case 'd': case 'i':                         { fmt_flags |= fmt_signed; goto got_int; }
+                    case 'd': case 'i': { fmt_flags |= fmt_signed; } PASSTHRU
                     case 'u': got_int:
                     {
                         intfmt_t value = 0;
@@ -940,7 +940,8 @@
                     }
                     case 2:
                     {
-                        unsigned short* param_offset_table = reinterpret_cast<unsigned short *>(&param_data_table[0]);
+                        unsigned char* table = &param_data_table[0];
+                        unsigned short* param_offset_table = reinterpret_cast<unsigned short *>(table);
                         for(unsigned n=0; n<n_params; ++n)
                         {
                             // Convert the size & typecode into an offset
@@ -948,17 +949,17 @@
                             unsigned offset = n + paramsize_units;
                             param_offset_table[n] = offset;
                             // Load the parameter and store it
-                            unsigned char* tgt = &param_data_table[largest * offset];
+                            unsigned char* tgt = &table[largest * offset];
                             switch(typecode)
                             {
-                                default:{ type0:; int v = va_arg(ap,int);     std::memcpy(tgt,&v,sizeof(v)); } break;
-                                case 1: { long      v = va_arg(ap,long);      std::memcpy(tgt,&v,sizeof(v)); } break;
-                                case 2: { long long v = va_arg(ap,long long); std::memcpy(tgt,&v,sizeof(v)); } break;
-                                case 3: { void*     v = va_arg(ap,void*);     std::memcpy(tgt,&v,sizeof(v)); } break;
+                                default:{ type0:; *(int*)tgt = va_arg(ap,int);     break; }
+                                case 1: { *(long*)tgt      = va_arg(ap,long);      break; }
+                                case 2: { *(long long*)tgt = va_arg(ap,long long); break; }
+                                case 3: { *(void**)tgt     = va_arg(ap,void*);     break; }
                                 case 4: if_constexpr(!SUPPORT_FLOAT_FORMATS) { goto type0; } else
-                                        { double      v = va_arg(ap,double);      std::memcpy(tgt,&v,sizeof(v)); break; }
+                                        { *(double*)tgt    = va_arg(ap,double);    break; }
                                 case 5: if_constexpr(!SUPPORT_FLOAT_FORMATS || !SUPPORT_LONG_DOUBLE) { goto type0; } else
-                                        { long double v = va_arg(ap,long double); std::memcpy(tgt,&v,sizeof(v)); break; }
+                                        { *(long double*)tgt = va_arg(ap,long double); break; }
                             }
                         }
                         break;


gni, forgot to call the new subtest

gni, forgot to call the new subtest

--HG--
extra : convert_revision : svn%3A283d02a7-25f6-0310-bc7c-ecb5cbfe19da/trunk/kdesupport/eigen2%40961206

--- test/basicstuff.cpp
+++ test/basicstuff.cpp
@@ -129,4 +129,6 @@
     CALL_SUBTEST( basicStuff(Matrix<float, 100, 100>()) );
     CALL_SUBTEST( basicStuff(Matrix<long double,Dynamic,Dynamic>(10,10)) );
   }
+
+  CALL_SUBTEST(casting());
 }


Make Global::manager pointer, so we can delete it before logger

svn path=/trunk/kdesupport/qca/; revision=651714

--- src/qca_core.cpp
+++ src/qca_core.cpp
@@ -55,7 +55,7 @@
 	bool secmem;
 	bool first_scan;
 	QString app_name;
-	ProviderManager manager;
+	ProviderManager *manager;
 	Random *rng;
 	Logger *logger;
 	QVariantMap properties;
@@ -68,13 +68,18 @@
 		first_scan = false;
 		rng = 0;
 		logger = new Logger;
+		manager = new ProviderManager;
 	}

 	~Global()
 	{
 		KeyStoreManager::shutdown();
+		delete manager;
+		manager = 0;
+		delete rng;
+		rng = 0;
 		delete logger;
-		delete rng;
+		logger = 0;
 	}

 	void ensure_first_scan()
@@ -86,7 +91,7 @@
 	void scan()
 	{
 		first_scan = true;
-		manager.scan();
+		manager->scan();
 	}

 	void ksm_scan()
@@ -138,7 +143,7 @@

 	global = new Global;
 	global->secmem = secmem;
-	global->manager.setDefault(create_default_provider()); // manager owns it
+	global->manager->setDefault(create_default_provider()); // manager owns it
 	++(global->refs);

 	// for maximum setuid safety, qca should be initialized before qapp:
@@ -196,12 +201,12 @@
 	// single
 	if(!provider.isEmpty())
 	{
-		Provider *p = global->manager.find(provider);
+		Provider *p = global->manager->find(provider);
 		if(!p)
 		{
 			// ok, try scanning for new stuff
 			global->scan();
-			p = global->manager.find(provider);
+			p = global->manager->find(provider);
 		}

 		if(p && features_have(p->features(), features))
@@ -210,13 +215,13 @@
 	// all
 	else
 	{
-		if(features_have(global->manager.allFeatures(), features))
+		if(features_have(global->manager->allFeatures(), features))
 			return true;

 		// ok, try scanning for new stuff
 		global->scan();

-		if(features_have(global->manager.allFeatures(), features))
+		if(features_have(global->manager->allFeatures(), features))
 			return true;
 	}
 	return false;
@@ -236,7 +241,7 @@

 	// query all features
 	global->scan();
-	return global->manager.allFeatures();
+	return global->manager->allFeatures();
 }

 QStringList defaultFeatures()
@@ -246,7 +251,7 @@
 	if(!global)
 		return QStringList();

-	return global->manager.find("default")->features();
+	return global->manager->find("default")->features();
 }

 ProviderList providers()
@@ -258,7 +263,7 @@

 	global->ensure_first_scan();

-	return global->manager.providers();
+	return global->manager->providers();
 }

 bool insertProvider(Provider *p, int priority)
@@ -270,7 +275,7 @@

 	global->ensure_first_scan();

-	return global->manager.add(p, priority);
+	return global->manager->add(p, priority);
 }

 void setProviderPriority(const QString &name, int priority)
@@ -282,7 +287,7 @@

 	global->ensure_first_scan();

-	global->manager.changePriority(name, priority);
+	global->manager->changePriority(name, priority);
 }

 int providerPriority(const QString &name)
@@ -294,7 +299,7 @@

 	global->ensure_first_scan();

-	return global->manager.getPriority(name);
+	return global->manager->getPriority(name);
 }

 Provider *findProvider(const QString &name)
@@ -306,7 +311,7 @@

 	global->ensure_first_scan();

-	return global->manager.find(name);
+	return global->manager->find(name);
 }

 Provider *defaultProvider()
@@ -316,7 +321,7 @@
 	if(!global)
 		return 0;

-	return global->manager.find("default");
+	return global->manager->find("default");
 }

 void scanForPlugins()
@@ -340,13 +345,13 @@
 		return;

 	// if the global_rng was owned by a plugin, then delete it
-	if(global->rng && (global->rng->provider() != global->manager.find("default")))
+	if(global->rng && (global->rng->provider() != global->manager->find("default")))
 	{
 		delete global->rng;
 		global->rng = 0;
 	}

-	global->manager.unloadAll();
+	global->manager->unloadAll();
 }

 QString pluginDiagnosticText()
@@ -356,7 +361,7 @@
 	if(!global)
 		return QString();

-	return global->manager.diagnosticText();
+	return global->manager->diagnosticText();
 }

 void clearPluginDiagnosticText()
@@ -366,7 +371,7 @@
 	if(!global)
 		return;

-	global->manager.clearDiagnosticText();
+	global->manager->clearDiagnosticText();
 }

 void setProperty(const QString &name, const QVariant &value)
@@ -641,26 +646,26 @@
 	if(!provider.isEmpty())
 	{
 		// try using specific provider
-		p = global->manager.findFor(provider, type);
+		p = global->manager->findFor(provider, type);
 		if(!p)
 		{
 			// maybe this provider is new, so scan and try again
 			global->scan();
 			scanned = true;
-			p = global->manager.findFor(provider, type);
+			p = global->manager->findFor(provider, type);
 		}
 	}
 	if(!p)
 	{
 		// try using some other provider
-		p = global->manager.findFor(QString(), type);
+		p = global->manager->findFor(QString(), type);
 		if((!p || p->name() == "default") && !scanned)
 		{
 			// maybe there are new providers, so scan and try again
 			//   before giving up or using default
 			global->scan();
 			scanned = true;
-			p = global->manager.findFor(QString(), type);
+			p = global->manager->findFor(QString(), type);
 		}
 	}

@@ -705,7 +710,7 @@
 		if(!global)
 			return 0;

-		p = global->manager.find(_p);
+		p = global->manager->find(_p);
 		if(!p)
 			return 0;
 	}


Add Smoothing to Pitch wheel and mod wheel and fix pedal handling for Midi-to-CV

--- src/core/MidiToCV.cpp
+++ src/core/MidiToCV.cpp
@@ -9,6 +9,12 @@
  * MIDIToCVInterface converts midi note on/off events, velocity , channel aftertouch, pitch wheel and mod wheel to
  * CV
  */
+struct MidiValue {
+	int val = 0; // Controller value
+	TransitionSmoother tSmooth;
+	bool changed = false; // Value has been changed by midi message (only if it is in sync!)
+};
+
 struct MIDIToCVInterface : MidiIO, Module {
 	enum ParamIds {
 		RESET_PARAM,
@@ -34,17 +40,17 @@
 	std::list<int> notes;
 	bool pedal = false;
 	int note = 60; // C4, most modules should use 261.626 Hz
-	int mod = 0;
 	int vel = 0;
-	int afterTouch = 0;
-	int pitchWheel = 64;
-	bool retrigger = false;
-	bool retriggered = false;
+	MidiValue mod;
+	MidiValue afterTouch;
+	MidiValue pitchWheel;
+	bool gate = false;

 	SchmittTrigger resetTrigger;

 	MIDIToCVInterface() : MidiIO(), Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
-
+		pitchWheel.val = 64;
+		pitchWheel.tSmooth.set(0, 0);
 	}

 	~MIDIToCVInterface() {
@@ -77,11 +83,14 @@
 };

 void MIDIToCVInterface::resetMidi() {
-	mod = 0;
-	pitchWheel = 64;
-	afterTouch = 0;
+	mod.val = 0;
+	mod.tSmooth.set(0, 0);
+	pitchWheel.val = 64;
+	pitchWheel.tSmooth.set(0, 0);
+	afterTouch.val = 0;
+	afterTouch.tSmooth.set(0, 0);
 	vel = 0;
-	outputs[GATE_OUTPUT].value = 0.0;
+	gate = false;
 	notes.clear();
 }

@@ -99,11 +108,6 @@

 	outputs[PITCH_OUTPUT].value = ((note - 60)) / 12.0;

-	bool gate = pedal || !notes.empty();
-	if (retrigger && retriggered) {
-		gate = false;
-		retriggered = false;
-	}
 	if (resetTrigger.process(params[RESET_PARAM].value)) {
 		resetMidi();
 		return;
@@ -112,11 +116,27 @@
 	lights[RESET_LIGHT].value -= lights[RESET_LIGHT].value / 0.55 / engineGetSampleRate(); // fade out light

 	outputs[GATE_OUTPUT].value = gate ? 10.0 : 0.0;
-	outputs[MOD_OUTPUT].value = mod / 127.0 * 10.0;
-	outputs[PITCHWHEEL_OUTPUT].value = (pitchWheel - 64) / 64.0 * 10.0;
-	outputs[CHANNEL_AFTERTOUCH_OUTPUT].value = afterTouch / 127.0 * 10.0;
 	outputs[VELOCITY_OUTPUT].value = vel / 127.0 * 10.0;

+	int steps = int(engineGetSampleRate() / 32);
+
+	if (mod.changed) {
+		mod.tSmooth.set(outputs[MOD_OUTPUT].value, (mod.val / 127.0 * 10.0), steps);
+		mod.changed = false;
+	}
+	outputs[MOD_OUTPUT].value = mod.tSmooth.next();
+
+	if (pitchWheel.changed) {
+		pitchWheel.tSmooth.set(outputs[PITCHWHEEL_OUTPUT].value, (pitchWheel.val - 64) / 64.0 * 10.0, steps);
+		pitchWheel.changed = false;
+	}
+	outputs[PITCHWHEEL_OUTPUT].value = pitchWheel.tSmooth.next();
+
+
+	/* NOTE: I'll leave out value smoothing for after touch for now. I currently don't
+	 * have an after touch capable device around and I assume it would require different
+	 * smoothing*/
+	outputs[CHANNEL_AFTERTOUCH_OUTPUT].value = afterTouch.val / 127.0 * 10.0;
 }

 void MIDIToCVInterface::pressNote(int note) {
@@ -127,7 +147,7 @@
 	// Push note
 	notes.push_back(note);
 	this->note = note;
-	retriggered = true;
+	gate = true;
 }

 void MIDIToCVInterface::releaseNote(int note) {
@@ -138,12 +158,15 @@

 	if (pedal) {
 		// Don't release if pedal is held
+		gate = true;
 	} else if (!notes.empty()) {
 		// Play previous note
 		auto it2 = notes.end();
 		it2--;
 		this->note = *it2;
-		retriggered = true;
+		gate = true;
+	} else {
+		gate = false;
 	}
 }

@@ -153,7 +176,7 @@
 	int data1 = msg[1];
 	int data2 = msg[2];

-	//fprintf(stderr, "channel %d status %d data1 %d data2 %d\n", channel, status, data1,data2);
+	fprintf(stderr, "channel %d status %d data1 %d data2 %d\n", channel, status, data1, data2);

 	// Filter channels
 	if (this->channel >= 0 && this->channel != channel)
@@ -177,19 +200,24 @@
 		case 0xb: // cc
 			switch (data1) {
 				case 0x01: // mod
-					this->mod = data2;
+					mod.val = data2;
+					mod.changed = true;
 					break;
 				case 0x40: // sustain
 					pedal = (data2 >= 64);
-					releaseNote(-1);
+					if (!pedal) {
+						releaseNote(-1);
+					}
 					break;
 			}
 			break;
 		case 0xe: // pitch wheel
-			this->pitchWheel = data2;
+			pitchWheel.val = data2;
+			pitchWheel.changed = true;
 			break;
 		case 0xd: // channel aftertouch
-			this->afterTouch = data1;
+			afterTouch.val = data1;
+			afterTouch.changed = true;
 			break;
 	}
 }
@@ -225,7 +253,8 @@
 	}

 	addParam(createParam<LEDButton>(Vec(7 * 15, labelHeight), module, MIDIToCVInterface::RESET_PARAM, 0.0, 1.0, 0.0));
-	addChild(createLight<SmallLight<RedLight>>(Vec(7 * 15 + 5, labelHeight + 5), module, MIDIToCVInterface::RESET_LIGHT));
+	addChild(createLight<SmallLight<RedLight>>(Vec(7 * 15 + 5, labelHeight + 5), module,
+											   MIDIToCVInterface::RESET_LIGHT));
 	{
 		Label *label = new Label();
 		label->box.pos = Vec(margin, yPos);
@@ -257,7 +286,7 @@
 	}

 	std::string labels[MIDIToCVInterface::NUM_OUTPUTS] = {"1V/oct", "Gate", "Velocity", "Mod Wheel", "Pitch Wheel",
-															"Aftertouch"};
+														  "Aftertouch"};

 	for (int i = 0; i < MIDIToCVInterface::NUM_OUTPUTS; i++) {
 		Label *label = new Label();


[Qt] use tr() instead of QObject::tr() in intro.cpp

--- src/qt/intro.cpp
+++ src/qt/intro.cpp
@@ -181,8 +181,8 @@
                 fs::create_directory(dataDir.toStdString());
                 break;
             } catch(fs::filesystem_error &e) {
-                QMessageBox::critical(0, QObject::tr("Bitcoin"),
-                                      QObject::tr("Error: Specified data directory \"%1\" can not be created.").arg(dataDir));
+                QMessageBox::critical(0, tr("Bitcoin"),
+                    tr("Error: Specified data directory \"%1\" can not be created.").arg(dataDir));
                 /* fall through, back to choosing screen */
             }
         }


qt: Adjust BLOCK_CHAIN_SIZE to 20GB

qt: Adjust BLOCK_CHAIN_SIZE to 20GB

This increases the space requirement for selecting a data directory in
the UI.
As suggested by @bardiharborow, fixes #3830.

--- src/qt/intro.cpp
+++ src/qt/intro.cpp
@@ -14,7 +14,7 @@

 /* Minimum free space (in bytes) needed for data directory */
 static const uint64_t GB_BYTES = 1000000000LL;
-static const uint64_t BLOCK_CHAIN_SIZE = 10LL * GB_BYTES;
+static const uint64_t BLOCK_CHAIN_SIZE = 20LL * GB_BYTES;

 /* Check free space asynchronously to prevent hanging the UI thread.


reload base after we call memmove

reload base after we call memmove

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@2549 2bbb7eff-a529-9590-31e7-b0007b416f81

--- src/core/SkAAClip.cpp
+++ src/core/SkAAClip.cpp
@@ -460,6 +460,8 @@
         return false;
     }

+    this->validate();
+
     const int width = fBounds.width();
     RunHead* head = fRunHead;
     YOffset* yoff = head->yoffsets();
@@ -498,6 +500,10 @@
         SkASSERT(!fBounds.isEmpty());
         head->fRowCount -= skip;
         SkASSERT(head->fRowCount > 0);
+
+        this->validate();
+        // need to reset this after the memmove
+        base = head->data();
     }

     //  Look to trim away empty rows from the bottom.
@@ -520,6 +526,7 @@
         head->fRowCount -= skip;
         SkASSERT(head->fRowCount > 0);
     }
+    this->validate();

     return true;
 }
@@ -922,7 +929,9 @@
             SkASSERT(!(count & 1));
             int w = 0;
             for (int x = 0; x < count; x += 2) {
-                w += ptr[0];
+                int n = ptr[0];
+                SkASSERT(n > 0);
+                w += n;
                 SkASSERT(w <= fWidth);
                 ptr += 2;
             }


Litecoin: Update blockchain size

Litecoin: Update blockchain size

--- src/qt/intro.cpp
+++ src/qt/intro.cpp
@@ -23,7 +23,7 @@

 static const uint64_t GB_BYTES = 1000000000LL;
 /* Minimum free space (in GB) needed for data directory */
-constexpr uint64_t BLOCK_CHAIN_SIZE = 18;
+constexpr uint64_t BLOCK_CHAIN_SIZE = 20;
 /* Minimum free space (in GB) needed for data directory when pruned; Does not include prune target */
 static const uint64_t CHAIN_STATE_SIZE = 3;
 /* Total required space (in GB) depending on user choice (prune, not prune) */


fix test for empty config

fix test for empty config

handle empty setconfig

BUG=skia:

Review URL: https://codereview.chromium.org/159533002

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@13394 2bbb7eff-a529-9590-31e7-b0007b416f81

--- src/core/SkBitmap.cpp
+++ src/core/SkBitmap.cpp
@@ -263,7 +263,7 @@
         return reset_return_false(this);
     }

-    if (info.isEmpty()) {
+    if (info.width() < 0 || info.height() < 0) {
         return reset_return_false(this);
     }


Added support for quantizing to CI4/I4.

Added support for quantizing to CI4/I4.

--- src/quantize.cpp
+++ src/quantize.cpp
@@ -33,6 +33,8 @@
 #include <limits>
 #include <cmath>

+#include <iostream>
+
 using std::max;
 using std::min;

@@ -55,6 +57,10 @@
 	return min(max(x,F(minval<I>())),F(maxval<I>()));
 }

+inline int8_t clip_4bit(int8_t x) {
+	return min(max(x,int8_t(-7)),int8_t(7));
+}
+
 template<typename IType, typename SType, typename OType>
 inline void quantize(IType ival, SType scale, OType& oval) {
 	//std::cout << (int)minval<OType>() << ", " << (int)maxval<OType>() << std::endl;
@@ -96,6 +102,31 @@
 	for( Size i=0; i<nelement; ++i ) {
 		func(in[i], out[i]);
 		//std::cout << std::hex << (int)in[i] << " --> " << (int)out[i] << std::endl;
+	}
+}
+
+template<typename T, typename Func, typename Size>
+void foreach_simple_cpu_4bit(T const* in,
+                             int8_t*       out,
+                             Size     nelement,
+                             Func     func) {
+	T tempR;
+	T tempI;
+	int8_t tempO;
+	for( Size i=0; i<nelement; i+=2 ) {
+		tempR = in[i+0];
+		tempI = in[i+1];
+		if(func.byteswap_in) {
+			byteswap(tempR, &tempR);
+			byteswap(tempI, &tempI);
+		}
+		//std::cout << tempR << ", " << tempI << " --> " << rint(clip_4bit(tempR)) << ", " << rint(clip_4bit(tempI)) << '\n';
+		tempO = (((int8_t(rint(clip_4bit(tempR)))*16)     ) & 0xF0) | \
+			    (((int8_t(rint(clip_4bit(tempI)))*16) >> 4) & 0x0F);
+		if(func.byteswap_out) {
+			byteswap(tempO, &tempO);
+		}
+		out[i/2] = tempO;
 	}
 }

@@ -133,6 +164,10 @@
 	bool byteswap_in  = ( in->big_endian != is_big_endian());
 	bool byteswap_out = (out->big_endian != is_big_endian());

+	if( out->dtype == BF_DTYPE_I4 ){
+		BF_ASSERT(nelement%2 == 0, BF_STATUS_UNSUPPORTED_STRIDE);
+	}
+
 #define CALL_FOREACH_SIMPLE_CPU_QUANTIZE(itype,stype,otype) \
 	foreach_simple_cpu((itype*)in->data, \
 	                   (otype*)out->data, \
@@ -144,6 +179,14 @@
 	if( in->dtype == BF_DTYPE_F32 || in->dtype == BF_DTYPE_CF32 ) {
 		// TODO: Support T-->T with endian conversion (like quantize but with identity func instead)
 		switch( out->dtype ) {
+		case BF_DTYPE_CI4: nelement *= 2;
+		case BF_DTYPE_I4: {
+			foreach_simple_cpu_4bit((float*)in->data, \
+			                        (int8_t*)out->data, \
+			                        nelement, \
+			                        QuantizeFunctor<float,float,uint8_t> \
+			                        (scale,byteswap_in,byteswap_out)); break;
+		}
 		case BF_DTYPE_CI8: nelement *= 2;
 		case BF_DTYPE_I8: {
 			CALL_FOREACH_SIMPLE_CPU_QUANTIZE(float,float,int8_t); break;


handle bad xform in drawTextRSXform

handle bad xform in drawTextRSXform

Bug: oss-fuzz:6955
Change-Id: Ide1f57459a611980a86afea577eb4c2425e49e63
Reviewed-on: https://skia-review.googlesource.com/114782
Reviewed-by: Mike Reed <f5cabf8735907151a446812c9875d6c0c712d847@google.com>
Commit-Queue: Mike Reed <f5cabf8735907151a446812c9875d6c0c712d847@google.com>

--- src/core/SkDevice.cpp
+++ src/core/SkDevice.cpp
@@ -511,8 +511,11 @@
         // with a localmatrixshader so that the shader draws as if there was no change to the ctm.
         if (shader) {
             SkMatrix inverse;
-            SkAssertResult(localM.invert(&inverse));
-            localPaint.setShader(shader->makeWithLocalMatrix(inverse));
+            if (localM.invert(&inverse)) {
+                localPaint.setShader(shader->makeWithLocalMatrix(inverse));
+            } else {
+                localPaint.setShader(nullptr);  // can't handle this xform
+            }
         }

         int subLen = proc((const char*)text);


Simplify RNG

Simplify RNG

--- src/random_lcg.C
+++ src/random_lcg.C
@@ -11,10 +11,10 @@
 const uint64_t prn_mod    = 0x8000000000000000;      // 2^63
 const uint64_t prn_mask   = 0x7fffffffffffffff;      // 2^63 - 1
 const uint64_t prn_stride = 152917LL;                // stride between particles
-const double   prn_norm = pow(2, -63);               // 2^-63
+const double   prn_norm   = pow(2, -63);             // 2^-63

 // Module constants
-const int N_STREAMS = 5;
+const int N_STREAMS         = 5;
 const int STREAM_TRACKING   = 0;
 const int STREAM_TALLIES    = 1;
 const int STREAM_SOURCE     = 2;
@@ -82,16 +82,8 @@
 extern "C" uint64_t
 future_seed(uint64_t n, uint64_t seed)
 {
-  // In cases where we want to skip backwards, we add the period of the random
-  // number generator until the number of PRNs to skip is positive since
-  // skipping ahead that much is the same as skipping backwards by the original
-  // amount.
-
-  uint64_t nskip = n;
-  while (nskip > prn_mod) nskip += prn_mod;
-
   // Make sure nskip is less than 2^M.
-  nskip &= prn_mask;
+  n &= prn_mask;

   // The algorithm here to determine the parameters used to skip ahead is
   // described in F. Brown, "Random Number Generation with Arbitrary Stride,"
@@ -105,17 +97,17 @@
   uint64_t g_new = 1;
   uint64_t c_new = 0;

-  while (nskip > 0) {
+  while (n > 0) {
     // Check if the least significant bit is 1.
-    if (nskip & 1) {
-      g_new = (g_new * g) & prn_mask;
-      c_new = (c_new * g + c) & prn_mask;
+    if (n & 1) {
+      g_new = g_new * g;
+      c_new = c_new * g + c;
     }
-    c = ((g + 1) * c) & prn_mask;
-    g = (g * g) & prn_mask;
+    c = (g + 1) * c;
+    g = g * g;

     // Move bits right, dropping least significant bit.
-    nskip >>= 1;
+    n >>= 1;
   }

   // With G and C, we can now find the new seed.


Clang vs. gcc issue >.<

Clang vs. gcc issue >.<

Former-commit-id: 4de5af34b6ea74a720faa29919584f30b5f3be2c

--- src/read_imu.cpp
+++ src/read_imu.cpp
@@ -172,7 +172,7 @@
     double data_buffer[7];

     for(unsigned int i = 0; i < nEpochs; i++){
-      fread(&data_buffer, sizeof(double), 7, fid); // double
+      fread(&data_buffer, 8, 7, fid); // double

       for(int j = 0; j < 7; j++){
         data(i,j) = data_buffer[j];
@@ -185,7 +185,7 @@
     long data_buffer[6];

     for(unsigned int i = 0; i < nEpochs; i++){
-      fread(&time_buffer, sizeof(double), 1, fid); // double
+      fread(&time_buffer, 8, 1, fid); // double

       fread(&data_buffer, 4, 6, fid); // long


:bug: fix(list): fixed pop function of linked-list

--- cplusplus/wrencc2/container/linked_list.hh
+++ cplusplus/wrencc2/container/linked_list.hh
@@ -124,7 +124,7 @@

   T pop_head() {
     NodeType* node = head_;
-    if (head_ = head_->value; head_ == nullptr)
+    if (head_ = head_->next; head_ == nullptr)
       tail_ = nullptr;
     T r = node->value;
     destroy_aux(node);


Added missing std:: namespace prefix

Added missing std:: namespace prefix

--- src/core/fileutil.cpp
+++ src/core/fileutil.cpp
@@ -47,7 +47,7 @@
 bool IsAbsolutePath(const std::string &filename) {
     if (filename.size() == 0) return false;
     return (filename[0] == '\\' || filename[0] == '/' ||
-            filename.find(':') != string::npos);
+            filename.find(':') != std::string::npos);
 }

 std::string AbsolutePath(const std::string &filename) {


Added rng method for getting a pointer to the gsl_rng object

--- src/core/src/RngGsl.C
+++ src/core/src/RngGsl.C
@@ -115,4 +115,10 @@
   return gsl_ran_gamma(m_rng,a,b);
 }

+const gsl_rng*
+RngGsl::rng() const
+{
+  return m_rng;
+}
+
 }  // End namespace QUESO


Fix fallback behaviour when maximum edit distance is reached during diff

--- src/core/text-diff.cc
+++ src/core/text-diff.cc
@@ -16,7 +16,7 @@
   return position;
 }

-static int MAX_EDIT_DISTANCE = 1024;
+static int MAX_EDIT_DISTANCE = 4 * 1024;

 Patch text_diff(const Text &old_text, const Text &new_text) {
   Patch result;
@@ -26,14 +26,16 @@

   vector<diff_edit> edit_script;

-  if (diff(
+  int edit_distance = diff(
     old_text.content.data(),
     old_text.content.size(),
     new_text.content.data(),
     new_text.content.size(),
     MAX_EDIT_DISTANCE,
     &edit_script
-  ) == -1) {
+  );
+
+  if (edit_distance == -1 || edit_distance >= MAX_EDIT_DISTANCE) {
     result.splice(Point(), old_text.extent(), new_text.extent(), old_text, new_text);
     return result;
   }


Digest: fixed compatibility with OpenSSL >= 1.1.x

--- src/crypto/Digest.cpp
+++ src/crypto/Digest.cpp
@@ -100,7 +100,12 @@
 {
 #ifdef HAVE_OPENSSL
 	free(ret);
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+	if (ctx) EVP_MD_CTX_free((EVP_MD_CTX*)ctx);
+#else
 	if (ctx) EVP_MD_CTX_destroy((EVP_MD_CTX*)ctx);
+#endif
+
 #endif
 }

@@ -146,7 +151,11 @@
 		throw InvalidAlgorithmException("%s",(const char*)name);
 	}
 	if (!ctx) {
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+		ctx=EVP_MD_CTX_new();
+#else
 		ctx=EVP_MD_CTX_create();
+#endif
 		if (!ctx) throw OutOfMemoryException();
 	} else {
 		reset();
@@ -170,8 +179,10 @@
 #endif
 #ifndef OPENSSL_NO_SHA
 		case Algo_SHA1: m=EVP_sha1(); break;
-		case Algo_ECDSA: m=EVP_ecdsa(); break;
-
+		case Algo_ECDSA:
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+			m=EVP_ecdsa(); break;
+#endif
 #endif
 #ifndef OPENSSL_NO_SHA256
 		case Algo_SHA224: m=EVP_sha224(); break;
@@ -196,7 +207,11 @@
 		throw InvalidAlgorithmException("%i",algorithm);
 	}
 	if (!ctx) {
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+		ctx=EVP_MD_CTX_new();
+#else
 		ctx=EVP_MD_CTX_create();
+#endif
 		if (!ctx) throw OutOfMemoryException();
 	} else {
 		reset();
@@ -314,7 +329,11 @@
 		if (!ret) throw OutOfMemoryException();
 	}
 	EVP_DigestFinal((EVP_MD_CTX*)ctx,ret,&len);
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+	EVP_MD_CTX_reset((EVP_MD_CTX*)ctx);
+#else
 	EVP_MD_CTX_cleanup((EVP_MD_CTX*)ctx);
+#endif
 	EVP_DigestInit_ex((EVP_MD_CTX*)ctx,(const EVP_MD*)m, NULL);
 	bytecount=0;
 	return ByteArray(ret,len);
@@ -328,7 +347,11 @@
 #else
 	if (!m) throw NoAlgorithmSpecifiedException();
 	if (!ctx) throw NoAlgorithmSpecifiedException();
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+	EVP_MD_CTX_reset((EVP_MD_CTX*)ctx);
+#else
 	EVP_MD_CTX_cleanup((EVP_MD_CTX*)ctx);
+#endif
 	EVP_DigestInit((EVP_MD_CTX*)ctx,(const EVP_MD*)m);
 	bytecount=0;
 #endif


Use our own hmac_sha256 instead of OpenSSL's in scrypt.cpp

--- src/crypto/scrypt.cpp
+++ src/crypto/scrypt.cpp
@@ -28,9 +28,12 @@
  */

 #include "crypto/scrypt.h"
+
+#include "crypto/hmac_sha256.h"
+#include "crypto/sha256.h"
 #include "uint256.h"
 #include "utilstrencodings.h"
-#include <openssl/sha.h>
+
 #include <string>

 #include <string.h>
@@ -47,73 +50,6 @@
 }
 #endif

-typedef struct HMAC_SHA256Context {
-    SHA256_CTX ictx;
-    SHA256_CTX octx;
-} HMAC_SHA256_CTX;
-
-/* Initialize an HMAC-SHA256 operation with the given key. */
-static void
-HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, const void *_K, size_t Klen)
-{
-    unsigned char pad[64];
-    unsigned char khash[32];
-    const unsigned char *K = (const unsigned char *)_K;
-    size_t i;
-
-    /* If Klen > 64, the key is really SHA256(K). */
-    if (Klen > 64) {
-        SHA256_Init(&ctx->ictx);
-        SHA256_Update(&ctx->ictx, K, Klen);
-        SHA256_Final(khash, &ctx->ictx);
-        K = khash;
-        Klen = 32;
-    }
-
-    /* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */
-    SHA256_Init(&ctx->ictx);
-    memset(pad, 0x36, 64);
-    for (i = 0; i < Klen; i++)
-        pad[i] ^= K[i];
-    SHA256_Update(&ctx->ictx, pad, 64);
-
-    /* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */
-    SHA256_Init(&ctx->octx);
-    memset(pad, 0x5c, 64);
-    for (i = 0; i < Klen; i++)
-        pad[i] ^= K[i];
-    SHA256_Update(&ctx->octx, pad, 64);
-
-    /* Clean the stack. */
-    memset(khash, 0, 32);
-}
-
-/* Add bytes to the HMAC-SHA256 operation. */
-static void
-HMAC_SHA256_Update(HMAC_SHA256_CTX *ctx, const void *in, size_t len)
-{
-    /* Feed data to the inner SHA256 operation. */
-    SHA256_Update(&ctx->ictx, in, len);
-}
-
-/* Finish an HMAC-SHA256 operation. */
-static void
-HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX *ctx)
-{
-    unsigned char ihash[32];
-
-    /* Finish the inner SHA256 operation. */
-    SHA256_Final(ihash, &ctx->ictx);
-
-    /* Feed the inner hash to the outer SHA256 operation. */
-    SHA256_Update(&ctx->octx, ihash, 32);
-
-    /* Finish the outer SHA256 operation. */
-    SHA256_Final(digest, &ctx->octx);
-
-    /* Clean the stack. */
-    memset(ihash, 0, 32);
-}

 /**
  * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
@@ -124,7 +60,6 @@
 PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
               size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen)
 {
-    HMAC_SHA256_CTX PShctx, hctx;
     size_t i;
     uint8_t ivec[4];
     uint8_t U[32];
@@ -134,8 +69,7 @@
     size_t clen;

     /* Compute HMAC state after processing P and S. */
-    HMAC_SHA256_Init(&PShctx, passwd, passwdlen);
-    HMAC_SHA256_Update(&PShctx, salt, saltlen);
+    CHMAC_SHA256 PShctx = CHMAC_SHA256(passwd, passwdlen).Write(salt, saltlen);

     /* Iterate through the blocks. */
     for (i = 0; i * 32 < dkLen; i++) {
@@ -143,18 +77,14 @@
         be32enc(ivec, (uint32_t)(i + 1));

         /* Compute U_1 = PRF(P, S || INT(i)). */
-        memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX));
-        HMAC_SHA256_Update(&hctx, ivec, 4);
-        HMAC_SHA256_Final(U, &hctx);
+        CHMAC_SHA256(PShctx).Write(ivec, 4).Finalize(U);

         /* T_i = U_1 ... */
         memcpy(T, U, 32);

         for (j = 2; j <= c; j++) {
             /* Compute U_j. */
-            HMAC_SHA256_Init(&hctx, passwd, passwdlen);
-            HMAC_SHA256_Update(&hctx, U, 32);
-            HMAC_SHA256_Final(U, &hctx);
+            CHMAC_SHA256(passwd, passwdlen).Write(U, 32).Finalize(U);

             /* ... xor U_j ... */
             for (k = 0; k < 32; k++)
@@ -168,8 +98,6 @@
         memcpy(&buf[i * 32], T, clen);
     }

-    /* Clean PShctx, since we never called _Final on it. */
-    memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
 }

 static inline uint32_t


274. H-Index

274. H-Index

--- cpp/271-280/H-Index.cpp
+++ cpp/271-280/H-Index.cpp
@@ -1,19 +1,13 @@
 class Solution {
 public:
     int hIndex(vector<int>& citations) {
-
         sort(citations.begin(), citations.end());
-
         int h = citations.size();
-
-        int i = 0;
-        for(int i = 0;i < citations.size();i++)
-        {
-            if(citations[i] >= h)
+        for (int i = 0;i < citations.size();i++) {
+            if (citations[i] >= h)
                 break;
             h--;
         }
-
         return h;
     }
-};+};


Better error reporting.

Better error reporting.

--- cpp/lib/src/FileUtil.cc
+++ cpp/lib/src/FileUtil.cc
@@ -45,7 +45,8 @@
     char * const path_template(strdupa((path_prefix + "XXXXXX").c_str()));
     const int fd(::mkstemp(path_template));
     if (fd == -1)
-        throw std::runtime_error("in AutoTempFile::AutoTempFile: mkstemp(3) failed!");
+        throw std::runtime_error("in AutoTempFile::AutoTempFile: mkstemp(3) fore path prefix \"" + path_prefix
+                                 + "\" failed! (" + std::string(::strerror(errno)) + ")");
     ::close(fd);
     path_ = path_template;
 }


Better error reporting.

Better error reporting.

--- cpp/lib/src/MarcUtil.cc
+++ cpp/lib/src/MarcUtil.cc
@@ -288,8 +288,8 @@

 bool Record::insertField(const std::string &new_field_tag, const std::string &new_field_value) {
     if (new_field_tag.length() != DirectoryEntry::TAG_LENGTH)
-        throw std::runtime_error("in MarcUtil::Record::insertField: \"new_field_tag\" must have a length of "
-                                 + std::to_string(DirectoryEntry::TAG_LENGTH) + "!");
+        throw std::runtime_error("in MarcUtil::Record::insertField: new field tag \"" + new_field_tag
+                                 + "\" must have a length of " + std::to_string(DirectoryEntry::TAG_LENGTH) + "!");

     if (not record_will_be_written_as_xml_) {
        if (not leader_.setRecordLength(leader_.getRecordLength() + new_field_value.length()


Update TextUtil.cc

Update TextUtil.cc

--- cpp/lib/src/TextUtil.cc
+++ cpp/lib/src/TextUtil.cc
@@ -174,7 +174,7 @@
     const std::string word_wrap("¬");
     bool concat_without_whitespace(false);

-    while(parser->skipTo(SimpleXmlParser<StringDataSource>::Type::OPENING_TAG, "span")) {
+    while (parser->skipTo(SimpleXmlParser<StringDataSource>::Type::OPENING_TAG, "span")) {
         SimpleXmlParser<StringDataSource>::Type type;
         std::map<std::string, std::string> attrib_map;
         std::string data;


cpp/restinio: add client post feature

cpp/restinio: add client post feature

--- cpp/restinio/client.cpp
+++ cpp/restinio/client.cpp
@@ -54,14 +54,14 @@

 std::string create_http_request(const restinio::http_request_header_t header,
                                 const restinio::http_header_fields_t header_fields,
-                                const restinio::http_connection_header_t connection)
+                                const restinio::http_connection_header_t connection,
+                                const std::string body)
 {
     std::stringstream request;

     request << restinio::method_to_string(header.method()) << " " <<
                header.request_target() << " " <<
                "HTTP/" << header.http_major() << "." << header.http_minor() << "\r\n";
-
     for (auto header_field: header_fields)
         request << header_field.name() << ": " << header_field.value() << "\r\n";

@@ -78,24 +78,38 @@
             throw std::invalid_argument("upgrade");
             break;
     }
-    request << "Connection: " << conn_str << "\r\n\r\n";
+    request << "Connection: " << conn_str << "\r\n";
+    if (!body.empty()){
+        request << "Content-Length: " << body.size() << "\r\n\r\n";
+        request << body;
+    }
+    request << "\r\n\r\n";

     return request.str();
 }

 int main(const int argc, char* argv[])
 {
-    if (argc < 4){
-        std::cerr << "Insufficient arguments! Needs <addr> <port> <target>" << std::endl;
+    if (argc < 5){
+        std::cerr << "Insufficient arguments! Needs <method> <addr> <port> <target> <body_if_any>" << std::endl;
         return 1;
     }
-    const std::string addr = argv[1];
-    const in_port_t port = atoi(argv[2]);
-    const std::string target = argv[3];
+    const std::string method_str = argv[1];
+    const std::string addr = argv[2];
+    const in_port_t port = atoi(argv[3]);
+    const std::string target = argv[4];
+    const std::string body = argv[5] ? argv[5] : "";

     restinio::http_request_header_t header;
     header.request_target(target);
-    header.method(restinio::http_method_t::http_get);
+    restinio::http_method_t method;
+    if (method_str == "get")
+        method = restinio::http_method_t::http_get;
+    else if (method_str == "post")
+        method = restinio::http_method_t::http_post;
+    else
+        throw std::invalid_argument(method_str);
+    header.method(method);

     restinio::http_header_fields_t header_fields;
     header_fields.append_field(restinio::http_field_t::host,
@@ -103,11 +117,11 @@
     header_fields.append_field(restinio::http_field_t::user_agent, "RESTinio client");
     header_fields.append_field(restinio::http_field_t::accept, "*/*");

+    // build request
     auto connection = restinio::http_connection_header_t::keep_alive;
-
-    // build request
-    auto request = create_http_request(header, header_fields, connection);
+    auto request = create_http_request(header, header_fields, connection, body);
     printf(request.c_str());
+    return 1;

     // setup http_parser & callbacks
     http_parser_settings settings; // = restinio::impl::create_parser_settings();


added doxygen comments to cppa::opencl::program

--- cppa/opencl/program.hpp
+++ cppa/opencl/program.hpp
@@ -42,6 +42,9 @@
 template<typename Signature>
 class actor_facade;

+/**
+ * @brief A wrapper for OpenCL's cl_program.
+ */
 class program {

     template<typename Signature>
@@ -49,11 +52,15 @@

  public:

+    /**
+     * @brief Factory method, that creates a cppa::opencl::program
+     *        from a given @p kernel_source.
+     * @returns A program object.
+     */
     static program create(const char* kernel_source);

  private:

-    //program();
     program(context_ptr context, program_ptr program);

     context_ptr m_context;


cql3: expr: Use column_maybe_subscripted in equal()

equal() used to take column_value which could be subscripted as an argument.
column_value.sub will be removed so this function needs to take column_maybe_subscripted now.

To get lhs value the code uses get_value() which is ready to handle subscripted columns.

Signed-off-by: Jan Ciolek <b66a6f3989e26cb552db14b7ab163c3a50292e24@scylladb.com>

--- cql3/expr/expression.cc
+++ cql3/expr/expression.cc
@@ -238,7 +238,7 @@
 }

 /// True iff lhs's value equals rhs.
-bool equal(const managed_bytes_opt& rhs, const column_value& lhs, const column_value_eval_bag& bag) {
+bool equal(const managed_bytes_opt& rhs, const column_maybe_subscripted& lhs, const column_value_eval_bag& bag) {
     if (!rhs) {
         return false;
     }
@@ -250,7 +250,7 @@
 }

 /// Convenience overload for expression.
-bool equal(const expression& rhs, const column_value& lhs, const column_value_eval_bag& bag) {
+bool equal(const expression& rhs, const column_maybe_subscripted& lhs, const column_value_eval_bag& bag) {
     return equal(evaluate(rhs, bag.options).value.to_managed_bytes_opt(), lhs, bag);
 }

@@ -266,8 +266,8 @@
                 format("tuple equality size mismatch: {} elements on left-hand side, {} on right",
                        columns_tuple.elements.size(), rhs.size()));
     }
-    auto as_column_value = [] (const expression& e) { return expr::as<column_value>(e); };
-    return boost::equal(rhs, columns_tuple.elements | boost::adaptors::transformed(as_column_value), [&] (const managed_bytes_opt& b, const column_value& lhs) {
+    return boost::equal(rhs, columns_tuple.elements | boost::adaptors::transformed(as_column_maybe_subscripted),
+    [&] (const managed_bytes_opt& b, const column_maybe_subscripted& lhs) {
         return equal(b, lhs, bag);
     });
 }
@@ -488,7 +488,7 @@
         throw std::logic_error("unexpected expression type in is_one_of(single column)");
     }
     return boost::algorithm::any_of(get_list_elements(in_list), [&] (const managed_bytes_opt& b) {
-        return equal(b, col, bag);
+        return equal(b, as_column_maybe_subscripted(col), bag);
     });
 }

@@ -500,7 +500,7 @@
     }
     return boost::algorithm::any_of(get_list_of_tuples_elements(in_list), [&] (const std::vector<managed_bytes_opt>& el) {
         return boost::equal(tuple.elements, el, [&] (const expression& c, const managed_bytes_opt& b) {
-            return equal(b, expr::as<column_value>(c), bag);
+            return equal(b, as_column_maybe_subscripted(c), bag);
         });
     });
 }
@@ -540,9 +540,9 @@
     return expr::visit(overloaded_functor{
             [&] (const column_value& col) {
                 if (opr.op == oper_t::EQ) {
-                    return equal(opr.rhs, col, bag);
+                    return equal(opr.rhs, &col, bag);
                 } else if (opr.op == oper_t::NEQ) {
-                    return !equal(opr.rhs, col, bag);
+                    return !equal(opr.rhs, &col, bag);
                 } else if (is_slice(opr.op)) {
                     return limits(col, opr.op, opr.rhs, bag);
                 } else if (opr.op == oper_t::CONTAINS) {


ENH: Fixed minor issue (initialization of quantiles value when clearing controller widget).

--- Code/Common/Gui/mvdColorDynamicsController.cxx
+++ Code/Common/Gui/mvdColorDynamicsController.cxx
@@ -262,7 +262,7 @@
     colorBandDynWgt->SetHighIntensity( 1.0 );

     colorBandDynWgt->SetLowQuantile( 2.0 );
-    colorBandDynWgt->SetLowQuantile( 2.0 );
+    colorBandDynWgt->SetHighQuantile( 2.0 );
     }
     colorBandDynWgt->blockSignals( widgetSignalsBlocked );
     }


Fix case

Fix case

--- Core/Sources/Implementations/genotype/gene.cpp
+++ Core/Sources/Implementations/genotype/gene.cpp
@@ -3,7 +3,7 @@
 #include <stdexcept>

 #include "../../Headers/genotype/gene.hpp"
-#include "../../Headers/Utility/jsmn.h"
+#include "../../Headers/utility/jsmn.h"
 #include "../../Headers/type.hpp"
 #include "../../Headers/training/parameters.hpp"
 #include "../../Headers/utility/random.hpp"


Fix typo which lead failure of reverting composited state of various widgets on theme switch from oxygen-gtk to any other

--- src/animations/oxygeninnershadowdata.cpp
+++ src/animations/oxygeninnershadowdata.cpp
@@ -164,7 +164,7 @@

         // remove compositing flag
         GdkWindow* window( gtk_widget_get_window( widget ) );
-        if( GTK_IS_WINDOW( window ) && G_OBJECT_TYPE_NAME( widget ) != std::string("GtkPizza") )
+        if( GDK_IS_WINDOW( window ) && G_OBJECT_TYPE_NAME( widget ) != std::string("GtkPizza") )
         { gdk_window_set_composited(window,initiallyComposited); }
     }


Fix parsing album art from FLAC files.

Fix parsing album art from FLAC files.

--- src/plugins/taglib_plugin/TaglibMetadataReader.cpp
+++ src/plugins/taglib_plugin/TaglibMetadataReader.cpp
@@ -269,7 +269,7 @@
     std::string path(uri);
     std::string extension;

-    std::string::size_type lastDot = path.find_last_of(".");
+    const std::string::size_type lastDot = path.find_last_of(".");
     if (lastDot != std::string::npos) {
         extension = path.substr(lastDot + 1).c_str();
     }
@@ -332,7 +332,7 @@

             /* aif files are similar to wav files, but for some reason taglib
             doesn't seem to expose non-id3v2 tags */
-            auto aifFile = dynamic_cast<TagLib::RIFF::AIFF::File*>(file.file());
+            const auto aifFile = dynamic_cast<TagLib::RIFF::AIFF::File*>(file.file());
             if (aifFile) {
                 if (aifFile->hasID3v2Tag()) {
                     this->ReadID3V2(aifFile->tag(), target);
@@ -341,7 +341,7 @@

             /* taglib hides certain properties (like album artist) in the XiphComment's
             field list. if we're dealing with a straight-up Xiph tag, process it now */
-            auto xiphTag = dynamic_cast<TagLib::Ogg::XiphComment*>(tag);
+            const auto xiphTag = dynamic_cast<TagLib::Ogg::XiphComment*>(tag);
             if (xiphTag) {
                 this->ReadFromMap(xiphTag->fieldListMap(), target);
                 this->ExtractReplayGain(xiphTag->fieldListMap(), target);
@@ -355,6 +355,18 @@
                 /* flac files may have more than one type of tag embedded. see if there's
                 see if there's a xiph comment burried deep. */
                 auto flacFile = dynamic_cast<TagLib::FLAC::File*>(file.file());
+                if (flacFile) {
+                    auto pictures = flacFile->pictureList();
+                    for (auto picture : pictures) {
+                        if (picture->type() == TagLib::FLAC::Picture::FrontCover) {
+                            auto byteVector = picture->data();
+                            if (byteVector.size()) {
+                                target->SetThumbnail(byteVector.data(), byteVector.size());
+                            }
+                            break;
+                        }
+                    }
+                }
                 if (flacFile && flacFile->hasXiphComment()) {
                     this->ReadFromMap(flacFile->xiphComment()->fieldListMap(), target);
                     this->ExtractReplayGain(flacFile->xiphComment()->fieldListMap(), target);
@@ -365,7 +377,7 @@
                 NOT exposed a map with normalized keys, so we have to do special property
                 handling here... */
                 if (!handled) {
-                    auto mp4File = dynamic_cast<TagLib::MP4::File*>(file.file());
+                    const auto mp4File = dynamic_cast<TagLib::MP4::File*>(file.file());
                     if (mp4File && mp4File->hasMP4Tag()) {
                         auto mp4TagMap = static_cast<TagLib::MP4::Tag*>(tag)->itemListMap();
                         this->ExtractValueForKey(mp4TagMap, "aART", "album_artist", target);
@@ -376,7 +388,7 @@
                 }

                 if (!handled) {
-                    auto wvFile = dynamic_cast<TagLib::WavPack::File*>(file.file());
+                    const auto wvFile = dynamic_cast<TagLib::WavPack::File*>(file.file());
                     if (wvFile && wvFile->hasAPETag()) {
                         this->ReadFromMap(wvFile->properties(), target);
                         this->ExtractReplayGain(wvFile->properties(), target);
@@ -728,7 +740,7 @@
                     /* there can be multiple pictures, apparently. let's just use
                     the first one. */

-                    TagLib::ID3v2::AttachedPictureFrame *picture =
+                    const TagLib::ID3v2::AttachedPictureFrame *picture =
                         static_cast<TagLib::ID3v2::AttachedPictureFrame*>(pictures.front());

                     TagLib::ByteVector pictureData = picture->picture();
@@ -823,8 +835,8 @@
 {
     if (audioProperties) {
         std::string duration = std::to_string(audioProperties->length());
-        int bitrate = audioProperties->bitrate();
-        int channels = audioProperties->channels();
+        const int bitrate = audioProperties->bitrate();
+        const int channels = audioProperties->channels();

         this->SetTagValue("duration", duration, track);


Enhancement #48: routine name in Instruction

--- src/bindings/python/processingPyConf.cpp
+++ src/bindings/python/processingPyConf.cpp
@@ -109,11 +109,12 @@
     /* Create the class dictionary */
     PyObject *dictInstClass = xPyDict_New();
     PyDict_SetItemString(dictInstClass, "address", PyInt_FromLong(inst->getAddress()));
-    PyDict_SetItemString(dictInstClass, "threadId", PyInt_FromLong(inst->getThreadID()));
+    PyDict_SetItemString(dictInstClass, "assembly", PyString_FromFormat("%s", inst->getDisassembly().c_str()));
+    PyDict_SetItemString(dictInstClass, "isBranch", PyBool_FromLong(inst->isBranch()));
     PyDict_SetItemString(dictInstClass, "opcode", PyInt_FromLong(inst->getOpcode()));
     PyDict_SetItemString(dictInstClass, "opcodeCategory", PyInt_FromLong(inst->getOpcodeCategory()));
-    PyDict_SetItemString(dictInstClass, "assembly", PyString_FromFormat("%s", inst->getDisassembly().c_str()));
-    PyDict_SetItemString(dictInstClass, "isBranch", PyBool_FromLong(inst->isBranch()));
+    PyDict_SetItemString(dictInstClass, "routineName", PyString_FromFormat("%s", RTN_FindNameByAddress(inst->getAddress()).c_str()));
+    PyDict_SetItemString(dictInstClass, "threadId", PyInt_FromLong(inst->getThreadID()));

     /* Setup the symbolic element list */
     PyObject *SEList                         = xPyList_New(inst->numberOfElements());
@@ -178,11 +179,12 @@
     /* Create the class dictionary */
     PyObject *dictInstClass = xPyDict_New();
     PyDict_SetItemString(dictInstClass, "address", PyInt_FromLong(irb->getAddress()));
-    PyDict_SetItemString(dictInstClass, "threadId", PyInt_FromLong(ap->getThreadID()));
+    PyDict_SetItemString(dictInstClass, "assembly", PyString_FromFormat("%s", irb->getDisassembly().c_str()));
+    PyDict_SetItemString(dictInstClass, "isBranch", PyBool_FromLong(irb->isBranch()));
     PyDict_SetItemString(dictInstClass, "opcode", PyInt_FromLong(irb->getOpcode()));
     PyDict_SetItemString(dictInstClass, "opcodeCategory", PyInt_FromLong(irb->getOpcodeCategory()));
-    PyDict_SetItemString(dictInstClass, "assembly", PyString_FromFormat("%s", irb->getDisassembly().c_str()));
-    PyDict_SetItemString(dictInstClass, "isBranch", PyBool_FromLong(irb->isBranch()));
+    PyDict_SetItemString(dictInstClass, "routineName", PyString_FromFormat("%s", RTN_FindNameByAddress(irb->getAddress()).c_str()));
+    PyDict_SetItemString(dictInstClass, "threadId", PyInt_FromLong(ap->getThreadID()));

     /* Before the processing, the symbolic element list is empty */
     PyObject *SEList = xPyList_New(0);


initial test of box based hit volume for normal shots. TODO: playtest and then commonize with other shots in the base class.

--- src/clientbase/SegmentedShotStrategy.cxx
+++ src/clientbase/SegmentedShotStrategy.cxx
@@ -276,9 +276,8 @@
 {
   float minTime = Infinity;
   // expired shot can't hit anything
-  if (getPath().isExpired()) {
+  if (getPath().isExpired())
     return minTime;
-  }

   // get tank radius
   const float radius2 = tank.radius * tank.radius;
@@ -291,23 +290,22 @@
   Ray tankLastMotion(lastTankPositionRaw, tank.motion.getDirection());

   // if bounding box of tank and entire shot doesn't overlap then no hit
+
+  // should this be a box that is actually enclosing the entire hit volume?
   const Extents& tankBBox = tank.bbox;
-  if (!bbox.touches(tankBBox)) {
+  if (!bbox.touches(tankBBox))
     return minTime;
-  }

   static BZDB_float shotRadius(BZDBNAMES.SHOTRADIUS);

   // check each segment in interval (prevTime,currentTime]
   const float dt = float(currentTime - prevTime);
   const int numSegments = (const int)segments.size();
-  for (int i = lastSegment; i <= segment && i < numSegments; i++) {
+  for (int i = lastSegment; i <= segment && i < numSegments; i++)
+  {
     // can never hit your own first laser segment
-    if ((i == 0) && tank.testLastSegment &&
-        (getPath().getShotType() == LaserShot)) {
+    if ((i == 0) && tank.testLastSegment && (getPath().getShotType() == LaserShot))
       continue;
-    }
-
 /*
     // skip segments that don't overlap in time with current interval
     if (segments[i].end <= prevTime) continue;
@@ -317,9 +315,8 @@
     // if shot segment and tank bboxes don't overlap then no hit,
     // or if it's a shot that is out of the world boundary
     const ShotPathSegment& s = segments[i];
-    if (!s.bbox.touches(tankBBox) || (s.reason == ShotPathSegment::Boundary)) {
+    if (!s.bbox.touches(tankBBox) || (s.reason == ShotPathSegment::Boundary))
       continue;
-    }

     // construct relative shot ray:  origin and velocity relative to
     // my tank as a function of time (t=0 is start of the interval).
@@ -327,28 +324,41 @@

     // get hit time
     float t;
-    if (tank.test2D) {
+	if (tank.test2D) // for now just test as a box, the box -> sphere test does not use the same volume and may cause more problems then it tries to solve by being fast
+	{
       // find closest approach to narrow box around tank.  width of box
       // is shell radius so you can actually hit narrow tank head on.
       static fvec3 tankBase(0.0f, 0.0f, -0.5f * tankHeight);
       t = Intersect::timeRayHitsBlock(relativeRay, tankBase, tank.angle,
 			0.5f * tank.length, shotRadius, tankHeight);
-    } else {
-      // find time when shot hits sphere around tank
-      t = Intersect::rayAtDistanceFromOrigin(relativeRay, 0.99f * tank.radius);
-    }
+    }
+	else// find time when shot hits sphere around tank
+	{
+		// old sphere code, has problems when the hit is inside the smaller "prehit" box
+ //     t = Intersect::rayAtDistanceFromOrigin(relativeRay, 0.99f * tank.radius);
+
+		// find closest approach to wide box around tank.  width of box
+		// is tank radius so you get a little fudge factor on the side
+		static fvec3 tankBase(0.0f, 0.0f, -0.5f * tankHeight);
+		t = Intersect::timeRayHitsBlock(relativeRay, tankBase, tank.angle,
+			0.5f * tank.length, tank.radius, tankHeight);
+	}

     // short circuit if time is greater then smallest time so far
-    if (t > minTime) continue;
+    if (t > minTime)
+		continue;

     // make sure time falls within segment
-    if ((t < 0.0f) || (t > dt)) continue;
-    if (t > (s.end - prevTime)) continue;
+    if ((t < 0.0f) || (t > dt))
+		continue;
+    if (t > (s.end - prevTime))
+		continue;

     // check if shot hits tank -- get position at time t, see if in radius
     fvec3 closestPos;
     relativeRay.getPoint(t, closestPos);
-    if (closestPos.lengthSq() < radius2) {
+    if (closestPos.lengthSq() < radius2)
+	{
       // save best time so far
       minTime = t;

@@ -357,7 +367,7 @@
       tank.motion.getPoint(t, tankPos);

       // compute position of intersection
-      position = tankPos + closestPos;
+      position = tankPos + closestPos + fvec3(0,0,0.5f * tankHeight);
       //printf("%u:%u %u:%u\n", tank->getId().port, tank->getId().number, getPath().getPlayer().port, getPath().getPlayer().number);
     }
   }


earthWatcher: break after parsing 's' option.

--- src/clients/earthWatcher/earthWatcher.cc
+++ src/clients/earthWatcher/earthWatcher.cc
@@ -161,6 +161,7 @@
             case 's':
                 serverName = optarg;
                 args |= argServerName;
+                break;

             case 'h':
             default:


Updated default value of velocity parameters

--- ble-cpp/src/model/SystemModelInBuilding.hpp
+++ ble-cpp/src/model/SystemModelInBuilding.hpp
@@ -31,9 +31,9 @@
 namespace loc{

     class SystemModelInBuildingProperty{
-        double probabilityUp_ = 0.25;
-        double probabilityDown_ = 0.25;
-        double probabilityStay_ = 0.5;
+        double probabilityUp_ = 0.1;
+        double probabilityDown_ = 0.1;
+        double probabilityStay_ = 0.8;

         double probabilityFloorJump_ = 0.0;


Added Hex to GetTimeStep

Added Hex to GetTimeStep

--- solvers/CompressibleFlowSolver/EquationSystems/CompressibleFlowSystem.cpp
+++ solvers/CompressibleFlowSolver/EquationSystems/CompressibleFlowSystem.cpp
@@ -36,6 +36,7 @@
 #include <CompressibleFlowSolver/EquationSystems/CompressibleFlowSystem.h>
 #include <LocalRegions/TriExp.h>
 #include <LocalRegions/QuadExp.h>
+#include <LocalRegions/HexExp.h>
 #include <MultiRegions/ExpList.h>
 #include <MultiRegions/AssemblyMap/AssemblyMapDG.h>
 #include <solvers/ADRSolver/EquationSystems/UnsteadyDiffusion.cpp>
@@ -948,6 +949,12 @@
             {
                 minLength = sqrt(Area);
             }
+            else if (boost::dynamic_pointer_cast<LocalRegions::HexExp>(
+                         m_fields[0]->GetExp(n)))
+            {
+                minLength = sqrt(Area);
+            }
+

             tstep[n] = m_cflSafetyFactor * alpha * minLength
                      / (stdVelocity[n] * cLambda