From a4d2e24f1c9d089dc63f9dc2898edb7d8025ce54 Mon Sep 17 00:00:00 2001 From: malc Date: Mon, 14 Jun 2010 09:03:26 +0400 Subject: [PATCH] Fix two outline related bugs 1. outline->link can apparently be NULL (making_of_sotc.pdf) 2. titles can and do contain all kind of weird and not so weird characters so that scanf barfs on them --- link.c | 8 +++++--- main.ml | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/link.c b/link.c index 28eb060..c8aaa80 100644 --- a/link.c +++ b/link.c @@ -456,6 +456,8 @@ static void recurse_outline (pdf_outline *outline, int level) int top = 0; int pageno = -1; + if (!outline->link) goto next; + obj = outline->link->dest; if (fz_isarray (obj)) { int i; @@ -484,9 +486,9 @@ static void recurse_outline (pdf_outline *outline, int level) } } lprintf ("%*c%s %d\n", level, ' ', outline->title, pageno); - printd (state.sock, "o \"%s\" %d %d %d", - outline->title, level, pageno, top); - + printd (state.sock, "o %d %d %d %s", + level, pageno, top, outline->title); + next: if (outline->child) { recurse_outline (outline->child, level + 1); } diff --git a/main.ml b/main.ml index 75c1993..7f03927 100644 --- a/main.ml +++ b/main.ml @@ -494,9 +494,11 @@ let act cmd = state.pages <- pagelayout :: state.pages | 'o' -> - let (s, l, n, t) as outline = - Scanf.sscanf cmd "o %S %d %d %d" (fun s l n t -> s, l, n, t) + let (l, n, t, pos) = + Scanf.sscanf cmd "o %d %d %d %n" (fun l n t pos -> l, n, t, pos) in + let s = String.sub cmd pos (String.length cmd - pos) in + let outline = (s, l, n, t) in let outlines = match state.outlines with | Olist outlines -> Olist (outline :: outlines) -- 2.11.4.GIT