/ Check-in [137a26a0bf]
DEMO | DOWNLOAD | DEPLOY | SEARCH
Login

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

Overview
Comment:Fix markdown memory leak. Support "-m Markdown" instead of "-m Jsi_Markdown", etc...
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:137a26a0bfd1f2a9bbdba62bd2d1955e0193868a
User & Date: pmacdona 2019-06-11 15:33:31
Context
2019-06-14
19:00
pre-release "2.8.37". check-in: 36306fb935 user: pmacdona tags: trunk
2019-06-11
15:33
Fix markdown memory leak. Support "-m Markdown" instead of "-m Jsi_Markdown", etc... check-in: 137a26a0bf user: pmacdona tags: trunk
2019-06-09
15:34
Tests. check-in: fd4864866e user: pmacdona tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/jsiInterp.c.

780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795












796

797
798
799

800
801
802
803
804
805
806
                break;
            case 'm':
                if (argc <= 2)
                    rc = Jsi_LogError("missing argument");
                else if (argv[2][0] == '-')
                    rc = Jsi_EvalString(interp, "runModule('Jsi_Module');", JSI_EVAL_ISMAIN);
                else {
                    Jsi_DString dStr = {};
                    const char *cps, *cpe;
                    cps = Jsi_Strrchr(argv[2], '/');
                    if (cps) cps++; else cps = argv[2];
                    cpe = Jsi_Strrchr(cps, '.');
                    int len = (cpe?cpe-cps:(int)Jsi_Strlen(cps));
                    if (cpe)
                        Jsi_DSPrintf(&dStr, "source(\"%s\");", argv[2]);
                    else












                        Jsi_DSPrintf(&dStr, "require(\"%s\");", argv[2]);

                    Jsi_DSPrintf(&dStr, "puts(runModule(\"%.*s\",console.args.slice(1)));", len, cps);
                    rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
                    Jsi_DSFree(&dStr);

                }
                break;
            case 's':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Safe');", JSI_EVAL_ISMAIN);
                break;
            case 'S':
                rc = Jsi_EvalString(interp, "runModule('Jsi_SqliteUI');", JSI_EVAL_ISMAIN);







|







|
>
>
>
>
>
>
>
>
>
>
>
>
|
>



>







780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
                break;
            case 'm':
                if (argc <= 2)
                    rc = Jsi_LogError("missing argument");
                else if (argv[2][0] == '-')
                    rc = Jsi_EvalString(interp, "runModule('Jsi_Module');", JSI_EVAL_ISMAIN);
                else {
                    Jsi_DString dStr = {}, eStr = {};
                    const char *cps, *cpe;
                    cps = Jsi_Strrchr(argv[2], '/');
                    if (cps) cps++; else cps = argv[2];
                    cpe = Jsi_Strrchr(cps, '.');
                    int len = (cpe?cpe-cps:(int)Jsi_Strlen(cps));
                    if (cpe)
                        Jsi_DSPrintf(&dStr, "source(\"%s\");", argv[2]);
                    else {
                        const char *av = argv[2];
                        if (Jsi_Strncmp(av, "Jsi_", 4)) { // Support Jsi_Safe using just Safe, etc.
                            Jsi_DSPrintf(&eStr, "%s/lib/Jsi_%s.jsi", JSI_ZVFS_DIR, av);
                            Jsi_Value *fv = jsi_AccessFile(interp, Jsi_DSValue(&eStr), R_OK);
                            if (fv) {
                                Jsi_DecrRefCount(interp, fv);
                                Jsi_DSFree(&eStr);
                                Jsi_DSPrintf(&eStr, "Jsi_%s", av);
                                cps = av = Jsi_DSValue(&eStr);
                                len = Jsi_Strlen(cps);
                            }
                        }
                        Jsi_DSPrintf(&dStr, "require(\"%s\");", av);
                    }
                    Jsi_DSPrintf(&dStr, "puts(runModule(\"%.*s\",console.args.slice(1)));", len, cps);
                    rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
                    Jsi_DSFree(&dStr);
                    Jsi_DSFree(&eStr);
                }
                break;
            case 's':
                rc = Jsi_EvalString(interp, "runModule('Jsi_Safe');", JSI_EVAL_ISMAIN);
                break;
            case 'S':
                rc = Jsi_EvalString(interp, "runModule('Jsi_SqliteUI');", JSI_EVAL_ISMAIN);

Changes to src/jsiMarkdown.c.

436
437
438
439
440
441
442

443
444
445
446
447
448
449
...
746
747
748
749
750
751
752

753
754
755
756
757
758
759
...
770
771
772
773
774
775
776

777
778
779
780
781
782
783
...
798
799
800
801
802
803
804

805
806
807
808
809
810
811
812

813
814
815
816
817
818
819
...
837
838
839
840
841
842
843

844
845
846
847
848
849
850
....
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
....
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831


1832
1833
1834
1835
1836
1837
1838
            /* no action from the callback */
            end = i+1;
        } else {
            i += end;
            end = i;
        }
    }

}


/* find_emph_char -- looks for the next emph char, skipping other constructs */
static size_t find_emph_char(char *data, size_t size, char c) {
    size_t i = 1;

................................................................................
    }

    /* real code span */
    if( f_begin<f_end ) {
        Jsi_DString work = {};
        jsi_DSInitAppend(&work, data+f_begin, f_end-f_begin);
        if( !rndr->make.codespan(ob, &work, rndr->make.opts) ) end = 0;

    } else {
        if( !rndr->make.codespan(ob, 0, rndr->make.opts) ) end = 0;
    }
    return end;
}


