groonga-http: use application/javascript for JSONP

--- src/groonga.c
+++ src/groonga.c
@@ -1032,8 +1032,11 @@
 } ht_context;

 static void
-h_output_set_header(grn_ctx *ctx, grn_obj *header,
-                    grn_rc rc, long long int content_length)
+h_output_set_header(grn_ctx *ctx,
+                    grn_obj *header,
+                    grn_rc rc,
+                    long long int content_length,
+                    grn_obj *foot)
 {
   switch (rc) {
   case GRN_SUCCESS :
@@ -1058,7 +1061,14 @@
                GRN_TEXT_VALUE(&http_response_server_line),
                GRN_TEXT_LEN(&http_response_server_line));
   GRN_TEXT_PUTS(ctx, header, "Content-Type: ");
-  GRN_TEXT_PUTS(ctx, header, grn_ctx_get_mime_type(ctx));
+  if (grn_ctx_get_output_type(ctx) == GRN_CONTENT_JSON &&
+      foot &&
+      GRN_TEXT_LEN(foot) > 0 &&
+      GRN_TEXT_VALUE(foot)[GRN_TEXT_LEN(foot) - 1] == ';') {
+    GRN_TEXT_PUTS(ctx, header, "application/javascript");
+  } else {
+    GRN_TEXT_PUTS(ctx, header, grn_ctx_get_mime_type(ctx));
+  }
   GRN_TEXT_PUTS(ctx, header, "\r\n");
   if (content_length >= 0) {
     GRN_TEXT_PUTS(ctx, header, "Connection: close\r\n");
@@ -1185,10 +1195,10 @@

   if (!hc->in_body) {
     if (is_last_message) {
-      h_output_set_header(ctx, &header_, expr_rc, GRN_TEXT_LEN(&body_));
+      h_output_set_header(ctx, &header_, expr_rc, GRN_TEXT_LEN(&body_), NULL);
       hc->is_chunked = GRN_FALSE;
     } else {
-      h_output_set_header(ctx, &header_, expr_rc, -1);
+      h_output_set_header(ctx, &header_, expr_rc, -1, NULL);
       hc->is_chunked = GRN_TRUE;
     }
     header = &header_;
@@ -1258,7 +1268,8 @@
   h_output_set_header(ctx, &header, expr_rc,
                       GRN_TEXT_LEN(&head) +
                       GRN_TEXT_LEN(&body) +
-                      GRN_TEXT_LEN(&foot));
+                      GRN_TEXT_LEN(&foot),
+                      &foot);
   if (should_return_body) {
     h_output_send(ctx, fd, &header, &head, &body, &foot);
   } else {


Implement get_relation_constraint_oid_compat helper (#3836)

--- src/backend/distributed/commands/foreign_constraint.c
+++ src/backend/distributed/commands/foreign_constraint.c
@@ -42,6 +42,7 @@
 										  Var *referencedDistColumn,
 										  int *referencingAttrIndex,
 										  int *referencedAttrIndex);
+static Oid get_relation_constraint_oid_compat(HeapTuple heapTuple);

 /*
  * ConstraintIsAForeignKeyToReferenceTable checks if the given constraint is a
@@ -514,9 +515,7 @@

 		if (!inheritedConstraint && constraintForm->contype == CONSTRAINT_FOREIGN)
 		{
-			Oid constraintId = get_relation_constraint_oid(relationId,
-														   constraintForm->conname.data,
-														   true);
+			Oid constraintId = get_relation_constraint_oid_compat(heapTuple);
 			char *statementDef = pg_get_constraintdef_command(constraintId);

 			tableForeignConstraints = lappend(tableForeignConstraints, statementDef);
@@ -533,6 +532,31 @@
 	PopOverrideSearchPath();

 	return tableForeignConstraints;
+}
+
+
+/*
+ * get_relation_constraint_oid_compat returns OID of the constraint represented
+ * by the constraintForm, which is passed as an heapTuple. OID of the contraint
+ * is already stored in the constraintForm struct if major PostgreSQL version is
+ * 12. However, in the older versions, we should utilize HeapTupleGetOid to deduce
+ * that OID with no cost.
+ */
+static Oid
+get_relation_constraint_oid_compat(HeapTuple heapTuple)
+{
+	Assert(heapTuple != NULL);
+
+	Oid constraintOid = InvalidOid;
+
+#if PG_VERSION_NUM >= PG_VERSION_12
+	Form_pg_constraint constraintForm = (Form_pg_constraint) GETSTRUCT(heapTuple);
+	constraintOid = constraintForm->oid;
+#else
+	constraintOid = HeapTupleGetOid(heapTuple);
+#endif
+
+	return constraintOid;
 }


chip/stm32/debug_printf.h: Fix header guard

The include guard on debug_printf.h was __CROS_EC_DEBUG_H rather than
__CROS_EC_DEBUG_PRINTF_H. Unfortunately, debug.h also used
__CROS_EC_DEBUG_H which resulted in errors if both were included by a
single compilation unit.

BRANCH=none
BUG=b:180144572
TEST=./util/compare_build.sh -b all -j90

Signed-off-by: Bobby Casey <a3c107f0b4efaee07148ab0813ba992bba562a69@google.com>
Change-Id: I2354181644e1d50bf06a20ec51d432f4d583b50a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3735349
Reviewed-by: Tom Hughes <fc5c12f30a5ed2baa0581f44ee14ad1eb7b20d83@chromium.org>

--- chip/stm32/debug_printf.h
+++ chip/stm32/debug_printf.h
@@ -4,8 +4,8 @@
  */
 /* Synchronous UART debug printf */

-#ifndef __CROS_EC_DEBUG_H
-#define __CROS_EC_DEBUG_H
+#ifndef __CROS_EC_DEBUG_PRINTF_H
+#define __CROS_EC_DEBUG_PRINTF_H

 #ifdef CONFIG_DEBUG_PRINTF
 __attribute__((__format__(__printf__, 1, 2))) void
@@ -14,4 +14,4 @@
 #define debug_printf(...)
 #endif

-#endif /* __CROS_EC_DEBUG_H */
+#endif /* __CROS_EC_DEBUG_PRINTF_H */


[POWERPC] Add sane defaults for Xilinx EDK generated xparameters files

Signed-off-by: Grant Likely <9069e6f5a2b566e2674a0ba1e2bf39c12c195fad@secretlab.ca>
Signed-off-by: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>

--- arch/ppc/platforms/4xx/xparameters/xparameters.h
+++ arch/ppc/platforms/4xx/xparameters/xparameters.h
@@ -34,3 +34,63 @@
 	.io_type	 = SERIAL_IO_MEM,				\
   },
 #endif
+
+/*
+ * A few reasonable defaults for the #defines which could be missing depending
+ * on the IP version or variant (e.g. OPB vs PLB)
+ */
+
+#ifndef XPAR_EMAC_0_CAM_EXIST
+#define XPAR_EMAC_0_CAM_EXIST 0
+#endif
+#ifndef XPAR_EMAC_0_JUMBO_EXIST
+#define XPAR_EMAC_0_JUMBO_EXIST 0
+#endif
+#ifndef XPAR_EMAC_0_TX_DRE_TYPE
+#define XPAR_EMAC_0_TX_DRE_TYPE 0
+#endif
+#ifndef XPAR_EMAC_0_RX_DRE_TYPE
+#define XPAR_EMAC_0_RX_DRE_TYPE 0
+#endif
+#ifndef XPAR_EMAC_0_TX_INCLUDE_CSUM
+#define XPAR_EMAC_0_TX_INCLUDE_CSUM 0
+#endif
+#ifndef XPAR_EMAC_0_RX_INCLUDE_CSUM
+#define XPAR_EMAC_0_RX_INCLUDE_CSUM 0
+#endif
+
+#ifndef XPAR_EMAC_1_CAM_EXIST
+#define XPAR_EMAC_1_CAM_EXIST 0
+#endif
+#ifndef XPAR_EMAC_1_JUMBO_EXIST
+#define XPAR_EMAC_1_JUMBO_EXIST 0
+#endif
+#ifndef XPAR_EMAC_1_TX_DRE_TYPE
+#define XPAR_EMAC_1_TX_DRE_TYPE 0
+#endif
+#ifndef XPAR_EMAC_1_RX_DRE_TYPE
+#define XPAR_EMAC_1_RX_DRE_TYPE 0
+#endif
+#ifndef XPAR_EMAC_1_TX_INCLUDE_CSUM
+#define XPAR_EMAC_1_TX_INCLUDE_CSUM 0
+#endif
+#ifndef XPAR_EMAC_1_RX_INCLUDE_CSUM
+#define XPAR_EMAC_1_RX_INCLUDE_CSUM 0
+#endif
+
+#ifndef XPAR_GPIO_0_IS_DUAL
+#define XPAR_GPIO_0_IS_DUAL 0
+#endif
+#ifndef XPAR_GPIO_1_IS_DUAL
+#define XPAR_GPIO_1_IS_DUAL 0
+#endif
+#ifndef XPAR_GPIO_2_IS_DUAL
+#define XPAR_GPIO_2_IS_DUAL 0
+#endif
+#ifndef XPAR_GPIO_3_IS_DUAL
+#define XPAR_GPIO_3_IS_DUAL 0
+#endif
+#ifndef XPAR_GPIO_4_IS_DUAL
+#define XPAR_GPIO_4_IS_DUAL 0
+#endif
+


libteam: use "err" for error messages instead of printf

Signed-off-by: Jiri Pirko <fa978af6b66b63204eae0f383d59a9477a8acf5e@redhat.com>

--- lib/libteam.c
+++ lib/libteam.c
@@ -354,17 +354,17 @@

 		if (nla_parse_nested(port_attrs, TEAM_ATTR_PORT_MAX,
 				     nl_port, NULL)) {
-			printf("failed to parse nested attributes.\n");
+			err(th, "failed to parse nested attributes.\n");
 			return NL_SKIP;
 		}

 		if (!port_attrs[TEAM_ATTR_PORT_IFINDEX]) {
-			printf("ifindex port attribute not found\n");
+			err(th, "ifindex port attribute not found\n");
 			return NL_SKIP;
 		}
 		port = malloc(sizeof(struct team_port));
 		if (!port) {
-			printf("malloc failed.\n");
+			err(th, "malloc failed.\n");
 			return NL_SKIP;
 		}
 		memset(port, 0, sizeof(struct team_port));
@@ -603,7 +603,7 @@

 		if (nla_parse_nested(option_attrs, TEAM_ATTR_OPTION_MAX,
 				     nl_option, NULL)) {
-			printf("failed to parse nested attributes.\n");
+			err(th, "failed to parse nested attributes.\n");
 			return NL_SKIP;
 		}

@@ -614,7 +614,7 @@
 		}
 		name = nla_get_string(option_attrs[TEAM_ATTR_OPTION_NAME]);
 		if (__find_option(&tmp_list, name)) {
-			printf("option named \"%s\" is already in list.\n", name);
+			err(th, "option named \"%s\" is already in list.\n", name);
 			continue;
 		}

@@ -638,7 +638,7 @@
 			opt_type = TEAM_OPTION_TYPE_STRING;
 			break;
 		default:
-			printf("unknown nla_type received.\n");
+			err(th, "unknown nla_type received.\n");
 			continue;
 		}

@@ -1107,7 +1107,7 @@
 	int grp_id;

 	if (!ifindex) {
-		printf("Passed interface index %d is not valid.\n", ifindex);
+		err(th, "Passed interface index %d is not valid.\n", ifindex);
 		return -ENOENT;
 	}
 	th->ifindex = ifindex;
@@ -1116,32 +1116,32 @@

 	err = genl_connect(th->nl_sock);
 	if (err) {
-		printf("Failed to connect to netlink sock.\n");
+		err(th, "Failed to connect to netlink sock.\n");
 		return -nl2syserr(err);
 	}

 	err = genl_connect(th->nl_sock_event);
 	if (err) {
-		printf("Failed to connect to netlink event sock.\n");
+		err(th, "Failed to connect to netlink event sock.\n");
 		return -nl2syserr(err);
 	}

 	th->family = genl_ctrl_resolve(th->nl_sock, TEAM_GENL_NAME);
 	if (th->family < 0) {
-		printf("Failed to resolve netlink family.\n");
+		err(th, "Failed to resolve netlink family.\n");
 		return -nl2syserr(th->family);
 	}

 	grp_id = genl_ctrl_resolve_grp(th->nl_sock, TEAM_GENL_NAME,
 				       TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME);
 	if (grp_id < 0) {
-		printf("Failed to resolve netlink multicast groups.\n");
+		err(th, "Failed to resolve netlink multicast groups.\n");
 		return -nl2syserr(grp_id);
 	}

 	err = nl_socket_add_membership(th->nl_sock_event, grp_id);
 	if (err < 0) {
-		printf("Failed to add netlink membership.\n");
+		err(th, "Failed to add netlink membership.\n");
 		return -nl2syserr(err);
 	}

@@ -1156,13 +1156,13 @@

 	err = get_port_list(th);
 	if (err) {
-		printf("Failed to get port list.\n");
+		err(th, "Failed to get port list.\n");
 		return err;
 	}

 	err = get_options(th);
 	if (err) {
-		printf("Failed to get options.\n");
+		err(th, "Failed to get options.\n");
 		return err;
 	}


OpenGL: set GL format before instanciating QApplication

as recommended in the Qt docs:
http://doc.qt.io/qt-5/qopenglwidget.html#details

--- src/gui/gui.h
+++ src/gui/gui.h
@@ -40,6 +40,8 @@
     class App {
       public:
         App (int& cmdline_argc, char** cmdline_argv) {
+          ::MR::GUI::GL::set_default_context ();
+
           new QApplication (cmdline_argc, cmdline_argv);

           ::MR::ProgressInfo::display_func = Dialog::ProgressBar::display;
@@ -48,8 +50,6 @@
           ::MR::Exception::display_func = Dialog::display_exception;

           ::MR::App::check_overwrite_files_func = Dialog::File::check_overwrite_files_func;
-
-          ::MR::GUI::GL::set_default_context ();
         }

         ~App () {


Added runtime dir bookmark.

Added runtime dir bookmark.

--- src/gui_cpp.h
+++ src/gui_cpp.h
@@ -1895,7 +1895,11 @@

     imguiBeginScroll(_height, &_state.m_scroll);

-    const uint8_t button = imguiTabs(UINT8_MAX, true, ImguiAlign::LeftIndented, 21, 0, 3, "Root", "Home", "Desktop");
+    imguiSeparatorLine(1);
+    imguiSeparator(2);
+    const uint8_t button = imguiTabs(UINT8_MAX, true, ImguiAlign::LeftIndented, 21, 0, 4, "Root", "Home", "Desktop", "Runtime");
+    imguiSeparatorLine(1);
+    imguiSeparator(4);

     for (size_t ii = 0, end = dir.n_files; ii < end; ii++)
     {
@@ -1986,9 +1990,13 @@
         {
             dm::homeDir(_state.m_directory);
         }
-        else //if (2 == button). // desktop
+        else if (2 == button) // desktop
         {
             dm::desktopDir(_state.m_directory);
+        }
+        else //if (3 == button). // runtime
+        {
+            bx::pwd(_state.m_directory, DM_PATH_LEN);
         }
     }

@@ -2025,7 +2033,11 @@

     imguiBeginScroll(_height, &_state.m_scroll, true);

-    const uint8_t button = imguiTabs(UINT8_MAX, true, ImguiAlign::LeftIndented, 21, 0, 3, "Root", "Home", "Desktop");
+    imguiSeparatorLine(1);
+    imguiSeparator(2);
+    const uint8_t button = imguiTabs(UINT8_MAX, true, ImguiAlign::LeftIndented, 21, 0, 4, "Root", "Home", "Desktop", "Runtime");
+    imguiSeparatorLine(1);
+    imguiSeparator(4);

     for (size_t ii = 0, end = dir.n_files; ii < end; ii++)
     {
@@ -2144,9 +2156,13 @@
         {
             dm::homeDir(_state.m_directory);
         }
-        else //if (2 == button). // desktop
+        else if (2 == button) // desktop
         {
             dm::desktopDir(_state.m_directory);
+        }
+        else //if (3 == button). // runtime
+        {
+            bx::pwd(_state.m_directory, DM_PATH_LEN);
         }
     }


Fix build on linux

Fix build on linux

--- Source/HeliumRain/Flare.h
+++ Source/HeliumRain/Flare.h
@@ -43,7 +43,7 @@
 	{ \
 		if (!ensure(Expression)) \
 		{ \
-			FlareReportError(TEXT(__FUNCTION__)); \
+			FlareReportError(__FUNCTION__); \
 		} \
 	} \
 	while (0)


Import the latest version ehopt.c from the Cygnus Sourceware anoncvs
repository (dated 5-3-1999).

This fixes the endless loop the assembler gets in when it is trying to
decide how big part of the exception handling table should be on the Alpha.
This version of this file allows qradiobutton.cpp from qt and widget.cc
from kdelibs11 to be compilable.

--- contrib/binutils/gas/ehopt.c
+++ contrib/binutils/gas/ehopt.c
@@ -261,17 +261,52 @@
      expressionS *exp;
      unsigned int *pnbytes;
 {
+  static int saw_size;
+  static symbolS *size_end_sym;
   static int saw_advance_loc4;
   static fragS *loc4_frag;
   static int loc4_fix;

+  if (saw_size
+      && S_IS_DEFINED (size_end_sym))
+    {
+      /* We have come to the end of the CIE or FDE.  See below where
+         we set saw_size.  We must check this first because we may now
+         be looking at the next size.  */
+      saw_size = 0;
+      saw_advance_loc4 = 0;
+    }
+
   if (flag_traditional_format)
     {
       /* Don't optimize.  */
     }
   else if (strcmp (segment_name (now_seg), ".eh_frame") != 0)
-    saw_advance_loc4 = 0;
-  else if (*pnbytes == 1
+    {
+      saw_size = 0;
+      saw_advance_loc4 = 0;
+    }
+  else if (! saw_size
+	   && *pnbytes == 4)
+    {
+      /* This might be the size of the CIE or FDE.  We want to know
+         the size so that we don't accidentally optimize across an FDE
+         boundary.  We recognize the size in one of two forms: a
+         symbol which will later be defined as a difference, or a
+         subtraction of two symbols.  Either way, we can tell when we
+         are at the end of the FDE because the symbol becomes defined
+         (in the case of a subtraction, the end symbol, from which the
+         start symbol is being subtracted).  Other ways of describing
+         the size will not be optimized.  */
+      if ((exp->X_op == O_symbol || exp->X_op == O_subtract)
+	  && ! S_IS_DEFINED (exp->X_add_symbol))
+	{
+	  saw_size = 1;
+	  size_end_sym = exp->X_add_symbol;
+	}
+    }
+  else if (saw_size
+	   && *pnbytes == 1
 	   && exp->X_op == O_constant
 	   && exp->X_add_number == DW_CFA_advance_loc4)
     {


allow address,redirect==NULL when status!=0

--- src/handler.c
+++ src/handler.c
@@ -77,7 +77,8 @@
     request->translate.transformation = response->transformation;

     if (response->status == (http_status_t)-1 ||
-        (response->address.type == RESOURCE_ADDRESS_NONE &&
+        (response->status == (http_status_t)0 &&
+         response->address.type == RESOURCE_ADDRESS_NONE &&
          response->redirect == NULL)) {
         http_server_send_message(request->request,
                                  HTTP_STATUS_INTERNAL_SERVER_ERROR,


correct allocation size

correct allocation size

--- src/handler.c
+++ src/handler.c
@@ -69,7 +69,7 @@
     struct request *request2;
     int ret;

-    request2 = p_malloc(request->pool, sizeof(*request));
+    request2 = p_malloc(request->pool, sizeof(*request2));

     ret = request_uri_parse(request, &request2->uri);
     if (ret < 0)
@@ -96,7 +96,7 @@
     struct translate_response *tr;
     const char *index_file = NULL;

-    request2 = p_malloc(request->pool, sizeof(*request));
+    request2 = p_malloc(request->pool, sizeof(*request2));
     uri = &request2->uri;

     ret = request_uri_parse(request, &request2->uri);


hidpp10: fix setting resolution on G9

hidpp10: fix setting resolution on G9

The G9 sends a short report and does not
have separate DPIs for x and y.

--- src/hidpp10.c
+++ src/hidpp10.c
@@ -2109,12 +2109,24 @@
 			       uint16_t yres)
 {
 	unsigned idx = dev->index;
-	union hidpp10_message resolution = CMD_CURRENT_RESOLUTION(REPORT_ID_LONG, idx, SET_LONG_REGISTER_REQ);
-
-	hidpp_set_unaligned_le_u16(&resolution.data[4], hidpp10_get_dpi_mapping(dev, xres));
-	hidpp_set_unaligned_le_u16(&resolution.data[6], hidpp10_get_dpi_mapping(dev, yres));
-
-	return hidpp10_request_command(dev, &resolution);
+	union hidpp10_message resolution = CMD_CURRENT_RESOLUTION(REPORT_ID_SHORT, idx, SET_REGISTER_REQ);
+	union hidpp10_message resolution_long = CMD_CURRENT_RESOLUTION(REPORT_ID_LONG, idx, SET_LONG_REGISTER_REQ);
+	int res;
+
+	switch (dev->profile_type) {
+	case HIDPP10_PROFILE_G9:
+		resolution.data[4] = hidpp10_get_dpi_mapping(dev, xres);
+		res = hidpp10_request_command(dev, &resolution);
+		break;
+        default:
+		hidpp_set_unaligned_le_u16(&resolution_long.data[4], hidpp10_get_dpi_mapping(dev, xres));
+		hidpp_set_unaligned_le_u16(&resolution_long.data[6], hidpp10_get_dpi_mapping(dev, yres));
+
+		res = hidpp10_request_command(dev, &resolution_long);
+		break;
+        }
+
+	return res;
 }

 /* -------------------------------------------------------------------------- */


hidpp10: use helper function to extract wpid/build information

Signed-off-by: Peter Hutterer <b9c50af7afa7642f6f854434cda9ffe54ece8b85@who-t.net>

--- src/hidpp10.c
+++ src/hidpp10.c
@@ -59,6 +59,12 @@
 	return (buf[1] << 8) | buf[0];
 }

+static inline uint16_t
+hidpp10_get_unaligned_u16(uint8_t *buf)
+{
+	return (buf[0] << 8) | buf[1];
+}
+
 const char *device_types[0xFF] = {
 	[0x00] = "Unknown",
 	[0x01] = "Keyboard",
@@ -489,8 +495,7 @@
 		return -1;

 	dev->report_interval = pairing_information.msg.string[2];
-	dev->wpid = (pairing_information.msg.string[3] << 8) |
-			pairing_information.msg.string[4];
+	dev->wpid = hidpp10_get_unaligned_u16(&pairing_information.msg.string[3]);
 	dev->device_type = pairing_information.msg.string[7];

 	res = hidpp10_request_command(device, &device_name);
@@ -543,8 +548,7 @@

 	res = hidpp10_request_command(device, &build_information);
 	if (res == 0) {
-		dev->build = (build_information.msg.string[1] << 8) |
-				build_information.msg.string[2];
+		dev->build = hidpp10_get_unaligned_u16(&build_information.msg.string[1]);
 	}

 	return 0;


Fix mixed decl in nstime.c

Fix mixed decl in nstime.c

Fix mixed decl in the gettimeofday() branch of nstime_update()

--- src/nstime.c
+++ src/nstime.c
@@ -128,9 +128,11 @@
 		time->ns = ts.tv_sec * BILLION + ts.tv_nsec;
 	}
 #else
-	struct timeval tv;
-	gettimeofday(&tv, NULL);
-	time->ns = tv.tv_sec * BILLION + tv.tv_usec * 1000;
+	{
+		struct timeval tv;
+		gettimeofday(&tv, NULL);
+		time->ns = tv.tv_sec * BILLION + tv.tv_usec * 1000;
+	}
 #endif

 	/* Handle non-monotonic clocks. */


Minor documentation fix.

Minor documentation fix.

--- src/numbbo.h
+++ src/numbbo.h
@@ -97,19 +97,14 @@
 const double * numbbo_get_largest_values_of_interest(const numbbo_problem_t *self);

 /**
- * Write initial variable values for the problem ${self} into
- * ${initial_solution}.
- *
-<<<<<<< local
+ * Return an initial solution, i.e. a feasible variable setting, to the
+ * problem.
+ *
+ * By default, the center of the problems region of interest
+ * is the initial solution.
+ *
  * @ref numbbo_get_smallest_values_of_interest
  * @ref numbbo_get_largest_values_of_interest
-=======
- * By default, the center of the ${problem}s region of interest
- * is the initial solution.
- *
- * See also numbbo_get_*_values_of_interest()
- *
->>>>>>> other
  */
 void numbbo_get_initial_solution(const numbbo_problem_t *self,
                                  double *initial_solution);


Entity tags: weak comparison for If-None-Match.

--- src/http/modules/ngx_http_not_modified_filter_module.c
+++ src/http/modules/ngx_http_not_modified_filter_module.c
@@ -13,7 +13,7 @@
 static ngx_uint_t ngx_http_test_if_unmodified(ngx_http_request_t *r);
 static ngx_uint_t ngx_http_test_if_modified(ngx_http_request_t *r);
 static ngx_uint_t ngx_http_test_if_match(ngx_http_request_t *r,
-    ngx_table_elt_t *header);
+    ngx_table_elt_t *header, ngx_uint_t weak);
 static ngx_int_t ngx_http_not_modified_filter_init(ngx_conf_t *cf);

@@ -69,7 +69,7 @@
     }

     if (r->headers_in.if_match
-        && !ngx_http_test_if_match(r, r->headers_in.if_match))
+        && !ngx_http_test_if_match(r, r->headers_in.if_match, 0))
     {
         return ngx_http_filter_finalize_request(r, NULL,
                                                 NGX_HTTP_PRECONDITION_FAILED);
@@ -84,7 +84,7 @@
         }

         if (r->headers_in.if_none_match
-            && !ngx_http_test_if_match(r, r->headers_in.if_none_match))
+            && !ngx_http_test_if_match(r, r->headers_in.if_none_match, 1))
         {
             return ngx_http_next_header_filter(r);
         }
@@ -161,10 +161,11 @@

 static ngx_uint_t
-ngx_http_test_if_match(ngx_http_request_t *r, ngx_table_elt_t *header)
+ngx_http_test_if_match(ngx_http_request_t *r, ngx_table_elt_t *header,
+    ngx_uint_t weak)
 {
     u_char     *start, *end, ch;
-    ngx_str_t  *etag, *list;
+    ngx_str_t   etag, *list;

     list = &header->value;

@@ -176,25 +177,42 @@
         return 0;
     }

-    etag = &r->headers_out.etag->value;
+    etag = r->headers_out.etag->value;

     ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-                   "http im:\"%V\" etag:%V", list, etag);
+                   "http im:\"%V\" etag:%V", list, &etag);
+
+    if (weak
+        && etag.len > 2
+        && etag.data[0] == 'W'
+        && etag.data[1] == '/')
+    {
+        etag.len -= 2;
+        etag.data += 2;
+    }

     start = list->data;
     end = list->data + list->len;

     while (start < end) {

-        if (etag->len > (size_t) (end - start)) {
+        if (weak
+            && end - start > 2
+            && start[0] == 'W'
+            && start[1] == '/')
+        {
+            start += 2;
+        }
+
+        if (etag.len > (size_t) (end - start)) {
             return 0;
         }

-        if (ngx_strncmp(start, etag->data, etag->len) != 0) {
+        if (ngx_strncmp(start, etag.data, etag.len) != 0) {
             goto skip;
         }

-        start += etag->len;
+        start += etag.len;

         while (start < end) {
             ch = *start;


Correct nullability for MIKMIDINoteEvent convenience methods.

--- Source/MIKMIDINoteEvent.h
+++ Source/MIKMIDINoteEvent.h
@@ -29,10 +29,10 @@
  *
  *  @return An initialized MIKMIDINoteEvent instance, or nil if an error occurred.
  */
-+ (nullable instancetype)noteEventWithTimeStamp:(MusicTimeStamp)timeStamp
-										   note:(UInt8)note
-									   velocity:(UInt8)velocity
-									   duration:(Float32)duration
++ (instancetype)noteEventWithTimeStamp:(MusicTimeStamp)timeStamp
+								  note:(UInt8)note
+							  velocity:(UInt8)velocity
+							  duration:(Float32)duration
 										channel:(UInt8)channel;

 /**
@@ -43,7 +43,7 @@
  *
  *  @return A new MIKMIDINoteEvent instance, or nil if there is an error.
  */
-+ (nullable instancetype)noteEventWithTimeStamp:(MusicTimeStamp)timeStamp message:(MIDINoteMessage)message;
++ (instancetype)noteEventWithTimeStamp:(MusicTimeStamp)timeStamp message:(MIDINoteMessage)message;

 // Properties


Remove "assumption" from struct ucc

Remove "assumption" from struct ucc

--- src/ucc/ucc.c
+++ src/ucc/ucc.c
@@ -63,9 +63,6 @@
 	const char **isystems;

 	int syntax_only;
-	int current_assumption;
-	int *assumptions;
-
 	enum mode mode;
 };

@@ -384,7 +381,9 @@
 static void parse_argv(
 		int argc, char **argv,
 		struct ucc *const state,
-		struct specvars *specvars)
+		struct specvars *specvars,
+		int *const assumptions,
+		int *const current_assumption)
 {
 	int i;

@@ -595,13 +594,13 @@

 					/* TODO: "asm-with-cpp"? */
 					if(!strcmp(arg, "c"))
-						state->current_assumption = mode_preproc;
+						*current_assumption = mode_preproc;
 					else if(!strcmp(arg, "cpp-output"))
-						state->current_assumption = mode_compile;
+						*current_assumption = mode_compile;
 					else if(!strcmp(arg, "asm") || !strcmp(arg, "assembler"))
-						state->current_assumption = mode_assemb;
+						*current_assumption = mode_assemb;
 					else if(!strcmp(arg, "none"))
-						state->current_assumption = -1; /* reset */
+						*current_assumption = -1; /* reset */
 					else
 						die("-x accepts \"c\", \"cpp-output\", \"asm\", \"assembler\" "
 								"or \"none\", not \"%s\"", arg);
@@ -683,7 +682,7 @@
 input:
 			n = dynarray_count(state->inputs);
 			dynarray_add(&state->inputs, argv[i]);
-			state->assumptions[n] = state->current_assumption;
+			assumptions[n] = *current_assumption;
 		}
 	}
 }
