Package: grep-dctrl Version: 2.6.7 Followup-For: Bug #205044
I have also been bitten by the mysterious "Unexpected end of line" error message. I haven't been able to use grep-dctrl for many months because of it, and I finally sat down tonight to figure out why. Turns out there's an invalid entry in my /var/lib/dpkg/{available,status} files, so I can't blame grep-dctrl for barfing. (And I suspect grep-dctrl broke for me the day I installed the package in question. Which, BTW, is Nero, a closed-source commercial program, not part of Debian... so clearly the real blame lies with Nero for distributing a bad .deb file.) However, I *can* blame grep-dctrl for not reporting the exact file and line number where it encountered the problem. So I cooked up a patch. I'll attach two files: the entry from my "available" file that cause grep-dctrl to barf (you can just save this to a file, run grep-dctrl on it, and see the error message), and a patch that makes it report the filename and line number for any syntax errors detected in para_parse_next(). (Incidentally, "dpkg -l" runs just fine on my system despite the apparently-bad "available" file ... so there might be some inconsistency between the parser used by dpkg and that used by grep-dctrl. Hmmm.) -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.14.4-gw1 Locale: LANG=en_CA.utf8, LC_CTYPE=en_CA.utf8 (charmap=UTF-8) Versions of packages grep-dctrl depends on: ii libc6 2.3.5-12.1 GNU C Library: Shared libraries an grep-dctrl recommends no packages. -- no debconf information
Package: nerolinux Maintainer: Nero AG. (http://www.nero.com) Architecture: i386 Version: 2.0.0.2-1 Depends: libc6 (>= 2.2.4-4), libglib1.2 (>= 1.2.0), libgtk1.2 (>= 1.2.10-4), xlibs (>= 4.1.0) Size: 10472864 Description: NeroLINUX CD/DVD burning software Copyright: Nero AG. NeroLINUX uses Nero 6.6's embedded API to bring Nero's powerful CD/DVD-writer functions to the Linux Desktop.
Only in grep-dctrl-2.6.7.hacked: available Only in grep-dctrl-2.6.7.hacked: avail.d Only in grep-dctrl-2.6.7.hacked: dbg Only in grep-dctrl-2.6.7.hacked/debian: stamp Only in grep-dctrl-2.6.7.hacked: fieldtrie.o Only in grep-dctrl-2.6.7.hacked: fnutil.o Only in grep-dctrl-2.6.7.hacked: fsaf.o Only in grep-dctrl-2.6.7.hacked: getaline.o Only in grep-dctrl-2.6.7.hacked: grep-dctrl Only in grep-dctrl-2.6.7.hacked: grep-dctrl.1 diff -ur grep-dctrl-2.6.7.base/grep-dctrl.c grep-dctrl-2.6.7.hacked/grep-dctrl.c --- grep-dctrl-2.6.7.base/grep-dctrl.c 2006-02-12 20:25:15.000000000 -0500 +++ grep-dctrl-2.6.7.hacked/grep-dctrl.c 2006-02-12 20:37:09.000000000 -0500 @@ -859,8 +859,10 @@ if (fname.mode == m_error) break; + debug_message("opening file", fname.s); fd = open_ifile(fname); if (fd == -1) break; + int lineno = 1; { struct stat stat; @@ -889,9 +891,9 @@ FSAF * fp = fsaf_fdopen(fd); para_t para; - for (para_init(¶, fp, &args.p.trie); + for (para_init(¶, fp, &args.p.trie, fname.s, &lineno); !para_eof(¶); - para_parse_next(¶)) { + para_parse_next(¶, fname.s, &lineno)) { if ((args.invert_match || !does_para_satisfy(&args.p, ¶)) && (!args.invert_match || does_para_satisfy(&args.p, ¶))) { continue; Only in grep-dctrl-2.6.7.hacked: grep-dctrl.o Only in grep-dctrl-2.6.7.hacked: misc.o Only in grep-dctrl-2.6.7.hacked: msg.o diff -ur grep-dctrl-2.6.7.base/paragraph.c grep-dctrl-2.6.7.hacked/paragraph.c --- grep-dctrl-2.6.7.base/paragraph.c 2005-06-08 12:31:24.000000000 -0400 +++ grep-dctrl-2.6.7.hacked/paragraph.c 2006-02-12 21:02:28.000000000 -0500 @@ -21,17 +21,17 @@ #include "paragraph.h" #include "strutil.h" -void para_init(para_t * para, FSAF * fp, fieldtrie_t * trie) +void para_init(para_t * para, FSAF * fp, fieldtrie_t * trie, const char * filename, int * lineno) { para->fp = fp; para->trie = trie; para->start = 0; para->end = 0; para->eof = false; - para_parse_next(para); + para_parse_next(para, filename, lineno); } -void para_parse_next(para_t * para) +void para_parse_next(para_t * para, const char * filename, int * lineno) { debug_message("para_parse_next", 0); para->start = para->end; @@ -63,6 +63,7 @@ break; case '\n': para->start++; + (*lineno)++; break; default: field_start = --pos; @@ -72,7 +73,7 @@ case FIELD_NAME: switch (c) { case -1: - message(L_FATAL, _("unexpected end of file"), 0); + line_message(L_FATAL, _("unexpected end of file"), filename, *lineno); fail(); case ':': { size_t len = (pos-1) - field_start; @@ -91,16 +92,18 @@ } break; case '\n': - message(L_FATAL, _("unexpected end of line"), 0); + (*lineno)++; + line_message(L_FATAL, _("unexpected end of line"), filename, *lineno); fail(); } break; case BODY: switch (c) { case -1: - message(L_FATAL, _("unexpected end of file"), 0); + line_message(L_FATAL, _("unexpected end of file"), filename, *lineno); fail(); case '\n': + (*lineno)++; if (field_data != 0) { field_data->end = pos-1; while (field_data->start < field_data->end @@ -118,6 +121,8 @@ //para->eof = true; /* pass through */ case '\n': + /* Don't count this newline: it'll be (re)counted when we enter + START state for next paragraph */ state = END; break; case ' ': case '\t': @@ -133,6 +138,7 @@ case -1: /* pass through */ case '\n': + (*lineno)++; state = END; break; case ' ': case '\t': diff -ur grep-dctrl-2.6.7.base/paragraph.h grep-dctrl-2.6.7.hacked/paragraph.h --- grep-dctrl-2.6.7.base/paragraph.h 2005-06-08 12:31:24.000000000 -0400 +++ grep-dctrl-2.6.7.hacked/paragraph.h 2006-02-12 20:37:14.000000000 -0500 @@ -44,9 +44,9 @@ /* Initialize the given para_t, associating with it the given * FSAF and the field trie. */ -void para_init(para_t *, FSAF *, fieldtrie_t *); +void para_init(para_t *, FSAF *, fieldtrie_t *, const char *, int *); -void para_parse_next(para_t *); +void para_parse_next(para_t *, const char *, int *); static inline bool para_eof(para_t * para) { return para->eof; } Only in grep-dctrl-2.6.7.hacked: paragraph.o Only in grep-dctrl-2.6.7.hacked/po: ca.mo Only in grep-dctrl-2.6.7.hacked/po: de.mo Only in grep-dctrl-2.6.7.hacked/po: fi.mo Only in grep-dctrl-2.6.7.hacked/po: fr.mo Only in grep-dctrl-2.6.7.hacked/po: grep-dctrl.pot Only in grep-dctrl-2.6.7.hacked/po: it.mo Only in grep-dctrl-2.6.7.hacked/po: pt_BR.mo Only in grep-dctrl-2.6.7.hacked: predicate.o Only in grep-dctrl-2.6.7.hacked: rc.o Only in grep-dctrl-2.6.7.hacked: strutil.o Only in grep-dctrl-2.6.7.hacked: sync-available Only in grep-dctrl-2.6.7.hacked: util.o