develooper Front page | perl.perl5.porters | Postings from September 2001

Patch to put qsortsv in the public API

Thread Next
From:
Brian Ingerson
Date:
September 29, 2001 17:41
Subject:
Patch to put qsortsv in the public API
Message ID:
20010929174113.A30223@ttul.org
This patch is needed to support the patch I have made to Data::Dumper which
allows for the sorting of hash keys.

Sarathy suggested dropping the 'q' to leave 'sortsv'.

Cheers, Brian

--- embed.pl.orig       Wed Sep 26 20:25:26 2001
+++ embed.pl    Sat Sep 29 16:31:18 2001
@@ -1469,6 +1469,7 @@
 Afp    |SV*    |mess           |const char* pat|...
 Ap     |SV*    |vmess          |const char* pat|va_list* args
 p      |void   |qerror         |SV* err
+Apd    |void   |sortsv         |SV ** array|size_t num_elts|SVCOMPARE_t f
 Apd    |int    |mg_clear       |SV* sv
 Apd    |int    |mg_copy        |SV* sv|SV* nsv|const char* key|I32 klen
 Apd    |MAGIC* |mg_find        |SV* sv|int type
@@ -2104,7 +2105,6 @@
 s      |void   |save_lines     |AV *array|SV *sv
 s      |OP*    |doeval         |int gimme|OP** startop
 s      |PerlIO *|doopen_pmc    |const char *name|const char *mode
-s      |void   |qsortsv        |SV ** array|size_t num_elts|SVCOMPARE_t f
 #endif
 
 #if defined(PERL_IN_PP_HOT_C) || defined(PERL_DECL_PROT)


--- pp_ctl.c.orig       Wed Sep 26 06:59:55 2001
+++ pp_ctl.c    Sat Sep 29 16:59:43 2001
@@ -1018,8 +1018,8 @@
                cx->blk_sub.oldcurpad = PL_curpad;
                cx->blk_sub.argarray = av;
            }
-           qsortsv((myorigmark+1), max,
-                   is_xsub ? sortcv_xsub : hasargs ? sortcv_stacked :
sortcv);
+           sortsv((myorigmark+1), max,
+                  is_xsub ? sortcv_xsub : hasargs ? sortcv_stacked :
sortcv);
 
            POPBLOCK(cx,PL_curpm);
            PL_stack_sp = newsp;
@@ -1030,8 +1030,8 @@
     else {
        if (max > 1) {
            MEXTEND(SP, 20);    /* Can't afford stack realloc on signal. */
-           qsortsv(ORIGMARK+1, max,
-                   (PL_op->op_private & OPpSORT_NUMERIC)
+           sortsv(ORIGMARK+1, max,
+                  (PL_op->op_private & OPpSORT_NUMERIC)
                        ? ( (PL_op->op_private & OPpSORT_INTEGER)
                            ? ( overloading ? amagic_i_ncmp : sv_i_ncmp)
                            : ( overloading ? amagic_ncmp : sv_ncmp))
@@ -4032,8 +4032,18 @@
 ** They make convenient temporary pointers in other places.
 */
 
-STATIC void
-S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp)
+/* 
+=for apidoc sortsv
+   
+Sort an array in place. Here is an example:
+
+    sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale); 
+
+=cut
+*/
+    
+void
+Perl_sortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp)
 {
     int i, run;
     int sense;


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