Further work on SM2 error codes

Further work on SM2 error codes

Also does some reformatting to tidy things up

Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6386)

--- crypto/sm2/sm2_crypt.c
+++ crypto/sm2/sm2_crypt.c
@@ -83,7 +83,7 @@
                 const uint8_t *msg,
                 size_t msg_len, uint8_t *ciphertext_buf, size_t *ciphertext_len)
 {
-    int rc = 0;
+    int rc = 0, ciphertext_leni;
     size_t i;
     BN_CTX *ctx = NULL;
     BIGNUM *k = NULL;
@@ -91,9 +91,7 @@
     BIGNUM *y1 = NULL;
     BIGNUM *x2 = NULL;
     BIGNUM *y2 = NULL;
-
     EVP_MD_CTX *hash = EVP_MD_CTX_new();
-
     struct SM2_Ciphertext_st ctext_struct;
     const EC_GROUP *group = EC_KEY_get0_group(key);
     const BIGNUM *order = EC_GROUP_get0_order(group);
@@ -101,30 +99,32 @@
     EC_POINT *kG = NULL;
     EC_POINT *kP = NULL;
     uint8_t *msg_mask = NULL;
-
     uint8_t *x2y2 = NULL;
     uint8_t *C3 = NULL;
-
     const size_t field_size = EC_field_size(group);
     const size_t C3_size = EVP_MD_size(digest);

-    if (field_size == 0 || C3_size == 0)
-       goto done;
+    /* NULL these before any "goto done" */
+    ctext_struct.C2 = NULL;
+    ctext_struct.C3 = NULL;
+
+    if (hash == NULL
+            || group == NULL
+            || order == NULL
+            || P == NULL
+            || field_size == 0
+            || C3_size == 0) {
+        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_INTERNAL_ERROR);
+        goto done;
+    }

     kG = EC_POINT_new(group);
     kP = EC_POINT_new(group);
-    if (kG == NULL || kP == NULL)
-       {
-       SM2err(SM2_F_SM2_ENCRYPT, ERR_R_MALLOC_FAILURE);
-       goto done;
-       }
-
     ctx = BN_CTX_new();
-    if (ctx == NULL)
-       {
-       SM2err(SM2_F_SM2_ENCRYPT, ERR_R_MALLOC_FAILURE);
-       goto done;
-       }
+    if (kG == NULL || kP == NULL || ctx == NULL) {
+        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_MALLOC_FAILURE);
+        goto done;
+    }

     BN_CTX_start(ctx);
     k = BN_CTX_get(ctx);
@@ -133,112 +133,93 @@
     y1 = BN_CTX_get(ctx);
     y2 = BN_CTX_get(ctx);

-    if (y2 == NULL)
-        {
+    if (y2 == NULL) {
         SM2err(SM2_F_SM2_ENCRYPT, ERR_R_BN_LIB);
         goto done;
-        }
+    }

     x2y2 = OPENSSL_zalloc(2 * field_size);
     C3 = OPENSSL_zalloc(C3_size);

-    if (x2y2 == NULL || C3 == NULL)
-        {
+    if (x2y2 == NULL || C3 == NULL) {
         SM2err(SM2_F_SM2_ENCRYPT, ERR_R_MALLOC_FAILURE);
         goto done;
-        }
+    }

     memset(ciphertext_buf, 0, *ciphertext_len);

-    BN_priv_rand_range(k, order);
-
-    if (EC_POINT_mul(group, kG, k, NULL, NULL, ctx) == 0)
-        {
+    if (!BN_priv_rand_range(k, order)) {
+        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_INTERNAL_ERROR);
+        goto done;
+    }
+
+    if (!EC_POINT_mul(group, kG, k, NULL, NULL, ctx)
+            || !EC_POINT_get_affine_coordinates_GFp(group, kG, x1, y1, ctx)
+            || !EC_POINT_mul(group, kP, NULL, P, k, ctx)
+            || !EC_POINT_get_affine_coordinates_GFp(group, kP, x2, y2, ctx)) {
         SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EC_LIB);
         goto done;
-        }
-
-    if (EC_POINT_get_affine_coordinates_GFp(group, kG, x1, y1, ctx) == 0)
-        {
-        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EC_LIB);
-        goto done;
-        }
-
-    if (EC_POINT_mul(group, kP, NULL, P, k, ctx) == 0)
-        {
-        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EC_LIB);
-        goto done;
-        }
-
-    if (EC_POINT_get_affine_coordinates_GFp(group, kP, x2, y2, ctx) == 0)
-        {
-        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EC_LIB);
-        goto done;
-        }
-
-    BN_bn2binpad(x2, x2y2, field_size);
-    BN_bn2binpad(y2, x2y2 + field_size, field_size);
+    }
+
+    if (BN_bn2binpad(x2, x2y2, field_size) < 0
+            || BN_bn2binpad(y2, x2y2 + field_size, field_size) < 0) {
+        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_INTERNAL_ERROR);
+        goto done;
+    }

     msg_mask = OPENSSL_zalloc(msg_len);
-    if (msg_mask == NULL)
-       {
+    if (msg_mask == NULL) {
        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_MALLOC_FAILURE);
        goto done;
-       }
+   }

     /* X9.63 with no salt happens to match the KDF used in SM2 */
-    if (ECDH_KDF_X9_62(msg_mask, msg_len, x2y2, 2 * field_size, NULL, 0, digest)
-        == 0)
-        goto done;
+    if (!ECDH_KDF_X9_62(msg_mask, msg_len, x2y2, 2 * field_size, NULL, 0,
+                        digest)) {
+        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EVP_LIB);
+        goto done;
+    }

     for (i = 0; i != msg_len; ++i)
         msg_mask[i] ^= msg[i];

-    if (EVP_DigestInit(hash, digest) == 0)
-        {
+    if (EVP_DigestInit(hash, digest) == 0
+            || EVP_DigestUpdate(hash, x2y2, field_size) == 0
+            || EVP_DigestUpdate(hash, msg, msg_len) == 0
+            || EVP_DigestUpdate(hash, x2y2 + field_size, field_size) == 0
+            || EVP_DigestFinal(hash, C3, NULL) == 0) {
         SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EVP_LIB);
         goto done;
-        }
-
-    if (EVP_DigestUpdate(hash, x2y2, field_size) == 0)
-        {
-        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EVP_LIB);
-        goto done;
-        }
-
-    if (EVP_DigestUpdate(hash, msg, msg_len) == 0)
-        {
-        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EVP_LIB);
-        goto done;
-        }
-
-    if (EVP_DigestUpdate(hash, x2y2 + field_size, field_size) == 0)
-        {
-        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EVP_LIB);
-        goto done;
-        }
-
-    if (EVP_DigestFinal(hash, C3, NULL) == 0)
-        {
-        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EVP_LIB);
-        goto done;
-        }
+    }

     ctext_struct.C1x = x1;
     ctext_struct.C1y = y1;
     ctext_struct.C3 = ASN1_OCTET_STRING_new();
-    ASN1_OCTET_STRING_set(ctext_struct.C3, C3, C3_size);
     ctext_struct.C2 = ASN1_OCTET_STRING_new();
-    ASN1_OCTET_STRING_set(ctext_struct.C2, msg_mask, msg_len);
-
-    *ciphertext_len = i2d_SM2_Ciphertext(&ctext_struct, &ciphertext_buf);
-
+
+    if (ctext_struct.C3 == NULL || ctext_struct.C2 == NULL) {
+       SM2err(SM2_F_SM2_ENCRYPT, ERR_R_MALLOC_FAILURE);
+       goto done;
+    }
+    if (!ASN1_OCTET_STRING_set(ctext_struct.C3, C3, C3_size)
+            || !ASN1_OCTET_STRING_set(ctext_struct.C2, msg_mask, msg_len)) {
+        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_INTERNAL_ERROR);
+        goto done;
+    }
+
+    ciphertext_leni = i2d_SM2_Ciphertext(&ctext_struct, &ciphertext_buf);
+    /* Ensure cast to size_t is safe */
+    if (ciphertext_leni < 0) {
+        SM2err(SM2_F_SM2_ENCRYPT, ERR_R_INTERNAL_ERROR);
+        goto done;
+    }
+    *ciphertext_len = (size_t)ciphertext_leni;
+
+    rc = 1;
+
+ done:
     ASN1_OCTET_STRING_free(ctext_struct.C2);
     ASN1_OCTET_STRING_free(ctext_struct.C3);
-
-    rc = 1;
-
- done:
     OPENSSL_free(msg_mask);
     OPENSSL_free(x2y2);
     OPENSSL_free(C3);


compiler warning

compiler warning

--- plugins/auth/caching_sha2_pw.c
+++ plugins/auth/caching_sha2_pw.c
@@ -194,6 +194,7 @@
 }
 #endif

+#ifndef HAVE_GNUTLS
 static char *load_pub_key_file(const char *filename, int *pub_key_size)
 {
   FILE *fp= NULL;
@@ -230,6 +231,7 @@
   }
   return buffer;
 }
+#endif

 static int auth_caching_sha2_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)


x509_vfy.c: Improve a couple of internally documenting comments

Reviewed-by: Paul Dale <ddec78389666b4f7c9b4d110380c848489a3e4aa@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13735)

--- crypto/x509/x509_vfy.c
+++ crypto/x509/x509_vfy.c
@@ -356,8 +356,8 @@
     return 0;
 }

-/*
- * Alternative lookup method: look from a STACK stored in other_ctx.
+/*-
+ * Alternative get_issuer method: look up from a STACK_OF(X509) in other_ctx.
  * Returns -1 on internal error.
  */
 static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
@@ -368,7 +368,10 @@
     return 0;
 }

-/* Returns NULL on internal error (such as out of memory) */
+/*-
+ * Alternative lookup method: look from a STACK stored in other_ctx.
+ * Returns NULL on internal error (such as out of memory).
+ */
 static STACK_OF(X509) *lookup_certs_sk(X509_STORE_CTX *ctx,
                                        const X509_NAME *nm)
 {
@@ -834,7 +837,7 @@
     for (i = num_untrusted; i < num; i++) {
         x = sk_X509_value(ctx->chain, i);
         trust = X509_check_trust(x, ctx->param->trust, 0);
-        /* If explicitly trusted return trusted */
+        /* If explicitly trusted (so not neutral nor rejected) return trusted */
         if (trust == X509_TRUST_TRUSTED)
             goto trusted;
         if (trust == X509_TRUST_REJECTED)
@@ -1816,7 +1819,7 @@
             }
         }

-        /* in addition to RFC 5280, do also for trusted (root) cert */
+        /* In addition to RFC 5280 requirements do also for trust anchor cert */
         /* Calls verify callback as needed */
         if (!ossl_x509_check_cert_time(ctx, xs, n))
             return 0;
