summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-01-16 16:09:39 -0700
committerKarl Williamson <khw@cpan.org>2020-01-23 15:46:56 -0700
commit5e6ebb121e85847e480061b087a1c6fe206e6c3a (patch)
treed1969c0e839254b5592520aada53ee7746ea3f5c /util.c
parent6bbb95d461386ba11dd9774938f86c634974ae58 (diff)
downloadperl-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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/util.c b/util.c
index 88752653c9..f3acdfe862 100644
--- a/util.c
+++ b/util.c
@@ -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 */
/*