Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / glib / glib-2.28.1-win32-2.patch
blobee4b868f6b1a1806e33ebd7bca64a0c0ace3f17d
1 --- misc/glib-2.28.1/build/win32/make.msc 2011-04-01 16:52:15.676157900 +0200
2 +++ misc/build/glib-2.28.1/build/win32/make.msc 2011-04-01 16:52:02.168385300 +0200
3 @@ -55,7 +55,7 @@
4 BABL_LIBS = $(BABL)\babl\babl-1.0.lib
6 # force inclusion of the _right_ cairoversion.h even when using without installation
7 -CAIRO_CFLAGS = -FI $(CAIRO)\cairo-version.h -I $(CAIRO)\src -I $(CAIRO)
8 +CAIRO_CFLAGS = -I $(CAIRO)\src -I $(CAIRO)
9 CAIRO_LIBS = $(CAIRO)\src\libcairo.lib
11 DIRENT_CFLAGS = -I ..\build\win32\dirent
12 --- misc/glib-2.28.1/gobject/glib-mkenums 2011-04-01 16:52:15.155128100 +0200
13 +++ misc/build/glib-2.28.1/gobject/glib-mkenums 2011-04-01 16:51:30.994602300 +0200
14 @@ -1 +1,538 @@
15 -dummy
16 +#! perl.exe
18 +use warnings;
19 +use File::Basename;
20 +use Safe;
22 +# glib-mkenums.pl
23 +# Information about the current enumeration
24 +my $flags; # Is enumeration a bitmask?
25 +my $option_underscore_name; # Overriden underscore variant of the enum name
26 + # for example to fix the cases we don't get the
27 + # mixed-case -> underscorized transform right.
28 +my $option_lowercase_name; # DEPRECATED. A lower case name to use as part
29 + # of the *_get_type() function, instead of the
30 + # one that we guess. For instance, when an enum
31 + # uses abnormal capitalization and we can not
32 + # guess where to put the underscores.
33 +my $seenbitshift; # Have we seen bitshift operators?
34 +my $enum_prefix; # Prefix for this enumeration
35 +my $enumname; # Name for this enumeration
36 +my $enumshort; # $enumname without prefix
37 +my $enumname_prefix; # prefix of $enumname
38 +my $enumindex = 0; # Global enum counter
39 +my $firstenum = 1; # Is this the first enumeration per file?
40 +my @entries; # [ $name, $val ] for each entry
41 +my $sandbox = Safe->new; # sandbox for safe evaluation of expressions
43 +sub parse_trigraph {
44 + my $opts = shift;
45 + my @opts;
47 + for $opt (split /\s*,\s*/, $opts) {
48 + $opt =~ s/^\s*//;
49 + $opt =~ s/\s*$//;
50 + my ($key,$val) = $opt =~ /(\w+)(?:=(.+))?/;
51 + defined $val or $val = 1;
52 + push @opts, $key, $val;
53 + }
54 + @opts;
56 +sub parse_entries {
57 + my $file = shift;
58 + my $file_name = shift;
59 + my $looking_for_name = 0;
61 + while (<$file>) {
62 + # read lines until we have no open comments
63 + while (m@/\*([^*]|\*(?!/))*$@) {
64 + my $new;
65 + defined ($new = <$file>) || die "Unmatched comment in $ARGV";
66 + $_ .= $new;
67 + }
68 + # strip comments w/o options
69 + s@/\*(?!<)
70 + ([^*]+|\*(?!/))*
71 + \*/@@gx;
73 + # strip newlines
74 + s@\n@ @;
76 + # skip empty lines
77 + next if m@^\s*$@;
79 + if ($looking_for_name) {
80 + if (/^\s*(\w+)/) {
81 + $enumname = $1;
82 + return 1;
83 + }
84 + }
86 + # Handle include files
87 + if (/^\#include\s*<([^>]*)>/ ) {
88 + my $file= "../$1";
89 + open NEWFILE, $file or die "Cannot open include file $file: $!\n";
91 + if (parse_entries (\*NEWFILE, $NEWFILE)) {
92 + return 1;
93 + } else {
94 + next;
95 + }
96 + }
98 + if (/^\s*\}\s*(\w+)/) {
99 + $enumname = $1;
100 + $enumindex++;
101 + return 1;
104 + if (/^\s*\}/) {
105 + $enumindex++;
106 + $looking_for_name = 1;
107 + next;
110 + if (m@^\s*
111 + (\w+)\s* # name
112 + (?:=( # value
113 + \s*\w+\s*\(.*\)\s* # macro with multiple args
114 + | # OR
115 + (?:[^,/]|/(?!\*))* # anything but a comma or comment
116 + ))?,?\s*
117 + (?:/\*< # options
118 + (([^*]|\*(?!/))*)
119 + >\s*\*/)?,?
120 + \s*$
121 + @x) {
122 + my ($name, $value, $options) = ($1,$2,$3);
124 + if (!defined $flags && defined $value && $value =~ /<</) {
125 + $seenbitshift = 1;
128 + if (defined $options) {
129 + my %options = parse_trigraph($options);
130 + if (!defined $options{skip}) {
131 + push @entries, [ $name, $value, $options{nick} ];
133 + } else {
134 + push @entries, [ $name, $value ];
136 + } elsif (m@^\s*\#@) {
137 + # ignore preprocessor directives
138 + } else {
139 + print STDERR "$0: $file_name:$.: Failed to parse `$_'\n";
143 + return 0;
146 +sub version {
147 + print "glib-mkenums version glib-@GLIB_VERSION@\n";
148 + print "glib-mkenums comes with ABSOLUTELY NO WARRANTY.\n";
149 + print "You may redistribute copies of glib-mkenums under the terms of\n";
150 + print "the GNU General Public License which can be found in the\n";
151 + print "GLib source package. Sources, examples and contact\n";
152 + print "information are available at http://www.gtk.org\n";
153 + exit 0;
155 +sub usage {
156 + print "Usage:\n";
157 + print " glib-mkenums [OPTION...] [FILES...]\n\n";
158 + print "Help Options:\n";
159 + print " -h, --help Show this help message\n\n";
160 + print "Utility Options:\n";
161 + print " --fhead <text> Output file header\n";
162 + print " --fprod <text> Per input file production\n";
163 + print " --ftail <text> Output file trailer\n";
164 + print " --eprod <text> Per enum text (produced prior to value itarations)\n";
165 + print " --vhead <text> Value header, produced before iterating over enum values\n";
166 + print " --vprod <text> Value text, produced for each enum value\n";
167 + print " --vtail <text> Value tail, produced after iterating over enum values\n";
168 + print " --comments <text> Comment structure\n";
169 + print " --template file Template file\n";
170 + print " -v, --version Print version informations\n\n";
171 + print "Production text substitutions:\n";
172 + print " \@EnumName\@ PrefixTheXEnum\n";
173 + print " \@enum_name\@ prefix_the_xenum\n";
174 + print " \@ENUMNAME\@ PREFIX_THE_XENUM\n";
175 + print " \@ENUMSHORT\@ THE_XENUM\n";
176 + print " \@ENUMPREFIX\@ PREFIX\n";
177 + print " \@VALUENAME\@ PREFIX_THE_XVALUE\n";
178 + print " \@valuenick\@ the-xvalue\n";
179 + print " \@valuenum\@ the integer value (limited support, Since: 2.26)\n";
180 + print " \@type\@ either enum or flags\n";
181 + print " \@Type\@ either Enum or Flags\n";
182 + print " \@TYPE\@ either ENUM or FLAGS\n";
183 + print " \@filename\@ name of current input file\n";
184 + print " \@basename\@ base name of the current input file (Since: 2.22)\n";
185 + exit 0;
188 +# production variables:
189 +my $fhead = ""; # output file header
190 +my $fprod = ""; # per input file production
191 +my $ftail = ""; # output file trailer
192 +my $eprod = ""; # per enum text (produced prior to value itarations)
193 +my $vhead = ""; # value header, produced before iterating over enum values
194 +my $vprod = ""; # value text, produced for each enum value
195 +my $vtail = ""; # value tail, produced after iterating over enum values
196 +my $comment_tmpl = ""; # comment template
198 +sub read_template_file {
199 + my ($file) = @_;
200 + my %tmpl = ('file-header', $fhead,
201 + 'file-production', $fprod,
202 + 'file-tail', $ftail,
203 + 'enumeration-production', $eprod,
204 + 'value-header', $vhead,
205 + 'value-production', $vprod,
206 + 'value-tail', $vtail,
207 + 'comment', $comment_tmpl);
208 + my $in = 'junk';
209 + open (FILE, $file) || die "Can't open $file: $!\n";
210 + while (<FILE>) {
211 + if (/^\/\*\*\*\s+(BEGIN|END)\s+([\w-]+)\s+\*\*\*\//) {
212 + if (($in eq 'junk') && ($1 eq 'BEGIN') && (exists($tmpl{$2}))) {
213 + $in = $2;
214 + next;
216 + elsif (($in eq $2) && ($1 eq 'END') && (exists($tmpl{$2}))) {
217 + $in = 'junk';
218 + next;
219 + } else {
220 + die "Malformed template file $file\n";
223 + if (!($in eq 'junk')) {
224 + $tmpl{$in} .= $_;
227 + close (FILE);
228 + if (!($in eq 'junk')) {
229 + die "Malformed template file $file\n";
231 + $fhead = $tmpl{'file-header'};
232 + $fprod = $tmpl{'file-production'};
233 + $ftail = $tmpl{'file-tail'};
234 + $eprod = $tmpl{'enumeration-production'};
235 + $vhead = $tmpl{'value-header'};
236 + $vprod = $tmpl{'value-production'};
237 + $vtail = $tmpl{'value-tail'};
238 + $comment_tmpl = $tmpl{'comment'};
240 + # default to C-style comments
241 + $comment_tmpl = "/* \@comment\@ */" if $comment_tmpl eq "";
244 +if (!defined $ARGV[0]) {
245 + usage;
247 +while ($_=$ARGV[0],/^-/) {
248 + shift;
249 + last if /^--$/;
250 + if (/^--template$/) { read_template_file (shift); }
251 + elsif (/^--fhead$/) { $fhead = $fhead . shift }
252 + elsif (/^--fprod$/) { $fprod = $fprod . shift }
253 + elsif (/^--ftail$/) { $ftail = $ftail . shift }
254 + elsif (/^--eprod$/) { $eprod = $eprod . shift }
255 + elsif (/^--vhead$/) { $vhead = $vhead . shift }
256 + elsif (/^--vprod$/) { $vprod = $vprod . shift }
257 + elsif (/^--vtail$/) { $vtail = $vtail . shift }
258 + elsif (/^--comments$/) { $comment_tmpl = shift }
259 + elsif (/^--help$/ || /^-h$/ || /^-\?$/) { usage; }
260 + elsif (/^--version$/ || /^-v$/) { version; }
261 + else { usage; }
262 + last if not defined($ARGV[0]);
265 +# put auto-generation comment
267 + my $comment = $comment_tmpl;
268 + $comment =~ s/\@comment\@/Generated data (by glib-mkenums)/;
269 + print "\n" . $comment . "\n\n";
272 +if (length($fhead)) {
273 + my $prod = $fhead;
274 + my $base = basename ($ARGV[0]);
276 + $prod =~ s/\@filename\@/$ARGV[0]/g;
277 + $prod =~ s/\@basename\@/$base/g;
278 + $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
279 + $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
280 + chomp ($prod);
282 + print "$prod\n";
285 +while (<>) {
286 + if (eof) {
287 + close (ARGV); # reset line numbering
288 + $firstenum = 1; # Flag to print filename at next enum
291 + # read lines until we have no open comments
292 + while (m@/\*([^*]|\*(?!/))*$@) {
293 + my $new;
294 + defined ($new = <>) || die "Unmatched comment in $ARGV";
295 + $_ .= $new;
297 + # strip comments w/o options
298 + s@/\*(?!<)
299 + ([^*]+|\*(?!/))*
300 + \*/@@gx;
302 + if (m@^\s*typedef\s+enum\s*
303 + ({)?\s*
304 + (?:/\*<
305 + (([^*]|\*(?!/))*)
306 + >\s*\*/)?
307 + \s*({)?
308 + @x) {
309 + if (defined $2) {
310 + my %options = parse_trigraph ($2);
311 + next if defined $options{skip};
312 + $enum_prefix = $options{prefix};
313 + $flags = $options{flags};
314 + $option_lowercase_name = $options{lowercase_name};
315 + $option_underscore_name = $options{underscore_name};
316 + } else {
317 + $enum_prefix = undef;
318 + $flags = undef;
319 + $option_lowercase_name = undef;
320 + $option_underscore_name = undef;
322 + if (defined $option_lowercase_name) {
323 + if (defined $option_underscore_name) {
324 + print STDERR "$0: $ARGV:$.: lowercase_name overriden with underscore_name\n";
325 + $option_lowercase_name = undef;
326 + } else {
327 + print STDERR "$0: $ARGV:$.: lowercase_name is deprecated, use underscore_name\n";
330 + # Didn't have trailing '{' look on next lines
331 + if (!defined $1 && !defined $4) {
332 + while (<>) {
333 + if (s/^\s*\{//) {
334 + last;
339 + $seenbitshift = 0;
340 + @entries = ();
342 + # Now parse the entries
343 + parse_entries (\*ARGV, $ARGV);
345 + # figure out if this was a flags or enums enumeration
346 + if (!defined $flags) {
347 + $flags = $seenbitshift;
350 + # Autogenerate a prefix
351 + if (!defined $enum_prefix) {
352 + for (@entries) {
353 + my $nick = $_->[2];
354 + if (!defined $nick) {
355 + my $name = $_->[0];
356 + if (defined $enum_prefix) {
357 + my $tmp = ~ ($name ^ $enum_prefix);
358 + ($tmp) = $tmp =~ /(^\xff*)/;
359 + $enum_prefix = $enum_prefix & $tmp;
360 + } else {
361 + $enum_prefix = $name;
365 + if (!defined $enum_prefix) {
366 + $enum_prefix = "";
367 + } else {
368 + # Trim so that it ends in an underscore
369 + $enum_prefix =~ s/_[^_]*$/_/;
371 + } else {
372 + # canonicalize user defined prefixes
373 + $enum_prefix = uc($enum_prefix);
374 + $enum_prefix =~ s/-/_/g;
375 + $enum_prefix =~ s/(.*)([^_])$/$1$2_/;
378 + for $entry (@entries) {
379 + my ($name,$num,$nick) = @{$entry};
380 + if (!defined $nick) {
381 + ($nick = $name) =~ s/^$enum_prefix//;
382 + $nick =~ tr/_/-/;
383 + $nick = lc($nick);
384 + @{$entry} = ($name, $num, $nick);
389 + # Spit out the output
390 + if (defined $option_underscore_name) {
391 + $enumlong = uc $option_underscore_name;
392 + $enumsym = lc $option_underscore_name;
393 + $enumshort = $enumlong;
394 + $enumshort =~ s/^[A-Z][A-Z0-9]*_//;
396 + $enumname_prefix = $enumlong;
397 + $enumname_prefix =~ s/$enumshort$//;
398 + } else {
399 + # enumname is e.g. GMatchType
400 + $enspace = $enumname;
401 + $enspace =~ s/^([A-Z][a-z]*).*$/$1/;
403 + $enumshort = $enumname;
404 + $enumshort =~ s/^[A-Z][a-z]*//;
405 + $enumshort =~ s/([^A-Z])([A-Z])/$1_$2/g;
406 + $enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
407 + $enumshort = uc($enumshort);
409 + $enumname_prefix = $enumname;
410 + $enumname_prefix =~ s/^([A-Z][a-z]*).*$/$1/;
411 + $enumname_prefix = uc($enumname_prefix);
413 + $enumlong = uc($enspace) . "_" . $enumshort;
414 + $enumsym = lc($enspace) . "_" . lc($enumshort);
416 + if (defined($option_lowercase_name)) {
417 + $enumsym = $option_lowercase_name;
421 + if ($firstenum) {
422 + $firstenum = 0;
424 + if (length($fprod)) {
425 + my $prod = $fprod;
426 + my $base = basename ($ARGV);
428 + $prod =~ s/\@filename\@/$ARGV/g;
429 + $prod =~ s/\@basename\@/$base/g;
430 + $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
431 + $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
432 + chomp ($prod);
434 + print "$prod\n";
438 + if (length($eprod)) {
439 + my $prod = $eprod;
441 + $prod =~ s/\@enum_name\@/$enumsym/g;
442 + $prod =~ s/\@EnumName\@/$enumname/g;
443 + $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
444 + $prod =~ s/\@ENUMNAME\@/$enumlong/g;
445 + $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
446 + if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
447 + if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
448 + if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
449 + $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
450 + $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
451 + chomp ($prod);
453 + print "$prod\n";
456 + if (length($vhead)) {
457 + my $prod = $vhead;
459 + $prod =~ s/\@enum_name\@/$enumsym/g;
460 + $prod =~ s/\@EnumName\@/$enumname/g;
461 + $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
462 + $prod =~ s/\@ENUMNAME\@/$enumlong/g;
463 + $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
464 + if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
465 + if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
466 + if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
467 + $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
468 + $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
469 + chomp ($prod);
471 + print "$prod\n";
474 + if (length($vprod)) {
475 + my $prod = $vprod;
476 + my $next_num = 0;
478 + $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
479 + $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
480 + for (@entries) {
481 + my ($name,$num,$nick) = @{$_};
482 + my $tmp_prod = $prod;
484 + if ($prod =~ /\@valuenum\@/) {
485 + # only attempt to eval the value if it is requested
486 + # this prevents us from throwing errors otherwise
487 + if (defined $num) {
488 + # use sandboxed perl evaluation as a reasonable
489 + # approximation to C constant folding
490 + $num = $sandbox->reval ($num);
492 + # make sure it parsed to an integer
493 + if (!defined $num or $num !~ /^-?\d+$/) {
494 + die "Unable to parse enum value '$num'";
496 + } else {
497 + $num = $next_num;
500 + $tmp_prod =~ s/\@valuenum\@/$num/g;
501 + $next_num = $num + 1;
504 + $tmp_prod =~ s/\@VALUENAME\@/$name/g;
505 + $tmp_prod =~ s/\@valuenick\@/$nick/g;
506 + if ($flags) { $tmp_prod =~ s/\@type\@/flags/g; } else { $tmp_prod =~ s/\@type\@/enum/g; }
507 + if ($flags) { $tmp_prod =~ s/\@Type\@/Flags/g; } else { $tmp_prod =~ s/\@Type\@/Enum/g; }
508 + if ($flags) { $tmp_prod =~ s/\@TYPE\@/FLAGS/g; } else { $tmp_prod =~ s/\@TYPE\@/ENUM/g; }
509 + chomp ($tmp_prod);
511 + print "$tmp_prod\n";
515 + if (length($vtail)) {
516 + my $prod = $vtail;
518 + $prod =~ s/\@enum_name\@/$enumsym/g;
519 + $prod =~ s/\@EnumName\@/$enumname/g;
520 + $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
521 + $prod =~ s/\@ENUMNAME\@/$enumlong/g;
522 + $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
523 + if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
524 + if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
525 + if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
526 + $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
527 + $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
528 + chomp ($prod);
530 + print "$prod\n";
535 +if (length($ftail)) {
536 + my $prod = $ftail;
537 + my $base = basename ($ARGV);
539 + $prod =~ s/\@filename\@/$ARGV/g;
540 + $prod =~ s/\@basename\@/$base/g;
541 + $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
542 + $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
543 + chomp ($prod);
545 + print "$prod\n";
548 +# put auto-generation comment
550 + my $comment = $comment_tmpl;
551 + $comment =~ s/\@comment\@/Generated data ends here/;
552 + print "\n" . $comment . "\n\n";