aboutsummaryrefslogtreecommitdiffstats
path: root/rcfile_l.l
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-07-04 05:05:23 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-07-04 05:05:23 +0000
commit2afc40a88856ba00c517ca9d58ec834a3492aa91 (patch)
tree91a1adb2293e3468da140cfb2031568eca886928 /rcfile_l.l
parentd2fa025b2f64bd04e19d192051463d336bb8fdd1 (diff)
downloadfetchmail-2afc40a88856ba00c517ca9d58ec834a3492aa91.tar.gz
fetchmail-2afc40a88856ba00c517ca9d58ec834a3492aa91.tar.bz2
fetchmail-2afc40a88856ba00c517ca9d58ec834a3492aa91.zip
Remodularize so the parser is more self-contained.
svn path=/trunk/; revision=1150
Diffstat (limited to 'rcfile_l.l')
-rw-r--r--rcfile_l.l47
1 files changed, 46 insertions, 1 deletions
diff --git a/rcfile_l.l b/rcfile_l.l
index 1b88f36a..f708f157 100644
--- a/rcfile_l.l
+++ b/rcfile_l.l
@@ -115,5 +115,50 @@ remote(folder)? {
[ \t\r]+ ; /* whitespace */
-
+%%
+#include <string.h>
+
+void escapes(cp, tp)
+/* process standard C-style escape sequences in a string */
+const char *cp; /* source string with escapes */
+char *tp; /* target buffer for digested string */
+{
+ while (*cp)
+ {
+ int cval = 0;
+
+ if (*cp == '\\' && strchr("0123456789xX", cp[1]))
+ {
+ char *dp, *hex = "00112233445566778899aAbBcCdDeEfF";
+ int dcount = 0;
+
+ if (*++cp == 'x' || *cp == 'X')
+ for (++cp; (dp = strchr(hex, *cp)) && (dcount++ < 2); cp++)
+ cval = (cval * 16) + (dp - hex) / 2;
+ else if (*cp == '0')
+ while (strchr("01234567",*cp) != (char*)NULL && (dcount++ < 3))
+ cval = (cval * 8) + (*cp++ - '0');
+ else
+ while ((strchr("0123456789",*cp)!=(char*)NULL)&&(dcount++ < 3))
+ cval = (cval * 10) + (*cp++ - '0');
+ }
+ else if (*cp == '\\') /* C-style character escapes */
+ {
+ switch (*++cp)
+ {
+ case '\\': cval = '\\'; break;
+ case 'n': cval = '\n'; break;
+ case 't': cval = '\t'; break;
+ case 'b': cval = '\b'; break;
+ case 'r': cval = '\r'; break;
+ default: cval = *cp;
+ }
+ cp++;
+ }
+ else
+ cval = *cp++;
+ *tp++ = cval;
+ }
+ *tp = '\0';
+}