commit ef3e3b0e670dd6606ccbfd34f9116279d151cac2 Author: Joel Brobecker Date: Mon Jan 2 16:58:49 2012 +0400 Local changes to update-copyright. Not finalized yet - to be discussed with original authors. diff --git a/gdb/gnulib/extra/update-copyright b/gdb/gnulib/extra/update-copyright index d86a12b..f649d78 100755 --- a/gdb/gnulib/extra/update-copyright +++ b/gdb/gnulib/extra/update-copyright @@ -138,6 +138,22 @@ if (!$this_year || $this_year !~ m/^\d{4}$/) $this_year = $year + 1900; } +# Handling of prefixes that start a multi-line comment. +# In most cases when wrapping lines, the next line should start with +# spaces rather than the same prefix. +# +# By default, we wrap '/*' into " *". +my %multiline_prefixes = ('/*' => ' *'); + +# Process the MULTILINE_COMMENT_PREFIXES. They add and/or override +# the defautlts above. +for (split /^/, $ENV{MULTILINE_COMMENT_PREFIXES} || '') + { + next if (/^\s*$/); + s/\n+$//; # I do not understand why chomp($_); does not work here. + $multiline_prefixes{$_} = ' ' x length($_); + } + # Unless the file consistently uses "\r\n" as the EOL, use "\n" instead. my $eol = /(?:^|[^\r])\n/ ? "\n" : "\r\n"; @@ -149,14 +165,24 @@ while (/(^|\n)(.{0,$prefix_max})$copyright_re/g) { $leading = "$1$2"; $prefix = $2; - if ($prefix =~ /^(\s*\/)\*(\s*)$/) + + foreach my $p (keys %multiline_prefixes) { - $prefix =~ s,/, ,; - my $prefix_ws = $prefix; - $prefix_ws =~ s/\*/ /; # Only whitespace. - if (/\G(?:[^*\n]|\*[^\/\n])*\*?\n$prefix_ws/) + my $prefix_re = quotemeta($p); + + if ($prefix =~ /^\s*$prefix_re\s*$/) { - $prefix = $prefix_ws; + $prefix =~ s,$prefix_re,$multiline_prefixes{$p},; + + # FIXME: I don't understand the following but I think it is + # specific to handling "/* " (turning it into " * "). + # No longer needed with the current approach? + # my $prefix_ws = $prefix; + # $prefix_ws =~ s/\*/ /; # Only whitespace. + # if (/\G(?:[^*\n]|\*[^\/\n])*\*?\n$prefix_ws/) + # { + # $prefix = $prefix_ws; + # } } } $ws_re = '[ \t\r\f]'; # \s without \n