builder: reset the combo box title after adding a widget

--- tools/mx-builder.c
+++ tools/mx-builder.c
@@ -437,15 +437,16 @@
 }

 static void
-mx_builder_add_widget (MxBuilder *builder,
-                       MxButton  *button)
+mx_builder_add_widget (MxBuilder  *builder,
+                       GParamSpec *notify_pspec,
+                       MxComboBox *combo)
 {
   const gchar *typename;
   guint id;
   ClutterActor *new_widget;
   GParamSpec *pspec;

-  typename = mx_combo_box_get_active_text (MX_COMBO_BOX (builder->combobox));
+  typename = mx_combo_box_get_active_text (combo);

   /* skip separators */
   if (typename[0] == ' ')
@@ -475,6 +476,11 @@
     g_object_set (new_widget, "text", &typename[2], NULL);

   mx_builder_set_selected_widget (builder, new_widget);
+
+  /* Reset combo box title */
+  g_signal_handlers_block_by_func (combo, mx_builder_add_widget, builder);
+  mx_combo_box_set_active_text (combo, "Add");
+  g_signal_handlers_unblock_by_func (combo, mx_builder_add_widget, builder);
 }

 static void


Replace the read back of the software interrupt register with barrier instructions (CCS/RM48/TMS570).

--- FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h
+++ FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h
@@ -56,19 +56,19 @@
     ***************************************************************************

-    http://www.FreeRTOS.org - Documentation, books, training, latest versions,
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,
     license and Real Time Engineers Ltd. contact details.

     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
     including FreeRTOS+Trace - an indispensable productivity tool, and our new
     fully thread aware and reentrant UDP/IP stack.

-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
-    Integrity Systems, who sell the code with commercial support,
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
+    Integrity Systems, who sell the code with commercial support,
     indemnification and middleware, under the OpenRTOS brand.
-
-    http://www.SafeRTOS.com - High Integrity Systems also provide a safety
-    engineered and independently SIL3 certified version for use in safety and
+
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety
+    engineered and independently SIL3 certified version for use in safety and
     mission critical applications that require provable dependability.
 */

@@ -105,7 +105,7 @@

 /* Architecture specifics. */
 #define portSTACK_GROWTH    (-1)
-#define portTICK_RATE_MS    ((portTickType) 1000 / configTICK_RATE_HZ)
+#define portTICK_RATE_MS    ((portTickType) 1000 / configTICK_RATE_HZ)
 #define portBYTE_ALIGNMENT  8

 /* Critical section handling. */
@@ -122,7 +122,7 @@
 #define portYIELD()             	vPortYield()
 #define portSYS_SSIR1_REG			( * ( ( volatile unsigned long * ) 0xFFFFFFB0 ) )
 #define portSYS_SSIR1_SSKEY			( 0x7500UL )
-#define portYIELD_WITHIN_API()		{ portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  ( void ) portSYS_SSIR1_REG; }
+#define portYIELD_WITHIN_API()		{ portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  asm( " DSB " ); asm( " ISB " ); }
 #define portYIELD_FROM_ISR( x )		if( x != pdFALSE ){ portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  ( void ) portSYS_SSIR1_REG; }

 /* Architecture specific optimisations. */


Fixed #789 Fix utest/ctest.h on Mingw.

Fixed #789 Fix utest/ctest.h on Mingw.

--- utest/ctest.h
+++ utest/ctest.h
@@ -56,6 +56,10 @@

 #ifdef __APPLE__
 #define __CTEST_APPLE
+#endif
+
+#ifdef __MINGW32__
+#undef CTEST_SEGFAULT
 #endif

 #if defined(_WIN32) && defined(_MSC_VER)


MAINT: clean up convolution.template.c for comments and line length.

--- src/convolution.template.c
+++ src/convolution.template.c
@@ -1,5 +1,5 @@
-// Copyright (c) 2006-2012 Filip Wasilewski <http://en.ig.ma/>
-// See COPYING for license details.
+/* Copyright (c) 2006-2012 Filip Wasilewski <http://en.ig.ma/> */
+/* See COPYING for license details. */

 #include "convolution.h"

@@ -16,52 +16,50 @@
     $DTYPE$ sum;
     $DTYPE$* ptr_w = output;

