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.16 by maloninc, Mon Sep 12 21:44:33 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 287  void WikiData::modSubject(wxString* newS Line 288  void WikiData::modSubject(wxString* newS
288          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());
289    
290          if((fp = fopen(newFullPath, "r")) == NULL) {          if((fp = fopen(newFullPath, "r")) == NULL) {
291                  rename(oldFullPath, newFullPath);                  if(rename(oldFullPath, newFullPath) < 0) wxLogMessage(wxT("rename error: errno=[%d]"), errno);
292          }          }
293          else if(strcmp(oldFullPath, newFullPath)){          else if(strcmp(oldFullPath, newFullPath)){
294                  wxLogMessage(wxT("File has already exist. [%s]"), fileName->c_str());                  wxLogMessage(wxT("File has already exist. [%s]"), fileName->c_str());
295                  fclose(fp);                  fclose(fp);
296          }          }
297            else {
298                    fclose(fp);
299            }
300    
301          delete oldSubject;          delete oldSubject;
302          delete oldFileName;          delete oldFileName;
# Line 309  const wxString* WikiData::getText() Line 313  const wxString* WikiData::getText()
313          FILE* fp;          FILE* fp;
314          char  buf[MAX_BUF_SIZE];          char  buf[MAX_BUF_SIZE];
315          char  fullPath[MAX_BUF_SIZE];          char  fullPath[MAX_BUF_SIZE];
316            iconv_t     codeSet;
317            char        outbuf[MAX_BUF_SIZE];
318            char*       inbufPtr;
319            char*       outbufPtr;
320            int         inbufSize;
321            int         outbufSize;
322          wxCSConv    conv(wxT(CODE_SET_SYSTEM));          wxCSConv    conv(wxT(CODE_SET_SYSTEM));
         wxCSConv    eucConv(wxT(CODE_SET_EUC_JP));  
323          wxString*   tmpStr;          wxString*   tmpStr;
324    
325            codeSet = iconv_open(CODE_SET_SYSTEM, CODE_SET_EUC_JP);
326            if(codeSet == (iconv_t)-1) {
327                    MN_FATAL_ERROR(wxT("failed iconv_open"));
328            }
329    
330          if(text) {          if(text) {
331                    iconv_close(codeSet);
332                  return text;                  return text;
333          }          }
334    
# Line 325  const wxString* WikiData::getText() Line 340  const wxString* WikiData::getText()
340          }          }
341    
342          while(fgets(buf, MAX_BUF_SIZE, fp)) {          while(fgets(buf, MAX_BUF_SIZE, fp)) {
343                  tmpStr = new wxString(buf, eucConv);  #ifdef __WXMAC__
344                    for(int i = 0; buf[i] != 0; i++) if(buf[i] == (char)MAC_BACKSLASH) buf[i] = '\\';
345    #endif
346                    inbufPtr = buf;
347                    inbufSize = sizeof(buf);
348                    outbufPtr = outbuf;
349                    outbufSize = sizeof(outbuf);
350                    memset(outbuf, 0, outbufSize);
351                    iconv(codeSet, (ICONV_CONST char**)&inbufPtr, (size_t*)&inbufSize, &outbufPtr, (size_t*)&outbufSize);
352                    tmpStr = new wxString((char*)outbuf, conv);
353                  *text += *tmpStr;                  *text += *tmpStr;
354                  delete tmpStr;                  delete tmpStr;
355          }          }
356            iconv_close(codeSet);
357          fclose(fp);          fclose(fp);
358    
359          return text;          return text;
360  }  }
361    
# Line 377  void WikiData::save() Line 403  void WikiData::save()
403    
404          memset(inbuf, 0, sizeof(inbuf));          memset(inbuf, 0, sizeof(inbuf));
405          strcpy(inbuf,(const char*)text->mb_str());          strcpy(inbuf,(const char*)text->mb_str());
406    
407    #ifdef __WXMAC__
408            for(int i = 0; inbuf[i] != 0; i++) if(inbuf[i] == (char)MAC_BACKSLASH) inbuf[i] = '\\';
409    #endif
410    
411          inbufPtr = inbuf;          inbufPtr = inbuf;
412          inbufSize = strlen(inbufPtr);          inbufSize = strlen(inbufPtr);
413          outbufPtr = outbuf;          outbufPtr = outbuf;

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

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