From nobody@FreeBSD.org  Sat Jan 30 09:17:10 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7B328106568D
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Jan 2010 09:17:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 6AF248FC1B
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Jan 2010 09:17:10 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0U9HAu0093871
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Jan 2010 09:17:10 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0U9HAlP093870;
	Sat, 30 Jan 2010 09:17:10 GMT
	(envelope-from nobody)
Message-Id: <201001300917.o0U9HAlP093870@www.freebsd.org>
Date: Sat, 30 Jan 2010 09:17:10 GMT
From: Mikolaj Golub <to.my.trociny@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] incorrect handling of \ at the end of line in awk(1)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143363
>Category:       bin
>Synopsis:       [patch] incorrect handling of \ at the end of line in awk(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 30 09:20:00 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Mikolaj Golub
>Release:        FreeBSD zhuzha.ua1 8.0-STABLE FreeBSD 8.0-STABLE #6: Sun Jan 24 21:36:17 EET 2010     root@zhuzha.ua1:/usr/obj/usr/src/sys/GENERIC  i386
>Organization:
>Environment:
>Description:
awk(1) handles incorrectly \ at the end of line (inserts additional empty line).

This problem with awk(1) was reported to NetBSD by Aleksey Cheusov and it was fixed there.

http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=37212

FreeBSD version still has this bug.
>How-To-Repeat:
Run the following script. awk(1) inserts an empty line after each useful line.

 
 #!/usr/bin/awk -f

 
 function usage (){
 	print "usage: program_name [OPTION] [files...]\n\
 OPTIONS:\n\
  -h|--help       display this screen\n\
  -V|--version    version\n\
 " 
 	exit 0
 }

 
 BEGIN {
 	usage()
 }
>Fix:
See the attached patch adopted from NetBSD.

Patch attached with submission follows:

--- contrib/one-true-awk.orig/lex.c	2007-06-05 18:33:51.000000000 +0300
+++ contrib/one-true-awk/lex.c	2010-01-30 10:58:42.000000000 +0200
@@ -378,6 +378,7 @@
 		case '\\':
 			c = input();
 			switch (c) {
+			case '\n': break;
 			case '"': *bp++ = '"'; break;
 			case 'n': *bp++ = '\n'; break;	
 			case 't': *bp++ = '\t'; break;


>Release-Note:
>Audit-Trail:
>Unformatted:
