void LyXLex::printTable()
{
lyxerr << "\nNumber of tags: " << no_items << endl;
- for(int i=0; i<no_items; i++)
+ for(int i= 0; i<no_items; i++)
lyxerr << "table[" << i
<< "]: tag: `" << table[i].tag
<< "' code:" << table[i].code << endl;
int LyXLex::lex()
{
//NOTE: possible bug.
- if (next() && status==LEX_TOKEN)
+ if (next() && status == LEX_TOKEN)
return search_kw(buff);
else
return status;
bool LyXLex::EatLine()
{
- int i=0;
+ int i= 0;
int c = '\0'; // getc() returns an int
- while (!feof(file) && c!='\n' && i!=(LEX_MAX_BUFF-1)) {
+ while (!feof(file) && c!= '\n' && i!= (LEX_MAX_BUFF-1)) {
c = getc(file);
if (c != '\r')
buff[i++] = c;
}
- if (i==(LEX_MAX_BUFF-1) && c !='\n') {
+ if (i == (LEX_MAX_BUFF-1) && c != '\n') {
printError("Line too long");
c = '\n'; // Pretend we had an end of line
--lineno; // but don't increase line counter (netto effect)
++i; // and preserve last character read.
}
- if (c=='\n') {
+ if (c == '\n') {
++lineno;
buff[--i] = '\0'; // i can never be 0 here, so no danger
status = LEX_DATA;
int LyXLex::search_kw(char const * const tag) const
{
- int m, k=0 , l= 0, r=no_items;
+ int m, k= 0 , l= 0, r= no_items;
while (l < r) {
m = (l+r)/2;
if (table[m].tag)
k = compare_no_case(table[m].tag, tag);
- if (k==0)
+ if (k == 0)
return table[m].code;
else
if (k<0) l = m+1; else r = m;
status = 0;
while (!feof(file) && !status) {
c = getc(file);
- if (c=='#') {
+ if (c == '#') {
// Read rest of line (fast :-)
fgets(buff, sizeof(buff), file);
++lineno;
continue;
}
- if (c=='\"') {
+ if (c == '\"') {
int i = -1;
do {
c = getc(file);
if (c != '\r')
buff[++i] = c;
- } while (c!='\"' && c!='\n' && !feof(file) &&
- i!=(LEX_MAX_BUFF-2));
+ } while (c!= '\"' && c!= '\n' && !feof(file) &&
+ i!= (LEX_MAX_BUFF-2));
- if (i==(LEX_MAX_BUFF-2)) {
+ if (i == (LEX_MAX_BUFF-2)) {
printError("Line too long");
c = '\"'; // Pretend we got a "
++i;
}
- if (c!='\"') {
+ if (c!= '\"') {
printError("Missing quote");
- if (c=='\n')
+ if (c == '\n')
++lineno;
}
break;
}
- if (c==',')
+ if (c == ',')
continue; /* Skip ','s */
if (c > ' ' && !feof(file)) {
status = LEX_TOKEN;
}
- if (c== '\r' && !feof(file)) {
+ if (c == '\r' && !feof(file)) {
// The Windows support has lead to the
// possibility of "\r\n" at the end of
// a line. This will stop LyX choking
c = getc(file);
}
- if (c=='\n')
+ if (c == '\n')
++lineno;
}
c = getc(file);
// skip ','s
- if (c==',') continue;
+ if (c == ',') continue;
- if (c=='\\') {
+ if (c == '\\') {
// escape
int i = 0;
do {
continue;
}
- if (c=='#') {
+ if (c == '#') {
// Read rest of line (fast :-)
fgets(buff, sizeof(buff), file);
++lineno;
}
// string
- if (c=='\"') {
+ if (c == '\"') {
int i = -1;
bool escaped = false;
do {
buff[++i] = c;
if (!escaped && c == '\"') break;
- } while (c!='\n' && !feof(file) &&
- i!=(LEX_MAX_BUFF-2));
+ } while (c!= '\n' && !feof(file) &&
+ i!= (LEX_MAX_BUFF-2));
- if (i==(LEX_MAX_BUFF-2)) {
+ if (i == (LEX_MAX_BUFF-2)) {
printError("Line too long");
c = '\"'; // Pretend we got a "
++i;
}
- if (c!='\"') {
+ if (c!= '\"') {
printError("Missing quote");
- if (c=='\n')
+ if (c == '\n')
++lineno;
}
}
// new line
- if (c=='\n')
+ if (c == '\n')
++lineno;
}
printError("Line too long");
}
- if (c == '\\') ungetc(c,file); // put it back
+ if (c == '\\') ungetc(c, file); // put it back
buff[i] = '\0';
status = LEX_TOKEN;
}
- if (c=='\n')
+ if (c == '\n')
++lineno;
}