1#!/bin/sed -f
2#
3# Copyright (c) 2014-2015 ARM Limited
4# All rights reserved
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# Authors: Andreas Sandberg
19
20# READ BEFORE EDITING:
21#
22# * Avoid adding or removing newlines (e.g., deleting matched lines). It's
23#   much easier to understand the Doxygen logs if they point to the right
24#   line in the source files.
25#
26# * SED can be hard to read, so please document what your replacement rules
27#   are supposed to do and why.
28#
29
30# Handle TODO/FIXME/BUG comments
31/\/\/ \(TODO\|FIXME\|BUG\):/ {
32    # Transform the first line of the comment block into a Doxygen C++ comment.
33    s/\([^\]\)\/\/ /\1\/\/\/ /;
34
35    : todo_comment_cont
36    # Replace any TODO/FIXME/BUG commands with Doxygen equivalents
37    s/\(TODO\|FIXME\):/@todo /;
38    s/\(BUG\):/@bug /;
39    # Get the next line
40    n;
41    # If this line is only contains whitespace and a comment, it is a
42    # conntinuation of the previous line. If so, make it a Doxygen comment.
43    s/\([:space:]*\)\/\/\([^\/]\)/\1\/\/\/\2/ ;
44    # Try to match another line if the previous s command matched a line.
45    t todo_comment_cont;
46}
47