Picol  Check-in [824d95ebfa]

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

Overview
Comment:picol.h: Clarify a comment and improve formatting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk | version-0.4.0
Files: files | file ages | folders
SHA1:824d95ebfa4097e4585d6f1260d9f0e2c52b67fa
User & Date: dbohdan 2020-07-14 08:33:12
Context
2020-07-14
08:33
picol.h: Clarify a comment and improve formatting. Leaf check-in: 824d95ebfa user: dbohdan tags: trunk, version-0.4.0
08:23
picolSource(): Initialize the buffers. check-in: a424361c16 user: dbohdan tags: trunk
Changes

Changes to picol.h.

469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
...
487
488
489
490
491
492
493

494
495
496
497
498
499
500
...
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
....
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
picolResult picolParseSep(picolParser *p);
picolResult picolParseString(picolParser *p);
picolResult picolParseVar(picolParser *p);
int picolQsortCompInt(const void* a, const void *b);
int picolQsortCompStr(const void* a, const void *b);
int picolQsortCompStrDecr(const void* a, const void *b);
picolResult picolQuoteForShell(char* dest, size_t dest_size, int argc,
                       const char** argv);
picolResult picolRegisterCmd(picolInterp *interp, const char *name,
                             picolFunc f, void *pd);
picolResult picolReplace(char* str, size_t str_size, char* from, char* to,
                         int nocase);
int picolScanInt(const char* str, int base);
picolResult picolSetFmtResult(picolInterp* interp, const char* fmt, int result);
picolResult picolSetIntVar(picolInterp *interp, const char *name, int value);
................................................................................
picolResult picolSource(picolInterp *interp, const char *filename);
int picolStrCompare(const char* a, const char* b, size_t len, int nocase);
picolResult picolUnsetVar(picolInterp* interp, const char* name);
picolBool picolWildEq(const char* pat, const char* str, int n);
picolCmd *picolGetCmd(picolInterp *interp, const char *name);
picolInterp* picolCreateInterp(void);
picolInterp* picolCreateInterp2(int register_core_cmds, int randomize);

picolVar *picolGetVar2(picolInterp *interp, const char *name, int global);
void picolDropCallFrame(picolInterp *interp);
void picolEscape(char *str, size_t str_size);
void picolInitInterp(picolInterp *interp);
void picolInitParser(picolParser *p, const char *text);
void* picolScanPtr(const char* str);
void picolRegisterCoreCmds(picolInterp *interp);
................................................................................

#endif /* PICOL_H */

/* -------------------------------------------------------------------------- */

#ifdef PICOL_IMPLEMENTATION

/* ---------------------------====-------------------------- parser functions */
void picolInitParser(picolParser* p, const char* text) {
    p->text  = p->pos = text;
    p->len   = strlen(text);
    p->start = 0;
    p->end = 0;
    p->insidequote = 0;
    p->type  = PICOL_PT_EOL;
................................................................................
            done=1;
        } else {
            *p = '\0';
        }
        if (PICOL_EQ(start, "args") && done) {
            int rc = picolList(buf, sizeof(buf), argc - a - 1, argv + a + 1);
            if (rc != PICOL_OK) {
                /* TODO: Handle the error correctly. */
                goto arityerr;
            }
            picolSetVar(interp, start, buf);
            a = argc-1;
            break;
        }
        if (++a > argc-1) {







|







 







>







 







|







 







|







469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
...
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
...
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
....
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
picolResult picolParseSep(picolParser *p);
picolResult picolParseString(picolParser *p);
picolResult picolParseVar(picolParser *p);
int picolQsortCompInt(const void* a, const void *b);
int picolQsortCompStr(const void* a, const void *b);
int picolQsortCompStrDecr(const void* a, const void *b);
picolResult picolQuoteForShell(char* dest, size_t dest_size, int argc,
                               const char** argv);
picolResult picolRegisterCmd(picolInterp *interp, const char *name,
                             picolFunc f, void *pd);
picolResult picolReplace(char* str, size_t str_size, char* from, char* to,
                         int nocase);
int picolScanInt(const char* str, int base);
picolResult picolSetFmtResult(picolInterp* interp, const char* fmt, int result);
picolResult picolSetIntVar(picolInterp *interp, const char *name, int value);
................................................................................
picolResult picolSource(picolInterp *interp, const char *filename);
int picolStrCompare(const char* a, const char* b, size_t len, int nocase);
picolResult picolUnsetVar(picolInterp* interp, const char* name);
picolBool picolWildEq(const char* pat, const char* str, int n);
picolCmd *picolGetCmd(picolInterp *interp, const char *name);
picolInterp* picolCreateInterp(void);
picolInterp* picolCreateInterp2(int register_core_cmds, int randomize);
/* Currently you can't destroy interps. */
picolVar *picolGetVar2(picolInterp *interp, const char *name, int global);
void picolDropCallFrame(picolInterp *interp);
void picolEscape(char *str, size_t str_size);
void picolInitInterp(picolInterp *interp);
void picolInitParser(picolParser *p, const char *text);
void* picolScanPtr(const char* str);
void picolRegisterCoreCmds(picolInterp *interp);
................................................................................

#endif /* PICOL_H */

/* -------------------------------------------------------------------------- */

#ifdef PICOL_IMPLEMENTATION

/* --------------------------------------------------------- parser functions */
void picolInitParser(picolParser* p, const char* text) {
    p->text  = p->pos = text;
    p->len   = strlen(text);
    p->start = 0;
    p->end = 0;
    p->insidequote = 0;
    p->type  = PICOL_PT_EOL;
................................................................................
            done=1;
        } else {
            *p = '\0';
        }
        if (PICOL_EQ(start, "args") && done) {
            int rc = picolList(buf, sizeof(buf), argc - a - 1, argv + a + 1);
            if (rc != PICOL_OK) {
                /* TODO: Handle this error separately. */
                goto arityerr;
            }
            picolSetVar(interp, start, buf);
            a = argc-1;
            break;
        }
        if (++a > argc-1) {