@@ -515,6 +515,98 @@ scanpmdisfunctions(HashTable ht, ScanFunc func, int flags)
515
515
scanfunctions (ht , func , flags , DISABLED );
516
516
}
517
517
518
+ /* Functions for the functions_source special parameter. */
519
+
520
+ /* Retrieve the source file for a function by explicit name */
521
+
522
+ /**/
523
+ static HashNode
524
+ getfunction_source (UNUSED (HashTable ht ), const char * name , int dis )
525
+ {
526
+ Shfunc shf ;
527
+ Param pm = NULL ;
528
+
529
+ pm = (Param ) hcalloc (sizeof (struct param ));
530
+ pm -> node .nam = dupstring (name );
531
+ pm -> node .flags = PM_SCALAR |PM_READONLY ;
532
+ pm -> gsu .s = dis ? & pmdisfunction_gsu : & pmfunction_gsu ;
533
+
534
+ if ((shf = (Shfunc ) shfunctab -> getnode2 (shfunctab , name )) &&
535
+ (dis ? (shf -> node .flags & DISABLED ) : !(shf -> node .flags & DISABLED ))) {
536
+ pm -> u .str = getshfuncfile (shf );
537
+ if (!pm -> u .str )
538
+ pm -> u .str = dupstring ("" );
539
+ }
540
+ return & pm -> node ;
541
+ }
542
+
543
+ /* Retrieve the source file for functions by scanning the table */
544
+
545
+ /**/
546
+ static void
547
+ scanfunctions_source (UNUSED (HashTable ht ), ScanFunc func , int flags , int dis )
548
+ {
549
+ struct param pm ;
550
+ int i ;
551
+ HashNode hn ;
552
+
553
+ memset ((void * )& pm , 0 , sizeof (struct param ));
554
+ pm .node .flags = PM_SCALAR |PM_READONLY ;
555
+ pm .gsu .s = dis ? & pmdisfunction_gsu : & pmfunction_gsu ;
556
+
557
+ for (i = 0 ; i < shfunctab -> hsize ; i ++ ) {
558
+ for (hn = shfunctab -> nodes [i ]; hn ; hn = hn -> next ) {
559
+ if (dis ? (hn -> flags & DISABLED ) : !(hn -> flags & DISABLED )) {
560
+ pm .node .nam = hn -> nam ;
561
+ if (func != scancountparams &&
562
+ ((flags & (SCANPM_WANTVALS |SCANPM_MATCHVAL )) ||
563
+ !(flags & SCANPM_WANTKEYS ))) {
564
+ pm .u .str = getshfuncfile ((Shfunc )hn );
565
+ if (!pm .u .str )
566
+ pm .u .str = dupstring ("" );
567
+ }
568
+ func (& pm .node , flags );
569
+ }
570
+ }
571
+ }
572
+ }
573
+
574
+ /* Param table entry for retrieving functions_source element */
575
+
576
+ /**/
577
+ static HashNode
578
+ getpmfunction_source (HashTable ht , const char * name )
579
+ {
580
+ return getfunction_source (ht , name , 0 );
581
+ }
582
+
583
+ /* Param table entry for retrieving ds_functions_source element */
584
+
585
+ /**/
586
+ static HashNode
587
+ getpmdisfunction_source (HashTable ht , const char * name )
588
+ {
589
+ return getfunction_source (ht , name , 1 );
590
+ }
591
+
592
+ /* Param table entry for scanning functions_source table */
593
+
594
+ /**/
595
+ static void
596
+ scanpmfunction_source (HashTable ht , ScanFunc func , int flags )
597
+ {
598
+ scanfunctions_source (ht , func , flags , 0 );
599
+ }
600
+
601
+ /* Param table entry for scanning dis_functions_source table */
602
+
603
+ /**/
604
+ static void
605
+ scanpmdisfunction_source (HashTable ht , ScanFunc func , int flags )
606
+ {
607
+ scanfunctions_source (ht , func , flags , 1 );
608
+ }
609
+
518
610
/* Functions for the funcstack special parameter. */
519
611
520
612
/**/
@@ -2095,6 +2187,8 @@ static struct paramdef partab[] = {
2095
2187
NULL , getpmdisbuiltin , scanpmdisbuiltins ),
2096
2188
SPECIALPMDEF ("dis_functions" , 0 ,
2097
2189
& pmdisfunctions_gsu , getpmdisfunction , scanpmdisfunctions ),
2190
+ SPECIALPMDEF ("dis_functions_source" , PM_READONLY , NULL ,
2191
+ getpmdisfunction_source , scanpmdisfunction_source ),
2098
2192
SPECIALPMDEF ("dis_galiases" , 0 ,
2099
2193
& pmdisgaliases_gsu , getpmdisgalias , scanpmdisgaliases ),
2100
2194
SPECIALPMDEF ("dis_patchars" , PM_ARRAY |PM_READONLY ,
@@ -2111,6 +2205,8 @@ static struct paramdef partab[] = {
2111
2205
& funcstack_gsu , NULL , NULL ),
2112
2206
SPECIALPMDEF ("functions" , 0 , & pmfunctions_gsu , getpmfunction ,
2113
2207
scanpmfunctions ),
2208
+ SPECIALPMDEF ("functions_source" , PM_READONLY , NULL ,
2209
+ getpmfunction_source , scanpmfunction_source ),
2114
2210
SPECIALPMDEF ("functrace" , PM_ARRAY |PM_READONLY ,
2115
2211
& functrace_gsu , NULL , NULL ),
2116
2212
SPECIALPMDEF ("galiases" , 0 ,
0 commit comments