mirror of https://github.com/libsdl-org/SDL.git
examples: Improve source code output when there are multiple files.
This commit is contained in:
parent
bc8b768b9a
commit
883576beb8
|
|
@ -80,12 +80,13 @@ sub handle_example_dir {
|
||||||
opendir(my $dh, "$examples_dir/$category/$example") or die("Couldn't opendir '$examples_dir/$category/$example': $!\n");
|
opendir(my $dh, "$examples_dir/$category/$example") or die("Couldn't opendir '$examples_dir/$category/$example': $!\n");
|
||||||
my $spc = '';
|
my $spc = '';
|
||||||
while (readdir($dh)) {
|
while (readdir($dh)) {
|
||||||
next if not /\.c\Z/; # only care about .c files.
|
|
||||||
my $path = "$examples_dir/$category/$example/$_";
|
my $path = "$examples_dir/$category/$example/$_";
|
||||||
next if not -f $path; # only care about files.
|
next if not -f $path; # only care about files.
|
||||||
push @files, $path;
|
push @files, $path if /\.[ch]\Z/; # add .c and .h files to source code.
|
||||||
$files_str .= "$spc$path";
|
if (/\.c\Z/) { # only care about .c files for compiling.
|
||||||
$spc = ' ';
|
$files_str .= "$spc$path";
|
||||||
|
$spc = ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
closedir($dh);
|
closedir($dh);
|
||||||
|
|
||||||
|
|
@ -124,7 +125,7 @@ sub handle_example_dir {
|
||||||
my $pid = open2(my $child_out, my $child_in, $highlight_cmd);
|
my $pid = open2(my $child_out, my $child_in, $highlight_cmd);
|
||||||
|
|
||||||
my $htmlified_source_code = '';
|
my $htmlified_source_code = '';
|
||||||
foreach (@files) {
|
foreach (sort(@files)) {
|
||||||
my $path = $_;
|
my $path = $_;
|
||||||
open my $srccode, '<', $path or die("Couldn't open '$path': $!\n");
|
open my $srccode, '<', $path or die("Couldn't open '$path': $!\n");
|
||||||
my $fname = "$path";
|
my $fname = "$path";
|
||||||
|
|
@ -133,6 +134,7 @@ sub handle_example_dir {
|
||||||
while (<$srccode>) {
|
while (<$srccode>) {
|
||||||
print $child_in $_;
|
print $child_in $_;
|
||||||
}
|
}
|
||||||
|
print $child_in "\n\n\n";
|
||||||
close($srccode);
|
close($srccode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue