From b1dcd16e660f8c613a78cda5ec9fc6312b0b87c1 Mon Sep 17 00:00:00 2001 From: redpony Date: Tue, 29 Jun 2010 18:09:34 +0000 Subject: bug fix git-svn-id: https://ws10smt.googlecode.com/svn/trunk@65 ec762483-ff6d-05da-a07a-a48fb63a330f --- extools/sentence_pair.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/extools/sentence_pair.cc b/extools/sentence_pair.cc index 5706398f..02df3349 100644 --- a/extools/sentence_pair.cc +++ b/extools/sentence_pair.cc @@ -51,14 +51,15 @@ int AnnotatedParallelSentence::ReadAlignmentPoint(const char* buf, short* a, short* b) { if (end - start < 3) { - cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl; abort(); + cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl; + exit(1); } int c = start; *a = 0; while(c < end && buf[c] != '-') { if (buf[c] < '0' || buf[c] > '9') { - cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl; - abort(); + cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl; + exit(1); } (*a) *= 10; (*a) += buf[c] - '0'; @@ -66,13 +67,14 @@ int AnnotatedParallelSentence::ReadAlignmentPoint(const char* buf, } ++c; if (c >= end) { - cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl; abort(); + cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl; + exit(1); } (*b) = 0; while(c < end && (!permit_col || (permit_col && buf[c] != ':'))) { if (buf[c] < '0' || buf[c] > '9') { - cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl; - abort(); + cerr << "Alignment point badly formed: " << string(buf, start, end-start) << endl << buf << endl; + exit(1); } (*b) *= 10; (*b) += buf[c] - '0'; @@ -99,7 +101,12 @@ void AnnotatedParallelSentence::ParseSpanLabel(const char* buf, int start, int e short a,b; int c = ReadAlignmentPoint(buf, start, end, true, &a, &b) + 1; if (buf[c-1] != ':' || c >= end) { - cerr << "Span badly formed: " << string(buf, start, end-start) << endl; abort(); + cerr << "Span badly formed: " << string(buf, start, end-start) << endl << buf << endl; + exit(1); + } + if (a >= e_len || b > e_len) { + cerr << "(" << a << ',' << b << ") is out of bounds in labeled span. INPUT=\n" << buf << endl; + exit(1); } // cerr << a << " " << b << " " << string(buf,c,end-c) << endl; span_types(a,b).push_back(-TD::Convert(string(buf, c, end-c))); -- cgit v1.2.3