1##
2## Copyright 2023 The Android Open Source Project
3##
4## Licensed under the Apache License, Version 2.0 (the "License");
5## you may not use this file except in compliance with the License.
6## You may obtain a copy of the License at
7##
8##      http://www.apache.org/licenses/LICENSE-2.0
9##
10## Unless required by applicable law or agreed to in writing, software
11## distributed under the License is distributed on an "AS IS" BASIS,
12## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13## See the License for the specific language governing permissions and
14## limitations under the License.
15
16use diagnostics;
17use strict;
18use warnings;
19
20##
21## Take a string of parameters in and return the parameter name commented out
22##
23## e.g.
24## int a, char b, std::string c => int /* a */, char /* b */, std::string /* c */
25##
26sub comment_out_input_vars {
27    my $input_param_string = shift @_;
28    my @return_param_string;
29    my @params = split /,/, $input_param_string;
30    foreach (@params) {
31        ## Trim leading and trailing space
32        s/^\s+|\s+$//g;
33        ## Reduce multiple internal spaces to single space
34        s/\s\+/ /g;
35        my @w = split /\s+/, $_;
36        my $s;
37        if ($#w != 0) {
38            chomp($w[$#w]);
39            $w[$#w] = "/* $w[$#w] */";
40        }
41        $s .= join " ", @w;
42        push(@return_param_string, $s);
43      }
44      return join(', ', @return_param_string);
45}
46
471;
48