@@ -2451,8 +2454,8 @@
 }

 /*
- * Set alternative lookup method: just a STACK of trusted certificates. This
- * avoids X509_STORE nastiness where it isn't needed.
+ * Set alternative get_issuer method: just from a STACK of trusted certificates.
+ * This avoids the complexity of X509_STORE where it is not needed.
  */
 void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk)
 {


Fix a lo_manage()'s bug.

Fix a lo_manage()'s bug.

--- contrib/lo/lo.c
+++ contrib/lo/lo.c
@@ -1,7 +1,7 @@
 /*
  *	PostgreSQL type definitions for managed LargeObjects.
  *
- *	$Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.10 2001/10/28 06:25:40 momjian Exp $
+ *	$Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.11 2001/12/07 04:18:31 inoue Exp $
  *
  */

@@ -176,7 +176,7 @@
 		char	   *orig = SPI_getvalue(trigtuple, tupdesc, attnum);
 		char	   *newv = SPI_getvalue(newtuple, tupdesc, attnum);

-		if ((orig != newv && (orig == NULL || newv == NULL)) || (orig != NULL && newv != NULL && strcmp(orig, newv)))
+		if (orig != NULL && (newv == NULL || strcmp(orig, newv)))
 			DirectFunctionCall1(lo_unlink,
 								ObjectIdGetDatum(atooid(orig)));


Refactor to support multiple fns

Refactor to support multiple fns

--- binlogp.c
+++ binlogp.c
@@ -1,3 +1,5 @@
+#define _XOPEN_SOURCE 600
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -9,8 +11,6 @@
 #include <string.h>
 #include <time.h>

-#define MIN_TIMESTAMP 1262325600	/* 2010-01-01 00:00:00 */
-time_t MAX_TIMESTAMP;
 #define MAX_RETRIES	409600			/* how many bytes to seek ahead looking for a record */

 #define GET_BIT(x,bit) (!!(x & 1 << bit))
@@ -22,6 +22,9 @@
 #define MAX_TYPE_CODE 27
 #define MIN_EVENT_LENGTH 91
 #define MAX_EVENT_LENGTH 1073741824
+#define MAX_SERVER_ID 2147483648
+#define MIN_TIMESTAMP 1262325600	/* 2010-01-01 00:00:00 */
+time_t MAX_TIMESTAMP;				/* Set this time(NULL) on startup */

 char* event_types[27] = {
@@ -133,7 +136,8 @@
 			e->event_length > MIN_EVENT_LENGTH &&
 			e->event_length < MAX_EVENT_LENGTH &&
 			e->timestamp > MIN_TIMESTAMP &&
-			e->timestamp < MAX_TIMESTAMP) {
+			e->timestamp < MAX_TIMESTAMP &&
+			e->server_id < MAX_SERVER_ID) {
 		return 1;
 	} else {
 		return 0;
@@ -148,43 +152,33 @@
 	fprintf(stderr, "Reading %zd bytes from %llu\n", amount, (long long)seek_pos);
 #endif
 	data = malloc(amount);
-	lseek(fd, SEEK_SET, seek_pos);
-	read(fd, data, amount);
+	if (pread(fd, data, amount, seek_pos) < 0) {
+		perror("read in read_extra_data:");
+	}
 	return data;
 }

-int main(int argc, char **argv)
-{
-	int fd;
+int nearest_offset(int fd, off_t starting_offset, struct stat *stbuf)
+{
 	unsigned int num_increments = 0;
 	off_t offset;
-	off_t seeked;
 	ssize_t amt_read;
-	struct stat stbuf;
 	struct event evbuf;
-	if (argc != 3) {
-		usage();
-		return 1;
-	}
-	if (stat(argv[1], &stbuf)) {
-		perror("Error stat-ing file");
-		return 1;
-	}
-	MAX_TIMESTAMP = time(NULL);
-	offset = atoll(argv[2]);
-	fd = open(argv[1], O_RDONLY);
+	offset = starting_offset;
+#if DEBUG
+	fprintf(stderr, "In nearest offset mode, got fd=%d, starting_offset=%llu\n", fd, (long long)starting_offset);
+#endif
 	while (num_increments < MAX_RETRIES)
 	{
-		if (stbuf.st_size < offset) {
-			fprintf(stderr, "%s is only %lld bytes, requested %lld\n", argv[1], (long long)stbuf.st_size, (long long)offset);
+		if (stbuf->st_size < offset) {
+			fprintf(stderr, "file is only %lld bytes, requested %lld\n", (long long)stbuf->st_size, (long long)offset);
 			return 1;
 		}
 #ifdef DEBUG
 		fprintf(stderr, "Seeking to %lld\n", (long long)offset);
 #endif
-		seeked = lseek(fd, offset, SEEK_SET);
-		if (seeked != offset) {
-			fprintf(stderr, "Error seeking to offset %lld\n", (long long) offset);
+		if ((lseek(fd, offset, SEEK_SET) < 0)) {
+			perror("Error seeking");
 			return 1;
 		}
 		amt_read = read(fd, (void*)&evbuf, HEADER_SIZE);
@@ -217,6 +211,57 @@
 			free(evbuf.data);
 		}
 	}
+	return 0;
+}
+
+int main(int argc, char **argv)
+{
+	int fd, exit_status;
+	struct stat stbuf;
+	int opt;
+
+	int t_mode = 0;
+	int o_mode = 0;
+
+	MAX_TIMESTAMP = time(NULL);
+
+	/* Parse args */
+	while ((opt = getopt(argc, argv, "to")) != -1) {
+		switch (opt) {
+			case 't':		/* Time mode */
+				t_mode = 1;
+				break;
+			case 'o':		/* Offset mode */
+				o_mode = 1;
+				break;
+			default:
+				usage();
+				return 1;
+		}
+	}
+	if (optind >= argc) {
+		usage();
+		return 1;
+	}
+	/* First argument is always filename */
+	if (stat(argv[optind], &stbuf)) {
+		perror("Error stat-ing file");
+		return 1;
+	}
+#if DEBUG
+	fprintf(stderr, "Opening file %s\n", argv[optind]);
+#endif
+	if ((fd = open(argv[optind], O_RDONLY)) <= 0) {
+		perror("Error opening file");
+		return 1;
+	}
+	exit_status = 0;
+	if (t_mode) {
+	}
+	else if (o_mode) {
+		off_t starting_offset = atoll(argv[optind+1]);
+		exit_status = nearest_offset(fd, starting_offset, &stbuf);
+	}
 	close(fd);
-	return 0;
-}
+	return exit_status;
+}


switch style of swapping for comparison timings


net/lwip: update neighbor cache state using target lladdr

This commit is the patch to update neighbor cache state using target
lladdr.
 - as per the RFC 4861, 83.3 Host specification
   I the link-layer address is the same as that already in the cache,
   the cache entry's state remains unchanged.

Change-Id: Ife813c0b5bded3e4c13308fc444e0c34590f5564
Signed-off-by: Changsoon Kim <c1120524009612ae00648f6848418e342ca4bc0a@samsung.com>

--- os/net/lwip/src/core/ipv6/nd6.c
+++ os/net/lwip/src/core/ipv6/nd6.c
@@ -94,6 +94,8 @@

 /* Router tables. */
 struct nd6_neighbor_cache_entry neighbor_cache[LWIP_ND6_NUM_NEIGHBORS];
+
+
 struct nd6_destination_cache_entry destination_cache[LWIP_ND6_NUM_DESTINATIONS];
 struct nd6_prefix_list_entry prefix_list[LWIP_ND6_NUM_PREFIXES];
 struct nd6_router_list_entry default_router_list[LWIP_ND6_NUM_ROUTERS];
@@ -115,6 +117,7 @@

 /* Forward declarations. */
 static s8_t nd6_find_neighbor_cache_entry(const ip6_addr_t *ip6addr);
+static s8_t nd6_find_lladdr_neighbor_cache_entry(const u8_t *lladdr, const struct netif *inp);
 static s8_t nd6_new_neighbor_cache_entry(void);
 static void nd6_free_neighbor_cache_entry(s8_t i);
 static s8_t nd6_find_destination_cache_entry(const ip6_addr_t *ip6addr);
@@ -1045,45 +1048,34 @@
 		ip6_addr_set(&(destination_cache[i].next_hop_addr), &(ND6H_RD_TARGET_ADDR(redir_hdr)));

 		/* If Link-layer address of other router is given, try to add to neighbor cache. */
-
 		if (lladdr_opt != NULL) {
-			if (ND6H_LLADDR_OPT_TYPE(lladdr_opt) == ND6_OPTION_TYPE_TARGET_LLADDR) {
-				/* Copy target address to current source address, to have an aligned copy. */
-				ip6_addr_set(&tmp, &(ND6H_RD_TARGET_ADDR(redir_hdr)));
-
-				i = nd6_find_neighbor_cache_entry(&tmp);
+			/* Copy target address to current source address, to have an aligned copy. */
+			ip6_addr_set(&tmp, &(ND6H_RD_TARGET_ADDR(redir_hdr)));
+
+			i = nd6_find_neighbor_cache_entry(&tmp);
+
+			if (i < 0) {
+				/* Creates the Neighbor cache entry for the target */
+				i = nd6_new_neighbor_cache_entry();
 				if (i < 0) {
-					/* Creates the Neighbor cache entry for the target */
-					i = nd6_new_neighbor_cache_entry();
-					if (i >= 0) {
-						neighbor_cache[i].netif = inp;
-						MEMCPY(neighbor_cache[i].lladdr, ND6H_LLADDR_OPT_ADDR(lladdr_opt), inp->hwaddr_len);
-						ip6_addr_set(&(neighbor_cache[i].next_hop_address), &tmp);
-
-						/**
-						 * Receiving a message does not prove reachability: only in one direction.
-						 * Delay probe in case we get confirmation of reachability from upper layer (TCP).
-						 */
-						/* RFC 4861, 8.3.  Host Specification
-						 * Reachability state MUST be set to STALE as specified in Section 7.3.3
-						 */
-						neighbor_cache[i].state = ND6_STALE;
-					} else {
-						LWIP_DEBUGF(ND6_DEBUG, ("Failed to create a new neighbor cache entry\n"));
-						ND6_STATS_INC(nd6.memerr);
-					}
-				} else {
-					/* Updates the Neighbor cache entry for the target */
-					MEMCPY(neighbor_cache[i].lladdr, ND6H_LLADDR_OPT_ADDR(lladdr_opt), inp->hwaddr_len);
-					/* Receiving a message does not prove reachability: only in one direction.
-					 * Delay probe in case we get confirmation of reachability from upper layer (TCP).
-					 */
-					/* RFC 4861, 8.3.  Host Specification
-					 * Reachability state MUST be set to STALE as specified in Section 7.3.3
-					 */
-					neighbor_cache[i].state = ND6_STALE;
-				}
-			}
+					LWIP_DEBUGF(ND6_DEBUG, ("Failed to create a new neighbor cache entry\n"));
+					ND6_STATS_INC(nd6.memerr);
+					pbuf_free(p);
+					return;
+				}
+			}
+
+			neighbor_cache[i].netif = inp;
+
+			/* If the link-layer address is the same as that already in the cache,
+			 * the cache entry's state remains unchanged.
+			 */
+			if (nd6_find_lladdr_neighbor_cache_entry(ND6H_LLADDR_OPT_ADDR(lladdr_opt), inp) < 0) {
+				neighbor_cache[i].state = ND6_STALE;
+			}
+
+			MEMCPY(neighbor_cache[i].lladdr, ND6H_LLADDR_OPT_ADDR(lladdr_opt), inp->hwaddr_len);
+			ip6_addr_set(&(neighbor_cache[i].next_hop_address), &tmp);
 		}
 		break;				/* ICMP6_TYPE_RD */
 	}
@@ -1192,8 +1184,8 @@
 				/* Retries exceeded. */
 				nd6_cleanup_all_caches(&neighbor_cache[i].next_hop_address);
 			} else {
-				neighbor_cache[i].counter.incomplete_time += ND6_TMR_INTERVAL;
-				if (retrans_timer <= ND6_TMR_INTERVAL ||
+				neighbor_cache[i].counter.incomplete_time += LWIP_ND6_RETRANS_TIMER;
+				if (retrans_timer <= LWIP_ND6_RETRANS_TIMER ||
 					neighbor_cache[i].counter.incomplete_time >= retrans_timer) {
 					/* Send a NS for this entry */
 					neighbor_cache[i].counter.incomplete_time = 0;
@@ -1234,8 +1226,8 @@
 			if (neighbor_cache[i].probes_sent >= LWIP_ND6_MAX_UNICAST_SOLICIT) {
 				nd6_cleanup_all_caches(&neighbor_cache[i].next_hop_address);
 			} else {
-				neighbor_cache[i].counter.probe_time += ND6_TMR_INTERVAL;
-				if (retrans_timer <= ND6_TMR_INTERVAL ||
+				neighbor_cache[i].counter.probe_time += LWIP_ND6_RETRANS_TIMER;
+				if (retrans_timer <= LWIP_ND6_RETRANS_TIMER ||
 					neighbor_cache[i].counter.probe_time >= retrans_timer) {
 					/* Send a NS for this entry. */
 					neighbor_cache[i].counter.probe_time = 0;
@@ -1624,6 +1616,31 @@
 			return i;
 		}
 	}
+	return -1;
+}
+
+/**
+ * Search for a neighbor cache entry by using link-layer address (lladdr)
+ *
+ * @param lladdr the Link-layer address
+ * @param netif points to a network interface
+ * @return The neighbor cache entry index that matched, -1 if no
+ * entry is found
+ */
+static s8_t nd6_find_lladdr_neighbor_cache_entry(const u8_t *lladdr, const struct netif *inp)
+{
+	s8_t i;
+
+	if (inp == NULL || lladdr == NULL) {
+		return -1;
+	}
+
+	for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
+		if (!MEMCMP(neighbor_cache[i].lladdr, lladdr, inp->hwaddr_len)) {
+			return i;
+		}
+	}
+
 	return -1;
 }


Add method to PropertyHelper to remove an item from List property

git-svn-id: 9e047e1e624cce0a2485e750063112e834f85522@7965 fc29be9c-2cb0-420d-b520-73dbd18add6e

--- OpenSim/Java/OpenSimJNI/OpenSimContext.h
+++ OpenSim/Java/OpenSimJNI/OpenSimContext.h
@@ -409,6 +409,24 @@
             p.appendValue<std::string>(aStringArray.get(i));
     }

+    static void removeItem(AbstractProperty& p, int index)
+    {
+        if (p.size()>index && p.getMinListSize() >= p.size()-1){
+            AbstractProperty* cloneP = p.clone();
+            p.clear();
+            for(int i=0; i<p.size();i++){
+                if (i!= index){
+                if (p.getTypeName()=="String")
+                    p.appendValue(cloneP->getValue<std::string>(i));
+                else if (p.getTypeName()=="Int")
+                    p.appendValue(cloneP->getValue<int>(i));
+                else if (p.getTypeName()=="double")
+                    p.appendValue(cloneP->getValue<double>(i));
+                }
+            }
+        }
+    }
+
 };

 } // namespace OpenSim


