/ Check-in [04eb7ce14f]
DEMO | DOWNLOAD | DEPLOY | SEARCH
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix Jsi_GetBool to fail if empty string. wsdemo.jsi: client demo fix.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:04eb7ce14fef169ee7b971cfcb668407883128f4
User & Date: pmacdona 2019-05-16 14:58:54
Context
2019-05-21
14:05
Release "2.8.29". Fix length bug in non-zStr handling, eg. chan.read(N). check-in: 8c05719e99 user: pmacdona tags: trunk
2019-05-16
14:58
Fix Jsi_GetBool to fail if empty string. wsdemo.jsi: client demo fix. check-in: 04eb7ce14f user: pmacdona tags: trunk
2019-05-15
04:01
String.match, further fix. check-in: d9d4c2b3bc user: pmacdona tags: trunk
Changes

Changes to js-demos/wsdemo.jsi.

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        
    function WsFilter(ws:userobj, id:number, urlprot:string, ishttp:boolean) {
        printf("onFilter: %d %s %S\n", id, urlprot, ishttp);
        return true;
    }
    
    function WsRecv(ws:userobj, id:number, str:string) {
        puts("RECV: "+str);
        if (!self.client)
            self.ws.send(id, str);
    }
    
    function ClientSend(n) {
        var msg = 'hello world '+(n+1);
        LogDebug('SEND:', msg, n);
................................................................................
        }
        LogDebug("Starting:\n", conf, wsopts);
        debugger;
        self.ws = new WebSocket( wsopts );
        
        if (self.client)
            ClientSend(self.count);
        else
            exec('xdg-open http://127.0.0.1:'+self.port+'/'+self.file+' &');
        
        while (!self.done)
            update(10);
    }
    
    main();







|







 







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        
    function WsFilter(ws:userobj, id:number, urlprot:string, ishttp:boolean) {
        printf("onFilter: %d %s %S\n", id, urlprot, ishttp);
        return true;
    }
    
    function WsRecv(ws:userobj, id:number, str:string) {
        puts("RECV(srv="+!self.client+"): "+ str);
        if (!self.client)
            self.ws.send(id, str);
    }
    
    function ClientSend(n) {
        var msg = 'hello world '+(n+1);
        LogDebug('SEND:', msg, n);
................................................................................
        }
        LogDebug("Starting:\n", conf, wsopts);
        debugger;
        self.ws = new WebSocket( wsopts );
        
        if (self.client)
            ClientSend(self.count);
        else if (self.file != '')
            exec('xdg-open http://127.0.0.1:'+self.port+'/'+self.file+' &');
        
        while (!self.done)
            update(10);
    }
    
    main();

Changes to src/jsi.c.

19514
19515
19516
19517
19518
19519
19520


19521
19522
19523
19524
19525
19526
19527
.....
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
    
            Jsi_Value *val = Jsi_ValueMakeString(interp, NULL, 
                jsi_SubstrDup(str, pos[i].rm_so, pos[i].rm_eo - pos[i].rm_so));
            if (ofs)
                *ofs = pos[i].rm_eo;
            Jsi_ValueInsertArray(interp, ret, num_matches, val, 0);
            num_matches++;


        }
        if (num_matches && match && !isglob)
            return JSI_OK;
        if (num_matches == 1 && (ofs || !isglob))
            break;
        
        str += pos[0].rm_eo;
................................................................................

    return JsiCheckConversion(string, endptr);
}

Jsi_RC Jsi_GetBool(Jsi_Interp* interp, const char *string, bool *n)
{
    int len = Jsi_Strlen(string);
    if ((Jsi_Strncasecmp(string, "true", len)==0 && len<=4)) {
        *n = 1;
        return JSI_OK;
    }
    if ((Jsi_Strncasecmp(string, "false", len)==0 && len<=5)) {
        *n = 0;
        return JSI_OK;
    }
    return JSI_ERROR;
}

/* Converts a hex character to its integer value */







>
>







 







|



|







19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
.....
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
    
            Jsi_Value *val = Jsi_ValueMakeString(interp, NULL, 
                jsi_SubstrDup(str, pos[i].rm_so, pos[i].rm_eo - pos[i].rm_so));
            if (ofs)
                *ofs = pos[i].rm_eo;
            Jsi_ValueInsertArray(interp, ret, num_matches, val, 0);
            num_matches++;
            if ( match && isglob)
                break;
        }
        if (num_matches && match && !isglob)
            return JSI_OK;
        if (num_matches == 1 && (ofs || !isglob))
            break;
        
        str += pos[0].rm_eo;
................................................................................

    return JsiCheckConversion(string, endptr);
}

Jsi_RC Jsi_GetBool(Jsi_Interp* interp, const char *string, bool *n)
{
    int len = Jsi_Strlen(string);
    if (len && (Jsi_Strncasecmp(string, "true", len)==0 && len<=4)) {
        *n = 1;
        return JSI_OK;
    }
    if (len && (Jsi_Strncasecmp(string, "false", len)==0 && len<=5)) {
        *n = 0;
        return JSI_OK;
    }
    return JSI_ERROR;
}

/* Converts a hex character to its integer value */

Changes to src/jsiUtils.c.

2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245

    return JsiCheckConversion(string, endptr);
}

Jsi_RC Jsi_GetBool(Jsi_Interp* interp, const char *string, bool *n)
{
    int len = Jsi_Strlen(string);
    if ((Jsi_Strncasecmp(string, "true", len)==0 && len<=4)) {
        *n = 1;
        return JSI_OK;
    }
    if ((Jsi_Strncasecmp(string, "false", len)==0 && len<=5)) {
        *n = 0;
        return JSI_OK;
    }
    return JSI_ERROR;
}

/* Converts a hex character to its integer value */







|



|







2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245

    return JsiCheckConversion(string, endptr);
}

Jsi_RC Jsi_GetBool(Jsi_Interp* interp, const char *string, bool *n)
{
    int len = Jsi_Strlen(string);
    if (len && (Jsi_Strncasecmp(string, "true", len)==0 && len<=4)) {
        *n = 1;
        return JSI_OK;
    }
    if (len && (Jsi_Strncasecmp(string, "false", len)==0 && len<=5)) {
        *n = 0;
        return JSI_OK;
    }
    return JSI_ERROR;
}

/* Converts a hex character to its integer value */