Fixed major issues
[ede] / libede / src / FileSystemSearch.ec
index 690cd71..d198f1b 100644 (file)
@@ -12,7 +12,7 @@ struct SearchStackFrame
    int tag;
    char path[MAX_LOCATION];
    FileListing listing;
    int tag;
    char path[MAX_LOCATION];
    FileListing listing;
-   
+
    bool branched;
    //DataRow result;
    //DataRow browse;
    bool branched;
    //DataRow result;
    //DataRow browse;
@@ -47,7 +47,7 @@ public:
       terminate = false;
    }
 
       terminate = false;
    }
 
-   virtual bool Window::NotifyUpdateSearchLocation(FileSystemSearch search, char * location);
+   virtual bool Window::NotifyUpdateSearchLocation(FileSystemSearch search, const char * location);
    virtual bool Window::NotifySearchSortResults(FileSystemSearch search);
    virtual bool Window::NotifySearchSortBrowser(FileSystemSearch search);
    virtual bool Window::NotifySearchTerminated(FileSystemSearch search);
    virtual bool Window::NotifySearchSortResults(FileSystemSearch search);
    virtual bool Window::NotifySearchSortBrowser(FileSystemSearch search);
    virtual bool Window::NotifySearchTerminated(FileSystemSearch search);
@@ -61,7 +61,7 @@ public:
 
 
 
 
 
 
-   bool SearchFileContent(String path)
+   bool SearchFileContent(const String path)
    {
       bool match = false;
       File file = FileOpen(path, read);
    {
       bool match = false;
       File file = FileOpen(path, read);
@@ -96,8 +96,8 @@ public:
                      find = SearchString(buffer, start, contentSearch, optionContentMatchCase, optionContentMatchWord);
 
                      // todo add a maximum line length possibility as param
                      find = SearchString(buffer, start, contentSearch, optionContentMatchCase, optionContentMatchWord);
 
                      // todo add a maximum line length possibility as param
-                     for(bstart = start; 
-                           bstart < readCount && newLine && (!find || newLine < find); 
+                     for(bstart = start;
+                           bstart < readCount && newLine && (!find || newLine < find);
                               bstart += (newLine - &buffer[bstart]) / sizeof(char))
                      {
                         newLine = strstr(&buffer[bstart], "\n");
                               bstart += (newLine - &buffer[bstart]) / sizeof(char))
                      {
                         newLine = strstr(&buffer[bstart], "\n");
@@ -131,14 +131,14 @@ public:
                      find = SearchString(buffer, start, contentSearch, optionContentMatchCase, optionContentMatchWord);
                file.Seek(seekBack, current);
             }
                      find = SearchString(buffer, start, contentSearch, optionContentMatchCase, optionContentMatchWord);
                file.Seek(seekBack, current);
             }
-            match = (bool)find;
+            match = find != null;
          }
          delete file;
       }
       return match;
    }
          }
          delete file;
       }
       return match;
    }
-   
-   // I wonder if this is optimized at the c level to be compiled inline 
+
+   // I wonder if this is optimized at the c level to be compiled inline
    // and to use in-place in-stack memory for both the return value and the parameters
    // if not, c should be more optimized...
    // would the const have any impact on optimization?
    // and to use in-place in-stack memory for both the return value and the parameters
    // if not, c should be more optimized...
    // would the const have any impact on optimization?
@@ -155,24 +155,24 @@ public:
       // \\Nateus\data\ is not remote, etc...
       // How to?
       FileStats stats;
       // \\Nateus\data\ is not remote, etc...
       // How to?
       FileStats stats;
-      
+
       terminate = false;
       count = 0;
       matchCount = 0;
       terminate = false;
       count = 0;
       matchCount = 0;
-      
+
       hasNameSearch = (strlen(nameSearch) != 0);
       hasSizeSearch = false;  // this is temporary
       hasContentSearch = (strlen(contentSearch) != 0);
 
       listLines = true;
       lines = OldList { };
       hasNameSearch = (strlen(nameSearch) != 0);
       hasSizeSearch = false;  // this is temporary
       hasContentSearch = (strlen(contentSearch) != 0);
 
       listLines = true;
       lines = OldList { };
-      
+
       //SearchDir(location);
 
       FileGetStats(location, stats);
 
       strcpy(stack[0].path, location);
       //SearchDir(location);
 
       FileGetStats(location, stats);
 
       strcpy(stack[0].path, location);
-      stack[0].listing = FileListing { stack[0].path };  // there should be a sorted = true/false 
+      stack[0].listing = FileListing { stack[0].path };  // there should be a sorted = true/false
 
       //fsb.list.Clear();
                                                          // Binary Search sorting...
 
       //fsb.list.Clear();
                                                          // Binary Search sorting...
@@ -198,7 +198,7 @@ public:
          }
          guiApp.Unlock();
       }
          }
          guiApp.Unlock();
       }
-      
+
       for(frame = 0; frame >= 0 && !terminate; )
       {
          guiApp.Lock();
       for(frame = 0; frame >= 0 && !terminate; )
       {
          guiApp.Lock();
@@ -222,13 +222,13 @@ public:
          if(stack[frame].listing.Find())
          {
             count++;
          if(stack[frame].listing.Find())
          {
             count++;
-            
+
             //match = (strcmp(stack[frame].listing.name, nameSearch) == 0);
             //match = (stack[frame].listing.name[0] == nameSearch[0]);
             //match = (bool)strstr(stack[frame].listing.name, nameSearch);
             //match = (strcmp(stack[frame].listing.name, nameSearch) == 0);
             //match = (stack[frame].listing.name[0] == nameSearch[0]);
             //match = (bool)strstr(stack[frame].listing.name, nameSearch);
-               
+
             if(hasNameSearch)
             if(hasNameSearch)
-               match = (bool)SearchString(stack[frame].listing.name, 0, nameSearch, optionNameMatchCase, optionNameMatchWord);
+               match = SearchString(stack[frame].listing.name, 0, nameSearch, optionNameMatchCase, optionNameMatchWord) != null;
             else
                match = true;
 
             else
                match = true;