................................................................................
        if( rndr->make.normal_text ) {
            jsi_DSInitAppend(&work, data+1,1);
            rndr->make.normal_text(ob, &work, rndr->make.opts);
        } else {
            Jsi_DSAppendLen(ob, data+1, 1);
        }
    }

    return 2;
}


/* char_entity -- '&' escaped when it doesn't belong to an entity */
/* valid entities are assumed to be anything matching &#?[A-Za-z0-9]+; */
static size_t char_entity(
................................................................................
        end++;
    }
    if( end<size && data[end]==';' ) {
        /* real entity */
        end++;
    } else {
        /* lone '&' */

        return 0;
    }
    if( rndr->make.entity ) {
        jsi_DSInitAppend(&work, data, end);
        rndr->make.entity(ob, &work, rndr->make.opts);
    } else {
        Jsi_DSAppendLen(ob, data, end);
    }

    return end;
}


/* char_langle_tag -- '<' when tags or autolinks are allowed */
static size_t char_langle_tag(
    Jsi_DString *ob,
................................................................................
    }

    if( !ret ) {
        return 0;
    } else {
        return end;
    }

}


/* get_link_inline -- extract inline-style link and title from
** parenthesed data
*/
static int get_link_inline(
................................................................................
                    rndr->make.blockhtml(ob, &work, rndr->make.opts);
                    return work_size;
                }
            }
        }

        /* no special case recognised */
        return 0;
    }

    /* looking for an unindented matching closing tag */
    /*  followed by a blank line */
    i = 1;
    found = 0;
#if 0
................................................................................
                i += j-1;
                found = 1;
                break;
            }
        }
    }

    if( !found ) return 0;

    /* the end of the block has been found */
    jsi_DSInitAppend(&work, data, i);
    if( rndr->make.blockhtml ) {
        rndr->make.blockhtml(ob, &work, rndr->make.opts);
    }


    return i;
}


/* parse_table_cell -- parse a cell inside a table */
static void parse_table_cell(
    Jsi_DString *ob,     /* output blob */







>







 







>







 







>







 







>








>







 







>







 







|







 







|






>
>







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
...
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
...
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
...
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
...
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
....
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
....
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
            /* no action from the callback */
            end = i+1;
        } else {
            i += end;
            end = i;
        }
    }
    Jsi_DSFree(&work);
}


/* find_emph_char -- looks for the next emph char, skipping other constructs */
static size_t find_emph_char(char *data, size_t size, char c) {
    size_t i = 1;

................................................................................
    }

    /* real code span */
    if( f_begin<f_end ) {
        Jsi_DString work = {};
        jsi_DSInitAppend(&work, data+f_begin, f_end-f_begin);
        if( !rndr->make.codespan(ob, &work, rndr->make.opts) ) end = 0;
        Jsi_DSFree(&work);
    } else {
        if( !rndr->make.codespan(ob, 0, rndr->make.opts) ) end = 0;
    }
    return end;
}


................................................................................
        if( rndr->make.normal_text ) {
            jsi_DSInitAppend(&work, data+1,1);
            rndr->make.normal_text(ob, &work, rndr->make.opts);
        } else {
            Jsi_DSAppendLen(ob, data+1, 1);
        }
    }
    Jsi_DSFree(&work);
    return 2;
}


/* char_entity -- '&' escaped when it doesn't belong to an entity */
/* valid entities are assumed to be anything matching &#?[A-Za-z0-9]+; */
static size_t char_entity(
................................................................................
        end++;
    }
    if( end<size && data[end]==';' ) {
        /* real entity */
        end++;
    } else {
        /* lone '&' */
        Jsi_DSFree(&work);
        return 0;
    }
    if( rndr->make.entity ) {
        jsi_DSInitAppend(&work, data, end);
        rndr->make.entity(ob, &work, rndr->make.opts);
    } else {
        Jsi_DSAppendLen(ob, data, end);
    }
    Jsi_DSFree(&work);
    return end;
}


/* char_langle_tag -- '<' when tags or autolinks are allowed */
static size_t char_langle_tag(
    Jsi_DString *ob,
................................................................................
    }

    if( !ret ) {
        return 0;
    } else {
        return end;
    }
    Jsi_DSFree(&work);
}


/* get_link_inline -- extract inline-style link and title from
** parenthesed data
*/
static int get_link_inline(
................................................................................
                    rndr->make.blockhtml(ob, &work, rndr->make.opts);
                    return work_size;
                }
            }
        }

        /* no special case recognised */
        i=0; goto done;
    }

    /* looking for an unindented matching closing tag */
    /*  followed by a blank line */
    i = 1;
    found = 0;
#if 0
................................................................................
                i += j-1;
                found = 1;
                break;
            }
        }
    }

    if( !found ) {i=0; goto done;}

    /* the end of the block has been found */
    jsi_DSInitAppend(&work, data, i);
    if( rndr->make.blockhtml ) {
        rndr->make.blockhtml(ob, &work, rndr->make.opts);
    }
done:
    Jsi_DSFree(&work);
    return i;
}


/* parse_table_cell -- parse a cell inside a table */
static void parse_table_cell(
    Jsi_DString *ob,     /* output blob */