From jbackus@plex.nl Thu Apr  8 13:33:38 1999
Return-Path: <jbackus@plex.nl>
Received: from gw-nl3.philips.com (gw-nl3.philips.com [192.68.44.35])
	by hub.freebsd.org (Postfix) with ESMTP id 4DA0015076
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  8 Apr 1999 13:33:25 -0700 (PDT)
	(envelope-from jbackus@plex.nl)
Received: from smtprelay-nl1.philips.com (localhost.philips.com [127.0.0.1])
          by gw-nl3.philips.com with ESMTP id WAA27538
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 8 Apr 1999 22:31:24 +0200 (MEST)
          (envelope-from jbackus@plex.nl)
Received: from smtprelay-eur1.philips.com(130.139.36.3) by gw-nl3.philips.com via mwrap (4.0a)
	id xma027536; Thu, 8 Apr 99 22:31:24 +0200
Received: from hal.mpn.cp.philips.com (hal.mpn.cp.philips.com [130.139.64.195]) 
	by smtprelay-nl1.philips.com (8.9.3/8.6.10-1.2.2m-970826) with SMTP id WAA28647
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 8 Apr 1999 22:31:24 +0200 (MET DST)
Received: (qmail 21045 invoked from network); 8 Apr 1999 20:31:45 -0000
Received: from unknown (HELO jos.bugworks.com) (172.16.121.81)
  by hal.mpn.cp.philips.com with SMTP; 8 Apr 1999 20:31:45 -0000
Received: (qmail 4642 invoked by uid 1000); 8 Apr 1999 20:31:09 -0000
Message-Id: <19990408203109.4641.qmail@jos.bugworks.com>
Date: 8 Apr 1999 20:31:09 -0000
From: Jos Backus <jbackus@plex.nl>
Reply-To: Jos Backus <jbackus@plex.nl>
To: FreeBSD-gnats-submit@freebsd.org
Subject: perl's h2ph's processing of cpp #warning/#error directives is broken.
X-Send-Pr-Version: 3.2

>Number:         11032
>Category:       bin
>Synopsis:       h2ph's cpp #warning/#error directive processing is broken
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr  8 13:40:00 PDT 1999
>Closed-Date:    Thu Jul 13 08:02:43 PDT 2000
>Last-Modified:  Thu Jul 13 08:03:25 PDT 2000
>Originator:     Jos Backus
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
BugWorks
>Environment:

-current as of today.

jos% perl -v

This is perl, version 5.005_02 built for i386-freebsd

>Description:

perl barfs when using the debugger because of improper quoting.

/usr/include/sys/ioctl.h contains:

  #warning "Don't #include ioctl.h in the kernel.  Include xxxio.h instead."

/usr/libdata/perl/5.00502/mach/sys/ioctl.ph contains:

  warn(""Don't #include ioctl.h in the kernel.  Include xxxio.h instead.""

Not Good.

>How-To-Repeat:

jos% cat prog
exit 0;
jos% perl -d prog

Loading DB routines from perl5db.pl version 1.0401
Emacs support available.

Enter h or `h h' for help.

Bareword found where operator expected at /usr/libdata/perl/5.00502/mach/sys/ioctl.ph line 4, near """Don't"
	require sys/ioctl.ph called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 328
	eval {...} called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 328
	readline::preinit called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 89
	require Term/ReadLine/readline.pm called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/Perl.pm line 58
	eval {...} called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/Perl.pm line 58
	Term::ReadLine::Perl::new('Term::ReadLine', 'perldb', 'GLOB(0x806b27c)', 'GLOB(0x806b318)') called at /usr/libdata/perl/5.00502/perl5db.pl line 1460
	DB::setterm called at /usr/libdata/perl/5.00502/perl5db.pl line 418
	DB::DB called at prog line 1
	(Missing operator before Don't?)
	require sys/ioctl.ph called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 328
	eval {...} called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 328
	readline::preinit called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/readline.pm line 89
	require Term/ReadLine/readline.pm called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/Perl.pm line 58
	eval {...} called at /usr/local/lib/perl5/site_perl/5.005/Term/ReadLine/Perl.pm line 58
	Term::ReadLine::Perl::new('Term::ReadLine', 'perldb', 'GLOB(0x806b27c)', 'GLOB(0x806b318)') called at /usr/libdata/perl/5.00502/perl5db.pl line 1460
	DB::setterm called at /usr/libdata/perl/5.00502/perl5db.pl line 418
	DB::DB called at prog line 1
main::(prog:1):	exit 0;
 DB<1> q
jos% 

>Fix:
	
Fix h2ph to properly deal with these directives by escaping single quotes and
removing the outermost quotes, if present:

--- /usr/bin/h2ph.orig  Thu Apr  8 22:02:27 1999
+++ /usr/bin/h2ph       Thu Apr  8 22:26:50 1999
@@ -196,10 +196,12 @@
                print OUT $t,"}\n";
            } elsif(/^undef\s+(\w+)/) {
                print OUT $t, "undef(&$1) if defined(&$1);\n";
-           } elsif(/^error\s+(.*)/) {
-               print OUT $t, "die(\"$1\");\n";
-           } elsif(/^warning\s+(.*)/) {
-               print OUT $t, "warn(\"$1\");\n";
+           } elsif(/^error\s+"?(.*)"?$/) {
+               (my $text = $1) =~ s,',\\',g;
+               print OUT $t, "die(\"$text\");\n";
+           } elsif(/^warning\s+"?(.*?)"?$/) {
+               (my $text = $1) =~ s,',\\',g;
+               print OUT $t, "warn(\"$text\");\n";
            } elsif(/^ident\s+(.*)/) {
                print OUT $t, "# $1\n";
            }         

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: nbm 
State-Changed-When: Thu Jul 13 08:02:43 PDT 2000 
State-Changed-Why:  
This seems to have been fixed by 3.3-RELEASE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=11032 
>Unformatted:
