Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Dec 2018 17:10:07 +0000 (UTC)
From:      Yuri Pankov <yuripv@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r341596 - stable/12/usr.bin/localedef
Message-ID:  <201812051710.wB5HA7IZ089094@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yuripv
Date: Wed Dec  5 17:10:06 2018
New Revision: 341596
URL: https://svnweb.freebsd.org/changeset/base/341596

Log:
  MFC r339827:
  localedef: define characters in "space" class also as "print", except
  for the known conflicts ("control" characters can't be "print"able).
  POSIX doesn't explicitly forbid this, and actually includes <space>
  character in "print".
  
  PR:		225692
  Reviewed by:	bapt, cem (previous version), pfg (previous version)
  Differential Revision:	https://reviews.freebsd.org/D17467

Modified:
  stable/12/usr.bin/localedef/ctype.c

Modified: stable/12/usr.bin/localedef/ctype.c
==============================================================================
--- stable/12/usr.bin/localedef/ctype.c	Wed Dec  5 17:06:00 2018	(r341595)
+++ stable/12/usr.bin/localedef/ctype.c	Wed Dec  5 17:10:06 2018	(r341596)
@@ -120,7 +120,13 @@ add_ctype_impl(ctype_node_t *ctn)
 		ctn->ctype |= (_ISDIGIT | _ISGRAPH | _ISPRINT | _ISXDIGIT | _E4);
 		break;
 	case T_ISSPACE:
-		ctn->ctype |= _ISSPACE;
+		/*
+		 * This can be troublesome as <form-feed>, <newline>,
+		 * <carriage-return>, <tab>, and <vertical-tab> are defined both
+		 * as space and cntrl, and POSIX doesn't allow cntrl/print
+		 * combination.  We will take care of this in dump_ctype().
+		 */
+		ctn->ctype |= (_ISSPACE | _ISPRINT);
 		break;
 	case T_ISCNTRL:
 		ctn->ctype |= _ISCNTRL;
@@ -378,9 +384,15 @@ dump_ctype(void)
 			ctn->ctype |= _ISPRINT;
 
 		/*
-		 * Finally, POSIX requires that certain combinations
-		 * are invalid.  We don't flag this as a fatal error,
-		 * but we will warn about.
+		 * POSIX requires that certain combinations are invalid.
+		 * Try fixing the cases we know about (see add_ctype_impl()).
+		 */
+		if ((ctn->ctype & (_ISSPACE|_ISCNTRL)) == (_ISSPACE|_ISCNTRL))
+			ctn->ctype &= ~_ISPRINT;
+
+		/*
+		 * Finally, don't flag remaining cases as a fatal error,
+		 * and just warn about them.
 		 */
 		if ((ctn->ctype & _ISALPHA) &&
 		    (ctn->ctype & (_ISPUNCT|_ISDIGIT)))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812051710.wB5HA7IZ089094>