diff --git a/batch/makedist.sh b/batch/makedist.sh index bfaaa07a67..16ef2fe05d 100755 --- a/batch/makedist.sh +++ b/batch/makedist.sh @@ -257,6 +257,7 @@ src/documentinfo.php src/documentinfoset.php src/documenthashmatcher.php src/documentrequest.php +src/fieldchangeset.php src/fieldrender.php src/filefilter.php src/formatspec.php diff --git a/src/fieldchangeset.php b/src/fieldchangeset.php new file mode 100644 index 0000000000..97a34539ae --- /dev/null +++ b/src/fieldchangeset.php @@ -0,0 +1,55 @@ + */ + public $_m = []; + + const ABSENT = 0; + const UNCHANGED = 1; + const CHANGED = 2; + + /** @param ?string $s + * @return $this */ + function mark_unchanged($s) { + $this->apply($s, self::UNCHANGED); + return $this; + } + + /** @param ?string $s + * @return $this */ + function mark_changed($s) { + $this->apply($s, self::CHANGED); + return $this; + } + + /** @param string $src + * @param string $dst + * @return $this */ + function mark_synonym($src, $dst) { + $this->_m[$src] = $this->_m[$dst] = + ($this->_m[$src] ?? 0) | ($this->_m[$dst] ?? 0); + return $this; + } + + /** @param ?string $s + * @param 1|2 $bit */ + private function apply($s, $bit) { + foreach (explode(" ", $s ?? "") as $word) { + if ($word !== "") { + $this->_m[$word] = ($this->_m[$word] ?? 0) | $bit; + if (($colon = strpos($word, ":")) !== false) { + $px = substr($word, 0, $colon); + $this->_m[$px] = ($this->_m[$px] ?? 0) | $bit; + } + } + } + } + + /** @param string $key + * @return 0|1|2|3 */ + function test($key) { + return $this->_m[$key] ?? 0; + } +}