tchar eat(tchar c) { register tchar i; while (i = getch(), !issame(i, c) && (cbits(i) != '\n')) ; if (cbits(c) != ' ' && !issame(i, c)) nodelim(c); return(i); }
void setov(void) { register int j = 0, k; tchar i, delim, o[NOV]; int w[NOV]; if (ismot(i = getch())) return; delim = i; for (k = 0; (k < NOV) && (j = cbits(i = getch()), !issame(i, delim)) && (j != '\n'); k++) { o[k] = i; w[k] = width(i); } if (!issame(j, delim)) nodelim(delim); o[k] = w[k] = 0; if (o[0]) for (j = 1; j; ) { j = 0; for (k = 1; o[k] ; k++) { if (w[k-1] < w[k]) { j++; i = w[k]; w[k] = w[k-1]; w[k-1] = i; i = o[k]; o[k] = o[k-1]; o[k-1] = i; } } } else return; pbbuf[pbp++] = makem(w[0] / 2); for (k = 0; o[k]; k++) ; while (k>0) { k--; if (pbp >= pbsize-4) if (growpbbuf() == NULL) { errprint("no space for .ov"); done(2); } pbbuf[pbp++] = makem(-((w[k] + w[k+1]) / 2)); pbbuf[pbp++] = o[k]; } }
/* increases frequency of ngram(p,len) */ static inline int increasefreq( table_t *t, char *p, int len ) { uint4 hash = simplehash( p, len ) & TABLEMASK; entry_t *entry = t->table[ hash ]; while ( entry ) { if ( issame( entry->str, p, len ) ) { /*** Found it! ***/ entry->cnt++; return 1; } else { entry = entry->next; } } /*** Not found, so create ***/ entry = wgmempool_alloc( t->pool, sizeof(entry_t) ); strcpy( entry->str, p ); entry->cnt = 1; entry->next = t->table[hash]; t->table[hash] = entry; return 1; }
static void findMarkdownTags (void) { vString *name = vStringNew(); const unsigned char *line; while ((line = readLineFromInputFile()) != NULL) { int name_len = vStringLength(name); /* underlines must be the same length or more */ if (name_len > 0 && (line[0] == '=' || line[0] == '-') && issame((const char*) line)) { makeMarkdownTag(name, true); } else if (line[0] == '#') { vStringClear(name); vStringCatS(name, (const char *) line); makeMarkdownTag(name, false); } else { vStringClear (name); if (! isspace(*line)) vStringCatS(name, (const char*) line); } } vStringDelete (name); }
int pcmp(unsigned char * newbuffer, unsigned char* oldbuffer,unsigned int numpix) { for (unsigned int i=0;i<numpix;++i) { if (!issame(newbuffer+i*4,oldbuffer+i*4)) {//iswhite(newbuffer+i*4)!=iswhite(oldbuffer+i*4)) { return 1; } } return 0; }
void TformattedstringviewEnv::processcustomkeyword(StrPtr keyword, StrPtr in, QString &out) { if (issame(keyword,_qstr("\\linkitem"))) { TFuncTreeItem *item=GetTSCenv().G_functreeitem(in); if (item==NULL) { out=_qstr("!!!Unresolved link "); out+=in; return; } QString name; item->G_name(name); out=TFormatString(_qstr("\\hyperlink{^1}{^2}"),in,name); } if (issame(keyword,_qstr("\\softwarename"))) out="\\textbf{Z--Flux}"; }
void T3DControl_Menu::paramchanged(StrPtr iname) { if (issame(iname,_qstr("SelectID"))) { SelectItem(&root,selectid->G_string()); } /* if (offset>selectidx->G_val()) offset=selectidx->G_val(); if (offset<=selectidx->G_val()-county->G_val()) offset=selectidx->G_val()-county->G_val()+1; if (offset<0) offset=0;*/ }
T3DControl_Menu_Item* T3DControl_Menu_Item::finditem(StrPtr iID) { if (issame(iID,ID)) return this; for (int i=0; i<subitems.G_count(); i++) { T3DControl_Menu_Item *rs=subitems[i]->finditem(iID); if (rs!=NULL) return rs; } return NULL; }
void setbra(void) { register int k; tchar i, *j, dwn, delim; int cnt; tchar brabuf[NC]; if (ismot(i = getch())) return; delim = i; j = brabuf + 1; cnt = 0; #ifdef NROFF dwn = sabsmot(2 * t.Halfline) | MOT | VMOT; #endif #ifndef NROFF dwn = sabsmot((int)EM) | MOT | VMOT; #endif while ((k = cbits(i = getch()), !issame(delim, i)) && (k != '\n') && (j <= (brabuf + NC - 4))) { *j++ = i | ZBIT; *j++ = dwn; cnt++; } if (!issame(i, delim)) nodelim(delim); if (--cnt < 0) return; else if (!cnt) { ch = *(j - 2); return; } *j = 0; #ifdef NROFF *--j = *brabuf = sabsmot(cnt * t.Halfline) | MOT | NMOT | VMOT; #endif #ifndef NROFF *--j = *brabuf = sabsmot((cnt * (int)EM) / 2) | MOT | NMOT | VMOT; #endif *--j &= ~ZBIT; pushback(brabuf); }
void setline(void) { register tchar *i; tchar c, delim; int length; int w, cnt, rem, temp; tchar linebuf[NC]; if (ismot(c = getch())) return; delim = c; vflag = 0; dfact = EM; length = quant(hatoi(), HOR); dfact = 1; if (!length) { eat(delim); return; } s0: if (c = getch(), issame(c, delim)) { ch = c; c = RULE | chbits; } else if (cbits(c) == FILLER) goto s0; w = width(c); i = linebuf; if (length < 0) { *i++ = makem(length); length = -length; } if (!(cnt = length / w)) { *i++ = makem(-(temp = ((w - length) / 2))); *i++ = c; *i++ = makem(-(w - length - temp)); goto s1; } if ((rem = length % w)) { if (connectchar(c)) *i++ = c | ZBIT; *i++ = makem(rem); } if (cnt) { *i++ = RPT; *i++ = cnt; *i++ = c; } s1: *i++ = 0; eat(delim); pushback(linebuf); }
static int getpenalty(int *valp) { tchar c, delim; if (ismot(delim = getch())) return 0; if (readpenalty(valp) == 0) return 0; c = getch(); if (!issame(c, delim)) { nodelim(delim); return 0; } return 1; }
/* looks up ngram(p,len) */ static entry_t *findfreq( table_t *t, char *p, int len ) { uint4 hash = simplehash( p, len ) & TABLEMASK; entry_t *entry = t->table[ hash ]; while ( entry ) { if ( issame( entry->str, p, len ) ) { return entry; } else { entry = entry->next; } } return NULL; }
bool T3DControl_Menu::SelectItem(T3DControl_Menu_Item *current, StrPtr id) { current->cursubsel=-1; if (issame(id,current->ID)) { return true; } for (int i=0; i<current->subitems.G_count(); i++) if (SelectItem(current->subitems[i],id)) { current->cursubsel=i; return true; } return false; }
/* TODO: parse overlining & underlining as distinct sections. */ static void findRstTags (void) { vString *name = vStringNew (); fpos_t filepos; const unsigned char *line; memset(&filepos, 0, sizeof(fpos_t)); memset(kindchars, 0, sizeof kindchars); nestingLevels = nestingLevelsNew(); while ((line = readLineFromInputFile ()) != NULL) { int line_len = strlen((const char*) line); int name_len_bytes = vStringLength(name); int name_len = utf8_strlen(vStringValue(name), name_len_bytes); /* if the name doesn't look like UTF-8, assume one-byte charset */ if (name_len < 0) name_len = name_len_bytes; /* underlines must be the same length or more */ if (line_len >= name_len && name_len > 0 && ispunct(line[0]) && issame((const char*) line)) { char c = line[0]; int kind = get_kind(c); if (kind >= 0) { makeRstTag(name, kind, filepos); continue; } } vStringClear (name); if (!isspace(*line)) { vStringCatS(name, (const char*)line); filepos = getInputFilePosition(); } vStringTerminate(name); } vStringDelete (name); nestingLevelsFree(nestingLevels); }
void execute_implement(TSC_funcarglist *arglist, TSC_value *retval, TSC_value *assigntoval, TSC_value *owner) { TSC_list *list=G_valuecontent<TSC_list>(retval); list->reset(); T3DObjectStarGlobe *starglobe=G_valuecontent<T3DObjectStarGlobe>(owner); StrPtr constid=arglist->get(0)->G_content_string()->G_string(); Tarray<QString> &const_code=G_3DCosmos().const_code; Tdoublearray &const_X_1=G_3DCosmos().const_X_1; Tdoublearray &const_X_2=G_3DCosmos().const_X_2; Tdoublearray &const_Y_1=G_3DCosmos().const_Y_1; Tdoublearray &const_Y_2=G_3DCosmos().const_Y_2; Tdoublearray &const_Z_1=G_3DCosmos().const_Z_1; Tdoublearray &const_Z_2=G_3DCosmos().const_Z_2; double rd=starglobe->radius->G_val(); for (int i=0; i<const_code.G_count(); i++) if (issame(constid,*const_code[i])) { TSC_value val_map; val_map.createtype(GetTSCenv().G_datatype(SC_valname_map)); TSC_map *map=G_valuecontent<TSC_map>(&val_map); { TSC_value val_pt; val_pt.createtype(GetTSCenv().G_datatype(SC_valname_vertex)); Tvertex *pt=G_valuecontent<Tvertex>(&val_pt); pt->copyfrom(rd*const_X_1[i],rd*const_Y_1[i],rd*const_Z_1[i]); map->Set(_qstr("Point1"),&val_pt); } { TSC_value val_pt; val_pt.createtype(GetTSCenv().G_datatype(SC_valname_vertex)); Tvertex *pt=G_valuecontent<Tvertex>(&val_pt); pt->copyfrom(rd*const_X_2[i],rd*const_Y_2[i],rd*const_Z_2[i]); map->Set(_qstr("Point2"),&val_pt); } list->add(&val_map); } }
void T3DObjectStarMap::calculate() { double x0,y0,z0,gr,fc; double hx,hy,hz,vx,vy,vz; T4color col2,col2L,col2R; double sx=sizex->G_val(); double sy=sizey->G_val(); double ssize=starsize->G_val(); if (calculated) return; Tdoublearray &stars_MAG=G_3DCosmos().stars_MAG; Tdoublearray &stars_E1=G_3DCosmos().stars_E1; Tdoublearray &stars_E2=G_3DCosmos().stars_E2; Tarray<QString> &const_code=G_3DCosmos().const_code; Tdoublearray &const_E1_1=G_3DCosmos().const_E1_1; Tdoublearray &const_E1_2=G_3DCosmos().const_E1_2; Tdoublearray &const_E2_1=G_3DCosmos().const_E2_1; Tdoublearray &const_E2_2=G_3DCosmos().const_E2_2; //for stars starvertexbuffer.reset();starcolorbufferL.reset();starcolorbufferR.reset();startexturebuffer.reset(); if (ssize>0) { for (int i=0; i<stars_E1.G_count(); i++) { x0=mapx(stars_E1[i]); y0=mapy(stars_E2[i]); z0=0; gr=(7-stars_MAG[i])/7; gr=sqrt(gr); if (gr<0.15) gr=0.15; if (gr>1.0) gr=1.0; fc=ssize*gr; hx=fc;hy=0;hz=0; vx=0;vy=fc;vz=0; col2.r=gr*color->G_R(); col2.g=gr*color->G_G(); col2.b=gr*color->G_B(); col2.a=1*color->G_A(); col2L=col2;col2L.ColMapL(); col2R=col2;col2R.ColMapR(); startexturebuffer.add(T2textureidx(0,0)); starvertexbuffer.add(Tvec3d(x0-hx-vx,y0-hy-vy,z0-hz-vz)); startexturebuffer.add(T2textureidx(0,1)); starvertexbuffer.add(Tvec3d(x0-hx+vx,y0-hy+vy,z0-hz+vz)); startexturebuffer.add(T2textureidx(1,1)); starvertexbuffer.add(Tvec3d(x0+hx+vx,y0+hy+vy,z0+hz+vz)); startexturebuffer.add(T2textureidx(1,0)); starvertexbuffer.add(Tvec3d(x0+hx-vx,y0+hy-vy,z0+hz-vz)); starcolorbufferL.add(col2L);starcolorbufferL.add(col2L);starcolorbufferL.add(col2L);starcolorbufferL.add(col2L); starcolorbufferR.add(col2R);starcolorbufferR.add(col2R);starcolorbufferR.add(col2R);starcolorbufferR.add(col2R); } } //for constellation lines conlinesvertexbuffer.reset(); conlinestexturebuffer.reset(); QString constname=singleconstellationname->G_string(); double linesize=conlinesize->G_val(); if (linesize>1.0e-9) { for (int i=0; i<const_E1_1.G_count(); i++) if ((qstrlen(constname)==0)||(issame(*const_code[i],constname))) { double xx1=mapx(const_E1_1[i]); double xx2=mapx(const_E1_2[i]); double yy1=mapy(const_E2_1[i]); double yy2=mapy(const_E2_2[i]); if (xx1>xx2) { double tmp=xx1; xx1=xx2; xx2=tmp; tmp=yy1; yy1=yy2; yy2=tmp; } if (fabs(xx1-xx2)<sx/2) { addline(xx1,yy1,xx2,yy2); } else { addline(xx2-sx,yy1,xx1,yy2); addline(xx2,yy1,xx1+sx,yy2); } } } calculated=true; }
void setvline(void) { register int i; tchar c, _d, delim, rem, ver, neg; int cnt, v; tchar vlbuf[NC]; register tchar *vlp; if (ismot(c = getch())) return; delim = c; dfact = lss; vflag++; i = quant(hatoi(), VERT); dfact = 1; if (!i) { eat(delim); vflag = 0; return; } if (c = getch(), issame(c, delim)) { c = BOXRULE | chbits; /*default box rule*/ } else { _d = getch(); if (!issame(_d, delim)) nodelim(delim); } c |= ZBIT; neg = 0; if (i < 0) { i = -i; neg = NMOT; } #ifdef NROFF v = 2 * t.Halfline; #endif #ifndef NROFF v = EM; #endif cnt = i / v; rem = makem(i % v) | neg; ver = makem(v) | neg; vlp = vlbuf; if (!neg) *vlp++ = ver; if (absmot(rem) != 0) { *vlp++ = c; *vlp++ = rem; } while ((vlp < (vlbuf + NC - 3)) && cnt--) { *vlp++ = c; *vlp++ = ver; } *(vlp - 2) &= ~ZBIT; if (!neg) vlp--; *vlp++ = 0; pushback(vlbuf); vflag = 0; }
Tcyclorbit2* G_stockcyclorbit(StrPtr name) { for (int i=0; i<stockcyclorbitnames.G_count(); i++) if (issame(*stockcyclorbitnames[i],name)) return stockcyclorbits[i]; return NULL; }
void setdraw (void) /* generate internal cookies for a drawing function */ { int i, dx[NPAIR], dy[NPAIR], type; tchar c, delim; #ifndef NROFF int hpos, vpos; int j, k; tchar drawbuf[NC]; #else extern int tlp, utf8; char drawbuf[NC]; #endif /* NROFF */ /* input is \D'f dx dy dx dy ... c' (or at least it had better be) */ /* this does drawing function f with character c and the */ /* specified dx,dy pairs interpreted as appropriate */ /* pairs are deltas from last point, except for radii */ /* l dx dy: line from here by dx,dy */ /* c x: circle of diameter x, left side here */ /* e x y: ellipse of diameters x,y, left side here */ /* a dx1 dy1 dx2 dy2: ccw arc: ctr at dx1,dy1, then end at dx2,dy2 from there */ /* ~ dx1 dy1 dx2 dy2...: spline to dx1,dy1 to dx2,dy2 ... */ /* f dx dy ...: f is any other char: like spline */ if (ismot(c = getch())) return; delim = c; type = cbits(getch()); for (i = 0; i < NPAIR ; i++) { do { c = getch(); if (issame(c, delim)) goto argend; } while (cbits(c) == ' '); /* ought to pick up optional drawing character */ if (cbits(c) != ' ') ch = c; vflag = 0; dfact = type == DRAWTHICKNESS ? 1 : EM; dx[i] = quant(hatoi(), HOR); if (dx[i] > MAXMOT) dx[i] = MAXMOT; else if (dx[i] < -MAXMOT) dx[i] = -MAXMOT; do { c = getch(); if (issame(c, delim)) { dy[i++] = 0; goto argend; } } while (cbits(c) == ' '); if (cbits(c) != ' ') ch = c; vflag = 1; dfact = lss; dy[i] = quant(hatoi(), VERT); if (type == DRAWTHICKNESS) dy[i] = 0; else if (dy[i] > MAXMOT) dy[i] = MAXMOT; else if (dy[i] < -MAXMOT) dy[i] = -MAXMOT; } argend: dfact = 1; vflag = 0; #ifndef NROFF drawbuf[0] = DRAWFCN | chbits | ZBIT; drawbuf[1] = type | chbits | ZBIT; drawbuf[2] = '.' | chbits | ZBIT; /* use default drawing character */ hpos = vpos = 0; for (k = 0, j = 3; k < i; k++) { drawbuf[j++] = MOT | ((dx[k] >= 0) ? sabsmot(dx[k]) : (NMOT | sabsmot(-dx[k]))); drawbuf[j++] = MOT | VMOT | ((dy[k] >= 0) ? sabsmot(dy[k]) : (NMOT | sabsmot(-dy[k]))); hpos += dx[k]; vpos += dy[k]; } if (type == DRAWELLIPSE || type == DRAWELLIPSEFI) { drawbuf[5] = drawbuf[4] | NMOT; /* so the net vertical is zero */ j = 6; } if (gflag && (type == DRAWPOLYGON || type == DRAWPOLYGONFI) && (hpos || vpos)) { drawbuf[j++] = MOT | ((hpos < 0) ? sabsmot(-hpos) : (NMOT | sabsmot(hpos))); drawbuf[j++] = MOT | VMOT | ((vpos < 0) ? sabsmot(-vpos) : (NMOT | sabsmot(vpos))); } drawbuf[j++] = DRAWFCN | chbits | ZBIT; /* marks end for ptout */ drawbuf[j] = 0; pushback(drawbuf); #else switch (type) { case 'l': if (dx[0] && !dy[0]) { if (dx[0] < 0) { snprintf(drawbuf, sizeof(drawbuf), "\\h'%du'", dx[0]); cpushback(drawbuf); } snprintf(drawbuf, sizeof(drawbuf), "\\l'%du%s'", dx[0], tlp ? "\\&-" : utf8 ? "\\U'2500'" : ""); cpushback(drawbuf); } else if (dy[0] && !dx[0]) { snprintf(drawbuf, sizeof(drawbuf), "\\L'%du%s'", dy[0], tlp ? "|" : utf8 ? "\\U'2502'" : ""); cpushback(drawbuf); } } #endif }