From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rupert Swarbrick Newsgroups: gmane.emacs.bugs Subject: bug#19254: 25.0.50; Special characters not stripped on C/C++ header auto-insert Date: Tue, 2 Dec 2014 15:23:37 +0000 Message-ID: <889h9xeulc6.fsf@xl-cam-21.cam.broadcom.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417533933 20499 80.91.229.3 (2 Dec 2014 15:25:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Dec 2014 15:25:33 +0000 (UTC) To: 19254@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 02 16:25:25 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XvpKP-0005g2-EU for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Dec 2014 16:25:25 +0100 Original-Received: from localhost ([::1]:37393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvpKP-000676-12 for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Dec 2014 10:25:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvpKC-00066n-Ep for bug-gnu-emacs@gnu.org; Tue, 02 Dec 2014 10:25:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvpK3-0001l9-CO for bug-gnu-emacs@gnu.org; Tue, 02 Dec 2014 10:25:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvpK3-0001kc-9W for bug-gnu-emacs@gnu.org; Tue, 02 Dec 2014 10:25:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XvpK2-0004TD-MX for bug-gnu-emacs@gnu.org; Tue, 02 Dec 2014 10:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Rupert Swarbrick Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Dec 2014 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19254 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Original-Received: via spool by submit@debbugs.gnu.org id=B.141753384617106 (code B ref -1); Tue, 02 Dec 2014 15:25:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Dec 2014 15:24:06 +0000 Original-Received: from localhost ([127.0.0.1]:51901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XvpJ7-0004Rq-U4 for submit@debbugs.gnu.org; Tue, 02 Dec 2014 10:24:06 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44610) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XvpJ5-0004Rf-Ge for submit@debbugs.gnu.org; Tue, 02 Dec 2014 10:24:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvpIw-0001OP-9m for submit@debbugs.gnu.org; Tue, 02 Dec 2014 10:24:03 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:59018) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvpIw-0001OL-7U for submit@debbugs.gnu.org; Tue, 02 Dec 2014 10:23:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvpIq-0005sq-2T for bug-gnu-emacs@gnu.org; Tue, 02 Dec 2014 10:23:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvpIj-0001Lu-Uh for bug-gnu-emacs@gnu.org; Tue, 02 Dec 2014 10:23:48 -0500 Original-Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:7646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvpIj-0001LR-Oa for bug-gnu-emacs@gnu.org; Tue, 02 Dec 2014 10:23:41 -0500 X-IronPort-AV: E=Sophos;i="5.07,501,1413270000"; d="scan'208";a="52234220" Original-Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 02 Dec 2014 09:08:32 -0800 Original-Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 2 Dec 2014 07:23:31 -0800 Original-Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Tue, 2 Dec 2014 07:23:49 -0800 Original-Received: from xl-cam-21.broadcom.com (xl-cam-21.cam.broadcom.com [10.177.132.81]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 933BE40FEA for ; Tue, 2 Dec 2014 07:23:07 -0800 (PST) Original-Received: by xl-cam-21.broadcom.com (Postfix, from userid 35990) id B8FF140061E; Tue, 2 Dec 2014 15:23:37 +0000 (GMT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:96805 Archived-At: The default value of auto-insert-alist is rather unhelpful if you have a C/C++ header file called something like foo-bar.h because the generated header guard looks something like #ifndef FOO-BAR_H #define FOO-BAR_H #endif The hyphen is a break in the CPP identifier, which makes the header guard not work (GCC, at least, ignores everything past FOO and spits out a warning). I think that something like the following replacement is probably better: '(("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header") (replace-regexp-in-string "[^A-Z0-9]" "_" (upcase (file-name-nondirectory buffer-file-name)) t t) "#ifndef " str \n "#define " str "\n\n" _ "\n\n#endif") This is basically the same as the definition in Emacs master at the moment, but doesn't explicitly split basename from extension and instead replaces non-alphanumeric characters with underscores. Could the default be changed to this or something like it? Rupert PS: I'm not including defaults of the build configuration because they're pretty irrelevant in this case. I've got a snapshot build from master last week and the default auto-insert-alist was last changed in 2012. PPS: If anyone else has been irritated by this, here's a workaround until there's a fix in master which makes it to your distribution's packages: (defvar rjs-c-hdr-replacement '(("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header") (replace-regexp-in-string "[^A-Z0-9]" "_" (upcase (file-name-nondirectory buffer-file-name)) t t) "#ifndef " str \n "#define " str "\n\n" _ "\n\n#endif")) (unless (member rjs-c-hdr-replacement auto-insert-alist) (setq auto-insert-alist (cons rjs-c-hdr-replacement auto-insert-alist)))