/* as well as 01's, change blanks to nulls, so that rc will * treat the words as separate arguments */ void exportenv(Envy *e) { int f, n, hasvalue, first; Word *w; Symtab *sy; char nam[256]; for(;e->name; e++){ sy = symlook(e->name, S_VAR, 0); if (e->values == 0 || e->values->s == 0 || e->values->s[0] == 0) hasvalue = 0; else hasvalue = 1; if(sy == 0 && !hasvalue) /* non-existant null symbol */ continue; snprint(nam, sizeof nam, "/env/%s", e->name); if (sy != 0 && !hasvalue) { /* Remove from environment */ /* we could remove it from the symbol table * too, but we're in the child copy, and it * would still remain in the parent's table. */ remove(nam); delword(e->values); e->values = 0; /* memory leak */ continue; } f = create(nam, OWRITE, 0666L); if(f < 0) { fprint(2, "can't create %s, f=%d\n", nam, f); perror(nam); continue; } first = 1; for (w = e->values; w; w = w->next) { n = strlen(w->s); if (n) { if(first) first = 0; else{ if (write (f, "\0", 1) != 1) perror(nam); } if (write(f, w->s, n) != n) perror(nam); } } close(f); } }
static void envupd(char *name, Word *value) { Envy *e; for(e = envy; e->name; e++) if(strcmp(name, e->name) == 0){ delword(e->values); e->values = value; return; } e->name = name; e->values = value; envinsert(0,0); }
/*------------------------------------------------------------------------ * ttyiin - handle interrupt-level input for a tty *------------------------------------------------------------------------ */ void ttyiin(struct devsw *pdev, unsigned char ch) { struct tty *ptty = (struct tty *)pdev->dvioblk; struct tchars *ptc; static unsigned char lastc; if (ch == '\n' && lastc == '\r') return; lastc = ch; if (ptty->tty_iflags & TIF_RAW) { iputchar(ptty, ch); if (scount(ptty->tty_isema) <= 0) signal(ptty->tty_isema); return; } if (ch == '\r') ch = '\n'; ptc = &ptty->tty_tchars; if (ch == ptc->tc_erase) { delchar(ptty); return; } else if (ch == ptc->tc_werase) { delword(ptty); return; } else if (ch == ptc->tc_reprint) { reprint(ptty); return; } else if (ch == ptc->tc_intr) { send(ptty->tty_cpid, INTRMSG); return; } else if (ch == ptc->tc_eof) { ptty->tty_iflags |= TIF_EOF; } else if (ch == ptc->tc_status) { x_ps(CONSOLE, CONSOLE, CONSOLE, 0); } iputchar(ptty, ch); if ((ptty->tty_iflags & (TIF_CBREAK|TIF_RAW)) || ch == ptty->tty_tchars.tc_eol || ch == ptty->tty_tchars.tc_eof) if (scount(ptty->tty_isema) <= 0) signal(ptty->tty_isema); }
MainWin::MainWin(QWidget *parent):QMainWindow(parent) { ui.setupUi(this); ui.result->weight[0] = .1; ui.result->weight[1] = .1; ui.result->weight[2] = .1; ui.result->weight[3] = .1; ui.result->weight[4] = .35; ui.result->weight[5] = .25; cbrd = QApplication::clipboard(); QObject::connect(ui.leText,SIGNAL(textChanged(QString)),this,SLOT(gotranslate())); QObject::connect(ui.tbNew,SIGNAL(released()),this,SLOT(waneword())); QObject::connect(ui.tbReload,SIGNAL(released()),this,SLOT(reload())); QObject::connect(ui.tbForms,SIGNAL(released()),this,SIGNAL(wannaform())); QObject::connect(ui.tbDelete,SIGNAL(released()),this,SLOT(delword())); QObject::connect(ui.result,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(wanoldword(QModelIndex))); QObject::connect(ui.result,SIGNAL(indexchanged(int)),this,SLOT(reselect(int))); QObject::connect(cbrd,SIGNAL(dataChanged()),this,SLOT(tranCbrd())); }
static Word* subsub(Word *v, char *s, char *end) { int nmid; Word *head, *tail, *w, *h; Word *a, *b, *c, *d; Bufblock *buf; char *cp, *enda; a = extractpat(s, &cp, "=%&", end); b = c = d = 0; if(PERCENT(*cp)) b = extractpat(cp+1, &cp, "=", end); if(*cp == '=') c = extractpat(cp+1, &cp, "&%", end); if(PERCENT(*cp)) d = stow(cp+1); else if(*cp) d = stow(cp); head = tail = 0; buf = newbuf(); for(; v; v = v->next){ h = w = 0; if(submatch(v->s, a, b, &nmid, &enda)){ /* enda points to end of A match in source; * nmid = number of chars between end of A and start of B */ if(c){ h = w = wdup(c); while(w->next) w = w->next; } if(PERCENT(*cp) && nmid > 0){ if(w){ bufcpy(buf, w->s, strlen(w->s)); bufcpy(buf, enda, nmid); insert(buf, 0); free(w->s); w->s = strdup(buf->start); } else { bufcpy(buf, enda, nmid); insert(buf, 0); h = w = newword(buf->start); } buf->current = buf->start; } if(d && *d->s){ if(w){ bufcpy(buf, w->s, strlen(w->s)); bufcpy(buf, d->s, strlen(d->s)); insert(buf, 0); free(w->s); w->s = strdup(buf->start); w->next = wdup(d->next); while(w->next) w = w->next; buf->current = buf->start; } else h = w = wdup(d); } } if(w == 0) h = w = newword(v->s); if(head == 0) head = h; else tail->next = h; tail = w; } freebuf(buf); delword(a); delword(b); delword(c); delword(d); return head; }