MonetDB: Mar2018 - Use bool.

2018-05-24 Thread Sjoerd Mullender
Changeset: 7082e38195c2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7082e38195c2
Modified Files:
gdk/gdk_aggr.c
Branch: Mar2018
Log Message:

Use bool.


diffs (truncated from 457 to 300 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -147,7 +147,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e,
 /* -- */
 /* sum */
 
-static inline int
+static inline bool
 samesign(double x, double y)
 {
return (x >= 0) == (y >= 0);
@@ -182,13 +182,13 @@ static BUN
 dofsum(const void *restrict values, oid seqb, BUN start, BUN end,
void *restrict results, BUN ngrp, int tp1, int tp2,
const oid *restrict cand, const oid *candend, const oid *restrict gids,
-   oid min, oid max, int skip_nils, int abort_on_error,
-   int nil_if_empty, const char *func)
+   oid min, oid max, bool skip_nils, bool abort_on_error,
+   bool nil_if_empty, const char *func)
 {
struct pergroup {
int npartials;
int maxpartials;
-   int valseen;
+   bool valseen;
 #ifdef INFINITES_ALLOWED
float infs;
 #else
@@ -224,7 +224,7 @@ dofsum(const void *restrict values, oid 
return BUN_NONE;
for (grp = 0; grp < ngrp; grp++) {
pergroup[grp].npartials = 0;
-   pergroup[grp].valseen = 0;
+   pergroup[grp].valseen = false;
pergroup[grp].maxpartials = 2;
pergroup[grp].infs = 0;
pergroup[grp].partials = GDKmalloc(pergroup[grp].maxpartials * 
sizeof(double));
@@ -268,7 +268,7 @@ dofsum(const void *restrict values, oid 
}
continue;
}
-   pergroup[grp].valseen = 1;
+   pergroup[grp].valseen = true;
 #ifdef INFINITES_ALLOWED
if (isinf(x)) {
pergroup[grp].infs += x;
@@ -476,7 +476,7 @@ dofsum(const void *restrict values, oid 
   goto overflow);  \
}   \
} else {\
-   int seenval = 0;\
+   bool seenval = false;   \
for (i = start; i < end && nils == 0; i++) { \
x = vals[i];\
if (is_##TYPE1##_nil(x)) {  \
@@ -490,7 +490,7 @@ dofsum(const void *restrict values, oid 
   TYPE2, sum, \
   
GDK_##TYPE2##_max, \
   goto overflow); \
-   seenval = 1;\
+   seenval = true; \
}   \
}   \
*seen = seenval;\
@@ -500,7 +500,7 @@ dofsum(const void *restrict values, oid 
} else if (ngrp == 1) { \
/* single group, with candidate list */ \
TYPE2 sum;  \
-   int seenval = 0;\
+   bool seenval = false;   \
ALGODEBUG fprintf(stderr,   \
  "#%s: with candidates, no groups; " \
  "start " BUNFMT ", end " BUNFMT \
@@ -523,7 +523,7 @@ dofsum(const void *restrict values, oid 
   TYPE2, sum,  \
   GDK_##TYPE2##_max, \
   goto overflow);  \
-   seenval = 1;\
+   seenval = true; \
}   \
}   \
if (seenval)\
@@ -609,11 +609,11 @@ dofsum(const void *restrict values, oid 
} while (0)
 
 static BUN
-dosum(const void *restrict values, int nonil, oid seqb, BUN start, BUN end,
+dosum(const void *restrict values, bool nonil, oid seqb, BUN start, BUN end,
   void *restrict results, BUN ngrp, int tp1, int tp2,

MonetDB: Mar2018 - Use bool.

2018-05-14 Thread Sjoerd Mullender
Changeset: 41602c59ac49 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=41602c59ac49
Modified Files:
clients/mapiclient/msqldump.c
Branch: Mar2018
Log Message:

Use bool.


diffs (72 lines):

diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -57,14 +57,14 @@ main(int argc, char **argv)
char *host = NULL;
char *dbname = NULL;
int trace = 0;
-   int describe = 0;
-   int functions = 0;
-   int useinserts = 0;
+   bool describe = false;
+   bool functions = false;
+   bool useinserts = false;
int c;
Mapi mid;
-   int quiet = 0;
+   bool quiet = false;
stream *out;
-   char user_set_as_flag = 0;
+   bool user_set_as_flag = false;
char *table = NULL;
static struct option long_options[] = {
{"host", 1, 0, 'h'},
@@ -89,7 +89,7 @@ main(int argc, char **argv)
if (user)
free(user);
user = strdup(optarg);
-   user_set_as_flag = 1;
+   user_set_as_flag = true;
break;
case 'h':
host = optarg;
@@ -104,15 +104,15 @@ main(int argc, char **argv)
dbname = strdup(optarg);
break;
case 'D':
-   describe = 1;
+   describe = true;
break;
case 'N':
-   useinserts = 1;
+   useinserts = true;
break;
case 'f':
if (table)
usage(argv[0], -1);
-   functions = 1;
+   functions = true;
break;
case 't':
if (table || functions)
@@ -120,7 +120,7 @@ main(int argc, char **argv)
table = optarg;
break;
case 'q':
-   quiet = 1;
+   quiet = true;
break;
case 'X':
trace = MAPI_TRACE;
@@ -201,9 +201,9 @@ main(int argc, char **argv)
dump_version(mid, out, "--");
}
if (functions)
-   c = dump_functions(mid, out, 1, NULL, NULL, NULL);
+   c = dump_functions(mid, out, true, NULL, NULL, NULL);
else if (table)
-   c = dump_table(mid, NULL, table, out, describe, 1, useinserts);
+   c = dump_table(mid, NULL, table, out, describe, true, 
useinserts);
else
c = dump_database(mid, out, describe, useinserts);
mnstr_flush(out);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Mar2018 - Use bool.

2018-05-14 Thread Sjoerd Mullender
Changeset: 5f8f480df40b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5f8f480df40b
Modified Files:
clients/mapiclient/dump.c
Branch: Mar2018
Log Message:

Use bool.


diffs (133 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -121,15 +121,15 @@ get_schema(Mapi mid)
 }
 
 /* return TRUE if the HUGEINT type exists */
-static int
+static bool
 has_hugeint(Mapi mid)
 {
MapiHdl hdl;
-   int ret;
+   bool ret;
static int hashge = -1;
 
if (hashge >= 0)
-   return hashge;
+   return (bool) hashge;
 
if ((hdl = mapi_query(mid,
  "SELECT id "
@@ -145,7 +145,7 @@ has_hugeint(Mapi mid)
if (mapi_error(mid))
goto bailout;
mapi_close_handle(hdl);
-   hashge = ret;
+   hashge = (int) ret;
return ret;
 
   bailout:
@@ -383,8 +383,8 @@ static int dump_column_definition(
const char *schema,
const char *tname,
const char *tid,
-   int foreign,
-   int hashge);
+   bool foreign,
+   bool hashge);
 
 static const char *geomsubtypes[] = {
NULL,   /* 0 */
@@ -399,7 +399,7 @@ static const char *geomsubtypes[] = {
 };
 
 static int
-dump_type(Mapi mid, stream *toConsole, const char *c_type, const char 
*c_type_digits, const char *c_type_scale, int hashge)
+dump_type(Mapi mid, stream *toConsole, const char *c_type, const char 
*c_type_digits, const char *c_type_scale, bool hashge)
 {
int space = 0;
 
@@ -533,7 +533,7 @@ dump_type(Mapi mid, stream *toConsole, c
 }
 
 static int
-dump_column_definition(Mapi mid, stream *toConsole, const char *schema, const 
char *tname, const char *tid, int foreign, int hashge)
+dump_column_definition(Mapi mid, stream *toConsole, const char *schema, const 
char *tname, const char *tid, bool foreign, bool hashge)
 {
MapiHdl hdl = NULL;
char *query;
@@ -782,7 +782,7 @@ describe_table(Mapi mid, const char *sch
int type = 0;
size_t maxquerylen;
char *sname = NULL;
-   int hashge;
+   bool hashge;
 
if (schema == NULL) {
if ((sname = strchr(tname, '.')) != NULL) {
@@ -1343,14 +1343,14 @@ dump_function_comment(Mapi mid, stream *
int len = 5120;
char *query = malloc(len);
MapiHdl hdl = NULL;
-   int hashge;
+   bool hashge;
 
if (!query)
return 1;
 
snprintf(query, len,
"%s "
-   "SELECT coalesce(function_type_keyword, '') AS category, "
+   "SELECT coalesce(ft.function_type_keyword, '') AS category, "
   "s.name AS schema, "
   "CASE RANK() OVER (PARTITION BY f.id ORDER BY p.number 
ASC) WHEN 1 THEN f.name ELSE NULL END AS name, "
   "p.type, "
@@ -1425,7 +1425,7 @@ dump_function_comment(Mapi mid, stream *
 }
 
 static int
-dump_function(Mapi mid, stream *toConsole, const char *fid, int hashge)
+dump_function(Mapi mid, stream *toConsole, const char *fid, bool hashge)
 {
MapiHdl hdl;
size_t qlen = 5120 + strlen(fid);
@@ -1449,8 +1449,8 @@ dump_function(Mapi mid, stream *toConsol
 "f.type, "
 "s.name, "
 "f.name, "
-"function_type_keyword, "
-"language_keyword "
+"ft.function_type_keyword, "
+"fl.language_keyword "
  "FROM sys.functions f "
   "JOIN sys.schemas s ON f.schema_id = s.id "
   "JOIN function_types ft ON f.type = 
ft.function_type_id "
@@ -1562,14 +1562,14 @@ dump_functions(Mapi mid, stream *toConso
MapiHdl hdl;
char *query, *q, *end_q;
size_t len;
-   int hashge;
+   bool hashge;
char *to_free = NULL;
-   char wantSystem;
+   bool wantSystem;
long prev_sid;
 
if (fname != NULL) {
/* dump a single function */
-   wantSystem = 1;
+   wantSystem = true;
 
if (sname == NULL) {
/* no schema given, so figure it out */
@@ -1587,7 +1587,7 @@ dump_functions(Mapi mid, stream *toConso
sname = to_free;
}
} else {
-   wantSystem = 0;
+   wantSystem = false;
}
 
hashge = has_hugeint(mid);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Mar2018 - Use bool.

2018-04-19 Thread Sjoerd Mullender
Changeset: 8c6317c0e121 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8c6317c0e121
Modified Files:
gdk/gdk_project.c
Branch: Mar2018
Log Message:

Use bool.


diffs (truncated from 339 to 300 lines):

diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -18,7 +18,7 @@
 
 #define project_loop(TYPE) \
 static gdk_return  \
-project_##TYPE(BAT *bn, BAT *l, BAT *r, int nilcheck)  \
+project_##TYPE(BAT *bn, BAT *l, BAT *r, bool nilcheck) \
 {  \
oid lo, hi; \
const TYPE *restrict rt;\
@@ -39,11 +39,11 @@ project_##TYPE(BAT *bn, BAT *l, BAT *r, 
if (o[lo] < rseq || o[lo] >= rend) {\
if (is_oid_nil(o[lo])) {\
bt[lo] = TYPE##_nil;\
-   bn->tnonil = 0; \
-   bn->tnil = 1;   \
-   bn->tsorted = 0;\
-   bn->trevsorted = 0; \
-   bn->tkey = 0;   \
+   bn->tnonil = false; \
+   bn->tnil = true;\
+   bn->tsorted = false;\
+   bn->trevsorted = false; \
+   bn->tkey = false;   \
lo++;   \
break;  \
} else {\
@@ -54,8 +54,8 @@ project_##TYPE(BAT *bn, BAT *l, BAT *r, 
v = rt[o[lo] - rseq];   \
bt[lo] = v; \
if (is_##TYPE##_nil(v) && bn->tnonil) { \
-   bn->tnonil = 0; \
-   bn->tnil = 1;   \
+   bn->tnonil = false; \
+   bn->tnil = true;\
lo++;   \
break;  \
}   \
@@ -66,11 +66,11 @@ project_##TYPE(BAT *bn, BAT *l, BAT *r, 
if (o[lo] < rseq || o[lo] >= rend) {\
if (is_oid_nil(o[lo])) {\
bt[lo] = TYPE##_nil;\
-   bn->tnonil = 0; \
-   bn->tnil = 1;   \
-   bn->tsorted = 0;\
-   bn->trevsorted = 0; \
-   bn->tkey = 0;   \
+   bn->tnonil = false; \
+   bn->tnil = true;\
+   bn->tsorted = false;\
+   bn->trevsorted = false; \
+   bn->tkey = false;   \
} else {\
GDKerror("BATproject: does not match 
always\n"); \
return GDK_FAIL;\
@@ -110,20 +110,20 @@ project_void(BAT *bn, BAT *l, BAT *r)
bt = (oid *) Tloc(bn, 0);
bn->tsorted = l->tsorted;
bn->trevsorted = l->trevsorted;
-   bn->tkey = l->tkey & 1;
-   bn->tnonil = 1;
-   bn->tnil = 0;
+   bn->tkey = l->tkey;
+   bn->tnonil = true;
+   bn->tnil = false;
rseq = r->hseqbase;
rend = rseq + BATcount(r);
for (lo = 0, hi = lo + BATcount(l); lo < hi; lo++) {
if (o[lo] < rseq || o[lo] >= rend) {
if (is_oid_nil(o[lo])) {
bt[lo] = oid_nil;
-   bn->tnonil = 0;
-   bn->tnil = 1;
-   bn->tsorted = 0;
-   bn->trevsorted = 0;
-  

MonetDB: Mar2018 - Use bool for 1 bit wide bitfields.

2018-02-23 Thread Sjoerd Mullender
Changeset: fdcfff1daeaf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fdcfff1daeaf
Modified Files:
gdk/gdk.h
Branch: Mar2018
Log Message:

Use bool for 1 bit wide bitfields.


diffs (55 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -580,13 +580,13 @@ typedef struct {
char *base; /* base pointer in memory. */
char filename[32];  /* file containing image of the heap */
 
-   unsigned int copied:1,  /* a copy of an existing map. */
+   bool copied:1,  /* a copy of an existing map. */
hashash:1,  /* the string heap contains hash values */
forcemap:1, /* force STORE_MMAP even if heap exists */
-   cleanhash:1;/* string heaps must clean hash */
+   cleanhash:1,/* string heaps must clean hash */
+   dirty:1;/* specific heap dirty marker */
storage_t storage;  /* storage mode (mmap/malloc). */
storage_t newstorage;   /* new desired storage mode at re-allocation. */
-   bte dirty;  /* specific heap dirty marker */
bte farmid; /* id of farm where heap is located */
bat parentid;   /* cache id of VIEW parent bat */
 } Heap;
@@ -745,7 +745,7 @@ typedef struct {
MT_Id tid;  /* which thread created it */
unsigned int
 copiedtodisk:1,/* once written */
-dirty:2,   /* dirty wrt disk? */
+dirty:1,   /* dirty wrt disk? */
 dirtyflushed:1,/* was dirty before commit started? */
 descdirty:1,   /* bat descriptor dirty marker */
 restricted:2,  /* access privileges */
@@ -769,16 +769,15 @@ typedef struct {
 
unsigned short width;   /* byte-width of the atom array */
bte type;   /* type id. */
-   bte shift;  /* log2 of bunwidth */
-   unsigned int
-varsized:1,/* varsized (1) or fixedsized (0) */
-key:1, /* no duplicate values present */
-unique:1,  /* no duplicate values allowed */
-dense:1,   /* OID only: only consecutive values */
-nonil:1,   /* there are no nils in the column */
-nil:1, /* there is a nil in the column */
-sorted:1,  /* column is sorted in ascending order */
-revsorted:1;   /* column is sorted in descending order */
+   bte shift;  /* log2 of bun width */
+   bool varsized:1,/* varsized (1) or fixedsized (0) */
+   key:1,  /* no duplicate values present */
+   unique:1,   /* no duplicate values allowed */
+   dense:1,/* OID only: only consecutive values */
+   nonil:1,/* there are no nils in the column */
+   nil:1,  /* there is a nil in the column */
+   sorted:1,   /* column is sorted in ascending order */
+   revsorted:1;/* column is sorted in descending order */
BUN nokey[2];   /* positions that prove key==FALSE */
BUN nosorted;   /* position that proves sorted==FALSE */
BUN norevsorted;/* position that proves revsorted==FALSE */
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Mar2018 - Use bool.

2018-02-23 Thread Sjoerd Mullender
Changeset: f952edb15c7a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f952edb15c7a
Modified Files:
clients/mapiclient/mclient.c
Branch: Mar2018
Log Message:

Use bool.


diffs (truncated from 335 to 300 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -71,11 +71,11 @@ static stream *fromConsole = NULL;
 static char *language = NULL;
 static char *logfile = NULL;
 static char promptbuf[16];
-static int echoquery = 0;
+static bool echoquery = false;
 #ifdef HAVE_ICONV
 static char *encoding;
 #endif
-static int errseen = 0;
+static bool errseen = false;
 
 #define setPrompt() sprintf(promptbuf, "%.*s>", (int) sizeof(promptbuf) - 2, 
language)
 #define debugMode() (strncmp(promptbuf, "mdb", 3) == 0)
@@ -94,7 +94,7 @@ enum formatters {
 };
 static enum formatters formatter = NOformatter;
 char *separator = NULL;/* column separator for CSV/TAB format 
*/
-int csvheader = 0; /* include header line in CSV format */
+bool csvheader = false;/* include header line in CSV format */
 
 #define DEFWIDTH 80
 
@@ -123,9 +123,9 @@ static char *pager = 0; /* use external
 #endif
 static int rowsperpage = 0;/* for SQL pagination */
 static int pagewidth = 0;  /* -1: take whatever is necessary, >0: limit */
-static int pagewidthset = 0;   /* whether the user set the width explicitly */
+static bool pagewidthset = false; /* whether the user set the width explicitly 
*/
 static int croppedfields = 0;  /* whatever got cropped/truncated */
-static char firstcrop = 1; /* first time we see cropping/truncation */
+static bool firstcrop = true;  /* first time we see cropping/truncation */
 
 enum modifiers {
NOmodifier,
@@ -259,13 +259,13 @@ static enum itimers {
T_PERF  // return detailed performance
 } timermode = T_NONE;
 
-static int timerHumanCalled = 0;
+static bool timerHumanCalled = false;
 static void
 timerHuman(int64_t sqloptimizer, int64_t maloptimizer, int64_t querytime, int 
singleinstr, int total)
 {
timertype t = th - t0;
 
-   timerHumanCalled = 1;
+   timerHumanCalled = true;
 
/*
 * report only the times we do actually measure:
@@ -571,7 +571,8 @@ utf8skip(char *s, size_t i)
 static int
 SQLrow(int *len, int *numeric, char **rest, int fields, int trim, char wm)
 {
-   int i, more, first = 1;
+   int i;
+   bool more, first = true;
char *t;
int rows = 0;   /* return number of output lines printed */
size_t ulen;
@@ -598,7 +599,7 @@ SQLrow(int *len, int *numeric, char **re
cutafter[i] = -1;
 
do {
-   more = 0;
+   more = false;
for (i = 0; i < fields; i++) {
if (rest[i] == NULL || *rest[i] == 0) {
mnstr_printf(toConsole, "%c %*s ",
@@ -697,7 +698,7 @@ SQLrow(int *len, int *numeric, char **re
if (cutafter[i] == 0)
rest[i] = NULL;
if (rest[i])
-   more = 1;
+   more = true;
} else {
mnstr_printf(toConsole, "%c",
 first ? '|' : i > 0 && 
cutafter[i - 1] == 0 ? '>' : ':');
@@ -736,7 +737,7 @@ SQLrow(int *len, int *numeric, char **re
mnstr_printf(toConsole, "%c%s\n",
 first ? '|' : i > 0 && cutafter[i - 1] == 0 ? '>' 
: ':',
 wm ? ">" : "");
-   first = 0;
+   first = false;
rows++;
} while (more);
 
@@ -1667,8 +1668,8 @@ SQLrenderer(MapiHdl hdl)
   croppedfields, croppedfields != 1 ? "s" : "");
if (fields != printfields || croppedfields > 0) {
mnstr_printf(toConsole, "!");
-   if (firstcrop == 1) {
-   firstcrop = 0;
+   if (firstcrop) {
+   firstcrop = false;
mnstr_printf(toConsole, "\nnote: to disable dropping 
columns and/or truncating fields use \\w-1");
}
}
@@ -1686,7 +1687,7 @@ setFormatter(const char *s)
if (separator)
free(separator);
separator = NULL;
-   csvheader = 0;
+   csvheader = false;
 #ifdef _TWO_DIGIT_EXPONENT
if (formatter == TESTformatter)
_set_output_format(0);
@@ -1712,7 +1713,7 @@ setFormatter(const char *s)
separator[strlen(separator) - 1] = 0;
} else
separator = strdup(s + 4);
-   csvheader = 1;
+   csvheader =