develooper Front page | perl.perl5.porters | Postings from April 2004

How to access sort subpragma values in xs?

Thread Next
From:
Zartaj T. Majeed
Date:
April 2, 2004 15:18
Subject:
How to access sort subpragma values in xs?
Message ID:
006001c418fd$cf9e0a10$19b2f882@margalla
I have an xs in which I'd like to know the value of a sort
subpragma in the calling script. So I have something like:

#script.pl
use sort 'stable';
# functionality implemented in myext.xs

In the C sources for myext I have copied something from
pp_sort.c:

#define SORTHINTS(hintsv) \
    (((hintsv) = GvSV(gv_fetchpv("sort::hints", GV_ADDMULTI, SVt_IV))), \
    (SvIOK(hintsv) ? ((I32)SvIV(hintsv)) : 0))

to be used as:

if(SORTHINTS(hintsv) & HINT_SORT_STABLE)
  /* do something for stable sort */
else
  /* do something else */

The problem is SORTHINTS does not give me the
right values in myext and control always flows to the else. 
My guess is it is looking in the wrong interpreter context 
but I don't know how to access the context for 
the calling script and get the right value.

Thanks,
Zartaj




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About