26 for(
int i=0;
i<cshList.size();
i++) {
29 cout <<
"ifile : " << ifile.Data() << endl;
30 if(script!=
"")
if(!ifile.Contains(script))
continue;
34 if (!in.good()) {cout <<
"Error Opening File : " << ifile.Data() << endl;
exit(1);}
37 ofile.ReplaceAll(
".csh",
".sh");
38 cout <<
"ofile : " << ofile.Data() << endl;
42 if (!out.good()) {cout <<
"Error Opening File : " << ofile.Data() << endl;
exit(1);}
46 in.getline(istring,1024);
47 if (!in.good())
break;
49 if(ostring.Contains(
"_SKIP_CSH2SH_")) {
50 out << ostring.Data() << endl;
53 if(!ostring.Contains(
"_SKIP_csh2sh_")) ostring.ReplaceAll(
".csh",
".sh");
54 ostring.ReplaceAll(
"endif",
"fi");
55 ostring.ReplaceAll(
"unsetenv",
"unset");
56 ostring.ReplaceAll(
"#!/bin/tcsh",
"#!/bin/bash");
59 if(ostring.Contains(
"if")&&ostring.Contains(
"(")&&ostring.Contains(
")")) {
61 for(
int j=0;
j<ostring.Sizeof();
j++)
if(ostring[
j]==
'(') {
if(tag) tag=
false;
else ostring[
j]=
' ';}
63 for(
int j=ostring.Sizeof()-1;
j>=0;
j--)
if(ostring[
j]==
')') {
if(tag) tag=
false;
else ostring[
j]=
' ';}
68 ostring.ReplaceAll(
"! $?",
"-z $");
70 ostring.ReplaceAll(
"$1 == \'\'",
"-z $1");
71 ostring.ReplaceAll(
"$2 == \'\'",
"-z $2");
72 ostring.ReplaceAll(
"$2 != \'\'",
"-n $2");
73 ostring.ReplaceAll(
"$3 == \'\'",
"-z $3");
74 ostring.ReplaceAll(
"$3 != \'\'",
"-n $3");
75 ostring.ReplaceAll(
"(",
"[ ");
76 ostring.ReplaceAll(
"==",
"=");
77 ostring.ReplaceAll(
"\'",
"\"");
78 ostring.ReplaceAll(
")",
" ]");
79 ostring.ReplaceAll(
" then",
"; then");
80 if(ostring.ReplaceAll(
"\"$PATH\" !~",
"! $PATH =~"))
81 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
82 if(ostring.ReplaceAll(
"\"$LD_LIBRARY_PATH\" !~",
"! $LD_LIBRARY_PATH =~"))
83 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
84 if(ostring.ReplaceAll(
"\"$MANPATH\" !~",
"! $MANPATH =~"))
85 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
86 if(ostring.ReplaceAll(
"\"$PYTHONPATH\" !~",
"! $PYTHONPATH =~"))
87 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
88 if(ostring.ReplaceAll(
"\"$INFOPATH\" !~",
"! $INFOPATH =~"))
89 {ostring.ReplaceAll(
" [ ",
" [[ ");ostring.ReplaceAll(
" ];",
" ]];");}
90 ostring.ReplaceAll(
"*",
"");
91 ostring.ReplaceAll(
" !~ ",
" != ");
94 TRegexp re4(
"set.*=.*\".*setenv.*$");
95 if(ostring.Contains(re4)) {
96 ostring.ReplaceAll(
"setenv ",
"export ");
97 ostring.ReplaceAll(
"set ",
"");
98 ostring.ReplaceAll(
"$",
"= $");
99 ostring.ReplaceAll(
" ",
"");
100 ostring.ReplaceAll(
"\"export",
"\"export ");
101 out << ostring.Data() << endl;
105 ostring.ReplaceAll(
"exit",
"return 0");
106 ostring.ReplaceAll(
"setenv",
"export");
107 ostring.ReplaceAll(
"\t",
" ");
108 ostring.ReplaceAll(
"else if",
"elif");
111 for(
int j=0;
j<ostring.Sizeof();
j++)
if(ostring[
j]==
' ') iblanks++;
else break;
112 if(!ostring.Contains(
"$#"))
if(ostring.First(
"#")>0) ostring.Remove(ostring.First(
"#"));
113 if((ostring.Contains(
"export")&&!ostring.Contains(
"unexport"))||ostring.Contains(
"alias")){
116 for(
int j=0;
j<token->GetEntries();
j++){ tok[
j]=(TObjString*)token->At(
j);}
117 ostring = tok[0]->GetString()+
" "+tok[1]->GetString()+
"="+tok[2]->GetString();
119 if(token->GetEntries()>3){
for(
int j=3;
j<token->GetEntries();
j++)
120 {ostring.Append(
" ");ostring.Append(tok[
j]->
GetString());}}
123 TRegexp re1(
"set.*=.*basename");
124 if(ostring.Contains(re1)) {
125 ostring.ReplaceAll(
"set",
"");
126 ostring.ReplaceAll(
" ",
"");
127 ostring.ReplaceAll(
"basename",
"basename ");
130 TRegexp re2(
"set.*=.*$");
131 if(ostring.Contains(re2)&&!ostring.Contains(
"alias")) {
132 ostring.ReplaceAll(
"set",
"");
136 TRegexp re3(
"@.*[-=+*:].*[0-9]");
137 if(ostring.Contains(re3)) {
138 ostring.ReplaceAll(
"@",
"(( ");
139 ostring = ostring+
" ))";
142 for(
int j=0;
j<iblanks;
j++) out <<
" ";
143 out << ostring.Data() << endl;
158 int index =
string.Index(t);
161 for(
int j=index+1;
j<
string.Sizeof();
j++) {
if(
string[
j]==
'$')
break; pat+=
" ";}
163 string.ReplaceAll(pat,pat0);
170 TString wdir = gSystem->WorkingDirectory();
171 TSystemDirectory gdir(
"", dir_name);
172 TList *dfiles = gdir.GetListOfFiles();
179 while ((dfile = (TSystemFile*)dnext())) {
180 fname = dfile->GetName();
181 sprintf(path,
"%s/%s",dir_name.Data(),fname.Data());
183 if ((endString!=
"")&&!fname.EndsWith(endString)) fsave=
false;
184 if ((beginString!=
"")&&!fname.BeginsWith(beginString)) fsave=
false;
185 if(fsave) fileList.push_back(path);
188 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)