Changeset: 3e835de43b22 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3e835de43b22 Modified Files: monetdb5/mal/mal_scenario.c monetdb5/mal/mal_session.c monetdb5/modules/mal/mal_io.c Branch: malparsing Log Message:
tests seem to run (for a large part) blocked IO is without prompt! (end block replaced that a long time ago) non blocked IO also needs a (f)flush on end of output (even if there is no prompt) diffs (169 lines): diff --git a/monetdb5/mal/mal_scenario.c b/monetdb5/mal/mal_scenario.c --- a/monetdb5/mal/mal_scenario.c +++ b/monetdb5/mal/mal_scenario.c @@ -195,7 +195,7 @@ initScenario(Client c, Scenario s) } if (s->initClient && s->initClientCmd == 0){ s->initClientCmd = (MALfcn) getAddress( s->initClient); - if( s->initSystemCmd == NULL){ + if( s->initClientCmd == NULL){ msg = createException(MAL,"initScenario","Address of initClient command not resolved"); goto wrapup; } 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 @@ -599,28 +599,19 @@ MALreader(Client c) blocked = isa_block_stream(c->fdin->s); if(c->fdin->pos >= c->fdin->len ){ /* we need more input from console */ - if(!blocked ){ - if( c->prompt && c->prompt[0]){ + if (!blocked){ + if (c->prompt && c->prompt[0]) mnstr_write(c->fdout, c->prompt, strlen(c->prompt), 1); - mnstr_flush(c->fdout); - c->fdin->eof = 0; - } + mnstr_flush(c->fdout); + c->fdin->eof = 0; } else { /* we need more input from blocked stream */ - if(c->fdin->eof && c->prompt && c->prompt[0]){ - mnstr_write(c->fdout, c->prompt, strlen(c->prompt), 1); + if(c->fdin->eof) mnstr_flush(c->fdout); - } c->fdin->pos =c->fdin->len = 0; c->fdin->eof = 0; } nr = bstream_next(c->fdin); -/* - if (!nr && blocked ){ - c->fdin->eof = 0; - nr = bstream_next(c->fdin); // check for eof - } -*/ if(nr < 0 || (!blocked && c->fdin->eof)){ alternative: if (c->bak){ @@ -629,9 +620,9 @@ MALreader(Client c) #endif MCpopClientInput(c); nr = -1; // force reading next part - } else{ + } else { // if we have unprocessed data we should return and await its consumption - if(c->line && *c->line){ + if(c->line && *c->line && c->linefill){ return MAL_SUCCEED; } MT_lock_set(&mal_contextLock); @@ -640,16 +631,16 @@ MALreader(Client c) return MAL_SUCCEED; } } - if( !nr) + if (!nr) continue; // Handle very long lines - if ( c->fdin->len >= c->linesize){ - l = GDKrealloc(c->line, c->linesize + c->fdin->len + 512); + if ((c->fdin->len - c->fdin->pos + c->linefill) >= c->linesize){ + l = GDKrealloc(c->line, c->linesize + c->fdin->len - c->fdin->pos + c->linefill + 512); if( l == NULL) throw(MAL,"mal.readline", MAL_MALLOC_FAIL); c->line = l; - c->linesize += c->fdin->len + 512; + c->linesize += c->fdin->len - c->fdin->pos + c->linefill + 512; } } // read until you find a complete MAL unit @@ -689,40 +680,31 @@ MALreader(Client c) nr = bstream_next(c->fdin); // check for eof if (c->fdin->eof) goto alternative; - if( nr) + if (nr) goto continuecomment; } } else { // skip string literals - if ( *l == '"' ){ - if ( string == 0) + if (*l == '"'){ + if (string == 0) string = 1; - else - if ( string && *(l-1) != '\\') + else if (string && *(l-1) != '\\') string = !string; } // collect the characters to be parsed *s++ = *l; c->linefill++; c->fdin->pos++; - if ( c->listing) + if (c->listing) mnstr_printf(c->fdout,"%c", *l); - if( string) + if (string) continue; - if ( *l == ';' ){ + if (*l == ';'){ /* found end of MAL instruction */ /* eat away any visible remaining blank space as well */ *s = 0; - for(l++; *l && c->fdin->pos < c->fdin->len ; l++) - { - switch(*l){ - case ' ': case '\t': case '\n': - c->fdin->pos++; - continue; - default: - return MAL_SUCCEED; - } - } + for(l++; *l && (*l == ' ' || *l == '\t' || *l == '\n') && c->fdin->pos < c->fdin->len; l++) + ; return MAL_SUCCEED; } } @@ -878,7 +860,7 @@ MALengine(Client c) c->glb->stkbot = prg->def->vtop; } - if( prg->def->errors) + if (prg->def->errors) GDKfree(prg->def->errors); prg->def->errors = NULL; if (c->itrace) diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c --- a/monetdb5/modules/mal/mal_io.c +++ b/monetdb5/modules/mal/mal_io.c @@ -475,7 +475,7 @@ IOprintf(Client cntxt, MalBlkPtr mb, Mal (void) mb; switch( pci->argc){ case 2: msg= IOprintf_(&fmt2,*fmt); - break; + break; case 3: msg= IOprintf_(&fmt2,*fmt,G(2)); break; case 4: msg= IOprintf_(&fmt2,*fmt,G(2),G(3)); @@ -492,12 +492,13 @@ IOprintf(Client cntxt, MalBlkPtr mb, Mal break; case 10: msg= IOprintf_(&fmt2,*fmt,G(2),G(3),G(4),G(5),G(6),G(7),G(8),G(9)); } - if (msg== MAL_SUCCEED) { - mnstr_printf(cntxt->fdout,"%s",fmt2); + if (msg == MAL_SUCCEED) { + mnstr_printf(cntxt->fdout, "%s", fmt2); GDKfree(fmt2); } return msg; } + str IOprintfStream(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){ str *fmt = getArgReference_str(stk,pci,2); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list