tsSystem debug bug
@@ -6,7 +6,7 @@ | ||
6 | 6 | ############################################### |
7 | 7 | |
8 | 8 | our $fullPackageName = "[tinyState pseudo-coroutine]"; |
9 | -our $version = "[0.3.4]"; | |
9 | +our $version = "[0.3.5]"; | |
10 | 10 | our $bugReportAddress = "[http://www.globalbase.org/]"; |
11 | 11 | our $prog = "tinyState"; |
12 | 12 | our $dependency = "customInstall_alternative"; |
@@ -52,9 +52,6 @@ | ||
52 | 52 | count = 1; |
53 | 53 | } |
54 | 54 | |
55 | -uint8_t | |
56 | -gtData::debug; | |
57 | - | |
58 | 55 | void |
59 | 56 | gtData::add_backptr(gtData * obj) |
60 | 57 | { |
@@ -142,6 +142,8 @@ | ||
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | + | |
146 | + | |
145 | 147 | void * |
146 | 148 | sObject::operator new(size_t cbSize,const char * __file,int __line) |
147 | 149 | throw(std::bad_alloc) |
@@ -1,5 +1,6 @@ | ||
1 | 1 | |
2 | 2 | #include <stdio.h> |
3 | +#include <stdlib.h> | |
3 | 4 | #include "ts/c++/stdObject.h" |
4 | 5 | |
5 | 6 |
@@ -14,6 +15,7 @@ | ||
14 | 15 | { |
15 | 16 | this->ref = 0; |
16 | 17 | this->insert_zombie_list(); |
18 | + | |
17 | 19 | } |
18 | 20 | |
19 | 21 |
@@ -19,6 +19,7 @@ | ||
19 | 19 | return; |
20 | 20 | this->length(strlen(str)+1); |
21 | 21 | strcpy(&this->ary[0],str); |
22 | + | |
22 | 23 | } |
23 | 24 | |
24 | 25 | stdString::stdString(stdString * s) |
@@ -44,6 +45,7 @@ | ||
44 | 45 | sprintf(buffer,fmt,data); |
45 | 46 | length(len=strlen(buffer)); |
46 | 47 | memcpy(&this->ary[0],buffer,len+1); |
48 | + | |
47 | 49 | } |
48 | 50 | |
49 | 51 | stdString::stdString(const char * fmt,double data) |
@@ -57,6 +59,7 @@ | ||
57 | 59 | sprintf(buffer,fmt,data); |
58 | 60 | length(len=strlen(buffer)); |
59 | 61 | memcpy(&this->ary[0],buffer,len+1); |
62 | + | |
60 | 63 | } |
61 | 64 | |
62 | 65 | stdString::stdString(const char * fmt,void * data) |
@@ -70,6 +73,7 @@ | ||
70 | 73 | sprintf(buffer,fmt,data); |
71 | 74 | length(len=strlen(buffer)); |
72 | 75 | memcpy(&this->ary[0],buffer,len+1); |
76 | + | |
73 | 77 | } |
74 | 78 | |
75 | 79 | stdString::stdString(char ch) |
@@ -78,6 +82,7 @@ | ||
78 | 82 | { |
79 | 83 | this->ary[0] = ch; |
80 | 84 | this->ary[1] = 0; |
85 | + | |
81 | 86 | } |
82 | 87 | |
83 | 88 | stdString::stdString() |
@@ -84,6 +89,7 @@ | ||
84 | 89 | : |
85 | 90 | stdArray<char,false>(1) |
86 | 91 | { |
92 | + | |
87 | 93 | } |
88 | 94 | |
89 | 95 | stdString::stdString(const char * str,int sp,int ep) |
@@ -141,6 +147,10 @@ | ||
141 | 147 | void |
142 | 148 | stdString::length(int len) |
143 | 149 | { |
150 | + if ( len < 0 ) { | |
151 | + this->stdArray<char,false>::length(-1); | |
152 | + return; | |
153 | + } | |
144 | 154 | this->stdArray<char,false>::length(len+1); |
145 | 155 | this->ary[len] = 0; |
146 | 156 | } |
@@ -498,3 +508,4 @@ | ||
498 | 508 | return 0; |
499 | 509 | return NEW stdString(this,0,rx_work->match->ary[0].rm_so); |
500 | 510 | } |
511 | + |
@@ -429,6 +429,7 @@ | ||
429 | 429 | tinyState_::do_thread(TS_STATE_TYPE state,stdEvent * ev) |
430 | 430 | { |
431 | 431 | TS_STATE_FUNC func; |
432 | +TS_STATE_TYPE ret; | |
432 | 433 | func = this->getFunc(state); |
433 | 434 | return (*func)(this,ev); |
434 | 435 | } |
@@ -583,7 +584,8 @@ | ||
583 | 584 | void |
584 | 585 | tinyState_::remove_listener(stdEventHandle * eh) |
585 | 586 | { |
586 | - (*this->event_listener)[eh->type]->del(eh,0); | |
587 | + if ( (*this->event_listener)[eh->type] ) | |
588 | + (*this->event_listener)[eh->type]->del(eh,0); | |
587 | 589 | eh->listener->remove_handle(eh); |
588 | 590 | if ( check_listener ) |
589 | 591 | wakeup(); |
@@ -137,17 +137,6 @@ | ||
137 | 137 | REF_SET(this->commandLine,NEW stdString(commandLine)); |
138 | 138 | this->ret = this->do_exec(commandLine,fd_r,fd_w,fd_err,dmode); |
139 | 139 | this->dmode = dmode; |
140 | - if ( this->ret >= 0 ) { | |
141 | - sObject::refine_fd(*fd_r, | |
142 | - ifp->get_sobj_file(), | |
143 | - ifp->get_sobj_line()); | |
144 | - sObject::refine_fd(*fd_w, | |
145 | - ifp->get_sobj_file(), | |
146 | - ifp->get_sobj_line()); | |
147 | - sObject::refine_fd(*fd_err, | |
148 | - ifp->get_sobj_file(), | |
149 | - ifp->get_sobj_line()); | |
150 | - } | |
151 | 140 | *retp = ret; |
152 | 141 | } |
153 | 142 |
@@ -65,8 +65,6 @@ | ||
65 | 65 | |
66 | 66 | public: |
67 | 67 | |
68 | - static uint8_t debug; | |
69 | - | |
70 | 68 | gtData(short type): |
71 | 69 | type(type), |
72 | 70 | flags(0), |
@@ -258,12 +256,16 @@ | ||
258 | 256 | next(0), |
259 | 257 | str(0) |
260 | 258 | { |
259 | + | |
261 | 260 | REF_SET(this->str,_str); |
262 | 261 | } |
263 | 262 | virtual ~gtDataStringElement() { |
264 | 263 | REF_SET(str,0); |
265 | 264 | REF_SET(next,0); |
265 | + | |
266 | + | |
266 | 267 | } |
268 | + | |
267 | 269 | }; |
268 | 270 | |
269 | 271 | class gtDataString : public gtData { |
@@ -76,8 +76,13 @@ | ||
76 | 76 | } |
77 | 77 | void length(int len) { |
78 | 78 | int i,clen; |
79 | - if ( leng == len ) | |
80 | - return; | |
79 | + if ( len >= 0 ) { | |
80 | + if ( leng == len ) | |
81 | + return; | |
82 | + } | |
83 | + else { | |
84 | + len = leng; | |
85 | + } | |
81 | 86 | __TYPE * tmp = ary; |
82 | 87 | ary = new (__file,__line) __TYPE[len](); |
83 | 88 | clen = leng > len ? len : leng; |
@@ -21,6 +21,7 @@ | ||
21 | 21 | int key; |
22 | 22 | int count; |
23 | 23 | stdHalfOrderNode * n[2]; |
24 | + | |
24 | 25 | }; |
25 | 26 | |
26 | 27 | class stdHalfOrderQueue : public stdObject { |
@@ -8,6 +8,7 @@ | ||
8 | 8 | #include "ts/c++/ts_types.h" |
9 | 9 | #include "ts/c++/sObject.h" |
10 | 10 | |
11 | + | |
11 | 12 | class stdObject : public sObject { |
12 | 13 | public: |
13 | 14 |
@@ -26,6 +27,7 @@ | ||
26 | 27 | printf(const char * fmt,...); |
27 | 28 | |
28 | 29 | static const char * trace_all; |
30 | + | |
29 | 31 | protected: |
30 | 32 | virtual void refNotice() {} |
31 | 33 | virtual void refNotice1() {} |
@@ -43,6 +45,7 @@ | ||
43 | 45 | |
44 | 46 | static stdObject * zombie_list; |
45 | 47 | static int zombie_count; |
48 | + | |
46 | 49 | }; |
47 | 50 | |
48 | 51 |
@@ -57,7 +60,6 @@ | ||
57 | 60 | (*_tmp_x) = (_tmp); \ |
58 | 61 | } |
59 | 62 | |
60 | - | |
61 | 63 | #endif |
62 | 64 | |
63 | 65 |
@@ -15,6 +15,8 @@ | ||
15 | 15 | stdArray<stdString*> * values; |
16 | 16 | stdArray<regmatch_t,false> * match; |
17 | 17 | |
18 | + rxWork() { | |
19 | + } | |
18 | 20 | ~rxWork() { |
19 | 21 | REF_SET(values,0); |
20 | 22 | REF_SET(match,0); |
@@ -37,6 +39,7 @@ | ||
37 | 39 | |
38 | 40 | ~stdString() { |
39 | 41 | REF_SET(rx_work,0); |
42 | + | |
40 | 43 | }; |
41 | 44 | |
42 | 45 | int length(); |
@@ -75,8 +78,10 @@ | ||
75 | 78 | stdString * rxPrev(); |
76 | 79 | |
77 | 80 | unsigned debug:1; |
81 | + | |
78 | 82 | private: |
79 | 83 | rxWork * rx_work; |
84 | + | |
80 | 85 | }; |
81 | 86 | |
82 | 87 |