8 for(
int i=0;
i<cshList.size();
i++) {
11 cout <<
"ifile : " << ifile.Data() << endl;
12 if(script!=
"")
if(!ifile.Contains(script))
continue;
16 if (!in.good()) {cout <<
"Error Opening File : " << ifile.Data() << endl;
exit(1);}
19 ofile.ReplaceAll(
".csh",
".sh");
20 cout <<
"ofile : " << ofile.Data() << endl;
24 if (!out.good()) {cout <<
"Error Opening File : " << ofile.Data() << endl;
exit(1);}
28 in.getline(istring,1024);
29 if (!in.good())
break;
31 if(ostring.Contains(
"_SKIP_CSH2SH_")) {
32 out << ostring.Data() << endl;
35 if(!ostring.Contains(
"_SKIP_csh2sh_")) ostring.ReplaceAll(
".csh",
".sh");
36 ostring.ReplaceAll(
"endif",
"fi");
37 ostring.ReplaceAll(
"unsetenv",
"unset");
38 ostring.ReplaceAll(
"#!/bin/tcsh",
"#!/bin/bash");
41 if(ostring.Contains(
"if")&&ostring.Contains(
"(")&&ostring.Contains(
")")) {
43 for(
int j=0;
j<ostring.Sizeof();
j++)
if(ostring[
j]==
'(') {
if(tag) tag=
false;
else ostring[
j]=
' ';}
45 for(
int j=ostring.Sizeof()-1;
j>=0;
j--)
if(ostring[
j]==
')') {
if(tag) tag=
false;
else ostring[
j]=
' ';}
50 ostring.ReplaceAll(
"! $?",
"-z $");
52 ostring.ReplaceAll(
"$1 == \'\'",
"-z $1");
53 ostring.ReplaceAll(
"$2 == \'\'",
"-z $2");
54 ostring.ReplaceAll(
"$2 != \'\'",
"-n $2");
55 ostring.ReplaceAll(
"$3 == \'\'",
"-z $3");
56 ostring.ReplaceAll(
"$3 != \'\'",
"-n $3");
57 ostring.ReplaceAll(
"(",
"[ ");
58 ostring.ReplaceAll(
"==",
"=");
59 ostring.ReplaceAll(
"\'",
"\"");
60 ostring.ReplaceAll(
")",
" ]");
61 ostring.ReplaceAll(
" then",
"; then");
62 if(ostring.ReplaceAll(
"\"$PATH\" !~",
"! $PATH =~"))
63 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
64 if(ostring.ReplaceAll(
"\"$LD_LIBRARY_PATH\" !~",
"! $LD_LIBRARY_PATH =~"))
65 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
66 if(ostring.ReplaceAll(
"\"$PYTHONPATH\" !~",
"! $PYTHONPATH =~"))
67 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
68 if(ostring.ReplaceAll(
"\"$INFOPATH\" !~",
"! $INFOPATH =~"))
69 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
70 ostring.ReplaceAll(
"*",
"");
71 ostring.ReplaceAll(
" !~ ",
" != ");
74 TRegexp re4(
"set.*=.*\".*setenv.*$");
75 if(ostring.Contains(re4)) {
76 ostring.ReplaceAll(
"setenv ",
"export ");
77 ostring.ReplaceAll(
"set ",
"");
78 ostring.ReplaceAll(
"$",
"= $");
79 ostring.ReplaceAll(
" ",
"");
80 ostring.ReplaceAll(
"\"export",
"\"export ");
81 out << ostring.Data() << endl;
85 ostring.ReplaceAll(
"exit",
"return 0");
86 ostring.ReplaceAll(
"setenv",
"export");
87 ostring.ReplaceAll(
"\t",
" ");
88 ostring.ReplaceAll(
"else if",
"elif");
91 for(
int j=0;
j<ostring.Sizeof();
j++)
if(ostring[
j]==
' ') iblanks++;
else break;
92 if(!ostring.Contains(
"$#"))
if(ostring.First(
"#")>0) ostring.Remove(ostring.First(
"#"));
93 if((ostring.Contains(
"export")&&!ostring.Contains(
"unexport"))||ostring.Contains(
"alias")){
96 for(
int j=0;
j<token->GetEntries();
j++){ tok[
j]=(TObjString*)token->At(
j);}
97 ostring = tok[0]->GetString()+
" "+tok[1]->GetString()+
"="+tok[2]->GetString();
99 if(token->GetEntries()>3){
for(
int j=3;
j<token->GetEntries();
j++)
100 {ostring.Append(
" ");ostring.Append(tok[
j]->
GetString());}}
103 TRegexp re1(
"set.*=.*basename");
104 if(ostring.Contains(re1)) {
105 ostring.ReplaceAll(
"set",
"");
106 ostring.ReplaceAll(
" ",
"");
107 ostring.ReplaceAll(
"basename",
"basename ");
110 TRegexp re2(
"set.*=.*$");
111 if(ostring.Contains(re2)&&!ostring.Contains(
"alias")) {
112 ostring.ReplaceAll(
"set",
"");
116 TRegexp re3(
"@.*[-=+*:].*[0-9]");
117 if(ostring.Contains(re3)) {
118 ostring.ReplaceAll(
"@",
"(( ");
119 ostring = ostring+
" ))";
122 for(
int j=0;
j<iblanks;
j++) out <<
" ";
123 out << ostring.Data() << endl;
138 int index =
string.Index(t);
141 for(
int j=index+1;
j<
string.Sizeof();
j++) {
if(
string[
j]==
'$')
break; pat+=
" ";}
143 string.ReplaceAll(pat,pat0);
150 TString wdir = gSystem->WorkingDirectory();
151 TSystemDirectory gdir(
"", dir_name);
152 TList *dfiles = gdir.GetListOfFiles();
159 while ((dfile = (TSystemFile*)dnext())) {
160 fname = dfile->GetName();
161 sprintf(path,
"%s/%s",dir_name.Data(),fname.Data());
163 if ((endString!=
"")&&!fname.EndsWith(endString)) fsave=
false;
164 if ((beginString!=
"")&&!fname.BeginsWith(beginString)) fsave=
false;
165 if(fsave) fileList.push_back(path);
168 gSystem->ChangeDirectory(wdir);
wavearray< double > t(hp.size())
cout<< "baudline_FFL : "<< baudline_FFL<< endl;ofstream out;out.open(baudline_FFL, ios::out);if(!out.good()){cout<< "Error Opening File : "<< baudline_FFL<< endl;exit(1);}ifstream in;in.open(frFiles[ifoID], ios::in);if(!in.good()){cout<< "Error Opening File : "<< frFiles[ifoID]<< endl;exit(1);}TString pfile_path="";char istring[1024];while(1){in > istring
void cwb_csh2sh(TString script="")
vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="")
TString RemoveMultipleBlank(TString string, TString left, TString right)
cout<< "Starting reading output directory ..."<< endl;vector< TString > fileList
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)