Bug 143090

Summary: [PATCH] Let indent(1) handle widecharacter literals correctly
Product: Base System Reporter: Tobias Rehbein <tobias.rehbein>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: pfg, pstef
Priority: Normal    
Version: 8.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
indent.diff
none
Fix for current none

Description Tobias Rehbein 2010-01-22 18:40:02 UTC
        I noticed that indent(1) handles widecharacter literals (e.g. L'c' or
        L"string") incorrectly. indent(1)s parser treats the L-prefix and the
        quoted part as seperate tokens. The result is:

                L'c'            ->      L 'c'
                L"string"       ->      L "string"

        Of course this breaks any code using widecharacters. As I use indent(1)
        quite extensively I decided to fix this issue. 
        
        As this is my first patch against the FreeBSD user land feel free to
        comment!

        The first version of this patch including examples was posted to
        freebsd-current@freebsd.org:

        http://archive.netbsd.se/?ml=freebsd-current&a=2010-01&m=12274166

How-To-Repeat:         indent /usr/src/lib/libc/string/wcsxfrm.c
Comment 1 Pedro F. Giffuni freebsd_committer freebsd_triage 2016-08-07 18:09:18 UTC
Created attachment 173382 [details]
Fix for current

Fix by Piotr Stephaniak:

"The patch from bugzilla is not enough, with that as-is, indent 
would be able to break valid code as pointed out by Peter Jeremy in 
https://lists.freebsd.org/pipermail/freebsd-hackers/2008-April/024336.html "
Comment 2 Pedro F. Giffuni freebsd_committer freebsd_triage 2016-08-07 18:11:13 UTC
(In reply to Pedro F. Giffuni from comment #1)
Nevermind the commnet: it corresponds to another bug.

The new patch should be good though.
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-11-27 20:38:42 UTC
A commit references this bug:

Author: pfg
Date: Sun Nov 27 20:38:15 UTC 2016
New revision: 309220
URL: https://svnweb.freebsd.org/changeset/base/309220

Log:
  indent(1): Properly handle the wide string literal and wide char constant L.

  indent(1) treated the "L" in "L'a'" as if it were an identifier and forced
  a space character after it, breaking valid code.

  PR:		143090
  MFC after:	2 weeks

Changes:
  head/usr.bin/indent/indent.c
  head/usr.bin/indent/indent_codes.h
  head/usr.bin/indent/lexi.c
Comment 4 Piotr Pawel Stefaniak freebsd_committer freebsd_triage 2017-08-26 09:21:20 UTC
Fixed by r309220.
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-03-08 06:55:15 UTC
A commit references this bug:

Author: eadler
Date: Thu Mar  8 06:54:33 UTC 2018
New revision: 330633
URL: https://svnweb.freebsd.org/changeset/base/330633

Log:
  MFC r309220:

  indent(1): Properly handle the wide string literal and wide char constant L.

  indent(1) treated the "L" in "L'a'" as if it were an identifier and forced
  a space character after it, breaking valid code.

  PR:		143090

Changes:
_U  stable/11/
  stable/11/usr.bin/indent/indent.c
  stable/11/usr.bin/indent/indent_codes.h
  stable/11/usr.bin/indent/lexi.c