-    i = step-1; // first element taken from input is input[step-1]
-    //extending by (F-2)/2 elements
-    start = F_2 = F/2;
+    i = step-1;  /* first element taken from input is input[step-1] */
+    start = F_2 = F/2;  /* extending by (F-2)/2 elements */
     corr = 0;

     for(i=start; i < F; i+=step){
         sum = 0;
-        for(j = 0; j < i+1-corr; ++j)    // overlapping
+        for(j = 0; j < i+1-corr; ++j)    /* overlapping */
             sum += filter[j]*input[i-j-corr];

         if(N%2){
-            if(F-j){ // if something to extend
+            if(F-j){ /* if something to extend */
                 sum += filter[j] * input[N-1];
                 if(F-j){
                     for(k = 2-corr; k <= F-j; ++k)
                         sum += filter[j-1+k] * input[N-k+1];
                 }
             }
-        } else { // extra element from input   -> i0 i1 i2 [i2]
+        } else { /* extra element from input   -> i0 i1 i2 [i2] */
             for(k = 1; k <= F-j; ++k)
                 sum += filter[j-1+k] * input[N-k];
         }
         *(ptr_w++) = sum;
     }

-    // F - N-1        - filter in input range
-    // most time is spent in this loop
-    for(; i < N; i+=step){                    // input elements,
+    /* F - N-1 : filter in input range.  Most time is spent in this loop */
+    for(; i < N; i+=step){    /* input elements, */
         sum = 0;
         for(j = 0; j < F; ++j)
             sum += input[i-j]*filter[j];
         *(ptr_w++) = sum;
     }

-    for(; i < N-step + (F/2)+1 + N%2; i += step){    // input elements
+    for(; i < N-step + (F/2)+1 + N%2; i += step){   /* input elements */
         sum = 0;
         k = i-N+1;
-        for(j = k; j < F; ++j)                // overlapped elements
+        for(j = k; j < F; ++j)   /* overlapped elements */
             sum += filter[j]*input[i-j];

         if(N%2 == 0){
-            for(j = 0; j < k; ++j){            // out of boundary (filter elements [0, k-1])
+            for(j = 0; j < k; ++j){  /* out of boundary (filter elements [0, k-1]) */
                 sum += filter[j]*input[k-1-j];
             }
-        } else {                            // repeating extra element -> i0 i1 i2 [i2]
-            for(j = 0; j < k-1; ++j)        // out of boundary (filter elements [0, k-1])
+        } else {  /* repeating extra element -> i0 i1 i2 [i2] */
+            for(j = 0; j < k-1; ++j)  /* out of boundary (filter elements [0, k-1]) */
                 sum += filter[j]*input[k-2-j];
             sum += filter[k-1] * input[N-1];
         }
@@ -76,20 +74,21 @@
                              $DTYPE$* output,
                              const_index_t step, MODE mode)
 {
-
-    // This convolution performs efficient downsampling by computing every step'th
-    // element of normal convolution (currently tested only for step=1 and step=2).
-    //
-    // It also implements several different strategies of dealing with border
-    // distortion problem (the problem of computing convolution for not existing
-    // elements of signal). To handle this the signal has to be "extended" on both
-    // sides by computing the missing values.
-    //
-    // General schema is as follows:
-    // 1. Handle extended on the left, convolve filter with samples computed for time < 0
-    // 2. Do the normal decimated convolution of filter with signal samples
-    // 3. Handle extended on the right, convolve filter with samples computed for time > n-1
-
+    /*
+     * This convolution performs efficient downsampling by computing every
+     * step'th element of normal convolution (currently tested only for step=1
+     * and step=2).
+     *
+     * It also implements several different strategies of dealing with border
+     * distortion problem (the problem of computing convolution for not
+     * existing elements of signal). To handle this the signal has to be
+     * "extended" on both sides by computing the missing values.
+     *
+     * General schema is as follows: 1. Handle extended on the left, convolve
+     * filter with samples computed for time < 0 2. Do the normal decimated
+     * convolution of filter with signal samples 3. Handle extended on the
+     * right, convolve filter with samples computed for time > n-1
+     */

     index_t i, j, k;
     index_t start;
@@ -106,18 +105,17 @@

     $DTYPE$* ptr_w = output;

-    i = start = step-1; // first element taken from input is input[step-1]
+    i = start = step-1; /* first element taken from input is input[step-1] */

     if(F <= N){

         if(mode == MODE_PERIODIZATION){
             return $DTYPE$_downsampling_convolution_periodization(input, N, filter, F, output, step);

-        // Other signal extension modes
+        /* Other signal extension modes */
         } else {

-            ///////////////////////////////////////////////////////////////////////
-            // 0 - F-1    - sliding in filter
+            /* 0 - F-1 : sliding in filter */
             switch(mode)
             {
                 case MODE_SYMMETRIC:
@@ -139,7 +137,7 @@
                             sum += filter[j]*input[i-j];
                         k = i+1;
                         for(j = i+1; j < F; ++j)
-                            sum += filter[j] * (input[0] - input[j-k]); // -=
+                            sum += filter[j] * (input[0] - input[j-k]);
                         *(ptr_w++) = sum;
                     }
                     break;
@@ -196,16 +194,14 @@
                     break;
             }

-            ///////////////////////////////////////////////////////////////////////
-            // F - N-1        - filter in input range - simple convolution
-            // most time is spent in this loop
-            //printf("entering loop\n");
+            /*
+             * F - N-1 : filter in input range - simple convolution
+             * Most time is spent in this loop.
+             */
             #ifdef OPT_UNROLL4
-            // manually unroll the loop a bit
-            //printf("F: %d, N: %d, i: %d\n", F, N, i);
+            /* manually unroll the loop a bit */
             if((N - F)/step > 4) {
-                for(; i < (N - (3*step)); i += 4*step){                    // input elements,
-                    //printf("EO4 iter: %d\n", i);
+                for(; i < (N - (3*step)); i += 4*step){  /* input elements */
                     sum  = input[i]          * filter[0];
                     sum2 = input[i+step]     * filter[0];
                     sum3 = input[i+(2*step)] * filter[0];
@@ -226,8 +222,7 @@

             #ifdef OPT_UNROLL2
             if((N - F)/step > 2) {
-                for(; i < (N - step); i += 2*step){                    // input elements,
-                    //printf("EO2 iter: %d\n", i);
+                for(; i < (N - step); i += 2*step){  /* input elements, */
                     sum  = input[i]   * filter[0];
                     sum2 = input[i+step] * filter[0];
                     for(j = 1; j < F; ++j){
@@ -240,80 +235,80 @@
             }
             #endif

-            for(; i < N; i+=step){                    // input elements,
+            for(; i < N; i+=step){  /* input elements, */
                 sum = input[i] * filter[0];
                 for(j = 1; j < F; ++j){
-                    //printf("EO1 iter: %d\n", i);
                     sum += input[i-j]*filter[j];
                 }
                 *(ptr_w++) = sum;
             }
-            ///////////////////////////////////////////////////////////////////////
-            // N - N+F-1    - sliding out filter
+
+            /* N - N+F-1 : sliding out filter */
             switch(mode)
             {
                 case MODE_SYMMETRIC:
-                    for(; i < N+F-1; i += step){    // input elements
-                        sum = 0;
-                        k = i-N+1;                    // 1, 2, 3 // overlapped elements
-                        for(j = k; j < F; ++j)                    //TODO: j < F-_offset
-                            sum += filter[j]*input[i-j];
-
-                        for(j = 0; j < k; ++j)        // out of boundary        //TODO: j = _offset
-                            sum += filter[j]*input[N-k+j]; // j-i-1            0*(N-1), 0*(N-2) 1*(N-1)
+                    for(; i < N+F-1; i += step){  /* input elements */
+                        sum = 0;
+                        k = i-N+1;   /* 1, 2, 3 : overlapped elements */
+                        for(j = k; j < F; ++j)   /*TODO: j < F-_offset */
+                            sum += filter[j]*input[i-j];
+
+                        for(j = 0; j < k; ++j)  /* out of boundary (TODO: j = _offset) */
+                            /* j-i-1      0*(N-1), 0*(N-2) 1*(N-1) */
+                            sum += filter[j]*input[N-k+j];

                         *(ptr_w++) = sum;
                     }
                     break;

                 case MODE_ASYMMETRIC:
-                    for(; i < N+F-1; i += step){    // input elements
+                    for(; i < N+F-1; i += step){  /* input elements */
                         sum = 0;
                         k = i-N+1;
-                        for(j = k; j < F; ++j)        // overlapped elements
-                            sum += filter[j]*input[i-j];
-
-                        for(j = 0; j < k; ++j)        // out of boundary
-                            sum += filter[j]*(input[N-1]-input[N-k-1+j]); // -=    j-i-1
+                        for(j = k; j < F; ++j)   /* overlapped elements */
+                            sum += filter[j]*input[i-j];
+
+                        for(j = 0; j < k; ++j)   /* out of boundary */
+                            sum += filter[j]*(input[N-1]-input[N-k-1+j]); /* -= j-i-1 */
                         *(ptr_w++) = sum;
                     }
                     break;

                 case MODE_CONSTANT_EDGE:
-                    for(; i < N+F-1; i += step){    // input elements
+                    for(; i < N+F-1; i += step){  /* input elements */
                         sum = 0;
                         k = i-N+1;
-                        for(j = k; j < F; ++j)        // overlapped elements
-                            sum += filter[j]*input[i-j];
-
-                        for(j = 0; j < k; ++j)        // out of boundary (filter elements [0, k-1])
-                            sum += filter[j]*input[N-1]; // input[N-1] = const
+                        for(j = k; j < F; ++j)   /* overlapped elements */
+                            sum += filter[j]*input[i-j];
+
+                        for(j = 0; j < k; ++j)  /* out of boundary (filter elements [0, k-1]) */
+                            sum += filter[j]*input[N-1]; /* input[N-1] = const */

                         *(ptr_w++) = sum;
                     }
                     break;

                 case MODE_SMOOTH:
-                    for(; i < N+F-1; i += step){    // input elements
-                        sum = 0;
-                        k = i-N+1; // 1, 2, 3, ...
-                        for(j = k; j < F; ++j)        // overlapped elements
+                    for(; i < N+F-1; i += step){  /* input elements */
+                        sum = 0;
+                        k = i-N+1;
+                        for(j = k; j < F; ++j)  /* overlapped elements */
                             sum += filter[j]*input[i-j];

                         tmp = input[N-1]-input[N-2];
-                        for(j = 0; j < k; ++j)        // out of boundary (filter elements [0, k-1])
+                        for(j = 0; j < k; ++j)  /* out of boundary (filter elements [0, k-1]) */
                             sum += filter[j] * (input[N-1] + tmp * (k-j));
                         *(ptr_w++) = sum;
                     }
                     break;

                 case MODE_PERIODIC:
-                    for(; i < N+F-1; i += step){    // input elements
+                    for(; i < N+F-1; i += step){  /* input elements */
                         sum = 0;
                         k = i-N+1;
-                        for(j = k; j < F; ++j)        // overlapped elements
-                            sum += filter[j]*input[i-j];
-                        for(j = 0; j < k; ++j)        // out of boundary (filter elements [0, k-1])
+                        for(j = k; j < F; ++j)   /* overlapped elements */
+                            sum += filter[j]*input[i-j];
+                        for(j = 0; j < k; ++j)  /* out of boundary (filter elements [0, k-1]) */
                             sum += filter[j]*input[k-1-j];
                         *(ptr_w++) = sum;
                     }
@@ -333,15 +328,15 @@
         return 0;

     } else {
-        // reallocating memory for short signals (shorter than filter) is cheap
-        return $DTYPE$_allocating_downsampling_convolution(input, N, filter, F, output, step, mode);
+        /* reallocating memory for short signals (shorter than filter) is cheap */
+        return $DTYPE$_allocating_downsampling_convolution(input, N, filter, F,
+                                                           output, step, mode);
     }
 }

-///////////////////////////////////////////////////////////////////////////////
-//
-// like downsampling_convolution, but with memory allocation
-//
+/*
+ * ### like downsampling_convolution, but with memory allocation ###
+ */

 int $DTYPE$_allocating_downsampling_convolution(const $DTYPE$* input, const_index_t N,
                                         const $DTYPE$* filter, const_index_t F,
@@ -357,7 +352,7 @@
     F_minus_1 = F - 1;
     start = F_minus_1+step-1;

-    // allocate memory and copy input
+    /* allocate memory and copy input */
     if(mode != MODE_PERIODIZATION){

         N_extended_len = N + 2*F_minus_1;
@@ -385,24 +380,24 @@

         if(step == 1)
             stop = N_extended_len-1;
-        else // step == 2
+        else /* step == 2 */
             stop = N_extended_len;
     }

-    // copy extended signal elements
+    /* copy extended signal elements */
     switch(mode){

         case MODE_PERIODIZATION:
-            if(N%2){ // odd - repeat last element
+            if(N%2){ /* odd - repeat last element */
                 buffer[N_extended_right_start] = input[N-1];
                 for(j = 1; j < F/2; ++j)
-                    buffer[N_extended_right_start+j] = buffer[F/2-2 + j]; // copy from beginning of `input` to right
-                for(j = 0; j < F/2-1; ++j)                                  // copy from 'buffer' to left
+                    buffer[N_extended_right_start+j] = buffer[F/2-2 + j]; /* copy from beginning of `input` to right */
+                for(j = 0; j < F/2-1; ++j)   /* copy from 'buffer' to left */
                     buffer[F/2-2-j] =  buffer[N_extended_right_start-j];
             } else {
                 for(j = 0; j < F/2; ++j)
-                    buffer[N_extended_right_start+j] = input[j%N]; // copy from beginning of `input` to right
-                for(j = 0; j < F/2-1; ++j)                           // copy from 'buffer' to left
+                    buffer[N_extended_right_start+j] = input[j%N]; /* copy from beginning of `input` to right */
+                for(j = 0; j < F/2-1; ++j)   /* copy from 'buffer' to left */
                     buffer[F/2-2-j] =  buffer[N_extended_right_start-1-j];
             }
             break;
@@ -413,7 +408,7 @@
                 buffer[N_extended_right_start+j] = input[N-1-(j%N)];
             }
             i=j;
-            // use `buffer` as source
+            /* use `buffer` as source */
             for(; j < F_minus_1; ++j){
                 buffer[F_minus_1-1-j] =  buffer[N_extended_right_start-1+i-j];
                 buffer[N_extended_right_start+j] = buffer[F_minus_1+j-i];
@@ -426,7 +421,7 @@
                 buffer[N_extended_right_start+j] = (input[N-1] - input[N-1-(j%N)]);
             }
             i=j;
-            // use `buffer` as source
+            /* use `buffer` as source */
             for(; j < F_minus_1; ++j){
                 buffer[F_minus_1-1-j] =  buffer[N_extended_right_start-1+i-j];
                 buffer[N_extended_right_start+j] = buffer[F_minus_1+j-i];
@@ -453,25 +448,22 @@

         case MODE_PERIODIC:
             for(j = 0; j < F_minus_1; ++j)
-                buffer[N_extended_right_start+j] = input[j%N]; // copy from beginning of `input` to right
-
-            for(j = 0; j < F_minus_1; ++j)                       // copy from 'buffer' to left
+                buffer[N_extended_right_start+j] = input[j%N]; /* copy from beginning of `input` to right */
+
+            for(j = 0; j < F_minus_1; ++j)   /* copy from 'buffer' to left */
                 buffer[F_minus_1-1-j] =  buffer[N_extended_right_start-1-j];
             break;

         case MODE_ZEROPAD:
         default:
-            //memset(buffer, 0, sizeof($DTYPE$)*F_minus_1);
-            //memset(buffer+N_extended_right_start, 0, sizeof($DTYPE$)*F_minus_1);
-            //memcpy(buffer+N_extended_right_start, buffer, sizeof($DTYPE$)*F_minus_1);
             break;
     }

-    ///////////////////////////////////////////////////////////////////////
-    // F - N-1        - filter in input range
-    // perform convolution with decimation
-    for(i=start; i < stop; i+=step){                    // input elements
+    /*
+     * F - N-1 : filter in input range, perform convolution with decimation
+     */
+    for(i=start; i < stop; i+=step){  /* input elements */
         sum = 0;
         for(j = 0; j < F; ++j){
             sum += buffer[i-j]*filter[j];
@@ -479,15 +471,15 @@
         *(ptr_w++) = sum;
     }

-    // free memory
+    /* free memory */
     wtfree(buffer);
     return 0;
 }

-///////////////////////////////////////////////////////////////////////////////
-// requires zero-filled output buffer
-// output is larger than input
-// performs "normal" convolution of "upsampled" input coeffs array with filter
+/*
+ * Requires zero-filled output buffer output is larger than input
+ * performs "normal" convolution of "upsampled" input coeffs array with filter
+ */

 int $DTYPE$_upsampling_convolution_full(const $DTYPE$* input, const_index_t N,
                                 const $DTYPE$* filter, const_index_t F,
@@ -502,31 +494,37 @@
     ptr_out = output + ((N-1) << 1);

     for(i = N-1; i >= 0; --i){
-        // sliding in filter from the right (end of input)
-        // i0 0  i1 0  i2 0
-        //                f1 -> o1
-        //             f1 f2 -> o2
-        //          f1 f2 f3 -> o3
+        /*
+         * sliding in filter from the right (end of input)
+         * i0 0  i1 0  i2 0
+         *                f1 -> o1
+         *             f1 f2 -> o2
+         *          f1 f2 f3 -> o3
+         */

         for(j = 0; j < F; ++j)
-            ptr_out[j] += input[i] * filter[j]; // input[i] - const in loop
+            ptr_out[j] += input[i] * filter[j]; /* input[i] - const in loop */
         ptr_out -= 2;
     }
     return 0;
 }

-///////////////////////////////////////////////////////////////////////////////
-// performs IDWT for PERIODIZATION mode only
-// (refactored from the upsampling_convolution_valid_sf function)
-//
-// The upsampling is performed by splitting filters to even and odd elements
-// and performing 2 convolutions
-//
-// The input data has to be periodically extended for this mode.
-
-int $DTYPE$_upsampling_convolution_valid_sf_periodization(const $DTYPE$* input, const_index_t N,
-                                    const $DTYPE$* filter, const_index_t F,
-                                    $DTYPE$* output, const_index_t O)
+/*
+ * performs IDWT for PERIODIZATION mode only
+ * (refactored from the upsampling_convolution_valid_sf function)
+ *
+ * The upsampling is performed by splitting filters to even and odd elements
+ * and performing 2 convolutions
+ *
+ * The input data has to be periodically extended for this mode.
+ */
+
+int $DTYPE$_upsampling_convolution_valid_sf_periodization(const $DTYPE$* input,
+                                                          const_index_t N,
+                                                          const $DTYPE$*
+                                                          filter, const_index_t
+                                                          F, $DTYPE$* output,
+                                                          const_index_t O)
 {

     $DTYPE$ *ptr_out = output;
@@ -538,88 +536,88 @@
     index_t i, j, k, N_p = 0;
     index_t F_2 = F/2;

-    if(F%2) return -3; // Filter must have even-length.
-
-    ///////////////////////////////////////////////////////////////////////////
-    // Handle special situation when input coeff data is shorter than half of
-    // the filter's length. The coeff array has to be extended periodically.
-    // This can be only valid for PERIODIZATION_MODE
-
+    if(F%2) return -3; /* Filter must have even-length. */
+
+    /*
+     * Handle special situation when input coeff data is shorter than half of
+     * the filter's length. The coeff array has to be extended periodically.
+     * This can be only valid for PERIODIZATION_MODE
+     */
     if(N < F_2)
-    // =======
     {
-        // Input data for periodization mode has to be periodically extended
-
-        // New length for temporary input
+        /* Input data for periodization mode has to be periodically extended */
+
+        /* New length for temporary input */
         N_p = F_2-1 +N;

-        // periodization_buf will hold periodically copied input coeffs values
+        /* periodization_buf will hold periodically copied input coeffs values */
         periodization_buf = wtcalloc(N_p, sizeof($DTYPE$));

         if(periodization_buf == NULL)
             return -1;

-        // Copy input data to its place in the periodization_buf
-        // -> [0 0 0 i1 i2 i3 0 0 0]
+        /* Copy input data to its place in the periodization_buf */
+        /* -> [0 0 0 i1 i2 i3 0 0 0] */
         k = (F_2-1)/2;
         for(i=k; i < k+N; ++i)
             periodization_buf[i] = input[(i-k)%N];

-        //if(N%2)
-        //    periodization_buf[i++] = input[N-1];
-
-        // [0 0 0 i1 i2 i3 0 0 0]
-        //  points here ^^
+        /* if(N%2)
+         *     periodization_buf[i++] = input[N-1];
+         *
+         * [0 0 0 i1 i2 i3 0 0 0]
+         *  points here ^^
+         */
         periodization_buf_rear = periodization_buf+i-1;

-        // copy cyclically () to right
-        // [0 0 0 i1 i2 i3 i1 i2 ...]
+        /* copy cyclically () to right   [0 0 0 i1 i2 i3 i1 i2 ...] */
         j = i-k;
         for(; i < N_p; ++i)
             periodization_buf[i] = periodization_buf[i-j];

-        // copy cyclically () to left
-        // [... i2 i3 i1 i2 i3 i1 i2 i3]
+        /* copy cyclically () to left    [... i2 i3 i1 i2 i3 i1 i2 i3] */
         j = 0;
         for(i=k-1; i >= 0; --i){
             periodization_buf[i] = periodization_buf_rear[j];
             --j;
         }

-        // Now perform the valid convolution
+        /* Now perform the valid convolution */
         if(F_2%2){
             $DTYPE$_upsampling_convolution_valid_sf(periodization_buf, N_p, filter, F, output, O, MODE_ZEROPAD);

-        // The F_2%2==0 case needs special result fix (oh my, another one..)
+        /* The F_2%2==0 case needs special result fix (oh my, another one..) */
         } else {

-            // Cheap result fix for short inputs
-            // Memory allocation for temporary output is done.
-            // Computed temporary result is copied to output*
-
-            ptr_out = wtcalloc(idwt_buffer_length(N, F, MODE_PERIODIZATION), sizeof($DTYPE$));
+            /*
+             * Cheap result fix for short inputs
+             * Memory allocation for temporary output is done.
+             * Computed temporary result is copied to output*
+             */
+            ptr_out = wtcalloc(idwt_buffer_length(N, F, MODE_PERIODIZATION),
+                                                  sizeof($DTYPE$));
             if(ptr_out == NULL){
                 wtfree(periodization_buf);
                 return -1;
             }

-            // Convolve here as for (F_2%2) branch above
+            /* Convolve here as for (F_2%2) branch above */
             $DTYPE$_upsampling_convolution_valid_sf(periodization_buf, N_p, filter, F, ptr_out, O, MODE_ZEROPAD);

-            // rewrite result to output
+            /* rewrite result to output */
             for(i=2*N-1; i > 0; --i){
                 output[i] += ptr_out[i-1];
             }
-            // and the first element
+            /* and the first element */
             output[0] += ptr_out[2*N-1];
             wtfree(ptr_out);
-            // and voil`a!, ugh
+            /* and voila!, ugh */
         }

     } else {
-    // Otherwise (N >= F_2)
-
-        // Allocate memory for even and odd elements of the filter
+    /* Otherwise (N >= F_2) */
+
+        /* Allocate memory for even and odd elements of the filter */
         filter_even = wtmalloc(F_2 * sizeof($DTYPE$));
         filter_odd = wtmalloc(F_2 * sizeof($DTYPE$));

@@ -629,37 +627,41 @@
             return -1;
         }

-        // split filter to even and odd values
+        /* split filter to even and odd values */
         for(i = 0; i < F_2; ++i){
             filter_even[i] = filter[i << 1];
             filter_odd[i] = filter[(i << 1) + 1];
         }

-        ///////////////////////////////////////////////////////////////////////////
-        // This part is quite complicated and has some wild checking to get results
-        // similar to those from Matlab(TM) Wavelet Toolbox
-
+        /*
+         * ############################################################
+         * This part is quite complicated and has some wild checking to
+         * get results similar to those from Matlab(TM) Wavelet Toolbox
+         */
         k = F_2-1;

-        // Check if extending is really needed
-        N_p = F_2-1 + (index_t) ceil(k/2.); /*split filter len correct. +  extra samples*/
-
-        // ok, if is then do:
-        // 1. Allocate buffers for front and rear parts of extended input
-        // 2. Copy periodically appropriate elements from input to the buffers
-        // 3. Convolve front buffer, input and rear buffer with even and odd
-        //    elements of the filter (this results in upsampling)
-        // 4. Free memory
+        /* Check if extending is really needed */
+        /* split filter len correct + extra samples*/
+        N_p = F_2-1 + (index_t) ceil(k/2.);
+
+        /*
+         * ok, if is then do:
+         * 1. Allocate buffers for front and rear parts of extended input
+         * 2. Copy periodically appropriate elements from input to the buffers
+         * 3. Convolve front buffer, input and rear buffer with even and odd
+         *    elements of the filter (this results in upsampling)
+         * 4. Free memory
+         */

         if(N_p > 0){
-        // =======
-
-            // Allocate memory only for the front and rear extension parts, not the
-            // whole input
+            /*
+             * Allocate memory only for the front and rear extension parts, not
+             * the whole input
+             */
             periodization_buf = wtcalloc(N_p, sizeof($DTYPE$));
             periodization_buf_rear = wtcalloc(N_p, sizeof($DTYPE$));

-            // Memory checking
+            /* Memory checking */
             if(periodization_buf == NULL || periodization_buf_rear == NULL){
                 if(periodization_buf == NULL) wtfree(periodization_buf);
                 if(periodization_buf_rear == NULL) wtfree(periodization_buf_rear);
@@ -668,18 +670,22 @@
                 return -1;
             }

-            // Fill buffers with appropriate elements
-            memcpy(periodization_buf + N_p - k, input, k * sizeof($DTYPE$));        // copy from beginning of input to end of buffer
-            for(i = 1; i <= (N_p - k); ++i)                                        // kopiowanie 'cykliczne' od końca input
+            /* Fill buffers with appropriate elements */
+
+            /* copy from beginning of input to end of buffer */
+            memcpy(periodization_buf + N_p - k, input, k * sizeof($DTYPE$));
+            for(i = 1; i <= (N_p - k); ++i)
                 periodization_buf[(N_p - k) - i] = input[N - (i%N)];

-            memcpy(periodization_buf_rear, input + N - k, k * sizeof($DTYPE$));    // copy from end of input to beginning of buffer
-            for(i = 0; i < (N_p - k); ++i)                                        // kopiowanie 'cykliczne' od początku input
+            /* copy from end of input to beginning of buffer */
+            memcpy(periodization_buf_rear, input + N - k, k * sizeof($DTYPE$));
+            for(i = 0; i < (N_p - k); ++i)
                 periodization_buf_rear[k + i] = input[i%N];

-            ///////////////////////////////////////////////////////////////////
-            // Convolve filters with the (front) periodization_buf and compute
-            // the first part of output
+            /*
+             * Convolve filters with the (front) periodization_buf and compute
+             * the first part of output
+             */

             ptr_base = periodization_buf + F_2 - 1;

@@ -694,22 +700,26 @@
                 if(k)
                     $DTYPE$_upsampling_convolution_valid_sf(periodization_buf + 1, N_p-1, filter, F, ptr_out, O-1, MODE_ZEROPAD);

-                ptr_out += k; // k0 - 1 // really move backward by 1
+                ptr_out += k; /* k0 - 1, really move backward by 1 */

             } else if(k){
-                $DTYPE$_upsampling_convolution_valid_sf(periodization_buf, N_p, filter, F, ptr_out, O, MODE_ZEROPAD);
+                $DTYPE$_upsampling_convolution_valid_sf(periodization_buf, N_p,
+                                                        filter, F, ptr_out, O,
+                                                        MODE_ZEROPAD);
                 ptr_out += k;
             }
         }

-        ///////////////////////////////////////////////////////////////////////////
-        // Perform _valid_ convolution (only when all filter_even and filter_odd elements
-        // are in range of input data).
-        //
-        // This part is simple, no extra hacks, just two convolutions in one loop
+        /*
+         * Perform _valid_ convolution (only when all filter_even and
+         * filter_odd elements are in range of input data).
+         *
+         * This part is simple, no extra hacks, just two convolutions in one
+         * loop
+         */

         ptr_base = ($DTYPE$*)input + F_2 - 1;
-        for(i = 0; i < N-(F_2-1); ++i){    // sliding over signal from left to right
+        for(i = 0; i < N-(F_2-1); ++i){ /* sliding over signal from left to right */

             sum_even = 0;
             sum_odd = 0;
@@ -722,32 +732,31 @@
             *(ptr_out++) += sum_even;
             *(ptr_out++) += sum_odd;
         }
-        //
-        ///////////////////////////////////////////////////////////////////////////

         if(N_p > 0){
-        // =======
-
             k = F_2-1;
             if(k%2 == 1){
-                if(F/2 <= N_p - 1){ // k > 1 ?
+                if(F/2 <= N_p - 1){ /* k > 1 ? */
                     $DTYPE$_upsampling_convolution_valid_sf(periodization_buf_rear , N_p-1, filter, F, ptr_out, O-1, MODE_ZEROPAD);
                 }

-                ptr_out += k; // move forward anyway -> see lower
-
-                if(F_2%2 == 0){ // remaining one element
+                ptr_out += k; /* move forward anyway -> see lower */
+
+                if(F_2%2 == 0){ /* remaining one element */
                     ptr_base = periodization_buf_rear + N_p - 1;

                     sum_even = 0;
                     for(j = 0; j < F_2; ++j){
                         sum_even += filter_even[j] * ptr_base[-j];
                     }
-                    *(--ptr_out) += sum_even; // move backward first
+                    *(--ptr_out) += sum_even; /* move backward first */
                 }
             } else {
                 if(k){
-                    $DTYPE$_upsampling_convolution_valid_sf(periodization_buf_rear, N_p, filter, F, ptr_out, O, MODE_ZEROPAD);
+                    $DTYPE$_upsampling_convolution_valid_sf(periodization_buf_rear,
+                                                            N_p, filter, F,
+                                                            ptr_out, O,
+                                                            MODE_ZEROPAD);
                 }
             }
         }
@@ -762,18 +771,19 @@
 }

-///////////////////////////////////////////////////////////////////////////////
-// performs IDWT for all modes
-//
-// The upsampling is performed by splitting filters to even and odd elements
-// and performing 2 convolutions.
-// After refactoring the PERIODIZATION mode case to separate function this
-// looks much clearer now.
-
-int $DTYPE$_upsampling_convolution_valid_sf(const $DTYPE$* input, const_index_t N,
-                                    const $DTYPE$* filter, const_index_t F,
-                                    $DTYPE$* output, const_index_t O,
-                                    MODE mode){
+/*
+ * performs IDWT for all modes
+ *
+ * The upsampling is performed by splitting filters to even and odd elements
+ * and performing 2 convolutions.  After refactoring the PERIODIZATION mode
+ * case to separate function this looks much clearer now.
+ */
+
+int $DTYPE$_upsampling_convolution_valid_sf(const $DTYPE$* input,
+                                            const_index_t N, const $DTYPE$*
+                                            filter, const_index_t F, $DTYPE$*
+                                            output, const_index_t O, MODE
+                                            mode){

     $DTYPE$ *ptr_out = output;
     $DTYPE$ *filter_even, *filter_odd;
@@ -793,13 +803,15 @@
     index_t i, j;
     index_t F_2 = F/2;

-    if(mode == MODE_PERIODIZATION) // Special case
-        return $DTYPE$_upsampling_convolution_valid_sf_periodization(input, N, filter, F, output, O);
-
-    if((F%2) || (N < F_2)) // Filter must have even length.
+    if(mode == MODE_PERIODIZATION) /* Special case */
+        return $DTYPE$_upsampling_convolution_valid_sf_periodization(input, N,
+                                                                     filter, F,
+                                                                     output, O);
+
+    if((F%2) || (N < F_2)) /* Filter must have even length. */
         return -1;

-    // Allocate memory for even and odd elements of the filter
+    /* Allocate memory for even and odd elements of the filter */
     filter_even = wtmalloc(F_2 * sizeof($DTYPE$));
     filter_odd = wtmalloc(F_2 * sizeof($DTYPE$));

@@ -809,24 +821,25 @@
         return -1;
     }

-    // split filter to even and odd values
+    /* split filter to even and odd values */
     for(i = 0; i < F_2; ++i){
         filter_even[i] = filter[i << 1];
         filter_odd[i] = filter[(i << 1) + 1];
     }

-    ///////////////////////////////////////////////////////////////////////////
-    // Perform _valid_ convolution (only when all filter_even and filter_odd elements
-    // are in range of input data).
-    //
-    // This part is simple, no extra hacks, just two convolutions in one loop
+    /*
+     * Perform _valid_ convolution (only when all filter_even and filter_odd elements
+     * are in range of input data).
+     *
+     * This part is simple, no extra hacks, just two convolutions in one loop
+     */

     ptr_base = ($DTYPE$*)input + F_2 - 1;
     i = 0;

     #ifdef OPT_UNROLL4
-    // manually unroll the loop a bit
-    for(; i < N-(F_2-1+8); i+=4){    // sliding over signal from left to right
+    /* manually unroll the loop a bit */
+    for(; i < N-(F_2-1+8); i+=4){    /* sliding over signal from left to right */
         sum_even  = filter_even[0] * ptr_base[i];
         sum_even2 = filter_even[0] * ptr_base[i+1];
         sum_even3 = filter_even[0] * ptr_base[i+2];
@@ -861,8 +874,8 @@
     #endif

     #ifdef OPT_UNROLL2
-    // manually unroll the loop a bit
-    for(; i < N-(F_2+1); i+=2){    // sliding over signal from left to right
+    /* manually unroll the loop a bit */
+    for(; i < N-(F_2+1); i+=2){    /* sliding over signal from left to right */
         sum_even = filter_even[0] * ptr_base[i];
         sum_even2 = filter_even[0] * ptr_base[i+1];

@@ -884,7 +897,7 @@
     }
     #endif

-    for(; i < N-(F_2-1); ++i){    // sliding over signal from left to right
+    for(; i < N-(F_2-1); ++i){    /* sliding over signal from left to right */
         sum_even = filter_even[0] * ptr_base[i];
         sum_odd  = filter_odd[0] * ptr_base[i];

@@ -896,17 +909,17 @@
         *(ptr_out++) += sum_even;
         *(ptr_out++) += sum_odd;
     }
-
-    //
-    ///////////////////////////////////////////////////////////////////////////

     wtfree(filter_even);
     wtfree(filter_odd);
     return 0;
 }

-// -> swt - todo
-int $DTYPE$_upsampled_filter_convolution(const $DTYPE$* input, const_index_t N, const $DTYPE$* filter, const_index_t F, $DTYPE$* output, const_index_t step, MODE mode)
+/* -> swt - todo */
+int $DTYPE$_upsampled_filter_convolution(const $DTYPE$* input,
+                                         const_index_t N, const $DTYPE$*
+                                         filter, const_index_t F, $DTYPE$*
+                                         output, const_index_t step, MODE mode)
 {
     return -1;
 }


Includes cleanup

Includes cleanup

--- src/browser.c
+++ src/browser.c
@@ -6,13 +6,13 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <pwd.h>
 #include <grp.h>
-#include <libgen.h>
 #include <gdk/gdkkeysyms.h>
 #include "callbacks.h"
 #include "browser.h"


tools: block on `poll()`

tools: block on `poll()`

--- tools/netresolve.c
+++ tools/netresolve.c
@@ -161,7 +161,7 @@
 			return false;
 		fprintf(stderr, "echo request\n");

-		status = poll(&sock, 1, -1);
+		status = poll(&sock, 1, 0);
 		if (status != 1)
 			return false;
 		status = recvfrom(sock.fd, buffer, sizeof buffer, 0, (struct sockaddr *) &sender, &salen);
@@ -379,7 +379,7 @@
 		fds[1].events = POLLIN;

 		while (true) {
-			if (poll(fds, 2, -1) == -1) {
+			if (poll(fds, 2, 0) == -1) {
 				fprintf(stderr, "poll: %s\n", strerror(errno));
 				break;
 			}


Fix declaration of snprintf for older MSVC

_snprintf_s takes an additional (size) argument, so is no direct replacement.
(Note that this code is currently unused - the two instances of snprintf here are within ifdef blocks that are not compiled for MSVC)

--- utest/ctest.h
+++ utest/ctest.h
@@ -84,7 +84,7 @@
 #endif

 #if _MSC_VER < 1900
-#define snprintf _snprintf_s
+#define snprintf _snprintf
 #endif

 #ifndef __cplusplus


Code cleanup

Code cleanup

--- src/browser.c
+++ src/browser.c
@@ -488,8 +488,11 @@

 /* useful */
+/* browser_error */
 static int _browser_error(char const * message, int ret);
+/* callbacks */
 static void _error_response(GtkDialog * dialog, gint arg, gpointer data);
+
 int browser_error(Browser * browser, char const * message, int ret)
 {
 	GtkWidget * dialog;


STYLE: Return type of const reduces code readability

This does not improve const correctness.

Issue identified by clang-tidy.

--- ImageSegmentation/itkWeightedVotingFusionImageFilter.h
+++ ImageSegmentation/itkWeightedVotingFusionImageFilter.h
@@ -250,7 +250,7 @@
   /**
    * Get the posterior probability image corresponding to a label.
    */
-  const ProbabilityImagePointer GetLabelPosteriorProbabilityImage( LabelType label )
+  ProbabilityImagePointer GetLabelPosteriorProbabilityImage( LabelType label )
     {
     if( this->m_RetainLabelPosteriorProbabilityImages )
       {
@@ -274,7 +274,7 @@
   /**
    * Get the voting weight image corresponding to an atlas.
    */
-  const ProbabilityImagePointer GetAtlasVotingWeightImage( unsigned int n )
+  ProbabilityImagePointer GetAtlasVotingWeightImage( unsigned int n )
     {
     if( this->m_RetainAtlasVotingWeightImages )
       {
@@ -298,7 +298,7 @@
   /**
    * Get the joint intensity fusion output image
    */
-  const ProbabilityImagePointer GetJointIntensityFusionImage( unsigned int n )
+  ProbabilityImagePointer GetJointIntensityFusionImage( unsigned int n )
     {
     if( n < this->m_NumberOfAtlasModalities )
       {


hcidump: Add ATT MTU req/resp and notify value

--- tools/parser/att.c
+++ tools/parser/att.c
@@ -132,12 +132,35 @@
 	}
 }

+static void att_mtu_req_dump(int level, struct frame *frm)
+{
+	uint16_t client_rx_mtu = btohs(htons(get_u16(frm)));
+
+	p_indent(level, frm);
+	printf("client rx mtu %d\n", client_rx_mtu);
+}
+
+static void att_mtu_resp_dump(int level, struct frame *frm)
+{
+	uint16_t server_rx_mtu = btohs(htons(get_u16(frm)));
+
+	p_indent(level, frm);
+	printf("server rx mtu %d\n", server_rx_mtu);
+}
+
 static void att_handle_notify_dump(int level, struct frame *frm)
 {
 	uint16_t handle = btohs(htons(get_u16(frm)));

 	p_indent(level, frm);
 	printf("handle 0x%2.2x\n", handle);
+
+	p_indent(level, frm);
+	printf("value ");
+	while (frm->len > 0) {
+		printf("0x%.2x ", get_u8(frm));
+	}
+	printf("\n");
 }

 void att_dump(int level, struct frame *frm)
@@ -150,6 +173,12 @@
 	printf("ATT: %s (0x%.2x)\n", attop2str(op), op);

 	switch (op) {
+		case ATT_OP_MTU_REQ:
+			att_mtu_req_dump(level + 1, frm);
+			break;
+		case ATT_OP_MTU_RESP:
+			att_mtu_resp_dump(level + 1, frm);
+			break;
 		case ATT_OP_HANDLE_NOTIFY:
 			att_handle_notify_dump(level + 1, frm);
 			break;


cfgmap: Clean up.

cfgmap: Clean up.

--- util/cfgmap.c
+++ util/cfgmap.c
@@ -69,12 +69,12 @@
 /**
  * Holds data for config map setters and getters.
  **/
-struct ib_cfgmap_handlers_data
+struct ib_cfgmap_handlers_data_t
 {
     const ib_cfgmap_init_t *init;
     void                   *base;
 };
-typedef struct ib_cfgmap_handlers_data ib_cfgmap_handlers_data;
+typedef struct ib_cfgmap_handlers_data_t ib_cfgmap_handlers_data_t;

 /**
  * Translate field getter to cfgmap getter.
@@ -95,7 +95,7 @@
         IB_FTRACE_RET_PTR(void, NULL);
     }

-    ib_cfgmap_handlers_data *data = (ib_cfgmap_handlers_data*)cbdata;
+    ib_cfgmap_handlers_data_t *data = (ib_cfgmap_handlers_data_t*)cbdata;

     IB_FTRACE_RET_PTR(
         const void,
@@ -126,7 +126,7 @@
         IB_FTRACE_RET_STATUS(IB_EINVAL);
     }

-    ib_cfgmap_handlers_data *data = (ib_cfgmap_handlers_data*)cbdata;
+    ib_cfgmap_handlers_data_t *data = (ib_cfgmap_handlers_data_t*)cbdata;

     IB_FTRACE_RET_STATUS(
         data->init->fn_set(
@@ -157,13 +157,13 @@
                               rec->fn_set, rec->cbdata_set,
                               rec->fn_get, rec->cbdata_get);

-            /* Create a field with data that points to the base+offset. */
+            /* Create a field without value. */
             rc = ib_field_createn(&f, cm->mp, rec->name, rec->type, NULL);
             if (rc != IB_OK) {
                 IB_FTRACE_RET_STATUS(rc);
             }
-            ib_cfgmap_handlers_data *data =
-                (ib_cfgmap_handlers_data*)ib_mpool_alloc(
+            ib_cfgmap_handlers_data_t *data =
+                (ib_cfgmap_handlers_data_t*)ib_mpool_alloc(
                     cm->mp,
                     sizeof(*data)
                 );


- store location, dunno why it does not work yet

--- tools/repo_rpmmd.c
+++ tools/repo_rpmmd.c
@@ -29,6 +29,10 @@
   STATE_NAME,
   STATE_ARCH,
   STATE_VERSION,
+
+  // package rpm-md
+  STATE_LOCATION,
+  STATE_CHECKSUM,

   /* resobject attributes */
   STATE_SUMMARY,
@@ -133,6 +137,10 @@
   { STATE_SOLVABLE,    "name",            STATE_NAME, 1 },
   { STATE_SOLVABLE,    "arch",            STATE_ARCH, 1 },
   { STATE_SOLVABLE,    "version",         STATE_VERSION, 0 },
+
+  // package attributes rpm-md
+  { STATE_SOLVABLE,    "location",            STATE_LOCATION, 0 },
+  { STATE_SOLVABLE,    "checksum",         STATE_CHECKSUM, 1 },

   /* resobject attributes */

@@ -214,10 +222,14 @@
   int docontent;
   int numpacks;
   Solvable *solvable;
+  Id lastsolvableid;
   struct stateswitch *swtab[NUMSTATES];
   enum state sbtab[NUMSTATES];
   const char *lang;
   const char *capkind;
+  // used to store tmp attributes
+  // while the tag ends
+  const char *tmpattr;
   Repodata *data;
 };

@@ -451,18 +463,18 @@
     {
     case STATE_METADATA:
       for (; *atts; atts += 2)
-	{
-	  if (!strcmp(*atts, "packages"))
-	    {
-	      pd->numpacks = atoi(atts[1]);
-	      if (pd->numpacks < 0)
-		pd->numpacks = 0;
+      {
+        if (!strcmp(*atts, "packages"))
+        {
+          pd->numpacks = atoi(atts[1]);
+          if (pd->numpacks < 0)
+            pd->numpacks = 0;
 #if 0
 	      fprintf(stderr, "numpacks: %d\n", pd->numpacks);
 #endif
-	      pd->solvable = pool_id2solvable(pool, repo_add_solvable_block(pd->common.repo, pd->numpacks));
-	    }
-	}
+            pd->solvable = pool_id2solvable(pool, repo_add_solvable_block(pd->common.repo, pd->numpacks));
+        }
+      }
       break;
     case STATE_SOLVABLE:
       pd->kind = 0;
@@ -474,7 +486,10 @@
         pd->kind = "patch";

       if (pd->numpacks == 0)
-	pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->common.repo));
+      {
+        pd->lastsolvableid = repo_add_solvable(pd->common.repo);
+        pd->solvable = pool_id2solvable(pool, pd->lastsolvableid);
+      }
 #if 0
       fprintf(stderr, "package #%d\n", pd->solvable - pool->solvables);
 #endif
@@ -562,6 +577,12 @@
       pd->lang = find_attr("lang", atts);
       //repodata_set_tstr( pd->data, pd-
       break;
+    case STATE_LOCATION:
+      pd->tmpattr = find_attr("href", atts);
+      break;
+    case STATE_CHECKSUM:
+      pd->tmpattr = find_attr("type", atts);
+      break;
     default:
       break;
     }
@@ -596,10 +617,10 @@
         s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
       s->supplements = repo_fix_legacy(repo, s->provides, s->supplements);
       if (pd->numpacks > 0)
-	{
-	  pd->numpacks--;
-	  pd->solvable++;
-	}
+      {
+        pd->numpacks--;
+        pd->solvable++;
+      }
       pd->kind = 0;
       break;
     case STATE_NAME:
@@ -651,6 +672,11 @@
       break;
     case STATE_DESCRIPTION:
       pd->lang = 0;
+      break;
+    case STATE_LOCATION:
+      repodata_set_str(pd->data, pd->lastsolvableid, id_mediafile, pd->tmpattr);
+      break;
+    case STATE_CHECKSUM:
       break;
     default:
       break;
@@ -713,6 +739,7 @@
   pd.common.tmp = 0;
   pd.common.tmpl = 0;
   pd.kind = 0;
+  pd.lastsolvableid = 0;
   XML_Parser parser = XML_ParserCreate(NULL);
   XML_SetUserData(parser, &pd);
   XML_SetElementHandler(parser, startElement, endElement);
@@ -729,6 +756,10 @@
 	break;
     }
   XML_ParserFree(parser);
+
+  if (pd.data)
+    repodata_internalize(pd.data);
+
   if (pd.numpacks)
     repo_free_solvable_block(repo, pd.solvable - pool->solvables, pd.numpacks, 1);
   sat_free(pd.content);


Fix memory leak in bs_size_new_from_str

Fix memory leak in bs_size_new_from_str

--- src/bs_size.c
+++ src/bs_size.c
@@ -433,13 +433,11 @@
     int str_len = 0;
     pcre2_match_data *match_data = NULL;
     int str_count = 0;
-    char *num_str = NULL;
     const char *radix_char = NULL;
     char *loc_size_str = NULL;
     mpf_t parsed_size;
     mpfr_t size;
     int status = 0;
-    char *unit_str = NULL;
     BSSize ret = NULL;
     PCRE2_UCHAR *substring = NULL;
     PCRE2_SIZE substring_len = 0;
@@ -491,7 +489,7 @@
     }

     status = pcre2_substring_get_byname (match_data, (PCRE2_SPTR) "numeric", &substring, &substring_len);
-    if (status < 0) {
+    if (status < 0 || substring_len < 1) {
         set_error (error, BS_ERROR_INVALID_SPEC, strdup_printf ("Failed to parse size spec: %s", size_str));
         pcre2_match_data_free (match_data);
         pcre2_code_free (regex);
@@ -499,13 +497,11 @@
         return NULL;
     }

-    num_str = strndup ((const char*) substring, substring_len);
-
     /* parse the number using GMP because it knows how to handle localization
        much better than MPFR */
     mpf_init2 (parsed_size, BS_FLOAT_PREC_BITS);
-    status = mpf_set_str (parsed_size, *num_str == '+' ? num_str+1 : num_str, 10);
-    free (num_str);
+    status = mpf_set_str (parsed_size, *substring == '+' ? (const char *) substring+1 : (const char *) substring, 10);
+    pcre2_substring_free (substring);
     if (status != 0) {
         set_error (error, BS_ERROR_INVALID_SPEC, strdup_printf ("Failed to parse size spec: %s", size_str));
         pcre2_match_data_free (match_data);
@@ -520,12 +516,11 @@
     mpf_clear (parsed_size);

     status = pcre2_substring_get_byname (match_data, (PCRE2_SPTR) "rest", &substring, &substring_len);
-    unit_str = strndup ((const char*) substring, substring_len);
-    if ((status >= 0) && strncmp (unit_str, "", 1) != 0) {
-        strstrip (unit_str);
-        if (!multiply_size_by_unit (size, unit_str)) {
+    if ((status >= 0) && strncmp ((const char *) substring, "", 1) != 0) {
+        strstrip ((char *) substring);
+        if (!multiply_size_by_unit (size, (char *) substring)) {
             set_error (error, BS_ERROR_INVALID_SPEC, strdup_printf ("Failed to recognize unit from the spec: %s", size_str));
-            free (unit_str);
+            pcre2_substring_free (substring);
             pcre2_match_data_free (match_data);
             pcre2_code_free (regex);
             free (loc_size_str);
@@ -533,7 +528,7 @@
             return NULL;
         }
     }
-    free (unit_str);
+    pcre2_substring_free (substring);
     pcre2_match_data_free (match_data);
     pcre2_code_free (regex);


pd: ectool: fix bug in infopddev command.

Change 94515d9e failed to set ec param port prior to sending the host command.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=none
TEST=manual, with two devices with different vid:pid see correct values now.

Reviewed-on: https://chromium-review.googlesource.com/241951
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
(cherry picked from commit 815cb8486655ade011128c6a2948bda4324dff0f)
Signed-off-by: Duncan Laurie <70662b43bc1a20b57ded72a2b08be88dd0da4841@chromium.org>

Change-Id: I6a0b9d30905509847c9481c222fa7e3c9a0264a1
Reviewed-on: https://chromium-review.googlesource.com/242132
Tested-by: Duncan Laurie <70662b43bc1a20b57ded72a2b08be88dd0da4841@chromium.org>
Reviewed-by: Duncan Laurie <70662b43bc1a20b57ded72a2b08be88dd0da4841@chromium.org>
Commit-Queue: Duncan Laurie <70662b43bc1a20b57ded72a2b08be88dd0da4841@chromium.org>

--- util/ectool.c
+++ util/ectool.c
@@ -934,6 +934,7 @@
 		return -1;
 	}

+	p->port = port;
 	r1 = (struct ec_params_usb_pd_discovery_entry *)ec_inbuf;
 	rv = ec_command(EC_CMD_USB_PD_DISCOVERY, 0, p, sizeof(*p),
 			ec_inbuf, ec_max_insize);


exit if there is an error opening the old solv

--- tools/rpmdb2solv.c
+++ tools/rpmdb2solv.c
@@ -34,22 +34,27 @@
   int g;
   const char *root = "/";

-  while ((g = getopt (argc, argv, "-r:")) >= 0)
+  while ((g = getopt (argc, argv, "r:")) >= 0)
     switch (g)
       {
       case 'r': root = optarg; break;
-      case 1:
-        refpool = pool;
-        if ((fp = fopen(argv[1], "r")) == NULL)
-          {
-            perror(argv[1]);
-            exit(0);
-          }
-        ref = repo_create(refpool, "ref");
-        repo_add_solv(ref, fp);
-        fclose(fp);
+      default:
+	exit(1);
       }

+  if (optind < argc)
+    {
+      refpool = pool;
+      if ((fp = fopen(argv[optind], "r")) == NULL)
+        {
+          perror(argv[optind]);
+          exit(1);
+        }
+      ref = repo_create(refpool, "ref");
+      repo_add_solv(ref, fp);
+      fclose(fp);
+    }
+
   repo = repo_create(pool, "installed");
   repo_add_rpmdb(repo, ref, root);
   if (ref)


Do not calculate massive time deltas when accelerating from zero

Or else the offset from stop will be huge and hugely wrong.

--- src/tasks/train_blaster.c
+++ src/tasks/train_blaster.c
@@ -181,7 +181,7 @@
             ctxt->name);

     // calculate when to wake up and send off that guy
-    const int speed_delta = to_speed - truth.speed;
+    const int speed_delta = truth.speed ? to_speed - truth.speed : 0;
     const int start_dist  = physics_starting_distance(ctxt, speed_delta);
     const int start_time  = physics_starting_time(ctxt, start_dist);
     const int velocity    = physics_current_velocity(ctxt);


Minor documentation fix

Minor documentation fix

--- src/core/include/tsp_glu.h
+++ src/core/include/tsp_glu.h
@@ -1,6 +1,6 @@
 /*

-$Id: tsp_glu.h,v 1.14 2006-04-26 07:53:52 erk Exp $
+$Id: tsp_glu.h,v 1.15 2006-05-18 18:32:07 erk Exp $

 -----------------------------------------------------------------------

@@ -260,8 +260,8 @@
 /**
  * GLU_get_provider_global_indexes provider global indexes corresponding
  * to given symbol list. Used to validate client provided symbol list
- * @param symbol_list IN the symbol list to validate
- * @param pg_indexes OUT array containing corresponding provider global indexes or -1 if not found
+ * @param[in] symbol_list the symbol list to validate
+ * @param[out] pg_indexes array containing corresponding provider global indexes or -1 if not found
  * @return TRUE if all symbol found, else return FALSE
  */
 typedef int32_t                (* GLU_get_pgi_ft           )(struct GLU_handle_t* this, TSP_sample_symbol_info_list_t* symbol_list, int* pg_indexes);
@@ -275,10 +275,10 @@

 /**
  * Filtered list of symbols managed by the GLU.
- * @param this Handle for the GLU (when the GLU is ACTIVE, it is always equal to GLU_GLOBAL_HANDLE)
- * @param filter_kind the filter kind
- * @param filter_string the filter string
- * @param ans_sample the answer_sample to be filled-in by the GLU.
+ * @param[in] this Handle for the GLU (when the GLU is ACTIVE, it is always equal to GLU_GLOBAL_HANDLE)
+ * @param[in] filter_kind the filter kind
+ * @param[in] filter_string the filter string
+ * @param[out] ans_sample the answer_sample to be filled-in by the GLU.
  * @return TRUE of FALSE. TRUE = OK;
  */
 typedef int32_t                (* GLU_get_filtered_ssi_list_ft)(struct GLU_handle_t* this, int32_t filter_kind, char* filter_string, TSP_answer_sample_t* symbol_list);
@@ -317,9 +317,9 @@
  * represented by its provider_global_index (correct pgi and authorization by
  * the GLU), the number returned is >0; else the number returned is <= 0
  *
- * @param pgi        IN, the index of the symbol concerned by the writing
- * @param value_ptr  IN, the new value of the symbol
- * @param value_size IN, the size of the value.
+ * @param[in] pgi        the index of the symbol concerned by the writing
+ * @param[in] value_ptr  the new value of the symbol
+ * @param[in] value_size the size of the value.
  * @return >0 on success <=0 on failure
  */
 typedef int32_t                (* GLU_async_sample_write_ft)(struct GLU_handle_t* this, int32_t pgi, void* value_ptr, uint32_t value_size);
@@ -331,9 +331,9 @@
  * represented by its provider_global_index (correct pgi and authorization by
  * the GLU), the number returned is >0; else the number returned is <= 0
  *
- * @param pgi        IN,  the index of the symbol concerned by the writing
- * @param value_ptr  OUT, the new value of the symbol
- * @param value_size INOUT, the size of the value.
+ * @param[in] pgi        the index of the symbol concerned by the writing
+ * @param[in] value_ptr  the new value of the symbol
+ * @param[in,out] value_size the size of the value.
  * @return >0 on success <=0 on failure
  */
 typedef int32_t                (* GLU_async_sample_read_ft)(struct GLU_handle_t* this, int32_t pgi, void* value_ptr, uint32_t* value_size);


cleanup

cleanup

--- src/builtin.h
+++ src/builtin.h
@@ -1591,10 +1591,7 @@
   auto &obj = typeAs<ArrayObject>(iterObj[0]);
   assert(iterObj[1].asInt() > -1);
   size_t index = iterObj[1].asInt();
-  if (index >= obj.size()) {
-    raiseOutOfRangeError(ctx, std::string("array iterator has already reached end"));
-    RET_ERROR;
-  }
+  assert(index < obj.size());
   auto value = obj.getValues()[index++];
   iterObj[1] = DSValue::createInt(index);
   RET(value);
@@ -1757,10 +1754,7 @@
 YDSH_METHOD map_next(RuntimeContext &ctx) {
   SUPPRESS_WARNING(map_next);
   auto &obj = typeAs<MapIterObject>(LOCAL(0));
-  if (!obj.hasNext()) {
-    raiseOutOfRangeError(ctx, std::string("map iterator has already reached end"));
-    RET_ERROR;
-  }
+  assert(obj.hasNext());
   RET(obj.next(ctx.typePool));
 }


dev+ [ci skip]

dev+ [ci skip]

--- src/tconv/convert/iconv.c
+++ src/tconv/convert/iconv.c
@@ -9,25 +9,17 @@

 /* ==================================================== */
 /* Some iconv implementations are buggy when source and */
-/* charset families are the same.                       */
+/* charset categories are the same.                     */
 /* In such a case our implementation is doing much more */
 /* work by forcing an intermediate representation,      */
 /* using an intermediate encoding that can encode all   */
-/* characters. Namely: UTF-8 or UTF-32.                 */
+/* characters. Namely: UTF-8.                           */
 /*                                                      */
 /* Also some iconv returns EINVAL in this case. We try  */
 /* with the intermediate representation as well in this */
 /* case.                                                */
 /*                                                      */
-/* When source and destination charset families are the */
-/* same:                                                */
-/* - UTF-8 intermediate encoding is used if destination */
-/*   charset is not UTF-8, or                           */
-/* - UTF-32 intermediate encoding                       */
-/* The implementation is simply calling recursively     */
-/* tconv.                                               */
-/*                                                      */
-/* The difficulty is about the families...              */
+/* The difficulty is about the families.                */
 /* We take the list from ICU to derive a list of        */
 /* "categories". This is particularly usefull when the  */
 /* input is an alias. If the category lookup fails, we  */
@@ -41,22 +33,21 @@
 /* Context */
 #define TCONV_ICONV_INITIAL_SIZE 4096
 typedef struct tconv_convert_iconv_context {
-  iconv_t  iconvp;        /* iconv itself */
-  short    intermediateb; /* Use an intermerdiate charset */
-  short    toutf8b;       /* destination is UTF-8 */
+  iconv_t     iconvp;           /* iconv itself */
+  short       intermediateb;    /* Use an intermerdiate UTF-8 charset */
+  short       toutf8b;          /* final charset destination is UTF-8 */

   /* --------------------------------------------- */
   /* When intermediateb is a true value            */
   /* --------------------------------------------- */
-  /* input   ->  internal  -> output               */
+  /* input   ->  UTF-8  -> output                  */
   /*     iconvfromp       iconvtop                 */
   /* --------------------------------------------- */
-  iconv_t  iconvfromp;    /* iconv "from" instance */
-  char    *internals;     /* Internal buffers */
-  short    internalutf8b; /* Internal buffer is UTF-8 */
-  size_t   internall;     /* Internal buffers length */
-  char    *internalp;     /* Internal buffers current position */
-  iconv_t  iconvtop;      /* iconv "to" instance */
+  iconv_t     iconvfromp;       /* "from" -> "UTF-8" iconv instance */
+  char       *internals;        /* Internal buffers */
+  size_t      internall;        /* Internal buffers length */
+  char       *internalp;        /* Internal buffers current position */
+  iconv_t     iconvtop;         /* "UTF-8" -> "to" iconv instance */
 } tconv_convert_iconv_context_t;

 #ifdef ICONV_SECOND_ARGUMENT_IS_CONST
@@ -71,9 +62,9 @@
 static inline char  *tconv_convert_iconv_charset_normalizeds(tconv_t tconvp, const char *charsets);
 static inline char  *tconv_convert_iconv_charset_lookupp(tconv_t tconvp, const char *charsets, char ***categoriespp);
 #ifdef ICONV_IS_NOT_TRUSTABLE
-static inline size_t tconv_convert_iconv_check(tconv_t tconvp, iconv_t iconvp, short toutf8b, char **inbufpp, size_t *inbytesleftlp, char **outbufpp, size_t *outbytesleftlp);
+static inline size_t tconv_convert_iconv_checkb(tconv_t tconvp, iconv_t iconvp, short toutf8b, char **inbufpp, size_t *inbytesleftlp, char **outbufpp, size_t *outbytesleftlp);
 static inline int    tconv_utf82ordi(tconv_uint8_t *utf8bytes, tconv_uint32_t *uint32p);
-static inline short  tconv_utf8_ok(tconv_t tconvp, tconv_uint8_t *utf8bytes, size_t lengthl);
+static inline short  tconv_utf8_okb(tconv_t tconvp, tconv_uint8_t *utf8bytes, size_t lengthl);
 #endif
 #ifndef ICONV_CAN_IGNORE
 #define TCONV_ICONV_IGNORE   "//IGNORE"
@@ -87,6 +78,10 @@
 static const int i_for_is_bigendian = 1;
 short is_bigendian;
 #define TCONV_SYSTEM_IS_BIGENDIAN() ( (*(char*)&i_for_is_bigendian) == 0 )
+
+/* The two possible values for internal charset */
+static char *UTF8s  = "UTF-8";
+static char *UTF32s = "UTF-32";

 /*****************************************************************************/
 void  *tconv_convert_iconv_new(tconv_t tconvp, const char *tocodes, const char *fromcodes, void *voidp)
@@ -98,7 +93,7 @@
   char                           *fromnormaliseds    = NULL;
   iconv_t                         iconvp             = NULL;
   short                           samecategoryb      = 0;
-  short                           forceintermediateb = 0;
+  short                           intermediateb      = 0;
   iconv_t                         iconvfromp         = NULL;
   iconv_t                         iconvtop           = NULL;
   char                           *internals          = NULL;
@@ -108,7 +103,6 @@
   short                           internalutf8b;
   char                          **tocategoriespp;
   char                          **fromcategoriespp;
-  char                           *intermediatecharsets;
   int                             i;
   int                             j;

@@ -169,89 +163,87 @@
       }
     }
 #endif
-
-    /* Normalized version should never be NULL - though categories can be */
-    tonormaliseds = tconv_convert_iconv_charset_lookupp(tconvp, tocodes, &tocategoriespp);
-    if (tonormaliseds == NULL) {
-      goto err;
-    }
-    fromnormaliseds = tconv_convert_iconv_charset_lookupp(tconvp, fromcodes, &fromcategoriespp);
-    if (fromnormaliseds == NULL) {
-      goto err;
-    }
-    if (tocategoriespp != NULL) {
-      for (i = 0; i < TCONV_ICONV_MAX_CATEGORY; i++) {
-        if (tocategoriespp[i] == NULL) {
+  }
+
+  /* Normalized version should never be NULL - though categories can be */
+  tonormaliseds = tconv_convert_iconv_charset_lookupp(tconvp, tocodes, &tocategoriespp);
+  if (tonormaliseds == NULL) {
+    goto err;
+  }
+  fromnormaliseds = tconv_convert_iconv_charset_lookupp(tconvp, fromcodes, &fromcategoriespp);
+  if (fromnormaliseds == NULL) {
+    goto err;
+  }
+
+  /* Check if destination category is UTF-8 */
+  if (tocategoriespp != NULL) {
+    for (i = 0; i < TCONV_ICONV_MAX_CATEGORY; i++) {
+      if (tocategoriespp[i] == NULL) {
+        break;
+      }
+      if (strcmp(tocategoriespp[i], "UTF-8") == 0) {
+        toutf8b = 1;
+        break;
+      }
+    }
+  }
+
+  /* Check if source category is UTF-8 */
+  if ((fromcategoriespp != NULL)) {
+    for (i = 0; i < TCONV_ICONV_MAX_CATEGORY; i++) {
+      if (tocategoriespp[i] == NULL) {
+        break;
+      }
+      for (j = 0; j < TCONV_ICONV_MAX_CATEGORY; j++) {
+        if (fromcategoriespp[j] == NULL) {
           break;
         }
-        if (strcmp(tocategoriespp[i], "UTF-8") == 0) {
-          toutf8b = 1;
+        if (strcmp(tocategoriespp[i], fromcategoriespp[j]) == 0) {
+          samecategoryb = 1;
           break;
         }
       }
-      if ((fromcategoriespp != NULL)) {
-        for (i = 0; i < TCONV_ICONV_MAX_CATEGORY; i++) {
-          if (tocategoriespp[i] == NULL) {
-            break;
-          }
-          for (j = 0; j < TCONV_ICONV_MAX_CATEGORY; j++) {
-            if (fromcategoriespp[j] == NULL) {
-              break;
-            }
-            if (strcmp(tocategoriespp[i], fromcategoriespp[j]) == 0) {
-              samecategoryb = 1;
-              break;
-            }
-          }
-        }
-        TCONV_TRACE(tconvp, "%s - same category mode is %s", funcs, samecategoryb ? "on" : "off");
-      }
-    }
-    if (samecategoryb) {
-    forceintermediate:
-      /* Determine the intermediate encoding: UTF-8 or UTF-32 */
-      TCONV_TRACE(tconvp, "%s - %s category is %sUTF-8", funcs, forceintermediateb ? "destination" : "same", toutf8b ? "" : "not ");
-      if (toutf8b) {
-        intermediatecharsets = "UTF-32";
-        internalutf8b        = 0;
+    }
+    TCONV_TRACE(tconvp, "%s - same category mode is %s", funcs, samecategoryb ? "on" : "off");
+  }
+
+  if (samecategoryb && ! toutf8b) {
+    /* Same category and destination, and this is not UTF-8 */
+  forceintermediate:
+    intermediateb = 1;
+
+    TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\")", funcs, tocodes, "UTF-8");
+    iconvtop = iconv_open(tocodes, "UTF-8");
+    if (iconvtop == NULL) {
+      goto err;
+    }
+    TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\") returned %p", funcs, tocodes, "UTF-8", iconvtop);
+
+    TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\")", funcs, "UTF-8", fromcodes);
+    iconvfromp = iconv_open("UTF-8", fromcodes);
+    if (iconvfromp == NULL) {
+      goto err;
+    }
+    TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\") returned %p", funcs, "UTF-8", fromcodes, iconvfromp);
+
+    TCONV_TRACE(tconvp, "%s - malloc(%ld)", funcs, (unsigned long) TCONV_ICONV_INITIAL_SIZE);
+    internals = (char *) malloc(internall);
+    if (internals == NULL) {
+      goto err;
+    }
+  } else {
+    /* Categories lookup failed or destination charset family is UTF-8 */
+    TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\")", funcs, tocodes, fromcodes);
+    iconvp = iconv_open(tocodes, fromcodes);
+    if (iconvp == NULL) {
+      /* On some implementation, for example solaris8, this can fail when we fall */
+      /* into categories that have the same number of bytes. We can be sure of what */
+      /* we do only when both destination and source categories are determined */
+      /* and destination category is not UTF-8 */
+      if ((tocategoriespp != NULL) && (fromcategoriespp != NULL) && (! toutf8b)) {
+        goto forceintermediate;
       } else {
-        intermediatecharsets = "UTF-8";
-        internalutf8b        = 1;
-      }
-
-      TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\")", funcs, intermediatecharsets, fromcodes);
-      iconvfromp = iconv_open(intermediatecharsets, fromcodes);
-      if (iconvfromp == NULL) {
         goto err;
-      }
-      TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\") returned %p", funcs, intermediatecharsets, fromcodes, iconvfromp);
-
-      TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\")", funcs, tocodes, intermediatecharsets);
-      iconvtop = iconv_open(tocodes, intermediatecharsets);
-      if (iconvtop == NULL) {
-        goto err;
-      }
-      TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\") returned %p", funcs, tocodes, intermediatecharsets, iconvtop);
-
-      TCONV_TRACE(tconvp, "%s - malloc(%ld)", funcs, (unsigned long) TCONV_ICONV_INITIAL_SIZE);
-      internals = (char *) malloc(internall);
-      if (internals == NULL) {
-        goto err;
-      }
-    } else {
-      /* Categories lookup failed, or succeeded but say the charsets are not in the same category: normal iconv */
-      TCONV_TRACE(tconvp, "%s - iconv_open(\"%s\", \"%s\")", funcs, tocodes, fromcodes);
-      iconvp = iconv_open(tocodes, fromcodes);
-      if (iconvp == NULL) {
-        /* On some implementation, for example solaris8, this can fail when we fall */
-        /* into categories that have the same number of bytes. We can be sure of what */
-        /* we do only when the destination category is found (i.e. toutf8b is set) */
-        if (tocategoriespp != NULL) {
-          forceintermediateb = 1;
-          goto forceintermediate;
-        } else {
-          goto err;
-        }
       }
     }
   }
@@ -265,11 +257,10 @@
   TCONV_TRACE(tconvp, "%s - contextp is %p", funcs, contextp);

   contextp->iconvp             = iconvp;
-  contextp->intermediateb      = samecategoryb || forceintermediateb;
+  contextp->intermediateb      = intermediateb;
   contextp->toutf8b            = toutf8b;
   contextp->iconvfromp         = iconvfromp;
   contextp->internals          = internals;
-  contextp->internalutf8b      = internalutf8b;
   contextp->internall          = internall;
   contextp->internalp          = internals;
   contextp->iconvtop           = iconvtop;
@@ -319,8 +310,8 @@
     rcl = tconv_convert_iconv_intermediatel(tconvp, contextp, inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
   } else {
 #ifdef ICONV_IS_NOT_TRUSTABLE
-    TCONV_TRACE(tconvp, "%s - tconv_convert_iconv_check(%p, %p, %d, %p, %p, %p, %p)", funcs, tconvp, contextp->iconvp, (int) contextp->toutf8b, inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
-    rcl = tconv_convert_iconv_check(tconvp, contextp->iconvp, contextp->toutf8b, inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
+    TCONV_TRACE(tconvp, "%s - tconv_convert_iconv_checkb(%p, %p, %d, %p, %p, %p, %p)", funcs, tconvp, contextp->iconvp, (int) contextp->toutf8b, inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
+    rcl = tconv_convert_iconv_checkb(tconvp, contextp->iconvp, contextp->toutf8b, inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
 #else
     TCONV_TRACE(tconvp, "%s - iconv(%p, %p, %p, %p, %p)", funcs, contextp->iconvp, inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
     rcl = iconv(contextp->iconvp, (ICONV_SECOND_ARGUMENT char **) inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
@@ -475,8 +466,8 @@

     TCONV_TRACE(tconvp, "%s - remains %ld bytes to flush", funcs, (unsigned long) tmpinbytesleftl);
 #ifdef ICONV_IS_NOT_TRUSTABLE
-    TCONV_TRACE(tconvp, "%s - tconv_convert_iconv_check(%p, %p, %d, %p, %p, %p, %p)", funcs, tconvp, contextp->iconvtop, (int) contextp->toutf8b, &tmpinbufp, &tmpinbytesleftl, outbufpp, outbytesleftlp);
-    rcl = tconv_convert_iconv_check(tconvp, contextp->iconvtop, !contextp->internalutf8b, &tmpinbufp, &tmpinbytesleftl, outbufpp, outbytesleftlp);
+    TCONV_TRACE(tconvp, "%s - tconv_convert_iconv_checkb(%p, %p, %d, %p, %p, %p, %p)", funcs, tconvp, contextp->iconvtop, 0 /* toutf8b */, &tmpinbufp, &tmpinbytesleftl, outbufpp, outbytesleftlp);
+    rcl = tconv_convert_iconv_checkb(tconvp, contextp->iconvtop, 0, &tmpinbufp, &tmpinbytesleftl, outbufpp, outbytesleftlp);
 #else
     TCONV_TRACE(tconvp, "%s - iconv(%p, %p, %p, %p, %p)", funcs, contextp->iconvtop, inbufpp, inbytesleftlp, outbufpp, outbytesleftlp);
     rcl = iconv(contextp->iconvtop, (ICONV_SECOND_ARGUMENT char **) &tmpinbufp, &tmpinbytesleftl, outbufpp, outbytesleftlp);
@@ -517,9 +508,9 @@

   /* A special case is then the user is asking for a reset to initial state without flush. */
   if (((inbufpp == NULL) || (*inbufpp == NULL)) && ((outbufpp == NULL) || (*outbufpp == NULL))) {
-    TCONV_TRACE(tconvp, "%s - iconv(%p, NULL, NULL, NULL, NULL)", funcs, contextp->iconvfromp);
+    TCONV_TRACE(tconvp, "%s - ...->%s - iconv(%p, NULL, NULL, NULL, NULL)", funcs, "UTF-8", contextp->iconvfromp);
     iconv(contextp->iconvfromp, NULL, NULL, NULL, NULL);
-    TCONV_TRACE(tconvp, "%s - iconv(%p, NULL, NULL, NULL, NULL)", funcs, contextp->iconvtop);
+    TCONV_TRACE(tconvp, "%s - %s->... - iconv(%p, NULL, NULL, NULL, NULL)", funcs, "UTF-8", contextp->iconvtop);
     iconv(contextp->iconvtop, NULL, NULL, NULL, NULL);
     TCONV_TRACE(tconvp, "%s - reset internal buffer backlog", funcs);
     contextp->internalp = contextp->internals;
@@ -536,10 +527,10 @@
   internalleftl       = contextp->internall;
   while (1) {
 #ifdef ICONV_IS_NOT_TRUSTABLE
-    TCONV_TRACE(tconvp, "%s - tconv_convert_iconv_check(%p, %p, %d, %p, %p, %p, %p)", funcs, tconvp, contextp->iconvfromp, (int) contextp->internalutf8b, inbufpp, inbytesleftlp, &(contextp->internalp), &internalleftl);
-    rcl = tconv_convert_iconv_check(tconvp, contextp->iconvfromp, contextp->internalutf8b, inbufpp, inbytesleftlp, &(contextp->internalp), &internalleftl);
+    TCONV_TRACE(tconvp, "%s - ...->%s - tconv_convert_iconv_checkb(%p, %p, %d, %p, %p, %p, %p)", funcs, "UTF-8", tconvp, contextp->iconvfromp, 1 /* toutf8b */, inbufpp, inbytesleftlp, &(contextp->internalp), &internalleftl);
+    rcl = tconv_convert_iconv_checkb(tconvp, contextp->iconvfromp, 1, inbufpp, inbytesleftlp, &(contextp->internalp), &internalleftl);
 #else
-    TCONV_TRACE(tconvp, "%s - iconv(%p, %p, %p, %p, %p)", funcs, contextp->iconvfromp, inbufpp, inbytesleftlp, &(contextp->internalp), &internalleftl);
+    TCONV_TRACE(tconvp, "%s - %s->... - iconv(%p, %p, %p, %p, %p)", funcs, "UTF-8", contextp->iconvfromp, inbufpp, inbytesleftlp, &(contextp->internalp), &internalleftl);
     rcl = iconv(contextp->iconvfromp,
                 (ICONV_SECOND_ARGUMENT char **) inbufpp,
                 inbytesleftlp,
@@ -662,10 +653,10 @@

 #ifdef ICONV_IS_NOT_TRUSTABLE
 /*****************************************************************************/
-static inline size_t tconv_convert_iconv_check(tconv_t tconvp, iconv_t iconvp, short toutf8b, char **inbufpp, size_t *inbytesleftlp, char **outbufpp, size_t *outbytesleftlp)
-/*****************************************************************************/
-{
-  static const char    funcs[] = "tconv_convert_iconv_check";
+static inline size_t tconv_convert_iconv_checkb(tconv_t tconvp, iconv_t iconvp, short toutf8b, char **inbufpp, size_t *inbytesleftlp, char **outbufpp, size_t *outbytesleftlp)
+/*****************************************************************************/
+{
+  static const char    funcs[] = "tconv_convert_iconv_checkb";
   char   **orig_inbufpp        = inbufpp;
   size_t  *orig_inbytesleftlp  = inbytesleftlp;
   char   **orig_outbufpp       = outbufpp;
@@ -696,7 +687,7 @@
     producedl = (size_t) (outbufp - *orig_outbufpp);
     TCONV_TRACE(tconvp, "%s - checking UTF-8 correctness on %ld bytes", funcs, (unsigned long) producedl);
     if (producedl > 0) {
-      if (! tconv_utf8_ok(tconvp, (tconv_uint8_t *) *orig_outbufpp, producedl)) {
+      if (! tconv_utf8_okb(tconvp, (tconv_uint8_t *) *orig_outbufpp, producedl)) {
         rcl = (size_t)-1;
         errno = EILSEQ;
       }
@@ -720,10 +711,10 @@
 }

 /*****************************************************************************/
-static inline short tconv_utf8_ok(tconv_t tconvp, tconv_uint8_t *utf8bytes, size_t lengthl)
-/*****************************************************************************/
-{
-  static const char funcs[] = "tconv_utf8_ok";
+static inline short tconv_utf8_okb(tconv_t tconvp, tconv_uint8_t *utf8bytes, size_t lengthl)
+/*****************************************************************************/
+{
+  static const char funcs[] = "tconv_utf8_okb";
   tconv_uint8_t    *p       = utf8bytes;
   tconv_uint8_t    *maxp    = utf8bytes + lengthl;
   short             rcb     = 1;


* journald: fix missing fields;

* journald: fix missing fields;

--- src/core/journald-server.c
+++ src/core/journald-server.c
@@ -366,10 +366,10 @@
         return true;
 }

-static void dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigned m, struct timeval *tv) {
+static int dispatch_message(Server *s, struct iovec *iovec, struct timeval *tv) {
+        unsigned n = 0;
         assert(s);
         assert(iovec);
-        assert(n > 0);

         char source_time[sizeof("_SOURCE_REALTIME_TIMESTAMP=") + DECIMAL_STR_MAX(usec_t)];

@@ -387,17 +387,17 @@
         if (!isempty(s->hostname_field))
                 IOVEC_SET_STRING(iovec[n++], s->hostname_field);

-        assert(n <= m);
-}
-
-static void dispatch_message_object(Server *s, struct iovec *iovec, unsigned n, unsigned m, pid_t object_pid) {
+        return n;
+}
+
+static int dispatch_message_object(Server *s, struct iovec *iovec, pid_t object_pid) {
+        unsigned n = 0;
+
         assert(s);
         assert(iovec);
-        assert(n > 0);
-        assert(n + (object_pid ? N_IOVEC_OBJECT_FIELDS : 0) <= m);

         if (!object_pid)
-                return;
+                return 0;

         char o_uid[sizeof("OBJECT_UID=") + DECIMAL_STR_MAX(uid_t)],
              o_gid[sizeof("OBJECT_GID=") + DECIMAL_STR_MAX(gid_t)];
@@ -442,7 +442,7 @@
                 IOVEC_SET_STRING(iovec[n++], x);
         }

-        assert(n <= m);
+        return n;
 }

 static void write_to_journal(Server *s, uid_t realuid, struct iovec *iovec, unsigned n, int priority) {
@@ -513,9 +513,9 @@
                 server_schedule_sync(s, priority);
 }

-static void dispatch_message_real(
+static int dispatch_message_real(
                 Server *s,
-                struct iovec *iovec, unsigned n, unsigned m,
+                struct iovec *iovec,
                 struct ucred *ucred,
                 const char *label, size_t label_len,
                 const char *unit_id) {
@@ -523,6 +523,7 @@
         char    pid[sizeof("_PID=") + DECIMAL_STR_MAX(pid_t)],
                 uid[sizeof("_UID=") + DECIMAL_STR_MAX(uid_t)],
                 gid[sizeof("_GID=") + DECIMAL_STR_MAX(gid_t)];
+        unsigned n = 0;
         char *x;
         int r;
         char *t;
@@ -530,8 +531,6 @@

         assert(s);
         assert(iovec);
-        assert(n > 0);
-        assert(n + N_IOVEC_META_FIELDS <= m);

         if (ucred) {
                 sprintf(pid, "_PID="PID_FMT, ucred->pid);
@@ -569,7 +568,8 @@
                         IOVEC_SET_STRING(iovec[n++], x);
                 }
         }
-        assert(n <= m);
+
+        return n;
 }

 void server_driver_message(Server *s, const char *format, ...) {
@@ -596,8 +596,8 @@
         ucred.uid = getuid();
         ucred.gid = getgid();

-        dispatch_message_real(s, iovec, n, ELEMENTSOF(iovec), &ucred, NULL, 0, NULL);
-        dispatch_message(s, iovec, n, ELEMENTSOF(iovec), NULL);
+        n += dispatch_message_real(s, &iovec[n], &ucred, NULL, 0, NULL);
+        n += dispatch_message(s, &iovec[n], NULL);
         write_to_journal(s, ucred.uid, iovec, n, LOG_INFO);
 }

@@ -646,9 +646,9 @@
                 server_driver_message(s, "Suppressed %u messages from uid %u", rl - 1, realuid);

 finish:
-        dispatch_message_real(s, iovec, n, m, ucred, label, label_len, unit_id);
-        dispatch_message_object(s, iovec, n, m, object_pid);
-        dispatch_message(s, iovec, n, m, tv);
+        n += dispatch_message_real(s, &iovec[n], ucred, label, label_len, unit_id);
+        n += dispatch_message_object(s, &iovec[n], object_pid);
+        n += dispatch_message(s, &iovec[n], tv);
         write_to_journal(s, realuid, iovec, n, priority);
 }


Fix datetime construction (contributed by Patrick Hurst)

--- src/c/urweb.c
+++ src/c/urweb.c
@@ -4001,7 +4001,8 @@

 uw_Basis_time uw_Basis_fromDatetime(uw_context ctx, uw_Basis_int year, uw_Basis_int month, uw_Basis_int day, uw_Basis_int hour, uw_Basis_int minute, uw_Basis_int second) {
   struct tm tm = { .tm_year = year - 1900, .tm_mon = month, .tm_mday = day,
-                   .tm_hour = hour, .tm_min = minute, .tm_sec = second };
+                   .tm_hour = hour, .tm_min = minute, .tm_sec = second,
+                   .tm_isdst = -1 };
   uw_Basis_time r = { timelocal(&tm) };
   return r;
 }


test/parameterizedTester.c: Fix

test/parameterizedTester.c: Fix

--- test/parameterizedTester.c
+++ test/parameterizedTester.c
@@ -16,6 +16,8 @@
   genericLogger_t *genericLoggerp;
   char            *inputs;
   size_t           inputl;
+  short            parsemodeb; /* Mark the test case using marpaESLIFGrammar_parseb */
+  int              parsemodei; /* To avoid ambiguity in the marpaESLIFGrammar_parseb case */
 } marpaESLIF_context_t;

 const static char *grammars = "# Parameterized grammar\n"
@@ -93,6 +95,8 @@
   marpaESLIF_context.genericLoggerp = genericLoggerp;
   marpaESLIF_context.inputs         = (char *) inputs;
   marpaESLIF_context.inputl         = strlen(inputs);
+  marpaESLIF_context.parsemodeb     = 0;
+  marpaESLIF_context.parsemodei     = 0;

   marpaESLIFRecognizerOption.userDatavp        = &marpaESLIF_context; /* User specific context */
   marpaESLIFRecognizerOption.readerCallbackp   = inputReaderb; /* Reader */
@@ -131,6 +135,7 @@
   GENERICLOGGER_NOTICE(genericLoggerp, "Testing parse");
   marpaESLIF_context.inputs         = (char *) inputs;
   marpaESLIF_context.inputl         = strlen(inputs);
+  marpaESLIF_context.parsemodeb     = 1;
   if (! marpaESLIFGrammar_parseb(marpaESLIFGrammarp, &marpaESLIFRecognizerOption, NULL /* marpaESLIFValueOptionp */, NULL /* exhaustedbp */)) {
     goto err;
   }
@@ -227,7 +232,17 @@
   }

   if (parameteri > 4) {
-    sprintf(outputs, "start ::= '%d'", parameteri);
+    /* To avoid ambiguity in the marpaESLIFGrammar_parse test case, we generate only once the rhs that will match */
+    if (marpaESLIF_contextp->parsemodeb) {
+      if (marpaESLIF_contextp->parsemodei++ == 0) {
+        sprintf(outputs, "start ::= '%d'", parameteri);
+      } else {
+        sprintf(outputs, "start ::= '%d'", -1);
+      }
+    } else {
+      /* Ambiguity is ok when we use the scan mode */
+      sprintf(outputs, "start ::= '%d'", parameteri);
+    }
   } else {
     sprintf(outputs, "start ::= . => rhs->(5, { x = 'Value of x', y = 'Value of y' }, String('Input should be 5'))");
   }


String docs

String docs

--- Library/Sources/Stroika/Foundation/Characters/String.h
+++ Library/Sources/Stroika/Foundation/Characters/String.h
@@ -544,9 +544,8 @@

             public:
                 /**
-                 *  Produce a substring of this string, starting at from, and up to to
-                 *  (require from <= to unless to == kBadStingIndex). If to is kBadIndex (default)
-                 *  then return all the way to the end of the string.
+                 *  Produce a substring of this string, starting at 'from', and up to 'to' (or end of string
+                 *  for one-arg overload).
                  *
                  *  *NB* This function treats the second argument differntly than String::substr () -
                  *  which respects the STL basic_string API. This function treats the second argument
@@ -554,10 +553,11 @@
                  *  very common cases of substr(N) - because second argument is defaulted, and,
                  *  substr (0, N) - because then the count and end are the same.
                  *
-                 *  \req  ((from <= to) or (to == kBadIndex));
-                 *  \req  ((to <= GetLength ()) or (to == kBadIndex));
+                 *  \req  (from <= to);
+                 *  \req  (to <= GetLength ());     // for 2-arg variant
                  *
                  *  @see substr
+                 *  @see CircustlarSubString
                  */
                 nonvirtual  String      SubString (size_t from) const;
                 nonvirtual  String      SubString (size_t from, size_t to) const;


Fix for lame clients

Fix for lame clients

--- src/core/surface/channel.c
+++ src/core/surface/channel.c
@@ -148,7 +148,8 @@
     }
   }

-  if (channel->is_client && channel->default_authority == NULL) {
+  if (channel->is_client && channel->default_authority == NULL &&
+      target != NULL) {
     char *default_authority = grpc_get_default_authority(target);
     if (default_authority) {
       channel->default_authority = grpc_mdelem_from_strings(


pca cleanup

pca cleanup

--- src/c/wahbm.c
+++ src/c/wahbm.c
@@ -36,7 +36,6 @@
     return tab32[(uint32_t)(value*0x07C4ACDD) >> 27];
 }

-
 // wahbm
 //{{{ struct wah_file init_wahbm_file(char *file_name)
 struct wah_file init_wahbm_file(char *file_name)
@@ -69,6 +68,7 @@
 }
 //}}}

+//{{{ uint32_t wahbm_pca_by_name(char *in, char *out)
 uint32_t wahbm_pca_by_name(char *in, char *out)
 {

@@ -116,8 +116,6 @@
         x_2_sc = wah_in_place_or(x_2_c, max_wah_size, i_2, i_2_s);

         for (j = i+1; j < wf.num_records; ++j) {
-            //fprintf(stderr, "i:%u\tj:%u\n", i, j);
-            //fprintf(stderr, "i:%u\tj:%u\t", i, j);
             memcpy(x_0, x_0_c, x_0_sc * sizeof(uint32_t));
             memcpy(x_1, x_1_c, x_1_sc * sizeof(uint32_t));
             memcpy(x_2, x_2_c, x_2_sc * sizeof(uint32_t));
@@ -125,57 +123,15 @@
             x_1_s = x_1_sc;
             x_2_s = x_2_sc;

-            /*
-            for (k = 0; k < x_0_s; ++k)
-                fprintf(stderr, "%u ", x_0[k]);
-            fprintf(stderr, "\n");
-            for (k = 0; k < x_1_s; ++k)
-                fprintf(stderr, "%u ", x_1[k]);
-            fprintf(stderr, "\n");
-            for (k = 0; k < x_2_s; ++k)
-                fprintf(stderr, "%u ", x_2[k]);
-            fprintf(stderr, "\n--\n");
-            */
-
-
-
             //load in the jth record
             j_0_s = get_wah_bitmap_in_place(wf, j, 0, &j_0);
             j_1_s = get_wah_bitmap_in_place(wf, j, 1, &j_1);
             j_2_s = get_wah_bitmap_in_place(wf, j, 2, &j_2);
             //find the xor of all 4
-
-            /*
-            for (k = 0; k < j_0_s; ++k)
-                fprintf(stderr, "%u ", j_0[k]);
-            fprintf(stderr, "\n");
-            for (k = 0; k < j_1_s; ++k)
-                fprintf(stderr, "%u ", j_1[k]);
-            fprintf(stderr, "\n");
-            for (k = 0; k < j_2_s; ++k)
-                fprintf(stderr, "%u ", j_2[k]);
-            fprintf(stderr, "\n--\n");
-            */
-
-

             x_0_s =  wah_in_place_xor(x_0, x_0_s, j_0, j_0_s);
             x_1_s =  wah_in_place_xor(x_1, x_1_s, j_1, j_1_s);
             x_2_s =  wah_in_place_xor(x_2, x_2_s, j_2, j_2_s);
-
-
-            /*
-            for (k = 0; k < x_0_s; ++k)
-                fprintf(stderr, "%u ", x_0[k]);
-            fprintf(stderr, "\n");
-            for (k = 0; k < x_1_s; ++k)
-                fprintf(stderr, "%u ", x_1[k]);
-            fprintf(stderr, "\n");
-            for (k = 0; k < x_2_s; ++k)
-                fprintf(stderr, "%u ", x_2[k]);
-            fprintf(stderr, "\n");
-            */
-

             memcpy(t, x_0, x_0_s * sizeof(uint32_t));
             t_s = x_0_s;
@@ -190,22 +146,19 @@
             i_to_j_d = 0;
             for (k = 0; k < x_0_s; ++k)
                 i_to_j_d += popcount(x_0[k]);
-                //i_to_j_d += x_0[k];
             for (k = 0; k < x_2_s; ++k)
                 i_to_j_d += popcount(x_2[k])*4;
-                //i_to_j_d += x_2[k];
-
-            //fprintf(stderr, "%u\n", i_to_j_d);
-            if (j!=0)
+
+            if (j!=i+1)
                 printf("\t");
             printf("%f", ((float)i_to_j_d)/((float)wf.num_fields));
-            printf("%f", ((float)i_to_j_d)/((float)wf.num_fields));
         }
         printf("\n");
     }

     return 0;
 }
+//}}}

 //{{{ uint32_t print_wahbm(struct wah_file wf,
 uint32_t print_wahbm(struct wah_file wf,


crazy but appear to have to disable deprecation warnings on declaration of deprecated Finally class for gcc

--- Library/Sources/Stroika/Foundation/Execution/Finally.h
+++ Library/Sources/Stroika/Foundation/Execution/Finally.h
@@ -45,6 +45,7 @@
              *              Thread::SuppressInterruptionInContext suppressThreadInterupts;
              *          in the function body
              */
+            DISABLE_COMPILER_GCC_WARNING_START("GCC diagnostic ignored \"[-Wdeprecated-declarations\"");
             class   _Deprecated_("Finally NOW DEPRECATED - USE mkFinally (soon to be replaced with again Finally, but now function)") Finally {
             public:
                 Finally (const function<void()>& cleanupCodeBlock);
@@ -62,6 +63,7 @@
             private:
                 function<void()> fCleanupCodeBlock_;
             };
+            DISABLE_COMPILER_GCC_WARNING_END("GCC diagnostic ignored \"[-Wdeprecated-declarations\"");

             /**


Add assertion for array comparison

Add assertion for array comparison

--- src/test/cpp/JUnitUtils.h
+++ src/test/cpp/JUnitUtils.h
@@ -82,4 +82,12 @@
 }
 #define JUNIT_ASSERT_EQUALS_STRING(_E, _R) _JUNIT_ASSERT_EQUALS_STRING(_E, _R, __FILE__, __LINE__)

+#define _JUNIT_ASSERT_EQUALS_ARRAY(_EXPECTED, _RESULT, _SIZE, _FILE, _LINE) { \
+  if (memcmp(_EXPECTED, _RESULT, _SIZE) != 0) { \
+    JavaExceptionUtils::throwExceptionOfType(env, kTypeJavaAssertion, \
+      "(at %s:%d)", _FILE, _LINE); \
+  } \
+}
+#define JUNIT_ASSERT_EQUALS_ARRAY(_E, _R, _S) _JUNIT_ASSERT_EQUALS_ARRAY(_E, _R, _S, __FILE__, __LINE__)
+
 #endif // __JUnitUtils_h__


Emit .macosx_version_min in object files

This is intended to remove warnings such as:
ld: warning: object file (path/to/temp/file.o) was built for newer OSX version (10.13) than being linked (10.11)

Version minimum chosen from the version used in
d19c42767876bf3d0fb1f62ea317a0757d0fa688, which was the first
introduction of passing -macosx_version_min to the Darwin linker.

--- src/cc1/cc1.c
+++ src/cc1/cc1.c
@@ -40,6 +40,11 @@
 #include "../config_as.h"

 static const char **system_includes;
+
+struct version
+{
+	int maj, min;
+};

 static struct
 {
@@ -228,10 +233,21 @@
 	return platform_sys() == PLATFORM_LINUX;
 }

+static int should_emit_macosx_version_min(struct version *const min)
+{
+	if(platform_sys() != PLATFORM_DARWIN)
+		return 0;
+
+	min->maj = 10;
+	min->min = 5;
+	return 1;
+}
+
 static void io_fin(int do_sections, const char *fname)
 {
 	const int execstack = 0;
 	int i;
+	struct version macosx_version_min;

 	(void)fname;

@@ -276,6 +292,15 @@
 			execstack ? "x" : "") < 0)
 	{
 		ccdie(0, "write to cc1 output:");
+	}
+
+	if(should_emit_macosx_version_min(&macosx_version_min)
+	&& fprintf(cc1_out,
+		".macosx_version_min %d, %d\n",
+		macosx_version_min.maj,
+		macosx_version_min.min) < 0)
+	{
+		ccdie("write to cc1 output:");
 	}

 	if(fclose(cc1_out))


Disabled signed/unsigned warning by default

--- src/cc1/cc1.c
+++ src/cc1/cc1.c
@@ -124,6 +124,7 @@
 		| WARN_INCOMPLETE_USE
 		| WARN_OPT_POSSIBLE
 		| WARN_LOSS_PRECISION
+		| WARN_SIGN_COMPARE
 		);

 enum fopt    fopt_mode = FOPT_CONST_FOLD | FOPT_SHOW_LINE | FOPT_PIC;


Fix memory leak of job

Fix memory leak of job

--- src/choices.c
+++ src/choices.c
@@ -241,6 +241,7 @@

 	pthread_mutex_destroy(&job->lock);
 	free(workers);
+	free(job);

 	if(*search) {
 		qsort(c->results, c->available, sizeof(struct scored_result), cmpchoice);


daemon: always name GSources

daemon: always name GSources

Signed-off-by: Marc-Antoine Perennou <07f76cf0511c79b361712839686f3cee8c75791c@Perennou.com>

--- src/daemon/gpaste-daemon.c
+++ src/daemon/gpaste-daemon.c
@@ -159,12 +159,12 @@
     };

 #ifdef G_OS_UNIX
-    g_unix_signal_add (SIGTERM, signal_handler, app);
-    g_unix_signal_add (SIGINT,  signal_handler, app);
+    g_source_set_name_by_id (g_unix_signal_add (SIGTERM, signal_handler, app), "[GPaste] SIGTERM listener");
+    g_source_set_name_by_id (g_unix_signal_add (SIGINT,  signal_handler, app), "[GPaste] SIGINT listener");

     Usr1Data usr1_data = { g_paste_daemon, gapp };

-    g_unix_signal_add (SIGUSR1, usr1_handler, &usr1_data);
+    g_source_set_name_by_id (g_unix_signal_add (SIGUSR1, usr1_handler, &usr1_data), "[GPaste] SIGUSR1 listener");
 #endif

     g_paste_bus_own_name (bus);


Used ltlv_nb_chunk function instead of computing it.

--- src/cli/cli.c
+++ src/cli/cli.c
@@ -367,13 +367,10 @@
         for (int i = 0; i <= indent; i++) {
                 printf("--");
         }
-
+
         printf(" @[%10li]: %8s (%d bytes)\n",
                 dz_get_offset(dz), tlv_type2str(type), len);
-        return len
-                + (len / TLV_MAX_VALUE_SIZE
-                        + MIN(1, len % TLV_MAX_VALUE_SIZE))
-                * TLV_SIZEOF_HEADER;
+        return len + ltlv_nb_chunks(len) * TLV_SIZEOF_HEADER;
 }

 int cli_print_all_tlv(dz_t *dz, int indent, int lvl, int debug) {


Add include guards to Graphics MockObjects.h.

--- SurgSim/Graphics/UnitTests/MockObjects.h
+++ SurgSim/Graphics/UnitTests/MockObjects.h
@@ -12,6 +12,9 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
+
+#ifndef SURGSIM_GRAPHICS_UNITTESTS_MOCKOBJECTS_H
+#define SURGSIM_GRAPHICS_UNITTESTS_MOCKOBJECTS_H

 #include "SurgSim/Math/Vector.h"
 #include "SurgSim/Graphics/Actor.h"
@@ -510,4 +513,6 @@
 	bool m_isInitialized;
 	/// Whether the view has been awoken
 	bool m_isAwoken;
-};+};
+
+#endif  // SURGSIM_GRAPHICS_UNITTESTS_MOCKOBJECTS_H