X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=cygwin%2Fcygwin.c;h=21ec98cd6e8cced24bc00684568084c28506edc2;hb=afce0a13caf9540b17869e0f39804bd5e44199c7;hp=84915f811e94a8242524eb25b4e832bbf1d6d4c3;hpb=a25ce5f3442bbcc3cab66c0ed964d3ef6a8e8ca3;p=p5sagit%2Fp5-mst-13.2.git diff --git a/cygwin/cygwin.c b/cygwin/cygwin.c index 84915f8..21ec98c 100644 --- a/cygwin/cygwin.c +++ b/cygwin/cygwin.c @@ -63,7 +63,7 @@ do_aspawn (SV *really, void **mark, void **sp) *a++ = SvPVx((SV *)*mark, n_a); else *a++ = ""; - *a = Nullch; + *a = (char*)NULL; if (argv[0][0] != '/' && argv[0][0] != '\\' && !(argv[0][0] && argv[0][1] == ':' @@ -83,7 +83,8 @@ int do_spawn (char *cmd) { dTHX; - char **a,*s,*metachars = "$&*(){}[]'\";\\?>|<~`\n"; + char const **a; + char *s,*metachars = "$&*(){}[]'\";\\?>|<~`\n"; const char *command[4]; while (*cmd && isSPACE(*cmd)) @@ -121,7 +122,7 @@ do_spawn (char *cmd) return do_spawnvp("sh",command); } - Newx (PL_Argv,(s-cmd)/2+2,char*); + Newx (PL_Argv,(s-cmd)/2+2,const char*); PL_Cmd=savepvn (cmd,s-cmd); a=PL_Argv; for (s=PL_Cmd; *s;) { @@ -132,7 +133,7 @@ do_spawn (char *cmd) if (*s) *s++='\0'; } - *a=Nullch; + *a = (char*)NULL; if (!PL_Argv[0]) return -1; @@ -145,7 +146,10 @@ XS(Cygwin_cwd) dXSARGS; char *cwd; - if(items != 0) + /* See http://rt.perl.org/rt3/Ticket/Display.html?id=38628 + There is Cwd->cwd() usage in the wild, and previous versions didn't die. + */ + if(items > 1) Perl_croak(aTHX_ "Usage: Cwd::cwd()"); if((cwd = getcwd(NULL, -1))) { ST(0) = sv_2mortal(newSVpv(cwd, 0)); @@ -289,28 +293,31 @@ XS(XS_Cygwin_mount_flags) char flags[260]; if (items != 1) - Perl_croak(aTHX_ "Usage: Cygwin::mount_flags(mnt_dir)"); + Perl_croak(aTHX_ "Usage: Cygwin::mount_flags(mnt_dir|'/cygwin')"); pathname = SvPV_nolen(ST(0)); - - /* TODO: check for cygdrive registry setting. use CW_GET_CYGDRIVE_INFO then + + /* TODO: Check for cygdrive registry setting, + * and then use CW_GET_CYGDRIVE_INFO */ if (!strcmp(pathname, "/cygdrive")) { char user[260]; char system[260]; char user_flags[260]; char system_flags[260]; + cygwin_internal (CW_GET_CYGDRIVE_INFO, user, system, user_flags, system_flags); - if (strlen(system) > 0) - strcpy (flags, system_flags); - if (strlen(user) > 0) - strcpy(flags, user_flags); - if (strlen(flags) > 0) - strcat(flags, ","); - strcat(flags, "cygdrive"); + + if (strlen(user) > 0) { + sprintf(flags, "%s,cygdrive,%s", user_flags, user); + } else { + sprintf(flags, "%s,cygdrive,%s", system_flags, system); + } + ST(0) = sv_2mortal(newSVpv(flags, 0)); XSRETURN(1); + } else { struct mntent *mnt; setmntent (0, 0); @@ -344,20 +351,6 @@ XS(XS_Cygwin_is_binmount) XSRETURN(1); } -XS(XS_Cygwin_is_textmount) -{ - dXSARGS; - char *pathname; - - if (items != 1) - Perl_croak(aTHX_ "Usage: Cygwin::is_textmount(pathname)"); - - pathname = SvPV_nolen(ST(0)); - - ST(0) = boolSV(!cygwin_internal(CW_GET_BINMODE, pathname)); - XSRETURN(1); -} - void init_os_extras(void) { @@ -373,7 +366,6 @@ init_os_extras(void) newXSproto("Cygwin::mount_table", XS_Cygwin_mount_table, file, ""); newXSproto("Cygwin::mount_flags", XS_Cygwin_mount_flags, file, "$"); newXSproto("Cygwin::is_binmount", XS_Cygwin_is_binmount, file, "$"); - newXSproto("Cygwin::is_textmount", XS_Cygwin_is_textmount, file, "$"); /* Initialize Win32CORE if it has been statically linked. */ handle = dlopen(NULL, RTLD_LAZY);