- Add support for either \ or / as separators on DOSISH systems
- Limit effect of \ as a quoting operator on DOSISH systems to
when it precedes one of []{}-~\ (to minimise backslashitis).
+0.992 Tue Mar 20 09:25:48 2001
+ - Add alphabetic sorting for csh compatibility (GLOB_ALPHASORT)
bsd_glob
glob
GLOB_ABEND
+ GLOB_ALPHASORT
GLOB_ALTDIRFUNC
GLOB_BRACE
GLOB_CSH
%EXPORT_TAGS = (
'glob' => [ qw(
GLOB_ABEND
+ GLOB_ALPHASORT
GLOB_ALTDIRFUNC
GLOB_BRACE
GLOB_CSH
return constant('GLOB_ERROR', 0);
}
-sub GLOB_CSH () { GLOB_BRACE() | GLOB_NOMAGIC() | GLOB_QUOTE() | GLOB_TILDE() }
+sub GLOB_CSH () {
+ GLOB_BRACE()
+ | GLOB_NOMAGIC()
+ | GLOB_QUOTE()
+ | GLOB_TILDE()
+ | GLOB_ALPHASORT()
+}
$DEFAULT_FLAGS = GLOB_CSH();
if ($^O =~ /^(?:MSWin32|VMS|os2|dos|riscos|MacOS)$/) {
=item C<GLOB_CSH>
For convenience, C<GLOB_CSH> is a synonym for
-C<GLOB_BRACE | GLOB_NOMAGIC | GLOB_QUOTE | GLOB_TILDE>.
+C<GLOB_BRACE | GLOB_NOMAGIC | GLOB_QUOTE | GLOB_TILDE | GLOB_ALPHASORT>.
=back
implemented in the Perl version because they involve more complex
interaction with the underlying C structures.
+The following flag has been added in the Perl implementation for
+csh compatibility:
+
+=over 4
+
+=item C<GLOB_ALPHASORT>
+
+If C<GLOB_NOSORT> is not in effect, sort filenames is alphabetical
+order (case does not matter) rather than in ASCII order.
+
+=back
+
=head1 DIAGNOSTICS
bsd_glob() returns a list of matching paths, possibly zero length. If an
#else
goto not_there;
#endif
+ if (strEQ(name, "GLOB_ALPHASORT"))
+#ifdef GLOB_ALPHASORT
+ return GLOB_ALPHASORT;
+#else
+ goto not_there;
+#endif
if (strEQ(name, "GLOB_ALTDIRFUNC"))
#ifdef GLOB_ALTDIRFUNC
return GLOB_ALTDIRFUNC;
* expand {1,2}{a,b} to 1a 1b 2a 2b
* gl_matchc:
* Number of matches in the current invocation of glob.
+ * GLOB_ALPHASORT:
+ * sort alphabetically like csh (case doesn't matter) instead of in ASCII
+ * order
*/
#include <EXTERN.h>
else if (!(pglob->gl_flags & GLOB_NOSORT))
qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
pglob->gl_pathc - oldpathc, sizeof(char *),
- (pglob->gl_flags & GLOB_NOCASE) ? ci_compare : compare);
+ (pglob->gl_flags & (GLOB_ALPHASORT|GLOB_NOCASE))
+ ? ci_compare : compare);
pglob->gl_flags = oldflags;
return(0);
}
#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
#define GLOB_NOCASE 0x1000 /* Treat filenames without regard for case. */
+#define GLOB_ALPHASORT 0x2000 /* Alphabetic, not ASCII sort, like csh. */
#define GLOB_NOSPACE (-1) /* Malloc call failed. */
#define GLOB_ABEND (-2) /* Unignored error. */
}
SvMAGIC(sv) = SvMAGIC(osv);
SvFLAGS(sv) |= SvMAGICAL(osv);
+ /* XXX SvMAGIC() is *shared* between osv and sv. This can
+ * lead to coredumps when both SVs are destroyed without one
+ * of their SvMAGIC() slots being NULLed. */
PL_localizing = 1;
SvSETMAGIC(sv);
PL_localizing = 0;
SvMAGICAL_off(sv);
SvMAGIC(sv) = 0;
}
- /* XXX this branch is pretty bogus--note that we seem to
- * only get here if the mg_get() in save_scalar_at() ends
- * up croaking. This code irretrievably clears(!) the magic
- * on the SV to avoid further croaking that might ensue
- * when the SvSETMAGIC() below is called. This needs a
- * total rethink. --GSAR */
+ /* XXX This branch is pretty bogus. This code irretrievably
+ * clears(!) the magic on the SV (either to avoid further
+ * croaking that might ensue when the SvSETMAGIC() below is
+ * called, or to avoid two different SVs pointing at the same
+ * SvMAGIC()). This needs a total rethink. --GSAR */
else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
SvTYPE(value) != SVt_PVGV)
{
SvFLAGS(value) |= (SvFLAGS(value) &
(SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT;
SvMAGICAL_off(value);
- mg_free(value);
+ /* XXX this is a leak when we get here because the
+ * mg_get() in save_scalar_at() croaked */
+ SvMAGIC(value) = 0;
}
SvREFCNT_dec(sv);
*(SV**)ptr = value;
{
$DESCRIPTOR(d_tab, "LNM$PROCESS");
struct dsc$descriptor_d d_name = {0,DSC$K_DTYPE_T,DSC$K_CLASS_D,0};
- unsigned long int iss, attr = 0;
+ unsigned long int iss, attr = LNM$M_CONFINE;
unsigned char acmode = PSL$C_USER;
struct itmlst_3 lnmlst[2] = {{0, LNM$_STRING, 0, 0},
{0, 0, 0, 0}};
fprintf(fp,"$ perl_del = \"delete\"\n");
fprintf(fp,"$ pif = \"if\"\n");
fprintf(fp,"$! --- define i/o redirection (sys$output set by lib$spawn)\n");
- fprintf(fp,"$ pif perl_popen_in .nes. \"\" then perl_define/user sys$input 'perl_popen_in'\n");
- fprintf(fp,"$ pif perl_popen_err .nes. \"\" then perl_define/user sys$error 'perl_popen_err'\n");
+ fprintf(fp,"$ pif perl_popen_in .nes. \"\" then perl_define/user/name_attributes=confine sys$input 'perl_popen_in'\n");
+ fprintf(fp,"$ pif perl_popen_err .nes. \"\" then perl_define/user/name_attributes=confine sys$error 'perl_popen_err'\n");
fprintf(fp,"$ pif perl_popen_out .nes. \"\" then perl_define sys$output 'perl_popen_out'\n");
fprintf(fp,"$ cmd = perl_popen_cmd\n");
fprintf(fp,"$! --- get rid of global symbols\n");
$ perl_del = "delete"
$ pif = "if"
$! --- define i/o redirection (sys$output set by lib$spawn)
-$ pif perl_popen_in .nes. "" then perl_define/user sys$input 'perl_popen_in'
-$ pif perl_popen_err .nes. "" then perl_define/user sys$error 'perl_popen_err'
+$ pif perl_popen_in .nes. "" then perl_define/user/name_attributes=confine sys$input 'perl_popen_in'
+$ pif perl_popen_err .nes. "" then perl_define/user/name_attributes=confine sys$error 'perl_popen_err'
$ pif perl_popen_out .nes. "" then perl_define sys$output 'perl_popen_out'
$ cmd = perl_popen_cmd
$! --- get rid of global symbols