line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
3
|
|
|
|
|
|
|
#include "perl.h" |
4
|
|
|
|
|
|
|
#include "XSUB.h" |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
typedef struct { const char* pointer; size_t length; } string; |
7
|
|
|
|
|
|
|
typedef struct { string key; string value; bool autovivify; } entry; |
8
|
|
|
|
|
|
|
typedef entry map[]; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#define MAP(key, value, autovivify) { { key, sizeof(key) - 1 }, { value, sizeof(value) - 1 }, autovivify } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#define hv_exists_no_uvar(hv, key, klen) cBOOL(hv_common_key_len((hv), (key), (klen), HV_FETCH_ISEXISTS | HV_DISABLE_UVAR_XKEY, NULL, 0)) |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
static map aliases = { |
15
|
|
|
|
|
|
|
MAP("\1RG", "_", 0), |
16
|
|
|
|
|
|
|
MAP("\14IST_SEPARATOR", "\"", 1), |
17
|
|
|
|
|
|
|
MAP("\20ID", "$", 1), |
18
|
|
|
|
|
|
|
MAP("\20ROCESS_ID", "$", 1), |
19
|
|
|
|
|
|
|
MAP("\20ROGRAM_NAME", "0", 1), |
20
|
|
|
|
|
|
|
MAP("\22EAL_GROUP_ID", "(", 1), |
21
|
|
|
|
|
|
|
MAP("\7ID", "(", 1), |
22
|
|
|
|
|
|
|
MAP("\5FFECTIVE_GROUP_ID", ")", 1), |
23
|
|
|
|
|
|
|
MAP("\5GID", ")", 1), |
24
|
|
|
|
|
|
|
MAP("\22EAL_USER_ID", "<", 1), |
25
|
|
|
|
|
|
|
MAP("\25ID", "<", 1), |
26
|
|
|
|
|
|
|
MAP("\5FFECTIVE_USER_ID", ">", 1), |
27
|
|
|
|
|
|
|
MAP("\5UID", ">", 1), |
28
|
|
|
|
|
|
|
MAP("\23UBSCRIPT_SEPARATOR", ";", 1), |
29
|
|
|
|
|
|
|
MAP("\23UBSEP", ";", 1), |
30
|
|
|
|
|
|
|
MAP("\17LD_PERL_VERSION", "]", 1), |
31
|
|
|
|
|
|
|
MAP("\23YSTEM_FD_MAX", "\6", 1), |
32
|
|
|
|
|
|
|
MAP("\11NPLACE_EDIT", "\11", 1), |
33
|
|
|
|
|
|
|
MAP("\17SNAME", "\17", 1), |
34
|
|
|
|
|
|
|
MAP("\20ERL_VERSION", "\26", 1), |
35
|
|
|
|
|
|
|
MAP("\5XECUTABLE_NAME", "\30", 1), |
36
|
|
|
|
|
|
|
MAP("\15ATCH", "&", 1), |
37
|
|
|
|
|
|
|
MAP("\20REMATCH", "`", 1), |
38
|
|
|
|
|
|
|
MAP("\20OSTMATCH", "'", 1), |
39
|
|
|
|
|
|
|
MAP("\20ERLDB", "\20", 1), |
40
|
|
|
|
|
|
|
MAP("\14AST_PAREN_MATCH", "+", 1), |
41
|
|
|
|
|
|
|
MAP("\14AST_SUBMATCH_RESULT", "\16", 1), |
42
|
|
|
|
|
|
|
MAP("\14AST_MATCH_END", "+", 1), |
43
|
|
|
|
|
|
|
MAP("\14AST_MATCH_START", "-", 1), |
44
|
|
|
|
|
|
|
MAP("\14AST_REGEXP_CODE_RESULT", "\22", 1), |
45
|
|
|
|
|
|
|
MAP("\11NPUT_LINE_NUMBER", ".", 1), |
46
|
|
|
|
|
|
|
MAP("\11NPUT_RECORD_SEPARATOR", "/", 1), |
47
|
|
|
|
|
|
|
MAP("\22S", "/", 1), |
48
|
|
|
|
|
|
|
MAP("\16R", ".", 1), |
49
|
|
|
|
|
|
|
MAP("\17UTPUT_FIELD_SEPARATOR", ",", 1), |
50
|
|
|
|
|
|
|
MAP("\17FS", ",", 1), |
51
|
|
|
|
|
|
|
MAP("\17UTPUT_RECORD_SEPARATOR", "\\", 1), |
52
|
|
|
|
|
|
|
MAP("\17RS", "\\", 1), |
53
|
|
|
|
|
|
|
MAP("\17UTPUT_AUTOFLUSH", "|", 1), |
54
|
|
|
|
|
|
|
MAP("\17S_ERROR", "!", 1), |
55
|
|
|
|
|
|
|
MAP("\5RRNO", "!", 1), |
56
|
|
|
|
|
|
|
MAP("\5XTENDED_OS_ERROR", "\5", 1), |
57
|
|
|
|
|
|
|
MAP("\5XCEPTIONS_BEING_CAUGHT", "\22", 1), |
58
|
|
|
|
|
|
|
MAP("\27ARNING", "\27", 1), |
59
|
|
|
|
|
|
|
MAP("\5VAL_ERROR", "@", 0), |
60
|
|
|
|
|
|
|
MAP("\3HILD_ERROR", "?", 1), |
61
|
|
|
|
|
|
|
MAP("\3OMPILING", "\3", 1), |
62
|
|
|
|
|
|
|
MAP("\4EBUGGING", "\4", 1), |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
33326
|
|
|
|
|
|
static I32 hash_name_filter(pTHX_ IV action, SV* value) { |
66
|
33326
|
|
|
|
|
|
MAGIC* magic = mg_find(value, PERL_MAGIC_uvar); |
67
|
|
|
|
|
|
|
STRLEN len; |
68
|
33326
|
50
|
|
|
|
|
const char* name = SvPV(magic->mg_obj, len); |
69
|
33326
|
100
|
|
|
|
|
if (name[0] <= 26) { |
70
|
|
|
|
|
|
|
size_t i; |
71
|
7551
|
100
|
|
|
|
|
for (i = 0; i < sizeof aliases / sizeof *aliases; ++i) { |
72
|
7425
|
100
|
|
|
|
|
if (aliases[i].key.length == len && strEQ(aliases[i].key.pointer, name)) { |
|
|
100
|
|
|
|
|
|
73
|
54
|
100
|
|
|
|
|
if (aliases[i].autovivify && !hv_exists_no_uvar(PL_defstash, aliases[i].key.pointer, aliases[i].key.length)) |
|
|
50
|
|
|
|
|
|
74
|
52
|
|
|
|
|
|
gv_fetchpvn(aliases[i].value.pointer, aliases[i].value.length, GV_ADD, SVt_PV); |
75
|
54
|
|
|
|
|
|
magic->mg_obj = newSVpvn(aliases[i].value.pointer, aliases[i].value.length); |
76
|
54
|
|
|
|
|
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
return 0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
static const struct ufuncs hash_filter = { hash_name_filter, NULL, 0 }; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
MODULE = English::Name PACKAGE = English::Name |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
PROTOTYPES: DISABLED |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
BOOT: |
90
|
1
|
|
|
|
|
|
sv_magic((SV*)PL_defstash, NULL, PERL_MAGIC_uvar, (const char*)&hash_filter, sizeof hash_filter); |