diff options
author | Karl Williamson <khw@cpan.org> | 2020-01-16 16:09:39 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-01-23 15:46:56 -0700 |
commit | 5e6ebb121e85847e480061b087a1c6fe206e6c3a (patch) | |
tree | d1969c0e839254b5592520aada53ee7746ea3f5c /util.c | |
parent | 6bbb95d461386ba11dd9774938f86c634974ae58 (diff) | |
download | perl-5e6ebb121e85847e480061b087a1c6fe206e6c3a.tar.gz |
Move cntrl_to_mnemonic() to util.c from regcomp.c
This is in preparation for it being used elsewhere, to reduce
duplication of code.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -1035,6 +1035,26 @@ Perl_fbm_instr(pTHX_ unsigned char *big, unsigned char *bigend, SV *littlestr, U } } +const char * +Perl_cntrl_to_mnemonic(const U8 c) +{ + /* Returns the mnemonic string that represents character 'c', if one + * exists; NULL otherwise. The only ones that exist for the purposes of + * this routine are a few control characters */ + + switch (c) { + case '\a': return "\\a"; + case '\b': return "\\b"; + case ESC_NATIVE: return "\\e"; + case '\f': return "\\f"; + case '\n': return "\\n"; + case '\r': return "\\r"; + case '\t': return "\\t"; + } + + return NULL; +} + /* copy a string to a safe spot */ /* |