ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/openbabel/patty.cpp
(Generate patch)

Comparing trunk/src/openbabel/patty.cpp (file contents):
Revision 751 by gezelter, Thu Nov 17 20:38:45 2005 UTC vs.
Revision 1081 by gezelter, Thu Oct 19 20:49:05 2006 UTC

# Line 2 | Line 2 | Copyright (C) 1998-2001 by OpenEye Scientific Software
2   patty.cpp - Programmable atom typer.
3  
4   Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
5 < Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison
5 > Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison
6  
7   This file is part of the Open Babel project.
8   For more information, see <http://openbabel.sourceforge.net/>
# Line 68 | Line 68 | void patty::read_rules(const string &infile)
68      vector<string> vs;
69      char buffer[BUFF_SIZE];
70      char tmp_str[BUFF_SIZE];
71 <    char patty_dir[BUFF_SIZE];
71 >    string patty_dir;
72      OBSmartsPattern *sp;
73  
74      ifs.open(infile.c_str());
75      ifsP= &ifs;
76      if (!ifs)
77      {
78 <        if (getenv("FORCE_PARAM_PATH") == NULL)
78 >        if (getenv("BABEL_DATADIR") == NULL)
79          {
80   #ifdef HAVE_SSTREAM
81            stringstream errorMsg;
82   #else
83            strstream errorMsg;
84   #endif
85 <          errorMsg << "The FORCE_PARAM_PATH environment variable is not defined" << endl;
85 >          errorMsg << "The BABEL_DATADIR environment variable is not defined" << endl;
86            errorMsg << "Please define it so the program can find " << infile << endl;
87 <          obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obWarning);
87 >          obErrorLog.ThrowError(__func__, errorMsg.str(), obWarning);
88              //            exit(0);
89          }
90          else
91 <            strcpy(patty_dir,getenv("FORCE_PARAM_PATH"));
92 <        strcat(patty_dir,FILE_SEP_CHAR);
93 <        strcat(patty_dir,infile.c_str());
94 <        ifs1.open(patty_dir);
91 >            patty_dir = getenv("BABEL_DATADIR");
92 >        patty_dir += FILE_SEP_CHAR;
93 >        patty_dir += infile;
94 >        ifs1.open(patty_dir.c_str());
95          ifsP= &ifs1;
96          //     if (!ifs1)
97          //    {
# Line 108 | Line 108 | void patty::read_rules(const string &infile)
108        strstream errorMsg;
109   #endif
110          errorMsg << "Could not open " << patty_dir << endl;
111 <        obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obWarning);
111 >        obErrorLog.ThrowError(__func__, errorMsg.str(), obWarning);
112          //        exit(0);
113      }
114      while (ifsP->getline(buffer,BUFF_SIZE))
# Line 118 | Line 118 | void patty::read_rules(const string &infile)
118              tokenize(vs,buffer," \t\n");
119              if (vs.size() >= 2)
120              {
121 <                strcpy(tmp_str,vs[0].c_str());
121 >                strncpy(tmp_str,vs[0].c_str(), sizeof(tmp_str) - 1);
122 >                tmp_str[sizeof(tmp_str) - 1] = '\0';
123                  sp = new OBSmartsPattern;
124                  sp->Init(tmp_str);
125                  _sp.push_back(sp);
# Line 145 | Line 146 | void patty::assign_rules(std::vector<std::string> &rul
146              tokenize(vs,buffer," \t\n");
147              if (vs.size() >= 2)
148              {
149 <                strcpy(tmp_str,vs[0].c_str());
149 >                strncpy(tmp_str,vs[0].c_str(), sizeof(tmp_str) - 1);
150 >                tmp_str[sizeof(tmp_str) - 1] = '\0';
151                  sp = new OBSmartsPattern;
152                  sp->Init(tmp_str);
153                  _sp.push_back(sp);
# Line 161 | Line 163 | void patty::assign_types(OBMol &mol, std::vector<std::
163   {
164      atm_typ.resize(mol.NumAtoms()+1);
165  
166 <    obErrorLog.ThrowError(__FUNCTION__,
166 >    obErrorLog.ThrowError(__func__,
167                            "Ran OpenBabel::PATTY::AssignTypes", obAuditMsg);
168  
169      for (unsigned int i = 0; i < _sp.size(); i++)
# Line 179 | Line 181 | void patty::assign_types(OBMol &mol, std::vector<std::
181                  strstream errorMsg;
182   #endif
183                  errorMsg << typ[i] << " " << smarts[i] << " matched ";
184 <                obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obDebug);
184 >                obErrorLog.ThrowError(__func__, errorMsg.str(), obDebug);
185                }
186  
187              for (unsigned int j = 0; j < match.size(); j++)
# Line 192 | Line 194 | void patty::assign_types(OBMol &mol, std::vector<std::
194                      strstream errorMsg;
195   #endif
196                      errorMsg << match[j][0] << " ";
197 <                    obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obDebug);
197 >                    obErrorLog.ThrowError(__func__, errorMsg.str(), obDebug);
198                    }
199                  atm_typ[match[j][0]] = typ[i];
200              }
# Line 204 | Line 206 | void patty::assign_types(OBMol &mol,vector<int> &atm_t
206   {
207      atm_typ.resize(mol.NumAtoms()+1);
208  
209 <    obErrorLog.ThrowError(__FUNCTION__,
209 >    obErrorLog.ThrowError(__func__,
210                            "Ran OpenBabel::PATTY::AssignTypes", obAuditMsg);
211  
212      for (unsigned int i = 0; i < _sp.size(); i++)
# Line 222 | Line 224 | void patty::assign_types(OBMol &mol,vector<int> &atm_t
224                      strstream errorMsg;
225   #endif
226                      errorMsg << typ[i] << " " << smarts[i] << " matched " ;
227 <                    obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obDebug);
227 >                    obErrorLog.ThrowError(__func__, errorMsg.str(), obDebug);
228                }
229  
230              for (unsigned int j = 0; j < match.size(); j++)
# Line 235 | Line 237 | void patty::assign_types(OBMol &mol,vector<int> &atm_t
237                      strstream errorMsg;
238   #endif
239                      errorMsg << match[j][0] << " ";
240 <                    obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obDebug);
240 >                    obErrorLog.ThrowError(__func__, errorMsg.str(), obDebug);
241                    }
242                  atm_typ[match[j][0]] = type_to_int(typ[i]);
243              }
# Line 286 | Line 288 | int patty::type_to_int(const string &type, bool failOn
288   #endif
289            errorMsg << "Unable to find type of feature passed in " << endl;
290            errorMsg << "Feature passed in is " << type << endl;
291 <          obErrorLog.ThrowError(__FUNCTION__, errorMsg.str(), obInfo);
291 >          obErrorLog.ThrowError(__func__, errorMsg.str(), obInfo);
292            //      exit(-1);
293          }
294        else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines