summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfm-x/pst_obj.c
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2015-08-13 10:59:03 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2015-08-13 10:59:03 +0000
commit2d4a7ddf09618de3129cecb386faa05eab3a551f (patch)
tree0af27e2b5a5ff6d8bbd8373ca805700d5cab043c /Build/source/texk/dvipdfm-x/pst_obj.c
parente99c0ea4de186714209c6be95394fe48a720567f (diff)
texk/dvipdfm-x: More static functions
git-svn-id: svn://tug.org/texlive/trunk@38112 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfm-x/pst_obj.c')
-rw-r--r--Build/source/texk/dvipdfm-x/pst_obj.c93
1 files changed, 91 insertions, 2 deletions
diff --git a/Build/source/texk/dvipdfm-x/pst_obj.c b/Build/source/texk/dvipdfm-x/pst_obj.c
index e082e8b3b16..f5769256590 100644
--- a/Build/source/texk/dvipdfm-x/pst_obj.c
+++ b/Build/source/texk/dvipdfm-x/pst_obj.c
@@ -597,7 +597,7 @@ pst_name_release (pst_name *obj)
}
#if 0
-int
+static int
pst_name_is_valid (const char *name)
{
static const char *valid_chars =
@@ -608,7 +608,19 @@ pst_name_is_valid (const char *name)
return 0;
}
-char *
+static int
+putxpair (unsigned char c, char **s)
+{
+ char hi = (c >> 4), lo = c & 0x0f;
+
+ **s = (hi < 10) ? hi + '0' : hi + '7';
+ *(*s+1) = (lo < 10) ? lo + '0' : lo + '7';
+ *s += 2;
+
+ return 2;
+}
+
+static char *
pst_name_encode (const char *name)
{
char *encoded_name, *p;
@@ -638,6 +650,21 @@ pst_name_encode (const char *name)
}
#endif
+static int
+getxpair (unsigned char **s)
+{
+ int hi, lo;
+ hi = xtoi(**s);
+ if (hi < 0)
+ return hi;
+ (*s)++;
+ lo = xtoi(**s);
+ if (lo < 0)
+ return lo;
+ (*s)++;
+ return ((hi << 4)| lo);
+}
+
pst_obj *
pst_parse_name (unsigned char **inbuf, unsigned char *inbufend) /* / is required */
{
@@ -760,6 +787,68 @@ pst_parse_string (unsigned char **inbuf, unsigned char *inbufend)
return NULL;
}
+/* Overflowed value is set to invalid char. */
+static unsigned char
+ostrtouc (unsigned char **inbuf, unsigned char *inbufend, unsigned char *valid)
+{
+ unsigned char *cur = *inbuf;
+ unsigned int val = 0;
+
+ while (cur < inbufend && cur < *inbuf + 3 &&
+ (*cur >= '0' && *cur <= '7')) {
+ val = (val << 3) | (*cur - '0');
+ cur++;
+ }
+ if (val > 255 || cur == *inbuf)
+ *valid = 0;
+ else
+ *valid = 1;
+
+ *inbuf = cur;
+ return (unsigned char) val;
+}
+
+static unsigned char
+esctouc (unsigned char **inbuf, unsigned char *inbufend, unsigned char *valid)
+{
+ unsigned char unescaped, escaped;
+
+ escaped = **inbuf;
+ *valid = 1;
+ switch (escaped) {
+ /* Backslash, unbalanced paranthes */
+ case '\\': case ')': case '(':
+ unescaped = escaped;
+ (*inbuf)++;
+ break;
+ /* Other escaped char */
+ case 'n': unescaped = '\n'; (*inbuf)++; break;
+ case 'r': unescaped = '\r'; (*inbuf)++; break;
+ case 't': unescaped = '\t'; (*inbuf)++; break;
+ case 'b': unescaped = '\b'; (*inbuf)++; break;
+ case 'f': unescaped = '\f'; (*inbuf)++; break;
+ /*
+ * An end-of-line marker preceeded by backslash is not part of a
+ * literal string
+ */
+ case '\r':
+ unescaped = 0;
+ *valid = 0;
+ *inbuf += (*inbuf < inbufend - 1 && *(*inbuf+1) == '\n') ? 2 : 1;
+ break;
+ case '\n':
+ unescaped = 0;
+ *valid = 0;
+ (*inbuf)++;
+ break;
+ /* Possibly octal notion */
+ default:
+ unescaped = ostrtouc(inbuf, inbufend, valid);
+ }
+
+ return unescaped;
+}
+
static pst_string *
pst_string_parse_literal (unsigned char **inbuf, unsigned char *inbufend)
{