Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnModel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.10 by maloninc, Thu Aug 11 01:51:21 2005 UTC revision 1.17 by maloninc, Tue Sep 13 01:37:43 2005 UTC
# Line 64  WikiList* mnModel::search(const char* se Line 64  WikiList* mnModel::search(const char* se
64    
65          /* searchStr to Tokens */          /* searchStr to Tokens */
66          token = strtok(outbuf, " ");          token = strtok(outbuf, " ");
67            if(token == NULL) return list;
68          tokenList[0] = (char*)malloc(strlen(token)+1);          tokenList[0] = (char*)malloc(strlen(token)+1);
69          snprintf(tokenList[0], strlen(token)+1, "%s", token);          snprintf(tokenList[0], strlen(token)+1, "%s", token);
70          i = 1;          i = 1;
# Line 94  WikiList* mnModel::search(const char* se Line 95  WikiList* mnModel::search(const char* se
95                          decodeFileName = decode(fileName->mb_str());                          decodeFileName = decode(fileName->mb_str());
96                          snprintf(decodeFileNameBuf, MAX_BUF_SIZE, "%s", decodeFileName);                          snprintf(decodeFileNameBuf, MAX_BUF_SIZE, "%s", decodeFileName);
97                          toLower(buf);                          toLower(buf);
                         toLower(outbuf);  
98                          toLower(decodeFileNameBuf);                          toLower(decodeFileNameBuf);
99                          found = TRUE;                          found = TRUE;
100                          for(i = 0; tokenList[i] != NULL; i++){                          for(i = 0; tokenList[i] != NULL; i++){
101                                    toLower(tokenList[i]);
102                                  if(strstr((const char*)buf, (const char*)tokenList[i]) ||                                  if(strstr((const char*)buf, (const char*)tokenList[i]) ||
103                                          strstr((const char*)decodeFileName, (const char*)tokenList[i])) {                                          strstr((const char*)decodeFileNameBuf, (const char*)tokenList[i])) {
104                                          found = TRUE;                                          found = TRUE;
105                                  }                                  }
106                                  else {                                  else {
# Line 132  void mnModel::addSearchStr(wxString* sea Line 133  void mnModel::addSearchStr(wxString* sea
133    
134          if(searchStrList->Index(searchStr->c_str()) == wxNOT_FOUND){          if(searchStrList->Index(searchStr->c_str()) == wxNOT_FOUND){
135                  string = new wxString(searchStr->c_str());                  string = new wxString(searchStr->c_str());
136                  searchStrList->Add(*string, 1);                  //searchStrList->Add(*string, 1);
137                    searchStrList->Insert(*string, 0);
138          }          }
139  }  }
140    
# Line 287  void WikiData::modSubject(wxString* newS Line 289  void WikiData::modSubject(wxString* newS
289          sprintf(newFullPath, "%s/%s", (const char*)dataDirName->mb_str(), (const char*)fileName->mb_str());          sprintf(newFullPath, "%s/%s", (const char*)dataDirName->mb_str(), (const char*)fileName->mb_str());
290    
291          if((fp = fopen(newFullPath, "r")) == NULL) {          if((fp = fopen(newFullPath, "r")) == NULL) {
292                  rename(oldFullPath, newFullPath);                  if(rename(oldFullPath, newFullPath) < 0) wxLogMessage(wxT("rename error: errno=[%d]"), errno);
293          }          }
294          else if(strcmp(oldFullPath, newFullPath)){          else if(strcmp(oldFullPath, newFullPath)){
295                  wxLogMessage(wxT("File has already exist. [%s]"), fileName->c_str());                  wxLogMessage(wxT("File has already exist. [%s]"), fileName->c_str());
296                  fclose(fp);                  fclose(fp);
297          }          }
298            else {
299                    fclose(fp);
300            }
301    
302          delete oldSubject;          delete oldSubject;
303          delete oldFileName;          delete oldFileName;
# Line 309  const wxString* WikiData::getText() Line 314  const wxString* WikiData::getText()
314          FILE* fp;          FILE* fp;
315          char  buf[MAX_BUF_SIZE];          char  buf[MAX_BUF_SIZE];
316          char  fullPath[MAX_BUF_SIZE];          char  fullPath[MAX_BUF_SIZE];
317            iconv_t     codeSet;
318            char        outbuf[MAX_BUF_SIZE];
319            char*       inbufPtr;
320            char*       outbufPtr;
321            int         inbufSize;
322            int         outbufSize;
323          wxCSConv    conv(wxT(CODE_SET_SYSTEM));          wxCSConv    conv(wxT(CODE_SET_SYSTEM));
         wxCSConv    eucConv(wxT(CODE_SET_EUC_JP));  
324          wxString*   tmpStr;          wxString*   tmpStr;
325    
326            codeSet = iconv_open(CODE_SET_SYSTEM, CODE_SET_EUC_JP);
327            if(codeSet == (iconv_t)-1) {
328                    MN_FATAL_ERROR(wxT("failed iconv_open"));
329            }
330    
331          if(text) {          if(text) {
332                    iconv_close(codeSet);
333                  return text;                  return text;
334          }          }
335    
# Line 325  const wxString* WikiData::getText() Line 341  const wxString* WikiData::getText()
341          }          }
342    
343          while(fgets(buf, MAX_BUF_SIZE, fp)) {          while(fgets(buf, MAX_BUF_SIZE, fp)) {
344                  tmpStr = new wxString(buf, eucConv);  #ifdef __WXMAC__
345                    for(int i = 0; buf[i] != 0; i++) if(buf[i] == (char)MAC_BACKSLASH) buf[i] = '\\';
346    #endif
347                    inbufPtr = buf;
348                    inbufSize = sizeof(buf);
349                    outbufPtr = outbuf;
350                    outbufSize = sizeof(outbuf);
351                    memset(outbuf, 0, outbufSize);
352                    iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize);
353                    tmpStr = new wxString((char*)outbuf, conv);
354                  *text += *tmpStr;                  *text += *tmpStr;
355                  delete tmpStr;                  delete tmpStr;
356          }          }
357            iconv_close(codeSet);
358          fclose(fp);          fclose(fp);
359    
360          return text;          return text;
361  }  }
362    
# Line 377  void WikiData::save() Line 404  void WikiData::save()
404    
405          memset(inbuf, 0, sizeof(inbuf));          memset(inbuf, 0, sizeof(inbuf));
406          strcpy(inbuf,(const char*)text->mb_str());          strcpy(inbuf,(const char*)text->mb_str());
407    
408    #ifdef __WXMAC__
409            for(int i = 0; inbuf[i] != 0; i++) if(inbuf[i] == (char)MAC_BACKSLASH) inbuf[i] = '\\';
410    #endif
411    
412          inbufPtr = inbuf;          inbufPtr = inbuf;
413          inbufSize = strlen(inbufPtr);          inbufSize = strlen(inbufPtr);
414          outbufPtr = outbuf;          outbufPtr = outbuf;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.17

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26