]> gitweb.hamatoma.de Git - crepublib/commitdiff
ReDirStatistics works
authorHamatoma <git.tortouse@hm.f-r-e-i.de>
Fri, 6 Feb 2015 23:54:43 +0000 (00:54 +0100)
committerHamatoma <git.tortouse@hm.f-r-e-i.de>
Fri, 6 Feb 2015 23:54:43 +0000 (00:54 +0100)
base/ReByteBuffer.hpp
base/ReSeqArray.cpp
cunit/cuReByteBuffer.cpp
cunit/cuReSeqArray.cpp
cunit/testall.cpp
os/ReDirTools.cpp
os/ReTraverser.cpp
os/ReTraverser.hpp

index 9dcc9f99445c671b09e0314258417ea378d39ded..dcf1f01daddd3bcca98d34ad05675437c8c66a38 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef REBYTEBUFFER_H_
 #define REBYTEBUFFER_H_
 
-#define PRIMARY_BUFFER_SIZE 512
+#define PRIMARY_BUFFER_SIZE 513
 
 /** @brief An efficient dynamic memory buffer.
  *
index efe1f8fdbf5d2c5c0782db2bb0ef9e4e19b705c0..4b66e3ff49c15638645b737ba0cb7b28801b7665 100644 (file)
@@ -462,13 +462,15 @@ void ReSeqArray::set(Index index, const Byte* source,
                        indexContent = m_content.length();
                        m_content.append(source, sourceLength);
                }
-               printf("vor:\n%s\n", ReByteBuffer("")
+/*             printf("vor:\n%s\n", ReByteBuffer("")
                        .appendHexDump(m_list.str(), m_entrySize*(1+index), 0,
                                m_entrySize*2, "%4d: ", false, m_entrySize, m_entrySize).str());
+               */
                setSequence(seq, indexContent, sourceLength, tag);
-               printf("dann:\n%s\n", ReByteBuffer("")
+               /*printf("dann:\n%s\n", ReByteBuffer("")
                        .appendHexDump(m_list.str(), m_entrySize*(1+index), 0,
                                m_entrySize*2, "%4d: ", false, m_entrySize, m_entrySize).str());
+                               */
        }
 }
 
index 4823b2fa07370d0ef055fe01dfb41f1bc844510e..63b8171aec45c5ecd78329cfbfd8efb56edb3b53 100644 (file)
@@ -15,6 +15,7 @@ public:
        }
 private:
        void run(){
+               testEnsureSize2();
                testHexDump();
                testFill();
                testAppendMilliSec();
@@ -37,6 +38,14 @@ private:
                testSplice();
                testReplace();
        }
