Changeset 247
- Timestamp:
- 04/04/07 21:35:56 (1 year ago)
- Files:
-
- 06/libkombilo/search.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
06/libkombilo/search.cpp
r245 r247 1036 1036 int rc = sqlite3_exec(db, sql, 0, 0, 0); 1037 1037 if (rc != SQLITE_OK) { 1038 printf("error %d\n", rc);1039 1038 throw DBError(); 1040 1039 } … … 2174 2173 2175 2174 HashhitF::HashhitF() { 2176 printf("oops\n");2177 2175 cont = 0; 2178 2176 emn = 0; … … 3794 3792 rc = sqlite3_exec(db, sql.c_str(), insertEntry, this, 0); 3795 3793 if (rc != SQLITE_OK && rc != SQLITE_ERROR) { 3796 printf("sql error %d\n", rc);3797 3794 throw DBError(); 3798 3795 } … … 3978 3975 void GameList::tagsearch(int tag) throw(DBError) { 3979 3976 char sql[200]; 3980 3977 3981 3978 if (!tag) return; 3982 3979 if (tag > 0) { … … 4060 4057 4061 4058 int GameList::find_duplicates(int bs, bool strict) throw(DBError) { 4059 if (!currentList->size()) return 0; // this also deals with the case of an empty db 4062 4060 int bs_index = 0; 4063 4061 if (duplicates) delete duplicates; … … 4315 4313 oldList = 0; 4316 4314 if (currentList) delete currentList; 4317 currentList = 0;4315 currentList = new vector<pair<int,int> >; 4318 4316 return; 4319 4317 } … … 4665 4663 int rc = sqlite3_prepare(db, sql_ins_rnp.c_str(), -1, &ppStmt, 0); 4666 4664 if (rc != SQLITE_OK || ppStmt==0) { 4667 printf("db error %d\n", rc);4668 4665 throw DBError(); // FIXME: catch busy error, (and/or throw DBError?) 4669 4666 } … … 4718 4715 // printf("nn\n"); 4719 4716 bool caughtSGFError = false; 4717 char* propValue = 0; 4718 4720 4719 try { 4721 4720 4722 4721 // parse current node, watch out for B, W, AB, AW, AE properties 4723 4724 4722 const char* s = currentN->SGFstring.c_str(); 4725 4723 int lSGFstring = strlen(s); … … 4756 4754 ID[IDindex] = 0; // found next property ID 4757 4755 bool IDrelevant= (!strcmp(ID,"B") || !strcmp(ID,"W") || !strcmp(ID,"AB") || !strcmp(ID,"AW") || !strcmp(ID,"AE")); 4758 char* propValue = new char[lSGFstring+1];4756 propValue = new char[100000]; 4759 4757 int propValueIndex = 0; 4760 4758 int oldPropValueIndex = 0; … … 4769 4767 if (97 <= s[i] && s[i] <= 96+bs) { // valid board coordinate? 4770 4768 propValue[propValueIndex++] = s[i]; 4769 if (propValueIndex > 99990) throw SGFError(); 4771 4770 } else if (s[i] == 't') { ; // allow passes, but do not record them (we handle them a little sloppily here) 4771 } else if (s[i] == ':') { 4772 if (propValueIndex - oldPropValueIndex != 2) 4773 throw SGFError(); 4774 char rect1 = 'a'; 4775 char rect2 = 'a'; 4776 i++; 4777 while (i<lSGFstring && (s[i] == '\t' || s[i] == ' ' || s[i] == '\r' || s[i] == '\n')) i++; 4778 if (i >= lSGFstring) throw SGFError(); 4779 if (97 <= s[i] && s[i] <= 96+bs) // valid board coordinate? 4780 rect1 = s[i]; 4781 else throw SGFError(); 4782 i++; 4783 while (i<lSGFstring && (s[i] == '\t' || s[i] == ' ' || s[i] == '\r' || s[i] == '\n')) i++; 4784 if (i >= lSGFstring) throw SGFError(); 4785 if (97 <= s[i] && s[i] <= 96+bs) // valid board coordinate? 4786 rect2 = s[i]; 4787 else throw SGFError(); 4788 i++; 4789 while (i<lSGFstring && (s[i] == '\t' || s[i] == ' ' || s[i] == '\r' || s[i] == '\n')) i++; 4790 if (i >= lSGFstring) throw SGFError(); 4791 if (s[i] == ']') { 4792 char st1 = propValue[propValueIndex-2]; 4793 char st2 = propValue[propValueIndex-1]; 4794 propValueIndex -= 2; // do not want to have the first entry twice! 4795 for(char x1 = st1; x1 <= rect1; x1++) { 4796 for(char x2 = st2; x2 <= rect2; x2++) { 4797 propValue[propValueIndex++] = x1; 4798 propValue[propValueIndex++] = x2; 4799 if (propValueIndex > 99990) throw SGFError(); 4800 } 4801 } 4802 oldPropValueIndex = propValueIndex; 4803 break; 4804 } else throw SGFError(); 4772 4805 } else { 4773 4806 throw SGFError(); … … 4776 4809 } 4777 4810 if (i >= lSGFstring) throw SGFError(); 4778 if (propValueIndex - oldPropValueIndex != 0 && propValueIndex - oldPropValueIndex != 2) 4811 4812 if (propValueIndex - oldPropValueIndex != 0 && propValueIndex - oldPropValueIndex != 2) { 4779 4813 throw SGFError(); 4814 } 4780 4815 oldPropValueIndex = propValueIndex; 4781 4816 … … 4794 4829 } 4795 4830 delete [] propValue; 4831 propValue = 0; 4796 4832 continue; 4797 4833 } … … 4838 4874 } 4839 4875 delete [] propValue; 4876 propValue = 0; 4840 4877 } 4841 4878 } catch (SGFError) { 4879 if (propValue) { 4880 delete [] propValue; 4881 propValue = 0; 4882 } 4842 4883 return_val |= SGF_ERROR; 4843 4884 caughtSGFError = true;
