Changeset 2218 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Oct 21, 2002, 5:38:02 PM (23 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nobjmgr.cc
r2180 r2218 218 218 bool NamedObjMgr::SetVar(string const & key, string const & val) 219 219 { 220 if ((key.length() < 1) || (! isalpha(key[0])) ) { 221 cout << "NamedObjMgr::SetVar( " << key << " ...) Bad VarName " << endl; 222 return(false); 223 } 220 224 #ifdef SANS_EVOLPLANCK 221 225 bool fg = true; … … 231 235 bool NamedObjMgr::HasVar(string const & key) 232 236 { 237 if ((key.length() < 1) || (! isalpha(key[0])) ) { 238 cout << "NamedObjMgr::HasVar( " << key << ") Bad VarName " << endl; 239 return(false); 240 } 233 241 #ifdef SANS_EVOLPLANCK 234 242 DVList::ValList::const_iterator it; … … 244 252 bool NamedObjMgr::DeleteVar(string const & key) 245 253 { 254 if ((key.length() < 1) || (! isalpha(key[0])) ) { 255 cout << "NamedObjMgr::DeleteVar( " << key << ") Bad VarName " << endl; 256 return(false); 257 } 246 258 #ifdef SANS_EVOLPLANCK 247 259 return(false); … … 254 266 string NamedObjMgr::GetVar(string const & key) 255 267 { 268 if ((key.length() < 1) || (! isalpha(key[0])) ) { 269 cout << "NamedObjMgr::GetVar( " << key << ") Bad VarName " << endl; 270 return(""); 271 } 256 272 // cout << " DEBUG::GetVar " << *myVars << endl; 257 273 return(myVars->GetS(key)); … … 503 519 504 520 myNObj++; 505 if (nobj.length() < 1) { 521 if ((nobj.length() < 1) || (! isalpha(nobj[0]) ) ) { 522 cout << "NamedObjMgr::AddObj() bad object name " << nobj ; 506 523 sprintf(buff,"O%d", myNObj); 507 524 nobj = buff; 525 cout << " changed to " << nobj << endl; 508 526 } 509 527 … … 580 598 cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl; 581 599 return(false); 582 600 } 583 601 nom = '/' + r1 + '/' + n1; 584 602 nomnew = '/' + r2 + '/' + n2; … … 587 605 cout << "NamedObjMgr::RenameObj() Error - No " << nom << " object !" << endl; 588 606 return(false); 589 } 607 } 608 if ((n2.length() < 1) || (! isalpha(n2[0])) ) { 609 cout << "NamedObjMgr::RenameObj() Error - bad new object name" << n2 << endl; 610 return(false); 611 } 590 612 NObjList::iterator it2 = myObjs->find(nomnew); 591 613 if (it2 != myObjs->end()) { … … 1501 1523 size_t p = nom.find('/'); 1502 1524 if (p < nom.length()) nom = nom.substr(0,p); 1503 if ( nom.length() < 1) return(false);1525 if ((nom.length() < 1) || (! isalpha(nom[0]) ) ) return(false); 1504 1526 return(true); 1505 1527 } -
trunk/SophyaPI/PIext/piacmd.cc
r2215 r2218 889 889 q3 = s.find_first_of("]",q2+1); 890 890 string sia = s.substr(q2+1, q3-q2-1); 891 if (sia.length() < 1) { 892 cerr << " Syntax error - in $varname[index] : $" 893 << vn << "[" << sia <<"]" << endl; 894 return(4); 895 } 896 if (isalpha(sia[0])) { 897 string sia2; 898 if (!GetVar(sia, sia2) || (sia2.length() < 1)) { 899 cerr << " Syntax error - in $varname[index] : $" 900 << vn << "[" << sia <<"]" << endl; 901 return(4); 902 } 903 sia = sia2; 904 } 891 905 int rcdia = ctoi(sia.c_str(), &iarr); 892 906 if (rcdia < 0) { … … 936 950 cerr << " PIACmd::SubstituteVar/Error: ArgsStack empty ! " 937 951 << " ($" << vn << ")" << endl; 938 vv = ""; return(false);952 vv = ""; return(false); 939 953 } 940 954 char buff[32]; 941 955 long an = ArgsStack.top().size(); 942 956 sprintf(buff,"%ld", an); 943 vv = buff; 957 vv = buff; return(true); 944 958 } 945 959 else if (ctoi(vn.c_str(), &ka) > 0) { // $0 $1 $2 ... … … 954 968 vv = ""; return(false); 955 969 } 956 vv = ArgsStack.top()[ka]; 957 } 970 vv = ArgsStack.top()[ka]; return(true); 971 } 972 else if (vn[0] == '#') { // Variable de type $#vname --> size(vname) 973 vn = vn.substr(1); 974 if (!omg.HasVar(vn) ) { 975 cerr << " PIACmd::SubstituteVarError: Undefined variable " 976 << vn << " ! " << endl; 977 vv = ""; return(false); 978 } 979 vn = omg.GetVar(vn); 980 vector<string> vs; 981 FillVStringFrString(vn, vs); 982 char buff[32]; 983 sprintf(buff,"%d", (int)vs.size()); 984 vv = buff; return(true); 985 } 958 986 else { // variable ordinaire geree par NamedObjMgr 959 987 if ( (!omg.HasVar(vn)) ) { 960 988 cerr << " PIACmd::SubstituteVarError: Undefined variable " 961 989 << vn << " ! " << endl; 962 vv = ""; return(false);963 } 964 vv = omg.GetVar(vn); 965 } 966 967 return( true);990 vv = ""; return(false); 991 } 992 vv = omg.GetVar(vn); return(true); 993 } 994 995 return(false); 968 996 } 969 997
Note:
See TracChangeset
for help on using the changeset viewer.