From Ivana:
- added new function AddParticles() (with default dummy implementation)
- added default implementation to TrackingRmax(), TrackingZmax()

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@7331 27541ba8-7e3a-0410-8455-c3a389f83636

--- vmc/inc/TVirtualMCApplication.h
+++ vmc/inc/TVirtualMCApplication.h
@@ -1,4 +1,4 @@
-// @(#)root/vmc:$Name:  $:$Id: TVirtualMCApplication.h,v 1.4 2002/04/26 08:46:10 brun Exp $
+// @(#)root/vmc:$Name:  $:$Id: TVirtualMCApplication.h,v 1.1 2003/07/15 09:56:58 brun Exp $
 // Author: Ivana Hrivnacova, 23/03/2002

 #ifndef ROOT_TVirtualMCApplication
@@ -24,6 +24,7 @@
     // methods
     virtual void ConstructGeometry() = 0;
     virtual void InitGeometry() = 0;
+    virtual void AddParticles() {}
     virtual void GeneratePrimaries() = 0;
     virtual void BeginEvent() = 0;
     virtual void BeginPrimary() = 0;
@@ -33,8 +34,8 @@
     virtual void FinishPrimary() = 0;
     virtual void FinishEvent() = 0;

-    virtual Double_t TrackingRmax() const = 0;
-    virtual Double_t TrackingZmax() const = 0;
+    virtual Double_t TrackingRmax() const { return DBL_MAX; }
+    virtual Double_t TrackingZmax() const { return DBL_MAX; }
     virtual void     Field(const Double_t* x, Double_t* b) const = 0;

   private:


ui-window: Properly convert PangoFontDescription to CSS

Using pango_font_description_to_string() as a value for the CSS font:
property is deprecated. Instead, convert the PangoFontDescription to the
correct series of CSS properties.

--- libchimara/ui-window.c
+++ libchimara/ui-window.c
@@ -74,6 +74,83 @@
 		ui_graphics_clear(win);
 }

+static const char *
+enum_value_get_nick(GType enum_type, unsigned value)
+{
+	GEnumClass *enum_class = g_type_class_ref(enum_type);
+	GEnumValue *enum_value = g_enum_get_value(enum_class, value);
+	const char *retval = enum_value->value_nick;
+	g_type_class_unref(enum_class);
+	return retval;
+}
+
+static char *
+pango_font_description_to_css(PangoFontDescription *font)
+{
+	GString *builder = g_string_new("*{");
+	PangoFontMask mask = pango_font_description_get_set_fields(font);
+
+	if (mask & PANGO_FONT_MASK_FAMILY)
+		g_string_append_printf(builder, "font-family: %s;",
+			pango_font_description_get_family(font));
+
+	if (mask & PANGO_FONT_MASK_SIZE) {
+		int size = pango_font_description_get_size(font) / PANGO_SCALE;
+		const char *unit = pango_font_description_get_size_is_absolute(font)? "pt" : "px";
+		g_string_append_printf(builder, "font-size: %d%s;", size, unit);
+	}
+
+	if (mask & PANGO_FONT_MASK_STYLE) {
+		PangoStyle style = pango_font_description_get_style(font);
+		g_string_append_printf(builder, "font-style: %s;",
+			enum_value_get_nick(PANGO_TYPE_STYLE, style));
+	}
+
+	if (mask & PANGO_FONT_MASK_VARIANT) {
+		PangoVariant variant = pango_font_description_get_variant(font);
+		g_string_append_printf(builder, "font-variant: %s;",
+			enum_value_get_nick(PANGO_TYPE_VARIANT, variant));
+	}
+
+	if (mask & PANGO_FONT_MASK_WEIGHT) {
+		PangoWeight weight = pango_font_description_get_weight(font);
+		unsigned val;
+		/* CSS weights do not quite correspond to Pango weights */
+		switch (weight) {
+		case PANGO_WEIGHT_THIN:
+		case PANGO_WEIGHT_ULTRALIGHT:
+		case PANGO_WEIGHT_LIGHT:
+		case PANGO_WEIGHT_NORMAL:
+		case PANGO_WEIGHT_MEDIUM:
+		case PANGO_WEIGHT_SEMIBOLD:
+		case PANGO_WEIGHT_BOLD:
+		case PANGO_WEIGHT_ULTRABOLD:
+		case PANGO_WEIGHT_HEAVY:
+			val = weight;
+			break;
+		case PANGO_WEIGHT_SEMILIGHT:
+		case PANGO_WEIGHT_BOOK:
+			val = 400;
+			break;
+		case PANGO_WEIGHT_ULTRAHEAVY:
+			val = 900;
+			break;
+		default:
+			val = CLAMP(weight - (weight % 100), 100, 900);
+		}
+		g_string_append_printf(builder, "font-weight: %u;", val);
+	}
+
+	if (mask & PANGO_FONT_MASK_STRETCH) {
+		PangoStretch stretch = pango_font_description_get_stretch(font);
+		g_string_append_printf(builder, "font-stretch: %s;",
+			enum_value_get_nick(PANGO_TYPE_STRETCH, stretch));
+	}
+
+	g_string_append_c(builder, '}');
+	return g_string_free(builder, FALSE);
+}
+
 void
 ui_window_override_font(winid_t win, GtkWidget *widget, PangoFontDescription *font)
 {
@@ -85,16 +162,16 @@
 		win->font_override = gtk_css_provider_new();
 	}

-	char *font_string = pango_font_description_to_string(font);
-	char *css = g_strdup_printf("*{ font: %s; }", font_string);
+	char *css = pango_font_description_to_css(font);

 	GError *error = NULL;
 	if (!gtk_css_provider_load_from_data(win->font_override, css, -1, &error)) {
+		char *font_string = pango_font_description_to_string(font);
 		g_critical("Error overriding font to %s: %s", font_string, error->message);
+		g_free(font_string);
 		g_clear_error(&error);
 	}

