void setOnly(Char *line_) { Char line[256]; short num, num1, num2, l; Char s[256]; Char STR1[256]; strcpy(line, line_); if (*line == '\0') return; if (startsWithIgnoreCase(line, "only")) GetNextWord(STR1, line, colon_, dummy); for (l = 0; l <= lines_in_paragraph - 1; l++) omit_line[l] = true; do { GetNextWord(s, line, blank_, comma_); if (*s == '\0') return; curtail(s, comma_); if (pos1('-', s) == 0) { getNum(s, &num); if (num > 0 && num <= lines_in_paragraph) omit_line[num-1] = false; else warning("Invalid line number in Only: is skipped", print); } else { getTwoNums(s, &num1, &num2); if (num1 > 0 && num2 <= lines_in_paragraph) { for (num = num1 - 1; num <= num2 - 1; num++) omit_line[num] = false; } else warning("Invalid line range in Only: is skipped", print); } } while (true); }
int CheckSubList(int code) { if(GetNextWord()[0]=='.') { return StrInList(GetNextWord(),szPreprocess[code].members); } else { error(ERR_PREPROCESSSUB,szPreprocess[code].label,szTemp); return -1; } }
Static void setVoices(Char *line) { short k; Char s[256], w[256]; Char STR1[256]; short FORLIM; nvoices = 0; nstaves = 0; do { GetNextWord(s, line, blank_, dummy); if (*s != '\0') { nstaves++; k = 0; first_on_stave[nstaves-1] = nvoices + 1; do { GetNextWord(w, s, blank_, comma_); curtail(w, comma_); if (*w != '\0') { k++; if (k <= 2) { nvoices++; checkLabel(w); strcpy(voice_label[nvoices-1], w); if (*instr_name[nstaves-1] == '\0') { strcpy(instr_name[nstaves-1], w); /* p2c: preamble.pas, line 266: * Note: Possible string truncation in assignment [145] */ } setStavePos(nvoices, nstaves, k); } } } while (*w != '\0'); if (k > 2) { sprintf(STR1, "More than two voices per stave: %s", s); error(STR1, print); } if (k == 2) { sprintf(instr_name[nstaves-1], "\\mtxTwoInstruments{%s}{%s}", voice_label[nvoices-2], voice_label[nvoices-1]); /* p2c: preamble.pas, line 273: * Note: Possible string truncation in assignment [145] */ } number_on_stave[nstaves-1] = k; } } while (*line != '\0'); FORLIM = nvoices; for (k = 0; k <= FORLIM - 1; k++) selected[k] = true; }
BOOL ReadObjHeader(LPSTR lpFileName, LPINT lpDataType, LPTIFFHEADER lpHeader ) /************************************************************************/ { int ifh; LPLONG lngptr; LPWORD shtptr; int nObjects; WORD wBytes, wByteOrder, wVersion; long lObjSize, lObjStart; LONG lDataOffset; BOOL bRet = FALSE; if ( (ifh = _lopen(lpFileName, OF_READ)) < 0) { Message( IDS_EOPEN, lpFileName ); return( FALSE ); } // Read in header info wBytes = OBJ_HDR_SIZE; if ( _lread(ifh, LineBuffer[0], wBytes) != wBytes ) goto BadRead; shtptr = (LPWORD)LineBuffer[0]; wByteOrder = GetNextWord(&shtptr); /* byte order is LSB,MSB */ wVersion = GetNextWord(&shtptr); /* Version Number */ nObjects = GetNextWord(&shtptr); /* Number of Objects */ lngptr = (LPLONG)shtptr; lObjSize = GetNextLong(&lngptr); /* size of object data */ lObjStart = GetNextLong(&lngptr); /* start of object data */ _llseek (ifh, lObjStart, 0); wBytes = (WORD)lObjSize; if ( _lread(ifh, LineBuffer[0], wBytes) != wBytes ) goto BadRead; shtptr = (LPWORD)LineBuffer[0]; shtptr += 8; // Obj data shtptr++; // Data type shtptr += 5; // lpOffsets before lDataOffset lngptr = (LPLONG)shtptr; lDataOffset = *lngptr; _llseek (ifh, lDataOffset, 0); bRet = ReadTiffHeader( ifh, lpFileName, -1, lpDataType, NO/*bReadOnly*/, lpHeader ); BadRead: _lclose(ifh); return( bRet ); }
int CParseString::Parse2(CString& item1, CString& item2, CString separ) { Init(separ); GetNextWord(item1); GetTail(item2); return (!item1.IsEmpty()) + (!item2.IsEmpty()); }
Char *NextWord(Char *Result, Char *s_, Char Delim, Char Term) { Char s[256]; strcpy(s, s_); return (GetNextWord(Result, s, Delim, Term)); }
Static void setSize(Char *line_) { Char line[256]; stave_index0 i = 0; Char word[256]; stave_index0 FORLIM; strcpy(line, line_); while (i < ninstr) { GetNextWord(word, line, blank_, dummy); if (*word == '\0') break; i++; getNum(word, &musicsize); stave_size[i-1] = musicsize; } if ((unsigned)musicsize >= 32 || ((1L << musicsize) & 0x110000L) == 0) { FORLIM = ninstr; for (i = 0; i <= FORLIM - 1; i++) { if (stave_size[i] == unspec) stave_size[i] = musicsize; } } if (musicsize < 16) musicsize = 16; else if (musicsize > 20) musicsize = 20; }
BString ParseArgvZeroFromString(const char* command) { char* ret = NULL; // make our own copy of the string... int slen = strlen(command); // need an extra nul byte to get GetNextWord() to stop char* cmd = new char[slen + 2]; strcpy(cmd, command); cmd[slen + 1] = '\0'; // zero out the second nul byte GunkSpaces(cmd); RemoveQuotes(cmd); char* beginWord = NULL, *endWord = cmd - 1; if (GetNextWord(&beginWord, &endWord)) { ret = new char[strlen(beginWord) + 1]; strcpy(ret, beginWord); UnGunk(ret); } delete [] cmd; BString retStr(ret?ret:""); delete [] ret; return retStr; }
int CParseString::GetParseNum(CString separ) { Init(separ); CString word; int num = 0; while (GetNextWord(word)) num++; return num; }
int CParseString::Parse(CStringArray& array, CString separ) { Init(separ); CString word; array.RemoveAll(); while (GetNextWord(word)) array.Add(word); return (int)array.GetSize(); }
Token Lexer::nextToken() { string stringBuffer = GetNextWord(); CheckNumberOnLength(stringBuffer); Symbol tokenType = tokenRecognizer.TokenTypeByTokensValue(stringBuffer); Token token = Token(tokenType, stringBuffer, line); return token; }
Local void addChords(struct LOC_processLine *LINK) { struct LOC_addChords V; Char w[256]; short j = 1; short mus_line; paragraph_index0 chord_line; boolean arpeggio; Char STR1[256]; short FORLIM; V.LINK = LINK; saveStatus(LINK->voice); getChordTies(LINK->voice, V.pitches, V.labels); *LINK->chords = '\0'; chord_line = chordLineNo(LINK->voice); if (chord_line == 0) LINK->no_chords = true; if (LINK->no_chords) return; GetNextWord(w, P[chord_line-1], blank, dummy); sprintf(STR1, "%c", barsym); if (!strcmp(w, STR1) || *w == '\0') LINK->no_chords = true; sprintf(STR1, "%c", tilde); if (!strcmp(w, STR1) || LINK->no_chords) return; mus_line = line_no; line_no = orig_line_no[chord_line-1]; arpeggio = (w[0] == '?'); if (arpeggio) { strcpy(LINK->chords, " ?"); predelete(w, 1); } *V.nt = '\0'; while (j <= strlen(w)) { if (w[j-1] == '{' || strcmp(V.nt, "{") && w[j-1] >= 'a' && w[j-1] <= 'g') outChord(&V); else if (w[j-1] == chord_flat) w[j-1] = 'f'; else if (w[j-1] == chord_left) w[j-1] = 'e'; sprintf(V.nt + strlen(V.nt), "%c", w[j-1]); j++; } if (*V.nt != '\0') outChord(&V); if (arpeggio) strcat(LINK->chords, " ?"); strcat(LINK->note, LINK->chords); FORLIM = strlen(V.labels); for (j = 0; j <= FORLIM - 1; j++) { if (V.labels[j] != ' ') error("Tie on chord note started but not finished", print); } line_no = mus_line; }
boolean startsWithBracedWord(Char *P_) { Char P[256]; Char w[256]; strcpy(P, P_); GetNextWord(w, P, blank, dummy); return (w[0] == '{' && w[strlen(w) - 1] == '}'); }
BOOL FASTCALL PreprocessInterrupt(int code) { FUNC *func; U8 *oldPtr; GetNextWord(); if(PRECOMPILING) return TRUE; if( (func=FindFunction(functions, szTemp)) == NULL || func->type != FUNCTYPE_INTERRUPT) { error(ERR_INTERRUPTNAMEEXP,szTemp); return FALSE; } if(FUNCFLAG_GETTYPE(func->flags) != code) { error(ERR_INTERRUPTTYPE, func->label, szIntTypes[code], szIntTypes[FUNCFLAG_GETTYPE(func->flags)]); return FALSE; } func->flags |= FUNCFLAG_USED; CheckRomBank(); if(curBank->maxsize<6){//curBank->maxsize+curBank->org<0xFFFA) { error(ERR_CURBANKINTERRUPTSMALL,curBank->label); return TRUE; } oldPtr = curBank->ptr; curBank->end = curBank->buffer+curBank->maxsize-6; switch(code) { case PREPROCESS_INTERRUPT_NMI: //if(curBank->ptr > curBank->end-6) // error(ERR_CURBANKINTERRUPTOVER,curBank->label); BankSeek(curBank->maxsize-6);//0xFFFA-curBank->org); break; case PREPROCESS_INTERRUPT_START: //if(curBank->ptr > curBank->end-4) // error(ERR_CURBANKINTERRUPTOVER,curBank->label); BankSeekIntVect(curBank->maxsize-4);//0xFFFC-curBank->org); break; case PREPROCESS_INTERRUPT_IRQ: //if(curBank->ptr > curBank->end-2) // error(ERR_CURBANKINTERRUPTOVER,curBank->label); BankSeekIntVect(curBank->maxsize-2);//0xFFFE-curBank->org); break; } AddFixOffs(FIXTYPE_FUNCTION,FIXOFFS_FAR,curBank->ptr,0,func); BankWriteIntVect(0); curBank->ptr = oldPtr; return TRUE; }
void vInstall(char *cmd) { char name[MAXREGPATHLEN+1]; char path[MAXREGPATHLEN+1]; char ver[MAXREGPATHLEN+1]; char *pPath, *pVer; cmd = GetNextWord(cmd, name); cmd = GetNextWord(cmd, ver); cmd = GetNextWord(cmd, path); pVer = ( ver[0] != '*' ) ? ver : NULL; pPath = ( path[0] != '*' ) ? path : NULL; error("VR_Install", VR_Install(name, pPath, pVer, FALSE)); } /* vInstall */
void addUptext(short voice_, boolean *no_uptext, Char *pretex) { struct LOC_addUptext V; Char font[256]; static Char lcz[4] = "lcz"; uptext_info *WITH; Char STR1[256], STR2[256], STR3[256]; V.voice = voice_; WITH = &U[V.voice-1]; if (WITH->uptext == 0) *no_uptext = true; if (*no_uptext) return; do { GetNextWord(V.w, P[WITH->uptext - 1], blank, dummy); sprintf(STR1, "%c", barsym); if (!strcmp(V.w, STR1) || *V.w == '\0') *no_uptext = true; sprintf(STR1, "%c", tilde); if (!strcmp(V.w, STR1) || *no_uptext) return; if (V.w[0] == '!') { strcpy(WITH->uptext_font, V.w); WITH->uptext_font[0] = '\\'; } if (V.w[0] == '@') adjustUptext(&V); } while (V.w[0] == '!'); /* ! is a kludge, will get me in trouble later */ strcpy(font, WITH->uptext_font); textTranslate(V.w, font); if (*font != '\0') sprintf(V.w, "%s{%s}", font, strcpy(STR1, V.w)); switch (lcz[WITH->uptext_lcz - 1]) { case 'l': sprintf(V.w, "\\mtxLchar{%s}{%s}", toString(STR1, default_ + WITH->uptext_adjust), strcpy(STR3, V.w)); break; case 'c': sprintf(V.w, "\\mtxCchar{%s}{%s}", toString(STR1, default_ + WITH->uptext_adjust), strcpy(STR2, V.w)); break; case 'z': sprintf(V.w, "\\mtxZchar{%s}{%s}", toString(STR1, default_ + WITH->uptext_adjust), strcpy(STR3, V.w)); break; } strcat(pretex, V.w); }
void vCreate(char *cmd) { /* Syntax: Create [new,] 5.0b1 */ char buf[512]; int flag = 0; cmd = GetNextWord(cmd, buf); error("VR_CreateRegistry", VR_CreateRegistry("Communicator", buf, cmd)); } /* vCreate */
LPCTSTR CRichEditSpellCheck::GetFirstWord() const { m_crCurrentWord.cpMin = m_crCurrentWord.cpMax = -1; m_sLeftover.Empty(); m_sCurrentWord.Empty(); // make sure text is current m_sText.Empty(); GetReferenceTextBeingChecked(); // start return GetNextWord(); }
Static line_type doCommand(Char *line_) { line_type Result; Char line[256]; Char command[256]; command_type last_command; boolean starts_with_note; Char STR1[256], STR3[256]; strcpy(line, line_); if (line[0] == comment && !isAssertion(line)) return comment_line; starts_with_note = maybeMusicLine(line); GetNextWord(command, line, blank_, colon_); sprintf(STR1, "%c", colon_); if (endsWith(command, STR1)) { last_command = findCommand(command); Result = command_line; if (last_command == enable) doEnable(line, true); else if (last_command == disable) doEnable(line, false); else if (last_command == range) orig_range_line = line_no; if (last_command != none) { if (mustAppend(last_command) && redefined[(long)last_command]) sprintf(cline[(long)last_command] + strlen(cline[(long)last_command]), "\n%s", line); else { strcpy(cline[(long)last_command], line); if (warn_redefine && redefined[(long)last_command]) { sprintf(STR3, "You have redefined preamble command %s", command); warning(STR3, print); } } if (last_command == start) strcpy(start_line, line); redefined[(long)last_command] = true; return Result; } Result = colon_line; sprintf(STR3, "%s%c %s", command, colon_, line); addStyle(STR3); orig_style_line[known_styles-1] = line_no; return Result; } else if (starts_with_note) return plain_line; else return unknown; return Result; }
Static void setName(void) { short i, FORLIM; if (!redefined[(long)name]) return; setFeature("instrumentNames", true); FORLIM = ninstr; for (i = 0; i <= FORLIM - 1; i++) { GetNextWord(instr_name[i], cline[(long)name], blank_, dummy); /* p2c: preamble.pas, line 226: * Note: Possible string truncation in assignment [145] */ } }
EXPORT_C TInt CScriptFile::GetNextWord(TLex& aInput, TChar aDelimiter, TInt& aOutput) { aOutput = 0; TPtrC string; TInt err = GetNextWord(aInput, aDelimiter, string); if (!err) { TLex number(string); err = number.Val(aOutput); } return err; }
Char *startString(Char *Result, voice_index0 voice) { Char s[256], w[256]; voice_index j; strcpy(s, start_line); for (j = 1; j <= voice; j++) GetNextWord(w, s, dummy, ';'); curtail(w, ';'); if (*w != '\0') { sprintf(Result, "%s ", w); return Result; } else return strcpy(Result, w); }
Static void doEnable(Char *line, boolean choice) { Char word[256]; Char STR1[256]; do { GetNextWord(word, line, blank_, dummy); if (*word != '\0') { if (!setFeature(word, choice)) { sprintf(STR1, "No such feature: %s", word); error(STR1, !print); } } } while (*word != '\0'); }
void vCreate(char *cmd) { // Syntax: Create [new,] 5.0b1 char buf[64]; int flag = 0; cmd = GetNextWord(cmd, buf); if (stricmp(buf, "NEW,") == 0) { flag = CR_NEWREGISTRY; } error("VR_CreateRegistry", VR_CreateRegistry(flag, cmd)); } // vCreate
int main (void) { int pos; while (1) { word = GetNextWord(); if ( 0 == word.length() ) { DumpDictionary(dictionary,count); break; } if ((pos = LocateWord(dictionary,word)) >= 0 ) count[pos]++; else if (!InsertWord(dictionary,word)) cout << "dictionary full " << word << " cannot be added\n"; } return 0; }
Static void setClefs(Char *line_) { Char line[256]; Char s[256]; strcpy(line, line_); nclefs = 0; do { GetNextWord(s, line, blank_, dummy); if (*s != '\0') { nclefs++; if (strlen(s) == 1) clef[nclefs-1] = s[0]; else clef[nclefs-1] = s[1]; } } while (*s != '\0'); }
int main (void) { ENTRY *pos; while (1) { word = GetNextWord(); if ( word.empty() ) { DumpDictionary(dictionary); break; } if ((pos = LocateWord(dictionary,word)) > 0 ) pos->count++; else if (!InsertWord(dictionary,word)) cout << "dictionary full" << word << "cannot be added\n"; } delete pos; return 0; }
int FASTCALL PreprocessCheckYesNo(BOOL *_PREP_OK) { int val = 0; if(GetNextWord()[0]=='"') { if(DoString()) { if((val=StrInStrint(szString, siYesNo))==-1) error(ERR_UNKREQUEST,szString); else { val = siYesNo[val].index; *_PREP_OK = TRUE; } } } else if(IsStrNum(szTemp)) { val = ConfirmChar(StrToInt(szTemp)); *_PREP_OK = TRUE; } else error(ERR_INTEXP); return val; }
//*********************************************************************** int CParser::GetNextToken() // return next token in the script //*********************************************************************** { if (!m_lpScript) return I_EOF; int i; int wWordLen, wLen; pCParseToken pToken; LPSTR pWord; if (wWordLen = GetNextWord()) { pWord = m_lpScript; // the word it just located m_lpScript += wWordLen; // just after this word for (i=0; (pToken = &TokenList[i]) && pToken->GetID(); i++) { LPSTR lpToken = pToken->GetToken(); wLen = pToken->GetTokenLen(); if ((wWordLen == wLen) && (_fstrnicmp(lpToken, pWord, wLen) == 0)) { BOOL bResult = TRUE; for (int q=0; bResult && q<pToken->GetParams(); q++) bResult = GetNextNum(&m_Params[q]); if (!bResult) RecordError(pToken, ERR_INSUF); return bResult ? pToken->GetID() : NULL; // found one. } } // cannot find that command char command[100]; command[0] = 0; lstrcpyn(command, pWord, wWordLen+1); CParseToken Dummy((LPSTR)command, 0, 0); RecordError(&Dummy, ERR_UNKNOWN); return NULL; } // no more words in the script return I_EOF; }
eXMLParserError CIwGameXmlParser::ParseAttributes(const char* data, int count, CIwGameXmlNode* node) { while (count > 0) { // Get attribute name int offset; int len = GetNextWord(data, offset); char c = *(data + offset); if (len <= 0 || c == '/' || c == '>') return eXMLParserError_None; CIwGameXmlAttribute* attrib = AllocAttribute(); //memcpy(str, data + offset, len); //str[len] = 0; //sprintf(str2, "Attrib name %s, ", str); //s3eDebugOutputString(str2); attrib->setName((char*)data + offset, len); node->AddAttribute(attrib); data += len + 1 + offset; count -= len + 1 + offset; if (count <= 0) return eXMLParserError_InvalidTag; // Get attribute value len = GetNextQuotedWord(data, offset); if (len < 0) return eXMLParserError_InvalidTag; //memcpy(str, data + offset, len); //str[len] = 0; //sprintf(str2, "Attrib value %s\n", str); //s3eDebugOutputString(str2); attrib->setValue((char*)data + offset, len); data += len + 2 + offset; count -= len + 2 + offset; if (count <= 0) return eXMLParserError_InvalidTag; } return eXMLParserError_None; }