Changeset: dbfd5385d6e0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dbfd5385d6e0
Removed Files:
monetdb5/mal/mal_readline.c
monetdb5/mal/mal_readline.h
Modified Files:
clients/Tests/exports.stable.out
monetdb5/mal/Makefile.ag
monetdb5/mal/mal_client.c
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_session.c
Branch: default
Log Message:
more Console related code cleanup
- don't use the client[0] output streams when debuging
- removed mal_readline code as this was console based
diffs (300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2217,7 +2217,6 @@ int getBitConstant(MalBlkPtr mb, bit val
int getBlockBegin(MalBlkPtr mb, int pc);
int getBlockExit(MalBlkPtr mb, int pc);
int getBteConstant(MalBlkPtr mb, bte val);
-char *getConsoleInput(Client c, const char *prompt, int linemode, int
exit_on_error);
int getDblConstant(MalBlkPtr mb, dbl val);
lng getDiskReads(void);
lng getDiskSpace(void);
@@ -2552,7 +2551,6 @@ str raiseRef;
str rangejoinRef;
str rankRef;
str rapiRef;
-int readConsole(Client cntxt);
MalStkPtr reallocGlobalStack(MalStkPtr s, int cnt);
str reconnectRef;
str reenterMAL(Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr
stk);
diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -38,7 +38,6 @@ lib_mal = {
mal_namespace.c mal_namespace.h \
mal_parser.c mal_parser.h \
mal_profiler.c mal_profiler.h \
- mal_readline.c mal_readline.h \
mal_resolve.c mal_resolve.h \
mal_sabaoth.c mal_sabaoth.h \
mal_scenario.c mal_scenario.h \
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
@@ -40,7 +40,6 @@
/* (author) M.L. Kersten */
#include "monetdb_config.h"
#include "mal_client.h"
-#include "mal_readline.h"
#include "mal_import.h"
#include "mal_parser.h"
#include "mal_namespace.h"
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -12,7 +12,6 @@
*/
#include "monetdb_config.h"
#include "mal.h"
-#include "mal_readline.h"
#include "mal_debugger.h"
#include "mal_interpreter.h" /* for getArgReference() */
#include "mal_linker.h" /* for getAddress() */
@@ -437,13 +436,6 @@ retryRead:
goto retryRead;
}
}
-#ifndef HAVE_EMBEDDED
- else if (cntxt == mal_clients) {
- /* switch to mdb streams */
- if (readConsole(cntxt) <= 0)
- break;
- }
-#endif
b = CURRENT(cntxt);
/* terminate the line with zero */
@@ -999,13 +991,13 @@ str mdbTrap(Client cntxt, MalBlkPtr mb,
int cnt = 20; /* total 10 sec delay */
int pc = getPC(mb,p);
- mnstr_printf(mal_clients[0].fdout, "#trapped %s.%s[%d]\n",
+ mnstr_printf(cntxt->fdout, "#trapped %s.%s[%d]\n",
getModuleId(mb->stmt[0]), getFunctionId(mb->stmt[0]),
pc);
- printInstruction(mal_clients[0].fdout, mb, stk, p, LIST_MAL_DEBUG);
+ printInstruction(cntxt->fdout, mb, stk, p, LIST_MAL_DEBUG);
cntxt->itrace = 'W';
MT_lock_set(&mal_contextLock);
if (trapped_mb) {
- mnstr_printf(mal_clients[0].fdout, "#registry not available\n");
+ mnstr_printf(cntxt->fdout, "#registry not available\n");
mnstr_flush(cntxt->fdout);
}
while (trapped_mb && cnt-- > 0) {
@@ -1040,12 +1032,12 @@ mdbStep(Client cntxt, MalBlkPtr mb, MalS
state.p = getInstrPtr(mb, pc);
state.pc = pc;
cntxt->mdb = &state;
- mnstr_printf(mal_clients[0].fdout, "#Process %d put to
sleep\n", (int) (cntxt - mal_clients));
+ mnstr_printf(cntxt->fdout, "#Process %d put to sleep\n", (int)
(cntxt - mal_clients));
cntxt->itrace = 'W';
mdbTrap(cntxt, mb, stk, state.p);
while (cntxt->itrace == 'W')
MT_sleep_ms(300);
- mnstr_printf(mal_clients[0].fdout, "#Process %d woke up\n",
(int) (cntxt - mal_clients));
+ mnstr_printf(cntxt->fdout, "#Process %d woke up\n", (int)
(cntxt - mal_clients));
return;
}
if (stk->cmd == 0)
diff --git a/monetdb5/mal/mal_readline.c b/monetdb5/mal/mal_readline.c
deleted file mode 100644
--- a/monetdb5/mal/mal_readline.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
- */
-
-#include "monetdb_config.h"
-#ifndef HAVE_EMBEDDED
-#include "mal.h"
-#include "mal_client.h"
-#include "mal_scenario.h"
-#include "mal_readline.h"
-#include "mal_debugger.h"
-
-#ifndef S_ISCHR
-#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
-#endif
-
-#ifdef HAVE_TERMIOS_H
-#include <termios.h>
-#endif
-
-static void
-showCommands(void)
-{
- printf("?\t - show this message\n");
- printf("\\q\t- terminate session\n");
-}
-
-char *
-getConsoleInput(Client c, const char *prompt, int linemode, int exit_on_error)
-{
- char *line = NULL;
- char *buf = NULL;
- size_t length;
- (void) exit_on_error;
- (void) linemode;
- (void) c;
-
- do {
- if (prompt) {
- fputs(prompt, stdout);
- fflush(stdout);
- }
- if (buf == NULL) {
- buf= malloc(BUFSIZ);
- if( buf == NULL){
- GDKerror("getConsoleInput: " MAL_MALLOC_FAIL);
- return NULL;
- }
- }
- line = fgets(buf, BUFSIZ, stdin);
-
- if (line == NULL) {
- /* end of file */
- free(buf);
- return NULL;
- } else
- length = strlen(line);
-
- if (length > 0 ) {
- /* test for special commands */
- while (length > 0 &&
- (*line & ~0x7F) == 0 &&
- isspace((unsigned char) *line)) {
- line++;
- length--;
- }
- /* in the switch, use continue if the line was
- processed, use break to send to parser */
- switch (*line) {
- case '\0':
- /* empty line */
- break;
- case '\\':
- switch (line[1]) {
- case 'q':
- free(buf);
- return NULL;
- default:
- break;
- }
- line= NULL;
- break;
- case '?':
- showCommands();
- line= NULL;
- continue;
- }
- /* make sure we return a pointer that can (and should)
be freed by the caller */
- if (line)
- line = buf;
- }
- } while (line == NULL);
- return line;
-}
-
-int
-readConsole(Client cntxt)
-{
- /* execute from stdin */
- struct stat statb;
- char *buf;
-
- if (cntxt->promptlength == 0 ||
- !(fstat(fileno(stdin), &statb) == 0 && S_ISCHR(statb.st_mode)) )
- return -1;
-
- /* read lines and move string to client buffer. */
- buf= getConsoleInput(cntxt, cntxt->prompt, 0, 1);
- if( buf) {
- size_t len= strlen(buf);
- if( len >= cntxt->fdin->size) {
- char *nbuf;
- /* extremely dirty inplace buffer overwriting */
- nbuf= realloc(cntxt->fdin->buf, len+1);
- if( nbuf == NULL) {
- GDKerror("readConsole: " MAL_MALLOC_FAIL);
- free(buf);
- goto bailout;
- }
- cntxt->fdin->buf = nbuf;
- cntxt->fdin->size = len;
- }
- strcpy(cntxt->fdin->buf, buf);
- cntxt->fdin->pos = 0;
- cntxt->fdin->len = len;
- free(buf);
- return 1;
- }
- bailout:
- cntxt->fdin->eof = true;
- return -1;
-}
-#endif
diff --git a/monetdb5/mal/mal_readline.h b/monetdb5/mal/mal_readline.h
deleted file mode 100644
--- a/monetdb5/mal/mal_readline.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
- */
-
-#ifndef READLINETOOLS_H_INCLUDED
-#define READLINETOOLS_H_INCLUDED
-
-#include "mal_client.h"
-mal_export int readConsole(Client cntxt);
-mal_export char * getConsoleInput(Client c, const char *prompt, int linemode,
int exit_on_error);
-
-#endif /* READLINETOOLS_H_INCLUDED */
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
@@ -14,18 +14,12 @@
#include "mal_interpreter.h" /* for runMAL(), garbageElement() */
#include "mal_parser.h" /* for parseMAL() */
#include "mal_namespace.h"
-#include "mal_readline.h"
#include "mal_authorize.h"
#include "mal_builder.h"
#include "mal_sabaoth.h"
#include "mal_private.h"
#include "gdk.h" /* for opendir and friends */
-#ifdef HAVE_EMBEDDED
-// FIXME:
-//#include "mal_init_inline.h"
-#endif
-
/*
* The MonetDB server uses a startup script to boot the system.
* This script is an ordinary MAL program, but will mostly
@@ -586,16 +580,6 @@ MALexitClient(Client c)
str
MALreader(Client c)
{
-#ifndef HAVE_EMBEDDED
- int r = 1;
- if (c == mal_clients) {
- r = readConsole(c);
- if (r < 0 && !c->fdin->eof)
- r = MCreadClient(c);
- if (r > 0)
- return MAL_SUCCEED;
- } else
-#endif
if (MCreadClient(c) > 0)
return MAL_SUCCEED;
MT_lock_set(&mal_contextLock);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list