This repository was archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathfixrc.pl
More file actions
executable file
·92 lines (71 loc) · 1.93 KB
/
Copy pathfixrc.pl
File metadata and controls
executable file
·92 lines (71 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/perl -w
# Fixes .rc files generated by Microsoft Developer Studio so that windres will
# correctly interpret them. To ensure correct paths to files, execute this script
# from the same place you will execute windres.
use strict;
my $Infile;
my $Outfile;
my $PathPrefix;
# Process command line arguments
for ( my $i = 0; $i < scalar @ARGV; $i++ ) {{
# Output file
if ( $ARGV[$i] =~ /^-o/i ) {
if ( $ARGV[$i] =~ /^-o$/i ) {
$i++;
if ( $i < scalar @ARGV ) {
$Outfile = $ARGV[$i];
}
} else {
$ARGV[$i] =~ /(?<=-o)(.*)/i;
$Outfile = $1;
}
next;
}
# Input file
$Infile = $ARGV[$i];
}}
unless ( $Infile and $Outfile ) {
die "Usage: $0 <input file> -o <output file>\n\n";
}
if ( $Infile =~ /.*(?=\/.*$)/ ) {
$PathPrefix = "$&/";
} else {
$PathPrefix = "";
}
open( INFILE, $Infile ) or die "\nError: Couldn't open INPUT file $Infile: $!";
open( OUTFILE, ">$Outfile" ) or die "\nError: Couldn't open OUTPUT file $Outfile: $!";
print "Converting $Infile for use with windres...\n";
# first define missing constants and include needed files
print OUTFILE << "marker";
// This file is a windres compatible version of $Infile
// It was fixed by $0 (perl $])
// afxres.h cannot be redistributed, so define constants and include files needed here
#ifndef _MSC_VER
#ifndef RC_INVOKED
#define RC_INVOKED
#endif
#include <windows.h>
#include <richedit.h>
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#endif
marker
while ( my $line = <INFILE> ) {
chomp $line;
if ( $line =~ /^\#include \"afxres.h\"/ ) {
print OUTFILE "#ifdef _MSC_VER\n";
print OUTFILE "$line\n";
print OUTFILE "#endif\n";
} else {
# add NOT WS_POPUP to all windows with WS_CHILD specified
$line =~ s/(?<!NOT\s)(WS_CHILD)/$1 \| NOT WS_POPUP/;
# Fix FONT statements (remove rubbish after font name)
if ( $line =~ /(^FONT\s+\w+,\s*".*")/ ) {
$line = $1;
}
print OUTFILE "$line\n";
}
}
close( OUTFILE );
close( INFILE );