blib/lib/Devel/PatchPerl/Plugin/Cygwin.pm

filter: Statementstmt 26.0% 18 / 69 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 27.7% 5 / 18 Podpod 100% 1 / 1 totaltotal 22.8% 24 / 105 CC 13 SCAR 31.5
CC
13
Cov
21%
patchperl
72.0
_patch_cygwin_ld2
20.0
_patch_cygwin_GNU_SOURCE
6.0
CRAP 23.4
↑ Summary
1 package Devel::PatchPerl::Plugin::Cygwin;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Devel::PatchPerl plugin for Cygwin
7 1 our $VERSION = 'v0.1.0'; # VERSION
8  
9 1 ▶use File::pushd qw[pushd];
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Devel::PatchPerl::Hints;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my @patch = (
15 {
16 perl => [
17 qr/^5\.10\.1$/,
18 qr/^5\.16\.[0-3]$/,
19 qr/^5\.18\.[0-2]$/,
20 qr/^5\.19\.[0-8]$/,
21 ],
22 subs => [ [ \&_patch_cygwin_c_stdio ] ],
23 },
24 {
25 perl => [ qr/^5\.10\.1$/ ],
26 subs => [ [ \&_patch_cygwin17 ] ],
27 },
28 {
29 perl => [ qr/^5\.8\.[0-8]$/ ],
30 subs => [ [ \&_patch_cygwin_ld2 ] ],
31 },
32 # After Devel::PatchPerl::Hints fixed, it is not necessary to apply the following entry.
33 {
34 perl => [
35 # qr/^5\.6\.2$/,
36 # qr/^5\.8\.[0-9]$/,
37 # qr/^5\.10\.[01]$/,
38 # qr/^5\.12\.[0-5]$/,
39 # qr/^5\.14\.[0-4]$/,
40 # qr/^5\.16\.[0-3]$/,
41 # qr/^5\.18\.[0-4]$/,
42 # qr/^5\.20\.[0-3]$/,
43 # qr/^5\.22\.[0-4]$/,
44 # qr/^5\.24\.[0-2]$/,
45 # qr/^5\.26\.0$/,
46 qr/.*/,
47 ],
48 subs => [ [ \&_patch_cygwin_GNU_SOURCE ] ], # required after libcrypt-devel-2.0-1 but always applying
49 },
50 {
51 perl => [
52 qr/^5\.8\.[0-9]$/,
53 qr/^5\.10\.[01]$/,
54 qr/^5\.12\.[0-5]$/,
55 qr/^5\.14\.[0-4]$/,
56 qr/^5\.16\.[0-3]$/,
57 ],
58 subs => [ [ \&_patch_cygwin_PATH_quote ] ],
59 },
60 );
61  
62 sub patchperl
63 0 ▶{
Subroutine patchperl: not called CC=8 SCAR=42.8
Pod documented
64 0 ▶ return unless $^O eq 'cygwin';
Branch: 1 branch
BranchTrueFalseTotal
unless $^O eq "cygwin" 0 0 0
65  
66 # TODO: Warn environment variables including parens.
67  
68 0 require Devel::PatchPerl;
69 # Devel::PatchPerl::_patch(),_is() are NOT a public interface, so the existence SHOULD NOT be relied
70 0 ▶ if(! defined *Devel::PatchPerl::_patch{CODE} || ! defined *Devel::PatchPerl::_is{CODE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined *Devel::PatchPerl::_patch{"CODE"} and defined *Devel::PatchPerl::_is{"CODE"}) 0 0 0
Condition0%0/3
defined *Devel::PatchPerl::_patch{"CODE"} and defined *Devel::PatchPerl::_is{"CODE"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined *Devel::PatchPerl::_patch{"CODE"} and defined *Devel::PatchPerl::_is{"CODE"}
defined *Devel::PatchPerl::_patch{"CODE"} defined *Devel::PatchPerl::_is{"CODE"}
Truth table0%0/3
A and B
A= defined *Devel::PatchPerl::_patch{"CODE"}B= defined *Devel::PatchPerl::_is{"CODE"}
ABresult
0X0
100
111
71 0 die 'Devel::PatchPerl::_patch() or Devel::PatchPerl::_is() not found, please contact with the author of '.__PACKAGE__;
72 }
73  
74 0 ▶ shift if eval { $_[0]->isa(__PACKAGE__) };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $_[0]->isa(__PACKAGE__) } } 0 0 0
75 0 my (%args) = @_;
76 # Copy from Devel::PatchPerl::patch_source()
77 0 my $source = File::Spec->rel2abs($args{source});
78 {
79 0 my $dir = pushd( $source );
80 0 for my $p ( grep { Devel::PatchPerl::_is( $_->{perl}, $args{version} ) } @patch ) {
81 0 for my $s (@{$p->{subs}}) {
82 0 my($sub, @args) = @$s;
83 0 ▶ push @args, $args{version} unless scalar @args;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @args 0 0 0
84 0 $sub->(@args);
85 }
86 }
87 }
88 }
89  
90 sub _patch_cygwin_c_stdio
91 0 ▶{
Subroutine _patch_cygwin_c_stdio: not called CC=1 SCAR=6.9
92 0 Devel::PatchPerl::_patch(<<'END');
93 --- cygwin/cygwin.c.orig 2014-01-13 09:20:07.000000000 +0900
94 +++ cygwin/cygwin.c 2014-05-02 19:16:25.950179100 +0900
95 @@ -2,6 +2,7 @@
96 * Cygwin extras
97 */
98  
99 +#define PERLIO_NOT_STDIO 0
100 #include "EXTERN.h"
101 #include "perl.h"
102 #undef USE_DYNAMIC_LOADING
103 END
104 }
105  
106 sub _patch_cygwin17
107 0 ▶{
Subroutine _patch_cygwin17: not called CC=1 SCAR=6.9
108 0 Devel::PatchPerl::_patch(<<'END');
109 --- cygwin/cygwin.c.orig 2009-05-04 01:54:56.000000000 +0900
110 +++ cygwin/cygwin.c 2014-05-03 19:39:53.093468100 +0900
111 @@ -10,9 +10,13 @@
112 #include <unistd.h>
113 #include <process.h>
114 #include <sys/cygwin.h>
115 +#include <cygwin/version.h>
116 #include <mntent.h>
117 #include <alloca.h>
118 #include <dlfcn.h>
119 +#if (CYGWIN_VERSION_API_MINOR >= 181)
120 +#include <wchar.h>
121 +#endif
122
123 /*
124 * pp_system() implemented via spawn()
125 @@ -140,6 +144,44 @@
126 return do_spawnvp(PL_Argv[0],(const char * const *)PL_Argv);
127 }
128
129 +#if (CYGWIN_VERSION_API_MINOR >= 181)
130 +char*
131 +wide_to_utf8(const wchar_t *wbuf)
132 +{
133 + char *buf;
134 + int wlen = 0;
135 + char *oldlocale = setlocale(LC_CTYPE, NULL);
136 + setlocale(LC_CTYPE, "utf-8");
137 +
138 + /* uvuni_to_utf8(buf, chr) or Encoding::_bytes_to_utf8(sv, "UCS-2BE"); */
139 + wlen = wcsrtombs(NULL, (const wchar_t **)&wbuf, wlen, NULL);
140 + buf = (char *) safemalloc(wlen+1);
141 + wcsrtombs(buf, (const wchar_t **)&wbuf, wlen, NULL);
142 +
143 + if (oldlocale) setlocale(LC_CTYPE, oldlocale);
144 + else setlocale(LC_CTYPE, "C");
145 + return buf;
146 +}
147 +
148 +wchar_t*
149 +utf8_to_wide(const char *buf)
150 +{
151 + wchar_t *wbuf;
152 + mbstate_t mbs;
153 + char *oldlocale = setlocale(LC_CTYPE, NULL);
154 + int wlen = sizeof(wchar_t)*strlen(buf);
155 +
156 + setlocale(LC_CTYPE, "utf-8");
157 + wbuf = (wchar_t *) safemalloc(wlen);
158 + /* utf8_to_uvuni_buf(pathname, pathname + wlen, wpath) or Encoding::_utf8_to_bytes(sv, "UCS-2BE"); */
159 + wlen = mbsrtowcs(wbuf, (const char**)&buf, wlen, &mbs);
160 +
161 + if (oldlocale) setlocale(LC_CTYPE, oldlocale);
162 + else setlocale(LC_CTYPE, "C");
163 + return wbuf;
164 +}
165 +#endif /* cygwin 1.7 */
166 +
167 /* see also Cwd.pm */
168 XS(Cygwin_cwd)
169 {
170 @@ -191,7 +233,12 @@
171
172 pid = (pid_t)SvIV(ST(0));
173
174 - if ((RETVAL = cygwin32_winpid_to_pid(pid)) > 0) {
175 +#if (CYGWIN_VERSION_API_MINOR >= 181)
176 + RETVAL = cygwin_winpid_to_pid(pid);
177 +#else
178 + RETVAL = cygwin32_winpid_to_pid(pid);
179 +#endif
180 + if (RETVAL > 0) {
181 XSprePUSH; PUSHi((IV)RETVAL);
182 XSRETURN(1);
183 }
184 @@ -204,29 +251,85 @@
185 int absolute_flag = 0;
186 STRLEN len;
187 int err;
188 - char *pathname, *buf;
189 + char *src_path;
190 + char *posix_path;
191 + int isutf8 = 0;
192
193 if (items < 1 || items > 2)
194 Perl_croak(aTHX_ "Usage: Cygwin::win_to_posix_path(pathname, [absolute])");
195
196 - pathname = SvPV(ST(0), len);
197 + src_path = SvPV(ST(0), len);
198 if (items == 2)
199 absolute_flag = SvTRUE(ST(1));
200
201 if (!len)
202 Perl_croak(aTHX_ "can't convert empty path");
203 - buf = (char *) safemalloc (len + 260 + 1001);
204 + isutf8 = SvUTF8(ST(0));
205
206 +#if (CYGWIN_VERSION_API_MINOR >= 181)
207 + /* Check utf8 flag and use wide api then.
208 + Size calculation: On overflow let cygwin_conv_path calculate the final size.
209 + */
210 + if (isutf8) {
211 + int what = absolute_flag ? CCP_WIN_W_TO_POSIX : CCP_WIN_W_TO_POSIX | CCP_RELATIVE;
212 + int wlen = sizeof(wchar_t)*(len + 260 + 1001);
213 + wchar_t *wpath = (wchar_t *) safemalloc(sizeof(wchar_t)*len);
214 + wchar_t *wbuf = (wchar_t *) safemalloc(wlen);
215 + if (!IN_BYTES) {
216 + mbstate_t mbs;
217 + char *oldlocale = setlocale(LC_CTYPE, NULL);
218 + setlocale(LC_CTYPE, "utf-8");
219 + /* utf8_to_uvuni_buf(src_path, src_path + wlen, wpath) or Encoding::_utf8_to_bytes(sv, "UCS-2BE"); */
220 + wlen = mbsrtowcs(wpath, (const char**)&src_path, wlen, &mbs);
221 + if (wlen > 0)
222 + err = cygwin_conv_path(what, wpath, wbuf, wlen);
223 + if (oldlocale) setlocale(LC_CTYPE, oldlocale);
224 + else setlocale(LC_CTYPE, "C");
225 + } else { /* use bytes; assume already ucs-2 encoded bytestream */
226 + err = cygwin_conv_path(what, src_path, wbuf, wlen);
227 + }
228 + if (err == ENOSPC) { /* our space assumption was wrong, not enough space */
229 + int newlen = cygwin_conv_path(what, wpath, wbuf, 0);
230 + wbuf = (wchar_t *) realloc(&wbuf, newlen);
231 + err = cygwin_conv_path(what, wpath, wbuf, newlen);
232 + wlen = newlen;
233 + }
234 + /* utf16_to_utf8(*p, *d, bytlen, *newlen) */
235 + posix_path = (char *) safemalloc(wlen*3);
236 + Perl_utf16_to_utf8(aTHX_ (U8*)&wpath, (U8*)posix_path, (I32)wlen*2, (I32*)&len);
237 + /*
238 + wlen = wcsrtombs(NULL, (const wchar_t **)&wbuf, wlen, NULL);
239 + posix_path = (char *) safemalloc(wlen+1);
240 + wcsrtombs(posix_path, (const wchar_t **)&wbuf, wlen, NULL);
241 + */
242 + } else {
243 + int what = absolute_flag ? CCP_WIN_A_TO_POSIX : CCP_WIN_A_TO_POSIX | CCP_RELATIVE;
244 + posix_path = (char *) safemalloc (len + 260 + 1001);
245 + err = cygwin_conv_path(what, src_path, posix_path, len + 260 + 1001);
246 + if (err == ENOSPC) { /* our space assumption was wrong, not enough space */
247 + int newlen = cygwin_conv_path(what, src_path, posix_path, 0);
248 + posix_path = (char *) realloc(&posix_path, newlen);
249 + err = cygwin_conv_path(what, src_path, posix_path, newlen);
250 + }
251 + }
252 +#else
253 + posix_path = (char *) safemalloc (len + 260 + 1001);
254 if (absolute_flag)
255 - err = cygwin_conv_to_full_posix_path(pathname, buf);
256 + err = cygwin_conv_to_full_posix_path(src_path, posix_path);
257 else
258 - err = cygwin_conv_to_posix_path(pathname, buf);
259 + err = cygwin_conv_to_posix_path(src_path, posix_path);
260 +#endif
261 if (!err) {
262 - ST(0) = sv_2mortal(newSVpv(buf, 0));
263 - safefree(buf);
264 - XSRETURN(1);
265 + EXTEND(SP, 1);
266 + ST(0) = sv_2mortal(newSVpv(posix_path, 0));
267 + if (isutf8) { /* src was utf-8, so result should also */
268 + /* TODO: convert ANSI (local windows encoding) to utf-8 on cygwin-1.5 */
269 + SvUTF8_on(ST(0));
270 + }
271 + safefree(posix_path);
272 + XSRETURN(1);
273 } else {
274 - safefree(buf);
275 + safefree(posix_path);
276 XSRETURN_UNDEF;
277 }
278 }
279 @@ -237,29 +340,80 @@
280 int absolute_flag = 0;
281 STRLEN len;
282 int err;
283 - char *pathname, *buf;
284 + char *src_path, *win_path;
285 + int isutf8 = 0;
286
287 if (items < 1 || items > 2)
288 Perl_croak(aTHX_ "Usage: Cygwin::posix_to_win_path(pathname, [absolute])");
289
290 - pathname = SvPV(ST(0), len);
291 + src_path = SvPVx(ST(0), len);
292 if (items == 2)
293 absolute_flag = SvTRUE(ST(1));
294
295 if (!len)
296 Perl_croak(aTHX_ "can't convert empty path");
297 - buf = (char *) safemalloc(len + 260 + 1001);
298 -
299 + isutf8 = SvUTF8(ST(0));
300 +#if (CYGWIN_VERSION_API_MINOR >= 181)
301 + /* Check utf8 flag and use wide api then.
302 + Size calculation: On overflow let cygwin_conv_path calculate the final size.
303 + */
304 + if (isutf8) {
305 + int what = absolute_flag ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_W | CCP_RELATIVE;
306 + int wlen = sizeof(wchar_t)*(len + 260 + 1001);
307 + wchar_t *wpath = (wchar_t *) safemalloc(sizeof(wchar_t)*len);
308 + wchar_t *wbuf = (wchar_t *) safemalloc(wlen);
309 + char *oldlocale = setlocale(LC_CTYPE, NULL);
310 + setlocale(LC_CTYPE, "utf-8");
311 + if (!IN_BYTES) {
312 + mbstate_t mbs;
313 + /* utf8_to_uvuni_buf(src_path, src_path + wlen, wpath) or Encoding::_utf8_to_bytes(sv, "UCS-2BE"); */
314 + wlen = mbsrtowcs(wpath, (const char**)&src_path, wlen, &mbs);
315 + if (wlen > 0)
316 + err = cygwin_conv_path(what, wpath, wbuf, wlen);
317 + } else { /* use bytes; assume already ucs-2 encoded bytestream */
318 + err = cygwin_conv_path(what, src_path, wbuf, wlen);
319 + }
320 + if (err == ENOSPC) { /* our space assumption was wrong, not enough space */
321 + int newlen = cygwin_conv_path(what, wpath, wbuf, 0);
322 + wbuf = (wchar_t *) realloc(&wbuf, newlen);
323 + err = cygwin_conv_path(what, wpath, wbuf, newlen);
324 + wlen = newlen;
325 + }
326 + /* also see utf8.c: Perl_utf16_to_utf8() or Encoding::_bytes_to_utf8(sv, "UCS-2BE"); */
327 + wlen = wcsrtombs(NULL, (const wchar_t **)&wbuf, wlen, NULL);
328 + win_path = (char *) safemalloc(wlen+1);
329 + wcsrtombs(win_path, (const wchar_t **)&wbuf, wlen, NULL);
330 + if (oldlocale) setlocale(LC_CTYPE, oldlocale);
331 + else setlocale(LC_CTYPE, "C");
332 + } else {
333 + int what = absolute_flag ? CCP_POSIX_TO_WIN_A : CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
334 + win_path = (char *) safemalloc(len + 260 + 1001);
335 + err = cygwin_conv_path(what, src_path, win_path, len + 260 + 1001);
336 + if (err == ENOSPC) { /* our space assumption was wrong, not enough space */
337 + int newlen = cygwin_conv_path(what, src_path, win_path, 0);
338 + win_path = (char *) realloc(&win_path, newlen);
339 + err = cygwin_conv_path(what, src_path, win_path, newlen);
340 + }
341 + }
342 +#else
343 + if (isutf8)
344 + Perl_warn(aTHX_ "can't convert utf8 path");
345 + win_path = (char *) safemalloc(len + 260 + 1001);
346 if (absolute_flag)
347 - err = cygwin_conv_to_full_win32_path(pathname, buf);
348 + err = cygwin_conv_to_full_win32_path(src_path, win_path);
349 else
350 - err = cygwin_conv_to_win32_path(pathname, buf);
351 + err = cygwin_conv_to_win32_path(src_path, win_path);
352 +#endif
353 if (!err) {
354 - ST(0) = sv_2mortal(newSVpv(buf, 0));
355 - safefree(buf);
356 - XSRETURN(1);
357 + EXTEND(SP, 1);
358 + ST(0) = sv_2mortal(newSVpv(win_path, 0));
359 + if (isutf8) {
360 + SvUTF8_on(ST(0));
361 + }
362 + safefree(win_path);
363 + XSRETURN(1);
364 } else {
365 - safefree(buf);
366 + safefree(win_path);
367 XSRETURN_UNDEF;
368 }
369 }
370 @@ -290,24 +444,22 @@
371 {
372 dXSARGS;
373 char *pathname;
374 - char flags[260];
375 + char flags[PATH_MAX];
376 + flags[0] = '\0';
377
378 if (items != 1)
379 - Perl_croak(aTHX_ "Usage: Cygwin::mount_flags(mnt_dir|'/cygwin')");
380 + Perl_croak(aTHX_ "Usage: Cygwin::mount_flags( mnt_dir | '/cygdrive' )");
381
382 pathname = SvPV_nolen(ST(0));
383
384 - /* TODO: Check for cygdrive registry setting,
385 - * and then use CW_GET_CYGDRIVE_INFO
386 - */
387 if (!strcmp(pathname, "/cygdrive")) {
388 - char user[260];
389 - char system[260];
390 - char user_flags[260];
391 - char system_flags[260];
392 + char user[PATH_MAX];
393 + char system[PATH_MAX];
394 + char user_flags[PATH_MAX];
395 + char system_flags[PATH_MAX];
396
397 - cygwin_internal (CW_GET_CYGDRIVE_INFO, user, system, user_flags,
398 - system_flags);
399 + cygwin_internal (CW_GET_CYGDRIVE_INFO, user, system,
400 + user_flags, system_flags);
401
402 if (strlen(user) > 0) {
403 sprintf(flags, "%s,cygdrive,%s", user_flags, user);
404 @@ -320,6 +472,7 @@
405
406 } else {
407 struct mntent *mnt;
408 + int found = 0;
409 setmntent (0, 0);
410 while ((mnt = getmntent (0))) {
411 if (!strcmp(pathname, mnt->mnt_dir)) {
412 @@ -328,12 +481,42 @@
413 strcat(flags, ",");
414 strcat(flags, mnt->mnt_opts);
415 }
416 + found++;
417 break;
418 }
419 }
420 endmntent (0);
421 - ST(0) = sv_2mortal(newSVpv(flags, 0));
422 - XSRETURN(1);
423 +
424 + /* Check if arg is the current volume moint point if not default,
425 + * and then use CW_GET_CYGDRIVE_INFO also.
426 + */
427 + if (!found) {
428 + char user[PATH_MAX];
429 + char system[PATH_MAX];
430 + char user_flags[PATH_MAX];
431 + char system_flags[PATH_MAX];
432 +
433 + cygwin_internal (CW_GET_CYGDRIVE_INFO, user, system,
434 + user_flags, system_flags);
435 +
436 + if (strlen(user) > 0) {
437 + if (strcmp(user,pathname)) {
438 + sprintf(flags, "%s,cygdrive,%s", user_flags, user);
439 + found++;
440 + }
441 + } else {
442 + if (strcmp(user,pathname)) {
443 + sprintf(flags, "%s,cygdrive,%s", system_flags, system);
444 + found++;
445 + }
446 + }
447 + }
448 + if (found) {
449 + ST(0) = sv_2mortal(newSVpv(flags, 0));
450 + XSRETURN(1);
451 + } else {
452 + XSRETURN_UNDEF;
453 + }
454 }
455 }
456
457 @@ -351,6 +534,8 @@
458 XSRETURN(1);
459 }
460
461 +XS(XS_Cygwin_sync_winenv){ cygwin_internal(CW_SYNC_WINENV); }
462 +
463 void
464 init_os_extras(void)
465 {
466 @@ -366,6 +551,7 @@
467 newXSproto("Cygwin::mount_table", XS_Cygwin_mount_table, file, "");
468 newXSproto("Cygwin::mount_flags", XS_Cygwin_mount_flags, file, "$");
469 newXSproto("Cygwin::is_binmount", XS_Cygwin_is_binmount, file, "$");
470 + newXS("Cygwin::sync_winenv", XS_Cygwin_sync_winenv, file);
471
472 /* Initialize Win32CORE if it has been statically linked. */
473 handle = dlopen(NULL, RTLD_LAZY);
474 END
475 }
476  
477 sub _patch_cygwin_ld2
478 0 ▶{
Subroutine _patch_cygwin_ld2: not called CC=4 SCAR=30.0
479 my @adjust = (
480 0 ▶ [ qr/^5\.8\.[0-7]$/, sub { $_[0] =~ s/ \|\| \$Is_VMS//; } ],
Subroutine __ANON__: not called CC=1 SCAR=6.9
481 0 ▶ [ qr/^5\.8\.[0-5]$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
482 # cygwin/Makefile.SHs
483 0 $_[0] =~ s/\@\@ -22,73/@@ -22,72/;
484 0 $_[0] =~ s/-\t\@chmod a\+x ld2\n//;
485 } ],
486 0 ▶ [ qr/^5\.8\.[0-2]$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
487 # cygwin/Makefile.SHs
488 0 $_[0] =~ s/\@\@ -22,72/@@ -22,71/;
489 0 $_[0] =~ s/these ones are mandatory/this one is pretty mandatory/;
490 0 $_[0] =~ s/-VERSION = '\$version'\n//;
491 0 $_[0] =~ s/ -e s,\@VERSION\@,\\\$\{VERSION},g//;
492 } ],
493 0 ▶ [ qr/^5\.8\.0$/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
494 # Makefile.SH
495 0 $_[0] =~ s/ pad\$\(OBJ_EXT\)//;
496 0 $_[0] =~ s/ opmini\.c//;
497 0 $_[0] =~ s/ \$\(obj\) \$\(libs\)/ \$(obj)/;
498 0 } ],
499 );
500 0 my $patch = <<'END'; $_->[1]->($patch) for grep { Devel::PatchPerl::_is( $_->[0], $_[0] ) } @adjust; Devel::PatchPerl::_patch($patch);
501 --- cygwin/Makefile.SHs.orig 2004-09-10 18:30:39.000000000 +0900
502 +++ cygwin/Makefile.SHs 2008-03-12 05:46:24.000000000 +0900
503 @@ -3,8 +3,8 @@
504
505 # Rerun `sh Makefile.SH; make depend' after making any change.
506
507 -# Additional rules supported: libperls.a (for static linking),
508 -# ld2, perlld (dynamic linking tools)
509 +# Additional rules supported: libperl.a (for static linking),
510 +# ld2 and perlld removed
511 #
512
513 #! /bin/sh
514 @@ -22,73 +22,33 @@
515 ;;
516 esac
517
518 -addtopath=`pwd`
519 +addtopath=`pwd | sed -e 's/ /\\\ /g'`
520 $spitshell >>Makefile <<!GROK!THIS!
521
522 cygwin.c: cygwin/cygwin.c
523 \$(LNS) cygwin/cygwin.c
524
525 -# shell script feeding perlld to decent perl
526 -ld2: $& Makefile perlld ${src}/cygwin/ld2.in
527 - @echo "extracting ld2 (with variable substitutions)"
528 - @$sed s,@buildpath@,$addtopath,g <${src}/cygwin/ld2.in >ld2
529 - @chmod a+x ld2
530 - @echo "installing ld2 into $installbin"
531 -# install is included in Cygwin distributions, and we make a note of th
532 -# requirement in the README.cygwin file. However, let's give them
533 -# a warning.
534 - @/usr/bin/install -c -m 755 ld2 ${installbin}/ld2
535 - @if test ! -f ${installbin}/ld2; then \
536 - echo "*************************************************" ; \
537 - echo "Make will probably fail in a few more steps." ; \
538 - echo "When it does, copy \"ld2\" to a directory in" ; \
539 - echo "your path, other than \".\"." ; \
540 - echo "\"/usr/local/bin\" or something similar will do." ; \
541 - echo "Then restart make." ; \
542 - echo "*************************************************" ; \
543 - fi
544 -
545 -!GROK!THIS!
546 -
547 -$spitshell >>Makefile <<!GROK!THIS!
548 -
549 -# perlld parameters
550 -#
551 -# these ones are mandatory
552 -DLLWRAP = 'dllwrap'
553 -VERSION = '$version'
554 -
555 -# following are optional.
556 -WRAPDRIVER = gcc
557 -DLLTOOL = dlltool
558 -EXPORT_ALL = 1
559 -
560 -# if some of extensions are empty,
561 -# no corresponding output will be done.
562 -# most probably, you'd like to have an export library
563 -DEF_EXT = .def
564 -EXP_EXT = .exp
565 -
566 -perlld: $& Makefile ${src}/cygwin/perlld.in
567 - @echo "extracting perlld (with variable substitutions)"
568 - @$sed -e s,@CC@,\${CC}, -e s,@DLLWRAP@,\${DLLWRAP},g \\
569 - -e s,@WRAPDRIVER@,\${WRAPDRIVER},g -e s,@DLLTOOL@,\${DLLTOOL},g \\
570 - -e s,@AS@,\${AS},g -e s,@EXPORT_ALL@,\${EXPORT_ALL},g \\
571 - -e s,@DEF_EXT@,\${DEF_EXT},g -e s,@EXP_EXT@,\${EXP_EXT},g \\
572 - -e s,@LIB_EXT@,\${LIB_EXT},g -e s,@VERSION@,\${VERSION},g \\
573 - ${src}/cygwin/perlld.in >perlld
574 -
575 !GROK!THIS!
576
577 # make sure that all library names are not malformed
578 libperl=`echo $libperl|sed -e s,\\\..*,,`
579 -
580 linklibperl=-l`echo $libperl|sed -e s,^lib,,`
581 +vers=`echo $version|tr '.' '_'`
582 +dllname=`echo $libperl|sed -e s,^lib,cyg,``echo $vers|sed -e s,_[0-9]$,,`
583 +# append "d" suffix to -DDEBUGGING build: cygperl5_10d.dll
584 +case $config_args in
585 + *DEBUGGING*)
586 + dllname="${dllname}"d
587 + ;;
588 +esac
589
590 $spitshell >>Makefile <<!GROK!THIS!
591 LIBPERL = $libperl
592 LLIBPERL= $linklibperl
593 +DLLNAME= $dllname
594 CLDFLAGS= -L$addtopath $ldflags
595 +LDDLFLAGS = --shared -L$addtopath $ldflags
596 +PLDLFLAGS =
597 CAT = $cat
598 AWK = $awk
599 !GROK!THIS!
600 @@ -104,13 +64,13 @@
601
602 # library used to make statically linked executables
603 # miniperl is linked against it to avoid libperl.dll locking
604 -$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
605 - $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
606 +$(LIBPERL)$(LIB_EXT): $& $(cwobj)
607 + $(AR) rcu $@ $(cwobj)
608
609 # dll and import library
610 -$(LIBPERL).dll$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj) ld2
611 - $(LDLIBPTH) ld2 $(SHRPLDFLAGS) -o $(LIBPERL)$(DLSUFFIX) \
612 - perl$(OBJ_EXT) $(cwobj) $(libs)
613 +$(LIBPERL).dll$(LIB_EXT): $& $(cwobj)
614 + $(LDLIBPTH) $(CC) $(SHRPLDFLAGS) -o $(DLLNAME)$(DLSUFFIX) -Wl,--out-implib=$@ \
615 + $(cwobj) $(libs)
616
617 # How to build executables.
618
619 @@ -122,7 +82,7 @@
620
621 miniperl.exe \
622 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) opmini$(OBJ_EXT)
623 - $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LLIBPERL) $(libs)
624 + $(LDLIBPTH) $(CC) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(libs)
625 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
626
627 perl.exe \
628 @@ -145,8 +105,8 @@
629 cwobj = $(obj)
630
631 # perl library
632 -$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj)
633 - $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj)
634 +$(LIBPERL)$(LIB_EXT): $& $(cwobj)
635 + $(AR) rcu $@ $(cwobj)
636
637 # How to build executables.
638
639 @@ -202,7 +162,9 @@
640
641 distdir: miniperl
642 -mkdir $(DIST_DIRECTORY)
643 - ./miniperl '-MExtUtils::Manifest' \
644 + ./miniperl -Ilib '-MExtUtils::Manifest' \
645 -e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')"
646
647 +test_prep:
648 +
649 !NO!SUBS!
650 --- hints/cygwin.sh.orig 2014-05-12 01:31:55.334217700 +0900
651 +++ hints/cygwin.sh 2014-05-12 01:32:24.439127900 +0900
652 @@ -63,11 +63,11 @@
653 esac
654
655 # compile Win32CORE "module" as static. try to avoid the space.
656 -if test -z "$static_ext"; then
657 - static_ext="Win32CORE"
658 -else
659 - static_ext="$static_ext Win32CORE"
660 -fi
661 +#if test -z "$static_ext"; then
662 +# static_ext="Win32CORE"
663 +#else
664 +# static_ext="$static_ext Win32CORE"
665 +#fi
666
667 # Win9x problem with non-blocking read from a closed pipe
668 d_eofnblk='define'
669 --- Makefile.SH.orig 2006-01-24 21:49:44.000000000 +0900
670 +++ Makefile.SH 2014-05-12 02:22:56.994353100 +0900
671 @@ -361,7 +361,7 @@
672 c = $(c1) $(c2) $(c3) $(c4) miniperlmain.c perlmain.c opmini.c
673
674 obj1 = $(mallocobj) gv$(OBJ_EXT) toke$(OBJ_EXT) perly$(OBJ_EXT) op$(OBJ_EXT) pad$(OBJ_EXT) regcomp$(OBJ_EXT) dump$(OBJ_EXT) util$(OBJ_EXT) mg$(OBJ_EXT) reentr$(OBJ_EXT)
675 -obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) run$(OBJ_EXT) pp_hot$(OBJ_EXT) sv$(OBJ_EXT) pp$(OBJ_EXT) scope$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_sys$(OBJ_EXT)
676 +obj2 = hv$(OBJ_EXT) av$(OBJ_EXT) perl$(OBJ_EXT) run$(OBJ_EXT) pp_hot$(OBJ_EXT) sv$(OBJ_EXT) pp$(OBJ_EXT) scope$(OBJ_EXT) pp_ctl$(OBJ_EXT) pp_sys$(OBJ_EXT)
677 obj3 = doop$(OBJ_EXT) doio$(OBJ_EXT) regexec$(OBJ_EXT) utf8$(OBJ_EXT) taint$(OBJ_EXT) deb$(OBJ_EXT) universal$(OBJ_EXT) xsutils$(OBJ_EXT) globals$(OBJ_EXT) perlio$(OBJ_EXT) perlapi$(OBJ_EXT) numeric$(OBJ_EXT) locale$(OBJ_EXT) pp_pack$(OBJ_EXT) pp_sort$(OBJ_EXT)
678
679 obj = $(obj1) $(obj2) $(obj3) $(ARCHOBJS)
680 @@ -496,9 +496,9 @@
681 LIBPERL_NONSHR = libperl_nonshr$(LIB_EXT)
682 MINIPERL_NONSHR = miniperl_nonshr$(EXE_EXT)
683
684 -$(LIBPERL_NONSHR): perl$(OBJ_EXT) $(obj)
685 +$(LIBPERL_NONSHR): $(obj)
686 $(RMS) $(LIBPERL_NONSHR)
687 - $(AR) rcu $(LIBPERL_NONSHR) perl$(OBJ_EXT) $(obj)
688 + $(AR) rcu $(LIBPERL_NONSHR) $(obj)
689
690 $(MINIPERL_NONSHR): $(LIBPERL_NONSHR) miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT)
691 $(CC) $(LDFLAGS) -o $(MINIPERL_NONSHR) miniperlmain$(OBJ_EXT) \
692 @@ -545,12 +545,12 @@
693 !GROK!THIS!
694 else
695 $spitshell >>Makefile <<'!NO!SUBS!'
696 -$(LIBPERL): $& perl$(OBJ_EXT) $(obj) $(LIBPERLEXPORT)
697 +$(LIBPERL): $& $(obj) $(LIBPERLEXPORT)
698 !NO!SUBS!
699 case "$useshrplib" in
700 true)
701 $spitshell >>Makefile <<'!NO!SUBS!'
702 - $(LD) -o $@ $(SHRPLDFLAGS) perl$(OBJ_EXT) $(obj) $(libs)
703 + $(LD) -o $@ $(SHRPLDFLAGS) $(obj) $(libs)
704 !NO!SUBS!
705 case "$osname" in
706 aix)
707 @@ -565,7 +565,7 @@
708 *)
709 $spitshell >>Makefile <<'!NO!SUBS!'
710 rm -f $(LIBPERL)
711 - $(AR) rcu $(LIBPERL) perl$(OBJ_EXT) $(obj)
712 + $(AR) rcu $(LIBPERL) $(obj)
713 @$(ranlib) $(LIBPERL)
714 !NO!SUBS!
715 ;;
716 @@ -590,7 +590,7 @@
717 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
718 $(CC) -o miniperl $(CLDFLAGS) \
719 `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
720 - miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perl$(OBJ_EXT) $(libs)
721 + miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(libs)
722 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
723 !NO!SUBS!
724 ;;
725 @@ -598,7 +598,7 @@
726 $spitshell >>Makefile <<'!NO!SUBS!'
727 miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL) opmini$(OBJ_EXT)
728 $(CC) -o miniperl `echo $(obj) | sed 's/ op$(OBJ_EXT) / /'` \
729 - miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perl$(OBJ_EXT) $(libs)
730 + miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) $(libs)
731 $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
732 !NO!SUBS!
733 ;;
734 END
735  
736 0 ▶ if($_[0] =~ /^5\.8\.[1-8]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /^5\.8\.[1-8]$/) { } 0 0 0
737 my @adjust = (
738 0 ▶ [ qr/^5\.8\.[1-7]/, sub { $_[0] =~ s/ \|\| \$Is_VMS//; } ],
Subroutine __ANON__: not called CC=1 SCAR=6.9
739 0 ▶ [ qr/^5\.8\.[1-4]/, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
740 0 $_[0] =~ s/\@\@ -260,40/@@ -260,39/;
741 0 $_[0] =~ s/-\t\t\$packlist->.*\n//;
742 0 } ],
743 );
744 0 my $patch = <<'END'; $_->[1]->($patch) for grep { Devel::PatchPerl::_is( $_->[0], $_[0] ) } @adjust; Devel::PatchPerl::_patch($patch);
745 --- installperl.orig 2006-01-29 00:35:28.000000000 +0900
746 +++ installperl 2014-05-12 02:41:30.833722700 +0900
747 @@ -260,40 +260,9 @@
748
749 if ($Is_Cygwin) {
750 $perldll = $libperl;
751 - my $v_e_r_s = $ver; $v_e_r_s =~ tr/./_/;
752 + my $v_e_r_s = substr($ver,0,-2); $v_e_r_s =~ tr/./_/;
753 $perldll =~ s/(\..*)?$/$v_e_r_s.$dlext/;
754 $perldll =~ s/^lib/cyg/;
755 - if ($Config{useshrplib} eq 'true') {
756 - # install ld2 and perlld as well
757 - foreach ('ld2', 'perlld') {
758 - safe_unlink("$installbin/$_");
759 - copy("$_", "$installbin/$_");
760 - chmod(0755, "$installbin/$_");
761 - $packlist->{"$installbin/$_"} = { type => 'file' };
762 - };
763 - open (LD2, ">$installbin/ld2");
764 - print LD2 <<SHELL;
765 -#!/bin/sh
766 -#
767 -# ld wrapper, passes all args to perlld;
768 -#
769 -for trythis in $installbin/perl
770 -do
771 - if [ -x \$trythis ]
772 - then
773 - \$trythis $installbin/perlld "\$\@"
774 - exit \$?
775 - fi
776 -done
777 -# hard luck!
778 -echo I see no perl executable around there
779 -echo perl is required to build dynamic libraries
780 -echo look if the path to perl in /bin/ld2 is correct
781 -exit 1
782 -SHELL
783 - close LD2;
784 - chmod(0755, "$installbin/ld2");
785 - };
786 } else {
787 $perldll = 'perl58.' . $dlext;
788 }
789 @@ -376,6 +345,7 @@
790 # Install library files.
791
792 my ($do_installarchlib, $do_installprivlib) = (0, 0);
793 +my $vershort = $Is_Cygwin ? substr($ver,0,-2) : $ver;
794
795 mkpath($installprivlib, $verbose, 0777);
796 mkpath($installarchlib, $verbose, 0777);
797 @@ -385,7 +355,7 @@
798 if (chdir "lib") {
799 $do_installarchlib = ! samepath($installarchlib, '.');
800 $do_installprivlib = ! samepath($installprivlib, '.');
801 - $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$ver/);
802 + $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$vershort/);
803
804 if ($do_installarchlib || $do_installprivlib) {
805 find(\&installlib, '.');
806 @@ -589,7 +559,7 @@
807 # ($installprivlib/pods for cygwin).
808
809 my $pod = ($Is_Cygwin || $Is_Darwin || $Is_VMS) ? 'pods' : 'pod';
810 -if ( !$versiononly || ($installprivlib =~ m/\Q$ver/)) {
811 +if ( !$versiononly || ($installprivlib =~ m/\Q$vershort/)) {
812 mkpath("${installprivlib}/$pod", $verbose, 0777);
813
814 # If Perl 5.003's perldiag.pod is there, rename it.
815 END
816 } else {
817 0 Devel::PatchPerl::_patch(<<'END');
818 --- installperl.orig 2002-07-17 03:57:32.000000000 +0900
819 +++ installperl 2014-05-12 11:10:17.032674700 +0900
820 @@ -234,29 +234,9 @@
821
822 if ($Is_Cygwin) {
823 $perldll = $libperl;
824 - my $v_e_r_s = $ver; $v_e_r_s =~ tr/./_/;
825 + my $v_e_r_s = substr($ver,0,-2); $v_e_r_s =~ tr/./_/;
826 $perldll =~ s/(\..*)?$/$v_e_r_s.$dlext/;
827 $perldll =~ s/^lib/cyg/;
828 - if ($Config{useshrplib} eq 'true') {
829 - # install ld2 and perlld as well
830 - foreach ('ld2', 'perlld') {
831 - safe_unlink("$installbin/$_");
832 - copy("$_", "$installbin/$_");
833 - chmod(0755, "$installbin/$_");
834 - };
835 - {
836 - open (LD2, ">$installbin/ld2");
837 - print LD2 "#!/bin/sh\n#\n# ld wrapper, passes all args to perlld;\n#\n"
838 - . "for trythis in $installbin/perl\ndo\n if [ -x \$trythis ]\n"
839 - . " then\n \$trythis $installbin/perlld \"\$\@\"\n"
840 - . " exit \$?\n fi\ndone\n# hard luck!\necho i see no perl"
841 - . " executable around there\necho perl is required to build "
842 - . "dynamic libraries\necho look if the path to perl in /bin/ld2"
843 - . " is correct\nexit 1\n";
844 - close LD2;
845 - };
846 - chmod(0755, "$installbin/ld2");
847 - };
848 } else {
849 $perldll = 'perl58.' . $dlext;
850 }
851 @@ -331,6 +311,7 @@
852 # Install library files.
853
854 my ($do_installarchlib, $do_installprivlib) = (0, 0);
855 +my $vershort = $Is_Cygwin ? substr($ver,0,-2) : $ver;
856
857 mkpath($installprivlib, $verbose, 0777);
858 mkpath($installarchlib, $verbose, 0777);
859 @@ -340,7 +321,7 @@
860 if (chdir "lib") {
861 $do_installarchlib = ! samepath($installarchlib, '.');
862 $do_installprivlib = ! samepath($installprivlib, '.');
863 - $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$ver/);
864 + $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$vershort/);
865
866 if ($do_installarchlib || $do_installprivlib) {
867 find(\&installlib, '.');
868 END
869 }
870 }
871  
872 sub _patch_cygwin_GNU_SOURCE
873 0 ▶{
Subroutine _patch_cygwin_GNU_SOURCE: not called CC=2 SCAR=17.9
874 # Override Devel::PatchPerl::Hints until it is fixed
875 0 ▶ Devel::PatchPerl::_patch(<<'END') if Devel::PatchPerl::Hints->hint_file("cygwin") =~ /ccflags="\$ccflags -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__"/;
Branch: 1 branch
BranchTrueFalseTotal
if "Devel::PatchPerl::Hints"->hint_file("cygwin") =~ /ccflags="\$ccflags -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__"/ 0 0 0
876 --- hints/cygwin.sh.orig 2018-05-16 17:14:35.085980800 +0900
877 +++ hints/cygwin.sh 2018-05-16 18:32:34.356348000 +0900
878 @@ -31,7 +31,7 @@
879 man3ext='3pm'
880 test -z "$use64bitint" && use64bitint='define'
881 test -z "$useithreads" && useithreads='define'
882 -ccflags="$ccflags -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__"
883 +ccflags="$ccflags -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE"
884 # - otherwise i686-cygwin
885 archname='cygwin'
886  
887 END
888 }
889  
890 sub _patch_cygwin_PATH_quote
891 0 ▶{
Subroutine _patch_cygwin_PATH_quote: not called CC=2 SCAR=17.9
892 my @adjust = (
893 [ [
894 qr/^5\.8\.[0-9]$/,
895 qr/^5\.10\.[01]$/,
896 0 ▶ ], sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
897 0 $_[0] =~ s|\@\@ -1,3 \+1,12 @@|@@ -1,4 +1,13 @@\n #! /bin/sh|;
898 0 } ],
899 );
900 0 my $patch = <<'END'; $_->[1]->($patch) for grep { Devel::PatchPerl::_is( $_->[0], $_[0] ) } @adjust; Devel::PatchPerl::_patch($patch);
901 --- Makefile.SH.orig 2013-03-05 00:16:21.000000000 +0900
902 +++ Makefile.SH 2018-05-17 14:35:26.914781400 +0900
903 @@ -1,3 +1,12 @@
904 +# quote() - Creates a shell literal
905 +# Usage: echo "...` quote "..." `..."
906 +quote() {
907 + case "$1" in
908 + '') echo "''" ;;
909 + *) echo "$1" | sed 's/\([^a-zA-Z0-9.:_\-\/]\)/\\\1/g' ;;
910 + esac
911 +}
912 +
913 case $PERL_CONFIG_SH in
914 '')
915 if test -f config.sh
916 @@ -119,7 +128,13 @@
917 ldlibpth=''
918 ;;
919 *)
920 - eval "ldlibpth=\"$ldlibpthname=`pwd`:\$$ldlibpthname\""
921 + eval "ldlibpthval=\"\$$ldlibpthname\""
922 +
923 + case "$ldlibpthval" in
924 + '') ldlibpth="$ldlibpthname=` quote "$pwd" `" ;;
925 + *) ldlibpth="$ldlibpthname=` quote "$pwd" `:` quote "$ldlibpthval" `" ;;
926 + esac
927 +
928 ;;
929 esac
930 # Strip off any trailing :'s
931 @@ -127,11 +142,6 @@
932 ;;
933 esac
934
935 - case "$ldlibpth" in
936 - # Protect any spaces
937 - *" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;;
938 - esac
939 -
940 case "$osname" in
941 linux)
942 # If there is a pre-existing $libperl from a previous
943 END
944 }
945  
946 1 1
947  
948 __END__
↑ Summary