Changeset: 698c3e10fed0 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=698c3e10fed0 Modified Files: common/stream/stream.c monetdb5/mal/mal_client.c monetdb5/mal/mal_readline.c monetdb5/mal/mal_session.c monetdb5/modules/mal/mal_mapi.c monetdb5/modules/mal/remote.c monetdb5/modules/mal/tablet.c sql/backends/monet5/sql_scenario.c sql/server/sql_scan.c Branch: default Log Message:
Use bool. diffs (truncated from 309 to 300 lines): diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -3216,7 +3216,7 @@ struct icstream { stream *s; char buffer[BUFSIZ]; size_t buflen; - int eof; + bool eof; }; static ssize_t @@ -3330,7 +3330,7 @@ ic_read(stream *restrict s, void *restri break; case 0: /* end of file */ - ic->eof = 1; + ic->eof = true; if (ic->buflen > 0) { /* incomplete input */ s->errnr = MNSTR_READ_ERROR; @@ -3382,7 +3382,7 @@ ic_read(stream *restrict s, void *restri * next call (i.e. keep ic->eof set), otherwise we * must clear it so that the next call will cause the * underlying stream to be read again */ - ic->eof = 0; + ic->eof = false; } return (ssize_t) ((elmsize * cnt - outbytesleft) / elmsize); } @@ -3493,7 +3493,7 @@ ic_open(iconv_t cd, stream *restrict ss, ic->cd = cd; ic->s = ss; ic->buflen = 0; - ic->eof = 0; + ic->eof = false; return s; } diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c --- a/monetdb5/mal/mal_client.c +++ b/monetdb5/mal/mal_client.c @@ -566,7 +566,7 @@ MCreadClient(Client c) if (!isa_block_stream(c->fdout) && c->promptlength > 0) mnstr_write(c->fdout, c->prompt, c->promptlength, 1); mnstr_flush(c->fdout); - in->eof = 0; + in->eof = false; } while ((rd = bstream_next(in)) > 0 && !in->eof) { sum += rd; diff --git a/monetdb5/mal/mal_readline.c b/monetdb5/mal/mal_readline.c --- a/monetdb5/mal/mal_readline.c +++ b/monetdb5/mal/mal_readline.c @@ -132,7 +132,7 @@ readConsole(Client cntxt) return 1; } bailout: - cntxt->fdin->eof = 1; + cntxt->fdin->eof = true; return -1; } #endif diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c --- a/monetdb5/mal/mal_session.c +++ b/monetdb5/mal/mal_session.c @@ -598,7 +598,7 @@ MALreader(Client c) int r = 1; if (c == mal_clients) { r = readConsole(c); - if (r < 0 && c->fdin->eof == 0) + if (r < 0 && !c->fdin->eof) r = MCreadClient(c); if (r > 0) return MAL_SUCCEED; diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c --- a/monetdb5/modules/mal/mal_mapi.c +++ b/monetdb5/modules/mal/mal_mapi.c @@ -266,7 +266,7 @@ doChallenge(void *data) GDKsyserror("SERVERlisten:"MAL_MALLOC_FAIL); return; } - bs->eof = 1; + bs->eof = true; MSscheduleClient(buf, challenge, bs, fdout, protocol, buflen); } diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c --- a/monetdb5/modules/mal/remote.c +++ b/monetdb5/modules/mal/remote.c @@ -1091,7 +1091,7 @@ str RMTbatload(Client cntxt, MalBlkPtr m throw(MAL, "remote.load", SQLSTATE(HY001) MAL_MALLOC_FAIL); /* grab the input stream and start reading */ - fdin->eof = 0; + fdin->eof = false; len = fdin->pos; while (len < fdin->len || bstream_next(fdin) > 0) { /* newline hunting (how spartan) */ @@ -1388,7 +1388,7 @@ str RMTbincopyfrom(Client cntxt, MalBlkP * rest is binary data directly on the stream. We get the first * line from the buffered stream we have here, and pass it on * together with the raw stream we have. */ - cntxt->fdin->eof = 0; /* in case it was before */ + cntxt->fdin->eof = false; /* in case it was before */ if (bstream_next(cntxt->fdin) <= 0) throw(MAL, "remote.bincopyfrom", "expected JSON header"); diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c --- a/monetdb5/modules/mal/tablet.c +++ b/monetdb5/modules/mal/tablet.c @@ -388,7 +388,8 @@ output_line_lookup(char **buf, size_t *l return 0; } -static int +/* returns TRUE if there is/might be more */ +static bool tablet_read_more(bstream *in, stream *out, size_t n) { if (out) { @@ -396,20 +397,20 @@ tablet_read_more(bstream *in, stream *ou /* query is not finished ask for more */ /* we need more query text */ if (bstream_next(in) < 0) - return EOF; + return false; if (in->eof) { if (mnstr_write(out, PROMPT2, sizeof(PROMPT2) - 1, 1) == 1) mnstr_flush(out); - in->eof = 0; + in->eof = false; /* we need more query text */ if (bstream_next(in) <= 0) - return EOF; + return false; } } while (in->len <= in->pos); } else if (bstream_read(in, n) <= 0) { - return EOF; + return false; } - return 1; + return true; } /* @@ -625,7 +626,7 @@ typedef struct { lng skip; /* number of lines to be skipped */ lng *time, wtime; /* time per col + time per thread */ int rounds; /* how often did we divide the work */ - int ateof; /* io control */ + bool ateof; /* io control */ bstream *b; stream *out; MT_Id tid; @@ -1234,8 +1235,8 @@ SQLproducer(void *p) READERtask *task = (READERtask *) p; int consoleinput = 0; int cur = 0; // buffer being filled - int blocked[MAXBUFFERS] = { 0 }; - int ateof[MAXBUFFERS] = { 0 }; + bool blocked[MAXBUFFERS] = { 0 }; + bool ateof[MAXBUFFERS] = { 0 }; BUN cnt = 0, bufcnt[MAXBUFFERS] = { 0 }; char *end, *e, *s, *base; const char *rsep = task->rsep; @@ -1269,7 +1270,7 @@ SQLproducer(void *p) goto parseSTDIN; } for (;;) { - ateof[cur] = tablet_read_more(task->b, task->out, task->b->size) == EOF; + ateof[cur] = !tablet_read_more(task->b, task->out, task->b->size); #ifdef _DEBUG_TABLET_CNTRL if (ateof[cur] == 0) mnstr_printf(GDKout, "#read %zu bytes pos = %zu eof=%d offset=" LLFMT " \n", @@ -1292,14 +1293,14 @@ SQLproducer(void *p) #ifdef _DEBUG_TABLET_CNTRL mnstr_printf(GDKout, "#bailout on SQLload %s\n", msg); #endif - ateof[cur] = 1; + ateof[cur] = true; break; } } parseSTDIN: #ifdef _DEBUG_TABLET_ - if (ateof[cur] == 0) + if (!ateof[cur]) mnstr_printf(GDKout, "#parse input:%.63s\n", task->b->buf + task->b->pos); #endif @@ -1314,7 +1315,7 @@ SQLproducer(void *p) between the threads, which we can not now update. Mimick an ateof instead; */ tablet_error(task, lng_nil, int_nil, "record too long", ""); - ateof[cur] = 1; + ateof[cur] = true; #ifdef _DEBUG_TABLET_CNTRL mnstr_printf(GDKout, "#bailout on SQLload confronted with too large record\n"); #endif @@ -1457,7 +1458,7 @@ SQLproducer(void *p) if (s+partial < end) { /* found a EOS in the input */ tablet_error(task, lng_nil, int_nil, "record too long (EOS found)", ""); - ateof[cur] = 1; + ateof[cur] = true; goto reportlackofinput; } break; @@ -1490,7 +1491,7 @@ SQLproducer(void *p) (cur + 1) % MAXBUFFERS); #endif MT_sema_down(&task->producer); - blocked[(cur + 1) % MAXBUFFERS] = 0; + blocked[(cur + 1) % MAXBUFFERS] = false; if (task->state == ENDOFCOPY) { THRdel(thr); return; @@ -1498,7 +1499,7 @@ SQLproducer(void *p) } /* other buffer is done, proceed with current buffer */ assert(!blocked[(cur + 1) % MAXBUFFERS]); - blocked[cur] = 1; + blocked[cur] = true; task->cur = cur; task->ateof = ateof[cur]; task->cnt = bufcnt[cur]; @@ -1535,7 +1536,7 @@ SQLproducer(void *p) /* consumers ask us to stop? */ if (task->state == ENDOFCOPY) { #ifdef _DEBUG_TABLET_CNTRL - if (ateof[cur] == 0) + if (!ateof[cur]) mnstr_printf(GDKout, "#SQL producer early exit %.63s\n", task->b->buf + task->b->pos); #endif @@ -1544,7 +1545,7 @@ SQLproducer(void *p) } bufcnt[cur] = cnt; #ifdef _DEBUG_TABLET_CNTRL - if (ateof[cur] == 0) + if (!ateof[cur]) mnstr_printf(GDKout, "#shuffle %zu: %.63s\n", strlen(s), s); #endif /* move the non-parsed correct row data to the head of the next buffer */ @@ -1674,7 +1675,7 @@ SQLload_file(Client cntxt, Tablet *as, b MT_sema_init(&task.producer, 0, "task.producer"); MT_sema_init(&task.consumer, 0, "task.consumer"); - task.ateof = 0; + task.ateof = false; task.b = b; task.out = out; @@ -1958,7 +1959,7 @@ SQLload_file(Client cntxt, Tablet *as, b ptask[j].wtime); } - task.ateof = 1; + task.ateof = true; task.state = ENDOFCOPY; #ifdef _DEBUG_TABLET_ for (i = 0; i < as->nr_attrs; i++) { diff --git a/sql/backends/monet5/sql_scenario.c b/sql/backends/monet5/sql_scenario.c --- a/sql/backends/monet5/sql_scenario.c +++ b/sql/backends/monet5/sql_scenario.c @@ -918,7 +918,7 @@ SQLreader(Client c) go = false; break; } - in->eof = 0; + in->eof = false; } if (in->buf == NULL) { more = false; @@ -927,7 +927,7 @@ SQLreader(Client c) #ifdef _SQL_READER_DEBUG fprintf(stderr, "#rd %d language %d eof %d\n", rd, language, in->eof); #endif - if (be->language == 'D' && in->eof == 0) + if (be->language == 'D' && !in->eof) return msg; if (rd == 0 && language !=0 && in->eof && !be->console) { diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c --- a/sql/server/sql_scan.c +++ b/sql/server/sql_scan.c @@ -592,7 +592,7 @@ static inline int scanner_read_more(struct scanner *lc, int n) { bstream *b = lc->rs; - int more = 0; + bool more = false; while (b->len < b->pos + lc->yycur + n) { @@ -604,8 +604,8 @@ scanner_read_more(struct scanner *lc, in if (b->eof || !isa_block_stream(b->s)) { _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list