@@ -729,8 +728,6 @@
 	dynarray_add_tmparray(&state->isystems, append->isystems);

 	assert(!state->syntax_only);
-
-	state->assumptions = append->assumptions;

 	state->mode = append->mode;
 }
@@ -742,10 +739,12 @@
 	struct ucc argstate = { 0 };
 	struct specopts specopts = { 0 };
 	struct specvars specvars = { 0 };
+	int *assumptions;
+	int current_assumption;

 	argstate.mode = mode_link;
-	argstate.current_assumption = -1;
-	argstate.assumptions = umalloc((argc - 1) * sizeof(*state.assumptions));
+	current_assumption = -1;
+	assumptions = umalloc((argc - 1) * sizeof(*assumptions));

 	specvars.shared = 0;
 	specvars.stdinc = 1;
@@ -769,7 +768,7 @@
 	/* we must parse argv first for things like -nostdinc.
 	 * then we can parse the spec file, then we need to
 	 * append argv's inputs, etc onto the state from the spec file */
-	parse_argv(argc - 1, argv + 1, &argstate, &specvars);
+	parse_argv(argc - 1, argv + 1, &argstate, &specvars, assumptions, &current_assumption);

 	if(!specvars.output && argstate.mode == mode_link)
 		specvars.output = "a.out";
@@ -780,7 +779,9 @@
 			dynarray_count(specopts.initflags),
 			specopts.initflags,
 			&state,
-			&specvars);
+			&specvars,
+			assumptions,
+			&current_assumption);

 	/* ensure argument state is appended to (spec)state,
 	 * allowing it to override things like initflags */
@@ -837,7 +838,7 @@
 	process_files(
 			state.mode,
 			state.inputs,
-			state.assumptions,
+			assumptions,
 			specvars.output,
 			state.args,
 			state.backend,
@@ -846,7 +847,7 @@
 	for(i = 0; i < 4; i++)
 		dynarray_free(char **, state.args[i], free);
 	dynarray_free(char **, state.inputs, NULL);
-	free(state.assumptions);
+	free(assumptions);

 	return 0;
 }


Correct set_owner() call in unionfs_symlink()

--- src/unionfs.c
+++ src/unionfs.c
@@ -534,7 +534,7 @@
 	int res = symlink(from, t);
 	if (res == -1) return -errno;

-	set_owner(to); // no error check, since creating the file succeeded
+	set_owner(t); // no error check, since creating the file succeeded

 	remove_hidden(to, i); // remove hide file (if any)
 	return 0;


Do not free strings to avoid segfault :(

--- src/object.c
+++ src/object.c
@@ -280,14 +280,14 @@
     if (o->refcount <= 0) redisPanic("decrRefCount against refcount <= 0");
     if (o->refcount == 1) {
         switch(o->type) {
-        case REDIS_STRING: freeStringObject(o); break;
+        case REDIS_STRING: /* freeStringObject(o) */; break;
         case REDIS_LIST: freeListObject(o); break;
         case REDIS_SET: freeSetObject(o); break;
         case REDIS_ZSET: freeZsetObject(o); break;
         case REDIS_HASH: freeHashObject(o); break;
         default: redisPanic("Unknown object type"); break;
         }
-        zfree(o);
+        /* zfree(o); */
     } else {
         o->refcount--;
     }


Handle infinite explicitly in createStringObjectFromLongLong().

--- src/object.c
+++ src/object.c
@@ -111,18 +111,30 @@

 /* Create a string object from a long double. If humanfriendly is non-zero
  * it does not use exponential format and trims trailing zeroes at the end,
- * however this result in loss of precision. Otherwise exp format is used
- * and the output of snprintf() is not modified. */
+ * however this results in loss of precision. Otherwise exp format is used
+ * and the output of snprintf() is not modified.
+ *
+ * The 'humanfriendly' option is used for INCRBYFLOAT and HINCRBYFLOAT. */
 robj *createStringObjectFromLongDouble(long double value, int humanfriendly) {
     char buf[256];
     int len;

-    /* We use 17 digits precision since with 128 bit floats that precision
-     * after rounding is able to represent most small decimal numbers in a way
-     * that is "non surprising" for the user (that is, most small decimal
-     * numbers will be represented in a way that when converted back into
-     * a string are exactly the same as what the user typed.) */
-    if (humanfriendly) {
+    if (isinf(value)) {
+        /* Libc in odd systems (Hi Solaris!) will format infinite in a
+         * different way, so better to handle it in an explicit way. */
+        if (value > 0) {
+            memcpy(buf,"inf",3);
+            len = 3;
+        } else {
+            memcpy(buf,"-inf",4);
+            len = 4;
+        }
+    } else if (humanfriendly) {
+        /* We use 17 digits precision since with 128 bit floats that precision
+         * after rounding is able to represent most small decimal numbers in a
+         * way that is "non surprising" for the user (that is, most small
+         * decimal numbers will be represented in a way that when converted
+         * back into a string are exactly the same as what the user typed.) */
         len = snprintf(buf,sizeof(buf),"%.17Lf", value);
         /* Now remove trailing zeroes after the '.' */
         if (strchr(buf,'.') != NULL) {


Add PRIVILEGED_FUNCTION qualifiers to port files.

--- Source/include/portable.h
+++ Source/include/portable.h
@@ -338,7 +338,7 @@
  *
  */
 #if( portUSING_MPU_WRAPPERS == 1 )
-	portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters, portBASE_TYPE xRunPrivileged );
+	portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters, portBASE_TYPE xRunPrivileged ) PRIVILEGED_FUNCTION;
 #else
 	portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters );
 #endif
@@ -354,14 +354,14 @@
  * Setup the hardware ready for the scheduler to take control.  This generally
  * sets up a tick interrupt and sets timers for the correct tick frequency.
  */
-portBASE_TYPE xPortStartScheduler( void );
+portBASE_TYPE xPortStartScheduler( void ) PRIVILEGED_FUNCTION;

 /*
  * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
  * the hardware is left in its original condition after the scheduler stops
  * executing.
  */
-void vPortEndScheduler( void );
+void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;

 /*
  * The structures and methods of manipulating the MPU are contained within the
@@ -372,7 +372,7 @@
  */
 #if( portUSING_MPU_WRAPPERS == 1 )
 	struct xMEMORY_REGION;
-	void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, portSTACK_TYPE *pxBottomOfStack, unsigned portSHORT usStackDepth );
+	void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, portSTACK_TYPE *pxBottomOfStack, unsigned portSHORT usStackDepth ) PRIVILEGED_FUNCTION;
 #endif

 #ifdef __cplusplus


openbsd: fix uv_fs_sendfile() unused variable warnings

--- src/unix/fs.c
+++ src/unix/fs.c
@@ -468,6 +468,10 @@
     return -1;
   }
 #else
+  /* Squelch compiler warnings. */
+  (void) &in_fd;
+  (void) &out_fd;
+
   return uv__fs_sendfile_emul(req);
 #endif
 }


Include guard rename

Include guard rename

--- src/usb_hid.h
+++ src/usb_hid.h
@@ -30,8 +30,8 @@
  * OF SUCH DAMAGE.
  */

-#ifndef USB_HID_H_
-#define USB_HID_H_
+#ifndef __USB_HID_H__
+#define __USB_HID_H__

 #include "usb_defs.h"


preventing sign-conversion warnings

preventing sign-conversion warnings

--- StateOS/kernel/oskernel.h
+++ StateOS/kernel/oskernel.h
@@ -2,7 +2,7 @@

     @file    StateOS: oskernel.h
     @author  Rajmund Szymanski
-    @date    25.06.2020
+    @date    07.12.2020
     @brief   This file defines set of kernel functions for StateOS.

  ******************************************************************************
@@ -288,7 +288,7 @@
 #if HW_TIMER_SIZE == 0
 	return System.cnt;
 #else
-	return port_sys_time();
+	return (cnt_t)port_sys_time();
 #endif
 }


* src/transform.c (xfm_lens): initialize *lens_name to NULL

Otherwise, we might deal with an uninitialized lens_name in callers,
something that gcc 7.1 spots under -O3.

--- src/transform.c
+++ src/transform.c
@@ -734,6 +734,9 @@
                       struct tree *xfm, const char **lens_name) {
     struct tree *l = NULL;

+    if (lens_name != NULL)
+        *lens_name = NULL;
+
     for (l = xfm->children;
          l != NULL && !streqv("lens", l->label);
          l = l->next);


Adding include.

Adding include.

--- src/op/nms.h
+++ src/op/nms.h
@@ -4,8 +4,8 @@
 //:
 //: \file:    nms.h
 //: \details: TODO
-//: \author:  Robert J. Peters
-//: \date:    01/01/2014
+//: \author:  Reed P Morrison
+//: \date:    08/09/2018
 //:
 //:   Licensed under the Apache License, Version 2.0 (the "License");
 //:   you may not use this file except in compliance with the License.


Add operation handler to buffer manager.

--- src/dtkDistributed/dtkDistributedBufferManager.h
+++ src/dtkDistributed/dtkDistributedBufferManager.h
@@ -14,7 +14,68 @@

 #pragma once

+#include <dtkCore>
+
 #include "dtkDistributedExport.h"
+
+// ///////////////////////////////////////////////////////////////////
+// dtkDistributedBufferOperationManager
+// ///////////////////////////////////////////////////////////////////
+
+struct DTKDISTRIBUTED_EXPORT dtkDistributedBufferOperationManager
+{
+public:
+    virtual ~dtkDistributedBufferOperationManager(void) {;}
+
+public:
+    virtual void addAssign(char *result, void *source, qlonglong count) = 0;
+    virtual void subAssign(char *result, void *source, qlonglong count) = 0;
+    virtual void mulAssign(char *result, void *source, qlonglong count) = 0;
+    virtual void divAssign(char *result, void *source, qlonglong count) = 0;
+};
+
+// ///////////////////////////////////////////////////////////////////
+// dtkDistributedBufferOperationManagerTyped
+// ///////////////////////////////////////////////////////////////////
+
+template <typename T> struct dtkDistributedBufferOperationManagerTyped : public dtkDistributedBufferOperationManager
+{
+public:
+    void addAssign(char *result, void *source, qlonglong count);
+    void subAssign(char *result, void *source, qlonglong count);
+    void mulAssign(char *result, void *source, qlonglong count);
+    void divAssign(char *result, void *source, qlonglong count);
+};
+
+// ///////////////////////////////////////////////////////////////////
+
+template <typename T> inline void dtkDistributedBufferOperationManagerTyped<T>::addAssign(char *result, void *source, qlonglong count)
+{
+    dtkArray<T> r = dtkArray<T>::fromWritableRawData(reinterpret_cast<T *>(result), count);
+    const dtkArray<T> s = dtkArray<T>::fromRawData(reinterpret_cast<T *>(source), count);
+    std::transform(r.begin(), r.end(), s.begin(), r.begin(), std::plus<T>());
+}
+
+template <typename T> inline void dtkDistributedBufferOperationManagerTyped<T>::subAssign(char *result, void *source, qlonglong count)
+{
+    dtkArray<T> r = dtkArray<T>::fromWritableRawData(reinterpret_cast<T *>(result), count);
+    const dtkArray<T> s = dtkArray<T>::fromRawData(reinterpret_cast<T *>(source), count);
+    std::transform(r.begin(), r.end(), s.begin(), r.begin(), std::minus<T>());
+}
+
+template <typename T> inline void dtkDistributedBufferOperationManagerTyped<T>::mulAssign(char *result, void *source, qlonglong count)
+{
+    dtkArray<T> r = dtkArray<T>::fromWritableRawData(reinterpret_cast<T *>(result), count);
+    const dtkArray<T> s = dtkArray<T>::fromRawData(reinterpret_cast<T *>(source), count);
+    std::transform(r.begin(), r.end(), s.begin(), r.begin(), std::multiplies<T>());
+}
+
+template <typename T> inline void dtkDistributedBufferOperationManagerTyped<T>::divAssign(char *result, void *source, qlonglong count)
+{
+    dtkArray<T> r = dtkArray<T>::fromWritableRawData(reinterpret_cast<T *>(result), count);
+    const dtkArray<T> s = dtkArray<T>::fromRawData(reinterpret_cast<T *>(source), count);
+    std::transform(r.begin(), r.end(), s.begin(), r.begin(), std::divides<T>());
+}

 // ///////////////////////////////////////////////////////////////////
 // dtkDistributedBufferManager
@@ -23,14 +84,15 @@
 class DTKDISTRIBUTED_EXPORT dtkDistributedBufferManager
 {
 public:
-    virtual ~dtkDistributedBufferManager(void) {;}
+             dtkDistributedBufferManager(void);
+    virtual ~dtkDistributedBufferManager(void);

 public:
     template <typename T>    T *allocate(qlonglong capacity);
     template <typename T> void  deallocate(T *& buffer);

 protected:
-    virtual void *allocate(qlonglong objectSize, qlonglong capacity) = 0;
+    virtual void *allocate(qlonglong objectSize, qlonglong capacity, int metatype_id) = 0;
     virtual void  deallocate(void *buffer, qlonglong objectSize) = 0;

 public:
@@ -48,20 +110,47 @@
     virtual void get(qint32 from, qlonglong position, void *array, qlonglong count = 1) = 0;
     virtual void put(qint32 dest, qlonglong position, void *array, qlonglong count = 1) = 0;
     virtual void addAssign(qint32 dest, qlonglong position, void *array, qlonglong nelements = 1) = 0;
+    virtual void mulAssign(qint32 dest, qlonglong position, void *array, qlonglong nelements = 1) = 0;

+protected:
+    virtual bool canHandleOperationManager(void);
+
+protected:
+    dtkDistributedBufferOperationManager *operation_manager;
 };

 // ///////////////////////////////////////////////////////////////////
 // dtkDistributedBufferManager templated member functions
 // ///////////////////////////////////////////////////////////////////

+inline dtkDistributedBufferManager::dtkDistributedBufferManager(void) : operation_manager(NULL)
+{
+}
+
+inline dtkDistributedBufferManager::~dtkDistributedBufferManager(void)
+{
+}
+
+inline bool dtkDistributedBufferManager::canHandleOperationManager(void)
+{
+    return true;
+}
+
 template <typename T> inline T *dtkDistributedBufferManager::allocate(qlonglong capacity)
 {
-    return static_cast<T *>(this->allocate(sizeof(T), capacity));
+    if (this->canHandleOperationManager() && !this->operation_manager)
+        this->operation_manager = new dtkDistributedBufferOperationManagerTyped<T>();
+
+    return static_cast<T *>(this->allocate(sizeof(T), capacity, qMetaTypeId<T>()));
 }

 template <typename T> inline void dtkDistributedBufferManager::deallocate(T *& buffer)
 {
+    if (this->operation_manager && this->canHandleOperationManager()) {
+        delete this->operation_manager;
+        this->operation_manager = NULL;
+    }
+
     this->deallocate(buffer, sizeof(T));
     buffer = NULL;
 }


patch to fixed register spilling in unrolled loop

--- src/optreg.c
+++ src/optreg.c
@@ -368,7 +368,7 @@
       SetVecBit(iv, FRETREG-1, 0);
       SetVecBit(iv, DRETREG-1, 0);
    #endif
-#if 1
+#if 0
       fprintf(stderr, "available regs = %s\n", BV2VarNames(iv));
 #endif
    return(AnyBitsSet(iv));
@@ -1160,6 +1160,69 @@
       }
    }
 }
+
+
+void KeepVarTogether(int N, IGNODE **igarr)
+/*
+ * Assumption: igarr is already sorted based on nref (nread + nwrite).
+ * this function will keep the live ranges of same variable with same nref
+ * together; this helps register assignment to avoid register spilling for
+ * unrolled code
+ */
+{
+   int i, j, k, nref;
+   IGNODE *igp;
+   short var;
+
+   i = 0;
+   while (i < N-1)
+   {
+      nref = igarr[i]->nread + igarr[i]->nwrite;
+      var = igarr[i]->var;
+/*
+ *    skip if ignode of live range is for same var (and same nref)
+ */
+      k = i + 1;
+      while (k < N && igarr[k]->var == var
+             && nref == (igarr[k]->nread + igarr[k]->nwrite) )
+         k++;
+      i = k - 1;
+/*
+ *    find node for same var with same nref and swap it to the next position
+ */
+      j = i + 1;
+      while(j < N)
+      {
+/*
+ *       ignodes are sorted based on nref.check until number of ref becomes less
+ */
+         if ( nref > (igarr[j]-> nread + igarr[j]->nwrite) )
+         {
+            break;
+         }
+/*
+ *       because of previous condition, no need to check the nref
+ */
+         else if (igarr[j]->var == var) // && nref == igarr[j]->nread + ig...
+         {
+/*
+ *          swap with next node if not the same
+ */
+            if (j != i + 1)
+            {
+               igp = igarr[i+1];
+               igarr[i+1] = igarr[j];
+               igarr[j] = igp;
+               i++;  /* var & nref are same for this position too */
+            }
+         }
+         j++;
+      }
+      i++;
+   }
+
+}
+
 void SortConstrainedIG(int N, IGNODE **igs)
 /*
  * Right now, this routine just calls the unconstrained sort, but eventually
@@ -1291,7 +1354,16 @@
         igarr[ncon++] = ig;
      }
    }
+#if 0
+   fprintf(stderr, "SORT IG: ncon=%d, uncon=%d\n", ncon, n-ncon);
+#endif
    SortConstrainedIG(ncon, igarr);
+#if 1
+/*
+ * keep live ranges of same variable (which access count are same) together
+ */
+   KeepVarTogether(ncon, igarr);
+#endif
    SortUnconstrainedIG(n-ncon, igarr+ncon);
    *N = n;
    return(igarr);
@@ -1317,9 +1389,9 @@
    for (i=0; i < N; i++)
    {
       ig = igs[i];
-#if 0
-      fprintf(stderr, "**********reg assignment for: %s\n", STname[ig->var-1]);
-      fprintf(stderr, "liveregs = %s\n", BV2VarNames(ig->liveregs));
+#if 1
+      /*fprintf(stderr, "**********reg assignment for: %s\n", STname[ig->var-1]);*/
+      /*fprintf(stderr, "liveregs = %s\n", BV2VarNames(ig->liveregs));*/
       ig->reg = GetRegForAsg(FLAG2PTYPE(STflag[ig->var-1]), iv, ig->liveregs);
 #else
       SetVecAll(iv, 0);
@@ -1358,9 +1430,13 @@
          }
          ig->reg++;
          iret++;
+#if 0
+         if (ig->reg >= VDREGBEG && ig->reg < VDREGEND)
+         fprintf(stderr, "REG ASSIGNED = %d\n", ig->reg-VDREGBEG );
+#endif
       }
       else
-#if 1
+#if 0
          fko_warn(__LINE__, "NO FREE REGISTER FOR LR %d of VAR %s!!!\n",
                ig->ignum, STname[ig->var-1]);
 #else
@@ -1733,12 +1809,17 @@
  */
    assert(scope);
    *tnig = CalcScopeIG(scope);
+#if 0
+   fprintf(stderr, "\nIG without sorting: \n");
+   DumpIG(stderr, NIG, IG);
+#endif
    igs = SortIG(&N, thresh);
+   nret = DoIGRegAsg(N, igs);
+   CheckIG(N, igs);
 #if 0
    fprintf(stderr, "NIG=%d N=%d\n", *tnig, N);
-#endif
-   nret = DoIGRegAsg(N, igs);
-   CheckIG(N, igs);
+   DumpIG(stderr, N, igs);
+#endif
 #if 0
    /*fprintf(stderr,"IG ");
    //DumpIG(stderr,N,igs);
@@ -2567,6 +2648,15 @@
  */
             if (IS_DEST_INUSE_IMPLICITLY(ip->inst[0]))
             {
+/*
+ *             FIXED: if we have same register as source and destination too;
+ *             updating ip->use would prevent the source to change it later.
+ *             so, change the op2 here before updating the liverange
+ */
+               if (ip->inst[2] == -dest) /* op1 == op2*/
+                  ip->inst[2] = -src;
+               if (ip->inst[3] == -dest) /* op1 == op3*/
+                  ip->inst[3] = -src;
                BitVecComb(ip->use, ip->use, ivdst, '-');
                BitVecComb(ip->use, ip->use, ivsrc, '|');
             }
@@ -2805,8 +2895,8 @@
                }
 /*
  *             Majedul: Invalid read reported by valgrind!
- *             FIXED: CopyPropTrans() may change the ip itself but return NULL!
- *             What if DelInst() delete ip itself!!!!
+ *             FIXED: CopyPropTrans() may change the ip itself but
+ *             returning NULL! What if DelInst() delete ip itself!!!!
  *             use ipnext to keep track previous one.
  *             NOTE: if ip->next is deleted and CopyPropTrans returns NULL as
  *             the next inst of ip->next is NULL !!!
@@ -3194,7 +3284,8 @@
 /*
  *       FIXED: we can't combine unaligned vector load
  */