RPL: do not return from rpl_process_dio after adding a DAG

--- core/net/rpl/rpl-dag.c
+++ core/net/rpl/rpl-dag.c
@@ -95,10 +95,11 @@
     printf("RPL: rank %u dioint %u, %u nbr(s)\n", curr_rank, curr_dio_interval, uip_ds6_nbr_num());
     while(p != NULL) {
       uip_ds6_nbr_t *nbr = rpl_get_nbr(p);
-      printf("RPL: nbr %3u %5u, %5u => %5u %c (last tx %u min ago)\n",
+      printf("RPL: nbr %3u %5u, %5u => %5u %c%c (last tx %u min ago)\n",
           nbr_table_get_lladdr(rpl_parents, p)->u8[7],
           p->rank, nbr ? nbr->link_metric : 0,
           default_instance->of->calculate_rank(p, 0),
+          default_instance->current_dag == p->dag ? 'd' : ' ',
           p == default_instance->current_dag->preferred_parent ? '*' : ' ',
           (unsigned)((now - p->last_tx_time) / (60 * CLOCK_SECOND)));
       p = nbr_table_next(rpl_parents, p);
@@ -1053,7 +1054,7 @@

 #if RPL_MAX_DAG_PER_INSTANCE > 1
 /*---------------------------------------------------------------------------*/
-void
+rpl_dag_t *
 rpl_add_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
 {
   rpl_instance_t *instance;
@@ -1064,7 +1065,7 @@
   dag = rpl_alloc_dag(dio->instance_id, &dio->dag_id);
   if(dag == NULL) {
     PRINTF("RPL: Failed to allocate a DAG object!\n");
-    return;
+    return NULL;
   }

   instance = dag->instance;
@@ -1078,7 +1079,7 @@
     if(p == NULL) {
       PRINTF("failed\n");
       dag->used = 0;
-      return;
+      return NULL;
     }
     PRINTF("succeeded\n");
   } else {
@@ -1105,7 +1106,7 @@
 	   dio->instance_id);
     rpl_remove_parent(p);
     dag->used = 0;
-    return;
+    return NULL;
   }

   dag->used = 1;
@@ -1130,6 +1131,8 @@
   ANNOTATE("#A join=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
   rpl_process_parent_event(instance, p);
   p->dtsn = dio->dtsn;
+
+  return dag;
 }
 #endif /* RPL_MAX_DAG_PER_INSTANCE > 1 */

@@ -1333,8 +1336,11 @@
   if(dag == NULL) {
 #if RPL_MAX_DAG_PER_INSTANCE > 1
     PRINTF("RPL: Adding new DAG to known instance.\n");
-    rpl_add_dag(from, dio);
-    return;
+    dag = rpl_add_dag(from, dio);
+    if(dag == NULL) {
+      PRINTF("RPL: Failed to add DAG.\n");
+      return;
+    }
 #else /* RPL_MAX_DAG_PER_INSTANCE > 1 */
     PRINTF("RPL: Only one instance supported.\n");
     return;


filter_modify: copy original event if condition is not matched (#1077 #1416)

Signed-off-by: Takahiro YAMASHITA <8b9f03f78cb27351a99f79113f99e589b65190d5@gmail.com>

--- plugins/filter_modify/modify.c
+++ plugins/filter_modify/modify.c
@@ -1382,6 +1382,7 @@
     struct filter_modify_ctx *ctx = context;

     int modifications = 0;
+    int total_modifications = 0;

     msgpack_sbuffer buffer;
     msgpack_sbuffer_init(&buffer);
@@ -1400,8 +1401,14 @@
     msgpack_unpacked_init(&result);
     while (msgpack_unpack_next(&result, data, bytes, &off) == MSGPACK_UNPACK_SUCCESS) {
         if (result.data.type == MSGPACK_OBJECT_ARRAY) {
-            modifications +=
+            modifications =
                 apply_modifying_rules(&packer, &result.data, ctx);
+
+            if (modifications == 0) {
+                // not matched, so copy original event.
+                msgpack_pack_object(&packer, result.data);
+            }
+            total_modifications += modifications;
         }
         else {
             msgpack_pack_object(&packer, result.data);
@@ -1409,7 +1416,7 @@
     }
     msgpack_unpacked_destroy(&result);

-    if(modifications == 0) {
+    if(total_modifications == 0) {
         msgpack_sbuffer_destroy(&buffer);
         return FLB_FILTER_NOTOUCH;
     }


[SECP256K1] Add missing secp256k1_ge_set_gej_var decl.

Summary: Backport of [[https://github.com/bitcoin-core/secp256k1/pull/877 | secp256k1#877]]

Test Plan:
  ninja check-secp256k1

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D9386

--- src/secp256k1/src/group.h
+++ src/secp256k1/src/group.h
@@ -62,8 +62,11 @@
 /** Set r equal to the inverse of a (i.e., mirrored around the X axis) */
 static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a);

-/** Set a group element equal to another which is given in jacobian coordinates */
+/** Set a group element equal to another which is given in jacobian coordinates. Constant time. */
 static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a);
+
+/** Set a group element equal to another which is given in jacobian coordinates. */
+static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a);

 /** Set a batch of group elements equal to the inputs given in jacobian coordinates */
 static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len);


removed unnecessary headers

removed unnecessary headers

--- features/nfc/nfc/NFCEEPROMDriver.h
+++ features/nfc/nfc/NFCEEPROMDriver.h
@@ -19,10 +19,6 @@

 #include <stdint.h>

-#include "NFCDefinitions.h"
-#include "NFCTarget.h"
-#include "NFCEEPROMDriver.h"
-
 #include "events/EventQueue.h"

 namespace mbed {


[secp256k1] fix tests.c in the count == 0 case

Summary: This is a backport of secp256k1's PR529

Test Plan:
  ninja check-secp256k1

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D4954

--- src/secp256k1/src/tests.c
+++ src/secp256k1/src/tests.c
@@ -2725,6 +2725,10 @@
     }

     /* Sanity check that zero scalars don't cause problems */
+    for (ncount = 0; ncount < 20; ncount++) {
+         random_scalar_order(&sc[ncount]);
+         random_group_element_test(&pt[ncount]);
+    }
     secp256k1_scalar_clear(&sc[0]);
     CHECK(ecmult_multi(&ctx->ecmult_ctx, scratch, &r, &szero, ecmult_multi_callback, &data, 20));
     secp256k1_scalar_clear(&sc[1]);


Fixing delay() to delay at least N milliseconds.
Fixing register name in micros() for ATmega8.

Former-commit-id: 9fc613ad6ffd66454390fd8e32be7ff740a41282

--- cores/arduino/wiring.c
+++ cores/arduino/wiring.c
@@ -59,8 +59,14 @@

 	cli();
 	t = TCNT0;
+
+#ifdef TIFR0
 	if ((TIFR0 & _BV(TOV0)) && (t == 0))
 		t = 256;
+#else
+	if ((TIFR & _BV(TOV0)) && (t == 0))
+		t = 256;
+#endif

 	m = timer0_overflow_count;
 	SREG = oldSREG;
@@ -72,7 +78,7 @@
 {
 	unsigned long start = millis();

-	while (millis() - start < ms)
+	while (millis() - start <= ms)
 		;
 }


Updated the 2nd flavour of Record::insertField.

--- cpp/lib/include/MARC.h
+++ cpp/lib/include/MARC.h
@@ -351,13 +351,16 @@
     char getBibliographicLevel() const { return leader_[7]; }
     void setBibliographicLevel(const char new_bibliographic_level) { leader_[7] = new_bibliographic_level; }

-    /** \return True if we added the new field and false if it is a non-repeatable field and we already have this tag. */
+    /** \return True if we added the new field and false if it is a non-repeatable field and we already have this tag.
+     *  \note   "new_field_value" includes the two indicators and any subfield structure if "new_field_tag" references a
+     *          variable field.
+     */
     bool insertField(const Tag &new_field_tag, const std::string &new_field_value);

     inline Field getField(const size_t field_index) { return fields_[field_index]; }
     inline const Field &getField(const size_t field_index) const { return fields_[field_index]; }

-    inline void insertField(const Tag &new_field_tag, const Subfields &subfields, const char indicator1 = ' ',
+    inline bool insertField(const Tag &new_field_tag, const Subfields &subfields, const char indicator1 = ' ',
                             const char indicator2 = ' ')
     {
         std::string new_field_value;
@@ -365,7 +368,7 @@
         new_field_value += indicator2;
         for (const auto &subfield : subfields)
             new_field_value += subfield.toString();
-        insertField(new_field_tag, new_field_value);
+        return insertField(new_field_tag, new_field_value);
     }

     inline void insertField(const Tag &new_field_tag, std::vector<Subfield> subfields, const char indicator1 = ' ',


cpu/stm32: Cleanup periph_eth

cpu/stm32: Cleanup periph_eth

Cleanup functions _rw_phy(), _phy_read(), and _phy_write() and rename them to
_mii_reg_{access,read,write}().

--- cpu/stm32/periph/eth.c
+++ cpu/stm32/periph/eth.c
@@ -104,40 +104,54 @@
 static uint8_t _link_state = LINK_STATE_DOWN;
 #endif

-/** Read or write a phy register, to write the register ETH_MACMIIAR_MW is to
- * be passed as the higher nibble of the value */
-static unsigned _rw_phy(unsigned addr, unsigned reg, unsigned value)
+/**
+ * @brief   Read or write a MII register
+ *
+ * @param[in]   addr    Which of the 32 possible PHY devices to access
+ * @param[in]   reg     MII register to access
+ * @param[in]   value   Value to write (ignored when @p write is `false`)
+ * @param[in]   write   Whether to write (`true`) or read (`false`) to/from the
+ *                      register
+ *
+ * @return  The value of the MII register accessed. (This should be equal to
+ *          @p value, if @p write was `true`.)
+ */
+static uint16_t _mii_reg_transfer(unsigned addr, unsigned reg, uint16_t value,
+                                  bool write)
 {
     unsigned tmp;

     while (ETH->MACMIIAR & ETH_MACMIIAR_MB) {}
     DEBUG("[stm32_eth] rw_phy %x (%x): %x\n", addr, reg, value);

-    tmp = (ETH->MACMIIAR & ETH_MACMIIAR_CR) | ETH_MACMIIAR_MB;
-    tmp |= (((addr & 0x1f) << 11) | ((reg & 0x1f) << 6));
-    tmp |= (value >> 16);
-
-    ETH->MACMIIDR = (value & 0xffff);
+    tmp = CLOCK_RANGE | ETH_MACMIIAR_MB
+        | (((addr & 0x1f) << 11) | ((reg & 0x1f) << 6));
+
+    if (write) {
+        tmp |= ETH_MACMIIAR_MW;
+        ETH->MACMIIDR = value;
+    }
+
     ETH->MACMIIAR = tmp;
     while (ETH->MACMIIAR & ETH_MACMIIAR_MB) {}

     DEBUG("[stm32_eth] %lx\n", ETH->MACMIIDR);
-    return (ETH->MACMIIDR & 0x0000ffff);
-}
-
-static inline int32_t _phy_read(uint16_t addr, uint8_t reg)
-{
-    return _rw_phy(addr, reg, 0);
-}
-
-static inline void _phy_write(uint16_t addr, uint8_t reg, uint16_t value)
-{
-    _rw_phy(addr, reg, (value & 0xffff) | (ETH_MACMIIAR_MW << 16));
+    return ETH->MACMIIDR;
+}
+
+static inline int16_t _mii_reg_read(uint16_t addr, uint8_t reg)
+{
+    return _mii_reg_transfer(addr, reg, 0, false);
+}
+
+static inline void _mii_reg_write(uint16_t addr, uint8_t reg, uint16_t value)
+{
+    _mii_reg_transfer(addr, reg, value, true);
 }

 static inline bool _get_link_status(void)
 {
-    return (_phy_read(0, PHY_BSMR) & BSMR_LINK_STATUS);
+    return (_mii_reg_read(0, PHY_BSMR) & BSMR_LINK_STATUS);
 }

 static void stm32_eth_get_addr(char *out)
@@ -292,7 +306,7 @@

     /* configure the PHY (standard for all PHY's) */
     /* if there's no PHY, this has no effect */
-    _phy_write(eth_config.phy_addr, PHY_BMCR, BMCR_RESET);
+    _mii_reg_write(eth_config.phy_addr, PHY_BMCR, BMCR_RESET);

     /* speed from conf */
     ETH->MACCR |= (ETH_MACCR_ROD | ETH_MACCR_IPCO | ETH_MACCR_APCS |
@@ -337,7 +351,7 @@

     /* configure speed, do it at the end so the PHY had time to
      * reset */
-    _phy_write(eth_config.phy_addr, PHY_BMCR, eth_config.speed);
+    _mii_reg_write(eth_config.phy_addr, PHY_BMCR, eth_config.speed);

     return 0;
 }


Bug: wrong index, reading out of memory bounds. Copied from https://dotnetinstaller.svn.sourceforge.net/svnroot/dotnetinstaller/trunk/, rev. 30 by dblockdotorg @ 6/15/2008 7:37 PM

--- dotNetInstaller/Tools/Guid.h
+++ dotNetInstaller/Tools/Guid.h
@@ -10,7 +10,7 @@
 		if(0 == (len = ::StringFromGUID2(rguid, (LPOLESTR) & progid, sizeof(progid) - 1)))
             throw TEXT("StringFromGUID2 failed");

-        progid[len] = 0;
+        progid[len - 1] = 0;
         return CString(progid);
 	}


handle unresponsive server

handle unresponsive server

--- firmware-src/sources/dhconnector.c
+++ firmware-src/sources/dhconnector.c
@@ -28,9 +28,11 @@
 #include <json/jsonparse.h>
 #include <ets_forward.h>

+#define HTTP_RESPONSE_TIMEOUT_MS 60000
 LOCAL CONNECTION_STATE mConnectionState;
 LOCAL struct espconn mDHConnector;
 LOCAL os_timer_t mRetryTimer;
+LOCAL os_timer_t mResponseTimer;
 LOCAL char mWSUrl[DHSETTINGS_SERVER_MAX_LENGTH];

 LOCAL void set_state(CONNECTION_STATE state);
@@ -45,8 +47,15 @@
 	os_timer_arm(&mRetryTimer, ms, 0);
 }

+LOCAL void response_timeout(void *arg) {
+	dhdebug("HTTP response timeout");
+	mConnectionState = CS_DISCONNECT;
+	espconn_disconnect(&mDHConnector);
+}
+
 LOCAL void ICACHE_FLASH_ATTR network_error_cb(void *arg, sint8 err) {
 	dhconnector_websocket_stop();
+	os_timer_disarm(&mResponseTimer);
 	dhesperrors_espconn_result("Connector error occurred:", err);
 	mConnectionState = CS_DISCONNECT;
 	arm_repeat_timer(RETRY_CONNECTION_INTERVAL_MS);
@@ -107,6 +116,7 @@
 		dhconnector_websocket_parse(data, len);
 		return;
 	}
+	os_timer_disarm(&mResponseTimer);
 	const char *rc = find_http_responce_code(data, len);
 	if(rc) { // HTTP
 		if(rc[0] == '1' && rc[1] == '0' && rc[2] == '1' && mConnectionState == CS_WEBSOCKET) { // HTTP responce code 101 - Switching Protocols
@@ -192,11 +202,15 @@
 		espconn_disconnect(&mDHConnector);
 	} else {
 		dhstat_add_bytes_sent(request->len);
+		os_timer_disarm(&mResponseTimer);
+		os_timer_setfn(&mResponseTimer, (os_timer_func_t *)response_timeout, 0);
+		os_timer_arm(&mResponseTimer, HTTP_RESPONSE_TIMEOUT_MS, 0);
 	}
 }

 LOCAL void network_disconnect_cb(void *arg) {
 	dhconnector_websocket_stop();
+	os_timer_disarm(&mResponseTimer);
 	switch(mConnectionState) {
 	case CS_GETINFO:
 		set_state(CS_WEBSOCKET);


whitespace

whitespace

--- src/ast/ast.h
+++ src/ast/ast.h
@@ -93,7 +93,7 @@
         // PARAM_EXTERNAL is not supported by z3 low level input format. This format is legacy, so
         // this is not a big problem.
         // Remark: PARAM_EXTERNAL can only be used to decorate theory decls.
-        PARAM_EXTERNAL
+        PARAM_EXTERNAL
     };
 private:
     kind_t m_kind;
@@ -123,7 +123,7 @@
     ~parameter();

     parameter& operator=(parameter const& other);
-
+
     kind_t get_kind() const { return m_kind; }
     bool is_int() const { return m_kind == PARAM_INT; }
     bool is_ast() const { return m_kind == PARAM_AST; }
@@ -131,7 +131,7 @@
     bool is_rational() const { return m_kind == PARAM_RATIONAL; }
     bool is_double() const { return m_kind == PARAM_DOUBLE; }
     bool is_external() const { return m_kind == PARAM_EXTERNAL; }
-
+
     bool is_int(int & i) const { return is_int() && (i = get_int(), true); }
     bool is_ast(ast * & a) const { return is_ast() && (a = get_ast(), true); }
     bool is_symbol(symbol & s) const { return is_symbol() && (s = get_symbol(), true); }
@@ -150,7 +150,7 @@
        deleted.
     */
     void del_eh(ast_manager & m, family_id fid);
-
+
     int get_int() const { SASSERT(is_int()); return m_int; }
     ast * get_ast() const { SASSERT(is_ast()); return m_ast; }
     symbol const & get_symbol() const { SASSERT(is_symbol()); return *(reinterpret_cast<const symbol *>(m_symbol)); }
@@ -162,7 +162,7 @@
     bool operator!=(parameter const & p) const { return !operator==(p); }

     unsigned hash() const;
-
+
     std::ostream& display(std::ostream& out) const;
 };

@@ -192,7 +192,7 @@

     /**
        \brief Return the family_id for s, a new id is created if !has_family(s)
-
+
        If has_family(s), then this method is equivalent to get_family_id(s)
     */
     family_id mk_family_id(symbol const & s);
@@ -201,11 +201,11 @@
        \brief Return the family_id for s, return null_family_id if s was not registered in the manager.
     */
     family_id get_family_id(symbol const & s) const;
-
+
     bool has_family(symbol const & s) const;

     void get_dom(svector<symbol>& dom) const { m_families.get_dom(dom); }
-
+
     void get_range(svector<family_id> & range) const { m_families.get_range(range); }

     symbol const & get_name(family_id fid) const { return fid >= 0 && fid < static_cast<int>(m_names.size()) ? m_names[fid] : symbol::null; }
@@ -220,15 +220,15 @@
 // -----------------------------------

 /**
-   \brief Each interpreted function declaration or sort has a kind.
+   \brief Each interpreted function declaration or sort has a kind.
    Kinds are used to identify interpreted functions and sorts in a family.
 */
-typedef int     decl_kind;
+typedef int     decl_kind;
 const decl_kind null_decl_kind = -1;

 /**
-   \brief Interpreted function declarations and sorts are associated with
-   a family id, kind, and parameters.
+   \brief Interpreted function declarations and sorts are associated with
+   a family id, kind, and parameters.
 */
 class decl_info {
     family_id            m_family_id;
@@ -236,22 +236,22 @@
     vector<parameter>    m_parameters;
 public:
     bool                 m_private_parameters;
-    decl_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind,
+    decl_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind,
               unsigned num_parameters = 0, parameter const * parameters = 0, bool private_params = false);

     decl_info(decl_info const& other);
     ~decl_info() {}
-
+
     void init_eh(ast_manager & m);
     void del_eh(ast_manager & m);
-
+
     family_id get_family_id() const { return m_family_id; }
     decl_kind get_decl_kind() const { return m_kind; }
     unsigned get_num_parameters() const { return m_parameters.size(); }
     parameter const & get_parameter(unsigned idx) const { return m_parameters[idx]; }
     parameter const * get_parameters() const { return m_parameters.begin(); }
     bool private_parameters() const { return m_private_parameters; }
-
+
     unsigned hash() const;
     bool operator==(decl_info const & info) const;
 };
@@ -274,7 +274,7 @@
         // number of elements precisely (e.g., arrays).  In this
         // cases, we mark the sort as too big. That is, the number
         // of elements is at least bigger than 2^64.
-        SS_FINITE_VERY_BIG,
+        SS_FINITE_VERY_BIG,
         SS_INFINITE
     } m_kind;
     uint64 m_size; // It is only meaningful if m_kind == SS_FINITE
@@ -296,13 +296,13 @@
     static sort_size mk_infinite() { return sort_size(SS_INFINITE, 0); }
     static sort_size mk_very_big() { return sort_size(SS_FINITE_VERY_BIG, 0); }
     static sort_size mk_finite(uint64 r) { return sort_size(SS_FINITE, r); }
-
+
     bool is_infinite() const { return m_kind == SS_INFINITE; }
     bool is_very_big() const { return m_kind == SS_FINITE_VERY_BIG; }
     bool is_finite() const { return m_kind == SS_FINITE; }
-
+
     static bool is_very_big_base2(unsigned power) { return power >= 64; }
-
+
     uint64 size() const { SASSERT(is_finite()); return m_size; }
 };

