Changeset: 0bb1a65266ab for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0bb1a65266ab Modified Files: monetdb5/mal/mal_debugger.c monetdb5/mal/mal_module.c monetdb5/modules/mal/manual.c Branch: default Log Message:
Reshuffle code, no functional change diffs (truncated from 456 to 300 lines): 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 @@ -529,8 +529,15 @@ retryRead: } } continue; - } else - showModules(out, cntxt->nspace); + } else{ + Module s; + for( s= cntxt->nspace; s; s= s->outer) { + mnstr_printf(out,"%s",s->name); + if( s->subscope==0) mnstr_printf(out,"?"); + if(s->outer) mnstr_printf(out,","); + } + mnstr_printf(out,"\n"); + } } break; case 'T': /* debug type resolver for a function call */ diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c --- a/monetdb5/mal/mal_module.c +++ b/monetdb5/mal/mal_module.c @@ -335,214 +335,8 @@ findInstruction(Module scope, MalBlkPtr return 0; } -void showModules(stream *f, Module s) -{ - for(; s; s= s->outer) { - mnstr_printf(f,"%s",s->name); - if( s->subscope==0) mnstr_printf(f,"?"); - if(s->outer) mnstr_printf(f,","); - } - mnstr_printf(f,"\n"); -} - /* - * The commands and operators come with a short description. - * The dumpManual() command produces a single file for post - * processing and producing a system manual. - */ -static int cmpModName(Module *f, Module *l){ - return strcmp((*f)->name, (*l)->name); -} - -/* - * The manual overview merely lists the mod.function names - * in texi format for inclusion in the documetation. - */ -void dumpManualOverview(stream *f, Module s, int recursive){ - int j,z,rows,cols; - Symbol t; - InstrPtr sig; - Module list[256]; int k, top=0, ftop, fnd; - InstrPtr fcn[5000]; - int r, c, *x = NULL, x_sze = 0; - - - if(s==NULL || f==NULL){ - return; - } - list[top++]=s; - while(s->outer && recursive){ list[top++]= s->outer;s=s->outer;} - - if(top>1) qsort(list, top, sizeof(Module), - (int(*)(const void *, const void *))cmpModName); - - cols = 4; - mnstr_printf(f,"@multitable @columnfractions .24 .24 .24 .24\n"); - for(k=0;k<top;k++){ - s= list[k]; - ftop = 0; - if( s->subscope) - for(j=0;j<MAXSCOPE;j++) - if(s->subscope[j]){ - for(t= s->subscope[j];t!=NULL;t=t->peer) { - sig= getSignature(t); - fnd = 0; - fnd= *getFunctionId(sig) == '#'; - for(z=0; z<ftop; z++) - if( strcmp(getFunctionId(fcn[z]),getFunctionId(sig))==0){ - fnd++; - break; - } - if( fnd == 0 && ftop<5000) - fcn[ftop++] = sig; - } - } - for(j=0; j<ftop; j++) - for(z=j+1; z<ftop; z++) - if( strcmp(getFunctionId(fcn[j]),getFunctionId(fcn[z])) >0) { - sig= fcn[j]; fcn[j]=fcn[z]; fcn[z]= sig; - } - mnstr_printf(f,"@" "item\n"); - rows = (ftop + cols - 1) / cols; - if (x == NULL) { - /* 2x* to allow for empty/skipped fields/columns */ - x_sze = 2 * cols * rows; - x = (int*) GDKmalloc(x_sze * sizeof(int)); - } else if (2 * cols * rows > x_sze) { - x_sze = 2 * cols * rows; - x = (int*) GDKrealloc(x, x_sze * sizeof(int)); - } - if( x == NULL){ - GDKerror("dumpManualOverview"MAL_MALLOC_FAIL); - return; - } - for (z = 0; z < rows; z++) { - x[cols * z] = z; - } - for (c = 1; c < cols; c++) { - for (r = 0; r < rows; r++) { - int i = (cols * r) + c - 1; - if (z < ftop && - (x[i] < 0 || strlen(getModuleId(fcn[x[i]])) + strlen(getFunctionId(fcn[x[i]])) < (size_t)(80 / cols))) { - x[i+1] = z++; - } else { - /* HACK to avoid long names running into next column in printed version */ - x[i+1] = -1; - } - } - } - z = 0; - for (r = 0; r < rows; r++) { - for (c = 0; c < cols; c++) { - str it[] = {"item", "tab"}; - mnstr_printf(f,"@" "%s\n", it[(c > 0)]); - if (x[z] != -1) { - mnstr_printf(f,"%s.%s\n", - getModuleId(fcn[x[z]]), getFunctionId(fcn[x[z]])); - } - z++; - } - } - } - mnstr_printf(f,"@end multitable\n"); - if (x != NULL) - GDKfree(x); -} -/* - * The manual help overview merely lists the mod.function names - * together with the help oneliner in texi format for inclusion in the documentation. - */ -void dumpManualHelp(stream *f, Module s, int recursive){ - int j,z; - Symbol t; - InstrPtr sig; - Module list[256]; int k, ftop, fnd,top=0; - InstrPtr fcn[5000]; - str hlp[5000],msg; - str hlp_texi = NULL; - size_t hlp_texi_len = 0; - - - if(s==NULL || f==NULL){ - return; - } - list[top++]=s; - while(s->outer && recursive){ list[top++]= s->outer;s=s->outer;} - - if(top>1) qsort(list, top, sizeof(Module), - (int(*)(const void *, const void *))cmpModName); - - for(k=0;k<top;k++){ - s= list[k]; - ftop = 0; - if( s->subscope) - for(j=0;j<MAXSCOPE;j++) - if(s->subscope[j]){ - for(t= s->subscope[j];t!=NULL;t=t->peer) { - sig= getSignature(t); - fnd = 0; - fnd= *getFunctionId(sig) == '#'; - for(z=0; z<ftop; z++) - if( strcmp(getFunctionId(fcn[z]),getFunctionId(sig))==0){ - if( hlp[z] == 0) - hlp[z]= t->def->help; - fnd++; - break; - } - if( fnd == 0 && ftop<5000){ - hlp[ftop]= t->def->help; - fcn[ftop++] = sig; - } - } - } - - for(j=0; j<ftop; j++) - for(z=j+1; z<ftop; z++) - if( strcmp(getFunctionId(fcn[j]),getFunctionId(fcn[z])) >0) { - msg= hlp[j]; hlp[j]=hlp[z]; hlp[z]= msg; - sig= fcn[j]; fcn[j]=fcn[z]; fcn[z]= sig; - } - - for(z=0; z<ftop; z++){ - mnstr_printf(f,"%s.%s", getModuleId(fcn[z]), getFunctionId(fcn[z])); - if( hlp[z] ) { - str hlp_ = hlp[z]; - size_t hlp_len = 2*strlen(hlp[z]) + 1; - if (hlp_texi == NULL) { - hlp_texi = (str) GDKmalloc(hlp_len); - hlp_texi_len = hlp_len; - } else if (hlp_len > hlp_texi_len) { - hlp_texi = (str) GDKrealloc(hlp_texi, hlp_len); - hlp_texi_len = hlp_len; - } - if (hlp_texi != NULL) { - str s, o = hlp_texi; - for ( s= hlp[z]; *s; s++){ - if (*s == '\n' || *s == '\t') - *o++ = ' '; - else - if( *s == '\\') { - *o++ = ' '; - s++; - } else - *o++ = *s; - } - *o++ = '\0'; - hlp_ = hlp_texi; - } - if (strlen(getModuleId(fcn[z])) + strlen(getFunctionId(fcn[z])) >= 20) { - /* HACK to avoid long names running into help text in printed version */ - } - mnstr_printf(f," | %s", hlp_); - } - mnstr_printf(f,"\n"); - } - } - if (hlp_texi != NULL) - GDKfree(hlp_texi); -} -/* - * Summarize the type resolution table. + * Summarize the type resolution table for debugging purposes. */ static void showModuleStat(stream *f, Module v,int cnt[256]){ diff --git a/monetdb5/modules/mal/manual.c b/monetdb5/modules/mal/manual.c --- a/monetdb5/modules/mal/manual.c +++ b/monetdb5/modules/mal/manual.c @@ -27,23 +27,210 @@ #include "monetdb_config.h" #include "manual.h" + +static int cmpModName(Module *f, Module *l){ + return strcmp((*f)->name, (*l)->name); +} + str MANUALcreateIndex(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { + stream *f = cntxt->fdout; + Module s = cntxt->nspace; + int j,z,rows,cols; + Symbol t; + InstrPtr sig; + Module list[256]; int k, top=0, ftop, fnd; + InstrPtr fcn[5000]; + int r, c, *x = NULL, x_sze = 0; + (void) mb; (void) stk; (void) pci; - dumpManualOverview(cntxt->fdout, cntxt->nspace, 1); + + if(s==NULL || f==NULL){ + return MAL_SUCCEED; + } + list[top++]=s; + while(s->outer){ list[top++]= s->outer;s=s->outer;} + + if(top>1) qsort(list, top, sizeof(Module), + (int(*)(const void *, const void *))cmpModName); + + cols = 4; + mnstr_printf(f,"@multitable @columnfractions .24 .24 .24 .24\n"); + for(k=0;k<top;k++){ + s= list[k]; + ftop = 0; + if( s->subscope) + for(j=0;j<MAXSCOPE;j++) + if(s->subscope[j]){ + for(t= s->subscope[j];t!=NULL;t=t->peer) { + sig= getSignature(t); + fnd = 0; + fnd= *getFunctionId(sig) == '#'; + for(z=0; z<ftop; z++) + if( strcmp(getFunctionId(fcn[z]),getFunctionId(sig))==0){ + fnd++; + break; + } + if( fnd == 0 && ftop<5000) + fcn[ftop++] = sig; + } + } + for(j=0; j<ftop; j++) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list