-         if (IS_LOAD(inst) && inst != VFLDS && inst != VDLDS
+         if (IS_LOAD(inst) && inst != VFLDS && inst != VDLDS
+               && inst != VFLDSB && inst != VDLDSB
                && !IS_UNALIGNED_VLOAD(inst))
          {
             k = -ip->inst[1];
@@ -3283,7 +3374,8 @@
  *       so, we can't do it with unaligned load
  *       FIXED.
  */
-         if (IS_LOAD(inst) && inst != VFLDS && inst != VDLDS
+         if (IS_LOAD(inst) && inst != VFLDS && inst != VDLDS
+               && inst != VFLDSB && inst != VDLDSB
                && !IS_UNALIGNED_VLOAD(inst))
          {
             k = -ipld->inst[1];


Add compilling directive

Add compilling directive

--- ring_buffer.h
+++ ring_buffer.h
@@ -1,4 +1,8 @@
 #include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif

 typedef struct ring_t           //some padding should be taking into consideration.
 {
@@ -29,5 +33,9 @@

 void rb_release(ring_t * rb);

+#ifdef __cplusplus
+}
+#endif

+


Revise based on Mark Roth comments.

Revise based on Mark Roth comments.

--- src/core/lib/security/transport/security_handshaker.c
+++ src/core/lib/security/transport/security_handshaker.c
@@ -166,12 +166,17 @@
   size_t unused_bytes_size = 0;
   result = tsi_handshaker_result_get_unused_bytes(
       h->handshaker_result, &unused_bytes, &unused_bytes_size);
-  grpc_slice leftover_slice =
-      grpc_slice_from_copied_buffer((char *)unused_bytes, unused_bytes_size);
   // Create secure endpoint.
-  h->args->endpoint = grpc_secure_endpoint_create(
-      protector, h->args->endpoint, &leftover_slice, 1);
-  grpc_slice_unref_internal(exec_ctx, leftover_slice);
+  if (unused_bytes_size > 0) {
+    grpc_slice slice =
+        grpc_slice_from_copied_buffer((char *)unused_bytes, unused_bytes_size);
+    h->args->endpoint =
+        grpc_secure_endpoint_create(protector, h->args->endpoint, &slice, 1);
+    grpc_slice_unref_internal(exec_ctx, slice);
+  } else {
+    h->args->endpoint =
+        grpc_secure_endpoint_create(protector, h->args->endpoint, NULL, 0);
+  }
   tsi_handshaker_result_destroy(h->handshaker_result);
   h->handshaker_result = NULL;
   // Clear out the read buffer before it gets passed to the transport.
@@ -223,17 +228,23 @@
         GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result);
   }
   // Send data to peer.
-  grpc_slice to_send = grpc_slice_from_copied_buffer(
-      (const char *)bytes_to_send, bytes_to_send_size);
-  grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &h->outgoing);
-  grpc_slice_buffer_add(&h->outgoing, to_send);
-  grpc_endpoint_write(exec_ctx, h->args->endpoint, &h->outgoing,
-                      &h->on_handshake_data_sent_to_peer);
-  // If handshake has completed, check peer and so on.
+  if (bytes_to_send_size > 0) {
+    grpc_slice to_send = grpc_slice_from_copied_buffer(
+        (const char *)bytes_to_send, bytes_to_send_size);
+    grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &h->outgoing);
+    grpc_slice_buffer_add(&h->outgoing, to_send);
+    grpc_endpoint_write(exec_ctx, h->args->endpoint, &h->outgoing,
+                        &h->on_handshake_data_sent_to_peer);
+  }
+  // If handshake has completed, check peer and so on. Otherwise, need to read
+  // more data from the peer.
   if (handshaker_result != NULL) {
     GPR_ASSERT(h->handshaker_result == NULL);
     h->handshaker_result = handshaker_result;
     error = check_peer_locked(exec_ctx, h);
+  } else {
+    grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+                       &h->on_handshake_data_received_from_peer);
   }
   return error;
 }
@@ -334,10 +345,6 @@
     gpr_mu_unlock(&h->mu);
     security_handshaker_unref(exec_ctx, h);
     return;
-  }
-  if (h->handshaker_result == NULL) {
-    grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
-                       &h->on_handshake_data_received_from_peer);
   }
   gpr_mu_unlock(&h->mu);
 }


Modified exceptions (now single bit integers)

--- src/utl_try.h
+++ src/utl_try.h
@@ -17,28 +17,31 @@
 # Exceptions

  Simple implementation of try/catch. try blocks can be nested.
- Exceptions are just integers > 0:
+ Exceptions are integers between 0 and 15

-  #define OUTOFMEM   100
-  #define WRONGINPUT 200
-
+  #define OUTOFMEM    1
+  #define WRONGINPUT  2
+  #define INTERNALERR 3
+
   try {
      ... code ...
-     if (something_failed) throw(execption_num)  // must be > 0
+     if (something_failed) throw(execption_num)  // must be > 0  and < 15
      some_other_func(); // you can trhow exceptions from other functions too
      ... code ...
   }
   catch(OUTOFMEM) {
      ... code ...
   }
-  catch(WRONGINPUT) {
+  catch(WRONGINPUT,INTERNALERR) {
      ... code ...
   }
   catchall {  // if not present, the exception will be ignored
      ... code ...
   }

-
+
+
+
 ** ]]] */

 //<<<//
@@ -48,26 +51,60 @@
 typedef struct utl_jb_s {
   jmp_buf           jmp;
   struct utl_jb_s  *prv;
-  int               err;
-  int32_t           flg;
+  const char       *fn;
+  int               ln;
+  int               ex;
+  int16_t           flg;
+  int16_t           id;
 } utl_jb_t;

 extern utl_jb_t *utl_jmp_list; // Defined in utl_hdr.c

-#define try  for ( utl_jb_t utl_jb = {.flg=0, .err=0, .prv=utl_jmp_list}; \
-                   !utl_jb.flg && (utl_jb.flg=1) && (utl_jmp_list=&utl_jb); \
-                   utl_jb.flg = utl_jb.flg == 1? (utl_jmp_list = utl_jb.prv, 1):1) \
-              if ((utl_jb.err = setjmp(utl_jb.jmp))== 0)
-
-#define catch(x) else if ((utl_jb.err == (x)) && (utl_jmp_list = utl_jb.prv, utl_jb.flg = 2))
-
-#define catchall else if ((utl_jb.err > 0) && (utl_jmp_list = utl_jb.prv, utl_jb.flg = 2))
-
-#define throw(x)  do {int ex_ = x; if (ex_ > 0 && utl_jmp_list) longjmp(utl_jmp_list->jmp,ex_); } while (0)
+#define UTL_TRY_INIT  {.flg=0, \
+                       .prv=utl_jmp_list, \
+                       .fn=utl_emptystring, \
+                       .ln=0, \
+                       .id=0}

-#define thrown()  utl_jb.err
-
-#define rethrow() throw(thrown())
+#define try  for ( utl_jb_t utl_jb = UTL_TRY_INIT; \
+                  !utl_jb.flg && (utl_jmp_list=&utl_jb); \
+                   utl_jmp_list=utl_jb.prv, utl_jb.flg=1) \
+              if ((utl_jb.ex = setjmp(utl_jb.jmp)) == 0)
+
+#define UTL_CATCH_TEST(x,y,w,z) ((1<<(x))|(1<<(y))|(1<<(w))|(1<<(z)))
+
+#define utl_catch(x,y,w,z) else if ( (utl_jb.ex  & UTL_CATCH_TEST(x,y,w,z)) \
+                                  && (utl_jmp_list=utl_jb.prv, utl_jb.flg=1))
+
+#define catch(...) utl_catch(utl_expand(utl_arg0(__VA_ARGS__,16)),\
+                             utl_expand(utl_arg1(__VA_ARGS__,16,16)),\
+                             utl_expand(utl_arg2(__VA_ARGS__,16,16,16)),\
+                             utl_expand(utl_arg3(__VA_ARGS__,16,16,16,16)))
+
+#define catchall else for ( utl_jmp_list=utl_jb.prv; \
+                           !utl_jb.flg; \
+                            utl_jb.flg=1)
+
+#define utl_throw(x,y)  do { \
+                          int ex_ = x; \
+                          if (ex_ > 0 && utl_jmp_list) {\
+                            utl_jmp_list->fn = __FILE__; \
+                            utl_jmp_list->ln = __LINE__;\
+                            utl_jmp_list->id = y;\
+                            longjmp(utl_jmp_list->jmp,ex_); \
+                          }\
+                        } while (0)
+
+#define throw(...) utl_throw(1<<(utl_expand(utl_arg0(__VA_ARGS__,0)) & 0xF),\
+                                 utl_expand(utl_arg1(__VA_ARGS__,0,0)))\
+
+#define rethrow()    utl_throw(utl_jb.ex,utl_jb.id)
+
+#define thrown()     utl_unpow2(utl_jb.ex)
+
+#define thrownid()   utl_jb.id
+#define thrownfile() utl_jb.fn
+#define thrownline() utl_jb.ln

 #endif
 //>>>//


data parsers BUGFIX multiple cases instance detection

when detecting multiple instances, take into account leaf-list and
list defined as shorthand case. Therefore we have to skip all
instances of the schema node  of first choice's data node (not just
the node itself).

--- src/tree_data.c
+++ src/tree_data.c
@@ -2225,7 +2225,7 @@
 autodelete:
     /* remove all nodes from other cases than 'sparent' */
     LY_TREE_FOR_SAFE(first_sibling, next, iter) {
-        if (node && iter == node) {
+        if (schemanode == iter->schema) {
             continue;
         }


Variant rework

Variant rework

--- src/variant.h
+++ src/variant.h
@@ -556,7 +556,7 @@
         constexpr bool move = !std::is_reference<T>::value && !std::is_const<T>::value;
         constexpr bool valid = std::is_copy_constructible<Type>::value
             || (move && std::is_move_constructible<Type>::value);
-        static_assert(valid, "The contained type must be at least MoveConstructible");
+        static_assert(valid, "The contained type must be CopyConstructible or MoveConstructible");
         using selector_t = conditional_t<move, std::true_type, std::false_type>;

         constructor_selector(std::addressof(value), selector_t{});


Fix argument order in method declarations.

--- src/output.c
+++ src/output.c
@@ -154,20 +154,6 @@
   xprintf(out, "} %s_vtable;\n", protocol_name);
 }

-static void declare_protocol_methods(FILE* out) {
-  method* meth;
-  field* arg;
-
-  for (meth = methods; meth; meth = meth->next) {
-    xprintf(out, "%s %s(%s*", meth->return_type, meth->name, protocol_name);
-
-    for (arg = meth->fields; arg; arg = arg->next)
-      xprintf(out, ", %s", arg->type);
-
-    xprintf(out, ");\n");
-  }
-}
-
 static void write_args(FILE* out, field* arg, char implicit) {
   /* Skip alignment-only and implicit members */
   while (arg && (arg->name[0] == ':' || arg->name[0] == implicit))
@@ -179,6 +165,18 @@
   /* Recursive case: Write earlier arguments, then this one */
   write_args(out, arg->next, implicit);
   xprintf(out, ", %s %s", arg->type, arg->name);
+}
+
+static void declare_protocol_methods(FILE* out) {
+  method* meth;
+
+  for (meth = methods; meth; meth = meth->next) {
+    xprintf(out, "%s %s(%s*", meth->return_type, meth->name, protocol_name);
+
+    write_args(out, meth->fields, 0);
+
+    xprintf(out, ");\n");
+  }
 }

 static void declare_element_ctors(FILE* out) {


data tree BUGFIX clear leaf dflt flag if value changes

Fixes #82

--- src/tree_data.c
+++ src/tree_data.c
@@ -430,6 +430,11 @@
         }
     }

+    if (!strcmp(leaf->value_str, val_str)) {
+        /* the value remains the same */
+        return EXIT_SUCCESS;
+    }
+
     backup = leaf->value_str;
     memcpy(&backup_val, &leaf->value, sizeof backup);
     leaf->value_str = lydict_insert(leaf->schema->module->ctx, val_str ? val_str : "", 0);
@@ -445,6 +450,9 @@

     /* value is correct, remove backup */
     lydict_remove(leaf->schema->module->ctx, backup);
