Skip to content

Commit 1a2eccb

Browse files
committed
📌 Nodepp | JSON Bug Fixing | V1.2.12 📌
1 parent 12c252e commit 1a2eccb

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

include/nodepp/json.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace nodepp { class json_t {
2929

3030
protected:
3131

32-
long get_next_sec( ulong _pos, const string_t& str ) const {
32+
long get_next_sec( ulong _pos, const string_t& str ) const noexcept {
3333
uchar k=0; while( _pos < str.size() ){
3434
switch( str[_pos] ){
3535
case ':': k += 6; break; case ',': k -= 6; break;
@@ -42,7 +42,7 @@ namespace nodepp { class json_t {
4242
} return _pos >= str.size() ? -1 : _pos;
4343
}
4444

45-
long get_next_key( ulong _pos, const string_t& str ) const {
45+
long get_next_key( ulong _pos, const string_t& str ) const noexcept {
4646
bool x=1; uchar k=0; while( _pos < str.size() ){
4747
switch( str[_pos] ){
4848
case '[': k += 1; break; case ']': k -= 1; break;
@@ -51,19 +51,21 @@ namespace nodepp { class json_t {
5151
if( x ){ k+=5; x=!x; }
5252
else { k-=5; x=!x; }
5353
break;
54-
}
55-
if( k == 0 ){ break; } ++_pos;
54+
} if( k == 0 ){ break; } ++_pos;
5655
} return _pos >= str.size() ? -1 : _pos;
5756
}
5857

59-
object_t get_data( const string_t& data ) const {
58+
object_t get_data( const string_t& data ) const noexcept {
59+
6060
static regex_t reg1 = regex_t( "[a-z]" );
6161
static regex_t reg2 = regex_t( "[.]\\d+" );
6262
static regex_t reg3 = regex_t( "\\d+" );
6363

6464
ulong x=0; while( x < data.size() && data[x]==' ' ){ ++x; }
65-
if( data.empty() || data[x] == ',' ) /*---*/ { return nullptr; }
66-
elif( data[x] == '"' ) /*---------------*/ { return data.slice(1,-1); }
65+
66+
if ( data.empty() || data[x] == ',' ) /*---*/ { return nullptr; }
67+
elif( data[x] == '"' ) /*---------------*/ {
68+
return data.slice( x+1, get_next_sec( x, data ) ); }
6769
elif( data[x] == '{' ) /*---------------*/ { return parse( data ); }
6870
elif( data[x] == '[' ) /*---------------*/ { return parse( data ); }
6971
elif( data.find("false") ) /*---------------*/ { return (bool) 0; }
@@ -75,7 +77,7 @@ namespace nodepp { class json_t {
7577
else /*---------------------------------*/ { return string::to_float(data); }
7678
} elif( reg3.match(data).size()>9 ) /*----*/ { return string::to_long(data); }
7779
else /*---------------------------------*/ { return string::to_int(data); }
78-
80+
7981
}
8082

8183
object_t get_object( ulong x, ulong y, const string_t& str ) const {
@@ -279,10 +281,10 @@ namespace nodepp { namespace json {
279281
namespace nodepp { namespace json {
280282
template< class... T >
281283
string_t stringify( const T&... args ){
282-
return format( args... );
284+
return format( args... );
283285
}
284286
}}
285287

286288
/*────────────────────────────────────────────────────────────────────────────*/
287289

288-
#endif
290+
#endif

include/nodepp/posix/mutex.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
namespace nodepp { namespace worker {
1818

19-
void delay( ulong time ){ process::delay(time); }
20-
void yield(){ delay(TIMEOUT); sched_yield(); }
21-
int pid(){ return (int)pthread_self(); }
22-
void exit(){ pthread_exit(NULL); }
19+
void delay( ulong time ){ process::delay(time); }
20+
void yield(){ delay(TIMEOUT); sched_yield(); }
21+
pthread_t pid(){ return pthread_self(); }
22+
void exit(){ pthread_exit(NULL); }
2323

2424
}}
2525

include/nodepp/posix/worker.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ namespace nodepp { class worker_t {
7171

7272
/*─······································································─*/
7373

74-
int pid() const noexcept { return type::cast<int>(obj->id); }
75-
void off() const noexcept { process::clear( obj->out ); }
76-
void close() const noexcept { process::clear( obj->out ); }
74+
pthread_t pid() const noexcept { return obj->id; }
75+
76+
/*─······································································─*/
77+
78+
void off() const noexcept { process::clear( obj->out ); }
79+
void close() const noexcept { process::clear( obj->out ); }
7780

7881
/*─······································································─*/
7982

include/nodepp/windows/mutex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace nodepp { namespace worker {
1919

2020
void delay( ulong time ){ process::delay(time); }
2121
void yield(){ delay(TIMEOUT); SwitchToThread(); }
22-
int pid(){ return GetCurrentThreadId(); }
22+
DWORD pid(){ return GetCurrentThreadId(); }
2323
void exit(){ ExitThread(0); }
2424

2525
}}

include/nodepp/windows/worker.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ namespace nodepp { class worker_t {
7272

7373
/*─······································································─*/
7474

75-
int pid() const noexcept { return type::cast<int>(obj->id); }
75+
DWORD pid() const noexcept { return obj->id; }
76+
77+
/*─······································································─*/
78+
7679
void off() const noexcept { process::clear( obj->out ); }
7780
void close() const noexcept { process::clear( obj->out ); }
7881

0 commit comments

Comments
 (0)