File 0001-vcc.y-factor-out-hexdigit-conversion.patch of Package libical.17517

From 6c167138a204cd2e0580036bad32a51dae05c80b Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Mon, 17 Sep 2018 16:47:16 +0200
Subject: [PATCH 1/5] vcc.y - factor out hexdigit conversion
References: https://github.com/libical/libical/pull/354

---
 src/libicalvcal/vcc.c | 17 +++++++++++------
 src/libicalvcal/vcc.y | 17 +++++++++++------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/libicalvcal/vcc.c b/src/libicalvcal/vcc.c
index d47bc099..c2a743c2 100644
--- a/src/libicalvcal/vcc.c
+++ b/src/libicalvcal/vcc.c
@@ -1126,6 +1126,15 @@ static int match_begin_end_name(int end) {
     return 0;
     }
 
+static int hexdigit_decode(char c)
+{
+	if (c >= '0' && c <= '9')
+		return c - '0';
+	if (c >= 'A' && c <= 'F')
+		return c - 'A' + 10;
+	return -1;
+}
+
 static char* lexGetQuotedPrintable()
     {
     char cur;
@@ -1139,12 +1148,8 @@ static char* lexGetQuotedPrintable()
                 int next[2];
                 int i;
                 for (i = 0; i < 2; i++) {
-                    next[i] = lexGetc();
-                    if (next[i] >= '0' && next[i] <= '9')
-                        c = c * 16 + next[i] - '0';
-                    else if (next[i] >= 'A' && next[i] <= 'F')
-                        c = c * 16 + next[i] - 'A' + 10;
-                    else
+                    next[i] = hexdigit_decode(lexGetc());
+                    if (next[i] < 0)
                         break;
                     }
                 if (i == 0) {
diff --git a/src/libicalvcal/vcc.y b/src/libicalvcal/vcc.y
index d97ea83b..45243df6 100644
--- a/src/libicalvcal/vcc.y
+++ b/src/libicalvcal/vcc.y
@@ -947,6 +947,15 @@ static int match_begin_end_name(int end) {
     return 0;
     }
 
+static int hexdigit_decode(char c)
+{
+	if (c >= '0' && c <= '9')
+		return c - '0';
+	if (c >= 'A' && c <= 'F')
+		return c - 'A' + 10;
+	return -1;
+}
+
 static char* lexGetQuotedPrintable()
     {
     char cur;
@@ -960,12 +969,8 @@ static char* lexGetQuotedPrintable()
                 int next[2];
                 int i;
                 for (i = 0; i < 2; i++) {
-                    next[i] = lexGetc();
-                    if (next[i] >= '0' && next[i] <= '9')
-                        c = c * 16 + next[i] - '0';
-                    else if (next[i] >= 'A' && next[i] <= 'F')
-                        c = c * 16 + next[i] - 'A' + 10;
-                    else
+                    next[i] = hexdigit_decode(lexGetc());
+                    if (next[i] < 0)
                         break;
                     }
                 if (i == 0) {
-- 
2.19.1

openSUSE Build Service is sponsored by