+       void testEnsureSize2(){
+               ReByteBuffer buffer;
+               buffer.setLength(PRIMARY_BUFFER_SIZE - 1);
+               buffer.fill('x', PRIMARY_BUFFER_SIZE - 1);
+               checkEqu(PRIMARY_BUFFER_SIZE - 1, (int) buffer.capacity());
+               buffer.ensureSize(PRIMARY_BUFFER_SIZE);
+               checkEqu(PRIMARY_BUFFER_SIZE*2 - 1, (int) buffer.capacity());
+       }
        void testHexDump(){
                ReByteBuffer buf;
                /* appendHexDump(const char* data, size_t length, int offset = 0, int bytePerLine = 16,
@@ -56,10 +65,8 @@ private:
                        " 28: 36373839 783132336789x123\n"
                        " 36: 343536           456     \n", buf.str());
                buf.setLength(0).appendHexDump("abcdefghijk", -1, 0, 8, "%3d: ", true, 2, 4);
-               printf("%s", buf.str());
-               checkEqu(" 20: 090ac3bc 32333435....2345\n"
-                       " 28: 36373839 783132336789x123\n"
-                       " 36: 343536           456     \n", buf.str());
+               checkEqu("  0: 6162 6364  6566 6768 | abcd efgh\n"
+                            "  8: 696a 6b              | ijk      \n", buf.str());
        }
        void testFill(){
                ReByteBuffer buf;
@@ -271,10 +278,10 @@ private:
                checkEqu("123", buffer.buffer());
                checkEqu(3u, buffer.length());
 
-               buffer.setLengthAndFillOut(511, 'y');
-               buffer.setLengthAndFillOut(512, 'z');
-               checkEqu("yyz", buffer.buffer() + 509);
-               checkEqu(521u, buffer.capacity());
+               buffer.setLengthAndFillOut(PRIMARY_BUFFER_SIZE - 1, 'y');
+               buffer.setLengthAndFillOut(PRIMARY_BUFFER_SIZE, 'z');
+               checkEqu("yyz", buffer.buffer() + PRIMARY_BUFFER_SIZE - 3);
+               checkEqu(PRIMARY_BUFFER_SIZE + 10 - 1, (int) buffer.capacity());
 
                ReByteBuffer buffer2;
                buffer2.set("xyz", -1);
index 11d890135405e40fe55a7e4832f25a98833d41f9..20bda85310567fd189578c1f9b7055350a579134 100644 (file)
@@ -196,7 +196,7 @@ private:
                ReSeqArray list;
                ReByteBuffer value;
                ReSeqArray::Tag tag = 0;
-
+               list.setSizes(8, 4);
                list.add(-1, "xxx", -1, ReSeqArray::Tag(1l) << 31);
                checkT(list.get(0, value, &tag));
                checkEqu(1ll << 31, tag);
index 8960425720124b6e0f14a2e3e6f6010ff34b0590..f9ca28a4fb2ecb07b2cdaf63c125adb79810c6ce 100644 (file)
@@ -13,8 +13,8 @@
 #endif
 
 void testBase(){
-       extern void testReByteBuffer();
-       testReByteBuffer();
+       extern void testReSeqArray(void);
+       testReSeqArray();
 
        extern void testReTestUnit();
        //testReTestUnit();
@@ -73,12 +73,12 @@ void testMath(){
 void testAll(){
        try
        {
-               testString();
-
                testOs();
+
                testBase();
-               testMath();
                testString();
+               testMath();
+               testOs();
        } catch (ReException e){
                fprintf(stderr, "testBase.cpp: unexpected exception: %s\n", e.getMessage());
        }
index 11d9bce8c35f46ab6f733045bd7cf4fd2002b0b5..193b94c0df71565ade75bc7b1d45f4e5ece268c7 100644 (file)
@@ -531,6 +531,9 @@ void ReDirOptions::optimizePathPattern(ReByteBuffer& buffer){
  * @param filter    OUT: the filter to set\r
  */\r
 void ReDirOptions::setFilterFromProgramArgs(ReDirEntryFilter_t& filter){\r
+{ ReByteBuffer buf;\r
+const char* ptr = m_programArgs.getString("pathpattern", buf);\r
+}\r
     ReByteBuffer buffer;\r
     if (m_programArgs.getString("younger", buffer)[0] != '\0')\r
         filter.m_maxAge = checkDate(buffer.str());\r
@@ -787,12 +790,11 @@ void ReDirStatistic::run(int argc, const char* argv[]){
                        if (ReStringUtils::lengthOfUnsigned(arg1, -1, (unsigned *) &depth) == 0)\r
                                m_programArgs.help("depth is not an integer", false, stdout);\r
                }\r
-        ReDirStatistic statistic;\r
         void (*proc) (const ReDirStatisticData& data,\r
                            ReDirStatistic& parent, ReByteBuffer& line) = &formatWithSizeFilesAndDirs;\r
         if (m_programArgs.getBool("kbyte"))\r
             proc = &formatLikeDu;\r
-        const ReStringList& list = statistic.calculate(m_programArgs.getArg(0), depth, proc);\r
+        const ReStringList& list = calculate(m_programArgs.getArg(0), depth, proc);\r
         ReByteBuffer buffer;\r
         for (size_t ix = 0; ix < list.count(); ix++){\r
             buffer.set(list.strOf(ix), list.strLengthOf(ix));\r
index d3f13bc59203a8797d066d5e1b806a753726a7c0..c934cb0a7c5b4a0056465afb1ca1960c40a37f89 100644 (file)
@@ -600,7 +600,7 @@ bool ReTraverser::initEntry(const ReByteBuffer& parent, const char* node, int le
 void ReTraverser::setPropertiesFromFilter(ReDirEntryFilter_t* filter){\r
        m_minLevel = filter->m_minDepth;\r
        m_maxLevel = filter->m_maxDepth;\r
-       m_dirPatterns = filter->m_pathPatterns;\r
+       setDirPattern(filter->m_pathPatterns);\r
 }\r
 \r
 /**\r
index b37766dbce30b360ebeafd54a52ef16d743b1497..1013d29cadf7cd77a26432eda8f0111d526c6151 100644 (file)
@@ -156,7 +156,7 @@ public:
      * @param pattern  pattern list for the subdirs to be entered
     */
     void setDirPattern(RePatternList* pattern)
-    { m_dirPatterns = pattern; }
+       { m_dirPatterns = pattern; m_dirPatterns->setIgnoreCase(true); }
     /** Sets the maximal depth.
      * @param value     the value to set
     */