Changeset 2753 for GTP/trunk/App/Demos/Vis/CHC_revisited/common.cpp
- Timestamp:
- 06/10/08 23:21:11 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/common.cpp
r2751 r2753 177 177 } 178 178 179 char * 180 TimeString() 179 char *TimeString() 181 180 { 182 181 time_t t; 183 182 time(&t); 183 184 184 return ctime(&t); 185 185 } 186 186 187 char * 188 GetAbsPath(char *name)187 188 char *GetAbsPath(char *name) 189 189 { 190 190 // char *url = new char[strlen(name)+1]; … … 192 192 193 193 // get the absolute path 194 int c = strlen(name);195 int i = c -1;194 size_t c = strlen(name); 195 int i = c - 1; 196 196 bool wasDot = false; 197 197 198 // search for double dot 198 for (;i>=0;i--) 199 if (name[i]=='.') { 199 for (; i >= 0; -- i) 200 { 201 if (name[i]=='.') 202 { 200 203 if (wasDot) 201 204 break; 202 205 wasDot = true; 203 } else 206 } 207 else 204 208 wasDot = false; 205 206 if (i>0) 207 i+=3; 208 if (i<0) 209 i=0; 210 211 char *url = new char[c-i+1]; 212 int j=0; 213 for (;i<c;i++,j++) 214 url[j] = name[i]; 215 url[j]=0; 216 217 return url; 209 } 210 211 if (i>0) 212 i+=3; 213 if (i<0) 214 i=0; 215 216 char *url = new char[c-i+1]; 217 218 int j=0; 219 220 for (;i<c;i++,j++) 221 url[j] = name[i]; 222 223 url[j]=0; 224 225 return url; 218 226 } 219 227 … … 230 238 char *GetPath(const char *s) 231 239 { 232 int i=strlen(s); 233 for (; i>0; i--) { 240 size_t i = strlen(s); 241 for (; i > 0; -- i) 242 { 234 243 if (s[i]=='/' || s[i]=='\\') 235 244 break;
Note: See TracChangeset
for help on using the changeset viewer.