@@ -320,16 +320,16 @@
 class sort_info : public decl_info {
     sort_size m_num_elements;
 public:
-    sort_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind,
+    sort_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind,
               unsigned num_parameters = 0, parameter const * parameters = 0, bool private_parameters = false):
         decl_info(family_id, k, num_parameters, parameters, private_parameters) {
     }
-
+
     sort_info(family_id family_id, decl_kind k, uint64 num_elements,
               unsigned num_parameters = 0, parameter const * parameters = 0, bool private_parameters = false):
         decl_info(family_id, k, num_parameters, parameters, private_parameters), m_num_elements(num_elements) {
     }
-
+
     sort_info(family_id family_id, decl_kind k, sort_size const& num_elements,
               unsigned num_parameters = 0, parameter const * parameters = 0, bool private_parameters = false):
         decl_info(family_id, k, num_parameters, parameters, private_parameters), m_num_elements(num_elements) {
@@ -337,7 +337,7 @@
     sort_info(sort_info const& other) : decl_info(other), m_num_elements(other.m_num_elements) {
     }
     ~sort_info() {}
-
+
     bool is_infinite() const { return m_num_elements.is_infinite(); }
     bool is_very_big() const { return m_num_elements.is_very_big(); }
     sort_size const & get_num_elements() const { return m_num_elements; }
@@ -367,7 +367,7 @@

     func_decl_info(family_id family_id = null_family_id, decl_kind k = null_decl_kind, unsigned num_parameters = 0, parameter const * parameters = 0);
     ~func_decl_info() {}
-
+
     bool is_associative() const { return m_left_assoc && m_right_assoc; }
     bool is_left_associative() const { return m_left_assoc; }
     bool is_right_associative() const { return m_right_assoc; }
@@ -394,8 +394,8 @@

     // Return true if the func_decl_info is equivalent to the null one (i.e., it does not contain any useful info).
     bool is_null() const {
-        return
-            get_family_id() == null_family_id && !is_left_associative() && !is_right_associative() && !is_commutative() &&
+        return
+            get_family_id() == null_family_id && !is_left_associative() && !is_right_associative() && !is_commutative() &&
             !is_chainable() && !is_pairwise() && !is_injective() && !is_idempotent() && !is_skolem();
     }
 };
