From patchwork Sun Jan 1 11:29:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 37945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3730027wrt; Sun, 1 Jan 2023 03:29:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXtBIg3Bw9JDOmwUKkboSQRT9MAFgtJqMcPCn4ehwz+xNOxlUZKIKmx697ckwIegy2f/GDH3 X-Received: by 2002:a05:6402:1759:b0:46c:f631:c0dc with SMTP id v25-20020a056402175900b0046cf631c0dcmr28174813edx.12.1672572574400; Sun, 01 Jan 2023 03:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672572574; cv=none; d=google.com; s=arc-20160816; b=shcXZKXaKGCCF8Qk1pNjZ+c054t3ro30nJjcPOJl1udOcgJSClehOym15h5zNlwE+y 5DBBwAaz7pXcDX6Y5Qd2xZX5oeitpyWQE7tQGCXxeFlFSQwdRio6wApjb3+rIvYcm0F+ +2Xdm1dWXD20i9JKbv3OKMqG7ah6Chx750zjrrPH9rBxZopSwP6/G5A0EI7wVhvloyJ1 lEXz1gfVMOSzF5sqJDEPlDL8Bw8CZXZ/ghlkQ05l2XIhv+ts6TA6js8HPmWjfrMVOhXm m8yVIoD2GG4EeCOBdDrUeV0CIVHHVqeZusUwbthLKsjmDDnDlmPN6/eHIfDtZ4p0F+pW jZ1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :delivered-to:dkim-signature:dkim-filter; bh=fH7PgjtzroYmnAQZ7zgQOnucGdpJOPI+vIySV4EeLos=; b=lPckH3EHbvVizA3sq8PgnKRIkW7quDeA+f1waz9mNjvhGAznsop282+XovSx9pcjs3 PPYrHiZDYovME2rf9t/Wnkn0RT1eUudzxeNGePQDwB52Qd3m2atGPju5l/y5x4okME6d U2TQDCe4Qfuf/PVVmC3fIkFbJMZ5YbzIILBS4Wy9PrTsTCw10g0P8XPeNneG5rnLg2TO f+QucNsTkLeYDyVRF/VtiWPj2PGAO0FjeeBYCfIluDjbI8mJzpOTTp/8jZXF+em9aHsX x7x/tAiEs16tU83aCZGlKchvujfVY41tlKeJbUC3AneRpTdrKNwH6ituQpaYC4jDojVw f1fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=DriFeDc0; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qk34-20020a1709077fa200b008366ae33ecesi21830154ejc.171.2023.01.01.03.29.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Jan 2023 03:29:34 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=DriFeDc0; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3785E3858C62 for ; Sun, 1 Jan 2023 11:29:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3785E3858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672572573; bh=fH7PgjtzroYmnAQZ7zgQOnucGdpJOPI+vIySV4EeLos=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DriFeDc0ghDt2jtSgXXfC8IHOUZVKxtcjhA3mQMsIoFmW68r/zMmezQlOZHkaXGeA gnqWhzu5KJw0HhWbh1pDTiZ4sU6LAt6FWTeeUsT5waIx/eL3ER8AjKYrC3Sc8UZeFO q/QxMAV1S68gWVjvRvFbWSdT2ygiA4WrtQI8jGcQ= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 817E13858D1E for ; Sun, 1 Jan 2023 11:29:24 +0000 (GMT) Received: by mail-pf1-x436.google.com with SMTP id e21so7536742pfl.1 for ; Sun, 01 Jan 2023 03:29:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fH7PgjtzroYmnAQZ7zgQOnucGdpJOPI+vIySV4EeLos=; b=NXbZjH8utAX9N+pul1SZHUaUXh2gpt3VNheUmlYeypPztzuA5QsSmJqxVFgSG3zYxX WIUU7wly9rgNmclO9BKUTdeCRSoSDQMoXIq6UNAI9uVXZRJUr8Uk0YBeCmhB68nigKBI dYtu2VBFVB7YwXown36tHnqd4xsoItXv5UYv8DS9jFHbauDZVK0AokqDU32jFTE8BmCy x4Y6li8HeTF5TBbaExpxgNzoXYhma6vPH5rOfWszbkZ9+FVyivugC+HjK1nCCXHM77YL n7OxGXfHrkgfaxr0e8Sc7j0/HIAHMT79x+0c1Qt/Ya3cJxzx8YFJwil6WTkqPpB2+xox M0mg== X-Gm-Message-State: AFqh2koeiklFYcvwqO21b1wjw8G7TCxYrnTjUN4J14FtYP9qJNC5sVr1 ViPQ8k0GXMbdaj6fo9C+ZrlMkLvawkM= X-Received: by 2002:a62:1ec7:0:b0:56d:1e00:f078 with SMTP id e190-20020a621ec7000000b0056d1e00f078mr34285087pfe.32.1672572563133; Sun, 01 Jan 2023 03:29:23 -0800 (PST) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id x124-20020a623182000000b005779110635asm16663653pfx.51.2023.01.01.03.29.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Jan 2023 03:29:22 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 501E81142CDF; Sun, 1 Jan 2023 21:59:20 +1030 (ACDT) Date: Sun, 1 Jan 2023 21:59:20 +1030 To: binutils@sourceware.org Subject: Update etc/update-copyright.py Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753819459972408659?= X-GMAIL-MSGID: =?utf-8?q?1753819459972408659?= This picks up some improvements from gcc/contrib. exceptions must derive from BaseException, port to python3, retain original file mode, fix name of script in examples. Adds libsframe to list of default dirs. I would have added gprofng too but there are some files claiming copyright by authors other than the Free Software Foundation. diff --git a/etc/update-copyright.py b/etc/update-copyright.py index f0036cae212..fcbf1045d1b 100755 --- a/etc/update-copyright.py +++ b/etc/update-copyright.py @@ -1,6 +1,6 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -# Copyright (C) 2013-2022 Free Software Foundation, Inc. +# Copyright (C) 2013-2023 Free Software Foundation, Inc. # # This script is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,15 +23,15 @@ # output has been vetted. You can instead pass the names of individual # directories, including those that haven't been approved. So: # -# update-copyright.pl --this-year +# update-copyright.py --this-year # # is the command that would be used at the beginning of a year to update # all copyright notices (and possibly at other times to check whether # new files have been added with old years). On the other hand: # -# update-copyright.pl --this-year libjava +# update-copyright.py --this-year libiberty # -# would run the script on just libjava/. +# would run the script on just libiberty/. # # This script was copied from gcc's contrib/ and modified to suit # binutils. In contrast to the gcc script, this one will update @@ -60,7 +60,10 @@ class GenericFilter: def __init__ (self): self.skip_files = set() self.skip_dirs = set() - self.skip_extensions = set() + self.skip_extensions = set([ + '.png', + '.pyc', + ]) self.fossilised_files = set() self.own_files = set() @@ -238,7 +241,7 @@ class Copyright: def add_external_author (self, holder): self.holders[holder] = None - class BadYear(): + class BadYear (Exception): def __init__ (self, year): self.year = year @@ -315,7 +318,7 @@ class Copyright: # If it looks like the copyright is incomplete, add the next line. while not self.is_complete (match): try: - next_line = file.next() + next_line = file.readline() except StopIteration: break @@ -394,6 +397,15 @@ class Copyright: return (line != orig_line, line, next_line) + def guess_encoding (self, pathname): + for encoding in ('utf8', 'iso8859'): + try: + open(pathname, 'r', encoding=encoding).read() + return encoding + except UnicodeDecodeError: + pass + return None + def process_file (self, dir, filename, filter): pathname = os.path.join (dir, filename) if filename.endswith ('.tmp'): @@ -407,8 +419,11 @@ class Copyright: lines = [] changed = False line_filter = filter.get_line_filter (dir, filename) - with open (pathname, 'r') as file: + mode = None + encoding = self.guess_encoding(pathname) + with open (pathname, 'r', encoding=encoding) as file: prev = None + mode = os.fstat (file.fileno()).st_mode for line in file: while line: next_line = None @@ -432,9 +447,10 @@ class Copyright: # If something changed, write the new file out. if changed and self.errors.ok(): tmp_pathname = pathname + '.tmp' - with open (tmp_pathname, 'w') as file: + with open (tmp_pathname, 'w', encoding=encoding) as file: for line in lines: file.write (line) + os.fchmod (file.fileno(), mode) if self.use_quilt: subprocess.call (['quilt', 'add', pathname]) os.rename (tmp_pathname, pathname) @@ -442,7 +458,7 @@ class Copyright: def process_tree (self, tree, filter): for (dir, subdirs, filenames) in os.walk (tree): # Don't recurse through directories that should be skipped. - for i in xrange (len (subdirs) - 1, -1, -1): + for i in range (len (subdirs) - 1, -1, -1): if filter.skip_dir (dir, subdirs[i]): del subdirs[i] @@ -593,13 +609,18 @@ class BinutilsCmdLine (CmdLine): self.add_dir ('etc') self.add_dir ('gas') self.add_dir ('gdb') + self.add_dir ('gdbserver') + self.add_dir ('gdbsupport') self.add_dir ('gold') self.add_dir ('gprof') + self.add_dir ('gprofng') self.add_dir ('include') self.add_dir ('ld', LdFilter()) + self.add_dir ('libbacktrace') self.add_dir ('libctf') self.add_dir ('libdecnumber') self.add_dir ('libiberty') + self.add_dir ('libsframe') self.add_dir ('opcodes') self.add_dir ('readline') self.add_dir ('sim') @@ -616,6 +637,7 @@ class BinutilsCmdLine (CmdLine): 'ld', 'libctf', 'libiberty', + 'libsframe', 'opcodes', ]