-	g_free(font_string);
 	g_free(css);

 	gtk_style_context_add_provider(style, GTK_STYLE_PROVIDER(win->font_override),


Add ADC for temp sensor

Add ADC for temp sensor

--- ports/stm32f4/common-hal/microcontroller/Processor.c
+++ ports/stm32f4/common-hal/microcontroller/Processor.c
@@ -3,7 +3,6 @@
  *
  * The MIT License (MIT)
  *
- * Copyright (c) 2017 Dan Halbert for Adafruit Industries
  * Copyright (c) 2019 Lucian Copeland for Adafruit Industries
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -34,11 +33,100 @@

 #define STM32_UUID ((uint32_t *)0x1FFF7A10)

+//Factory calibration locations
+#define ADC_CAL_ADDRESS         (0x1fff7a2a)
+#define ADC_CAL1                ((uint16_t*)(ADC_CAL_ADDRESS + 2))
+#define ADC_CAL2                ((uint16_t*)(ADC_CAL_ADDRESS + 4))
+
+// correction factor for reference value
+STATIC volatile float adc_refcor = 1.0f;
+
+#define CORE_TEMP_V25          (943)  /* (0.76v/3.3v)*(2^ADC resoultion) */
+#define CORE_TEMP_AVG_SLOPE    (3)    /* (2.5mv/3.3v)*(2^ADC resoultion) */
+
 float common_hal_mcu_processor_get_temperature(void) {
-    return NAN;
+    __HAL_RCC_ADC1_CLK_ENABLE();
+
+    //HAL Implementation
+    ADC_HandleTypeDef AdcHandle;
+    ADC_ChannelConfTypeDef sConfig;
+
+    AdcHandle.Instance = ADC1;
+    AdcHandle.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
+    AdcHandle.Init.Resolution = ADC_RESOLUTION_12B;
+    AdcHandle.Init.ScanConvMode = DISABLE;
+    AdcHandle.Init.ContinuousConvMode = DISABLE;
+    AdcHandle.Init.DiscontinuousConvMode = DISABLE;
+    AdcHandle.Init.NbrOfDiscConversion = 0;
+    AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
+    AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START;
+    AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT;
+    AdcHandle.Init.NbrOfConversion = 1;
+    AdcHandle.Init.DMAContinuousRequests = DISABLE;
+    AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
+    HAL_ADC_Init(&AdcHandle);
+
+    ADC->CCR |= ADC_CCR_TSVREFE;
+    ADC->CCR &= ~ADC_CCR_VBATE; // If this somehow got turned on, it'll return bad values.
+
+    sConfig.Channel = ADC_CHANNEL_TEMPSENSOR; //either 16 or 18, depending on chip
+    sConfig.Rank = 1;
+    sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES; //Taken from micropython
+    HAL_ADC_ConfigChannel(&AdcHandle, &sConfig);
+
+    HAL_ADC_Start(&AdcHandle);
+    if (HAL_ADC_PollForConversion(&AdcHandle,1) != HAL_OK) {
+        mp_raise_RuntimeError(translate("Temperature read timed out"));
+    }
+    uint32_t value = (uint32_t)HAL_ADC_GetValue(&AdcHandle);
+    HAL_ADC_Stop(&AdcHandle);
+
+    //There's no F4 specific appnote for this but it works the same as the L1 in AN3964
+    float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0;
+    return (((float)value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f;
+
+    // STATIC uint32_t adc_config_and_read_channel(ADC_HandleTypeDef *adcHandle, uint32_t channel) {
+    // adc_config_channel(adcHandle, channel);
+    // uint32_t raw_value = adc_read_channel(adcHandle);
+
+    // #if defined(STM32F4) || defined(STM32F7)
+    // // ST docs say that (at least on STM32F42x and STM32F43x), VBATE must
+    // // be disabled when TSVREFE is enabled for TEMPSENSOR and VREFINT
+    // // conversions to work.  VBATE is enabled by the above call to read
+    // // the channel, and here we disable VBATE so a subsequent call for
+    // // TEMPSENSOR or VREFINT works correctly.
+    // if (channel == ADC_CHANNEL_VBAT) {
+    //     ADC->CCR &= ~ADC_CCR_VBATE;
+    // }
+    // #endif
+
+    // return raw_value;
+
+    //     int adc_read_core_temp(ADC_HandleTypeDef *adcHandle) {
+    //     int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR);
+    //     return ((raw_value - CORE_TEMP_V25) / CORE_TEMP_AVG_SLOPE) + 25;
+    // }
+
+    // #if MICROPY_PY_BUILTINS_FLOAT
+    // // correction factor for reference value
+    // STATIC volatile float adc_refcor = 1.0f;
+
+    // float adc_read_core_temp_float(ADC_HandleTypeDef *adcHandle) {
+    //     int32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_TEMPSENSOR);
+    //     float core_temp_avg_slope = (*ADC_CAL2 - *ADC_CAL1) / 80.0;
+    //     return (((float)raw_value * adc_refcor - *ADC_CAL1) / core_temp_avg_slope) + 30.0f;
+    // }
 }

 float common_hal_mcu_processor_get_voltage(void) {
+//  float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) {
+//     uint32_t raw_value = adc_config_and_read_ref(adcHandle, ADC_CHANNEL_VREFINT);
+
+//     // update the reference correction factor
+//     adc_refcor = ((float)(*VREFIN_CAL)) / ((float)raw_value);
+
+//     return (*VREFIN_CAL) * ADC_SCALE;
+// }
     return NAN;
 }


added leading SYS for own lemonbar-parser

--- i3status.c
+++ i3status.c
@@ -566,6 +566,8 @@
         else if (output_format == O_TERM)
             /* Restore the cursor-position, clear line */
             printf("\033[u\033[K");
+        else if (output_format == O_NONE)
+            printf("SYS ");
         for (j = 0; j < cfg_size(cfg, "order"); j++) {
             cur_instance = per_instance + j;
             if (j > 0)


make sure tunnelID is non-zero

make sure tunnelID is non-zero

--- libi2pd/TunnelConfig.h
+++ libi2pd/TunnelConfig.h
@@ -35,6 +35,7 @@
 			RAND_bytes (replyKey, 32);
 			RAND_bytes (replyIV, 16);
 			RAND_bytes ((uint8_t *)&tunnelID, 4);
+			if (!tunnelID) tunnelID = 1; // tunnelID can't be zero
 			isGateway = true;
 			isEndpoint = true;
 			ident = r;
@@ -50,6 +51,7 @@
 			nextIdent = ident;
 			isEndpoint = false;
 			RAND_bytes ((uint8_t *)&nextTunnelID, 4);
+			if (!nextTunnelID) nextTunnelID = 1; // tunnelID can't be zero
 		}

 		void SetReplyHop (uint32_t replyTunnelID, const i2p::data::IdentHash& replyIdent)


prototype was wrong, change not tested

prototype was wrong, change not tested

--- libm/powerpc/w_scalb.c
+++ libm/powerpc/w_scalb.c
@@ -52,7 +52,11 @@
 ***********************************************************************/

 libm_hidden_proto(scalb)
+#ifdef _SCALB_INT
 double scalb ( double x, int n  )
+#else
+double scalb ( double x, double n  )
+#endif
       {
       DblInHex xInHex;


Make valgrind happier

Make valgrind happier

--- input-grapes.c
+++ input-grapes.c
@@ -31,6 +31,7 @@
   struct timeval tv;
   char cfg[256];

+  memset(cfg, 0, 256);
   res = malloc(sizeof(struct input_desc));
   if (res == NULL) {
     return NULL;


block: rename uniform to variable

block: rename uniform to variable

--- libnodegl/node_block.c
+++ libnodegl/node_block.c
@@ -173,10 +173,10 @@
     }
 }

-static int is_dynamic_uniform(const struct ngl_node *unode)
-{
-    const struct variable_info *uniform = unode->priv_data;
-    return uniform->dynamic;
+static int is_dynamic_variable(const struct ngl_node *vnode)
+{
+    const struct variable_info *variable = vnode->priv_data;
+    return variable->dynamic;
 }

 static int is_dynamic_buffer(const struct ngl_node *bnode)
@@ -199,7 +199,7 @@

 static int field_is_dynamic(const struct ngl_node *node, const struct block_field *fi)
 {
-    return fi->count ? is_dynamic_buffer(node) : is_dynamic_uniform(node);
+    return fi->count ? is_dynamic_buffer(node) : is_dynamic_variable(node);
 }

 static const uint8_t *get_data_ptr(const struct ngl_node *node, const struct block_field *fi)


Fix a bogus static analyzer bug.

Fix a bogus static analyzer bug.

--- if-linux.c
+++ if-linux.c
@@ -367,6 +367,7 @@
 				goto eexit;
 			buf = nbuf;
 		}
+		nladdr.nl_pid = 0; /* XXX clang static analyzer bug? */
 		nladdr_len = sizeof(nladdr);
 		bytes = recvfrom(fd, buf, buflen, flags,
 		    (struct sockaddr *)&nladdr, &nladdr_len);


Use the new xsocket function on Linux as well.

--- if-linux.c
+++ if-linux.c
@@ -249,28 +249,12 @@
 }

 static int
-_open_link_socket(struct sockaddr_nl *nl, int flags, int protocol)
+_open_link_socket(struct sockaddr_nl *nl, int protocol)
 {
 	int fd;

-#ifdef SOCK_CLOEXEC
-	if (flags)
-		flags = SOCK_CLOEXEC;
-	fd = socket(AF_NETLINK, SOCK_RAW | flags, protocol);
-	if (fd == -1)
-		return -1;
-#else
-	fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
-	if (fd == -1)
-		return -1;
-	if (flags &&
-	    (flags = fcntl(fd, F_GETFD, 0)) == -1 ||
-	    fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
-	{
-		close(fd);
-	        return -1;
-	}
-#endif
+	if ((fd = xsocket(AF_NETLINK, SOCK_RAW, protocol, O_CLOEXEC)) == -1)
+		return -1;
 	nl->nl_family = AF_NETLINK;
 	if (bind(fd, (struct sockaddr *)nl, sizeof(*nl)) == -1) {
 		close(fd);
@@ -294,7 +278,7 @@
 	snl.nl_groups |= RTMGRP_IPV6_ROUTE | RTMGRP_IPV6_IFADDR | RTMGRP_NEIGH;
 #endif

-	return _open_link_socket(&snl, 1, NETLINK_ROUTE);
+	return _open_link_socket(&snl, NETLINK_ROUTE);
 }

 static int
@@ -889,7 +873,7 @@
 	static unsigned int seq;

 	memset(&snl, 0, sizeof(snl));
-	if ((s = _open_link_socket(&snl, 0, protocol)) == -1)
+	if ((s = _open_link_socket(&snl, protocol)) == -1)
 		return -1;
 	memset(&iov, 0, sizeof(iov));
 	iov.iov_base = hdr;
@@ -1201,28 +1185,10 @@
 	int n;
 #endif

-#ifdef SOCK_CLOEXEC
-	if ((s = socket(PF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
-	    htons(protocol))) == -1)
-		return -1;
-#else
-	int flags;
-
-	if ((s = socket(PF_PACKET, SOCK_DGRAM, htons(protocol))) == -1)
-		return -1;
-	if ((flags = fcntl(s, F_GETFD, 0)) == -1 ||
-	    fcntl(s, F_SETFD, flags | FD_CLOEXEC) == -1)
-	{
-		close(s);
-	        return -1;
-	}
-	if ((flags = fcntl(s, F_GETFL, 0)) == -1 ||
-	    fcntl(s, F_SETFL, flags | O_NONBLOCK) == -1)
-	{
-		close(s);
-	        return -1;
-	}
-#endif
+	if ((s = xsocket(PF_PACKET, SOCK_DGRAM, htons(protocol),
+	    O_CLOEXEC | O_NONBLOCK)) == -1)
+		return -1;
+
 	/* Install the DHCP filter */
 	memset(&pf, 0, sizeof(pf));
 	if (protocol == ETHERTYPE_ARP) {


IIOD: Correctly exit the R/W thread when the buffer creation fails

It was previously deadlocking on the "last_cond" condition variable,
which is only signaled when CLOSE is used, which never happens if OPEN
fails.

Signed-off-by: Paul Cercueil <73d292422978d45c9eeef455bb1b24a0db453722@analog.com>

--- iiod/ops.c
+++ iiod/ops.c
@@ -472,17 +472,19 @@
 		iio_buffer_destroy(entry->buf);
 	pthread_mutex_unlock(&devlist_lock);

-	/* Signal the last client that the device has been closed */
-	pthread_mutex_lock(&entry->last_lock);
-	pthread_cond_signal(&entry->last_cond);
-
-	/* And wait for the last client to give us back the lock,
-	 * so that we can destroy it... */
-	pthread_cond_wait(&entry->last_cond, &entry->last_lock);
-	pthread_mutex_unlock(&entry->last_lock);
+	if (ret >= 0) {
+		/* Signal the last client that the device has been closed */
+		pthread_mutex_lock(&entry->last_lock);
+		pthread_cond_signal(&entry->last_cond);
+
+		/* And wait for the last client to give us back the lock,
+		 * so that we can destroy it... */
+		pthread_cond_wait(&entry->last_cond, &entry->last_lock);
+		pthread_mutex_unlock(&entry->last_lock);
+	}
+
 	pthread_mutex_destroy(&entry->last_lock);
 	pthread_cond_destroy(&entry->last_cond);
-
 	pthread_mutex_destroy(&entry->thdlist_lock);
 	pthread_attr_destroy(&entry->attr);

@@ -651,10 +653,7 @@
 		/* Wait until the device is opened by the rw thread */
 		pthread_cond_wait(&thd->cond, &thd->cond_lock);
 		pthread_mutex_unlock(&thd->cond_lock);
-		ret = (int) thd->err;
-		if (ret < 0)
-			goto err_free_thd;
-		return 0;
+		return (int) thd->err;
 	}

 	entry = malloc(sizeof(*entry));
@@ -692,9 +691,7 @@
 	/* Wait until the device is opened by the rw thread */
 	pthread_cond_wait(&thd->cond, &thd->cond_lock);
 	pthread_mutex_unlock(&thd->cond_lock);
-	ret = (int) thd->err;
-	if (!ret)
-		return 0;
+	return (int) thd->err;

 err_free_entry_mask:
 	free(entry->mask);


commit memslab

commit memslab

--- imembase.c
+++ imembase.c
@@ -1626,7 +1626,9 @@
 	iqueue_head *p, *next;
 	ilong index;

-	assert(ikmem_inited);
+	if (ikmem_inited == 0) {
+		return;
+	}

 	imutex_lock(&ikmem_lock);
 	for (p = ikmem_head.next; p != &ikmem_head; ) {


Bluetooth: Fix refcount balance for hci connection

hci_io_capa_reply_evt() holds reference for hciconnection. It's useless since
hci_io_capa_request_evt()/hci_simple_pair_complete_evt() already protects the
connection. In addition it leaves connection open after failed SSP pairing.

Signed-off-by: Ville Tervo <e7cc8809cc2487d94b3e66a5681f7dffe13b8458@nokia.com>
Signed-off-by: Gustavo F. Padovan <8463bae6aa74c6c37654a5ac7ce3bbb9fe6ffff8@profusion.mobi>

--- net/bluetooth/hci_event.c
+++ net/bluetooth/hci_event.c
@@ -2387,8 +2387,6 @@
 	if (!conn)
 		goto unlock;

-	hci_conn_hold(conn);
-
 	conn->remote_cap = ev->capability;
 	conn->remote_oob = ev->oob_data;
 	conn->remote_auth = ev->authentication;


[BRIDGE]: Fix crash in __ip_route_output_key with bridge netfilter

The bridge netfilter code attaches a fake dst_entry with a pointer to a
fake net_device structure to skbs it passes up to IPv4 netfilter. This
leads to crashes when the skb is passed to __ip_route_output_key when
dereferencing the namespace pointer.

Since bridging can currently only operate in the init_net namespace,
the easiest fix for now is to initialize the nd_net pointer of the
fake net_device struct to &init_net.

Should fix bugzilla 10323: http://bugzilla.kernel.org/show_bug.cgi?id=10323

Signed-off-by: Patrick McHardy <3a4d625ce225e891399f98db96a382ac4a84080b@trash.net>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/bridge/br_netfilter.c
+++ net/bridge/br_netfilter.c
@@ -110,7 +110,8 @@
  * ipt_REJECT needs it.  Future netfilter modules might
  * require us to fill additional fields. */
 static struct net_device __fake_net_device = {
-	.hard_header_len	= ETH_HLEN
+	.hard_header_len	= ETH_HLEN,
+	.nd_net			= &init_net,
 };

 static struct rtable __fake_rtable = {


Plugin details fixes

Plugin details fixes

Original commit message from CVS:
Plugin details fixes

--- ext/dvdread/dvdreadsrc.c
+++ ext/dvdread/dvdreadsrc.c
@@ -89,6 +89,7 @@
 GstElementDetails dvdreadsrc_details = {
   "DVD Source",
   "Source/File/DVD",
+  "LGPL",
   "Access a DVD title/chapter/angle using libdvdread",
   VERSION,
   "Erik Walthinsen <omega@cse.ogi.edu>",


Implement a custom trampoline for x86_64, resulting in roughly 30% speedup

--- ext/ffi_c/MethodHandle.c
+++ ext/ffi_c/MethodHandle.c
@@ -91,6 +91,12 @@
 typedef void (*methodfn)(ffi_cif* cif, void* retval, METHOD_PARAMS parameters, void* user_data);
 static void attached_method_fast_invoke(ffi_cif* cif, void* retval, METHOD_PARAMS parameters, void* user_data);
 static void attached_method_invoke(ffi_cif* cif, void* retval, METHOD_PARAMS parameters, void* user_data);
+static ffi_status prep_trampoline(MethodHandle* method, char* errmsg, size_t errmsgsize);
+static int trampoline_size(void);
+
+#if defined(__x86_64__) && defined(__GNUC__)
+# define CUSTOM_TRAMPOLINE 1
+#endif

 struct MethodHandle {
     FunctionType* info;
@@ -110,14 +116,7 @@
     MethodHandle* list;
 };

-static ffi_type* methodHandleParamTypes[] = {
-    &ffi_type_sint,
-    &ffi_type_pointer,
-    &ffi_type_ulong,
-};
-
 static MethodHandlePool defaultMethodHandlePool, fastMethodHandlePool;
-
 static int pageSize;

@@ -127,8 +126,7 @@
     MethodHandle* method, *list = NULL;
     MethodHandlePool* pool;
     caddr_t page;
-    ffi_status ffiStatus;
-    int nclosures, closureSize;
+    int nclosures, trampolineSize;
     int i, arity;

     arity = fnInfo->parameterCount;
@@ -154,8 +152,8 @@
         return method;
     }

-    closureSize = roundup(sizeof(METHOD_CLOSURE), 8);
-    nclosures = pageSize / closureSize;
+    trampolineSize = roundup(trampoline_size(), 8);
+    nclosures = pageSize / trampolineSize;
     page = allocatePage();
     if (page == NULL) {
         pool_unlock(pool);
@@ -172,24 +170,12 @@
         method->next = list;
         list = method;
         method->pool = pool;
-        method->code = method->closure = (METHOD_CLOSURE *) (page + (i * closureSize));
-
-        ffiStatus = ffi_prep_cif(&method->cif, FFI_DEFAULT_ABI, 3, &ffi_type_ulong,
-                    methodHandleParamTypes);
-        if (ffiStatus != FFI_OK) {
-            snprintf(errmsg, sizeof(errmsg), "ffi_prep_cif failed.  status=%#x", ffiStatus);
+        method->code = method->closure = (METHOD_CLOSURE *) (page + (i * trampolineSize));
+
+        if (prep_trampoline(method, errmsg, sizeof(errmsg)) != FFI_OK) {
             goto error;
         }
-
-#ifdef USE_RAW
-        ffiStatus = ffi_prep_raw_closure(method->closure, &method->cif, pool->fn, method);
-#else
-        ffiStatus = ffi_prep_closure(method->closure, &method->cif, pool->fn, method);
-#endif
-        if (ffiStatus != FFI_OK) {
-            snprintf(errmsg, sizeof(errmsg), "ffi_prep_closure failed.  status=%#x", ffiStatus);
-            goto error;
-        }
+
         continue;
 error:
         while (list != NULL) {
@@ -237,6 +223,44 @@
     return handle->code;
 }

+#ifndef CUSTOM_TRAMPOLINE
+
+static ffi_type* methodHandleParamTypes[] = {
+    &ffi_type_sint,
+    &ffi_type_pointer,
+    &ffi_type_ulong,
+};
+
+static ffi_status
+prep_trampoline(MethodHandle* method, char* errmsg, size_t errmsgsize)
+{
+    ffi_status ffiStatus = ffi_prep_cif(&method->cif, FFI_DEFAULT_ABI, 3, &ffi_type_ulong,
+            methodHandleParamTypes);
+    if (ffiStatus != FFI_OK) {
+        snprintf(errmsg, errmsgsize, "ffi_prep_cif failed.  status=%#x", ffiStatus);
+        return ffiStatus;
+    }
+
+#if defined(USE_RAW)
+    ffiStatus = ffi_prep_raw_closure(method->closure, &method->cif, method->pool->fn, method);
+#else
+    ffiStatus = ffi_prep_closure(method->closure, &method->cif, method->pool->fn, method);
+#endif
+    if (ffiStatus != FFI_OK) {
+        snprintf(errmsg, errmsgsize, "ffi_prep_closure failed.  status=%#x", ffiStatus);
+        return ffiStatus;
+    }
+
+    return FFI_OK;
+}
+
+static int
+trampoline_size(void)
+{
+    return sizeof(METHOD_CLOSURE);
+}
+
+#endif
 /*
  * attached_method_invoke is used as the <= MAX_METHOD_FIXED_ARITY argument fixed-arity fast path
  */
@@ -297,6 +321,91 @@
     *(VALUE *) mretval = rbffi_CallFunction(argc, argv, handle->function, handle->info);
 }

+#if defined(__x86_64__) && defined(CUSTOM_TRAMPOLINE)
+/*
+ * This is a hand-coded trampoline to speedup entry from ruby to the FFI translation
+ * layer for x86_64 arches.
+ *
+ * Since a ruby function has exactly 3 arguments, and the first 6 arguments are
+ * passed in registers for x86_64, we can tack on a context pointer by simply
+ * putting a value in %rcx, then jumping to the C trampoline code.
+ *
+ * This results in approx a 30% speedup for x86_64 FFI dispatch
+ */
+asm(
+    ".text\n\t"
+    ".globl ffi_trampoline\n\t"
+    ".type   ffi_trampoline, @function\n\t"
+    "ffi_trampoline:\n\t"
+    "movabsq $0xfee1deadcafebabe, %rcx\n\t"
+    "movabsq $0xfee1deadcafebabe, %r11\n\t"
+    "jmp *%r11\n\t"
+    ".globl ffi_trampoline_end\n\t"
+    "ffi_trampoline_end:\n\t"
+);
+
+extern void ffi_trampoline(int argc, VALUE* argv, VALUE self);
+extern void ffi_trampoline_end(void);
+
+#define X86_64_MAGIC (0xfee1deadcafebabe)
+static int x86_64_offsets(int *, int *);
+static VALUE x86_64_trampoline(int argc, VALUE* argv, VALUE self, MethodHandle*);
+static int x86_64_ctx_offset, x86_64_tramp_offset;
+
+static int
+x86_64_offset(int off) {
+    caddr_t ptr;
+    for (ptr = (caddr_t) &ffi_trampoline + off; ptr < (caddr_t) &ffi_trampoline_end; ++ptr) {
+        if (*(long *) ptr == X86_64_MAGIC) {
+            return ptr - (caddr_t) &ffi_trampoline;
+        }
+    }
+    return -1;
+}
+
+static int
+x86_64_offsets(int* ctxOffset, int* fnOffset)
+{
+    *ctxOffset = x86_64_offset(0);
+    if (*ctxOffset == -1) {
+        return -1;
+    }
+
+    *fnOffset = x86_64_offset(*ctxOffset + 8);
+    if (*fnOffset == -1) {
+        return -1;
+    }
+
+    return 0;
+}
+
+static VALUE
+x86_64_trampoline(int argc, VALUE* argv, VALUE self, MethodHandle* handle)
+{
+    return rbffi_CallFunction(argc, argv, handle->function, handle->info);
+}
+
+static ffi_status
+prep_trampoline(MethodHandle* method, char* errmsg, size_t errmsgsize)
+{
+    caddr_t ptr = (caddr_t) method->code;
+
+    memcpy(ptr, &ffi_trampoline, trampoline_size());
+    // Patch the context and function addresses into the stub code
+    *(long *)(ptr + x86_64_ctx_offset) = (long) method;
+    *(long *)(ptr + x86_64_tramp_offset) = (long) x86_64_trampoline;
+
+    return FFI_OK;
+}
+
+static int
+trampoline_size(void)
+{
+    return (caddr_t) &ffi_trampoline_end - (caddr_t) &ffi_trampoline;
+}
+
+#endif
+
 static int
 getPageSize()
 {
@@ -352,5 +461,11 @@
 #endif /* USE_PTHREAD_LOCAL */
     defaultMethodHandlePool.fn = attached_method_invoke;
     fastMethodHandlePool.fn = attached_method_fast_invoke;
-}
-
+
+#if defined(__x86_64__) && defined(CUSTOM_TRAMPOLINE)
+    if (x86_64_offsets(&x86_64_ctx_offset, &x86_64_tramp_offset) != 0) {
+        rb_raise(rb_eFatal, "Could not locate offsets in x86_64 trampoline code");
+    }
+#endif
+}
+


Add Connection#socket_fd method

Add Connection#socket_fd method

--- ext/libdbus/connection.c
+++ ext/libdbus/connection.c
@@ -223,6 +223,18 @@
   return Qnil;
 }

+static VALUE
+m_socket_fd(VALUE self)
+{
+  int fd;
+
+  if (dbus_connection_get_socket(unwrap_connection(self), &fd)) {
+    return INT2NUM(fd);
+  } else {
+    return Qnil;
+  }
+}
+
 void
 Init_libdbus_connection(VALUE mLibDBus)
 {
@@ -238,4 +250,5 @@
   rb_define_method(cConnection, "request_name", m_request_name, 1);
   rb_define_method(cConnection, "register_object_path", m_register_object_path, 1);
   rb_define_method(cConnection, "read_write_dispatch", m_read_write_dispatch, 1);
-}
+  rb_define_method(cConnection, "socket_fd", m_socket_fd, 0);
+}


Backport: Skip UTF-8 BOM at the beginning of strings

--- ext/redcarpet/markdown.c
+++ ext/redcarpet/markdown.c
@@ -2361,6 +2361,7 @@
 sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, struct sd_markdown *md)
 {
 #define MARKDOWN_GROW(x) ((x) + ((x) >> 1))
+	static const char UTF8_BOM[] = {0xEF, 0xBB, 0xBF};

 	struct buf *text;
 	size_t beg, end;
@@ -2377,6 +2378,12 @@

 	/* first pass: looking for references, copying everything else */
 	beg = 0;
+
+	/* Skip a possible UTF-8 BOM, even though the Unicode standard
+	 * discourages having these in UTF-8 documents */
+	if (doc_size >= 3 && memcmp(document, UTF8_BOM, 3) == 0)
+		beg += 3;
+
 	while (beg < doc_size) /* iterating over lines */
 		if (is_ref(document, beg, doc_size, &end, md->refs))
 			beg = end;


trunk: changeset 661

trunk: changeset 661

Some tab bar drawing fixes.

darcs-hash:20030527165509-e481e-aa54e8f84fa1b52d2848823f8d5a92eaf2ef1b20.gz

--- ionws/ionframe.c
+++ ionws/ionframe.c
@@ -263,23 +263,30 @@
 	if(frame->genframe.flags&WGENFRAME_TAB_HIDE)
 		return;

-	if(complete && !grdata->bar_inside_frame){
-		WBorder bd=frame_border(grdata);
-
-		if(REGION_IS_ACTIVE(frame)){
-			set_foreground(wglobal.dpy, grdata->tab_gc,
-						   grdata->act_frame_colors.bg);
+	if(complete){
+		if(!grdata->bar_inside_frame){
+			WBorder bd=frame_border(grdata);
+
+			if(REGION_IS_ACTIVE(frame)){
+				set_foreground(wglobal.dpy, grdata->tab_gc,
+							   grdata->act_frame_colors.bg);
+			}else{
+				set_foreground(wglobal.dpy, grdata->tab_gc,
+							   grdata->frame_colors.bg);
+			}
+
+			XFillRectangle(wglobal.dpy, WGENFRAME_WIN(frame), grdata->tab_gc,
+						   0, 0, REGION_GEOM(frame).w, grdata->bar_h+bd.ipad);
 		}else{
-			set_foreground(wglobal.dpy, grdata->tab_gc,
-						   grdata->frame_colors.bg);
+			WRectangle geom;
+			genframe_bar_geom((WGenFrame*)frame, &geom);
+
+			XClearArea(wglobal.dpy, WGENFRAME_WIN(frame),
+					   geom.x, geom.y, geom.w, geom.h, False);
 		}
-
-		XFillRectangle(wglobal.dpy, WGENFRAME_WIN(frame), grdata->tab_gc,
-					   0, 0, REGION_GEOM(frame).w, grdata->bar_h+bd.ipad);
-		complete=FALSE;
-	}
-
-	genframe_draw_bar_default((WGenFrame*)frame, complete);
+	}
+
+	genframe_draw_bar_default((WGenFrame*)frame, FALSE);
 }


cosmetics: merge decls

cosmetics: merge decls

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@12997 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

--- libavcodec/mpegaudiodec.c
+++ libavcodec/mpegaudiodec.c
@@ -2566,12 +2566,11 @@
 {
     MP3On4DecodeContext *s = avctx->priv_data;
     MPADecodeContext *m;
-    int len, out_size = 0;
+    int len, fsize, out_size = 0;
     uint32_t header;
     OUT_INT *out_samples = data;
     OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS];
     OUT_INT *outptr, *bp;
-    int fsize;
     int fr, j, n;

     len = buf_size;


Very necessary typecheck

Very necessary typecheck

--- ext/rugged/rugged_repo.c
+++ ext/rugged/rugged_repo.c
@@ -468,6 +468,7 @@
 	git_otype type;

 	Data_Get_Struct(self, git_repository, repo);
+	Check_Type(rb_buffer, T_STRING);

 	error = git_repository_odb(&odb, repo);
 	rugged_exception_check(error);


make sure we handle the (malloc(0)==NULL) case as Aubrey points out via the e-mail list

--- libc/inet/rpc/auth_unix.c
+++ libc/inet/rpc/auth_unix.c
@@ -183,12 +183,14 @@
   uid_t uid;
   gid_t gid;
   int max_nr_groups = sysconf (_SC_NGROUPS_MAX);
-  gid_t *gids;
+  gid_t *gids = NULL;
   AUTH *ret_auth;

-  gids = (gid_t*)malloc(sizeof(*gids) * max_nr_groups);
-  if (gids == NULL)
-    abort ();
+  if (max_nr_groups) {
+    gids = (gid_t*)malloc(sizeof(*gids) * max_nr_groups);
+    if (gids == NULL)
+      abort ();
+  }

   if (gethostname (machname, MAX_MACHINE_NAME) == -1)
     abort ();
@@ -202,7 +204,8 @@
      list of groups to NGRPS members since the code in
      authuxprot.c transforms a fixed array.  Grrr.  */
   ret_auth = __authunix_create (machname, uid, gid, MIN (NGRPS, len), gids);
-  free (gids);
+  if (gids)
+    free (gids);
   return ret_auth;
 }
 strong_alias(__authunix_create_default,authunix_create_default)


Destroy mousegrabber, put wc protocols together

--- compositor/server.c
+++ compositor/server.c
@@ -51,13 +51,14 @@
 			wlr_data_device_manager_create(server->wl_display);

 	wc_xwayland_init(server);
-	wc_mousegrabber_init(server);
 	wc_seat_init(server);
 	wc_output_init(server);
 	wc_inputs_init(server);
 	wc_views_init(server);
 	wc_layers_init(server);
 	wc_cursor_init(server);
+
+	wc_mousegrabber_init(server);

 	return true;
 }
@@ -74,6 +75,8 @@
 	wlr_screencopy_manager_v1_destroy(server->screencopy_manager);
 	wlr_data_device_manager_destroy(server->data_device_manager);

+	wc_mousegrabber_init(server);
+
 	wlr_compositor_destroy(server->compositor);

 	wl_display_destroy_clients(server->wl_display);


Declaration before statements

Declaration before statements

--- ext/rugged/rugged_tree.c
+++ ext/rugged/rugged_tree.c
@@ -127,10 +127,11 @@
 static VALUE rb_git_tree_entrycount_recursive(int argc, VALUE* argv, VALUE self)
 {
 	git_tree *tree;
-	Data_Get_Struct(self, git_tree, tree);
 	int error;
 	struct rugged_treecount_cb_payload payload;
 	VALUE rb_limit;
+
+	Data_Get_Struct(self, git_tree, tree);

 	rb_scan_args(argc, argv, "01", &rb_limit);


loop unrolling header included

loop unrolling header included

[r5266]

--- ir/common/firm.h
+++ ir/common/firm.h
@@ -66,14 +66,15 @@
 #include "ircgcons.h"      /* construct interprocedural graph */

 /* Optimizations */
-#include "irflag.h"        /* optimization flags */
-#include "irgopt.h"        /* optimize ir */
-#include "reassoc.h"       /* optimize ir by reassociation */
-#include "ldstopt.h"       /* optimize Load/Store */
-#include "cfopt.h"         /* optimize control flow */
-#include "tailrec.h"       /* optimize tail-recursion calls */
-#include "ircgopt.h"       /* Optimizations based on interprocedural graph */
-#include "strength_red.h"  /* Strength reduction */
+#include "irflag.h"         /* optimization flags */
+#include "irgopt.h"         /* optimize ir */
+#include "reassoc.h"        /* optimize ir by reassociation */
+#include "ldstopt.h"        /* optimize Load/Store */
+#include "cfopt.h"          /* optimize control flow */
+#include "tailrec.h"        /* optimize tail-recursion calls */
+#include "ircgopt.h"        /* Optimizations based on interprocedural graph */
+#include "strength_red.h"   /* Strength reduction */
+#include "loop_unrolling.h" /* Do loop unrolling*/

 /* Analyses */
 #include "irouts.h"        /* Graph reversal / out edges. */


Fix import

Fix import

--- FBTweak/FBTweakInlineInternal.h
+++ FBTweak/FBTweakInlineInternal.h
@@ -7,7 +7,6 @@
  of patent rights can be found in the PATENTS file in the same directory.
  */

-#import "FBTweakConstants.h"
 #import "FBTweakEnabled.h"
 #import "FBTweak.h"
 #import "FBTweakStore.h"


Introspection: fix annotation in e_client_get_capabilities

--- libedataserver/e-client.c
+++ libedataserver/e-client.c
@@ -478,7 +478,7 @@
  * This list, together with inner strings, is owned by the @client.
  * To check for individual capabilities use e_client_check_capability().
  *
- * Returns: #GSList of const strings of capabilities
+ * Returns: (transfer none): #GSList of const strings of capabilities
  *
  * Since: 3.2
  **/


refactor the grid-search code. implemented mert_tune_mmi

--- ext/trainer/train_proc.h
+++ ext/trainer/train_proc.h
@@ -241,6 +241,7 @@
     /// for reranking
     bool MERT_tune(Model &model, Proc &am, Corpus &devel, string out_file, Dict & sd);
     bool MERT_tune_edit_distance(Model &model, Proc &am, Corpus &devel, string out_file, Dict & sd, cnn::real weight_IDF=0.1);
+    void MERT_MMI_tune(Proc &am, Proc& anti_am, Corpus &devel, string out_file, Dict & sd);

 public:
     /// for test ranking candidate
@@ -526,6 +527,8 @@
         vector<vector<int>> res_kbest;
         vector<string> prv_response;
         vector<string> prv_response_ref;
+
+        am.reset();
         for (auto spair : diag)
         {
             ComputationGraph cg;
@@ -690,6 +693,8 @@
         vector<vector<int>> res_kbest;
         vector<string> prv_response;
         vector<string> prv_response_ref;
+
+        am.reset();
         for (auto spair : diag)
         {
             ComputationGraph cg;
@@ -869,51 +874,59 @@
         vector<vector<int>> res_kbest;
         vector<string> prv_response;
         vector<string> prv_response_ref;
+
+        vector<vector<vector<cnn::real>>> anit_model_correct_response_state;
+
+        am.reset();
         for (auto spair : diag)
         {
-            ComputationGraph cg;
-
             SentencePair turn = spair;
             vector<string> sref, srec;

             priority_queue<Hypothesis, vector<Hypothesis>, CompareHypothesis> beam_search_results;

-            if (turn_id == 0)
-            {
-                res = am.beam_decode(turn.first, cg, beam_search_decode, sd);
-            }
-            else
-            {
-                res = am.beam_decode(prv_turn.second, turn.first, cg, beam_search_decode, sd);
-            }
-
-            if (turn.first.size() > 0)
-            {
-                cout << "source: ";
-                for (auto p : turn.first){
-                    cout << sd.Convert(p) << " ";
-                }
-                cout << endl;
-            }
-
-            if (turn.second.size() > 0)
-            {
-                cout << "ref response: ";
-                for (auto p : turn.second){
-                    cout << sd.Convert(p) << " ";
-                    sref.push_back(sd.Convert(p));
-                }
-                cout << endl;
-            }
-
-            beam_search_results = am.get_beam_decode_complete_list();
-
-            /// averaged_log_likelihood , idf_score, bleu_score
-            /// the goal is to rerank using (1-weight) * averaged_log_likelihood + weight * score_from_anti_model
+            {
+                ComputationGraph cg;
+
+                if (turn_id == 0)
+                {
+                    res = am.beam_decode(turn.first, cg, beam_search_decode, sd);
+                }
+                else
+                {
+                    res = am.beam_decode(prv_turn.second, turn.first, cg, beam_search_decode, sd);
+                }
+
+                if (turn.first.size() > 0)
+                {
+                    cout << "source: ";
+                    for (auto p : turn.first){
+                        cout << sd.Convert(p) << " ";
+                    }
+                    cout << endl;
+                }
+
+                if (turn.second.size() > 0)
+                {
+                    cout << "ref response: ";
+                    for (auto p : turn.second){
+                        cout << sd.Convert(p) << " ";
+                        sref.push_back(sd.Convert(p));
+                    }
+                    cout << endl;
+                }
+
+                beam_search_results = am.get_beam_decode_complete_list();
+            }
+
             vector<int> best_res;
             cnn::real largest_score = -10000.0;
             while (!beam_search_results.empty())
             {
+                ComputationGraph cg;
+
+                anti_am.reset();
+
                 vector<int> result = beam_search_results.top().target;
                 cnn::real lk = beam_search_results.top().cost;

@@ -965,6 +978,119 @@
     string sBleuScore = bleuScore.GetScore();
     cout << "BLEU (4) score = " << sBleuScore << endl;
     of << "BLEU (4) score = " << sBleuScore << endl;
+
+    of.close();
+}
+
+/**
+use MERT to tune weights for MMI decoding
+*/
+template <class AM_t>
+void TrainProcess<AM_t>::MERT_MMI_tune(AM_t &am, AM_t& anti_am,
+    Corpus &devel, string out_file, Dict & sd)
+{
+    BleuMetric bleuScore;
+    bleuScore.Initialize();
+
+    /*cnn::real idf_weight = 0.1;
+    cnn::real edist_weight = 0.1;*/
+    IDFMetric idfScore(mv_idf);
+
+    EditDistanceMetric editDistScoreHyp;
+    EditDistanceMetric editDistScoreRef;
+
+    ofstream of(out_file);
+
+    vector<vector<tuple<cnn::real, cnn::real, cnn::real>>> dev_set_rerank_scores;
+    Timer iteration("completed in");
+
+    for (auto diag : devel){
+
+        SentencePair prv_turn;
+        size_t turn_id = 0;
+
+        /// train on two segments of a dialogue
+        vector<int> res;
+        vector<vector<int>> res_kbest;
+        vector<string> prv_response;
+        vector<string> prv_response_ref;
+
+        vector<vector<vector<cnn::real>>> anit_model_correct_response_state;
+
+        am.reset();
+        for (auto spair : diag)
+        {
+            SentencePair turn = spair;
+            vector<string> sref, srec;
+
+            priority_queue<Hypothesis, vector<Hypothesis>, CompareHypothesis> beam_search_results;
+
+            {
+                ComputationGraph cg;
+
+                if (turn_id == 0)
+                {
+                    res = am.beam_decode(turn.first, cg, beam_search_decode, sd);
+                }
+                else
+                {
+                    res = am.beam_decode(prv_turn.second, turn.first, cg, beam_search_decode, sd);
+                }
+
+                if (turn.second.size() > 0)
+                {
+                    for (auto p : turn.second){
+                        sref.push_back(sd.Convert(p));
+                    }
+                }
+
+                beam_search_results = am.get_beam_decode_complete_list();
+            }
+
+            vector<int> best_res;
+            cnn::real largest_score = -10000.0;
+            vector<tuple<cnn::real, cnn::real, cnn::real>> rerank_scores;
+            while (!beam_search_results.empty())
+            {
+                ComputationGraph cg;
+
+                anti_am.reset();
+
+                vector<int> result = beam_search_results.top().target;
+                cnn::real lk = beam_search_results.top().cost;
+
+                /// reverse direction
+                Dialogue backward_res, backward_src;
+                SentencePair sp_res, sp_src;
+                sp_src.first = result;
+                sp_src.second = turn.first;
+                backward_src.push_back(sp_src);
+                anti_am.build_graph(backward_res, backward_src, cg);
+
+                cnn::real anti_score = -as_scalar(cg.get_value(anti_am.s2txent.i)) / (0.0 + result.size());
+
+                srec.clear();
+                for (auto p : result){
+                    srec.push_back(sd.Convert(p));
+                }
+                cnn::real bleu_score = bleuScore.GetSentenceScore(sref, srec);
+
+                rerank_scores.push_back(make_tuple(lk, anti_score, bleu_score));
+                beam_search_results.pop();
+            }
+            dev_set_rerank_scores.push_back(rerank_scores);
+
+            turn_id++;
+            prv_turn = turn;
+            prv_response = srec;
+            prv_response_ref = sref;
+        }
+    }
+
+    /// learn a weight to IDF score
+    cnn::real optimal_wgt = grid_search(dev_set_rerank_scores);
+
+    of << "optimal weight to IDF score is " << optimal_wgt << endl;

     of.close();
 }
@@ -1019,6 +1145,7 @@
         /// train on two segments of a dialogue
         vector<int> res;
         vector<vector<int>> res_kbest;
+        am.reset();
         for (auto spair : diag)
         {
             ComputationGraph cg;
@@ -1029,9 +1156,9 @@
             priority_queue<Hypothesis, vector<Hypothesis>, CompareHypothesis> beam_search_results;

             if (turn_id == 0)
-	      res = am.beam_decode(turn.first, cg, beam_search_decode, sd);
+                res = am.beam_decode(turn.first, cg, beam_search_decode, sd);
             else
-	      res = am.beam_decode(prv_turn.second, turn.first, cg, beam_search_decode, sd);
+                res = am.beam_decode(prv_turn.second, turn.first, cg, beam_search_decode, sd);

             sref.clear();
             if (turn.second.size() > 0)
@@ -1044,8 +1171,8 @@
             if (rerankIDF > 0)
             {
                 beam_search_results = am.get_beam_decode_complete_list();
-		if (beam_search_results.empty())
-		  cerr << "beam search complete list is empty " << endl;
+		        if (beam_search_results.empty())
+                    cerr << "beam search complete list is empty " << endl;

                 /// averaged_log_likelihood , idf_score, bleu_score
                 /// the goal is to rerank using averaged_log_likelihood + weight * idf_score
@@ -1083,54 +1210,9 @@
     cout << "completed decoding" << endl;

     /// learn a weight to IDF score
-    vector<cnn::real> v_bleu_scores;
-    vector<cnn::real> v_wgts;
-    cnn::real max_bleu_score = -10000.0;
-    int idx_wgt = -1;
-    for (cnn::real idf_wgt = 0.0; idf_wgt <= 1.0; idf_wgt += 0.05)
-    {
-        v_wgts.push_back(idf_wgt);
-
-        cnn::real avg_bleu_score = 0;
-        for (auto t : dev_set_rerank_scores)
-        {
-            cnn::real max_combine_score = -10000.0;
-            int idx = -1;
-            int k = 0;
-            for (auto c : t)
-            {
-                cnn::real lk = std::get<0>(c);
-                cnn::real idfscore = std::get<1>(c);
-                cnn::real this_score = (1.0 - idf_wgt) * lk + idf_wgt * idfscore;
-                if (max_combine_score < this_score)
-                {
-                    max_combine_score = this_score;
-                    idx = k;
-                }
-                k++;
-            }
-
-            if (idx >= 0)
-	      avg_bleu_score += std::get<2>(t[idx]);
-	    else
-	      cerr << "warning no bleu scores " << endl;
-        }
-        v_bleu_scores.push_back(avg_bleu_score / dev_set_rerank_scores.size());
-
-        if (max_bleu_score < v_bleu_scores.back())
-        {
-	  max_bleu_score = v_bleu_scores.back();
-	  idx_wgt = v_bleu_scores.size() - 1;
-        }
-
-	cout << "w(" << idf_wgt << ") " << v_bleu_scores.back() << " ";
-    }
-    cout << endl;
-
-    cnn::real optimal_wgt = v_wgts[idx_wgt];
+    cnn::real optimal_wgt = grid_search(dev_set_rerank_scores);

     of << "optimal weight to IDF score is " << optimal_wgt << endl;
-    cout << "optimal weight to IDF score is " << optimal_wgt << endl;

     return true;
 }


fix fehler40

fix fehler40

[r15159]

--- ir/opt/ldstopt.c
+++ ir/opt/ldstopt.c
@@ -979,7 +979,12 @@
 	if (n <= 0)
 		return 0;

-	store = skip_Proj(get_Phi_pred(phi, 0));
+	/* must be only one user */
+	projM = get_Phi_pred(phi, 0);
+	if (get_irn_n_edges(projM) != 1)
+		return 0;
+
+	store = skip_Proj(projM);
 	old_store = store;
 	if (get_irn_op(store) != op_Store)
 		return 0;
@@ -1007,8 +1012,12 @@
 	exc  = info->exc_block;

 	for (i = 1; i < n; ++i) {
-		ir_node *pred = skip_Proj(get_Phi_pred(phi, i));
-
+		ir_node *pred = get_Phi_pred(phi, i);
+
+		if (get_irn_n_edges(pred) != 1)
+			return 0;
+
+		pred = skip_Proj(pred);
 		if (get_irn_op(pred) != op_Store)
 			return 0;


Revert r1628 which causes the crash of voe_auto_test.

With r1628, it's possible the second memcpy got a NULL nearendClean.

TBR=bjornv
Review URL: https://webrtc-codereview.appspot.com/390005

git-svn-id: 917f5d3ca488f358c4d40eaec14422cf392ccec9@1643 4adac7df-926f-26a2-2b94-8c16560cd09d

--- src/modules/audio_processing/aecm/echo_control_mobile.c
+++ src/modules/audio_processing/aecm/echo_control_mobile.c
@@ -337,10 +337,10 @@

     if (aecm->ECstartup)
     {
-        if ((nearendClean == NULL) && (nearendNoisy != out))
+        if (nearendClean == NULL)
         {
             memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples);
-        } else if (nearendClean != out)
+        } else
         {
             memcpy(out, nearendClean, sizeof(short) * nrOfSamples);
         }


DOC: caveat no longer needed

DOC: caveat no longer needed

--- Rendering/vtkImageViewer2.h
+++ Rendering/vtkImageViewer2.h
@@ -46,18 +46,6 @@
 // direction) for achieving this effect is provided by the
 // ImagePlaneWidgets.
 //
-// .SECTION Caveats
-// Since the displayed image is placed at a depth corresponding to the
-// z-coordinate of the particular image slice, you should reset the
-// camera clipping planes after each call to SetZSlice() to avoid
-// unintentional clipping of the image data, i.e.
-//
-// viewer->SetZSlice( slice );
-// viewer->GetRenderer()->ResetCameraClippingRange();
-//
-// If you do not call ResetCameraClippingRange() on the viewer's
-// renderer, the viewer may show a blank image at some ZSlice
-// settings.

 // .SECTION See Also
 // vtkRenderWindow vtkRenderer vtkImageActor vtkImageMapToWindowLevelColors


source_idle_changed_cb: Avoid a runtime warning.

Apparently it's possible for the 'changed' GSource to already be NULL
when we go to unref it in source_idle_changed_cb().  Not sure how that's
happening... possibly racing with dispose()?  In any case just check for
NULL first.

--- libedataserver/e-source.c
+++ libedataserver/e-source.c
@@ -629,8 +629,10 @@
 	ESource *source = E_SOURCE (user_data);

 	g_mutex_lock (source->priv->changed_lock);
-	g_source_unref (source->priv->changed);
-	source->priv->changed = NULL;
+	if (source->priv->changed != NULL) {
+		g_source_unref (source->priv->changed);
+		source->priv->changed = NULL;
+	}
 	g_mutex_unlock (source->priv->changed_lock);

 	g_signal_emit (source, signals[CHANGED], 0);


add <s> and </s> to the before and after the input strings

--- ext/trainer/train_proc.h
+++ ext/trainer/train_proc.h
@@ -514,7 +514,7 @@
             if (shuman.find("exit") == 0)
                 break;
 #endif
-
+            shuman = "<s> " + shuman + "</s>";
             convertHumanQuery(shuman, shuman_input, td);

             if (t_idx == 0)


make osr_flag_default a define, because "simple-minded" CRecoder cannot handle this

[r7902]

--- ir/opt/opt_osr.h
+++ ir/opt/opt_osr.h
@@ -20,9 +20,12 @@
 	osr_flag_none               = 0,  /**< no additional flags */
 	osr_flag_lftr_with_ov_check = 1,  /**< do only linear function test replacement
 	                                       if no overflow occurs. */
-	/** default setting */
-	osr_flag_default = osr_flag_lftr_with_ov_check
 } osr_flags;
+
+/* FirmJNI cannot handle identical enum values... */
+
+/** default setting */
+#define osr_flag_default osr_flag_lftr_with_ov_check

 /**
  * Do the Operator Scalar Replacement optimization and linear


fix typo

fix typo

SVN revision: 40958

--- src/modules/conf_interaction/e_int_config_interaction.c
+++ src/modules/conf_interaction/e_int_config_interaction.c
@@ -104,7 +104,7 @@
    e_widget_framelist_object_append(of, ob);
    cfdata->sl1 = ob;

-   ob = e_widget_label_add(evas, _("Threshold for for applying drag momentum"));
+   ob = e_widget_label_add(evas, _("Threshold for applying drag momentum"));
    e_widget_framelist_object_append(of, ob);
    cfdata->l2 = ob;
    ob = e_widget_slider_add(evas, 1, 0, _("%1.0f pixels/sec"), 0, 2000, 20, 0, &(cfdata->thumbscroll_momentum_threshhold), NULL, 200);


Fix doc warnings

Fix doc warnings

--- libgit2-glib/ggit-types.h
+++ libgit2-glib/ggit-types.h
@@ -590,11 +590,11 @@

 /**
  * GgitSubmoduleIgnore:
- * GGIT_SUBMODULE_IGNORE_DEFAULT: reset to default.
- * GGIT_SUBMODULE_IGNORE_NONE: any change or untracked == dirty.
- * GGIT_SUBMODULE_IGNORE_UNTRACKED: dirty if tracked files change.
- * GGIT_SUBMODULE_IGNORE_DIRTY: only dirty if HEAD moved.
- * GGIT_SUBMODULE_IGNORE_ALL: never dirty
+ * @GGIT_SUBMODULE_IGNORE_DEFAULT: reset to default.
+ * @GGIT_SUBMODULE_IGNORE_NONE: any change or untracked == dirty.
+ * @GGIT_SUBMODULE_IGNORE_UNTRACKED: dirty if tracked files change.
+ * @GGIT_SUBMODULE_IGNORE_DIRTY: only dirty if HEAD moved.
+ * @GGIT_SUBMODULE_IGNORE_ALL: never dirty
  *
  * Describes which submodules should be ignored.
  */


have a function to do ngram clustering with just one pass

--- ext/trainer/train_proc.h
+++ ext/trainer/train_proc.h
@@ -136,6 +136,7 @@
     /// for ngram
     void ngram_train(variables_map vm, const Corpus& test, Dict& sd);
     void ngram_clustering(variables_map vm, const Corpus& test, Dict& sd);
+    void ngram_one_pass_clustering(variables_map vm, const Corpus& test, Dict& sd);
     void representative_presentation(
         vector<nGram> pnGram,
         const Sentences& responses,
@@ -1681,9 +1682,9 @@

     for (int iter = 0; iter < vm["epochs"].as<int>(); iter++)
     {
-        shuffle(response.begin(), response.end(), std::default_random_engine(iter));
         if (iter == 0)
         {
+            shuffle(response.begin(), response.end(), std::default_random_engine(iter));
             for (int i = 0; i < ncls; i++)
             {
                 pnGram[i].LoadModel(".m" + boost::lexical_cast<string>(i));
@@ -1722,19 +1723,19 @@
             /// reassign data to closest cluster
             vector<Sentences> current_assignment(ncls);
             double totallk = 0;
-            for (int i = 0; i < response.size() / 2; i++)
-            {
-                if (response[i].size() == 0)
+            for (int i = 0; i < order_kept_responses.size(); i++)
+            {
+                if (order_kept_responses[i].size() == 0)
                     continue;

                 cnn::real largest ;
-                int iarg = closest_class_id(pnGram, 0, ncls, response[i], largest, interpolation_wgt);
+                int iarg = closest_class_id(pnGram, 0, ncls, order_kept_responses[i], largest, interpolation_wgt);

-                current_assignment[iarg].push_back(response[i]);
-                totallk += largest / response[i].size();
+                current_assignment[iarg].push_back(order_kept_responses[i]);
+                totallk += largest / order_kept_responses[i].size();
                 ncnt[iarg]++;
             }
-            totallk /= response.size();
+            totallk /= order_kept_responses.size();

             cout << "loglikelihood at iteration " << iter << " is " << totallk << endl;

@@ -1746,7 +1747,7 @@
                     if (p < MIN_OCC_COUNT)
                     {
                         /// randomly pick one sample for this class
-                        current_assignment[icls].push_back(response[rand0n_uniform(response.size()) - 1]);
+                        current_assignment[icls].push_back(response[rand0n_uniform(order_kept_responses.size()) - 1]);
                     }
                     icls++;
                 }
@@ -1810,6 +1811,138 @@
                 cout << ostr << endl;

             tid++;
+        }
+        did++;
+    }
+
+    if (ofs.is_open())
+        ofs.close();
+}
+
+/**
+keep turn id
+each turn has its own clusters
+ngram counts are not reliable. so use edit distance
+*/
+template <class AM_t>
+void TrainProcess<AM_t>::ngram_one_pass_clustering(variables_map vm, const Corpus& test, Dict& sd)
+{
+#define MAXTURNS 100
+    Corpus empty;
+    int ncls = vm["ngram-num-clusters"].as<int>();
+    vector<int> data2cls;
+    vector<cnn::real> cls2score; /// the highest score in this class
+    vector<Sentence> cls2data;  /// class to its closest response
+
+    vector<int> cls_cnt;
+    vector<nGram> pnGram;
+
+    cnn::real threshold = vm["llkthreshold"].as<cnn::real>();
+
+    cnn::real interpolation_wgt = vm["interpolation_wgt"].as<cnn::real>();
+
+    vector<long> ncnt(MAXTURNS, 0); /// every class must have at least one sample
+
+    long sid = 0;
+    for (auto& d : test)
+    {
+        for (auto &t : d)
+        {
+            Sentence rep = remove_first_and_last(t.second);
+
+            cnn::real largest = LZERO;
+            int iarg;
+
+            if (pnGram.size() > 0)
+                iarg = closest_class_id(pnGram, 0, pnGram.size(), rep, largest, interpolation_wgt);
+
+            if (largest < threshold && pnGram.size() < ncls)
+            {
+                pnGram.push_back(nGram());
+                pnGram.back().Initialize(vm);
+                pnGram.back().UpdateNgramCounts(rep, 0, sd);
+                pnGram.back().UpdateNgramCounts(rep, 1, sd);
+                iarg = pnGram.size() - 1;
+            }
+            else{
+                pnGram[iarg].UpdateNgramCounts(rep, 0, sd);
+                pnGram[iarg].UpdateNgramCounts(rep, 1, sd);
+            }
+
+            /// update centroid periodically
+            if ((pnGram.size() < ncls) || ((pnGram.size() > ncls - 1) && sid % 1000 == 0))
+            {
+                for (auto &p : pnGram){
+                    p.ComputeNgramModel();
+                }
+            }
+
+            sid++;
+        }
+    }
+
+    /// do classification now
+    vector<Sentence> typical_response(pnGram.size());
+    vector<cnn::real> best_score(pnGram.size(), LZERO);
+
+    ofstream ofs;
+    if (vm.count("outputfile") > 0)
+        ofs.open(vm["outputfile"].as<string>());
+    long did = 0;
+    long idx = 0;
+    for (auto& t : test)
+    {
+        int tid = 0;
+        for (auto& s : t)
+        {
+            cnn::real largest;
+            Sentence rep = remove_first_and_last(s.second);
+            long iarg = closest_class_id(pnGram, 0, pnGram.size(), rep, largest, interpolation_wgt);
+
+            if (best_score[iarg] < largest)
+            {
+                best_score[iarg] = largest;
+                typical_response[iarg] = s.second;
+            }
+            data2cls.push_back(iarg);
+        }
+    }
+
+    vector<string> i_representative;
+    for (auto& p : typical_response)
+    {
+        string sl = "";
+        for (auto w : p)
+            sl = sl + sd.Convert(w) + " ";
+        i_representative.push_back(sl);
+    }
+
+    long dataid = 0;
+    did = 0;
+    for (auto& t : test)
+    {
+        int tid = 0;
+        for (auto& s : t)
+        {
+            string userstr;
+            for (auto& p : s.first)
+                userstr = userstr + " " + sd.Convert(p);
+            string responsestr;
+            for (auto& p : s.second)
+                responsestr = responsestr + " " + sd.Convert(p);
+
+            int iarg = data2cls[dataid];
+            string ostr = boost::lexical_cast<string>(did)+" ||| " + boost::lexical_cast<string>(tid)+" ||| " + userstr + " ||| " + responsestr;
+            ostr = ostr + " ||| " + boost::lexical_cast<string>(iarg)+" ||| " + i_representative[iarg];
+            if (ofs.is_open())
+            {
+                ofs << ostr << endl;
+            }
+            else
+                cout << ostr << endl;
+
+            tid++;
+            dataid++;
         }
         did++;
     }


More doxygen comments

More doxygen comments

[r733]

--- ir/tr/typewalk.h
+++ ir/tr/typewalk.h
@@ -1,13 +1,18 @@
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
+* All rights reserved.
+*/

-* All rights reserved.
+/**
+* @file typewalk.h
 *
-* Author: Goetz Lindenmaier
+* Traverse the type information.
 *
-* traverse the type information.  The walker walks the whole ir graph
+* @author Goetz Lindenmaier
+*
+* The walker walks the whole ir graph
 * to find the distinct type trees in the type graph forest.
-* - execute the pre function before recursion
-* - execute the post function after recursion
+* - execute the pre() function before recursion
+* - execute the post() function after recursion
 */

 /* $Id$ */


Reduce mouse slider width in basic dialog.
Remove calls to dialog_resizable_set(0) because by default dialogs are not
resizable anyway.

SVN revision: 33173

--- src/modules/conf_screensaver/e_int_config_screensaver.c
+++ src/modules/conf_screensaver/e_int_config_screensaver.c
@@ -117,12 +117,10 @@
    ob = e_widget_label_add(evas, _("Time until X screensaver starts"));
    e_widget_framelist_object_append(of, ob);
    ob = e_widget_slider_add(evas, 1, 0, _("%1.0f minutes"), 1.0, 90.0, 1.0, 0,
-			    &(cfdata->timeout), NULL, 200);
+			    &(cfdata->timeout), NULL, 100);
    e_widget_framelist_object_append(of, ob);

    e_widget_list_object_append(o, of, 1, 1, 0.5);
-   e_dialog_resizable_set(cfd->dia, 0);
-
    return o;
 }

@@ -181,6 +179,5 @@
    e_widget_framelist_object_append(of, ob);
    e_widget_list_object_append(o, of, 1, 1, 0.5);

-   e_dialog_resizable_set(cfd->dia, 0);
    return o;
 }


runtime: Don't crash in Func.Name if the Func is nil.

GCC PR 66016
Related to Go issue 10696

R=iant
CC=gofrontend-dev
https://golang.org/cl/237950043

--- libgo/runtime/go-caller.c
+++ libgo/runtime/go-caller.c
@@ -231,6 +231,8 @@
 String
 runtime_funcname_go (Func *f)
 {
+  if (f == NULL)
+    return runtime_gostringnocopy ((const byte *) "");
   return f->name;
 }


removed diagnostic messages

removed diagnostic messages

--- types/table.c
+++ types/table.c
@@ -58,7 +58,7 @@

       j = 0;
       iter = n->bucket_head;
-      printf("Inserting %ld elements from node %ld into secondary table...\n", n->count, i);
+      //printf("Inserting %ld elements from node %ld into secondary table...\n", n->count, i);
       while (  j < n->count ) {
 	r = table_node_insert(n, iter->value);
 	if ( r == 1 ) {
@@ -71,7 +71,7 @@

 	  iter = n->bucket_head;
 	  j = 0;
-	  printf("redoing %lld...\n", iter->value);
+	  //printf("redoing %lld...\n", iter->value);
 	  continue;
 	} else if ( j < n->count - 1 ) {
 	  iter = iter->next;
@@ -79,7 +79,7 @@
 	j++;

       }
-      printf("Done inserting elements\n");
+      //printf("Done inserting elements\n");

       for ( j = 0; j < n->count; j++ )
 	pop_bucket(n);
@@ -175,10 +175,10 @@
   mpz_clear(position);

   if ( node->secondary_table[p] != 0 ) {
-    printf("conflict in position %ld: %lld is evicting %lld\n", p, v, node->secondary_table[p]);
+    /*    printf("conflict in position %ld: %lld is evicting %lld\n", p, v, node->secondary_table[p]);
     printf("function: %ld x + %ld mod %ld mod %ld\n", mpz_get_ui(node->secondary_hash_function.a),
 	   mpz_get_ui(node->secondary_hash_function.b), mpz_get_ui(node->secondary_hash_function.p),
-	   mpz_get_ui(node->secondary_hash_function.m));
+	   mpz_get_ui(node->secondary_hash_function.m));*/
     return 1;
   }
   node->secondary_table[p] = v;


list days of month

list days of month

--- u4_onemonth.c
+++ u4_onemonth.c
@@ -20,5 +20,22 @@

 int main() {

+	int daysinmonth = 0;
+	int startingday = 0;
+	int i = 0;
+
+	printf("Enter number of days in month: ");
+	scanf("%d", &daysinmonth);
+
+	printf("Enter starting day of the week (1=Monday, 7=Sunday): ");
+	scanf("%d", &startingday);
+	printf("\n");
+
+	for(i=1; i<=daysinmonth; i++) {
+		printf("%d ", i);
+	}
+
+	printf("\n");
+
 	return 0;
 }


Disable the original call to BIO_flush() now that we're doing our own buffering.

--- sbr/netsec.c
+++ sbr/netsec.c
@@ -800,7 +800,7 @@
      * For TLS connections, just call BIO_flush(); we'll let TLS handle
      * all of our output buffering.
      */
-#ifdef TLS_SUPPORT
+#if 0
     if (nsc->tls_active) {
 	rc = BIO_flush(nsc->ssl_io);

@@ -924,7 +924,21 @@
 	return NOTOK;
     }

-    nsc->sasl_mech = mechanism ? getcpy(mechanism) : NULL;
+    /*
+     * According to the RFC, mechanisms can only be uppercase letter, numbers,
+     * and a hypen or underscore.  So make sure we uppercase any letters
+     * in case the user passed in lowercase.
+     */
+
+    if (mechanism) {
+	char *p;
+	nsc->sasl_mech = getcpy(mechanism);
+
+	for (p = nsc->sasl_mech; *p; p++)
+	    if (isascii(*p))	/* Just in case */
+		*p = toupper(*p);
+    }
+
     nsc->sasl_proto_cb = callback;
     nsc->sasl_hostname = getcpy(hostname);

@@ -1533,6 +1547,7 @@

     nsc->tls_active = 1;

+#if 0
     /*
      * At this point, TLS has been activated; we're not going to use
      * the output buffer, so free it now to save a little bit of memory.
@@ -1542,6 +1557,7 @@
 	free(nsc->ns_outbuffer);
 	nsc->ns_outbuffer = NULL;
     }
+#endif

     return OK;
 #else /* TLS_SUPPORT */


changed line unwrap length to 45

changed line unwrap length to 45

--- txtnorm.c
+++ txtnorm.c
@@ -85,7 +85,7 @@
                 /* Handle text wrapping */
                 uChar[0] = getNextByte();

-                if (linePos > 60 && uChar[0] != ' ' && uChar[0] != '\t' && uChar[0] != '\n') {
+                if (linePos > 45 && uChar[0] != ' ' && uChar[0] != '\t' && uChar[0] != '\n') {
                     fwrite(" ", 1, 1, stdout);
                 } else {
                     fwrite("\n", 1, 1, stdout);


remove stale generated file

remove stale generated file

--- generated/blog_channel_ncd_net_backend_physical.h
+++ generated/blog_channel_ncd_net_backend_physical.h
@@ -1,4 +0,0 @@
-#ifdef BLOG_CURRENT_CHANNEL
-#undef BLOG_CURRENT_CHANNEL
-#endif
-#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_backend_physical


device: Delete storage device recursively

Device storage directory may contain multiple files like info or
attributes but also files stored by plug-ins or profiles,
so completely delete directory.

--- src/device.c
+++ src/device.c
@@ -34,6 +34,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <errno.h>
+#include <dirent.h>

 #include <bluetooth/bluetooth.h>
 #include <bluetooth/uuid.h>
@@ -2031,6 +2032,34 @@
 	return device->version;
 }

+static void delete_folder_tree(const char *dirname)
+{
+	DIR *dir;
+	struct dirent *entry;
+	char filename[PATH_MAX + 1];
+
+	dir = opendir(dirname);
+	if (dir == NULL)
+		return;
+
+	while ((entry = readdir(dir)) != NULL) {
+		if (g_str_equal(entry->d_name, ".") ||
+				g_str_equal(entry->d_name, ".."))
+			continue;
+
+		snprintf(filename, PATH_MAX, "%s/%s", dirname, entry->d_name);
+		filename[PATH_MAX] = '\0';
+
+		if (entry->d_type == DT_DIR)
+			delete_folder_tree(filename);
+		else
+			unlink(filename);
+	}
+	closedir(dir);
+
+	rmdir(dirname);
+}
+
 static void device_remove_stored(struct btd_device *device)
 {
 	const bdaddr_t *src = adapter_get_address(device->adapter);
@@ -2062,15 +2091,10 @@
 	ba2str(src, adapter_addr);
 	ba2str(&device->bdaddr, device_addr);

-	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
-			device_addr);
-	filename[PATH_MAX] = '\0';
-	remove(filename);
-
 	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s", adapter_addr,
 			device_addr);
 	filename[PATH_MAX] = '\0';
-	remove(filename);
+	delete_folder_tree(filename);
 }

 void device_remove(struct btd_device *device, gboolean remove_stored)


glcontext_egl: simplify log message regarding EGL_EXT_platform_x11 extension

--- libnodegl/glcontext_egl.c
+++ libnodegl/glcontext_egl.c
@@ -153,7 +153,7 @@
     if (egl->native_display) {
         /* XXX: only X11 is supported for now */
         if (!egl->has_platform_x11_ext) {
-            LOG(ERROR, "EGL implementation does not support mandatory extension: EGL_EXT_platform_x11");
+            LOG(ERROR, "EGL_EXT_platform_x11 is not supported");
             return EGL_NO_DISPLAY;
         }
         return egl->GetPlatformDisplay(EGL_PLATFORM_X11, egl->native_display, NULL);


glcontext_egl: declare local variable later on

--- libnodegl/glcontext_egl.c
+++ libnodegl/glcontext_egl.c
@@ -102,7 +102,6 @@
     struct egl_priv *egl = ctx->priv_data;
     EGLNativeDisplayType native_display = display ? (EGLNativeDisplayType)display : EGL_DEFAULT_DISPLAY;

-    int ret;
     egl->display = egl_get_display(egl, native_display);
     if (!egl->display) {
         LOG(ERROR, "could not retrieve EGL display");
@@ -111,7 +110,7 @@

     EGLint egl_minor;
     EGLint egl_major;
-    ret = eglInitialize(egl->display, &egl_major, &egl_minor);
+    int ret = eglInitialize(egl->display, &egl_major, &egl_minor);
     if (!ret) {
         LOG(ERROR, "could initialize EGL: 0x%x", eglGetError());
         return -1;


Use track_del_ref() in playlist_release()

--- libopenspotify/playlist.c
+++ libopenspotify/playlist.c
@@ -110,7 +110,6 @@
 /* Release resources held by the playlist context, called by sp_session_release() */
 void playlist_release(struct playlist_ctx *playlist_ctx) {
 	sp_playlist *playlist, *next_playlist;
-	sp_track *track;
 	int i;

 	if(playlist_ctx->container) {
@@ -127,14 +126,8 @@
 				/* FIXME: Free sp_user */
 			}

-			for(i = 0; i < playlist->num_tracks; i++) {
-				track = playlist->tracks[i];
-
-				if(track->name)
-					free(track->name);
-
-				free(playlist->tracks[i]);
-			}
+			for(i = 0; i < playlist->num_tracks; i++)
+				track_del_ref(playlist->tracks[i]);

 			if(playlist->num_tracks)
 				free(playlist->tracks);


message: handle management of WMS messages

--- libqmi-glib/qmi-message.c
+++ libqmi-glib/qmi-message.c
@@ -42,6 +42,7 @@
 #include "qmi-dms.h"
 #include "qmi-wds.h"
 #include "qmi-nas.h"
+#include "qmi-wms.h"

 #define PACKED __attribute__((packed))

@@ -698,6 +699,9 @@
     case QMI_SERVICE_NAS:
         contents = qmi_message_nas_get_printable (self, line_prefix);
         break;
+    case QMI_SERVICE_WMS:
+        contents = qmi_message_wms_get_printable (self, line_prefix);
+        break;
     default:
         break;
     }
@@ -731,6 +735,9 @@
     case QMI_SERVICE_NAS:
         return qmi_message_nas_get_version_introduced (self, major, minor);

+    case QMI_SERVICE_WMS:
+        return qmi_message_wms_get_version_introduced (self, major, minor);
+
     default:
         /* For the still unsupported services, cannot do anything */
         return FALSE;


Fixed  bug in mdev_remove_input/output()

Fixed  bug in mdev_remove_input/output()

--- src/device.c
+++ src/device.c
@@ -675,6 +675,67 @@

     snprintf(str1, 1024, "%s/get", sig->props.name);
     lo_server_del_method(md->server, str1, NULL);
+
+    msig_full_name(sig, str1, 1024);
+    mapper_router_signal rs = md->router->signals;
+    while (rs) {
+        if (rs->signal == sig) {
+            // need to disconnect?
+            mapper_connection c = rs->connections;
+            while (c) {
+                mapper_admin_set_bundle_dest_mesh(md->admin, c->link->admin_addr);
+                if (!c->link->self_link) {
+                    snprintf(str2, 1024, "%s%s", c->link->props.remote_name,
+                             c->props.remote_name);
+                    if (c->props.direction == DI_OUTGOING)
+                        mapper_admin_bundle_message(md->admin, ADM_DISCONNECT,
+                                                    0, "ss", str1, str2);
+                    else
+                        mapper_admin_bundle_message(md->admin, ADM_DISCONNECT,
+                                                    0, "ss", str2, str1);
+                }
+                mapper_connection temp = c->next;
+                mapper_router_remove_connection(md->router, c);
+                c = temp;
+            }
+            break;
+        }
+        rs = rs->next;
+    }
+
+    if (md->registered) {
+        // Notify subscribers
+        mapper_admin_set_bundle_dest_subscribers(md->admin, SUB_DEVICE_INPUTS);
+        mapper_admin_send_signal_removed(md->admin, md, sig);
+    }
+
+    md->props.num_inputs --;
+    mdev_increment_version(md);
+    msig_free(sig);
+}
+
+void mdev_remove_output(mapper_device md, mapper_signal sig)
+{
+    int i, n;
+    char str1[1024], str2[1024];
+    for (i=0; i<md->props.num_outputs; i++) {
+        if (md->outputs[i] == sig)
+            break;
+    }
+    if (i==md->props.num_outputs)
+        return;
+
+    for (n=i; n<(md->props.num_outputs-1); n++) {
+        md->outputs[n] = md->outputs[n+1];
+    }
+    if (sig->handler) {
+        snprintf(str1, 1024, "%s/got", sig->props.name);
+        lo_server_del_method(md->server, str1, NULL);
+    }
+    if (sig->instance_event_handler &&
+        (sig->instance_event_flags & IN_DOWNSTREAM_RELEASE)) {
+        lo_server_del_method(md->server, sig->props.name, "iiF");
+    }

     msig_full_name(sig, str1, 1024);
     mapper_router_signal rs = md->router->signals;
@@ -705,67 +766,6 @@

     if (md->registered) {
         // Notify subscribers
-        mapper_admin_set_bundle_dest_subscribers(md->admin, SUB_DEVICE_INPUTS);
-        mapper_admin_send_signal_removed(md->admin, md, sig);
-    }
-
-    md->props.num_inputs --;
-    mdev_increment_version(md);
-    msig_free(sig);
-}
-
-void mdev_remove_output(mapper_device md, mapper_signal sig)
-{
-    int i, n;
-    char str1[1024], str2[1024];
-    for (i=0; i<md->props.num_outputs; i++) {
-        if (md->outputs[i] == sig)
-            break;
-    }
-    if (i==md->props.num_outputs)
-        return;
-
-    for (n=i; n<(md->props.num_outputs-1); n++) {
-        md->outputs[n] = md->outputs[n+1];
-    }
-    if (sig->handler) {
-        snprintf(str1, 1024, "%s/got", sig->props.name);
-        lo_server_del_method(md->server, str1, NULL);
-    }
-    if (sig->instance_event_handler &&
-        (sig->instance_event_flags & IN_DOWNSTREAM_RELEASE)) {
-        lo_server_del_method(md->server, sig->props.name, "iiF");
-    }
-
-    msig_full_name(sig, str1, 1024);
-    mapper_router_signal rs = md->router->signals;
-    while (rs) {
-        if (rs->signal == sig) {
-            // need to disconnect?
-            mapper_connection c = rs->connections;
-            while (c) {
-                mapper_admin_set_bundle_dest_mesh(md->admin, c->link->admin_addr);
-                if (!c->link->self_link) {
-                    snprintf(str2, 1024, "%s%s", c->link->props.remote_name,
-                             c->props.remote_name);
-                    if (c->props.direction == DI_OUTGOING)
-                        mapper_admin_bundle_message(md->admin, ADM_DISCONNECT,
-                                                    0, "ss", str1, str2);
-                    else
-                        mapper_admin_bundle_message(md->admin, ADM_DISCONNECT,
-                                                    0, "ss", str2, str1);
-                }
-                mapper_connection temp = c->next;
-                mapper_router_remove_connection(md->router, c);
-                c = temp;
-            }
-            break;
-        }
-        rs = rs->next;
-    }
-
-    if (md->registered) {
-        // Notify subscribers
         mapper_admin_set_bundle_dest_subscribers(md->admin, SUB_DEVICE_OUTPUTS);
         mapper_admin_send_signal_removed(md->admin, md, sig);
     }


Revert "libqmi-glib,message: include raw data buffer when building printable string"

This reverts commit d89b9064afa991d5cc7737fa9b0b1b55c0e31158.

We already print the raw buffer when sending/receiving the message in QmiDevice,
which is actually better as we end up priting it *before* parsing it, so it's
much better for debugging purposes.

--- libqmi-glib/qmi-message.c
+++ libqmi-glib/qmi-message.c
@@ -800,7 +800,6 @@
     GString *printable;
     gchar *qmi_flags_str;
     gchar *contents;
-    gchar *raw;

     g_return_val_if_fail (self != NULL, NULL);
     g_return_val_if_fail (line_prefix != NULL, NULL);
@@ -809,20 +808,6 @@
         line_prefix = "";

     printable = g_string_new ("");
-
-    /* Print raw binary stream */
-    raw = __qmi_utils_str_hex (((GByteArray *)self)->data,
-                               ((GByteArray *)self)->len,
-                               ':');
-    g_string_append_printf (printable,
-                            "%sRAW:\n"
-                            "%s  length = %u\n"
-                            "%s  data   = %s\n",
-                            line_prefix,
-                            line_prefix, ((GByteArray *)self)->len,
-                            line_prefix, raw);
-    g_free (raw);
-
     g_string_append_printf (printable,
                             "%sQMUX:\n"
                             "%s  length  = %u\n"


TTMatrix: initializing variable so that behaviour is defined for bounds check

--- Foundation/library/includes/TTMatrix.h
+++ Foundation/library/includes/TTMatrix.h
@@ -368,7 +368,7 @@
 	*/
 	TTBoolean makeInBounds(TTRowID& i, TTColumnID& j, TTMatrixOutOfBoundsHandler handler = outOfBoundsClip)
 	{
-		TTUInt8 changes; // keep track of how many changes are made
+		TTUInt8 changes = 0; // keep track of how many changes are made
 		changes += makeRowIDInBounds(i, handler);
 		changes += makeColumnIDInBounds(j, handler);
 		return (changes > 0); // true or false, did anything change?


core/device: Don't check ready in service_removed

shared/gatt-client clears a given gatt-db if there's an error during its
init sequence, even if the given gatt-db was previously populated (e.g.
from a cache). This is to make sure that the database contents are at no
point invalid.

This patch removes a check for bt_gatt_client_is_ready and the
corresponding early-return from btd_device's service_removed handler, so
that other layers can be notified of invalidated gatt_db_attribute
pointers.

--- src/device.c
+++ src/device.c
@@ -2762,8 +2762,21 @@
 	struct gatt_primary *prim;
 	uint16_t start, end;

-	if (!bt_gatt_client_is_ready(device->client))
-		return;
+	/*
+	 * NOTE: shared/gatt-client clears the database in case of failure. This
+	 * triggers the service_removed callback for all affected services.
+	 * Hence, this function will be called in the following cases:
+	 *
+	 *    1. When a GATT service gets removed due to "Service Changed".
+	 *
+	 *    2. When a GATT service gets removed when the database get cleared
+	 *       upon disconnection with a non-bonded device.
+	 *
+	 *    3. When a GATT service gets removed when the database get cleared
+	 *       by shared/gatt-client when its initialization procedure fails,
+	 *       e.g. due to an ATT protocol error or an unexpected disconnect.
+	 *       In this case the gatt-client will not be ready.
+	 */

 	gatt_db_attribute_get_service_handles(attr, &start, &end);


fix bit:nand and bit:nor

fix bit:nand and bit:nor

--- extensions/bit/ext_bit.c
+++ extensions/bit/ext_bit.c
@@ -136,7 +136,7 @@
 static xmlChar
 extBitOpNand (xmlChar lb, xmlChar rb)
 {
-    return (lb == '0' && rb == '0') ? '1' : '0';
+    return (lb == '1' && rb == '1') ? '0' : '1';
 }

 static void
@@ -148,7 +148,7 @@
 static xmlChar
 extBitOpNor (xmlChar lb, xmlChar rb)
 {
-    return (lb == '0' || rb == '0') ? '1' : '0';
+    return (lb == '1' || rb == '1') ? '0' : '1';
 }

 static void


Use SetErrorMode() to suppress errors with LoadLibrary()

We use LoadLibrary() to load plug-ins.  If there are unresolved
imports or if a dependent DLL cannot be found, Windows will show an
error indicating such.  The call to SetErrorMode() suppresses this
dialog and instead returns a failure code from LoadLibrary().  This is
desirable, since we are already handling load failures gracefully and
can prevent unnecessary interruptions when NetIDMgr is being loaded at
startup.

Change-Id: If79a83465e373cd05902390c00f383dfdeb35f8d

--- ui/main.c
+++ ui/main.c
@@ -542,6 +542,10 @@
            processes started by plugins. */
         SetEnvironmentVariable(L"KERBEROSLOGIN_NEVER_PROMPT", L"1");

+        /* Suppress error messages when we can't load a library due to
+           unmet dependencies or if the library can't be found. */
+        SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+
         khm_version_init();

         khm_commctl_version = khm_get_commctl_version(NULL);


Lib: Present "exchange_exchange_bindings" capability to server

--- librabbitmq/amqp_socket.c
+++ librabbitmq/amqp_socket.c
@@ -1302,7 +1302,7 @@
   {
     amqp_table_entry_t default_properties[6];
     amqp_table_t default_table;
-    amqp_table_entry_t client_capabilities[1];
+    amqp_table_entry_t client_capabilities[2];
     amqp_table_t client_capabilities_table;
     amqp_connection_start_ok_t s;
     amqp_pool_t *channel_pool;
@@ -1322,6 +1322,8 @@

     client_capabilities[0] =
         amqp_table_construct_bool_entry("authentication_failure_close", 1);
+    client_capabilities[1] =
+        amqp_table_construct_bool_entry("exchange_exchange_bindings", 1);

     client_capabilities_table.entries = client_capabilities;
     client_capabilities_table.num_entries =


Omit the space separating adjacent encoded words, as specified in RFC 1522.

--- parse_mail.c
+++ parse_mail.c
@@ -973,29 +973,28 @@
     int len;
     char buffer[256];

-    /* Try to fold on LF */
-    if (ch == '\n') {
-	self->state = lex_fold;
-	return 0;
-    }
-
     /* Watch for RFC 1522-encoded words */
     switch (self->rfc1522_state) {
     case 0:
-	self->rfc1522_state = (ch == '=') ? 1 : 0;
+    case 10:
+	self->rfc1522_state = (ch == '=') ? (self->rfc1522_state + 1) : 0;
 	self->enc_word_point = self->point;
 	break;

     case 1:
-	self->rfc1522_state = (ch == '?') ? 2 : (ch == '=') ? 1 : 0;
+    case 11:
+	self->rfc1522_state = (ch == '?') ? (self->rfc1522_state + 1) : (ch == '=') ? 1 : 0;
 	break;

     case 2:
-	self->rfc1522_state = istoken(ch) ? 3 : (ch == '=') ? 1 : 0;
+    case 12:
+	self->rfc1522_state = istoken(ch) ? (self->rfc1522_state + 1) : (ch == '=') ? 1 : 0;
 	break;

     case 3:
+    case 13:
     case 5:
+    case 15:
 	if (ch == '?') {
 	    self->rfc1522_state++;
 	} else if (!istoken(ch)) {
@@ -1004,18 +1003,21 @@
 	break;

     case 4:
+    case 14:
 	self->enc_enc_point = self->point;
-	self->rfc1522_state = istoken(ch) ? 5 : (ch == '=') ? 1 : 0;
+	self->rfc1522_state = istoken(ch) ? (self->rfc1522_state + 1) : (ch == '=') ? 1 : 0;
 	break;

     case 6:
+    case 16:
 	self->enc_text_point = self->point;
-	self->rfc1522_state = isenc(ch) ? 7 : (ch == '=') ? 1 : 0;
+	self->rfc1522_state = isenc(ch) ? (self->rfc1522_state + 1) : (ch == '=') ? 1 : 0;
 	break;

     case 7:
+    case 17:
 	if (ch == '?') {
-	    self->rfc1522_state = 8;
+	    self->rfc1522_state++;
 	} else if (!isenc(ch)) {
 	    self->point[0] = 0;
 	    self->rfc1522_state = (ch == '=') ? 1 : 0;
@@ -1023,47 +1025,54 @@
 	break;

     case 8:
-	self->rfc1522_state = 0;
-	if (ch == '=') {
+    case 18:
+	self->rfc1522_state = (ch == '=') ? (self->rfc1522_state + 1) : 0;
+	break;
+
+    case 9:
+    case 19:
+#ifdef DEBUG
+	*self->point = 0;
+	printf("encoded word: \"%s\"\n", self->enc_word_point);
+#endif /* DEBUG */
+
+	/* Null-terminate the component strings */
+	assert(self->enc_text_point[-1] == '?');
+	self->enc_text_point[-1] = 0;
+	assert(self->enc_enc_point[-1] == '?');
+	self->enc_enc_point[-1] = 0;
+	assert(self->point[-2] == '?');
+	self->point[-2] = 0;
+
+	/* Decode the string */
+	len = rfc1522_decode(self->enc_word_point + 2,
+			     self->enc_enc_point,
+			     self->enc_text_point,
+			     buffer, sizeof(buffer));
+	if (len < 0) {
+	    /* Unable to decode; revert the string and carry on */
+#ifdef DEBUG
+	    printf("decoding failed\n");
+#endif /* DEBUG */
+	    self->enc_text_point[-1] = '?';
+	    self->enc_enc_point[-1] = '?';
+	    self->point[-2] = '?';
 	    self->rfc1522_state = 0;
-
+	} else {
+	    /* Decoded; copy it into place.  If we're in state 19 then
+	     * we need to overwrite the preceding space too. */
+	    if (self->rfc1522_state == 19) {
+		self->enc_word_point--;
+	    }
+	    memcpy(self->enc_word_point, buffer, len);
+	    self->point = self->enc_word_point + len;
 #ifdef DEBUG
-	    self->point[0] = ch;
-	    self->point[1] = 0;
-	    printf("encoded word: %s\n", self->enc_word_point);
+	    *self->point = 0;
+	    printf("decoded w%crd: \"%s\"\n",
+		   self->rfc1522_state == 19 ? '*' : 'o',
+		   self->enc_word_point);
 #endif /* DEBUG */
-
-	    /* Null-terminate the component strings */
-	    assert(self->enc_text_point[-1] == '?');
-	    self->enc_text_point[-1] = 0;
-	    assert(self->enc_enc_point[-1] == '?');
-	    self->enc_enc_point[-1] = 0;
-	    assert(self->point[-1] == '?');
-	    self->point[-1] = 0;
-
-	    /* Decode the string */
-	    len = rfc1522_decode(self->enc_word_point + 2,
-				 self->enc_enc_point,
-				 self->enc_text_point,
-				 buffer, sizeof(buffer));
-	    if (len < 0) {
-		/* Unable to decode; revert the string and carry on */
-#ifdef DEBUG
-		printf("decoding failed\n");
-#endif /* DEBUG */
-		self->enc_text_point[-1] = '?';
-		self->enc_enc_point[-1] = '?';
-		self->point[-1] = '?';
-	    } else {
-		/* Decoded; copy it into place */
-		memcpy(self->enc_word_point, buffer, len);
-		self->point = self->enc_word_point + len;
-#ifdef DEBUG
-		*self->point = 0;
-		printf("decoded word: %s\n", self->enc_word_point);
-#endif /* DEBUG */
-		return 0;
-	    }
+	    self->rfc1522_state = isspace(ch) ? 10 : 0;
 	}
 	break;

@@ -1071,9 +1080,9 @@
 	abort();
     }

-    /* Compress whitespace */
+    /* Try to fold on LF */
     if (isspace(ch)) {
-	self->state = lex_body_ws;
+	self->state = (ch == '\n') ? lex_fold : lex_body_ws;
 	return 0;
     }


Linux: more freeifaddrs

Linux: more freeifaddrs

--- src/dhcpcd.c
+++ src/dhcpcd.c
@@ -2438,11 +2438,17 @@
 exit1:
 	if (control_stop(&ctx) == -1)
 		logerr("%s: control_stop", __func__);
+	if (ifaddrs != NULL) {
+#ifdef PRIVSEP_GETIFADDRS
+		if (IN_PRIVSEP(&ctx))
+			free(ifaddrs);
+		else
+#endif
+			freeifaddrs(ifaddrs);
+	}
 #ifdef PRIVSEP
 	ps_stop(&ctx);
 #endif
-	if (ifaddrs != NULL)
-		freeifaddrs(ifaddrs);
 	/* Free memory and close fd's */
 	if (ctx.ifaces) {
 		while ((ifp = TAILQ_FIRST(ctx.ifaces))) {


Skip values from the inputboxes with disabled autocompletion

--- extensions/formhistory.c
+++ extensions/formhistory.c
@@ -202,6 +202,8 @@
     const gchar* script = "function dumpForm (inputs) {"
                  "  var out = '';"
                  "  for (i=0;i<inputs.length;i++) {"
+                 "    if (inputs[i].getAttribute('autocomplete') == 'off')"
+                 "        continue;"
                  "    if (inputs[i].value && (inputs[i].type == 'text' || inputs[i].type == 'password')) {"
                  "        var ename = inputs[i].getAttribute('name');"
                  "        var eid = inputs[i].getAttribute('id');"


Implement max_heapify, build_heap_data, build_max_heap

--- maxHeap/maxHeap/Heap.h
+++ maxHeap/maxHeap/Heap.h
@@ -17,7 +17,6 @@
 #define LEFT_CHILD(i)   i * 2       //get node left-child
 #define RIGHT_CHILD(i)  i * 2 + 1   //get node right-child

-
 struct node {
     int key;
     char *value;
@@ -25,18 +24,19 @@

 struct priority_queue {
     int size;
-    struct node *array;
+    struct node *heap;
 };

-void max_heapify(struct priority_queue p_queue, int i);
-void build_max_heap(struct priority_queue p_queue);
+void max_heapify(struct priority_queue p_queue, int i);         //Sort nodes of heap
+void build_max_heap(struct priority_queue p_queue);             //Make heap to max-heap
+struct priority_queue build_heap_data(FILE *fp);                //Get heap data from file

-int *insert(int *heap, struct node x);      //Insert x to heap
-int *max(int *heap);                        //Find max element in heap
-int *extract(int *heap);                    //Remove max element in heap
-int increase_key(int *heap, int x, int k);  //Increase value of x to k
-int h_delete(int *heap, int x);             //Delete element x
+int insert(struct priority_queue p_queue, struct node x);       //Insert x to heap
+int *max(struct priority_queue p_queue);                        //Find max element in heap
+int *extract(struct priority_queue p_queue);                    //Remove max element in heap
+int increase_key(struct priority_queue p_queue, int x, int k);  //Increase value of x to k
+int h_delete(struct priority_queue p_queue, int x);             //Delete element x

 void max_heapify(struct priority_queue p_queue, int i){

@@ -44,27 +44,57 @@
     int R = RIGHT_CHILD(i);
     int largest;

-
-    if(L <= p_queue.size && p_queue.array[L].key > p_queue.array[i].key) largest = L;
+    if(L <= p_queue.size && p_queue.heap[L].key > p_queue.heap[i].key) largest = L;
     else largest = i;

-    if(R <= p_queue.size && p_queue.array[R].key > p_queue.array[largest].key) largest = R;
+    if(R <= p_queue.size && p_queue.heap[R].key > p_queue.heap[largest].key) largest = R;

     if(largest != i){
-        struct node temp = p_queue.array[i];
-        p_queue.array[i] = p_queue.array[largest];
-        p_queue.array[largest] = temp;
-
+        struct node temp = p_queue.heap[i];
+        p_queue.heap[i] = p_queue.heap[largest];
+        p_queue.heap[largest] = temp;
         max_heapify(p_queue, largest);
     }
-
 }

 void build_max_heap(struct priority_queue p_queue){
-    int heap_size = p_queue.size;
-    for(int i = p_queue.size/2; i>0 ;){
+    int i = 0;
+    for(i = p_queue.size/2; i>0 ; i--){
         max_heapify(p_queue, i);
     }
+}
+
+struct priority_queue build_heap_data(FILE *fp) {
+
+    /* Init queue */
+    struct priority_queue new_queue;
+    new_queue.size = 0;
+
+    while(!feof(fp)){
+        if(new_queue.size == 0){
+            new_queue.heap = calloc(1,sizeof(struct node));
+        } else {
+            struct node *temp;
+            temp = realloc(new_queue.heap, (new_queue.size + 1) * sizeof(struct node));
+            new_queue.heap = temp;
+        }
+        fscanf(fp, "%d, %s",&new_queue.heap[new_queue.size].key, new_queue.heap[new_queue.size].value);
+        new_queue.size++;
+    }
+
+    return new_queue;
+};
+
+int insert(struct priority_queue p_queue, struct node x){
+
+    struct node *temp;
+    temp = realloc(p_queue.heap, (p_queue.size + 1) * sizeof(struct node));
+    p_queue.heap[p_queue.size] = x;
+    p_queue.size++;
+
+    max_heapify(p_queue, p_queue.size);
+
+    return 1;
 }


Create ip_addresses.c

Create ip_addresses.c

error: pathspec 'ip_addresses.c' did not match any file(s) known to git


driver: correctly filter on arg0 on all the replies from the driver

The filters need to be instantiated with the arg0 string, if one
exists in order for eavesdropping to work correctly.

Note that the driver only ever emmits replies with arg0 as a string,
never any other arguments and never object paths in stead of strings.

Signed-off-by: Tom Gundersen <7c8224529a7c718e876cb2496c973509fde1e50e@jklm.no>

--- src/driver.c
+++ src/driver.c
@@ -652,6 +652,7 @@
 }

 static int driver_method_hello(Peer *peer, CDVar *in_v, CDVar *out_v) {
+        char unique_name[UNIQUE_NAME_STRING_MAX + 1];
         int r;

         if (_c_unlikely_(peer_is_registered(peer)))
@@ -663,14 +664,13 @@
         if (r)
                 return error_trace(r);

+        unique_name_from_id(unique_name, peer->id);
+
         peer_register(peer);

-        c_dvar_write(out_v, "(");
-        driver_dvar_write_unique_name(out_v, peer);
-        c_dvar_write(out_v, ")");
-
-        /* XXX: pass arg0 */
-        r = driver_send_reply(peer, out_v, NULL);
+        c_dvar_write(out_v, "(s)", unique_name);
+
+        r = driver_send_reply(peer, out_v, unique_name);
         if (r)
                 return error_trace(r);

@@ -1001,7 +1001,8 @@
 }

 static int driver_method_get_name_owner(Peer *peer, CDVar *in_v, CDVar *out_v) {
-        const char *name_str;
+        const char *name_str, *owner_str;
+        char unique_name[UNIQUE_NAME_STRING_MAX + 1];
         int r;

         c_dvar_read(in_v, "(s)", &name_str);
@@ -1010,10 +1011,8 @@
         if (r)
                 return error_trace(r);

-        c_dvar_write(out_v, "(");
-
-        if (strcmp(name_str, "org.freedesktop.DBus") == 0) {
-                c_dvar_write(out_v, "s", "org.freedesktop.DBus");
+        if (!strcmp(name_str, "org.freedesktop.DBus")) {
+                owner_str = "org.freedesktop.DBus";
         } else {
                 Peer *owner;

@@ -1021,13 +1020,13 @@
                 if (!owner)
                         return DRIVER_E_NAME_OWNER_NOT_FOUND;

-                driver_dvar_write_unique_name(out_v, owner);
-        }
-
-        c_dvar_write(out_v, ")");
-
-        /* XXX: pass arg0 */
-        r = driver_send_reply(peer, out_v, NULL);
+                unique_name_from_id(unique_name, owner->id);
+                owner_str = unique_name;
+        }
+
+        c_dvar_write(out_v, "(s)", owner_str);
+
+        r = driver_send_reply(peer, out_v, owner_str);
         if (r)
                 return error_trace(r);

@@ -1242,8 +1241,7 @@
         c_string_to_hex(peer->bus->guid, sizeof(peer->bus->guid), buffer);
         c_dvar_write(out_v, "(s)", buffer);

-        /* XXX: pass arg0 */
-        r = driver_send_reply(peer, out_v, NULL);
+        r = driver_send_reply(peer, out_v, buffer);
         if (r)
                 return error_trace(r);


Don't leak form suggestions and don't return from the loop

--- extensions/formhistory.c
+++ extensions/formhistory.c
@@ -75,20 +75,26 @@
 static gchar*
 formhistory_build_js ()
 {
-    const gchar* suggestions = "";
+    gchar* suggestions = g_strdup ("");
     GHashTableIter iter;
     gpointer key, value;
+    gchar* script;
+
     g_hash_table_iter_init (&iter, global_keys);
     while (g_hash_table_iter_next (&iter, &key, &value))
-       suggestions = g_strdup_printf ("%s arr[\"%s\"] = [%s]; ",
-                                      suggestions, (char*)key, (char*)value);
-    gchar* script = g_strdup_printf ("function FormSuggestions(eid) { "
-                                     "arr = new Array();"
-                                     "%s"
-                                     "this.suggestions = arr[eid]; }"
-                                     "%s",
-                                     suggestions,
-                                     jsforms);
+    {
+       gchar* _suggestions = g_strdup_printf ("%s arr[\"%s\"] = [%s]; ",
+                                              suggestions, (char*)key, (char*)value);
+       katze_assign (suggestions, _suggestions);
+    }
+    script = g_strdup_printf ("function FormSuggestions(eid) { "
+                              "arr = new Array();"
+                              "%s"
+                              "this.suggestions = arr[eid]; }"
+                              "%s",
+                              suggestions,
+                              jsforms);
+    g_free (suggestions);
    return script;
 }

@@ -104,7 +110,7 @@
     while (g_hash_table_iter_next (&iter, (gpointer)&key, (gpointer)&value))
     {
         if (value && *value && (strlen (value) > MAXCHARS || strlen (value) < MINCHARS))
-            return;
+            continue;

         tmp = g_hash_table_lookup (global_keys, (gpointer)key);
         if (tmp)


Enforce attribute check of the virRegister functions

Signed-off-by: Pavel Hrdina <d4772d05997b8abf035041e3b4f4996380ea7e7a@redhat.com>

--- src/driver.h
+++ src/driver.h
@@ -2132,15 +2132,15 @@
  * TODO: also need ways to (des)activate a given driver
  *       lookup based on the URI given in a virConnectOpen(ReadOnly)
  */
-int virRegisterDriver(virDriverPtr);
-int virRegisterNetworkDriver(virNetworkDriverPtr);
-int virRegisterInterfaceDriver(virInterfaceDriverPtr);
-int virRegisterStorageDriver(virStorageDriverPtr);
-int virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr);
-int virRegisterSecretDriver(virSecretDriverPtr);
-int virRegisterNWFilterDriver(virNWFilterDriverPtr);
+int virRegisterDriver(virDriverPtr) ATTRIBUTE_RETURN_CHECK;
+int virRegisterNetworkDriver(virNetworkDriverPtr) ATTRIBUTE_RETURN_CHECK;
+int virRegisterInterfaceDriver(virInterfaceDriverPtr) ATTRIBUTE_RETURN_CHECK;
+int virRegisterStorageDriver(virStorageDriverPtr) ATTRIBUTE_RETURN_CHECK;
+int virRegisterNodeDeviceDriver(virNodeDeviceDriverPtr) ATTRIBUTE_RETURN_CHECK;
+int virRegisterSecretDriver(virSecretDriverPtr) ATTRIBUTE_RETURN_CHECK;
+int virRegisterNWFilterDriver(virNWFilterDriverPtr) ATTRIBUTE_RETURN_CHECK;
 # ifdef WITH_LIBVIRTD
-int virRegisterStateDriver(virStateDriverPtr);
+int virRegisterStateDriver(virStateDriverPtr) ATTRIBUTE_RETURN_CHECK;
 # endif
 void virDriverModuleInitialize(const char *defmoddir);
 void *virDriverLoadModule(const char *name);


fix, keep track of the sandwich flag when rounding the date part

Signed-off-by: Sebastian Freundt <1f0829204b3475c52f714f96be4e7b39a87b6e74@ga-group.nl>

--- src/dround.c
+++ src/dround.c
@@ -309,7 +309,9 @@
 		}
 	} else if (dt_sandwich_only_d_p(dur) &&
 		   (dt_sandwich_p(d) || dt_sandwich_only_d_p(d))) {
+		unsigned int sw = d.sandwich;
 		d.d = dround_ddur(d.d, dur.d, nextp);
+		d.sandwich = sw;
 	}
 	return d;
 }


dvbpsi.c: fix bug in dvbpsi_decoder_psi_section_add()

Inserting a new PSI section did not take into account that the previous
pointer could be none existing. It was equal to the start of the list,
which resulted in a loop.

(Fixes commit: 57c6cd6360106fe6ca9738d2fc52a2a87ad276cb)

--- src/dvbpsi.c
+++ src/dvbpsi.c
@@ -238,16 +238,19 @@
 {
     assert(p_decoder);
     assert(p_section);
-
+    assert(p_section->p_next == NULL);
+
+    /* Empty list */
     if (!p_decoder->p_sections)
     {
         p_decoder->p_sections = p_section;
+        p_section->p_next = NULL;
         return false;
     }

     /* Insert in right place */
     dvbpsi_psi_section_t *p = p_decoder->p_sections;
-    dvbpsi_psi_section_t *p_prev = p;
+    dvbpsi_psi_section_t *p_prev = NULL;
     bool b_overwrite = false;

     while (p)
@@ -260,14 +263,22 @@
             p->p_next = NULL;
             dvbpsi_DeletePSISections(p);
             b_overwrite = true;
-            break;
+            goto out;
         }
         else if (p->i_number > p_section->i_number)
         {
-            /* Insert */
-            p_prev->p_next = p_section;
-            p_section->p_next = p;
-            break;
+            /* Insert before p */
+            if (p_prev)
+            {
+                p_prev->p_next = p_section;
+                p_section->p_next = p;
+            }
+            else
+            {
+                p_section->p_next = p;
+                p_decoder->p_sections = p_section;
+            }
+            goto out;
         }

         p_prev = p;
@@ -278,8 +289,10 @@
     if (p_prev->i_number < p_section->i_number)
     {
         p_prev->p_next = p_section;
-    }
-
+        p_section->p_next = NULL;
+    }
+
+out:
     return b_overwrite;
 }


samd21: do not redefine LITTLE_ENDIAN

samd21: do not redefine LITTLE_ENDIAN

--- cpu/samd21/include/samd21.h
+++ cpu/samd21/include/samd21.h
@@ -227,7 +227,9 @@
  * \brief Configuration of the Cortex-M0+ Processor and Core Peripherals
  */

-#define LITTLE_ENDIAN          1
+#ifndef LITTLE_ENDIAN
+#   define LITTLE_ENDIAN       1
+#endif
 #define __CM0PLUS_REV          1         /*!< Core revision r0p1 */
 #define __MPU_PRESENT          0         /*!< MPU present or not */
 #define __NVIC_PRIO_BITS       2         /*!< Number of bits used for Priority Levels */


Create romanToDecimal.c

Create romanToDecimal.c

I've created a program that receive a roman number and converts to a decimal number.

error: pathspec 'math/romanToDecimal.c' did not match any file(s) known to git

--- math/romanToDecimal.c
+++ math/romanToDecimal.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#define MAX 20
+
+void calulaDec(int tam, char romano[MAX]) {
+	int i, dec = 0;
+
+	for(i = 0; i < tam; i++) {
+		if(romano[i] == 'C' && romano[i + 1] == 'M') {
+			dec += 900;
+			i++;
+		}
+		else if(romano[i] == 'C' && romano[i + 1] == 'D') {
+			dec += 400;
+			i++;
+		}
+		else if(romano[i] == 'X' && romano[i + 1] == 'C') {
+			dec += 90;
+			i++;
+		}
+		else if(romano[i] == 'X' && romano[i + 1] == 'L') {
+			dec += 40;
+			i++;
+		}
+		else if(romano[i] == 'I' && romano[i + 1] == 'X') {
+			dec += 9;
+			i++;
+		}
+		else if(romano[i] == 'I' && romano[i + 1] == 'V') {
+			dec += 4;
+			i++;
+		}
+		else if(romano[i] == 'M')
+			dec += 1000;
+		else if(romano[i] == 'D')
+			dec += 500;
+		else if(romano[i] == 'C')
+			dec += 100;
+		else if(romano[i] == 'L')
+			dec += 50;
+		else if(romano[i] == 'X')
+			dec += 10;
+		else if(romano[i] == 'V')
+			dec += 5;
+		else if(romano[i] == 'I')
+			dec += 1;
+	}
+
+	printf("%d\n", dec);
+}
+
+int main() {
+	char romano[MAX];
+	int tam;
+
+	scanf("%s", romano);
+	tam = strlen(romano);
+	calulaDec(tam, romano);
+
+	return 0;
+}


Fixes a logic error for when samples are unavailable.  Now, data representing 0dB is returned instead of amplitude 0, which represents the largest negative amplitude.  Now that it can be seen that the graph cuts out earlier than the audio, it shows how displaced the graph is.

--- src/editor.c
+++ src/editor.c
@@ -4817,7 +4817,12 @@
 		for(ctr2=0;ctr2 < num;ctr2++)
 		{	//For each requested waveform slice, add the data
 			if(slicestart + ctr2 + 1 > waveform->numslices)	//If the next slice to process doesn't exist
+			{
+				if(ctr2 == 0)	//If the first amplitude is unavailable,
+					results.min=results.peak=results.rms=waveform->zeroamp;	//Set it to a 0dB amplitude
+
 				break;					//exit this loop
+			}

 			results.min += channel[slicestart + ctr2].min;
 			results.peak += channel[slicestart + ctr2].peak;


when removing client, decrement maxBarrierCount too

--- crserverlib/server_stream.c
+++ crserverlib/server_stream.c
@@ -210,6 +210,7 @@
 					crFree(q);
 				}
 				cr_server.numClients--;
+				cr_server.maxBarrierCount--;
 				return;
 			}
 			q = q->next;


Support for alloca (untested)

Support for alloca (untested)

git-svn-id: 42b1393cca5d551bec90c34575d0b84245f1dba8@9063 0101bb08-14d6-0310-b084-bc0e0c8e3800

--- libspeex/stack_alloc.h
+++ libspeex/stack_alloc.h
@@ -60,9 +60,12 @@

 #endif

-#ifdef VAR_ARRAYS
+#if defined(VAR_ARRAYS)
 #define VARDECL(var)
 #define ALLOC(var, size, type) type var[size]
+#elif defined(USE_ALLOCA)
+#define VARDECL(var) var
+#define ALLOC(var, size, type) var = alloca(sizeof(type)*size)
 #else
 #define VARDECL(var) var
 #define ALLOC(var, size, type) var = PUSH(stack, size, type)