diff --git a/dev/tools/fixcopyrightheader.php b/dev/tools/fixcopyrightheader.php index f6b076e82ee..bda934bf3b7 100755 --- a/dev/tools/fixcopyrightheader.php +++ b/dev/tools/fixcopyrightheader.php @@ -120,16 +120,21 @@ function updateCopyrightNotice($filename, $fileType, $name, $email) } // Pattern to match the line matching the current developer - $pattern = "~(?:{$r_prefix0}|{$r_prefix1})Copyright \(C\)\s+(?:(?:\d{4}-)?(?\d{4}))\s+{$r_name}\s*\<{$r_email}>~"; + $pattern = "~(?:{$r_prefix0}|{$r_prefix1})Copyright \(C\)\s+(?:(?:(?\d{4})-)?(?\d{4}))\s+{$r_name}\s*\<{$r_email}>~"; // Check if the lines match the pattern $matches = array(); if (preg_match($pattern, $lines, $matches)) { - $existingYear = $matches['year']; + $existingYear = $matches['last']; + if (array_key_exists('start', $matches)) { + $startYear = $matches['start']; + } else { + $startYear = $existingYear; + } // Check if the existing year is different from the current year if ($existingYear !== date('Y')) { - // Update the year range to include or be up to the current year - $updatedNotice = preg_replace('/(\d{4})(-\d{4})?\s+/', $existingYear . '-' . date('Y') . "\t", $matches[0]); + // Extend the year range to the current year + $updatedNotice = preg_replace('/(?:\d{4}-)?\d{4}\s+/', $startYear . '-' . date('Y') . "\t", $matches[0]); // Replace the old notice with the updated one in the file file_put_contents($filename, preg_replace($pattern, $updatedNotice, file_get_contents($filename)));