]> granicus.if.org Git - strace/blob - maint/update_copyright_years.awk
nlattr: add UID/GID netlink attribute decoders
[strace] / maint / update_copyright_years.awk
1 # External variables:
2 #   COMMENT_MARKER    - marks beginning of the comment on the line
3 #   COMMENT_MARKER_RE - the same as previous, but in form usable
4 #                       as a part of a regular expression
5 #   COPYRIGHT_MARKER  - text inside comment
6 #   COPYRIGHT_NOTICE  - copyright notice text to insert
7
8 BEGIN {
9         # States:
10         #   0 - before finding copyright notice
11         #   1 - in copyright notice or its continuation
12         #   2 - right after the end of copyright notice
13         #   3 - copyright notice added
14         state = 0
15         prefix = " "
16
17         comment_re = "^" COMMENT_MARKER_RE
18         copyright_re = comment_re "([[:space:]]*)" COPYRIGHT_MARKER
19         copyright_cont_re = copyright_re
20 }
21
22 state <= 1 && match($0, copyright_re, a) {
23         state = 1
24         prefix = a[1]
25         # set copyright notice continuation
26         copyright_cont_re = comment_re a[1] "[[:space:]]"
27 }
28
29 # this is neither copyright notice nor its continuation
30 state == 1 && ($0 !~ copyright_re) && ($0 !~ copyright_cont_re) {
31         state = 2
32 }
33
34 state == 2 {
35         print COMMENT_MARKER prefix COPYRIGHT_NOTICE
36         state = 3
37 }
38
39 {
40         print
41 }
42
43 END {
44         exit 3 - state
45 }