예제 #1
0
/*******************************************************************
*
* CSVRead
*
*******************************************************************/
string CSVload::Read()
{
	if( !IsFile() ){ return ""; }
	string result = "";
	bool SkipStanbyFlag = false;

	while(!IsEof()){
		//エスケープシーケンススキップ
		if(IsEscapeSequence())
		{
			CharGet();//一文字飛ばす
			continue;
		}
		//デミリター文字か改行なら
		if(IsDemiliter()){
			CharGet();//一文字飛ばす
			break;
		}

		char c = CharGet();//1文字取得する

		if(c == '/'){//スラッシュがあれば
			if(SkipStanbyFlag){//前の文字もスラッシュだったら
				LineSkip();//改行までループ
				result = "";//中身をリセット
				SkipStanbyFlag = false;
				continue;
			}
			SkipStanbyFlag = true;//スキップスタンバイ
		}else{
			SkipStanbyFlag = false;
		}
		result += c;//文字を追加する
	}

	if( result == "" && !IsEof() ){ //もしも、文字列の中身がないならもう一度試行する
		result = Read(); 
	}

	return result;
}
예제 #2
0
파일: edit-sgml.c 프로젝트: Ionic/nx-libs
static void
DoReplace (FILE *f, ReplaceSet *s)
{
    int		c;
    String	*tag;
    Replace	*r;
    SkipStack	*ss = 0;
    LoopStack	*ls = 0;
    int		skipping = 0;

    while ((c = getc (f)) != EOF)
    {
	if (c == '@')
	{
	    tag = StringNew ();
	    while ((c = getc (f)) != '@')
	    {
		if (c == EOF)
		    abort ();
		StringAdd (tag, c);
	    }
	    if (ls)
		StringAddString (tag, ls->extra->buf);
	    switch (tag->buf[0]) {
	    case '?':
		ss = SkipStackPush (ss, skipping);
		if (!ReplaceSetFind (s, tag->buf + 1))
		    skipping++;
		LineSkip (f);
		break;
	    case ':':
		if (!ss)
		    abort ();
		if (ss->skipping == skipping)
		    ++skipping;
		else
		    --skipping;
		LineSkip (f);
		break;
	    case ';':
		skipping = ss->skipping;
		ss = SkipStackPop (ss);
		LineSkip (f);
		break;
	    case '{':
		ls = LoopStackPush (ls, f, tag->buf + 1);
		LineSkip (f);
		break;
	    case '}':
		ls = LoopStackLoop (s, ls, f);
		LineSkip (f);
		break;
	    default:
		r = ReplaceSetFind (s, tag->buf);
		if (r && !skipping)
		    StringPut (stdout, r->text);
		break;
	    }
	    StringDispose (tag);
	}
	else if (!skipping)
	    putchar (c);
    }
}
예제 #3
0
파일: aDev.c 프로젝트: EmmanuelU/aDev
int main(int argc, char *argv[ ]){
	ClearPrints();
	chdir(CombineStrings("/home/", GetUser()));
	DelFile(output_log);
	DebugLog("--- Begin Android Dev Tools ARGS");
	for(tick = 1; tick < argc; tick++) DebugLog(CombineStrings("ARG: ", argv[tick]));
	DebugLog("");
	DebugLog("--- Begin Android Dev Tools");
	CmdOut("aDev_adb devices > tmp.txt");
	if(IsFileEmpty("tmp.txt")){
		ClearPrints();
		PrintText("--- Proprietary Files Not Found! ---");
		PrintText("Run: \'aDev config\'");
		LineSkip();
		exit(-1);		
	}
	DelFile("tmp.txt");
	if(argc <= 1){
		PrintText("--- Invalid parameters! ---");
		PrintText("Run: \'aDev --help\'");
		LineSkip();
		exit(-1);
	}
	for(tick = 1; tick < argc; tick++){
		if(IsStringEmpty(argv[tick])) continue;
		if(CompareStrings(argv[tick], "--help") || CompareStrings(argv[tick], "-h")){
			PrintHelp();
			exit(0);
		}
		if(CompareStrings(argv[tick], "--version") || CompareStrings(argv[tick], "-v")){
			PrintVersion();
			exit(0);
		}
		else if(CompareStrings(argv[tick], "test")){
			PrintText("aDev was properly installed, enjoy!");
			LineSkip();
			exit(0);
		}
		else if(CompareStrings(argv[tick], "logcat")){
			DevLog(1);
			exit(0);
		}
		else if(CompareStrings(argv[tick], "dmesg")){
			DevLog(2);
			exit(0);
		}
		else if(CompareStrings(argv[tick], "kmsg")){
			DevLog(3);
			exit(0);
		}
		else if(CompareStrings(argv[tick], "screenshot")){
			ScreenShot();
			exit(0);
		}
		else if(CompareStrings(argv[tick], "info")){
			Info();
			exit(0);
		}
		else if(CompareStrings(argv[tick], "adb")){
			text = "aDev_adb ";
			for(tick2 = 1; tick2 < argc; tick2++) if(!CompareStrings(argv[tick2], "adb")) text = CombineStrings(text, CombineStrings(argv[tick2], " "));
			CmdOut(text);
			exit(0);
		}
		else if(CompareStrings(argv[tick], "fastboot")){
			text = "aDev_fastboot ";
			for(tick2 = 1; tick2 < argc; tick2++) if(!CompareStrings(argv[tick2], "fastboot")) text = CombineStrings(text, CombineStrings(argv[tick2], " "));
			CmdOut(text);
			exit(0);
		}
		else{
			for(tick2 = (argc - 1); tick2 < 0; tick2--){
				if(!IsValidArg(argv[tick2])) break;
				if(tick2 == 1) quit();
			}
			if(IsValidArg(argv[tick2])) tick2--;
			if(IsValidArg(argv[tick2])) quit();
			PrintText(CombineStrings("Unknown Parameter: ", argv[tick2]));
			quit();
		}
	}
	return 0;
}