Esempio n. 1
0
static int lineCountIndent(FILE *file, struct gcontext *gc) {
    int ch;

    while ( (ch=getc(file))!=EOF && ch!='\n' && ch!='\r' );
    if ( ch!=EOF )
	++gc->lineno;
    if ( ch=='\r' ) {
	ch = getc(file);
	if ( ch!='\n' )
	    ungetc(ch,file);
    }
return( gc->found_indent = countIndent(file));
}
Esempio n. 2
0
void LoadGroupList(void) {
    char *groupfilename;
    FILE *groups;
    struct gcontext gc;

    groupfilename = getPfaEditGroups();
    if ( groupfilename==NULL )
return;
    groups = fopen(groupfilename,"r");
    if ( groups==NULL )
return;
    memset(&gc,0,sizeof(gc));
    gc.found_indent = countIndent(groups);
    group_root = _LoadGroupList(groups,NULL,0,&gc);
    if ( !feof(groups))
	LogError( _("Unparsed characters found after end of groups file (last line parsed was %d).\n"), gc.lineno );
    fclose(groups);
}
Esempio n. 3
0
QString toSQLParse::indent(const QString &str/*SQLITEMAN, toSyntaxAnalyzer &syntax*/)
{
	stringTokenizer tokenizer(str/*SQLITEMAN, syntax*/);
	std::list<toSQLParse::statement> blk = parse(tokenizer);
	int pos = 0;
	int level = countIndent(str, pos);

	QString ret;
	for (std::list<toSQLParse::statement>::iterator i = blk.begin();
			i != blk.end();
			i++)
	{
		ret += indentStatement(*i, level/*SQLITEMAN, syntax*/);
	}
	pos = ret.length();
	while (pos > 0 && ret[pos - 1].isSpace())
	{
		pos--;
	}
	return ret.mid(0, pos) + ("\n");
}