<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/205b9723aa3a127b926bef7e959e2e204be11aa7">https://github.com/macports/macports-base/commit/205b9723aa3a127b926bef7e959e2e204be11aa7</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 205b9723aa3a127b926bef7e959e2e204be11aa7
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Tue Jul 11 05:15:45 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> Store variants with sign in registrydb as part of snapshot
</span>---
src/cregistry/entry.c | 41 +++++++++++++++++++++++++++++------------
src/cregistry/entry.h | 2 +-
2 files changed, 30 insertions(+), 13 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/entry.c b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 9690ae9..6fa879a 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1421,6 +1421,7 @@ int snapshot_store_ports(reg_registry* reg, reg_entry* snap_entry, reg_error* er
</span> break;
case 0:
reg_sqlite_error(reg->db, errPtr, query);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ result = 0;
</span> break;
}
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1442,6 +1443,7 @@ int snapshot_store_ports(reg_registry* reg, reg_entry* snap_entry, reg_error* er
</span> sqlite3_finalize(stmt);
}
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ free(entry);
</span> }
}
return result;
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1451,7 +1453,7 @@ int snapshot_store_port_variants(reg_registry* reg, reg_entry* port_entry,
</span> int snapshot_ports_id, reg_error* errPtr) {
reg_error error;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- int i, result = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int i, result = 1;
</span>
char* key1 = "variants";
char* key2 = "negated_variants";
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1466,17 +1468,27 @@ int snapshot_store_port_variants(reg_registry* reg, reg_entry* port_entry,
</span>
//return 1;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- variant* all_variants;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- all_variants = (variant*) malloc(sizeof(variant));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int variant_space = 10;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ variant* all_variants = (variant*) malloc(variant_space * sizeof(variant));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (all_variants == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span>
char* pos_delim = "+";
char* neg_delim = "-";
int variant_count = 0;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- get_parsed_variants(positive_variants_str, all_variants, pos_delim, &variant_count);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- get_parsed_variants(negative_variants_str, all_variants, neg_delim, &variant_count);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int p = get_parsed_variants(positive_variants_str, all_variants, pos_delim, &variant_count);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (p < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int n = get_parsed_variants(negative_variants_str, all_variants, neg_delim, &variant_count);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (n < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span>
printf("total var count: %d, ", variant_count);
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1485,7 +1497,7 @@ int snapshot_store_port_variants(reg_registry* reg, reg_entry* port_entry,
</span> char* query = "INSERT INTO registry.snapshot_port_variants "
"(snapshot_ports_id, variant_name, variant_sign) "
"VALUES (?, ?, ?)";
<span style='display:block; white-space:pre;background:#ffe0e0;'>- variant v = all_variants[i];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ variant v = *(all_variants + i);
</span> if((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
&& (sqlite3_bind_int64(stmt, 1, snapshot_ports_id) == SQLITE_OK)
&& (sqlite3_bind_text(stmt, 2, v.variant_name, -1, SQLITE_STATIC) == SQLITE_OK)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1497,7 +1509,6 @@ int snapshot_store_port_variants(reg_registry* reg, reg_entry* port_entry,
</span> case SQLITE_DONE:
printf("\nvariant stored: %s with sign: %s",
v.variant_name, v.variant_sign);
<span style='display:block; white-space:pre;background:#ffe0e0;'>- result = 1;
</span> break;
case SQLITE_BUSY:
break;
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1517,7 +1528,7 @@ int snapshot_store_port_variants(reg_registry* reg, reg_entry* port_entry,
</span> return result;
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-void get_parsed_variants(char* variants_str, variant* all_variants, char* delim, int* variant_count) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int get_parsed_variants(char* variants_str, variant* all_variants, char* delim, int* variant_count) {
</span>
printf("var count yet %d, ", *variant_count);
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1531,12 +1542,18 @@ void get_parsed_variants(char* variants_str, variant* all_variants, char* delim,
</span> variant v;
v.variant_name = token;
v.variant_sign = delim;
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- all_variants[*variant_count] = v;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *(all_variants + *variant_count) = v;
</span> *variant_count = *variant_count + 1;
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // all_variants = (variant*) realloc(all_variants, sizeof(variant));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // if(!all_variants) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ // }
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span> }
/**
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/entry.h b/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;color:#808080;'>index ca8a5e3..4fdee3e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -106,7 +106,7 @@ int snapshot_store_ports(reg_registry* reg, reg_entry* entry,
</span> int snapshot_store_port_variants(reg_registry* reg, reg_entry* port_entry,
int snapshot_ports_id, reg_error* errPtr);
<span style='display:block; white-space:pre;background:#ffe0e0;'>-void get_parsed_variants(char* variants_str, variant* all_variants,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int get_parsed_variants(char* variants_str, variant* all_variants,
</span> char* delim, int* variant_count);
int reg_all_open_entries(reg_registry* reg, reg_entry*** entries);
</pre><pre style='margin:0'>
</pre>