xref: /openssl/util/merge-err-lines (revision 8c0e7681)
1#! /usr/bin/env perl
2# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the Apache License 2.0 (the "License").  You may not use
5# this file except in compliance with the License.  You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9# Sometimes calls to XXXerr() are split into two lines, because the define'd
10# names are very long.  This script looks for those lines and merges them.
11# It should be run before the "err-to-raise" script.
12
13# Run this program like this:
14#       perl -pi util/merge-err-lines files...
15# or
16#       git grep -l '[A-Z0-9]err([^)]*$' | xargs perl -pi util/merge-err-lines
17
18use strict;
19use warnings;
20
21# Look for "{whitespace}XXXerr(no-close-paren{WHITESPACE}" lines
22if ( /^ *[_A-Z0-9]+err\([^)]+ *$/ ) {
23    my $copy = $_;
24    chop($copy);
25    $copy =~ s/ +$//;
26    my $next = <>;
27    $next =~ s/^ +//;
28    $_ = $copy . ' ' . $next;
29}
30