Browse Source

Cleanup

multi-byte
J. King 6 years ago
parent
commit
106167ab39
  1. 3
      .php_cs.dist
  2. 3
      RoboFile.php
  3. 4
      lib/Encoding/EUCJP.php
  4. 2
      lib/Encoding/EUCKR.php
  5. 4
      tools/mkindex.php
  6. 3
      tools/mktest.php

3
.php_cs.dist

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/** @license MIT
* Copyright 2018 J. King et al.
* See LICENSE and AUTHORS files for details */
@ -15,9 +16,11 @@ $paths = [
BASE."lib",
BASE."perf",
BASE."tests",
BASE."tools",
];
$rules = [
'@PSR2' => true,
'declare_strict_types' => true,
'braces' => ['position_after_functions_and_oop_constructs' => "same"],
'function_declaration' => ['closure_function_spacing' => "none"],
];

3
RoboFile.php

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Robo\Result;
@ -68,7 +69,7 @@ class RoboFile extends \Robo\Tasks {
/** Runs the coding standards fixer */
public function clean($opts = ['demo|d' => false]): Result {
$t = $this->taskExec(realpath(self::BASE."vendor/bin/php-cs-fixer"));
$t->arg("fix");
$t->arg("fix")->arg("--allow-risky=yes");
if ($opts['demo']) {
$t->args("--dry-run", "--diff")->option("--diff-format", "udiff");
}

4
lib/Encoding/EUCJP.php

@ -45,7 +45,7 @@ class EUCJP implements StatelessEncoding {
$jis0212 = true;
$lead = $b;
continue;
}
}
$pointer = null;
if (($lead >= 0xA1 && $lead <= 0xFE) && ($b >= 0xA1 && $b <= 0xFE)) {
$pointer = ($lead - 0xA1) * 94 + $b - 0xA1;
@ -143,7 +143,7 @@ class EUCJP implements StatelessEncoding {
$pos[] = $this->posByte;
$this->nextCode();
} while ($this->posByte < $start);
// finally pop off character offsets until either the definite trail byte or the requested final position is reached
// finally pop off character offsets until either the definite trail byte or the requested final position is reached
$this->posChar = $char;
while ($distance > 0 && sizeof($pos) > 0) {
$this->posChar--;

2
lib/Encoding/EUCKR.php

File diff suppressed because one or more lines are too long

4
tools/mkindex.php

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
$labels = [
'big5' => "big5",
'euc-jp' => "eucjp",
@ -46,7 +47,7 @@ if (!isset($labels[$label])) {
function single_byte(string $label) {
$entries = read_index($label, "https://encoding.spec.whatwg.org/index-$label.txt");
$dec_char = make_decoder_char_array($entries);
$dec_code = make_decoder_point_array($entires);
$dec_code = make_decoder_point_array($entries);
$enc = make_encoder_array($entries);
echo "const TABLE_DEC_CHAR = $dec_char;\n";
echo "const TABLE_DEC_CODE = $dec_code;\n";
@ -167,6 +168,7 @@ function make_decoder_point_array(array $entries): string {
function make_decoder_char_array(array $entries): string {
$out = [];
$i = 0;
foreach ($entries as $match) {
$index = (int) $match[1];
$code = $match[2];

3
tools/mktest.php

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
// this script generates a test series from the Web Platform test suite which exercises the index tables of multi-byte encodings with single characters
// they are pedantic sets of tests, and so the test suite itself only uses this series in optional tests
@ -35,7 +36,7 @@ if (!isset($tests[$label])) {
die("Invalid label specified. Must be one of: ".json_encode(array_keys($tests)));
}
foreach($tests[$label] as $name => $url) {
foreach ($tests[$label] as $name => $url) {
$data = make_test($label, $url);
$in = $data[0];
$out = $data[1];

Loading…
Cancel
Save