@@ -416,7 +416,7 @@
 class ast {
 protected:
     friend class ast_manager;
-
+
     unsigned m_id;
     unsigned m_kind:16;
     // Warning: the marks should be used carefully, since they are shared.
@@ -428,10 +428,10 @@
     //    So, it is only safe to use mark by "self-contained" code.
     //    They should be viewed as temporary information.
     //  - The functor shared_occs is used by some AST pretty printers.
-    //  - So, a code that uses marks could not use the pretty printer if
+    //  - So, a code that uses marks could not use the pretty printer if
     //    shared_occs used one of the public marks.
     //  - This was a constant source of assertion violations.
-    unsigned m_mark_shared_occs:1;
+    unsigned m_mark_shared_occs:1;
     friend class shared_occs_mark;
     void mark_so(bool flag) { m_mark_shared_occs = flag; }
     void reset_mark_so() { m_mark_shared_occs = false; }
@@ -442,18 +442,18 @@
     // In debug mode, we store who is the owner of the mark.
     void *   m_mark1_owner;
     void *   m_mark2_owner;
-#endif
-
-    void inc_ref() {
+#endif
+
+    void inc_ref() {
         SASSERT(m_ref_count < UINT_MAX);
-        m_ref_count ++;
-    }
-
-    void dec_ref() {
-        SASSERT(m_ref_count > 0);
-        m_ref_count --;
-    }
-
+        m_ref_count ++;
+    }
+
+    void dec_ref() {
+        SASSERT(m_ref_count > 0);
+        m_ref_count --;
+    }
+
     ast(ast_kind k):m_id(UINT_MAX), m_kind(k), m_mark1(false), m_mark2(false), m_mark_shared_occs(false), m_ref_count(0) {
         DEBUG_CODE({
             m_mark1_owner = 0;
@@ -521,7 +521,7 @@
 // -----------------------------------

 /**
-   The ids of expressions and declarations are in different ranges.
+   The ids of expressions and declarations are in different ranges.
 */
 const unsigned c_first_decl_id = (1u << 31u);

@@ -556,9 +556,9 @@

 class sort : public decl {
     friend class ast_manager;
-
+
     static unsigned get_obj_size() { return sizeof(sort); }
-
+
     sort(symbol const & name, sort_info * info):decl(AST_SORT, name, info) {}
 public:
     sort_info * get_info() const { return static_cast<sort_info*>(m_info); }
@@ -577,13 +577,13 @@

 class func_decl : public decl {
     friend class ast_manager;
-
+
     unsigned         m_arity;
     sort *           m_range;
     sort *           m_domain[0];
-
-    static unsigned get_obj_size(unsigned arity) { return sizeof(func_decl) + arity * sizeof(sort *); }
-
+
+    static unsigned get_obj_size(unsigned arity) { return sizeof(func_decl) + arity * sizeof(sort *); }
+
     func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range, func_decl_info * info);
 public:
     func_decl_info * get_info() const { return static_cast<func_decl_info*>(m_info); }
@@ -616,7 +616,7 @@
 class expr : public ast {
 protected:
     friend class ast_manager;
-
+
     expr(ast_kind k):ast(k) {}
 public:
 };
@@ -641,20 +641,20 @@

 class app : public expr {
     friend class ast_manager;
-
+
     func_decl *  m_decl;
     unsigned     m_num_args;
     expr *       m_args[0];
-
+
     static app_flags g_constant_flags;
-
+
     // remark: store term depth in the end of the app. the depth is only stored if the num_args > 0
-    static unsigned get_obj_size(unsigned num_args) {
-        return num_args == 0 ? sizeof(app) : sizeof(app) + num_args * sizeof(expr *) + sizeof(app_flags);
-    }
+    static unsigned get_obj_size(unsigned num_args) {
+        return num_args == 0 ? sizeof(app) : sizeof(app) + num_args * sizeof(expr *) + sizeof(app_flags);
+    }

     friend class tmp_app;
-
+
     app_flags * flags() const { return m_num_args == 0 ? &g_constant_flags : reinterpret_cast<app_flags*>(const_cast<expr**>(m_args + m_num_args)); }

     app(func_decl * decl, unsigned num_args, expr * const * args);
@@ -706,11 +706,11 @@
     expr ** get_args() {
         return get_app()->m_args;
     }
-
+
     void set_decl(func_decl * d) {
         get_app()->m_decl = d;
     }
-
+
     void set_num_args(unsigned num_args) {
         get_app()->m_num_args = num_args;
     }
@@ -746,12 +746,12 @@

 class var : public expr {
     friend class ast_manager;
-
+
     unsigned     m_idx;
     sort *       m_sort;
-
+
     static unsigned get_obj_size() { return sizeof(var); }
-
+
     var(unsigned idx, sort * s):expr(AST_VAR), m_idx(idx), m_sort(s) {}
 public:
     unsigned get_idx() const { return m_idx; }
@@ -775,13 +775,13 @@
     int                 m_weight;
     bool                m_has_unused_vars;
     bool                m_has_labels;
-    symbol              m_qid;
-    symbol              m_skid;
+    symbol              m_qid;
+    symbol              m_skid;
     unsigned            m_num_patterns;
     unsigned            m_num_no_patterns;
     char                m_patterns_decls[0];
-
-    static unsigned get_obj_size(unsigned num_decls, unsigned num_patterns, unsigned num_no_patterns) {
+
+    static unsigned get_obj_size(unsigned num_decls, unsigned num_patterns, unsigned num_no_patterns) {
         return sizeof(quantifier) + num_decls * (sizeof(sort *) + sizeof(symbol)) + (num_patterns + num_no_patterns) * sizeof(expr*);
     }

@@ -811,7 +811,7 @@
     expr * get_no_pattern(unsigned idx) const { return get_no_patterns()[idx]; }
     bool has_patterns() const { return m_num_patterns > 0 || m_num_no_patterns > 0; }
     unsigned get_size() const { return get_obj_size(m_num_decls, m_num_patterns, m_num_no_patterns); }
-
+
     bool may_have_unused_vars() const { return m_has_unused_vars; }
     void set_no_unused_vars() { m_has_unused_vars = false; }

@@ -884,8 +884,8 @@

 // This is the internal comparison functor for hash-consing AST nodes.
 struct ast_eq_proc {
-    bool operator()(ast const * n1, ast const * n2) const {
-        return n1->hash() == n2->hash() && compare_nodes(n1, n2);
+    bool operator()(ast const * n1, ast const * n2) const {
+        return n1->hash() == n2->hash() && compare_nodes(n1, n2);
     }
 };

@@ -917,18 +917,18 @@
 protected:
     ast_manager * m_manager;
     family_id     m_family_id;
-
+
     virtual void set_manager(ast_manager * m, family_id id) {
         SASSERT(m_manager == 0);
         m_manager   = m;
         m_family_id = id;
     }
-
+
     friend class ast_manager;
-
+
 public:
     decl_plugin():m_manager(0), m_family_id(null_family_id) {}
-
+
     virtual ~decl_plugin() {}
     virtual void finalize() {}

@@ -936,24 +936,24 @@
     virtual decl_plugin * mk_fresh() = 0;

     family_id get_family_id() const { return m_family_id; }
-
+
     virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters) = 0;
-
-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
+
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                      unsigned arity, sort * const * domain, sort * range) = 0;

-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const* parameters,
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const* parameters,
                                      unsigned num_args, expr * const * args, sort * range);

     /**
        \brief Return true if the plugin can decide whether two
        interpreted constants are equal or not.
-
+
        For all a, b:
           If is_value(a) and is_value(b)
           Then,
                are_equal(a, b) != are_distinct(a, b)
-
+
        The may be much more expensive than checking a pointer.

        We need this because some plugin values are too expensive too canonize.
@@ -963,7 +963,7 @@
     /**
        \brief Return true if \c a is a unique plugin value.
        The following property should hold for unique theory values:
-
+
        For all a, b:
           If is_unique_value(a) and is_unique_value(b)
           Then,
@@ -976,11 +976,11 @@
     virtual bool is_unique_value(app * a) const { return false; }

     virtual bool are_equal(app * a, app * b) const { return a == b && is_unique_value(a) && is_unique_value(b); }
-
+
     virtual bool are_distinct(app * a, app * b) const { return a != b && is_unique_value(a) && is_unique_value(b); }
-
+
     virtual void get_op_names(svector<builtin_name> & op_names, symbol const & logic = symbol()) {}
-
+
     virtual void get_sort_names(svector<builtin_name> & sort_names, symbol const & logic = symbol()) {}

     virtual expr * get_some_value(sort * s) { return 0; }
@@ -989,7 +989,7 @@
     // This may be the case, for example, for array and datatype sorts.
     virtual bool is_fully_interp(sort const * s) const { return true; }

-    // Event handlers for deleting/translating PARAM_EXTERNAL
+    // Event handlers for deleting/translating PARAM_EXTERNAL
     virtual void del(parameter const & p) {}
     virtual parameter translate(parameter const & p, decl_plugin & target) { UNREACHABLE(); return p; }
 };
@@ -1009,12 +1009,12 @@
     OP_TRUE, OP_FALSE, OP_EQ, OP_DISTINCT, OP_ITE, OP_AND, OP_OR, OP_IFF, OP_XOR, OP_NOT, OP_IMPLIES, OP_OEQ, OP_INTERP, LAST_BASIC_OP,

     PR_UNDEF, PR_TRUE, PR_ASSERTED, PR_GOAL, PR_MODUS_PONENS, PR_REFLEXIVITY, PR_SYMMETRY, PR_TRANSITIVITY, PR_TRANSITIVITY_STAR, PR_MONOTONICITY, PR_QUANT_INTRO,
-    PR_DISTRIBUTIVITY, PR_AND_ELIM, PR_NOT_OR_ELIM, PR_REWRITE, PR_REWRITE_STAR, PR_PULL_QUANT,
+    PR_DISTRIBUTIVITY, PR_AND_ELIM, PR_NOT_OR_ELIM, PR_REWRITE, PR_REWRITE_STAR, PR_PULL_QUANT,
     PR_PULL_QUANT_STAR, PR_PUSH_QUANT, PR_ELIM_UNUSED_VARS, PR_DER, PR_QUANT_INST,
-
+
     PR_HYPOTHESIS, PR_LEMMA, PR_UNIT_RESOLUTION, PR_IFF_TRUE, PR_IFF_FALSE, PR_COMMUTATIVITY, PR_DEF_AXIOM,

-    PR_DEF_INTRO, PR_APPLY_DEF, PR_IFF_OEQ, PR_NNF_POS, PR_NNF_NEG, PR_NNF_STAR, PR_SKOLEMIZE, PR_CNF_STAR,
+    PR_DEF_INTRO, PR_APPLY_DEF, PR_IFF_OEQ, PR_NNF_POS, PR_NNF_NEG, PR_NNF_STAR, PR_SKOLEMIZE, PR_CNF_STAR,
     PR_MODUS_PONENS_OEQ, PR_TH_LEMMA, PR_HYPER_RESOLVE, LAST_BASIC_PR
 };

@@ -1067,7 +1067,7 @@
     func_decl * m_lemma_decl;
     ptr_vector<func_decl> m_unit_resolution_decls;

-    func_decl * m_def_intro_decl;
+    func_decl * m_def_intro_decl;
     func_decl * m_iff_oeq_decl;
     func_decl * m_skolemize_decl;
     func_decl * m_mp_oeq_decl;
@@ -1083,7 +1083,7 @@
     static bool is_proof(decl_kind k) { return k > LAST_BASIC_OP; }
     bool check_proof_sorts(basic_op_kind k, unsigned arity, sort * const * domain) const;
     bool check_proof_args(basic_op_kind k, unsigned num_args, expr * const * args) const;
-    func_decl * mk_bool_op_decl(char const * name, basic_op_kind k, unsigned num_args = 0,
+    func_decl * mk_bool_op_decl(char const * name, basic_op_kind k, unsigned num_args = 0,
                                 bool asooc = false, bool comm = false, bool idempotent = false, bool flat_associative = false, bool chainable = false);
     func_decl * mk_implies_decl();
     func_decl * mk_proof_decl(char const * name, basic_op_kind k, unsigned num_parents);
@@ -1093,10 +1093,10 @@
     func_decl * mk_proof_decl(basic_op_kind k, unsigned num_parents);
     func_decl * mk_proof_decl(basic_op_kind k, unsigned num_parameters, parameter const* params, unsigned num_parents);
     func_decl * mk_proof_decl(
-        char const * name, basic_op_kind k,
+        char const * name, basic_op_kind k,
         unsigned num_parameters, parameter const* params, unsigned num_parents);

-
+
     virtual void set_manager(ast_manager * m, family_id id);
     func_decl * mk_eq_decl_core(char const * name, decl_kind k, sort * s, ptr_vector<func_decl> & cache);
     func_decl * mk_ite_decl(sort * s);
@@ -1105,7 +1105,7 @@
     sort* join(unsigned n, expr*const* es);
 public:
     basic_decl_plugin();
-
+
     virtual ~basic_decl_plugin() {}
     virtual void finalize();

@@ -1114,23 +1114,23 @@
     }

     virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters);
-
-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
+
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                      unsigned arity, sort * const * domain, sort * range);
-
-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
+
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                      unsigned num_args, expr * const * args, sort * range);
-
+
     virtual void get_op_names(svector<builtin_name> & op_names, symbol const & logic);
-
+
     virtual void get_sort_names(svector<builtin_name> & sort_names, symbol const & logic);

-    virtual bool is_value(app* a) const;
-
-    virtual bool is_unique_value(app* a) const;
-
+    virtual bool is_value(app* a) const;
+
+    virtual bool is_unique_value(app* a) const;
+
     sort * mk_bool_sort() const { return m_bool_sort; }
-    sort * mk_proof_sort() const { return m_proof_sort; }
+    sort * mk_proof_sort() const { return m_proof_sort; }

     virtual expr * get_some_value(sort * s);
 };
@@ -1139,7 +1139,7 @@

 // -----------------------------------
 //
-// label_decl_plugin
+// label_decl_plugin
 //
 // -----------------------------------

@@ -1168,7 +1168,7 @@

     /**
        contract: when label
-       parameter[0] (int):      0 - if the label is negative, 1 - if positive.
+       parameter[0] (int):      0 - if the label is negative, 1 - if positive.
        parameter[1] (symbol):   label's tag.
        ...
        parameter[n-1] (symbol): label's tag.
@@ -1178,13 +1178,13 @@
        ...
        parameter[n-1] (symbol): label's tag.
     */
-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                      unsigned arity, sort * const * domain, sort * range);
 };

 // -----------------------------------
 //
-// pattern_decl_plugin
+// pattern_decl_plugin
 //
 // -----------------------------------

@@ -1202,7 +1202,7 @@

     virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters);

-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                      unsigned arity, sort * const * domain, sort * range);
 };

@@ -1222,7 +1222,7 @@
    introduce unsoundess if the sort of a value is finite.

    Moreover, values should never be internalized in a logical context.
-
+
    However, values can be used during evaluation (i.e., simplification).

    \remark Model values can be viewed as the partion ids in Z3 1.x.
@@ -1234,18 +1234,18 @@
     virtual decl_plugin * mk_fresh() { return alloc(model_value_decl_plugin); }

     virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters);
