static int comparator (const void *va, const void *vb) { const char *a = *(const char* const*) va; const char *b = *(const char* const*) vb; while (*a && *b) { /* Make letters smaller than digits so that `atmega16a' follows `atmega16' without `atmega161' etc. between them. */ if (letter (*a) && digit (*b)) return -1; if (digit (*a) && letter (*b)) return 1; if (*a != *b) return *a - *b; a++; b++; } return *a - *b; }
getcomm() { char line[200], *cp, nb[25], *t; struct optstr *lp; int c, ci, found; for(lp= options; lp->optnam; lp++) *(lp->optadd) = 0; texname = texstr[texct=0]; tab = '\t'; printf(".nr %d \\n(.s\n", LSIZE); gets1(line); /* see if this is a command line */ if (index(line,';') == NULL) { backrest(line); return; } for(cp=line; (c = *cp) != ';'; cp++) { if (!letter(c)) continue; found=0; for(lp= options; lp->optadd; lp++) { if (prefix(lp->optnam, cp)) { *(lp->optadd) = 1; cp += strlen(lp->optnam); if (letter(*cp)) error("Misspelled global option"); while (*cp==' ')cp++; t=nb; if ( *cp == '(') while ((ci= *++cp) != ')') *t++ = ci; else cp--; *t++ = 0; *t=0; if (lp->optadd == &tab) { if (nb[0]) *(lp->optadd) = nb[0]; } if (lp->optadd == &linsize) printf(".nr %d %s\n", LSIZE, nb); if (lp->optadd == &delim1) { delim1 = nb[0]; delim2 = nb[1]; } found=1; break; } } if (!found) error("Illegal option"); } cp++; backrest(cp); return; }
Token Lexer::identifier() { letter(); while (is_alpha(cs_.peek())) letter(); return on_identifier(); }
void gen () { int f = 1; while (f) switch (rand () % 12) { case 0: len += 2; printf ("_R"); gen (); printf ("_o"); break; case 1: len += 2; printf ("_r"); gen (); printf ("_o"); break; case 2: len += 2; printf ("_L"); gen (); printf ("_o"); break; case 3: len += 2; printf ("_l"); gen (); printf ("_o"); break; case 4: len++; letter (); letter (); printf (" "); break; case 5: number (); break; case 6: len++; printf (" "); break; default: letter (); if (len << lev > minlen) f = 0; break; } }
int getlex() { char c; char *p; g1: c=next(); if (c == 0) return 0; if (c <= ' ') goto g1; if (c=='=') {if(thechar=='=') {next(); return T_EQ; }} if (c=='!') {if(thechar=='=') {next(); return T_NE; }} if (c=='<') {if(thechar=='=') {next(); return T_LE; }} if (c=='>') {if(thechar=='=') {next(); return T_GE; }} if (c=='<') {if(thechar=='<') {next(); return T_LESSLESS; }} if (c=='>') {if(thechar=='>') {next(); return T_GREATGREAT;}} if (c=='+') {if(thechar=='+') {next(); return T_PLUSPLUS; }} if (c=='-') {if(thechar=='-') {next(); return T_MINUSMINUS;}} if (c=='+') {if(thechar=='=') {next(); return T_PLUSASS; }} if (c=='-') {if(thechar=='=') {next(); return T_MINUSASS; }} if (c=='&') {if(thechar=='=') {next(); return T_ANDASS; }} if (c=='|') {if(thechar=='=') {next(); return T_ORASS; }} if (c=='*') {if(thechar=='=') {next(); return T_MULASS; }} if (c=='/') {if(thechar=='=') {next(); return T_DIVASS; }} if (instr1("()[]{},;*:%-><=+!&|#", c)) return c ; if (c == '/') { if (thechar == '*') { g2: c=next(); if (c != '*') goto g2; if (thechar != '/') goto g2; c=next(); return getlex(); } else return '/'; } if (c == '"') {getstring(c); return T_STRING;} if (digit(c)) { getdigit(c); return T_CONST; } if (c==39) { lexval=next(); if (lexval==92) {lexval=next(); if (lexval=='n') lexval=10; if (lexval=='t') lexval= 9; if (lexval=='0') lexval= 0; } next(); return T_CONST; } if (letter(c)) { strcpy1(symboltemp, symbol); p=&symbol; *p=c; p++; while(letter(thechar)) {c=next(); *p=c; p++; } *p=0; if (eqstr(symbol,"signed" )) return T_SIGNED; if (eqstr(symbol,"unsigned")) return T_UNSIGNED; if (eqstr(symbol,"void" )) return T_VOID; if (eqstr(symbol,"int" )) return T_INT; if (eqstr(symbol,"char" )) return T_CHAR; if (eqstr(symbol,"asm" )) return T_ASM; if (eqstr(symbol,"__asm" )) return T_ASMBLOCK; if (eqstr(symbol,"__emit__")) return T_EMIT; if (eqstr(symbol,"return" )) return T_RETURN; if (eqstr(symbol,"if" )) return T_IF; if (eqstr(symbol,"else" )) return T_ELSE; if (eqstr(symbol,"while" )) return T_WHILE; if (eqstr(symbol,"do" )) return T_DO; if (eqstr(symbol,"goto" )) return T_GOTO; if (eqstr(symbol,"define" )) return T_DEFINE; if (eqstr(symbol,"include" )) return T_INCLUDE; if (convertdefine() ) {strcpy1(symbol, symboltemp); return T_CONST;} return T_NAME; } error1("Zeichen nicht erkannt"); }
static int skip_word(const char *buf, int i, int len) { if (i >= len) return -1; if (!letter(buf[i])) return -1; while (i < len) { if (!letter(buf[i])) break; i++; } return i; }
QRectF frameRect(const QRectF &area, const QPoint &off = {0, 0}, QRectF *letterbox = nullptr) { QRectF rect = area; if (p->hasFrame()) { const double aspect = p->targetAspectRatio(); QSizeF frame(aspect, 1.0), letter(p->targetCropRatio(aspect), 1.0); letter.scale(area.width(), area.height(), Qt::KeepAspectRatio); frame.scale(letter, Qt::KeepAspectRatioByExpanding); QPointF pos(area.x(), area.y()); pos.rx() += (area.width() - frame.width())*0.5; pos.ry() += (area.height() - frame.height())*0.5; rect = {pos, frame}; QPointF xy(area.width(), area.height()); xy.rx() -= letter.width(); xy.ry() -= letter.height(); xy *= 0.5; QPointF offset = off; offset.rx() *= letter.width()/100.0; offset.ry() *= letter.height()/100.0; if (alignment & Qt::AlignLeft) offset.rx() -= xy.x(); else if (alignment & Qt::AlignRight) offset.rx() += xy.x(); if (alignment & Qt::AlignTop) offset.ry() -= xy.y(); else if (alignment & Qt::AlignBottom) offset.ry() += xy.y(); rect.translate(offset); xy += offset; if (letterbox) *letterbox = {xy, letter}; } return rect; }
bool Matcher::find(std::string &word, int &matchCount) { std::string arg = std::string(word); std::string token = std::string(""); int i = 0; int statePos = 0; matchCount = 0; while (i < word.size()) { Edge letter(word[i]); if (_fsa.checkState(letter, statePos) == 0) { token += letter.getChar(); if (_fsa.isFinalState(statePos) == true) { std::cout << "find token : " << token.c_str() << std::endl; matchCount++; token.clear(); statePos = 0; } else statePos++; } else { token.clear(); statePos = 0; } i++; } std::cout << "match count " << matchCount << std::endl; return true; }
string rearrangeString(string str, int k) { unordered_map<char, int> m; priority_queue<letter, vector<letter>, cmp> pq; for (int i = 0; i < str.length(); i++) { m[str[i]]++; } for (auto it = m.begin(); it != m.end(); it++) { pq.push(letter(it->first, it->second)); } int len = str.length(); string ans(len, '1'); int idx = 0; while (!pq.empty()) { char ch = pq.top().ch; int f = pq.top().frequency; pq.pop(); for (int i = 0; i < f; i++) { while (ans[idx] != '1') { if (idx + 1 < len) idx++; else idx = 0; } ans[idx] = ch; if (i + 1 < f) idx += k; } if (!check(ans, ch, k)) return ""; } return ans; }
void setname ( /* does parameter assignments */ unsigned char *argi, int xp ) { register unsigned char *argscan = argi; register struct namnod *n; if (letter(*argscan)) { while (alphanum(*argscan)) argscan++; if (*argscan == '=') { *argscan = 0; /* make name a cohesive string */ n = lookup(argi); *argscan++ = '='; attrib(n, xp); if (xp & N_ENVNAM) { n->namenv = n->namval = argscan; if (n == &pathnod) set_builtins_path(); } else assign(n, argscan); dolocale(n->namid); return; } } }
void TextPreview::word(int *x, int *y, const QByteArray &charIds, QPainter *painter, quint8 tableId) { foreach(char charId, charIds) { if(charId<0x20) return; letter(x, y, charId-0x20, painter, tableId); } }
static void fixDolMod(void) { int c; c = DgetC(0); if (c == ':') { do { c = DgetC(0), dolmcnt = 1, dolwcnt = 1; if (c == 'g' || c == 'a') { if (c == 'g') dolmcnt = 10000; else dolwcnt = 10000; c = DgetC(0); } if ((c == 'g' && dolmcnt != 10000) || (c == 'a' && dolwcnt != 10000)) { if (c == 'g') dolmcnt = 10000; else dolwcnt = 10000; c = DgetC(0); } if (c == 's') { /* [eichin:19910926.0755EST] */ int delimcnt = 2; int delim = DgetC(0); dolmod[dolnmod++] = c; dolmod[dolnmod++] = delim; if (!delim || letter(delim) || Isdigit(delim) || any(" \t\n", delim)) { seterror(ERR_BADSUBST); break; } while ((c = DgetC(0)) != (-1)) { dolmod[dolnmod++] = c; if(c == delim) delimcnt--; if(!delimcnt) break; } if(delimcnt) { seterror(ERR_BADSUBST); break; } continue; } if (!any("htrqxes", c)) stderror(ERR_BADMOD, c); dolmod[dolnmod++] = c; if (c == 'q') dolmcnt = 10000; } while ((c = DgetC(0)) == ':'); unDredc(c); } else unDredc(c); }
void Words::toLowerNonAscii(string &word) const { char *buf = (char*)malloc(word.length()*2); uint16_t bufIndex = 0; for (std::string::iterator i = word.begin(); i != word.end(); ++i) { unsigned char cc = *i; //cout << (uint8_t)cc<<endl; if (isascii(cc)) { //capital ascii mapped greek utf8letter mappedLetter = lmap.getGreekMappedAsciiCapitalLetters(cc); if (mappedLetter.first!=0 && mappedLetter.second!=0) { buf[bufIndex++] = mappedLetter.first; buf[bufIndex++] = mappedLetter.second; } else buf[bufIndex++] = tolower(cc); } else { if (cc!=0316 && cc!=0317) { buf[bufIndex++] = cc; } else { if ((i+1)!=word.end()) { ++i; unsigned char cc_2 = *i; utf8letter letter(cc, cc_2); utf8letter newLetter = lmap.getGreekLetters(letter); if (newLetter.first!=0 && newLetter.second!=0) { buf[bufIndex++] = newLetter.first; buf[bufIndex++] = newLetter.second; } else { buf[bufIndex++] = cc; buf[bufIndex++] = cc_2; } } else { buf[bufIndex++] = cc; } } } } buf[bufIndex]='\0'; word = string(buf); free(buf); }
static void fixDolMod(void) { eChar c; c = DgetC(0); if (c == ':') { do { c = DgetC(0), dolmcnt = 1, dol_flag_a = 0; if (c == 'g' || c == 'a') { if (c == 'g') dolmcnt = INT_MAX; else dol_flag_a = 1; c = DgetC(0); } if ((c == 'g' && dolmcnt != INT_MAX) || (c == 'a' && dol_flag_a == 0)) { if (c == 'g') dolmcnt = INT_MAX; else dol_flag_a = 1; c = DgetC(0); } if (c == 's') { /* [eichin:19910926.0755EST] */ int delimcnt = 2; eChar delim = DgetC(0); Strbuf_append1(&dolmod, (Char) c); Strbuf_append1(&dolmod, (Char) delim); if (delim == DEOF || !delim || letter(delim) || Isdigit(delim) || any(" \t\n", delim)) { seterror(ERR_BADSUBST); break; } while ((c = DgetC(0)) != DEOF) { Strbuf_append1(&dolmod, (Char) c); if(c == delim) delimcnt--; if(!delimcnt) break; } if(delimcnt) { seterror(ERR_BADSUBST); break; } continue; } if (!any("luhtrqxes", c)) stderror(ERR_BADMOD, (int)c); Strbuf_append1(&dolmod, (Char) c); if (c == 'q') dolmcnt = INT_MAX; } while ((c = DgetC(0)) == ':'); unDredc(c); } else unDredc(c); }
/*void insertParentProxy(ConfigVariablePtr var,AtomPcharKey=(unsigned char*)key;tr av) //add { AtomPtr atom; atom=*var->value.a; while(1){ //if(!atom->next)break; if(strcmp(atom->string,av->string)==0)return; if(!atom->next)break; atom=atom->next; } av->next=atom->next; atom->next=av; //av->next=*var->value.a; //*var->value.a=av; return; }*/ static int parseAtom1(char *buf, int offset, AtomPtr *value_return, int insensitive) { int y0, i, j, k; AtomPtr atom; int escape = 0; char *s; i = offset; if(buf[i] != '\0') { y0 = i; i++; while(buf[i] != '\"' && buf[i] != '\n' && buf[i] != '\0' && buf[i]!=',') { if(buf[i] == '\\' && buf[i + 1] != '\0') { escape = 1; i += 2; } else i++; } //if(buf[i] != '\0') //return -1; j = i ; } else { y0 = i; while(letter(buf[i]) || digit(buf[i]) || buf[i] == '_' || buf[i] == '-' || buf[i] == '~' || buf[i] == '.' || buf[i] == ':' || buf[i] == '/') i++; j = i; } if(escape) { s = malloc(i - y0); if(buf == NULL) return -1; k = 0; j = y0; while(j < i) { if(buf[j] == '\\' && j <= i - 2) { s[k++] = buf[j + 1]; j += 2; } else s[k++] = buf[j++]; } if(insensitive) atom = internAtomLowerN(s, k); else atom = internAtomN(s, k); free(s); j++; } else { if(insensitive) atom = internAtomLowerN(buf + y0, i - y0); else atom = internAtomN(buf + y0, i - y0); } *value_return = atom; return j; }
static void expand(const char *as) { const char *cs; const char *oldcs; char *sgpathp; struct stat stb; sgpathp = gpathp; cs = as; if (*cs == '~' && gpathp == gpath) { addpath('~'); for (cs++; letter(*cs) || digit(*cs) || *cs == '-';) addpath(*cs++); if (!*cs || *cs == '/') { if (gpathp != gpath + 1) { *gpathp = 0; if (gethdir(gpath + 1)) globerr = "Unknown user name after ~"; /* * Was: strcpy(gpath, gpath + 1); * but that's WRONG */ memmove(gpath, gpath+1, strlen(gpath+1)+1); } else { (void) strcpy(gpath, home); } gpathp = strend(gpath); } } while (!any(*cs, globchars)) { if (*cs == 0) { if (!globbed) Gcat(gpath, ""); else if (stat(gpath, &stb) >= 0) { Gcat(gpath, ""); globcnt++; } goto endit; } addpath(*cs++); } oldcs = cs; while (cs > as && *cs != '/') cs--, gpathp--; if (*cs == '/') cs++, gpathp++; *gpathp = 0; if (*oldcs == '{') { (void) execbrc(cs, ((char *)0)); return; } matchdir(cs); endit: gpathp = sgpathp; *gpathp = 0; }
void write_text(char* text) { int i; for(i = 0; i < strlen(text); i++) { letter(text[i]); } }
void word(char *str) { int i; int len = strlen(str); for (i = 0; i < len; i++) { letter(str[i]); } }
int main () { Circle letter(10, 100); printf("Radius : %d\n" "Area : %.2f\n", letter.get_radius(), letter.get_area() ); return 0; }
int getdigit(char c) { int i; lexval=0; lexval=c-'0'; /*lexval=int hi=0, c=char*/ if (thechar=='x') thechar='X'; if (thechar=='X') { next(); while(letter(thechar)) { c=next(); if(c>96) c=c-39; if (c>64) c=c-7; c=c-48; lexval=lexval << 4; /* *16 */ i=0; i=c; lexval=lexval+i;} }else { while(digit(thechar)) { c=next(); c=c-48; lexval=lexval*10; i=0; i=c; lexval=lexval+i; } } }
static void print(SDL_Surface *s, int x, int y, const char *t) { int i = 0; while (*t) { letter(s, *t, CSEL(i)); t++; i++; } }
static void expand(char *as) { char *cs; char *sgpathp, *oldcs; struct stat stb; sgpathp = gpathp; cs = as; if (*cs == '~' && gpathp == gpath) { addpath('~'); for (cs++; letter(*cs) || digit(*cs) || *cs == '-';) addpath(*cs++); if (!*cs || *cs == '/') { if (gpathp != gpath + 1) { *gpathp = 0; if (gethdir(gpath + 1)) { (void)sprintf(errstring = errbuf, "Unknown user name: %s after '~'", gpath+1); globerr = IPS; } strcpy(gpath, gpath + 1); } else strcpy(gpath, home); gpathp = strend(gpath); } } while (!any(*cs, globchars) && globerr == 0) { if (*cs == 0) { if (!globbed) Gcat(gpath, ""); else if (stat(gpath, &stb) >= 0) { Gcat(gpath, ""); globcnt++; } goto endit; } addpath(*cs++); } oldcs = cs; while (cs > as && *cs != '/') cs--, gpathp--; if (*cs == '/') cs++, gpathp++; *gpathp = 0; if (*oldcs == '{') { (void)execbrc(cs, ((char *)0)); return; } matchdir(cs); endit: gpathp = sgpathp; *gpathp = 0; }
void Dictionary::initialize_word_tree( void ) { for ( char ch = 'a'; ch <= 'z'; ch++ ) { m_dict_tree[ ch - 'a' ] = letter( ch ); if ( ch != 'z' ) { m_dict_tree[ ch - 'a' ].m_next = m_dict_tree + ( ch - 'a' + 1 ); } } }
void Draw(void) { clear(); cursor(6, 7); string("Score"); cursor(0, 7); letter( '0' + Score[0] ); cursor(15, 7); letter( '0' + Score[1] ); box(0, 1, Width*2, Height*2+1, 1); point(BallX + HCenter, BallY + VCenter, 1); line( HCenter-PadRow, VCenter + Paddle[0] - PadLen, HCenter-PadRow, VCenter + Paddle[0] + PadLen, 1 ); line( HCenter+PadRow, VCenter + Paddle[1] - PadLen, HCenter+PadRow, VCenter + Paddle[1] + PadLen, 1 ); screen_update(); }
bool IsLetterConstructibleFromMagazine::test() { string letter("apple pie"); string magazine("a p p l e p i e"); if (!isLetterConstructibleFromMagazine(letter, magazine)) { cout << "Should be able to construct " << letter << endl; cout << "Result cannot" << endl; return false; } return true; }
void vpline(const char *line, va_list ap) { char pbuf[BUFSZ]; char *bp = pbuf, *tl; int n,n0; if(!line || !*line) return; (void) vsnprintf(pbuf, sizeof pbuf, line, ap); if(flags.toplin == 1 && !strcmp(pbuf, toplines)) return; nscr(); /* %% */ /* If there is room on the line, print message on same line */ /* But messages like "You die..." deserve their own line */ n0 = strlen(bp); if(flags.toplin == 1 && tly == 1 && n0 + strlen(toplines) + 3 < CO-8 && /* leave room for --More-- */ strncmp(bp, "You ", 4)) { (void) strlcat(toplines, " ", sizeof toplines); (void) strlcat(toplines, bp, sizeof toplines); tlx += 2; addtopl(bp); return; } if(flags.toplin == 1) more(); remember_topl(); toplines[0] = 0; while(n0){ if(n0 >= CO){ /* look for appropriate cut point */ n0 = 0; for(n = 0; n < CO; n++) if(bp[n] == ' ') n0 = n; if(!n0) for(n = 0; n < CO-1; n++) if(!letter(bp[n])) n0 = n; if(!n0) n0 = CO-2; } (void) strncpy((tl = eos(toplines)), bp, n0); tl[n0] = '\0'; bp += n0; /* remove trailing spaces, but leave one */ while(n0 > 1 && tl[n0-1] == ' ' && tl[n0-2] == ' ') tl[--n0] = 0; n0 = strlen(bp); if(n0 && tl[0]) (void) strlcat(tl, "\n", toplines + sizeof toplines - tl); } redotoplin(); }
struct obj * mkobj(int let) { if(!let) let = mkobjstr[rn2(sizeof(mkobjstr) - 1)]; return( mksobj( letter(let) ? CORPSE + ((let > 'Z') ? (let-'a'+'Z'-'@'+1) : (let-'@')) : probtype(let) ) ); }
vector<string> letterCombinations(string digits) { string memory[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; vector<string> result; string tempResult(digits.size(), '0'); if(digits.size() == 0) return result; letter(result, tempResult, digits, memory, 0, digits.size()); return result; }
void AddWordDialog::on_buttonBox_accepted() { int iLength = ui->lineEdit->text().length(); int iX = ui->spinBox->value(); int iY = ui->spinBox_2->value(); for(int i=0;i<iLength;i++, iX+=4) { char cChar = ui->lineEdit->text().at(i).toLatin1(); Letter letter(cChar, iX, iY, EFONT_3x6); letter.vLetterToFrame(p_pFrameManager->pGetCurrentFrame(), ui->checkBox->isChecked()); } }
/* `Parsea` los comandos y argumentos*/ void parse_input() { /* Vacia **totalmente** los arrays donde se almacenan los comandos y args. */ empty(command, command_size); empty(args, args_size); empty(args2, args_size); if(!ENABLETYPE3PARSER) { /* Copia por longitud. No funciona en ejercicios con mas de dos args. */ memcpy(&command, &raw_input, 8*sizeof(char)); memcpy(&args, &(raw_input[9]), 100*sizeof(char)); } else { /* Parser de tipo 3 que ignora espacios o tabulaciones tanto iniciales, como finales o intemedias y separa la entrada en un comando y uno o dos argumentos */ int state = 0; char *rawinput_copy = raw_input; char buffer; int index = 0; while(*rawinput_copy){ buffer = (char) *rawinput_copy; if(letter(buffer) && (state==0 || state==1)) { command[index] = buffer; ++index; state = 1; } if(!letter(buffer) && state==1) { state = 2; index = 0; } if(letter(buffer) && (state==2 || state == 3)) { args[index] = buffer; ++index; state = 3; } if(!letter(buffer) && state==3) { state = 4; index = 0; } if(letter(buffer) && (state==4 || state==5)) { args2[index] = buffer; ++index; state = 5; } if(!letter(buffer) && state==5) { state = 6; } ++rawinput_copy; } } /*lastcalledcommand = (int)(command[7]) - '0';*/ debug(command); debug(args); debug(args2); /* Resetea el buffer de entrada */ empty(raw_input, raw_input_size); }