𝌔 Fossil Hub
Login | Fossil manual |
phptags tag tidier

Check-in [18003543bc]

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

Overview
Comment:Exchange preg_replace/e for _callback. (Technically unnecessary due to pre-constrained input, but would generate notices; and looks leaner split up.)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:18003543bc71e40f22a7fdf37a7c7a0dc419ff6a
User & Date: mario 2014-11-11 12:26:16
Context
2014-11-13
19:42
Now using `fpm` (with exe.rb/makesfx.exe) instead of `epm` for packaging. check-in: 2129130770 user: mario tags: trunk
2014-11-11
12:26
Exchange preg_replace/e for _callback. (Technically unnecessary due to pre-constrained input, but would generate notices; and looks leaner split up.) check-in: 18003543bc user: mario tags: trunk
12:01
Rewritten intro, general formatting (italic for tags, bold for cmdline opts), details on -D and config override file, env vars, and note about --recursive being builtin. check-in: caa59654f2 user: mario tags: trunk
Changes

Changes to phptags.

461
462
463
464
465
466
467








468


469

470
471
472
473
474
475
476
477
478





479
480
481
482
483
484
485
486


/**
 * Colorize control + non-printable characters and/or replace with C-string escapes.
 *
 */
function nonprint_visualize($str) {








    global $action;


    $map = $action->color ? array(

        "\r" => "\x1b[32m\\r\x1b[39m",
        "\n" => "\x1b[31m\\n\x1b[39m",
        "\t" => "\x1b[36m\\t\x1b[39m",
        " "  => "\x1b[34m\\x20\x1b[39m",
        "\\0" => "\x1b[41;1;33m\\0\x1b[0;39m",
        "\\"  => "\x1b[35m\\\\\x1b[39m",
        "\xEF\xBB\xBF" => "\x1b[4;1;36m\\xEF\\xBB\\xBF\x1b[0;39m",
    ) : array();
    return preg_replace("~\\xEF\\xBB\\xBF|[^\w-.,;:#*+´`\'\"!§$%&/()={}?<>|]~e",





           "isset(\$map['$0']) ? \$map['$0'] : '\\x'.strtoupper(current(unpack('H*','$0')))", $str);
}



#-- tokenizer --









>
>
>
>
>
>
>
>

>
>
|
>
|
|
|
|
|
|
|
<
<
>
>
>
>
>
|







461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487


488
489
490
491
492
493
494
495
496
497
498
499
500


/**
 * Colorize control + non-printable characters and/or replace with C-string escapes.
 *
 */
function nonprint_visualize($str) {
    return preg_replace_callback(
        "~\\xEF\\xBB\\xBF|[^\w-.,;:#*+´`\'\"!§$%&/()={}?<>|]~",
        "nonprint_visualize_rx_cb",
        $str
    );
}
// match callback
function nonprint_visualize_rx_cb($m) {
    global $action;
    // map
    static $map = array();
    if ($action->color) {
        $map = array(
            "\r" => "\x1b[32m\\r\x1b[39m",
            "\n" => "\x1b[31m\\n\x1b[39m",
            "\t" => "\x1b[36m\\t\x1b[39m",
            " "  => "\x1b[1;30m␣\x1b[0;39m",
            "\\0" => "\x1b[41;1;33m\\0\x1b[0;39m",
            "\\"  => "\x1b[35m\\\\\x1b[39m",
            "\xEF\xBB\xBF" => "\x1b[4;1;36m\\xEF\\xBB\\xBF\x1b[0;39m",


        );
    }
    // substitute if in colorization $map
    return isset($map[$m[0]])
         ? $map[$m[0]]  // color replacement for common escapes & chars
         : '\\x' . strtoupper(current(unpack('H*', $m[0])));  // binary
}



#-- tokenizer --