• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版5741bf229df9beb2eb9c57eec71c0cee64447855 (tree)
时间2011-01-04 20:31:14
作者Mikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Input lines are trimmed.

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/MolDS/trunk@28 1136aad2-a195-0410-b898-f5ea1d11b9d8

更改概述

差异

--- a/src/MolDS.cpp
+++ b/src/MolDS.cpp
@@ -7,6 +7,7 @@
77 #include<time.h>
88 #include<list>
99 #include<vector>
10+#include"base/Utilities.h"
1011 #include"base/MolDSException.h"
1112 #include"base/Enums.h"
1213 #undef INCLUDED_ENUMS
@@ -20,7 +21,6 @@
2021 #include"base/atoms/Satom.h"
2122 #include"base/MallocerFreer.h"
2223 #include"base/InputParser.h"
23-#include"base/Utilities.h"
2424 #include"base/EularAngle.h"
2525 #include"base/Parameters.h"
2626 #include"cndo/Cndo2.h"
--- a/src/base/InputParser.h
+++ b/src/base/InputParser.h
@@ -304,7 +304,9 @@ void InputParser::OutputInputTerms(vector<string> inputTerms){
304304 * # or // are treated as comment out
305305 *
306306 ****/
307-bool InputParser::IsCommentOut(string str){
307+bool InputParser::IsCommentOut(string tempStr){
308+
309+ string str = TrimString(tempStr);
308310
309311 string commentPrefix1 = "#";
310312 string prefix1;
--- a/src/base/Utilities.h
+++ b/src/base/Utilities.h
@@ -1,8 +1,7 @@
11 #ifndef INCLUDED_UTILITIES
22 #define INCLUDED_UTILITIES
33
4-#include <stdio.h> // printf, sprintf使用
5-#include <time.h> // tm構造体, time, localtime, gmtime使用
4+using namespace std;
65
76 namespace MolDS_base{
87
@@ -26,6 +25,33 @@ char *fmttm(char *buf, struct tm *st)
2625 return buf;
2726 }
2827
28+
29+string TrimString(const string str){
30+
31+ int nStart = 0;
32+ int nEnd = str.length() - 1;
33+
34+ // left trim
35+ for(int n = 0; n < str.length(); n++ ){
36+ if( str.data()[n] != ' ' ){
37+ nStart = n;
38+ break;
39+ }
40+ }
41+
42+ // right trim
43+ for(int n = str.length() - 1; n >= 0; n-- ){
44+ if( str.data()[n] != ' ' ){
45+ nEnd = n;
46+ break;
47+ }
48+ }
49+
50+ return(str.substr( nStart, nEnd - nStart + 1 ));
51+
52+}
53+
54+
2955 }
3056 #endif
3157
--- a/src/input.in
+++ b/src/input.in
@@ -4,7 +4,7 @@ SCF
44 SCF_END
55
66 THEORY
7- //cndo/2
7+ #cndo/2
88 //indo
99 //zindo/s
1010 none