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

Overview
Comment:Hardened isodate.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 4fed50bd75ba0e2c8abbf85624351c6b9432a56bb51f0060d376f11c05cb2db1
User & Date: rolf 2019-07-31 22:17:49
Context
2019-08-02
23:52
The comment is correct, adjusted the code to do what it say. check-in: 4d478f979b user: rolf tags: schema
2019-07-31
22:17
Hardened isodate. check-in: 4fed50bd75 user: rolf tags: schema
2019-07-23
23:54
Gardening around. Moved generation of all schmea related Tcl commands to tDOM_SchemaInit(). Moved the method 'status' as 'validationstatus' (alias 'vstatus') under the 'info' method and used the opportunity to start to define the schema command method info. check-in: e5493b6b50 user: rolf tags: schema
Changes

Changes to generic/schema.c.

4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601

4602
4603
4604
4605


4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
static int
isodateImpl (
    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    int i, y, m, d;

    if (*text == '-') {
        /* A bce date */
        text++;
    }
    for (i = 0; i < 4; i++) {
        if (*text < '0' || *text > '9') return 0;

        text++;
    }
    while (*text >= '0' && *text <= '9') text++;
    if (*text != '-') return 0;


    y = atoi(text-4);
    /* There isn't a year 0. it's either 0001 or -0001 */
    if (y == 0) return 0;
    text++;
    for (i = 0; i < 2; i++) {
        if (*text < '0' || *text > '9') return 0;
        text++;
    }
    if (*text != '-') return 0;
    m = atoi(text-2);







|







>




>
>
|

|







4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
static int
isodateImpl (
    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    int i, y, m, d, seenNonzero = 0;

    if (*text == '-') {
        /* A bce date */
        text++;
    }
    for (i = 0; i < 4; i++) {
        if (*text < '0' || *text > '9') return 0;
        if (*text != '0') seenNonzero = 1;
        text++;
    }
    while (*text >= '0' && *text <= '9') text++;
    if (*text != '-') return 0;
    /* We only need to know the modulo of the year for 4, 100 and 400,
     * for this the 4 last letters are enough */
    y = atoi(text-3);
    /* There isn't a year 0. it's either 0001 or -0001 */
    if (!seenNonzero) return 0;
    text++;
    for (i = 0; i < 2; i++) {
        if (*text < '0' || *text > '9') return 0;
        text++;
    }
    if (*text != '-') return 0;
    m = atoi(text-2);

Changes to tests/schema.test.

3184
3185
3186
3187
3188
3189
3190




3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
        <doc>-2004-02-29</doc>
        <doc>1900-02-29</doc>
        <doc>1234-02-01</doc>
        <doc>1234-08-10</doc>
        <doc>1234-08-222</doc>
        {<doc> 1234-08-22</doc>}
        {<doc>1234-08-22 </doc>}




    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 0}

test schema-14.10 {text: number} {
    tdom::schema s
    s define {
        defelement doc {
            text number
        }







>
>
>
>





|







3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
        <doc>-2004-02-29</doc>
        <doc>1900-02-29</doc>
        <doc>1234-02-01</doc>
        <doc>1234-08-10</doc>
        <doc>1234-08-222</doc>
        {<doc> 1234-08-22</doc>}
        {<doc>1234-08-22 </doc>}
        <doc>11234-08-22</doc>
        <doc>0000-02-01</doc>
        <doc>10000-08-22</doc>
        <doc>10000-02-29</doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 0 1 0 1 1}

test schema-14.10 {text: number} {
    tdom::schema s
    s define {
        defelement doc {
            text number
        }