-
+
     /**
-       contract:
+       contract:
        parameter[0]: (integer) value idx
        parameter[1]: (ast)     sort of the value.
     */
-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                      unsigned arity, sort * const * domain, sort * range);

     virtual bool is_value(app* n) const;

-    virtual bool is_unique_value(app* a) const;
+    virtual bool is_unique_value(app* a) const;
 };

 // -----------------------------------
@@ -1261,7 +1261,7 @@
     user_sort_plugin() {}

     virtual sort * mk_sort(decl_kind k, unsigned num_parameters, parameter const * parameters);
-    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
+    virtual func_decl * mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                      unsigned arity, sort * const * domain, sort * range);
     decl_kind register_name(symbol s);
     virtual decl_plugin * mk_fresh();
@@ -1321,7 +1321,7 @@
     bool is_term_ite(expr const * n) const { return is_ite(n) && !is_bool(n); }
     bool is_true(expr const * n) const { return is_app_of(n, m_fid, OP_TRUE); }
     bool is_false(expr const * n) const { return is_app_of(n, m_fid, OP_FALSE); }
-    bool is_complement_core(expr const * n1, expr const * n2) const {
+    bool is_complement_core(expr const * n1, expr const * n2) const {
         return (is_true(n1) && is_false(n2)) || (is_not(n1) && to_app(n1)->get_arg(0) == n2);
     }
     bool is_complement(expr const * n1, expr const * n2) const { return is_complement_core(n1, n2) || is_complement_core(n2, n1); }
@@ -1353,7 +1353,7 @@
 //
 // Get Some Value functor
 //
-// Functor for returning some value
+// Functor for returning some value
 // of the given sort.
 //
 // -----------------------------------
@@ -1394,11 +1394,11 @@
         static const unsigned max_trail_sz = 16;
         static const unsigned factor       = 2;
     };
-
+
     struct expr_array_config : public array_config {
         typedef expr *                   value;
     };
