Ejemplo n.º 1
0
bool SpiceFile::createSpiceSubckt(QTextStream *stream)
{
    (*stream)<<"\n";
    QFile sub_file(getSubcircuitFile());
    if (sub_file.open(QIODevice::ReadOnly|QFile::Text)) {
        QTextStream ts(&sub_file);
        (*stream)<<ts.readAll().remove(QChar(0x1A));
        sub_file.close();
    }
    (*stream)<<"\n";
    return true;
}
Ejemplo n.º 2
0
QString SpiceFile::getSubcktName()
{
    QString s = "";

    QFile sub_file(getSubcircuitFile());
    if (sub_file.open(QIODevice::ReadOnly)) {
        QStringList lst = QString(sub_file.readAll()).split("\n");
        foreach (QString str, lst) {
            QRegExp subckt_header("^\\s*\\.(S|s)(U|u)(B|b)(C|c)(K|k)(T|t)\\s.*");
            if (subckt_header.exactMatch(str)) {
                QRegExp sep("\\s");
                s = str.section(sep,1,1,QString::SectionSkipEmpty);
            }
        }
int main(int argc, char *argv[])
/******************************************************************
 * Parse command line printing usage if it doesn't make sense.
 * Then go call subber on each file.
 ******************************************************************/
{
int i;
char *p;
int option;
char *sname = "subs.in";		/* file containing substitutions */

if (argc < 2)
	{
USAGE:
	puts("Subs - a utility to perform massive string substitutions on source");
	puts("Usage:  subs [options] file1 ... filen [options]");
	puts("Options:	-f file (get files to do subs on from file)");
	puts("          -s file (get substitutions to perform from file.");
	puts("                   by default subs looks for subs.in)");
	puts("          -r      (read only - don't write out substitutions)");
	puts("          -b      (don't create .bak files on changed files)");
	puts("          -e      (looks for embedded substrings as well as");
	puts("                   entire C symbols");
	puts("          -c char (use char as the separator in substitution");
	puts("                   file.  Only matters in embedded case.");
	puts("                   '|' by default.)");
	puts("          -i      (interactive query on each substitution.)");
	puts("The format of subs.in is oldstring<sep>newstring<cr>.");
	puts("In the normal case <sep> can be any white space and newstring");
	puts("is required.  In the embedded case <sep> defaults to '|' and");
	puts("if there is no newstring, oldstring will be eliminated.");
	puts("Hashing algorithm doesn't work for one character sub sources.");
	puts("There can be more than one substitution in the file.");
	puts("Subs does take wildcards in the list of files to substitute.");
	exit(0);
	}
for (i=1; i<argc; i++)
	{
	p = argv[i];
	if (p[0] == '-')
		{
		option = tolower(p[1]);
		switch (option)
			{
			case 'f':
				if (i >= argc-1)
					goto USAGE;
				sub_param_file(argv[++i]);
				break;
			case 's':
				if (i >= argc-1)
					goto USAGE;
				sname = argv[++i];
				break;
			case 'c':
				if (i >= argc-1)
					goto USAGE;
				separator = argv[++i][0];
				break;
			case 'b':
				backup = FALSE;
				break;
			case 'i':
				batch = FALSE;
				setvbuf(stdin, NULL, _IONBF, 0);
				break;
			case 'e':
				embedded = TRUE;
				break;
			case 'r':
				writeit = FALSE;
				break;
			default:
				goto USAGE;
			}
		}
	else if (!has_wild_parts(p))
		{
		add_sub_file(p);
		}
	}
build_sub_file(sname, embedded);
plist = reverse_list(plist);
while (plist != NULL)
	{
	sub_file(plist->name);
	plist = plist->next;
	}
return 0;
}