113498266Sopenharmony_ci#!/usr/bin/env perl
213498266Sopenharmony_ci#***************************************************************************
313498266Sopenharmony_ci#                                  _   _ ____  _
413498266Sopenharmony_ci#  Project                     ___| | | |  _ \| |
513498266Sopenharmony_ci#                             / __| | | | |_) | |
613498266Sopenharmony_ci#                            | (__| |_| |  _ <| |___
713498266Sopenharmony_ci#                             \___|\___/|_| \_\_____|
813498266Sopenharmony_ci#
913498266Sopenharmony_ci# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1013498266Sopenharmony_ci#
1113498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which
1213498266Sopenharmony_ci# you should have received as part of this distribution. The terms
1313498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html.
1413498266Sopenharmony_ci#
1513498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell
1613498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is
1713498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file.
1813498266Sopenharmony_ci#
1913498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2013498266Sopenharmony_ci# KIND, either express or implied.
2113498266Sopenharmony_ci#
2213498266Sopenharmony_ci# SPDX-License-Identifier: curl
2313498266Sopenharmony_ci#
2413498266Sopenharmony_ci###########################################################################
2513498266Sopenharmony_ci
2613498266Sopenharmony_ci# provide all dir names to scan on the cmdline
2713498266Sopenharmony_ci
2813498266Sopenharmony_cisub convert {
2913498266Sopenharmony_ci    my ($dir)=@_;
3013498266Sopenharmony_ci    opendir(my $dh, $dir) || die "could not open $dir";
3113498266Sopenharmony_ci    my @cd = grep { /\.md\z/ && -f "$dir/$_" } readdir($dh);
3213498266Sopenharmony_ci    closedir $dh;
3313498266Sopenharmony_ci
3413498266Sopenharmony_ci    for my $cd (@cd) {
3513498266Sopenharmony_ci        my $nroff = "$cd";
3613498266Sopenharmony_ci        $nroff =~ s/\.md\z/.3/;
3713498266Sopenharmony_ci        print "$dir/$cd = $dir/$nroff\n";
3813498266Sopenharmony_ci        system("./scripts/cd2nroff -d $dir $dir/$cd");
3913498266Sopenharmony_ci    }
4013498266Sopenharmony_ci}
4113498266Sopenharmony_ci
4213498266Sopenharmony_cifor my $d (sort @ARGV) {
4313498266Sopenharmony_ci    convert($d);
4413498266Sopenharmony_ci}
45