-
+
     typedef parray_manager<expr_array_config> expr_array_manager;

     struct expr_dependency_config : public config {
@@ -1439,7 +1439,7 @@
     family_id                 m_model_value_family_id;
     family_id                 m_user_sort_family_id;
     family_id                 m_arith_family_id;
-    ast_table                 m_ast_table;
+    ast_table                 m_ast_table;
     id_gen                    m_expr_id_gen;
     id_gen                    m_decl_id_gen;
     sort *                    m_bool_sort;
@@ -1477,20 +1477,20 @@

     void enable_int_real_coercions(bool f) { m_int_real_coercions = f; }
     bool int_real_coercions() const { return m_int_real_coercions; }
-
+
     // Return true if s1 and s2 are equal, or coercions are enabled, and s1 and s2 are compatible.
     bool compatible_sorts(sort * s1, sort * s2) const;

     // For debugging purposes
     void display_free_ids(std::ostream & out) { m_expr_id_gen.display_free_ids(out); out << "\n"; m_decl_id_gen.display_free_ids(out); }
-
+
     void compact_memory();

     void compress_ids();

     // Equivalent to throw ast_exception(msg)
     void raise_exception(char const * msg);
-
+
     bool is_format_manager() const { return m_format_manager == 0; }

     ast_manager & get_format_manager() { return is_format_manager() ? *this : *m_format_manager; }
@@ -1498,7 +1498,7 @@
     void copy_families_plugins(ast_manager const & from);

     small_object_allocator & get_allocator() { return m_alloc; }
-
+
     family_id mk_family_id(symbol const & s) { return m_family_manager.mk_family_id(s); }
     family_id mk_family_id(char const * s) { return mk_family_id(symbol(s)); }

@@ -1507,70 +1507,70 @@

     symbol const & get_family_name(family_id fid) const { return m_family_manager.get_name(fid); }

-    bool is_builtin_family_id(family_id fid) const {
-        return
-            fid == null_family_id ||
-            fid == m_basic_family_id ||
-            fid == m_label_family_id ||
-            fid == m_pattern_family_id ||
+    bool is_builtin_family_id(family_id fid) const {
+        return
+            fid == null_family_id ||
+            fid == m_basic_family_id ||
+            fid == m_label_family_id ||
+            fid == m_pattern_family_id ||
             fid == m_model_value_family_id ||
-            fid == m_user_sort_family_id;
+            fid == m_user_sort_family_id;
     }

     reslimit& limit() { return m_limit; }
     bool canceled() { return !limit().inc(); }

     void register_plugin(symbol const & s, decl_plugin * plugin);
-
+
     void register_plugin(family_id id, decl_plugin * plugin);

     decl_plugin * get_plugin(family_id fid) const;
-
+
     bool has_plugin(family_id fid) const { return get_plugin(fid) != 0; }
-
+
     bool has_plugin(symbol const & s) const { return m_family_manager.has_family(s) && has_plugin(m_family_manager.get_family_id(s)); }
-
+
     void get_dom(svector<symbol> & dom) const { m_family_manager.get_dom(dom); }
-
+
     void get_range(svector<family_id> & range) const { m_family_manager.get_range(range); }
-
+
     family_id get_basic_family_id() const { return m_basic_family_id; }
-
+
     basic_decl_plugin * get_basic_decl_plugin() const { return static_cast<basic_decl_plugin*>(get_plugin(m_basic_family_id)); }

     family_id get_user_sort_family_id() const { return m_user_sort_family_id; }
-
+
     user_sort_plugin * get_user_sort_plugin() const { return static_cast<user_sort_plugin*>(get_plugin(m_user_sort_family_id)); }

     /**
        \brief Debugging support method: set the next expression identifier to be the least value id' s.t.
               - id' >= id
               - id' is not used by any AST in m_table
-              - id' is not in the expression m_free_ids
+              - id' is not in the expression m_free_ids

         This method should be only used to create small repros that exposes bugs in Z3.
     */
     void set_next_expr_id(unsigned id);
-
-    bool is_value(expr * e) const;
-
+
+    bool is_value(expr * e) const;
+
     bool is_unique_value(expr * e) const;

     bool are_equal(expr * a, expr * b) const;
-
+
     bool are_distinct(expr * a, expr * b) const;
-
+
     bool contains(ast * a) const { return m_ast_table.contains(a); }
-
+
     unsigned get_num_asts() const { return m_ast_table.size(); }

     void debug_ref_count() { m_debug_ref_count = true; }
-
-    void inc_ref(ast * n) {
+
+    void inc_ref(ast * n) {
         if (n)
             n->inc_ref();
     }
-
+
     void dec_ref(ast * n) {
         if (n) {
             n->dec_ref();
@@ -1578,45 +1578,45 @@
                 delete_node(n);
         }
     }
-
+
     template<typename T>
     void inc_array_ref(unsigned sz, T * const * a) {
         for(unsigned i = 0; i < sz; i++) {
             inc_ref(a[i]);
         }
     }
-
+
     template<typename T>
     void dec_array_ref(unsigned sz, T * const * a) {
         for(unsigned i = 0; i < sz; i++) {
             dec_ref(a[i]);
         }
     }
-
+
     static unsigned get_node_size(ast const * n);
-
-    size_t get_allocation_size() const {
-        return m_alloc.get_allocation_size();
-    }
-
+
+    size_t get_allocation_size() const {
+        return m_alloc.get_allocation_size();
+    }
+
 protected:
     ast * register_node_core(ast * n);
-
+
     template<typename T>
-    T * register_node(T * n) {
-        return static_cast<T *>(register_node_core(n));
-    }
-
+    T * register_node(T * n) {
+        return static_cast<T *>(register_node_core(n));
+    }
+
     void delete_node(ast * n);
-
-    void * allocate_node(unsigned size) {
+
+    void * allocate_node(unsigned size) {
         return m_alloc.allocate(size);
     }
-
+
     void deallocate_node(ast * n, unsigned sz) {
         m_alloc.deallocate(sz, n);
     }
-
+
 public:
     sort * get_sort(expr const * n) const { return ::get_sort(n); }
     void check_sort(func_decl const * decl, unsigned num_args, expr * const * args) const;
@@ -1629,12 +1629,12 @@

 private:
     sort * mk_sort(symbol const & name, sort_info * info);
-
+
 public:
     sort * mk_uninterpreted_sort(symbol const & name, unsigned num_parameters, parameter const * parameters);

     sort * mk_uninterpreted_sort(symbol const & name) { return mk_uninterpreted_sort(name, 0, 0); }
-
+
     sort * mk_sort(symbol const & name, sort_info const & info) {
         if (info.get_family_id() == null_family_id) {
             return mk_uninterpreted_sort(name);
@@ -1643,45 +1643,45 @@
             return mk_sort(name, &const_cast<sort_info &>(info));
         }
     }
-
+
     sort * mk_sort(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = 0);
-
+
     sort * mk_bool_sort() const { return m_bool_sort; }
-
+
     sort * mk_proof_sort() const { return m_proof_sort; }

     sort * mk_fresh_sort(char const * prefix = "");

     bool is_uninterp(sort const * s) const { return s->get_family_id() == null_family_id || s->get_family_id() == m_user_sort_family_id; }
-
+
     /**
        \brief A sort is "fully" interpreted if it is interpreted,
-       and doesn't depend on other uninterpreted sorts.
+       and doesn't depend on other uninterpreted sorts.
     */
     bool is_fully_interp(sort const * s) const;

-    func_decl * mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters,
+    func_decl * mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters,
                              unsigned arity, sort * const * domain, sort * range = 0);

-    func_decl * mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters,
+    func_decl * mk_func_decl(family_id fid, decl_kind k, unsigned num_parameters, parameter const * parameters,
                              unsigned num_args, expr * const * args, sort * range = 0);

-    app * mk_app(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = 0,
+    app * mk_app(family_id fid, decl_kind k, unsigned num_parameters = 0, parameter const * parameters = 0,
                  unsigned num_args = 0, expr * const * args = 0, sort * range = 0);

     app * mk_app(family_id fid, decl_kind k, unsigned num_args, expr * const * args);

     app * mk_app(family_id fid, decl_kind k, expr * arg);
-
+
     app * mk_app(family_id fid, decl_kind k, expr * arg1, expr * arg2);
-
+
     app * mk_app(family_id fid, decl_kind k, expr * arg1, expr * arg2, expr * arg3);

     app * mk_const(family_id fid, decl_kind k) { return mk_app(fid, k, 0, static_cast<expr * const *>(0)); }
 private:
-    func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range,
+    func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range,
                              func_decl_info * info);
-
+
     app * mk_app_core(func_decl * decl, expr * arg1, expr * arg2);

     app * mk_app_core(func_decl * decl, unsigned num_args, expr * const * args);
@@ -1690,8 +1690,8 @@
     func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range) {
         return mk_func_decl(name, arity, domain, range, static_cast<func_decl_info *>(0));
     }
-
-    func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range,
+
+    func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range,
                              func_decl_info const & info) {
         if (info.is_null()) {
             return mk_func_decl(name, arity, domain, range, static_cast<func_decl_info *>(0));
@@ -1700,69 +1700,69 @@
             return mk_func_decl(name, arity, domain, range, & const_cast<func_decl_info&>(info));
         }
     }
-
+
     func_decl * mk_func_decl(unsigned arity, sort * const * domain, func_decl_info const & info) {
-        return mk_func_decl(info.get_family_id(), info.get_decl_kind(), info.get_num_parameters(), info.get_parameters(),
+        return mk_func_decl(info.get_family_id(), info.get_decl_kind(), info.get_num_parameters(), info.get_parameters(),
                             arity, domain);
     }
-
+
     func_decl * mk_const_decl(symbol const & name, sort * s) {
         return mk_func_decl(name, static_cast<unsigned>(0), 0, s);
     }
-
+
     func_decl * mk_const_decl(symbol const & name, sort * s, func_decl_info const & info) {
         return mk_func_decl(name, static_cast<unsigned>(0), 0, s, info);
     }
-
+
     func_decl * mk_func_decl(symbol const & name, sort * domain, sort * range, func_decl_info const & info) {
         return mk_func_decl(name, 1, &domain, range, info);
     }
-
+
     func_decl * mk_func_decl(symbol const & name, sort * domain, sort * range) {
         return mk_func_decl(name, 1, &domain, range);
     }
-
+
     func_decl * mk_func_decl(symbol const & name, sort * domain1, sort * domain2, sort * range, func_decl_info const & info) {
         sort * d[2] = { domain1, domain2 };
         return mk_func_decl(name, 2, d, range, info);
     }
-
-    func_decl * mk_func_decl(symbol const & name, sort * domain1, sort * domain2, sort * range) {
+
+    func_decl * mk_func_decl(symbol const & name, sort * domain1, sort * domain2, sort * range) {
         sort * d[2] = { domain1, domain2 };
         return mk_func_decl(name, 2, d, range);
     }
-
-    func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range,
+
+    func_decl * mk_func_decl(symbol const & name, unsigned arity, sort * const * domain, sort * range,
                              bool assoc, bool comm = false, bool inj = false);

     func_decl * mk_func_decl(symbol const & name, sort * domain1, sort * domain2, sort * range, bool assoc, bool comm = false) {
         sort * d[2] = { domain1, domain2 };
         return mk_func_decl(name, 2, d, range, assoc, comm, false);
     }
-
+
     app * mk_app(func_decl * decl, unsigned num_args, expr * const * args);

     app * mk_app(func_decl * decl, expr * const * args) {
         return mk_app(decl, decl->get_arity(), args);
     }
-
+
     app * mk_app(func_decl * decl, expr * arg) {
         SASSERT(decl->get_arity() == 1);
         return mk_app(decl, 1, &arg);
     }
-
+
     app * mk_app(func_decl * decl, expr * arg1, expr * arg2) {
         SASSERT(decl->get_arity() == 2);
         expr * args[2] = { arg1, arg2 };
         return mk_app(decl, 2, args);
     }
-
+
     app * mk_app(func_decl * decl, expr * arg1, expr * arg2, expr * arg3) {
         SASSERT(decl->get_arity() == 3);
         expr * args[3] = { arg1, arg2, arg3 };
         return mk_app(decl, 3, args);
     }
-
+
     app * mk_const(func_decl * decl) {
         SASSERT(decl->get_arity() == 0);
         return mk_app(decl, static_cast<unsigned>(0), static_cast<expr**>(0));
@@ -1771,21 +1771,21 @@
     app * mk_const(symbol const & name, sort * s) {
         return mk_const(mk_const_decl(name, s));
     }
-
+
     func_decl * mk_fresh_func_decl(symbol const & prefix, symbol const & suffix, unsigned arity,
                                    sort * const * domain, sort * range);

     func_decl * mk_fresh_func_decl(unsigned arity, sort * const * domain, sort * range) { return mk_fresh_func_decl(symbol::null, symbol::null, arity, domain, range); }
-
-    func_decl * mk_fresh_func_decl(char const * prefix, char const * suffix, unsigned arity,
+
+    func_decl * mk_fresh_func_decl(char const * prefix, char const * suffix, unsigned arity,
                                    sort * const * domain, sort * range) {
         return mk_fresh_func_decl(symbol(prefix), symbol(suffix), arity, domain, range);
     }
-
+
     func_decl * mk_fresh_func_decl(char const * prefix, unsigned arity, sort * const * domain, sort * range) {
         return mk_fresh_func_decl(symbol(prefix), symbol::null, arity, domain, range);
     }
-
+
     app * mk_fresh_const(char const * prefix, sort * s) { return mk_const(mk_fresh_func_decl(prefix, 0, 0, s)); }

     symbol mk_fresh_var_name(char const * prefix = 0);
@@ -1808,7 +1808,7 @@
         return is_label(n)?(l = to_app(n)->get_arg(0), true):false;
     }

-    bool is_label(expr const * n, bool& pos) const {
+    bool is_label(expr const * n, bool& pos) const {
         if (is_app_of(n, m_label_family_id, OP_LABEL)) {
             pos  = to_app(n)->get_decl()->get_parameter(0).get_int() != 0;
             return true;
@@ -1832,37 +1832,37 @@

     app * mk_pattern(app * expr) { return mk_pattern(1, &expr); }

-    bool is_pattern(expr const * n) const;
-
-public:
-
-    quantifier * mk_quantifier(bool forall, unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body,
+    bool is_pattern(expr const * n) const;
+
+public:
+
+    quantifier * mk_quantifier(bool forall, unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body,
                                int weight = 0, symbol const & qid = symbol::null, symbol const & skid = symbol::null,
-                               unsigned num_patterns = 0, expr * const * patterns = 0,
+                               unsigned num_patterns = 0, expr * const * patterns = 0,
                                unsigned num_no_patterns = 0, expr * const * no_patterns = 0);

-    quantifier * mk_forall(unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body,
+    quantifier * mk_forall(unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body,
                            int weight = 0, symbol const & qid = symbol::null, symbol const & skid = symbol::null,
-                           unsigned num_patterns = 0, expr * const * patterns = 0,
+                           unsigned num_patterns = 0, expr * const * patterns = 0,
                            unsigned num_no_patterns = 0, expr * const * no_patterns = 0) {
         return mk_quantifier(true, num_decls, decl_sorts, decl_names, body, weight, qid, skid, num_patterns, patterns,
                              num_no_patterns, no_patterns);
     }

-    quantifier * mk_exists(unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body,
+    quantifier * mk_exists(unsigned num_decls, sort * const * decl_sorts, symbol const * decl_names, expr * body,
                            int weight = 0, symbol const & qid = symbol::null, symbol const & skid = symbol::null,
-                           unsigned num_patterns = 0, expr * const * patterns = 0,
+                           unsigned num_patterns = 0, expr * const * patterns = 0,
                            unsigned num_no_patterns = 0, expr * const * no_patterns = 0) {
         return mk_quantifier(false, num_decls, decl_sorts, decl_names, body, weight, qid, skid, num_patterns, patterns,
                              num_no_patterns, no_patterns);
     }
-
+
     quantifier * update_quantifier(quantifier * q, unsigned new_num_patterns, expr * const * new_patterns, expr * new_body);

     quantifier * update_quantifier(quantifier * q, unsigned new_num_patterns, expr * const * new_patterns, unsigned new_num_no_patterns, expr * const * new_no_patterns, expr * new_body);
-
+
     quantifier * update_quantifier(quantifier * q, expr * new_body);
-
+
     quantifier * update_quantifier_weight(quantifier * q, int new_weight);

     quantifier * update_quantifier(quantifier * q, bool new_is_forall, expr * new_body);
@@ -1919,12 +1919,12 @@
     bool empty(expr_dependency_array const & r) const { return m_expr_dependency_array_manager.empty(r); }
     expr_dependency * get(expr_dependency_array const & r, unsigned i) const { return m_expr_dependency_array_manager.get(r, i); }
     void set(expr_dependency_array & r, unsigned i, expr_dependency * v) { m_expr_dependency_array_manager.set(r, i, v); }
-    void set(expr_dependency_array const & s, unsigned i, expr_dependency * v, expr_dependency_array & r) {
-        m_expr_dependency_array_manager.set(s, i, v, r);
+    void set(expr_dependency_array const & s, unsigned i, expr_dependency * v, expr_dependency_array & r) {
+        m_expr_dependency_array_manager.set(s, i, v, r);
     }
     void push_back(expr_dependency_array & r, expr_dependency * v) { m_expr_dependency_array_manager.push_back(r, v); }
-    void push_back(expr_dependency_array const & s, expr_dependency * v, expr_dependency_array & r) {
-        m_expr_dependency_array_manager.push_back(s, v, r);
+    void push_back(expr_dependency_array const & s, expr_dependency * v, expr_dependency_array & r) {
+        m_expr_dependency_array_manager.push_back(s, v, r);
     }
     void pop_back(expr_dependency_array & r) { m_expr_dependency_array_manager.pop_back(r); }
     void pop_back(expr_dependency_array const & s, expr_dependency_array & r) { m_expr_dependency_array_manager.pop_back(s, r); }
@@ -1953,7 +1953,7 @@
     bool is_term_ite(expr const * n) const { return is_ite(n) && !is_bool(n); }
     bool is_true(expr const * n) const { return n == m_true; }
     bool is_false(expr const * n) const { return n == m_false; }
-    bool is_complement_core(expr const * n1, expr const * n2) const {
+    bool is_complement_core(expr const * n1, expr const * n2) const {
         return (is_true(n1) && is_false(n2)) || (is_not(n1) && to_app(n1)->get_arg(0) == n2);
     }
     bool is_complement(expr const * n1, expr const * n2) const { return is_complement_core(n1, n2) || is_complement_core(n2, n1); }
@@ -1981,14 +1981,14 @@
     MATCH_TERNARY(is_and);
     MATCH_TERNARY(is_or);

-    bool is_ite(expr const* n, expr*& t1, expr*& t2, expr*& t3) const {
-        if (is_ite(n)) {
-            t1 = to_app(n)->get_arg(0);
-            t2 = to_app(n)->get_arg(1);
+    bool is_ite(expr const* n, expr*& t1, expr*& t2, expr*& t3) const {
+        if (is_ite(n)) {
+            t1 = to_app(n)->get_arg(0);
+            t2 = to_app(n)->get_arg(1);
             t3 = to_app(n)->get_arg(2);
-            return true;
-        }
-        return false;
+            return true;
+        }
+        return false;
     }

 public:
@@ -2014,14 +2014,14 @@
     app * mk_interp(expr * arg) { return mk_app(m_basic_family_id, OP_INTERP, arg); }

-    func_decl* mk_and_decl() {
+    func_decl* mk_and_decl() {
         sort* domain[2] = { m_bool_sort, m_bool_sort };
-        return mk_func_decl(m_basic_family_id, OP_AND, 0, 0, 2, domain);
+        return mk_func_decl(m_basic_family_id, OP_AND, 0, 0, 2, domain);
     }
     func_decl* mk_not_decl() { return mk_func_decl(m_basic_family_id, OP_NOT, 0, 0, 1, &m_bool_sort); }
     func_decl* mk_or_decl() {
         sort* domain[2] = { m_bool_sort, m_bool_sort };
-        return mk_func_decl(m_basic_family_id, OP_OR, 0, 0, 2, domain);
+        return mk_func_decl(m_basic_family_id, OP_OR, 0, 0, 2, domain);
     }

 // -----------------------------------
@@ -2036,7 +2036,7 @@
     app * mk_model_value(unsigned idx, sort * s);
     bool is_model_value(expr const * n) const { return is_app_of(n, m_model_value_family_id, OP_MODEL_VALUE); }
     bool is_model_value(func_decl const * d) const { return is_decl_of(d, m_model_value_family_id, OP_MODEL_VALUE); }
-
+
     expr * get_some_value(sort * s, some_value_proc * p);
     expr * get_some_value(sort * s);

@@ -2059,7 +2059,7 @@
     bool fine_grain_proofs() const { return m_proof_mode == PGM_FINE; }
     proof_gen_mode proof_mode() const { return m_proof_mode; }
     void toggle_proof_mode(proof_gen_mode m) { m_proof_mode = m; } // APIs for creating proof objects return [undef]
-
+
     proof * mk_undef_proof() const { return m_undef_proof; }

     bool is_proof(expr const * n) const { return is_app(n) && to_app(n)->get_decl()->get_range() == m_proof_sort; }
@@ -2067,7 +2067,7 @@
     proof* mk_hyper_resolve(unsigned num_premises, proof* const* premises, expr* concl,
                             svector<std::pair<unsigned, unsigned> > const& positions,
                             vector<ref_vector<expr, ast_manager> > const& substs);
-
+

     bool is_undef_proof(expr const * e) const { return e == m_undef_proof; }
     bool is_asserted(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_ASSERTED); }
@@ -2089,30 +2089,30 @@
     bool is_quant_inst(expr const* e, expr*& not_q_or_i, ptr_vector<expr>& binding) const;
     bool is_rewrite(expr const* e, expr*& r1, expr*& r2) const;
     bool is_hyper_resolve(proof* p) const { return is_app_of(p, m_basic_family_id, PR_HYPER_RESOLVE); }
-    bool is_hyper_resolve(proof* p,
+    bool is_hyper_resolve(proof* p,
                           ref_vector<proof, ast_manager>& premises,
                           obj_ref<expr, ast_manager>& conclusion,
                           svector<std::pair<unsigned, unsigned> > & positions,
                           vector<ref_vector<expr, ast_manager> >& substs);

-
+
     bool is_def_intro(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_DEF_INTRO); }
     bool is_apply_def(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_APPLY_DEF); }
     bool is_skolemize(expr const * e) const { return is_app_of(e, m_basic_family_id, PR_SKOLEMIZE); }

     MATCH_UNARY(is_asserted);
-    MATCH_UNARY(is_lemma);
-
-    bool has_fact(proof const * p) const {
-        SASSERT(is_proof(p));
-        unsigned n = p->get_num_args();
-        return n > 0 && get_sort(p->get_arg(n - 1)) != m_proof_sort;
+    MATCH_UNARY(is_lemma);
+
+    bool has_fact(proof const * p) const {
+        SASSERT(is_proof(p));
+        unsigned n = p->get_num_args();
+        return n > 0 && get_sort(p->get_arg(n - 1)) != m_proof_sort;
     }
     expr * get_fact(proof const * p) const { SASSERT(is_proof(p)); SASSERT(has_fact(p)); return p->get_arg(p->get_num_args() - 1); }
-    unsigned get_num_parents(proof const * p) const {
-        SASSERT(is_proof(p));
+    unsigned get_num_parents(proof const * p) const {
+        SASSERT(is_proof(p));
         unsigned n = p->get_num_args();
-        return !has_fact(p) ? n : n - 1;
+        return !has_fact(p) ? n : n - 1;
     }
     proof * get_parent(proof const * p, unsigned idx) const { SASSERT(is_proof(p)); return to_app(p->get_arg(idx)); }
     proof * mk_true_proof();
@@ -2147,7 +2147,7 @@
     proof * mk_quant_inst(expr * not_q_or_i, unsigned num_bind, expr* const* binding);

     proof * mk_def_axiom(expr * ax);
-    proof * mk_unit_resolution(unsigned num_proofs, proof * const * proofs);
+    proof * mk_unit_resolution(unsigned num_proofs, proof * const * proofs);
     proof * mk_unit_resolution(unsigned num_proofs, proof * const * proofs, expr * new_fact);
     proof * mk_hypothesis(expr * h);
     proof * mk_lemma(proof * p, expr * lemma);
@@ -2166,7 +2166,7 @@
     proof * mk_and_elim(proof * p, unsigned i);
     proof * mk_not_or_elim(proof * p, unsigned i);

-    proof * mk_th_lemma(family_id tid,
+    proof * mk_th_lemma(family_id tid,
                         expr * fact, unsigned num_proofs, proof * const * proofs,
                         unsigned num_params = 0, parameter const* params = 0);

@@ -2180,7 +2180,7 @@
             worklist.push_back(n);
         }
     }
-
+
     template<typename T>
     void dec_array_ref(ptr_buffer<ast> & worklist, unsigned sz, T * const * a) {
         for(unsigned i = 0; i < sz; i++) {
@@ -2315,7 +2315,7 @@

     void mark(ast * n, bool flag) { if (flag) mark(n); else reset_mark(n); }

-    unsigned get_level() {
+    unsigned get_level() {
         return m_to_unmark.size();
     }

@@ -2334,7 +2334,7 @@
 typedef ast_fast_mark2   expr_fast_mark2;

 /**
-   Similar to ast_fast_mark, but increases reference counter.
+   Similar to ast_fast_mark, but increases reference counter.
 */
 template<unsigned IDX>
 class ast_ref_fast_mark {
@@ -2369,7 +2369,7 @@
         }
         m_to_unmark.push_back(n);
     }
-
+
     void reset() {
         ast * const * it  = m_to_unmark.c_ptr();
         ast * const * end = it + m_to_unmark.size();
@@ -2378,7 +2378,7 @@
         }
         m_to_unmark.reset();
     }
-
+
     void mark(ast * n, bool flag) { if (flag) mark(n); else reset_mark(n); }
 };

@@ -2396,7 +2396,7 @@
 /**
    \brief A mapping from AST to Boolean

-   \warning This map does not cleanup the entry associated with a node N,
+   \warning This map does not cleanup the entry associated with a node N,
    when N is deleted.
 */
 class ast_mark {
@@ -2422,7 +2422,7 @@
 */
 class scoped_mark : public ast_mark {
     ast_ref_vector  m_stack;
-    unsigned_vector m_lim;
+    unsigned_vector m_lim;
 public:
     scoped_mark(ast_manager& m): m_stack(m) {}
     virtual ~scoped_mark() {}
@@ -2459,4 +2459,4 @@

 #endif /* AST_H_ */

-
+


Implement box functions

Implement box functions

--- lua/lua_box.c
+++ lua/lua_box.c
@@ -51,14 +51,92 @@
 	return 1;
 }

+static int lua_box_center(lua_State* l)
+{
+	cpBB* b = luaG_checkbox(l, 1);
+	cpVect* v = luaG_pushvect(l);
+	*v = cpBBCenter(*b);
+	return 1;
+}
+
+static int lua_box_area(lua_State* l)
+{
+	cpBB* b = luaG_checkbox(l, 1);
+	lua_pushnumber(l, cpBBArea(*b));
+	return 1;
+}
+
+static int lua_box_mergedarea(lua_State* l)
+{
+	cpBB* a = luaG_checkbox(l, 1);
+	cpBB* b = luaG_checkbox(l, 2);
+	lua_pushnumber(l, cpBBMergedArea(*a,*b));
+	return 1;
+}
+
+static int lua_box_merge(lua_State* l)
+{
+	cpBB* a = luaG_checkbox(l, 1);
+	cpBB* b = luaG_checkbox(l, 2);
+	cpBB* ret = luaG_pushbox(l);
+	*ret = cpBBMerge(*a, *b);
+	return 1;
+}
+
+static int lua_box_expand(lua_State* l)
+{
+	cpBB* a = luaG_checkbox(l, 1);
+	cpVect* b = luaG_checkvect(l, 2);
+	cpBB* ret = luaG_pushbox(l);
+	*ret = cpBBExpand(*a, *b);
+	return 1;
+}
+
+static int lua_box_segment_query(lua_State* l)
+{
+	cpBB* b = luaG_checkbox(l, 1);
+	cpVect* f = luaG_checkvect(l, 2);
+	cpVect* t = luaG_checkvect(l, 3);
+
+	lua_pushnumber(l, cpBBSegmentQuery(*b, *f, *t));
+	return 1;
+}
+
+static int lua_box_intersectssegment(lua_State* l)
+{
+	cpBB* b = luaG_checkbox(l, 1);
+	cpVect* f = luaG_checkvect(l, 2);
+	cpVect* t = luaG_checkvect(l, 3);
+
+	lua_pushboolean(l, cpBBIntersectsSegment(*b, *f, *t));
+	return 1;
+}
+
+static int lua_box_new(lua_State* l)
+{
+	double a = luaL_checknumber(l, 1);
+	double b = luaL_checknumber(l, 2);
+	double c = luaL_checknumber(l, 3);
+	double d = luaL_checknumber(l, 4);
+	cpBB* n = luaG_pushbox(l);
+	*n = cpBBNew(a, b, c, d);
+	return 1;
+}
+
 static const luaL_reg methods[] = {
+	{"new", lua_box_new},
 	{"intersects", lua_box_intersects},
+	{"intersects_segment", lua_box_intersectssegment},
 	{"contains", lua_box_contains},
 	{"contains_vect", lua_box_containsvect},
+	{"expand", lua_box_expand},
+	{"merge", lua_box_merge},
+	{"center", lua_box_center},
+	{"area", lua_box_area},
+	{"area_merged", lua_box_mergedarea},
+	{"segment_query", lua_box_segment_query},
 	{NULL, NULL}
 };
-
-

 static const luaL_reg meta_methods[] = {
 	{NULL, NULL}


Delete render.c

Delete render.c

--- unit/render.c
+++ unit/render.c
@@ -1,5 +0,0 @@
-#include "../sol.h"
-
-int main() {
-
-}


[#300] Insert PGW-C/U F-TEID on S11 Create Session Response

--- src/sgw/sgw-s5c-handler.c
+++ src/sgw/sgw-s5c-handler.c
@@ -86,8 +86,6 @@
                 data;
     ogs_assert(pgw_s5c_teid);
     sess->pgw_s5c_teid = ntohl(pgw_s5c_teid->teid);
-    rsp->pgw_s5_s8__s2a_s2b_f_teid_for_pmip_based_interface_or_for_gtp_based_control_plane_interface.
-                presence = 0;

     /* Receive Data Plane(UL) : PGW-S5U */
     pgw_s5u_teid = rsp->bearer_contexts_created.s5_s8_u_sgw_f_teid.data;
@@ -119,9 +117,6 @@
     /* Setup GTP Node */
     OGS_SETUP_GTP_NODE(s5u_tunnel, pgw);

-    /* Remove S5C-F-TEID */
-    rsp->bearer_contexts_created.s5_s8_u_sgw_f_teid.presence = 0;
-
     /* Send Control Plane(UL) : SGW-S11 */
     memset(&sgw_s11_teid, 0, sizeof(ogs_gtp_f_teid_t));
     sgw_s11_teid.interface_type = OGS_GTP_F_TEID_S11_S4_SGW_GTP_C;


dump the contents of the returned packet.

--- bin/tests/lwres_test.c
+++ bin/tests/lwres_test.c
@@ -152,12 +152,27 @@
 {
 	lwres_gabnresponse_t *res;
 	int ret;
+	unsigned int i;

 	res = NULL;
-	ret = lwres_getaddrsbyname(ctx, "www.flame.org", LWRES_ADDRTYPE_V4,
+	ret = lwres_getaddrsbyname(ctx,
+				   "alias-04.test.flame.org.",
+				   LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6,
 				   &res);
 	printf("ret == %d\n", ret);
 	assert(ret == 0);
+	assert(res != NULL);
+
+	printf("Returned real name: (%u, %s)\n",
+	       res->realnamelen, res->realname);
+	printf("%u aliases:\n", res->naliases);
+	for (i = 0 ; i < res->naliases ; i++)
+		printf("\t(%u, %s)\n", res->aliaslen[i], res->aliases[i]);
+	printf("%u addresses:\n", res->naddrs);
+	for (i = 0 ; i < res->naddrs ; i++) {
+		printf("\tAddr len %u family %08x\n",
+		       res->addrs[i].length, res->addrs[i].family);
+	}

 	lwres_gabnresponse_free(ctx, &res);
 }


Fixed compilation on GNUstep by working around the fact KVO header isn't included in Foundation.h yet.

git-svn-id: 0833b781a6984bca00fd44c5b8a33a6c879c84c9@4216 7b3f36aa-e6db-49c1-8b4c-66eac1997e64

--- Headers/ETCompatibility.h
+++ Headers/ETCompatibility.h
@@ -36,6 +36,9 @@

 #ifndef GNUSTEP
 #import <EtoileUI/GNUstep.h>
+#else
+// NOTE: Temporary hack until GNUstep Base includes KVO header in Foundation.h
+#import <Foundation/NSKeyValueObserving.h>
 #endif

 // TODO: Should be improved to rely on a logging class.


Remove dependencies on TTreeFormula, TMatrixD and TDirectory.

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

--- tmva/inc/Factory.h
+++ tmva/inc/Factory.h
@@ -1,4 +1,4 @@
-// @(#)root/tmva $Id: Factory.h,v 1.27 2006/11/17 14:59:23 stelzer Exp $
+// @(#)root/tmva $Id: Factory.h,v 1.9 2006/11/20 15:35:28 brun Exp $
 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss

 /**********************************************************************************
@@ -48,15 +48,10 @@
 #include <vector>
 #include <map>
 #include "TCut.h"
-#include "TDirectory.h"
-#include "TTreeFormula.h"

 #ifndef ROOT_TMVA_Types
 #include "TMVA/Types.h"
 #endif
-#ifndef ROOT_TMatrixD
-#include "TMatrixD.h"
-#endif
 #ifndef ROOT_TMVA_DataSet
 #include "TMVA/DataSet.h"
 #endif
@@ -64,6 +59,8 @@
 #include "TMVA/MsgLogger.h"
 #endif

+class TTreeFormula;
+class TDirectory;
 class TFile;
 class TTree;
 class TNtuple;


Update EnvIBL.h

Update EnvIBL.h

--- SOCEngine/SOCEngine/ShaderCodes/EnvIBL.h
+++ SOCEngine/SOCEngine/ShaderCodes/EnvIBL.h
@@ -7,7 +7,7 @@
 #include "ShaderCommon.h"
 #include "BRDF.h"

-SamplerState ambientCubeMapSampler	: register( s4  );
+SamplerState	ambientCubeMapSampler	: register( s4  );
 TextureCube	ambientCubeMap		: register( t32 );

 cbuffer SkyMapInfoParam			: register( b7 )


#include <compat.h> for asprintf().

#include <compat.h> for asprintf().

git-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@731 d4fa192b-c00b-0410-8231-f00ffab90ce4

--- bin/varnishd/mgt_cli.c
+++ bin/varnishd/mgt_cli.c
@@ -4,14 +4,16 @@
  * The management process' CLI handling
  */

+#include <sys/types.h>
+
+#include <assert.h>
+#include <stdarg.h>
 #include <stdio.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-
+
+#include "compat.h"
 #include "cli_priv.h"
 #include "cli.h"
 #include "vsb.h"