summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mpi/ec.c6
-rw-r--r--src/misc.c33
2 files changed, 35 insertions, 4 deletions
diff --git a/mpi/ec.c b/mpi/ec.c
index c6d0fc8c..de681a10 100644
--- a/mpi/ec.c
+++ b/mpi/ec.c
@@ -42,6 +42,12 @@ _gcry_mpi_point_log (const char *name, mpi_point_t point, mpi_ec_t ctx)
gcry_mpi_t x, y;
char buf[100];
+ if (!point)
+ {
+ snprintf (buf, sizeof buf - 1, "%s.*", name);
+ log_mpidump (buf, NULL);
+ return;
+ }
snprintf (buf, sizeof buf - 1, "%s.X", name);
if (ctx)
diff --git a/src/misc.c b/src/misc.c
index d9b85cb1..d577b244 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -361,6 +361,22 @@ _gcry_log_printmpi (const char *text, gcry_mpi_t mpi)
}
}
+
+static int
+count_closing_parens (const char *p)
+{
+ int count = 0;
+
+ for (; *p; p++)
+ if (*p == ')')
+ count++;
+ else if (!strchr ("\n \t", *p))
+ return 0;
+
+ return count;
+}
+
+
/* Print SEXP in human readabale format. With TEXT of NULL print just the raw
dump without any wrappping, with TEXT an empty string, print a
trailing linefeed, otherwise print the full debug output. */
@@ -371,7 +387,7 @@ _gcry_log_printsxp (const char *text, gcry_sexp_t sexp)
if (text && *text)
{
- if ((with_lf = strchr (text, '\n')))
+ if ((with_lf = !!strchr (text, '\n')))
log_debug ("%s", text);
else
log_debug ("%s: ", text);
@@ -379,6 +395,7 @@ _gcry_log_printsxp (const char *text, gcry_sexp_t sexp)
if (sexp)
{
int any = 0;
+ int n_closing;
char *buf, *p, *pend;
size_t size;
@@ -395,18 +412,26 @@ _gcry_log_printsxp (const char *text, gcry_sexp_t sexp)
pend = strchr (p, '\n');
size = pend? (pend - p) : strlen (p);
if (with_lf)
- log_debug ("%.*s\n", (int)size, p);
+ log_debug ("%.*s", (int)size, p);
else
- log_printf ("%.*s\n", (int)size, p);
+ log_printf ("%.*s", (int)size, p);
if (pend)
p = pend + 1;
else
p += size;
+ n_closing = count_closing_parens (p);
+ if (n_closing)
+ {
+ while (n_closing--)
+ log_printf (")");
+ p = "";
+ }
+ log_printf ("\n");
}
while (*p);
gcry_free (buf);
}
- if (text)
+ else if (text)
log_printf ("\n");
}