+
+    /* clear the default flag, the value is different */
+    leaf->dflt = 0;

     if (leaf->schema->flags & LYS_UNIQUE) {
         /* locate the first parent list */


+write_string and changed vector syntax

+write_string and changed vector syntax

--- src/output.c
+++ src/output.c
@@ -4,6 +4,7 @@
 #include "output.h"

 void write_pair(object *obj, FILE *f, int h);
+void write_string(object *obj, FILE *f, int h);
 void write_vector(object *obj, FILE *f, int h);

 void write_object(object *obj, FILE *f, int h) {
@@ -17,10 +18,8 @@
         fprintf(f, "'%c'", to_char(obj));
     else if (is_number(obj))
         fprintf(f, "%.512g", to_number(obj));
-    else if (is_string(obj) && h)
-        fprintf(f, "%s", to_string(obj));
     else if (is_string(obj))
-        fprintf(f, "\"%s\"", to_string(obj));
+        write_string(obj, f, h);
     else if (is_symbol(obj))
         fprintf(f, "%s", to_symbol(obj));
     else if (is_compound(obj))
@@ -55,10 +54,14 @@
     unlock(obj);
 }

+void write_string(object *obj, FILE *f, int h) {
+    fprintf(f, h ? "%s" : "\"%s\"", to_string(obj));
+}
+
 void write_vector(object *obj, FILE *f, int h) {
     int k;

-    fprintf(f, "#(");
+    fprintf(f, "%%(");
     for (k = 0; k < vector_length(obj); k++) {
         write_object(vector_ref(obj, k), f, h);
         if (k < vector_length(obj) - 1)


data tree BUGFIX use of uninitialized variable

--- src/tree_data.c
+++ src/tree_data.c
@@ -3055,6 +3055,7 @@
                 if (iter->schema == ins->schema && iter->dflt) {
                     if (iter == sibling) {
                         ly_errno = LY_EINVAL;
+                        str = NULL;
                         LOGERR(LY_EINVAL, "Insert request refers node (%s) that is going to be auto-deleted.",
                                str = lyd_path(sibling));
                         free(str);


version bumped to 2.3.7

version bumped to 2.3.7

--- src/version.h
+++ src/version.h
@@ -1 +1 @@
-#define REDIS_VERSION "2.3.6"
+#define REDIS_VERSION "2.3.7"


Increment version number to v1.9.10

Increment version number to v1.9.10

--- src/version.h
+++ src/version.h
@@ -37,7 +37,7 @@

 #define SPGLIB_MAJOR_VERSION 1
 #define SPGLIB_MINOR_VERSION 9
-#define SPGLIB_MICRO_VERSION 9
+#define SPGLIB_MICRO_VERSION 10

 #endif


bump release

bump release

--- src/version.h
+++ src/version.h
@@ -12,6 +12,6 @@
 /* version macros */
 #define SCREENFETCH_C_VERSION_MAJOR "1"
 #define SCREENFETCH_C_VERSION_MINOR "4"
-#define SCREENFETCH_C_VERSION_RELEASE "0"
+#define SCREENFETCH_C_VERSION_RELEASE "1"

 #endif /* SCREENFETCH_C_VERSION_H */


edit to kick old nodes and new proto version

--- src/version.h
+++ src/version.h
@@ -30,13 +30,13 @@
 // network protocol versioning
 //

-static const int PROTOCOL_VERSION = 60016;
+static const int PROTOCOL_VERSION = 60060;

 // intial proto version, to be increased after version/verack negotiation
 static const int INIT_PROTO_VERSION = 209;

 // disconnect from peers older than this proto version
-static const int MIN_PEER_PROTO_VERSION = 60015;
+static const int MIN_PEER_PROTO_VERSION = 60051;

 // nTime field added to CAddress, starting with this version;
 // if possible, avoid requesting addresses nodes older than this


Give more context when indicating parse error near redirection

Signed-off-by: Sebastian Nowicki <72cef2e23c539c1a2a17e6651ec7265f998b0d23@gmail.com>

--- src/parser.c
+++ src/parser.c
@@ -303,7 +303,7 @@
 					if(isspace(*inputPtr)) {
 						inputPtr++;
 					}	else if(*inputPtr == '\0' || _isTerminator(*inputPtr)) {
-						fprintf(stderr, "mush: parse error near '%c'\n", *inputPtr);
+						fprintf(stderr, "mush: parse error near '%c%c'\n", *(inputPtr - 1), *inputPtr);
 						queueFree(commandQueue);
 						queueFree(tokens);
 						return NULL;


Update library version for V1.0.5

Update library version for V1.0.5

--- src/version.h
+++ src/version.h
@@ -1,3 +1,3 @@
 /* Generated file, do not edit. */
-#define APP_VERSION "v1.0.4+build.4.ga16b133"
-#define APP_VERSION_DATE "2018-05-09 15:55:15 +0700"
+#define APP_VERSION "1.0.5"
+#define APP_VERSION_DATE "2018-05-09 15:57:21 +0700"


Use strcmp to test lexeme

Use strcmp to test lexeme

--- src/parser.c
+++ src/parser.c
@@ -635,7 +635,7 @@
 {
     // I think I got this
     Token token = lexer_next(lexer);
-    if (token.lexeme != "=" && token.lexeme != "+=" && token.lexeme != "-=") {
+    if (strcmp(token.lexeme, "=") != 0 && strcmp(token.lexeme, "+=") != 0 && strcmp(token.lexeme, "-=") != 0) {
         parser_error(lexer, "Expected one of the following when parsing an assign_op and did not get them: = += -=");
         return false;
     }


revert last changes in version.h due to issues releated with polcoinj

--- src/version.h
+++ src/version.h
@@ -25,10 +25,10 @@
 // network protocol versioning
 //

-static const int PROTOCOL_VERSION = 70002;
+static const int PROTOCOL_VERSION = 70001;

 // earlier versions not supported
-static const int MIN_PROTO_VERSION = 70001;
+static const int MIN_PROTO_VERSION = 209;

 // nTime field added to CAddress, starting with this version;
 // if possible, avoid requesting addresses nodes older than this


Added the ability to parse HTTP/2 requests.

--- src/parser.c
+++ src/parser.c
@@ -696,7 +696,8 @@
   const char *lookfor;

   return !((lookfor = "HTTP/1.0", !memcmp (token, lookfor, 8)) ||
-           (lookfor = "HTTP/1.1", !memcmp (token, lookfor, 8)));
+           (lookfor = "HTTP/1.1", !memcmp (token, lookfor, 8)) ||
+           (lookfor = "HTTP/2", !memcmp (token, lookfor, 6)));
 }

 static char *
@@ -716,7 +717,8 @@
   else {
     req = line + strlen (meth);
     if ((proto = strstr (line, " HTTP/1.0")) == NULL &&
-        (proto = strstr (line, " HTTP/1.1")) == NULL) {
+        (proto = strstr (line, " HTTP/1.1")) == NULL &&
+        (proto = strstr (line, " HTTP/2")) == NULL) {
       return alloc_string ("-");
     }


version bump

version bump

--- src/version.h
+++ src/version.h
@@ -2,4 +2,4 @@

 #include <string>

-const std::string ACDC_VERSION = "1.00";+const std::string ACDC_VERSION = "1.01";


Removed warning

Removed warning

--- src/parser.c
+++ src/parser.c
@@ -65,27 +65,27 @@
 }

-Column_t** removeDuplicates(Column_t** old, uint64_t old_size, uint64_t* new_size){
-	uint64_t i,j;
-	uint64_t count = 0;
-	Column_t** new_arr = malloc(old_size*sizeof(Column_t*));
-	ALLOCATION_ERROR(new_arr);
-	for(j = 0; j<old_size; j++){
-		new_arr[j] = malloc(sizeof(Column_t));
-		ALLOCATION_ERROR(new_arr[j]);
-	}
-	for (i = 0; i < old_size; ++i) {
-		if(i == 0 || equal_col(&old[i], &old[i-1]) == False) {
-			new_arr[count]->column = old[i]->column;
-			new_arr[count]->op = old[i]->op;
-			new_arr[count]->value = old[i]->value;
-			count++;
-		}
-	}
-	new_arr = realloc(new_arr, count*sizeof(Column_t*));
-	*new_size = count;
-	return new_arr;
-}
+// Column_t** removeDuplicates(Column_t** old, uint64_t old_size, uint64_t* new_size){
+// 	uint64_t i,j;
+// 	uint64_t count = 0;
+// 	Column_t** new_arr = malloc(old_size*sizeof(Column_t*));
+// 	ALLOCATION_ERROR(new_arr);
+// 	for(j = 0; j<old_size; j++){
+// 		new_arr[j] = malloc(sizeof(Column_t));
+// 		ALLOCATION_ERROR(new_arr[j]);
+// 	}
+// 	for (i = 0; i < old_size; ++i) {
+// 		if(i == 0 || equal_col(&old[i], &old[i-1]) == False) {
+// 			new_arr[count]->column = old[i]->column;
+// 			new_arr[count]->op = old[i]->op;
+// 			new_arr[count]->value = old[i]->value;
+// 			count++;
+// 		}
+// 	}
+// 	new_arr = realloc(new_arr, count*sizeof(Column_t*));
+// 	*new_size = count;
+// 	return new_arr;
+// }

 // Boolean_t equal_col(const void *p1, const void *p2) {
 // 	const Column_t *f1 = *(Column_t**) p1;


Added additional error hint to format error ourput.

--- src/parser.c
+++ src/parser.c
@@ -1378,9 +1378,9 @@
   if (!glog->log_erridx)
     return;

-  for (i = 0; i < glog->log_erridx; ++i) {
+  for (i = 0; i < glog->log_erridx; ++i)
     LOG (("%s\n", glog->errors[i]));
-  }
+  LOG (("\n%s\n", ERR_HEADER));
 }

 /* Free all log errors stored during parsing. */


comment out unnecessary returns

comment out unnecessary returns

--- src/parser.c
+++ src/parser.c
@@ -70,7 +70,7 @@

     parser->state = MQTT_PARSER_STATE_REMAINING_LENGTH;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_REMAINING_LENGTH) {
@@ -108,7 +108,7 @@
     if (message->header.type == MQTT_MESSAGE_TYPE_CONNECT) {
       parser->state = MQTT_PARSER_STATE_CONNECT_PROTOCOL_NAME;

-      return MQTT_PARSER_RC_CONTINUE;
+      //return MQTT_PARSER_RC_CONTINUE;
     }
   }

@@ -117,7 +117,7 @@

     parser->state = MQTT_PARSER_STATE_CONNECT_PROTOCOL_VERSION;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_CONNECT_PROTOCOL_VERSION) {
@@ -131,7 +131,7 @@

     parser->state = MQTT_PARSER_STATE_CONNECT_FLAGS;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_CONNECT_FLAGS) {
@@ -150,7 +150,7 @@

     parser->state = MQTT_PARSER_STATE_CONNECT_KEEP_ALIVE;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_CONNECT_KEEP_ALIVE) {
@@ -170,7 +170,7 @@

     parser->state = MQTT_PARSER_STATE_CONNECT_WILL_TOPIC;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_CONNECT_WILL_TOPIC) {
@@ -180,7 +180,7 @@

     parser->state = MQTT_PARSER_STATE_CONNECT_WILL_MESSAGE;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_CONNECT_WILL_MESSAGE) {
@@ -190,7 +190,7 @@

     parser->state = MQTT_PARSER_STATE_CONNECT_USERNAME;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_CONNECT_USERNAME) {
@@ -200,7 +200,7 @@

     parser->state = MQTT_PARSER_STATE_CONNECT_PASSWORD;

-    return MQTT_PARSER_RC_CONTINUE;
+    //return MQTT_PARSER_RC_CONTINUE;
   }

   if (parser->state == MQTT_PARSER_STATE_CONNECT_PASSWORD) {


Update global test printing...

Update global test printing...

--- src/vm-test.c
+++ src/vm-test.c
@@ -30,7 +30,7 @@
     printf("global with %d fact%s\n", g->nfact, g->nfact == 1 ? "" : "s");
     for (i = 0; i < g->nfact; i++) {
         s = ohm_structure_to_string(OHM_STRUCTURE(g->facts[i]));
-        printf("  #%d: ", i); vm_fact_print(g->facts[i]); printf("\n");
+        printf("  #%d: ", i); vm_fact_print(stdout, g->facts[i]); printf("\n");
     }
 }

@@ -338,7 +338,7 @@
         case VM_TYPE_INTEGER: printf("%d", args[i].v.i); break;
         case VM_TYPE_DOUBLE:  printf("%f", args[i].v.d); break;
         case VM_TYPE_STRING:  printf("%s", args[i].v.s); break;
-        case VM_TYPE_GLOBAL:  vm_global_print(args[i].v.g); break;
+        case VM_TYPE_GLOBAL:  vm_global_print(stdout, args[i].v.g); break;
         default:              printf("<unknown type 0x%x>", args[i].type);
         }
         printf(" ");


iio.c: Replace sprintf with snprintf

iio.c: Replace sprintf with snprintf

Signed-off-by: Brendan Le Foll <3e0e8c4069934e8b47d99704927a85c66c0ceb33@intel.com>

--- src/iio/iio.c
+++ src/iio/iio.c
@@ -441,7 +441,7 @@
     int event_fd;
     int fd;

-    sprintf(bu, IIO_SLASH_DEV "%d", dev->num);
+    snprintf(bu, MAX_SIZE, IIO_SLASH_DEV "%d", dev->num);
     fd = open(bu, 0);
     ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
     close(fd);


windows: fix memory leak when non-zero tcp reads are used

--- src/win/tcp.c
+++ src/win/tcp.c
@@ -822,7 +822,8 @@

   if (!REQ_SUCCESS(req)) {
     /* An error occurred doing the read. */
-    if ((handle->flags & UV_HANDLE_READING)) {
+    if ((handle->flags & UV_HANDLE_READING) ||
+        !(handle->flags & UV_HANDLE_ZERO_READ)) {
       handle->flags &= ~UV_HANDLE_READING;
       buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
             uv_buf_init(NULL, 0) : handle->read_buffer;


windows: temporarily disable non-zero reads

--- src/win/tcp.c
+++ src/win/tcp.c
@@ -28,8 +28,11 @@

 /*
  * Threshold of active tcp streams for which to preallocate tcp read buffers.
+ * (Due to node slab allocator performing poorly under this pattern,
+ *  the optimization is temporarily disabled (threshold=0).  This will be
+ *  revisited once node allocator is improved.)
  */
-const unsigned int uv_active_tcp_streams_threshold = 50;
+const unsigned int uv_active_tcp_streams_threshold = 0;

 /*
  * Number of simultaneous pending AcceptEx calls.


win: fix msvc warning

win: fix msvc warning

PR-URL: https://github.com/libuv/libuv/pull/2091
Reviewed-By: Anna Henningsen <2bc1ecb410e142bce83bce6f212b41e1781536dc@addaleax.net>
Reviewed-By: Colin Ihrig <838f779c91673db29b8572ea3f54d191d3878ae2@gmail.com>
Reviewed-By: Jameson Nash <99e7f19e9f64df56d4e81dc00b8566e722cdd766@gmail.com>

--- src/win/tty.c
+++ src/win/tty.c
@@ -360,6 +360,8 @@
     }
   } else {
     was_reading = 0;
+    alloc_cb = NULL;
+    read_cb = NULL;
   }

   uv_sem_wait(&uv_tty_output_lock);


win,tty: properly close when created from CRT fd

When a Windows handle was opened from a CRT fd, it needs to be closed
with `close()` instead of `CloseHandle()`.

PR-URL: https://github.com/libuv/libuv/pull/396
Reviewed-By: Saúl Ibarra Corretgé <8a7991f6950ea189abf159d6ec98d2fcc13dc5f6@gmail.com>

--- src/win/tty.c
+++ src/win/tty.c
@@ -135,6 +135,7 @@
   uv_connection_init((uv_stream_t*) tty);

   tty->handle = handle;
+  tty->u.fd = fd;
   tty->reqs_pending = 0;
   tty->flags |= UV_HANDLE_BOUND;

@@ -1915,11 +1916,15 @@

 void uv_tty_close(uv_tty_t* handle) {
-  CloseHandle(handle->handle);
+  if (handle->u.fd == -1)
+    CloseHandle(handle->handle);
+  else
+    close(handle->u.fd);

   if (handle->flags & UV_HANDLE_READING)
     uv_tty_read_stop(handle);

+  handle->u.fd = -1;
   handle->handle = INVALID_HANDLE_VALUE;
   handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
   uv__handle_closing(handle);


Removed C++ 03 incompatibilities.

Removed C++ 03 incompatibilities.


* jbn_add_item_ x bugfix

* jbn_add_item_ x bugfix

--- src/jbl/jbl.c
+++ src/jbl/jbl.c
@@ -1471,6 +1471,7 @@
     n->type = JBV_STR;
     n->vptr = iwpool_strndup(pool, val, vlen, &rc);
     RCGO(rc, finish);
+    n->klidx = strlen(n->key);
   } else {
     n->type = JBV_NULL;
   }
@@ -1492,6 +1493,7 @@
     }
     n->key = iwpool_strdup(pool, key, &rc);
     RCGO(rc, finish);
+    n->klidx = strlen(n->key);
   }
   n->type = JBV_I64;
   n->vi64 = val;
@@ -1513,6 +1515,7 @@
     }
     n->key = iwpool_strdup(pool, key, &rc);
     RCGO(rc, finish);
+    n->klidx = strlen(n->key);
   }
   n->type = JBV_F64;
   n->vf64 = val;
@@ -1534,6 +1537,7 @@
     }
     n->key = iwpool_strdup(pool, key, &rc);
     RCGO(rc, finish);
+    n->klidx = strlen(n->key);
   }
   n->type = JBV_BOOL;
   n->vbool = val;
@@ -1555,6 +1559,7 @@
     }
     n->key = iwpool_strdup(pool, key, &rc);
     RCGO(rc, finish);
+    n->klidx = strlen(n->key);
   }
   n->type = JBV_OBJECT;
   jbn_add_item(parent, n);
@@ -1578,6 +1583,7 @@
     }
     n->key = iwpool_strdup(pool, key, &rc);
     RCGO(rc, finish);
+    n->klidx = strlen(n->key);
   }
   n->type = JBV_ARRAY;
   jbn_add_item(parent, n);


more

more

Signed-off-by: Jens Nyberg <7200009990a46d4bb36e24284136c70d739d75fd@gmail.com>

--- src/wm2/wm2.c
+++ src/wm2/wm2.c
@@ -173,6 +173,7 @@

 }

+static void place_window(struct widget *widget, int x, int y, unsigned int w, unsigned int h);
 static void place_widget(struct widget *widget, int x, int y, unsigned int w, unsigned int h);

 static void place_button(struct widget *widget, int x, int y, unsigned int w, unsigned int h)
@@ -188,28 +189,26 @@
 static void place_image(struct widget *widget, int x, int y, unsigned int w, unsigned int h)
 {

+}
+
+static void place_layout(struct widget *widget, int x, int y, unsigned int w, unsigned int h)
+{
+
+    struct widget_layout *layout = widget->data;
+    struct list_item *current = 0;
+
     widget->position.x = x;
     widget->position.y = y;
     widget->size.w = w;
     widget->size.h = h;

-}
-
-static void place_layout(struct widget *widget, int x, int y, unsigned int w, unsigned int h)
-{
-
-    struct widget_layout *layout = widget->data;
-
-    widget->position.x = x;
-    widget->position.y = y;
-    widget->size.w = w;
-    widget->size.h = h;
-
-    if (layout->type != LAYOUT_TYPE_FLOAT)
-    {
-
-        struct list_item *current = 0;
-
+    switch (layout->type)
+    {
+
+    case LAYOUT_TYPE_VERTICAL:
+        break;
+
+    case LAYOUT_TYPE_FLOAT:
         while ((current = pool_nextin(current, widget->id)))
         {

@@ -219,6 +218,8 @@

         }

+        break;
+
     }

 }
@@ -233,7 +234,7 @@

         struct widget *child = current->data;

-        place_widget(child, widget->position.x, widget->position.y, widget->size.w, widget->size.h);
+        place_widget(child, widget->position.x + 16, widget->position.y + 16 + 38, widget->size.w - 24, widget->size.h - 24);

     }

@@ -305,17 +306,12 @@
     state.mouseposition.x = x;
     state.mouseposition.y = y;

-    if (mousewidget)
-    {
-
-        render_damage(&display, mousewidget->position.x, mousewidget->position.y, mousewidget->position.x + mousewidget->size.w, mousewidget->position.y + mousewidget->size.h);
-
-        mousewidget->position.x = state.mouseposition.x;
-        mousewidget->position.y = state.mouseposition.y;
-
-        render_damage(&display, mousewidget->position.x, mousewidget->position.y, mousewidget->position.x + mousewidget->size.w, mousewidget->position.y + mousewidget->size.h);
-
-    }
+    render_damage(&display, mousewidget->position.x, mousewidget->position.y, mousewidget->position.x + mousewidget->size.w, mousewidget->position.y + mousewidget->size.h);
+
+    mousewidget->position.x = state.mouseposition.x;
+    mousewidget->position.y = state.mouseposition.y;
+
+    render_damage(&display, mousewidget->position.x, mousewidget->position.y, mousewidget->position.x + mousewidget->size.w, mousewidget->position.y + mousewidget->size.h);

     if (state.mousedrag || state.mouseresize)
     {
@@ -456,37 +452,30 @@

     loadfont(factor);

-    if (mousewidget)
-    {
-
-        struct widget_image *image = mousewidget->data;
-
-        switch (factor)
-        {
-
-        case 0:
-        case 1:
-            widget_initimage(image, mousedata16, mousecmap);
-
-            mousewidget->position.x = state.mouseposition.x;
-            mousewidget->position.y = state.mouseposition.y;
-            mousewidget->size.w = 12;
-            mousewidget->size.h = 16;
-
-            break;
-
-        case 2:
-        default:
-            widget_initimage(image, mousedata24, mousecmap);
-
-            mousewidget->position.x = state.mouseposition.x;
-            mousewidget->position.y = state.mouseposition.y;
-            mousewidget->size.w = 18;
-            mousewidget->size.h = 24;
-
-            break;
-
-        }
+    switch (factor)
+    {
+
+    case 0:
+    case 1:
+        widget_initimage(mousewidget->data, mousedata16, mousecmap);
+
+        mousewidget->position.x = state.mouseposition.x;
+        mousewidget->position.y = state.mouseposition.y;
+        mousewidget->size.w = 12;
+        mousewidget->size.h = 16;
+
+        break;
+
+    case 2:
+    default:
+        widget_initimage(mousewidget->data, mousedata24, mousecmap);
+
+        mousewidget->position.x = state.mouseposition.x;
+        mousewidget->position.y = state.mouseposition.y;
+        mousewidget->size.w = 18;
+        mousewidget->size.h = 24;
+
+        break;

     }


cosmetics: tab to spaces

cosmetics: tab to spaces

--- unittest/test_interpol.c
+++ unittest/test_interpol.c
@@ -14,244 +14,244 @@
 /* test cases */
 START_TEST(test_read_header_line)
 {
-	int *cols;
-	int *indices;
-	int r;
-	cols = calloc(n_vars, sizeof(int));
-	indices = calloc(n_vars, sizeof(int));
-	r = read_header_line(EXAMPLES_FILENAME("MAPK_10pt.dat"), n_vars, (char **)vars, cols, indices);
-	ck_assert_int_eq(r, n_vars);
-	ck_assert_int_eq(cols[0], 1);
-	ck_assert_int_eq(cols[1], 5);
-	ck_assert_int_eq(cols[2], 6);
-	ck_assert_int_eq(cols[3], 8);
-	ck_assert_int_eq(indices[0], 2);
-	ck_assert_int_eq(indices[1], 3);
-	ck_assert_int_eq(indices[2], 0);
-	ck_assert_int_eq(indices[3], 1);
-	free(cols);
-	free(indices);
+  int *cols;
+  int *indices;
+  int r;
+  cols = calloc(n_vars, sizeof(int));
+  indices = calloc(n_vars, sizeof(int));
+  r = read_header_line(EXAMPLES_FILENAME("MAPK_10pt.dat"), n_vars, (char **)vars, cols, indices);
+  ck_assert_int_eq(r, n_vars);
+  ck_assert_int_eq(cols[0], 1);
+  ck_assert_int_eq(cols[1], 5);
+  ck_assert_int_eq(cols[2], 6);
+  ck_assert_int_eq(cols[3], 8);
+  ck_assert_int_eq(indices[0], 2);
+  ck_assert_int_eq(indices[1], 3);
+  ck_assert_int_eq(indices[2], 0);
+  ck_assert_int_eq(indices[3], 1);
+  free(cols);
+  free(indices);
 }
 END_TEST

 START_TEST(test_read_columns)
 {
-	static int cols[] = {1, 5, 6, 8};
-	static int indices[] = {2, 3, 0, 1};
-	time_series_t *ts;
-	int i, r;
-	ts = calloc(1, sizeof(*ts));
-	ts->data = calloc(4, sizeof(double *));
-	for (i=0;i<4;i++) {
-		ts->data[i] = calloc(11, sizeof(double));
-	}
-	ts->time = calloc(11, sizeof(double));
-	r = read_columns(EXAMPLES_FILENAME("MAPK_10pt.dat"), 4, cols, indices, ts);
-	ck_assert_int_eq(r, 11);
-	ck_assert(ts->time[0] == 0);
-	ck_assert(ts->data[0][0] == 280);
-	ck_assert(ts->data[1][0] == 10);
-	ck_assert(ts->data[2][0] == 90);
-	ck_assert(ts->data[3][0] == 10);
-	ck_assert(ts->time[1] == 10);
-	ck_assert(ts->data[0][1] == 279.88);
-	ck_assert(ts->data[1][1] == 9.01507);
-	ck_assert(ts->data[2][1] == 80.718);
-	ck_assert(ts->data[3][1] == 8.68109);
-	ck_assert(ts->time[2] == 20);
-	ck_assert(ts->data[0][2] == 280.012);
-	ck_assert(ts->data[1][2] == 8.13013);
-	ck_assert(ts->data[2][2] == 71.2642);
-	ck_assert(ts->data[3][2] == 8.71021);
-	ck_assert(ts->time[10] == 100);
-	ck_assert(ts->data[0][10] == 251.69);
-	ck_assert(ts->data[1][10] == 21.2823);
-	ck_assert(ts->data[2][10] == 14.2049);
-	ck_assert(ts->data[3][10] == 56.6475);
-	free_data(ts);
+  static int cols[] = {1, 5, 6, 8};
+  static int indices[] = {2, 3, 0, 1};
+  time_series_t *ts;
+  int i, r;
+  ts = calloc(1, sizeof(*ts));
+  ts->data = calloc(4, sizeof(double *));
+  for (i=0;i<4;i++) {
+    ts->data[i] = calloc(11, sizeof(double));
+  }
+  ts->time = calloc(11, sizeof(double));
+  r = read_columns(EXAMPLES_FILENAME("MAPK_10pt.dat"), 4, cols, indices, ts);
+  ck_assert_int_eq(r, 11);
+  ck_assert(ts->time[0] == 0);
+  ck_assert(ts->data[0][0] == 280);
+  ck_assert(ts->data[1][0] == 10);
+  ck_assert(ts->data[2][0] == 90);
+  ck_assert(ts->data[3][0] == 10);
+  ck_assert(ts->time[1] == 10);
+  ck_assert(ts->data[0][1] == 279.88);
+  ck_assert(ts->data[1][1] == 9.01507);
+  ck_assert(ts->data[2][1] == 80.718);
+  ck_assert(ts->data[3][1] == 8.68109);
+  ck_assert(ts->time[2] == 20);
+  ck_assert(ts->data[0][2] == 280.012);
+  ck_assert(ts->data[1][2] == 8.13013);
+  ck_assert(ts->data[2][2] == 71.2642);
+  ck_assert(ts->data[3][2] == 8.71021);
+  ck_assert(ts->time[10] == 100);
+  ck_assert(ts->data[0][10] == 251.69);
+  ck_assert(ts->data[1][10] == 21.2823);
+  ck_assert(ts->data[2][10] == 14.2049);
+  ck_assert(ts->data[3][10] == 56.6475);
+  free_data(ts);
 }
 END_TEST

 START_TEST(test_read_data)
 {
-	time_series_t *ts;
-	int i;
-	ts = read_data(EXAMPLES_FILENAME("MAPK_10pt.dat"), n_vars, (char **)vars);
-	ck_assert(ts != NULL);
-	ck_assert_int_eq(ts->n_var, n_vars);
-	for (i=0;i<n_vars;i++) {
-		ck_assert_str_eq(ts->var[i], vars[i]);
-	}
-	ck_assert_int_eq(ts->n_data, n_vars);
-	ck_assert_int_eq(ts->n_time, 11);
-	ck_assert(ts->warn != NULL);
-	ck_assert_int_eq(ts->warn[0], 0);
-	ck_assert_int_eq(ts->warn[1], 0);
-	free_data(ts);
+  time_series_t *ts;
+  int i;
+  ts = read_data(EXAMPLES_FILENAME("MAPK_10pt.dat"), n_vars, (char **)vars);
+  ck_assert(ts != NULL);
+  ck_assert_int_eq(ts->n_var, n_vars);
+  for (i=0;i<n_vars;i++) {
+    ck_assert_str_eq(ts->var[i], vars[i]);
+  }
+  ck_assert_int_eq(ts->n_data, n_vars);
+  ck_assert_int_eq(ts->n_time, 11);
+  ck_assert(ts->warn != NULL);
+  ck_assert_int_eq(ts->warn[0], 0);
+  ck_assert_int_eq(ts->warn[1], 0);
+  free_data(ts);
 }
 END_TEST

 START_TEST(test_bisection)
 {
-	static const double x[] = {-20.0, -4.5, 0.0, 1.25, 8.5};
-	int r;
-	r = bisection(5, x, -4.5);
-	ck_assert_int_eq(r, 1);
-	r = bisection(5, x, 2.0);
-	ck_assert_int_eq(r, 3);
-	r = bisection(5, x, -30.0);
-	ck_assert_int_eq(r, -1);
-	r = bisection(5, x, 10.0);
-	ck_assert_int_eq(r, 4);
+  static const double x[] = {-20.0, -4.5, 0.0, 1.25, 8.5};
+  int r;
+  r = bisection(5, x, -4.5);
+  ck_assert_int_eq(r, 1);
+  r = bisection(5, x, 2.0);
+  ck_assert_int_eq(r, 3);
+  r = bisection(5, x, -30.0);
+  ck_assert_int_eq(r, -1);
+  r = bisection(5, x, 10.0);
+  ck_assert_int_eq(r, 4);
 }
 END_TEST

 START_TEST(test_hunt)
 {
-	static const double x[] = {-20.0, -4.5, 0.0, 1.25, 8.5};
-	static const int n = (int)sizeof(x)/sizeof(x[0]);
-	int i, r;
-	for (i=0;i<n;i++) {
-		r = i;
-		hunt(n, x, -30.0, &r);
-		ck_assert_int_eq(r, -1);
-	}
-	for (i=0;i<n;i++) {
-		r = i;
-		hunt(n, x, 0.1, &r);
-		ck_assert_int_eq(r, 2);
-	}
-	for (i=0;i<n;i++) {
-		r = i;
-		hunt(n, x, 0.0, &r);
-		ck_assert_int_eq(r, 2);
-	}
-	for (i=0;i<n;i++) {
-		r = i;
-		hunt(n, x, 10.0, &r);
-		ck_assert_int_eq(r, 4);
-	}
+  static const double x[] = {-20.0, -4.5, 0.0, 1.25, 8.5};
+  static const int n = (int)sizeof(x)/sizeof(x[0]);
+  int i, r;
+  for (i=0;i<n;i++) {
+    r = i;
+    hunt(n, x, -30.0, &r);
+    ck_assert_int_eq(r, -1);
+  }
+  for (i=0;i<n;i++) {
+    r = i;
+    hunt(n, x, 0.1, &r);
+    ck_assert_int_eq(r, 2);
+  }
+  for (i=0;i<n;i++) {
+    r = i;
+    hunt(n, x, 0.0, &r);
+    ck_assert_int_eq(r, 2);
+  }
+  for (i=0;i<n;i++) {
+    r = i;
+    hunt(n, x, 10.0, &r);
+    ck_assert_int_eq(r, 4);
+  }
 }
 END_TEST

 START_TEST(test_spline)
 {
-	assert(sizeof(xs)/sizeof(xs[0]) == sizeof(ys)/sizeof(ys[0]));
-	double *y2;
-	int r;
-	y2 = calloc(n_xs, sizeof(*y2));
-	r = spline(n_xs, xs, ys, y2);
-	ck_assert_int_eq(r, 1);
-	CHECK_DOUBLE_WITH_TOLERANCE(y2[0], 0.0);
-	CHECK_DOUBLE_WITH_TOLERANCE(y2[1], -10.80891608391608471607);
-	CHECK_DOUBLE_WITH_TOLERANCE(y2[2], 7.23566433566433531155);
-	CHECK_DOUBLE_WITH_TOLERANCE(y2[3], -1.63374125874125875058);
-	CHECK_DOUBLE_WITH_TOLERANCE(y2[4], 0.15839160839160837391);
-	CHECK_DOUBLE_WITH_TOLERANCE(y2[5], 0.0);
-	free(y2);
+  assert(sizeof(xs)/sizeof(xs[0]) == sizeof(ys)/sizeof(ys[0]));
+  double *y2;
+  int r;
+  y2 = calloc(n_xs, sizeof(*y2));
+  r = spline(n_xs, xs, ys, y2);
+  ck_assert_int_eq(r, 1);
+  CHECK_DOUBLE_WITH_TOLERANCE(y2[0], 0.0);
+  CHECK_DOUBLE_WITH_TOLERANCE(y2[1], -10.80891608391608471607);
+  CHECK_DOUBLE_WITH_TOLERANCE(y2[2], 7.23566433566433531155);
+  CHECK_DOUBLE_WITH_TOLERANCE(y2[3], -1.63374125874125875058);
+  CHECK_DOUBLE_WITH_TOLERANCE(y2[4], 0.15839160839160837391);
+  CHECK_DOUBLE_WITH_TOLERANCE(y2[5], 0.0);
+  free(y2);
 }
 END_TEST

 START_TEST(test_splint)
 {
-	double *y2;
-	double y;
-	int j;
-	y2 = calloc(n_xs, sizeof(*y2));
-	(void)spline(n_xs, xs, ys, y2);
-	splint(n_xs, xs, ys, y2, 0.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, -2.5);
-	ck_assert_int_eq(j, 0);
-	splint(n_xs, xs, ys, y2, 1.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 1.5);
-	ck_assert_int_eq(j, 1);
-	splint(n_xs, xs, ys, y2, 2.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, -0.5);
-	ck_assert_int_eq(j, 2);
-	splint(n_xs, xs, ys, y2, 4.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 0.99383741258741253866);
-	ck_assert_int_eq(j, 3);
-	splint(n_xs, xs, ys, y2, 8.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 1.37825174825174845417);
-	ck_assert_int_eq(j, 4);
-	splint(n_xs, xs, ys, y2, 16.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 3.20000000000000017764);
-	ck_assert_int_eq(j, 5);
-	free(y2);
+  double *y2;
+  double y;
+  int j;
+  y2 = calloc(n_xs, sizeof(*y2));
+  (void)spline(n_xs, xs, ys, y2);
+  splint(n_xs, xs, ys, y2, 0.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, -2.5);
+  ck_assert_int_eq(j, 0);
+  splint(n_xs, xs, ys, y2, 1.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 1.5);
+  ck_assert_int_eq(j, 1);
+  splint(n_xs, xs, ys, y2, 2.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, -0.5);
+  ck_assert_int_eq(j, 2);
+  splint(n_xs, xs, ys, y2, 4.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 0.99383741258741253866);
+  ck_assert_int_eq(j, 3);
+  splint(n_xs, xs, ys, y2, 8.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 1.37825174825174845417);
+  ck_assert_int_eq(j, 4);
+  splint(n_xs, xs, ys, y2, 16.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 3.20000000000000017764);
+  ck_assert_int_eq(j, 5);
+  free(y2);
 }
 END_TEST

 START_TEST(test_linint)
 {
-	double y;
-	int j;
-	linint(n_xs, xs, ys, 0.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, -2.5);
-	ck_assert_int_eq(j, 0);
-	linint(n_xs, xs, ys, 1.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 1.5);
-	ck_assert_int_eq(j, 1);
-	linint(n_xs, xs, ys, 2.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, -0.5);
-	ck_assert_int_eq(j, 2);
-	linint(n_xs, xs, ys, 4.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 0.625);
-	ck_assert_int_eq(j, 3);
-	linint(n_xs, xs, ys, 8.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 1.60000000000000008882);
-	ck_assert_int_eq(j, 4);
-	linint(n_xs, xs, ys, 16.0, &y, &j);
-	CHECK_DOUBLE_WITH_TOLERANCE(y, 3.20000000000000017764);
-	ck_assert_int_eq(j, 5);
+  double y;
+  int j;
+  linint(n_xs, xs, ys, 0.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, -2.5);
+  ck_assert_int_eq(j, 0);
+  linint(n_xs, xs, ys, 1.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 1.5);
+  ck_assert_int_eq(j, 1);
+  linint(n_xs, xs, ys, 2.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, -0.5);
+  ck_assert_int_eq(j, 2);
+  linint(n_xs, xs, ys, 4.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 0.625);
+  ck_assert_int_eq(j, 3);
+  linint(n_xs, xs, ys, 8.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 1.60000000000000008882);
+  ck_assert_int_eq(j, 4);
+  linint(n_xs, xs, ys, 16.0, &y, &j);
+  CHECK_DOUBLE_WITH_TOLERANCE(y, 3.20000000000000017764);
+  ck_assert_int_eq(j, 5);
 }
 END_TEST

 /* public */
 Suite *create_suite_interpol(void)
 {
-	Suite *s;
-	TCase *tc_read_header_line;
-	TCase *tc_read_columns;
-	TCase *tc_read_data;
-	TCase *tc_bisection;
-	TCase *tc_hunt;
-	TCase *tc_spline;
-	TCase *tc_splint;
-	TCase *tc_linint;
-
-	s = suite_create("interpol");
-
-	tc_read_header_line = tcase_create("read_header_line");
-	tcase_add_test(tc_read_header_line, test_read_header_line);
-	suite_add_tcase(s, tc_read_header_line);
-
-	tc_read_columns = tcase_create("read_columns");
-	tcase_add_test(tc_read_columns, test_read_columns);
-	suite_add_tcase(s, tc_read_columns);
-
-	tc_read_data = tcase_create("read_data");
-	tcase_add_test(tc_read_data, test_read_data);
-	suite_add_tcase(s, tc_read_data);
-
-	tc_bisection = tcase_create("bisection");
-	tcase_add_test(tc_bisection, test_bisection);
-	suite_add_tcase(s, tc_bisection);
-
-	tc_hunt = tcase_create("hunt");
-	tcase_add_test(tc_hunt, test_hunt);
-	suite_add_tcase(s, tc_hunt);
-
-	tc_spline = tcase_create("spline");
-	tcase_add_test(tc_spline, test_spline);
-	suite_add_tcase(s, tc_spline);
-
-	tc_splint = tcase_create("splint");
-	tcase_add_test(tc_splint, test_splint);
-	suite_add_tcase(s, tc_splint);
-
-	tc_linint = tcase_create("linint");
-	tcase_add_test(tc_linint, test_linint);
-	suite_add_tcase(s, tc_linint);
-
-	return s;
-}
+  Suite *s;
+  TCase *tc_read_header_line;
+  TCase *tc_read_columns;
+  TCase *tc_read_data;
+  TCase *tc_bisection;
+  TCase *tc_hunt;
+  TCase *tc_spline;
+  TCase *tc_splint;
+  TCase *tc_linint;
+
+  s = suite_create("interpol");
+
+  tc_read_header_line = tcase_create("read_header_line");
+  tcase_add_test(tc_read_header_line, test_read_header_line);
+  suite_add_tcase(s, tc_read_header_line);
+
+  tc_read_columns = tcase_create("read_columns");
+  tcase_add_test(tc_read_columns, test_read_columns);
+  suite_add_tcase(s, tc_read_columns);
+
+  tc_read_data = tcase_create("read_data");
+  tcase_add_test(tc_read_data, test_read_data);
+  suite_add_tcase(s, tc_read_data);
+
+  tc_bisection = tcase_create("bisection");
+  tcase_add_test(tc_bisection, test_bisection);
+  suite_add_tcase(s, tc_bisection);
+
+  tc_hunt = tcase_create("hunt");
+  tcase_add_test(tc_hunt, test_hunt);
+  suite_add_tcase(s, tc_hunt);
+
+  tc_spline = tcase_create("spline");
+  tcase_add_test(tc_spline, test_spline);
+  suite_add_tcase(s, tc_spline);
+
+  tc_splint = tcase_create("splint");
+  tcase_add_test(tc_splint, test_splint);
+  suite_add_tcase(s, tc_splint);
+
+  tc_linint = tcase_create("linint");
+  tcase_add_test(tc_linint, test_linint);
+  suite_add_tcase(s, tc_linint);
+
+  return s;
+}