Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23107/src/mal
Modified Files:
Tag: GDK-2
mal_client.mx mal_debugger.mx mal_interpreter.mx mal_module.mx
mal_readline.mx
Log Message:
propagated changes of Monday Sep 10 2007 - Tuesday Sep 18 2007
from the development trunk to the GDK-2 branch
Index: mal_client.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_client.mx,v
retrieving revision 1.154.2.3
retrieving revision 1.154.2.4
diff -u -d -r1.154.2.3 -r1.154.2.4
--- mal_client.mx 6 Sep 2007 13:52:35 -0000 1.154.2.3
+++ mal_client.mx 18 Sep 2007 12:42:47 -0000 1.154.2.4
@@ -763,9 +763,8 @@
in->buf[in->pos] == ';' || !in->buf[in->pos]))
in->pos++;
- if (in->pos >= in->len) {
+ if (in->pos >= in->len || in->mode) {
ssize_t rd, sum = 0;
- assert(in->pos == in->len);
if (in->eof || !isa_block_stream(in->s)) {
@:sendPrompt@
@@ -773,8 +772,23 @@
}
while ((rd = bstream_next(in)) > 0 && !in->eof) {
sum += rd;
- if (!in->mode)/* read one line at a time in line mode */
+ if (!in->mode) {/* read one line at a time in line mode
*/
break;
+ } else { /* find last new line */
+ char *p = in->buf+in->len-1;
+
+ while(p > in->buf && *p != '\n') {
+ *(p+1) = *p;
+ p--;
+ }
+ if (p > in->buf) {
+ *(p+1) = 0;
+ } else {
+ in->pos++;
+ }
+ if (p != in->buf+ in->len -1)
+ in->len++;
+ }
}
if (sum == 0 && in->eof && isa_block_stream(in->s)) {
/* we hadn't seen the EOF before, so just try again
Index: mal_debugger.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_debugger.mx,v
retrieving revision 1.200.2.7
retrieving revision 1.200.2.8
diff -u -d -r1.200.2.7 -r1.200.2.8
--- mal_debugger.mx 28 Aug 2007 13:14:58 -0000 1.200.2.7
+++ mal_debugger.mx 18 Sep 2007 12:42:49 -0000 1.200.2.8
@@ -468,6 +468,7 @@
} MdbState;
mal_export void mdbSetBreakpoint(Client cntxt, MalBlkPtr mb, int pc, char cmd);
+mal_export void mdbSetBreakRequest(Client cntxt, MalBlkPtr mb, str request,
char cmd);
mal_export void mdbClrBreakRequest(Client cntxt, str name);
mal_export void mdbShowBreakpoints(Client cntxt);
mal_export void mdbCommand(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
p, int pc);
@@ -1476,6 +1477,9 @@
p = getInstrPtr(mb, pc);
mdbCommand(cntxt, mb, stk, p, pc);
break;
+ case 't':
+ printTraceCall(cntxt->fdout,mb,stk,pc,cntxt->flags);
+ break;
case 'C':
mdbSessionActive= 0; /* for name completion */
}
Index: mal_module.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_module.mx,v
retrieving revision 1.50.2.5
retrieving revision 1.50.2.6
diff -u -d -r1.50.2.5 -r1.50.2.6
--- mal_module.mx 3 Sep 2007 13:08:10 -0000 1.50.2.5
+++ mal_module.mx 18 Sep 2007 12:42:52 -0000 1.50.2.6
@@ -789,6 +789,8 @@
return 1;
return 0;
}
+
+#define MAXHELP 500
char **getHelp(Module m, str inputpat, int completion)
{
str pat, modnme, fcnnme = 0;
@@ -797,11 +799,12 @@
int len1 = 0,len2 = 0,fnd=0;
char *t, **msg, buf[BUFSIZ];
int top=0, i,j,k, sig = 0, doc = 0;
+ int maxhelp= MAXHELP;
#ifdef MAL_SCOPE_DEBUG
printf("showHelp: %s",pat);
#endif
- msg= (char **) GDKmalloc( 1000 * sizeof(str));
+ msg= (char **) GDKmalloc( MAXHELP * sizeof(str));
msg[top]=0;
if (!inputpat)
@@ -852,9 +855,9 @@
if( strncmp(modnme,m->name,len1) ==0 ||
*modnme=='*'){
msg[top++] = GDKstrdup(m->name);
msg[top] =0;
- if( top == 999) {
- GDKfree(pat);
- return msg;
+ if( top == maxhelp-1) {
+ msg= (char **)
GDKrealloc(msg,sizeof(str)* maxhelp);
+ maxhelp+= MAXHELP;
}
}
m= m->sibling;
@@ -878,8 +881,8 @@
#endif
for(i=0; i< MAXSCOPE; i++)
for(k=0; k< MAXSCOPE; k++){
- m= scopeJump[i][k];
- while( m){
+ m= scopeJump[i][k];
+ while( m){
if( strncmp(modnme,m->name,len1) && *modnme!='*' ) {
m= m->sibling;
continue;
@@ -908,14 +911,11 @@
if(fnd) continue;
msg[top++]= GDKstrdup(buf+1);
- if( top >=998) {
- GDKfree(pat);
- return msg;
- }
if(v){
*v='a';
msg[top++]= GDKstrdup(v);
}
+ msg[top] = 0;
if( s->def->help) {
char *w;
@@ -926,10 +926,11 @@
/*ignore */
} else *v++ = *w;
*v = 0;
- }
+ } else fnd = 1; /* ignore non-existing
comment */
*v++ ='\n';
*v=0;
- } else if( strcmp(fcnnme,s->name)==0 ||
*fcnnme=='*' ) {
+ } else if(
strncmp(fcnnme,s->name,strlen(fcnnme))==0 ||
+ *fcnnme=='*' ) {
fcnDefinition(s->def,s->def->stmt[0],buf,FALSE);
buf[0]=' ';
t= strstr(buf,"address");
@@ -939,9 +940,9 @@
msg[top++] = GDKstrdup(buf+1);
msg[top] = 0;
}
- if( top >=998) {
- GDKfree(pat);
- return msg;
+ if( top >= maxhelp-3){
+ msg= (char **)
GDKrealloc(msg,sizeof(str)* (maxhelp+MAXHELP));
+ maxhelp+= MAXHELP;
}
}
m= m->sibling;
@@ -960,8 +961,9 @@
Module m;
Symbol s;
int top = 0, i,j,k;
+ int maxhelp= MAXHELP;
- msg= (char **) GDKmalloc( 2000 * sizeof(str));
+ msg= (char **) GDKmalloc( maxhelp * sizeof(str));
msg[top]=0;
if (!pat)
@@ -1001,7 +1003,10 @@
}
msg[top++] = GDKstrdup(buf);
msg[top] = 0;
- if( top == 1999) return msg;
+ if( top == maxhelp-1){
+ msg= (char **)
GDKrealloc(msg,sizeof(str)* (maxhelp+MAXHELP));
+ maxhelp+= MAXHELP;
+ }
}
m= m->sibling;
}
Index: mal_interpreter.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_interpreter.mx,v
retrieving revision 1.194.2.2
retrieving revision 1.194.2.3
diff -u -d -r1.194.2.2 -r1.194.2.3
--- mal_interpreter.mx 6 Sep 2007 13:52:35 -0000 1.194.2.2
+++ mal_interpreter.mx 18 Sep 2007 12:42:51 -0000 1.194.2.3
@@ -1576,13 +1576,10 @@
if( cntxt-> flags & ioFlag){
struct rusage resource;
getrusage(RUSAGE_SELF, &resource);
- if( resource.ru_inblock - oldinblock
- || resource.ru_oublock - oldoublock ) {
- stream_printf(cntxt->fdout," %3d R",
- resource.ru_inblock- oldinblock);
- stream_printf(cntxt->fdout," %3d W ",
- resource.ru_oublock- oldoublock);
- }
+ stream_printf(cntxt->fdout," %3d R",
+ resource.ru_inblock- oldinblock);
+ stream_printf(cntxt->fdout," %3d W ",
+ resource.ru_oublock- oldoublock);
}
#endif
if( cntxt->flags & memoryFlag){
Index: mal_readline.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_readline.mx,v
retrieving revision 1.48.4.3
retrieving revision 1.48.4.4
diff -u -d -r1.48.4.3 -r1.48.4.4
--- mal_readline.mx 28 Aug 2007 13:15:01 -0000 1.48.4.3
+++ mal_readline.mx 18 Sep 2007 12:42:54 -0000 1.48.4.4
@@ -154,28 +154,6 @@
(void) msg; (void) a; (void) b;
for(i=0;i<a; i++)
stream_printf(GDKout,"%s\n",msg[i]);
- stream_printf(GDKout,"%s",rl_line_buffer);
-}
-static int mal_help(int a, int b){
- char **msg,*c;
- int i;
-
- (void) a;
- (void) b;
-
- c = rl_line_buffer + strlen(rl_line_buffer);
- while( c > (rl_line_buffer+1) && isspace(*c))
- c--;
- while( c > (rl_line_buffer+1) && !isspace(*c))
- c--;
- msg= getHelp(MCgetClient()->nspace,c,0);
- stream_printf(GDKout,"\n");
- for(i=0; msg[i]; i++){
- stream_printf(GDKout,"%s\n",msg[i]);
- GDKfree(msg[i]);
- }
- GDKfree(msg);
- return 0;
}
@-
@= tst
@@ -192,18 +170,8 @@
static int index, len, last;
static char **msg =0;
const char *name;
- char buf[BUFSIZ];
int i;
- /* we pick our own portion of the linebuffer */
- text = rl_line_buffer + strlen(rl_line_buffer);
- while( text > (rl_line_buffer+1) && ! isspace((int) *text))
- text--;
- if (strlen(text) < BUFSIZ) {
- strcpy(buf,text);
- text= buf;
- }
-
#ifdef _MAL_READLINE_DEBUG
printf("expand:%d [%d] %s \n",state,(int)strlen(text),text);
#endif
@@ -217,6 +185,10 @@
GDKfree(msg);
}
msg = 0;
+ } else
+ if( last >0){
+ mal_unquote(msg[--last]);
+ return strdup(msg[last]);
}
if( mdbSession() ){
while ( (name = mdb_commands[index++]) ){
@@ -229,18 +201,45 @@
if( @:tst(name,text,len)@ )
return strdup(name);
}
- if( msg == 0){
- msg= getHelp(MCgetClient()->nspace,(str)(text),1);
- last =0;
+ if( msg == 0 && *text){
+ char cmd[BUFSIZ], *c;
+ c= strstr(text,":=");
+ if(c) text=c+2;
+ while(isspace((int)*text) ) text++;
+ c= strchr(text,'.');
+ if( c== NULL)
+ snprintf(cmd,BUFSIZ,"%s.*(",text);
+ else
+ snprintf(cmd,BUFSIZ,"%s(",text);
+ msg= getHelp(MCgetClient()->nspace,(str)cmd,1);
+ for(last=0; msg[last]; last++)
+ ;
}
- if( msg[last]){
- last++;
- mal_unquote(msg[last-1]);
- return strdup(msg[last-1]);
+ if(msg && last && msg[--last]){
+ mal_unquote(msg[last]);
+ return strdup(msg[last]);
}
return NULL;
}
+int rl_complete(int ignore, int key){
+ char *msg[1000];
+ int i,top=0;
+
+ putchar('\n');
+ while( (msg[top]= mal_command_generator(rl_line_buffer,top)) )
+ if( ++top== 1000) break;
+ for(i=0;i<top; i++)
+ printf("%s\n",msg[i]);
+
+ printf("%s%s",rl_prompt,rl_line_buffer);
+ for( top--;top>=0; top--)
+ free(msg[top]);
+ (void) ignore;
+ (void) key;
+ return 0;
+}
+
static char **
mal_completion(const char *text, int start, int end)
{
@@ -274,9 +273,6 @@
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "MonetDB";
- /* recognize the help function, should react to <FCN-2> */
- rl_bind_key('\033',mal_help);
-
/* Tell the completer that we want to try our own completion before std
completion (filename) kicks in. */
rl_attempted_completion_function = mal_completion;
rl_completion_display_matches_hook= mal_help_display;
@@ -338,7 +334,6 @@
do {
#ifdef HAVE_LIBREADLINE
if (prompt) {
- /* rl_completion_func_t *func = NULL;*/
if (buf)
free(buf);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins