svn commit: r306416 - stable/9/lib/libc/stdtime

2016-09-28 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep 28 20:54:47 2016
New Revision: 306416
URL: https://svnweb.freebsd.org/changeset/base/306416

Log:
  MFC r306075,r306109
  
  1) Microoptimize %p case.
  2) Implememt %u for GNU compatibility.
  3) Don't forget to advance buf for %w/%u.
  4) Fail with incomplete week (week 0) request and no such week in the
  year.
  5) Fix yday formula when Sunday requested and the week started from Monday.
  6) Fail with impossible yday for incomplete week (week 0) and direct %w/%u
  request.
  7) Shift yday/wday to the first day of the year, if incomplete week
  (week 0) requested and no %w/%u used.
  8) For already non-standard %z extension implement GNU compatible formats:
  +hh and -hh.
  9) Check for incorrect values for %z.
  
  PR: 212983 (case 3 only)

Modified:
  stable/9/lib/libc/stdtime/strptime.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/lib/   (props changed)
  stable/9/lib/libc/   (props changed)
  stable/9/lib/libc/stdtime/   (props changed)

Modified: stable/9/lib/libc/stdtime/strptime.c
==
--- stable/9/lib/libc/stdtime/strptime.cWed Sep 28 20:52:58 2016
(r306415)
+++ stable/9/lib/libc/stdtime/strptime.cWed Sep 28 20:54:47 2016
(r306416)
@@ -301,10 +301,11 @@ label:
 * XXX This is bogus if parsed before hour-related
 * specifiers.
 */
+   if (tm->tm_hour > 12)
+   return (NULL);
+
len = strlen(tptr->am);
if (strncasecmp_l(buf, tptr->am, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour == 12)
tm->tm_hour = 0;
buf += len;
@@ -313,8 +314,6 @@ label:
 
len = strlen(tptr->pm);
if (strncasecmp_l(buf, tptr->pm, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour != 12)
tm->tm_hour += 12;
buf += len;
@@ -374,15 +373,17 @@ label:
 
break;
 
+   case 'u':
case 'w':
if (!isdigit_l((unsigned char)*buf, locale))
return (NULL);
 
-   i = *buf - '0';
-   if (i > 6)
+   i = *buf++ - '0';
+   if (i < 0 || i > 7 || (c == 'u' && i < 1) ||
+   (c == 'w' && i > 6))
return (NULL);
 
-   tm->tm_wday = i;
+   tm->tm_wday = i % 7;
flags |= FLAG_WDAY;
 
break;
@@ -581,10 +582,16 @@ label:
i *= 10;
i += *buf - '0';
buf++;
+   } else if (len == 2) {
+   i *= 100;
+   break;
} else
return (NULL);
}
 
+   if (i > 1400 || (sign == -1 && i > 1200) ||
+   (i % 100) >= 60)
+   return (NULL);
tm->tm_hour -= sign * (i / 100);
tm->tm_min  -= sign * (i % 100);
*GMTp = 1;
@@ -609,17 +616,28 @@ label:
TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1);
flags |= FLAG_YDAY;
} else if (day_offset != -1) {
+   int tmpwday, tmpyday, fwo;
+
+   fwo = first_wday_of(tm->tm_year + TM_YEAR_BASE);
+   /* No incomplete week (week 0). */
+   if (week_offset == 0 && fwo == day_offset)
+   return (NULL);
+
/* Set the date to the first Sunday (or Monday)
 * of the specified week of the year.
 */
-   if (!(flags & FLAG_WDAY)) {
-   tm->tm_wday = day_offset;
-   flags |= FLAG_WDAY;
-   }
-   tm->tm_yday = (7 -
-   first_wday_of(tm->tm_year + TM_YEAR_BASE) +
-   day_offset) % 7 + (week_offset - 1) * 7 +
-   tm->tm_wday - day_offset;
+   tmpwday = (flags & FLAG_WDAY) ? tm->tm_wday :
+ 

svn commit: r306415 - stable/11/lib/libc/stdtime

2016-09-28 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep 28 20:52:58 2016
New Revision: 306415
URL: https://svnweb.freebsd.org/changeset/base/306415

Log:
  MFC r306075,r306109
  
  1) Microoptimize %p case.
  2) Implememt %u for GNU compatibility.
  3) Don't forget to advance buf for %w/%u.
  4) Fail with incomplete week (week 0) request and no such week in the
  year.
  5) Fix yday formula when Sunday requested and the week started from Monday.
  6) Fail with impossible yday for incomplete week (week 0) and direct %w/%u
  request.
  7) Shift yday/wday to the first day of the year, if incomplete week
  (week 0) requested and no %w/%u used.
  8) For already non-standard %z extension implement GNU compatible formats:
  +hh and -hh.
  9) Check for incorrect values for %z.
  
  PR: 212983 (case 3 only)

Modified:
  stable/11/lib/libc/stdtime/strptime.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdtime/strptime.c
==
--- stable/11/lib/libc/stdtime/strptime.c   Wed Sep 28 20:49:33 2016
(r306414)
+++ stable/11/lib/libc/stdtime/strptime.c   Wed Sep 28 20:52:58 2016
(r306415)
@@ -301,10 +301,11 @@ label:
 * XXX This is bogus if parsed before hour-related
 * specifiers.
 */
+   if (tm->tm_hour > 12)
+   return (NULL);
+
len = strlen(tptr->am);
if (strncasecmp_l(buf, tptr->am, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour == 12)
tm->tm_hour = 0;
buf += len;
@@ -313,8 +314,6 @@ label:
 
len = strlen(tptr->pm);
if (strncasecmp_l(buf, tptr->pm, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour != 12)
tm->tm_hour += 12;
buf += len;
@@ -374,15 +373,17 @@ label:
 
break;
 
+   case 'u':
case 'w':
if (!isdigit_l((unsigned char)*buf, locale))
return (NULL);
 
-   i = *buf - '0';
-   if (i > 6)
+   i = *buf++ - '0';
+   if (i < 0 || i > 7 || (c == 'u' && i < 1) ||
+   (c == 'w' && i > 6))
return (NULL);
 
-   tm->tm_wday = i;
+   tm->tm_wday = i % 7;
flags |= FLAG_WDAY;
 
break;
@@ -581,10 +582,16 @@ label:
i *= 10;
i += *buf - '0';
buf++;
+   } else if (len == 2) {
+   i *= 100;
+   break;
} else
return (NULL);
}
 
+   if (i > 1400 || (sign == -1 && i > 1200) ||
+   (i % 100) >= 60)
+   return (NULL);
tm->tm_hour -= sign * (i / 100);
tm->tm_min  -= sign * (i % 100);
*GMTp = 1;
@@ -609,17 +616,28 @@ label:
TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1);
flags |= FLAG_YDAY;
} else if (day_offset != -1) {
+   int tmpwday, tmpyday, fwo;
+
+   fwo = first_wday_of(tm->tm_year + TM_YEAR_BASE);
+   /* No incomplete week (week 0). */
+   if (week_offset == 0 && fwo == day_offset)
+   return (NULL);
+
/* Set the date to the first Sunday (or Monday)
 * of the specified week of the year.
 */
-   if (!(flags & FLAG_WDAY)) {
-   tm->tm_wday = day_offset;
-   flags |= FLAG_WDAY;
-   }
-   tm->tm_yday = (7 -
-   first_wday_of(tm->tm_year + TM_YEAR_BASE) +
-   day_offset) % 7 + (week_offset - 1) * 7 +
-   tm->tm_wday - day_offset;
+   tmpwday = (flags & FLAG_WDAY) ? tm->tm_wday :
+   day_offset;
+   tmpyday = (7 - fwo + day_offset) % 7 +
+   

svn commit: r306414 - stable/10/lib/libc/stdtime

2016-09-28 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep 28 20:49:33 2016
New Revision: 306414
URL: https://svnweb.freebsd.org/changeset/base/306414

Log:
  MFC r306075,r306109
  
  1) Microoptimize %p case.
  2) Implememt %u for GNU compatibility.
  3) Don't forget to advance buf for %w/%u.
  4) Fail with incomplete week (week 0) request and no such week in the
  year.
  5) Fix yday formula when Sunday requested and the week started from Monday.
  6) Fail with impossible yday for incomplete week (week 0) and direct %w/%u
  request.
  7) Shift yday/wday to the first day of the year, if incomplete week
  (week 0) requested and no %w/%u used.
  8) For already non-standard %z extension implement GNU compatible formats:
  +hh and -hh.
  9) Check for incorrect values for %z.
  
  PR: 212983 (case 3 only)

Modified:
  stable/10/lib/libc/stdtime/strptime.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdtime/strptime.c
==
--- stable/10/lib/libc/stdtime/strptime.c   Wed Sep 28 19:35:59 2016
(r306413)
+++ stable/10/lib/libc/stdtime/strptime.c   Wed Sep 28 20:49:33 2016
(r306414)
@@ -301,10 +301,11 @@ label:
 * XXX This is bogus if parsed before hour-related
 * specifiers.
 */
+   if (tm->tm_hour > 12)
+   return (NULL);
+
len = strlen(tptr->am);
if (strncasecmp_l(buf, tptr->am, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour == 12)
tm->tm_hour = 0;
buf += len;
@@ -313,8 +314,6 @@ label:
 
len = strlen(tptr->pm);
if (strncasecmp_l(buf, tptr->pm, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour != 12)
tm->tm_hour += 12;
buf += len;
@@ -374,15 +373,17 @@ label:
 
break;
 
+   case 'u':
case 'w':
if (!isdigit_l((unsigned char)*buf, locale))
return (NULL);
 
-   i = *buf - '0';
-   if (i > 6)
+   i = *buf++ - '0';
+   if (i < 0 || i > 7 || (c == 'u' && i < 1) ||
+   (c == 'w' && i > 6))
return (NULL);
 
-   tm->tm_wday = i;
+   tm->tm_wday = i % 7;
flags |= FLAG_WDAY;
 
break;
@@ -581,10 +582,16 @@ label:
i *= 10;
i += *buf - '0';
buf++;
+   } else if (len == 2) {
+   i *= 100;
+   break;
} else
return (NULL);
}
 
+   if (i > 1400 || (sign == -1 && i > 1200) ||
+   (i % 100) >= 60)
+   return (NULL);
tm->tm_hour -= sign * (i / 100);
tm->tm_min  -= sign * (i % 100);
*GMTp = 1;
@@ -609,17 +616,28 @@ label:
TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1);
flags |= FLAG_YDAY;
} else if (day_offset != -1) {
+   int tmpwday, tmpyday, fwo;
+
+   fwo = first_wday_of(tm->tm_year + TM_YEAR_BASE);
+   /* No incomplete week (week 0). */
+   if (week_offset == 0 && fwo == day_offset)
+   return (NULL);
+
/* Set the date to the first Sunday (or Monday)
 * of the specified week of the year.
 */
-   if (!(flags & FLAG_WDAY)) {
-   tm->tm_wday = day_offset;
-   flags |= FLAG_WDAY;
-   }
-   tm->tm_yday = (7 -
-   first_wday_of(tm->tm_year + TM_YEAR_BASE) +
-   day_offset) % 7 + (week_offset - 1) * 7 +
-   tm->tm_wday - day_offset;
+   tmpwday = (flags & FLAG_WDAY) ? tm->tm_wday :
+   day_offset;
+   tmpyday = (7 - fwo + day_offset) % 7 +
+   

svn commit: r306326 - stable/9/lib/libc/stdtime

2016-09-25 Thread Andrey A. Chernov
Author: ache
Date: Sun Sep 25 23:05:44 2016
New Revision: 306326
URL: https://svnweb.freebsd.org/changeset/base/306326

Log:
  MFC r272562,r272678,r272679
  
  1) Fix the case we have less arguments for format string than we expected.
  2) Return error on unsupported format specs.
  (both according to POSIX)
  3) For %Z format, understand "UTC" name too.
  
  PR: 93197 (only r272679)

Modified:
  stable/9/lib/libc/stdtime/strptime.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/lib/   (props changed)
  stable/9/lib/libc/   (props changed)
  stable/9/lib/libc/stdtime/   (props changed)

Modified: stable/9/lib/libc/stdtime/strptime.c
==
--- stable/9/lib/libc/stdtime/strptime.cSun Sep 25 22:57:59 2016
(r306325)
+++ stable/9/lib/libc/stdtime/strptime.cSun Sep 25 23:05:44 2016
(r306326)
@@ -103,9 +103,6 @@ _strptime(const char *buf, const char *f
 
ptr = fmt;
while (*ptr != 0) {
-   if (*buf == 0)
-   break;
-
c = *ptr++;
 
if (c != '%') {
@@ -123,7 +120,6 @@ _strptime(const char *buf, const char *f
 label:
c = *ptr++;
switch (c) {
-   case 0:
case '%':
if (*buf++ != '%')
return (NULL);
@@ -552,7 +548,8 @@ label:
strncpy(zonestr, buf, cp - buf);
zonestr[cp - buf] = '\0';
tzset();
-   if (0 == strcmp(zonestr, "GMT")) {
+   if (0 == strcmp(zonestr, "GMT") ||
+   0 == strcmp(zonestr, "UTC")) {
*GMTp = 1;
} else if (0 == strcmp(zonestr, tzname[0])) {
tm->tm_isdst = 0;
@@ -599,6 +596,9 @@ label:
while (isspace_l((unsigned char)*buf, locale))
buf++;
break;
+
+   default:
+   return (NULL);
}
}
 
@@ -674,6 +674,7 @@ strptime_l(const char * __restrict buf, 
ret = _strptime(buf, fmt, tm, &gmt, loc);
if (ret && gmt) {
time_t t = timegm(tm);
+
localtime_r(&t, tm);
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r306201 - stable/11/bin/cat

2016-09-22 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep 22 16:49:53 2016
New Revision: 306201
URL: https://svnweb.freebsd.org/changeset/base/306201

Log:
  MFC r305841
  
  Implement multibyte encoding support for -v with fallback

Modified:
  stable/11/bin/cat/cat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/bin/cat/cat.c
==
--- stable/11/bin/cat/cat.c Thu Sep 22 16:46:59 2016(r306200)
+++ stable/11/bin/cat/cat.c Thu Sep 22 16:49:53 2016(r306201)
@@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 static int bflag, eflag, lflag, nflag, sflag, tflag, vflag;
 static int rval;
@@ -207,6 +209,7 @@ static void
 cook_cat(FILE *fp)
 {
int ch, gobble, line, prev;
+   wint_t wch;
 
/* Reset EOF condition on stdin. */
if (fp == stdin && feof(stdin))
@@ -239,18 +242,40 @@ cook_cat(FILE *fp)
continue;
}
} else if (vflag) {
-   if (!isascii(ch) && !isprint(ch)) {
+   (void)ungetc(ch, fp);
+   /*
+* Our getwc(3) doesn't change file position
+* on error.
+*/
+   if ((wch = getwc(fp)) == WEOF) {
+   if (ferror(fp) && errno == EILSEQ) {
+   clearerr(fp);
+   /* Resync attempt. */
+   memset(&fp->_mbstate, 0, 
sizeof(mbstate_t));
+   if ((ch = getc(fp)) == EOF)
+   break;
+   wch = ch;
+   goto ilseq;
+   } else
+   break;
+   }
+   if (!iswascii(wch) && !iswprint(wch)) {
+ilseq:
if (putchar('M') == EOF || putchar('-') == EOF)
break;
-   ch = toascii(ch);
+   wch = toascii(wch);
}
-   if (iscntrl(ch)) {
-   if (putchar('^') == EOF ||
-   putchar(ch == '\177' ? '?' :
-   ch | 0100) == EOF)
+   if (iswcntrl(wch)) {
+   ch = toascii(wch);
+   ch = (ch == '\177') ? '?' : (ch | 0100);
+   if (putchar('^') == EOF || putchar(ch) == EOF)
break;
continue;
}
+   if (putwchar(wch) == WEOF)
+   break;
+   ch = -1;
+   continue;
}
if (putchar(ch) == EOF)
break;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r306200 - stable/10/bin/cat

2016-09-22 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep 22 16:46:59 2016
New Revision: 306200
URL: https://svnweb.freebsd.org/changeset/base/306200

Log:
  MFC r305841
  
  Implement multibyte encoding support for -v with fallback

Modified:
  stable/10/bin/cat/cat.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/cat/cat.c
==
--- stable/10/bin/cat/cat.c Thu Sep 22 16:05:19 2016(r306199)
+++ stable/10/bin/cat/cat.c Thu Sep 22 16:46:59 2016(r306200)
@@ -63,6 +63,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 static int bflag, eflag, lflag, nflag, sflag, tflag, vflag;
 static int rval;
@@ -205,6 +207,7 @@ static void
 cook_cat(FILE *fp)
 {
int ch, gobble, line, prev;
+   wint_t wch;
 
/* Reset EOF condition on stdin. */
if (fp == stdin && feof(stdin))
@@ -237,18 +240,40 @@ cook_cat(FILE *fp)
continue;
}
} else if (vflag) {
-   if (!isascii(ch) && !isprint(ch)) {
+   (void)ungetc(ch, fp);
+   /*
+* Our getwc(3) doesn't change file position
+* on error.
+*/
+   if ((wch = getwc(fp)) == WEOF) {
+   if (ferror(fp) && errno == EILSEQ) {
+   clearerr(fp);
+   /* Resync attempt. */
+   memset(&fp->_mbstate, 0, 
sizeof(mbstate_t));
+   if ((ch = getc(fp)) == EOF)
+   break;
+   wch = ch;
+   goto ilseq;
+   } else
+   break;
+   }
+   if (!iswascii(wch) && !iswprint(wch)) {
+ilseq:
if (putchar('M') == EOF || putchar('-') == EOF)
break;
-   ch = toascii(ch);
+   wch = toascii(wch);
}
-   if (iscntrl(ch)) {
-   if (putchar('^') == EOF ||
-   putchar(ch == '\177' ? '?' :
-   ch | 0100) == EOF)
+   if (iswcntrl(wch)) {
+   ch = toascii(wch);
+   ch = (ch == '\177') ? '?' : (ch | 0100);
+   if (putchar('^') == EOF || putchar(ch) == EOF)
break;
continue;
}
+   if (putwchar(wch) == WEOF)
+   break;
+   ch = -1;
+   continue;
}
if (putchar(ch) == EOF)
break;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r306109 - head/lib/libc/stdtime

2016-09-21 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep 21 15:47:40 2016
New Revision: 306109
URL: https://svnweb.freebsd.org/changeset/base/306109

Log:
  1) For already non-standard %z extension implement GNU compatible formats:
  +hh and -hh.
  2) Check for incorrect values for %z.
  
  MFC after:  7 days

Modified:
  head/lib/libc/stdtime/strptime.c

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cWed Sep 21 15:29:35 2016
(r306108)
+++ head/lib/libc/stdtime/strptime.cWed Sep 21 15:47:40 2016
(r306109)
@@ -582,10 +582,16 @@ label:
i *= 10;
i += *buf - '0';
buf++;
+   } else if (len == 2) {
+   i *= 100;
+   break;
} else
return (NULL);
}
 
+   if (i > 1400 || (sign == -1 && i > 1200) ||
+   (i % 100) >= 60)
+   return (NULL);
tm->tm_hour -= sign * (i / 100);
tm->tm_min  -= sign * (i % 100);
*GMTp = 1;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r306075 - head/lib/libc/stdtime

2016-09-20 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep 21 06:44:32 2016
New Revision: 306075
URL: https://svnweb.freebsd.org/changeset/base/306075

Log:
  1) Microoptimize %p case.
  2) Implememt %u for GNU compatibility.
  3) Don't forget to advance buf for %w/%u.
  4) Fail with incomplete week (week 0) request and no such week in the
  year.
  5) Fix yday formula when Sunday requested and the week started from Monday.
  6) Fail with impossible yday for incomplete week (week 0) and direct %w/%u
  request.
  7) Shift yday/wday to the first day of the year, if incomplete week
  (week 0) requested and no %w/%u used.
  
  MFC after:  7 days

Modified:
  head/lib/libc/stdtime/strptime.c

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cWed Sep 21 06:43:52 2016
(r306074)
+++ head/lib/libc/stdtime/strptime.cWed Sep 21 06:44:32 2016
(r306075)
@@ -301,10 +301,11 @@ label:
 * XXX This is bogus if parsed before hour-related
 * specifiers.
 */
+   if (tm->tm_hour > 12)
+   return (NULL);
+
len = strlen(tptr->am);
if (strncasecmp_l(buf, tptr->am, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour == 12)
tm->tm_hour = 0;
buf += len;
@@ -313,8 +314,6 @@ label:
 
len = strlen(tptr->pm);
if (strncasecmp_l(buf, tptr->pm, len, locale) == 0) {
-   if (tm->tm_hour > 12)
-   return (NULL);
if (tm->tm_hour != 12)
tm->tm_hour += 12;
buf += len;
@@ -374,15 +373,17 @@ label:
 
break;
 
+   case 'u':
case 'w':
if (!isdigit_l((unsigned char)*buf, locale))
return (NULL);
 
-   i = *buf - '0';
-   if (i > 6)
+   i = *buf++ - '0';
+   if (i < 0 || i > 7 || (c == 'u' && i < 1) ||
+   (c == 'w' && i > 6))
return (NULL);
 
-   tm->tm_wday = i;
+   tm->tm_wday = i % 7;
flags |= FLAG_WDAY;
 
break;
@@ -609,17 +610,28 @@ label:
TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1);
flags |= FLAG_YDAY;
} else if (day_offset != -1) {
+   int tmpwday, tmpyday, fwo;
+
+   fwo = first_wday_of(tm->tm_year + TM_YEAR_BASE);
+   /* No incomplete week (week 0). */
+   if (week_offset == 0 && fwo == day_offset)
+   return (NULL);
+
/* Set the date to the first Sunday (or Monday)
 * of the specified week of the year.
 */
-   if (!(flags & FLAG_WDAY)) {
-   tm->tm_wday = day_offset;
-   flags |= FLAG_WDAY;
-   }
-   tm->tm_yday = (7 -
-   first_wday_of(tm->tm_year + TM_YEAR_BASE) +
-   day_offset) % 7 + (week_offset - 1) * 7 +
-   tm->tm_wday - day_offset;
+   tmpwday = (flags & FLAG_WDAY) ? tm->tm_wday :
+   day_offset;
+   tmpyday = (7 - fwo + day_offset) % 7 +
+   (week_offset - 1) * 7 +
+   (tmpwday - day_offset + 7) % 7;
+   /* Impossible yday for incomplete week (week 0). */
+   if (tmpyday < 0) {
+   if (flags & FLAG_WDAY)
+   return (NULL);
+   tmpyday = 0;
+   }
+   tm->tm_yday = tmpyday;
flags |= FLAG_YDAY;
}
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305841 - head/bin/cat

2016-09-15 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep 15 17:24:39 2016
New Revision: 305841
URL: https://svnweb.freebsd.org/changeset/base/305841

Log:
  Implement multibyte encoding support for -v with fallback
  
  MFC after:  7 days

Modified:
  head/bin/cat/cat.c

Modified: head/bin/cat/cat.c
==
--- head/bin/cat/cat.c  Thu Sep 15 17:24:23 2016(r305840)
+++ head/bin/cat/cat.c  Thu Sep 15 17:24:39 2016(r305841)
@@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 static int bflag, eflag, lflag, nflag, sflag, tflag, vflag;
 static int rval;
@@ -207,6 +209,7 @@ static void
 cook_cat(FILE *fp)
 {
int ch, gobble, line, prev;
+   wint_t wch;
 
/* Reset EOF condition on stdin. */
if (fp == stdin && feof(stdin))
@@ -239,18 +242,40 @@ cook_cat(FILE *fp)
continue;
}
} else if (vflag) {
-   if (!isascii(ch) && !isprint(ch)) {
+   (void)ungetc(ch, fp);
+   /*
+* Our getwc(3) doesn't change file position
+* on error.
+*/
+   if ((wch = getwc(fp)) == WEOF) {
+   if (ferror(fp) && errno == EILSEQ) {
+   clearerr(fp);
+   /* Resync attempt. */
+   memset(&fp->_mbstate, 0, 
sizeof(mbstate_t));
+   if ((ch = getc(fp)) == EOF)
+   break;
+   wch = ch;
+   goto ilseq;
+   } else
+   break;
+   }
+   if (!iswascii(wch) && !iswprint(wch)) {
+ilseq:
if (putchar('M') == EOF || putchar('-') == EOF)
break;
-   ch = toascii(ch);
+   wch = toascii(wch);
}
-   if (iscntrl(ch)) {
-   if (putchar('^') == EOF ||
-   putchar(ch == '\177' ? '?' :
-   ch | 0100) == EOF)
+   if (iswcntrl(wch)) {
+   ch = toascii(wch);
+   ch = (ch == '\177') ? '?' : (ch | 0100);
+   if (putchar('^') == EOF || putchar(ch) == EOF)
break;
continue;
}
+   if (putwchar(wch) == WEOF)
+   break;
+   ch = -1;
+   continue;
}
if (putchar(ch) == EOF)
break;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305584 - stable/11/lib/libc/stdio

2016-09-08 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  8 07:16:15 2016
New Revision: 305584
URL: https://svnweb.freebsd.org/changeset/base/305584

Log:
  MFC r305413
  
  Fix error handling.

Modified:
  stable/11/lib/libc/stdio/fgets.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdio/fgets.c
==
--- stable/11/lib/libc/stdio/fgets.cThu Sep  8 07:14:48 2016
(r305583)
+++ stable/11/lib/libc/stdio/fgets.cThu Sep  8 07:16:15 2016
(r305584)
@@ -37,6 +37,7 @@ static char sccsid[] = "@(#)fgets.c   8.2 
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -55,11 +56,16 @@ fgets(char * __restrict buf, int n, FILE
char *s;
unsigned char *p, *t;
 
-   if (n <= 0) /* sanity check */
-   return (NULL);
-
FLOCKFILE(fp);
ORIENT(fp, -1);
+
+   if (n <= 0) {   /* sanity check */
+   fp->_flags |= __SERR;
+   errno = EINVAL;
+   FUNLOCKFILE(fp);
+   return (NULL);
+   }
+
s = buf;
n--;/* leave space for NUL */
while (n != 0) {
@@ -69,7 +75,7 @@ fgets(char * __restrict buf, int n, FILE
if ((len = fp->_r) <= 0) {
if (__srefill(fp)) {
/* EOF/error: stop with partial or no line */
-   if (s == buf) {
+   if (!__sfeof(fp) || s == buf) {
FUNLOCKFILE(fp);
return (NULL);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305583 - stable/10/lib/libc/stdio

2016-09-08 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  8 07:14:48 2016
New Revision: 305583
URL: https://svnweb.freebsd.org/changeset/base/305583

Log:
  MFC r305413
  
  Fix error handling.

Modified:
  stable/10/lib/libc/stdio/fgets.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdio/fgets.c
==
--- stable/10/lib/libc/stdio/fgets.cThu Sep  8 06:53:18 2016
(r305582)
+++ stable/10/lib/libc/stdio/fgets.cThu Sep  8 07:14:48 2016
(r305583)
@@ -37,6 +37,7 @@ static char sccsid[] = "@(#)fgets.c   8.2 
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -55,11 +56,16 @@ fgets(char * __restrict buf, int n, FILE
char *s;
unsigned char *p, *t;
 
-   if (n <= 0) /* sanity check */
-   return (NULL);
-
FLOCKFILE(fp);
ORIENT(fp, -1);
+
+   if (n <= 0) {   /* sanity check */
+   fp->_flags |= __SERR;
+   errno = EINVAL;
+   FUNLOCKFILE(fp);
+   return (NULL);
+   }
+
s = buf;
n--;/* leave space for NUL */
while (n != 0) {
@@ -69,7 +75,7 @@ fgets(char * __restrict buf, int n, FILE
if ((len = fp->_r) <= 0) {
if (__srefill(fp)) {
/* EOF/error: stop with partial or no line */
-   if (s == buf) {
+   if (!__sfeof(fp) || s == buf) {
FUNLOCKFILE(fp);
return (NULL);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305582 - stable/11/lib/libc/stdio

2016-09-07 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  8 06:53:18 2016
New Revision: 305582
URL: https://svnweb.freebsd.org/changeset/base/305582

Log:
  MFC r305406,r305409,r305412
  
  1) Fix errors handling.
  
  2) Prevent out of bounds access to ws[-1] (passed buffer) which happens
  when the first mb sequence is incomplete and there are not enougn chars in
  the read buffer. ws[-1] may lead to memory faults or false results, in
  case the memory here contains '\n'.
  
  3) Fix n == 1 case. Here should be no physical read (fill buffer) attempt
  (we read n - 1 chars with the room for NUL, see fgets()),
  and no NULL return.

Modified:
  stable/11/lib/libc/stdio/fgetws.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdio/fgetws.c
==
--- stable/11/lib/libc/stdio/fgetws.c   Thu Sep  8 06:42:30 2016
(r305581)
+++ stable/11/lib/libc/stdio/fgetws.c   Thu Sep  8 06:53:18 2016
(r305582)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 wchar_t *
 fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale)
 {
+   int sret;
wchar_t *wsp;
size_t nconv;
const char *src;
@@ -56,23 +57,31 @@ fgetws_l(wchar_t * __restrict ws, int n,
ORIENT(fp, 1);
 
if (n <= 0) {
+   fp->_flags |= __SERR;
errno = EINVAL;
goto error;
}
 
+   wsp = ws;
+   if (n == 1)
+   goto ok;
+
if (fp->_r <= 0 && __srefill(fp))
-   /* EOF */
+   /* EOF or ferror */
goto error;
-   wsp = ws;
+
+   sret = 0;
do {
src = fp->_p;
nl = memchr(fp->_p, '\n', fp->_r);
nconv = l->__mbsnrtowcs(wsp, &src,
nl != NULL ? (nl - fp->_p + 1) : fp->_r,
n - 1, &fp->_mbstate);
-   if (nconv == (size_t)-1)
+   if (nconv == (size_t)-1) {
/* Conversion error */
+   fp->_flags |= __SERR;
goto error;
+   }
if (src == NULL) {
/*
 * We hit a null byte. Increment the character count,
@@ -88,23 +97,30 @@ fgetws_l(wchar_t * __restrict ws, int n,
fp->_p = (unsigned char *)src;
n -= nconv;
wsp += nconv;
-   } while (wsp[-1] != L'\n' && n > 1 && (fp->_r > 0 ||
-   __srefill(fp) == 0));
-   if (wsp == ws)
-   /* EOF */
+   } while ((wsp == ws || wsp[-1] != L'\n') && n > 1 && (fp->_r > 0 ||
+   (sret = __srefill(fp)) == 0));
+   if (sret && !__sfeof(fp))
+   /* ferror */
goto error;
-   if (!l->__mbsinit(&fp->_mbstate))
+   if (!l->__mbsinit(&fp->_mbstate)) {
/* Incomplete character */
+   fp->_flags |= __SERR;
+   errno = EILSEQ;
goto error;
+   }
+   if (wsp == ws)
+   /* EOF */
+   goto error;
+ok:
*wsp = L'\0';
FUNLOCKFILE(fp);
-
return (ws);
 
 error:
FUNLOCKFILE(fp);
return (NULL);
 }
+
 wchar_t *
 fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305577 - stable/10/lib/libc/stdio

2016-09-07 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  8 05:13:50 2016
New Revision: 305577
URL: https://svnweb.freebsd.org/changeset/base/305577

Log:
  MFC r305406,r305409,r305412
  
  1) Fix errors handling.
  
  2) Prevent out of bounds access to ws[-1] (passed buffer) which happens
  when the first mb sequence is incomplete and there are not enougn chars in
  the read buffer. ws[-1] may lead to memory faults or false results, in
  case the memory here contains '\n'.
  
  3) Fix n == 1 case. Here should be no physical read (fill buffer) attempt
  (we read n - 1 chars with the room for NUL, see fgets()),
  and no NULL return.

Modified:
  stable/10/lib/libc/stdio/fgetws.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdio/fgetws.c
==
--- stable/10/lib/libc/stdio/fgetws.c   Thu Sep  8 02:38:55 2016
(r305576)
+++ stable/10/lib/libc/stdio/fgetws.c   Thu Sep  8 05:13:50 2016
(r305577)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 wchar_t *
 fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale)
 {
+   int sret;
wchar_t *wsp;
size_t nconv;
const char *src;
@@ -56,23 +57,31 @@ fgetws_l(wchar_t * __restrict ws, int n,
ORIENT(fp, 1);
 
if (n <= 0) {
+   fp->_flags |= __SERR;
errno = EINVAL;
goto error;
}
 
+   wsp = ws;
+   if (n == 1)
+   goto ok;
+
if (fp->_r <= 0 && __srefill(fp))
-   /* EOF */
+   /* EOF or ferror */
goto error;
-   wsp = ws;
+
+   sret = 0;
do {
src = fp->_p;
nl = memchr(fp->_p, '\n', fp->_r);
nconv = l->__mbsnrtowcs(wsp, &src,
nl != NULL ? (nl - fp->_p + 1) : fp->_r,
n - 1, &fp->_mbstate);
-   if (nconv == (size_t)-1)
+   if (nconv == (size_t)-1) {
/* Conversion error */
+   fp->_flags |= __SERR;
goto error;
+   }
if (src == NULL) {
/*
 * We hit a null byte. Increment the character count,
@@ -88,23 +97,30 @@ fgetws_l(wchar_t * __restrict ws, int n,
fp->_p = (unsigned char *)src;
n -= nconv;
wsp += nconv;
-   } while (wsp[-1] != L'\n' && n > 1 && (fp->_r > 0 ||
-   __srefill(fp) == 0));
-   if (wsp == ws)
-   /* EOF */
+   } while ((wsp == ws || wsp[-1] != L'\n') && n > 1 && (fp->_r > 0 ||
+   (sret = __srefill(fp)) == 0));
+   if (sret && !__sfeof(fp))
+   /* ferror */
goto error;
-   if (!l->__mbsinit(&fp->_mbstate))
+   if (!l->__mbsinit(&fp->_mbstate)) {
/* Incomplete character */
+   fp->_flags |= __SERR;
+   errno = EILSEQ;
goto error;
+   }
+   if (wsp == ws)
+   /* EOF */
+   goto error;
+ok:
*wsp = L'\0';
FUNLOCKFILE(fp);
-
return (ws);
 
 error:
FUNLOCKFILE(fp);
return (NULL);
 }
+
 wchar_t *
 fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305450 - stable/9/contrib/one-true-awk

2016-09-05 Thread Andrey A. Chernov
Author: ache
Date: Tue Sep  6 00:53:20 2016
New Revision: 305450
URL: https://svnweb.freebsd.org/changeset/base/305450

Log:
  MFC r305365
  
  The bug:
  $ echo x | awk '/[[:cntrl:]]/'
  x
  
  The NUL character in cntrl class truncates the pattern, and an empty
  pattern matches anything. The patch skips NUL as a quick fix.
  
  PR: 195792
  Submitted by:   kdrak...@zoho.com
  Approved by:b...@cs.princeton.edu (the author)

Modified:
  stable/9/contrib/one-true-awk/b.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/contrib/   (props changed)
  stable/9/contrib/one-true-awk/   (props changed)

Modified: stable/9/contrib/one-true-awk/b.c
==
--- stable/9/contrib/one-true-awk/b.c   Tue Sep  6 00:51:25 2016
(r305449)
+++ stable/9/contrib/one-true-awk/b.c   Tue Sep  6 00:53:20 2016
(r305450)
@@ -841,7 +841,7 @@ int relex(void) /* lexical analyzer for
if (cc->cc_name != NULL && prestr[1 + 
cc->cc_namelen] == ':' &&
prestr[2 + cc->cc_namelen] == ']') {
prestr += cc->cc_namelen + 3;
-   for (i = 0; i < NCHARS; i++) {
+   for (i = 1; i < NCHARS; i++) {
if (!adjbuf((char **) &buf, 
&bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
FATAL("out of space for reg 
expr %.10s...", lastre);
if (cc->cc_func(i)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305448 - stable/11/contrib/one-true-awk

2016-09-05 Thread Andrey A. Chernov
Author: ache
Date: Tue Sep  6 00:33:54 2016
New Revision: 305448
URL: https://svnweb.freebsd.org/changeset/base/305448

Log:
  MFC r305365
  
  The bug:
  $ echo x | awk '/[[:cntrl:]]/'
  x
  
  The NUL character in cntrl class truncates the pattern, and an empty
  pattern matches anything. The patch skips NUL as a quick fix.
  
  PR: 195792
  Submitted by:   kdrak...@zoho.com
  Approved by:b...@cs.princeton.edu (the author)

Modified:
  stable/11/contrib/one-true-awk/b.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/one-true-awk/b.c
==
--- stable/11/contrib/one-true-awk/b.c  Tue Sep  6 00:32:33 2016
(r305447)
+++ stable/11/contrib/one-true-awk/b.c  Tue Sep  6 00:33:54 2016
(r305448)
@@ -841,7 +841,7 @@ int relex(void) /* lexical analyzer for
if (cc->cc_name != NULL && prestr[1 + 
cc->cc_namelen] == ':' &&
prestr[2 + cc->cc_namelen] == ']') {
prestr += cc->cc_namelen + 3;
-   for (i = 0; i < NCHARS; i++) {
+   for (i = 1; i < NCHARS; i++) {
if (!adjbuf((char **) &buf, 
&bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
FATAL("out of space for reg 
expr %.10s...", lastre);
if (cc->cc_func(i)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305447 - stable/10/contrib/one-true-awk

2016-09-05 Thread Andrey A. Chernov
Author: ache
Date: Tue Sep  6 00:32:33 2016
New Revision: 305447
URL: https://svnweb.freebsd.org/changeset/base/305447

Log:
  MFC r305365
  
  The bug:
  $ echo x | awk '/[[:cntrl:]]/'
  x
  
  The NUL character in cntrl class truncates the pattern, and an empty
  pattern matches anything. The patch skips NUL as a quick fix.
  
  PR: 195792
  Submitted by:   kdrak...@zoho.com
  Approved by:b...@cs.princeton.edu (the author)

Modified:
  stable/10/contrib/one-true-awk/b.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/one-true-awk/b.c
==
--- stable/10/contrib/one-true-awk/b.c  Mon Sep  5 23:56:27 2016
(r305446)
+++ stable/10/contrib/one-true-awk/b.c  Tue Sep  6 00:32:33 2016
(r305447)
@@ -841,7 +841,7 @@ int relex(void) /* lexical analyzer for
if (cc->cc_name != NULL && prestr[1 + 
cc->cc_namelen] == ':' &&
prestr[2 + cc->cc_namelen] == ']') {
prestr += cc->cc_namelen + 3;
-   for (i = 0; i < NCHARS; i++) {
+   for (i = 1; i < NCHARS; i++) {
if (!adjbuf((char **) &buf, 
&bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
FATAL("out of space for reg 
expr %.10s...", lastre);
if (cc->cc_func(i)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305413 - head/lib/libc/stdio

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 06:46:04 2016
New Revision: 305413
URL: https://svnweb.freebsd.org/changeset/base/305413

Log:
  Fix error handling.
  
  MFC after:  3 days

Modified:
  head/lib/libc/stdio/fgets.c

Modified: head/lib/libc/stdio/fgets.c
==
--- head/lib/libc/stdio/fgets.c Mon Sep  5 06:10:51 2016(r305412)
+++ head/lib/libc/stdio/fgets.c Mon Sep  5 06:46:04 2016(r305413)
@@ -37,6 +37,7 @@ static char sccsid[] = "@(#)fgets.c   8.2 
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -55,11 +56,16 @@ fgets(char * __restrict buf, int n, FILE
char *s;
unsigned char *p, *t;
 
-   if (n <= 0) /* sanity check */
-   return (NULL);
-
FLOCKFILE(fp);
ORIENT(fp, -1);
+
+   if (n <= 0) {   /* sanity check */
+   fp->_flags |= __SERR;
+   errno = EINVAL;
+   FUNLOCKFILE(fp);
+   return (NULL);
+   }
+
s = buf;
n--;/* leave space for NUL */
while (n != 0) {
@@ -69,7 +75,7 @@ fgets(char * __restrict buf, int n, FILE
if ((len = fp->_r) <= 0) {
if (__srefill(fp)) {
/* EOF/error: stop with partial or no line */
-   if (s == buf) {
+   if (!__sfeof(fp) || s == buf) {
FUNLOCKFILE(fp);
return (NULL);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305412 - head/lib/libc/stdio

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 06:10:51 2016
New Revision: 305412
URL: https://svnweb.freebsd.org/changeset/base/305412

Log:
  Fix n == 1 case. Here should be no physical read (fill buffer) attempt
  (we read n - 1 chars with the room for NUL, see fgets()),
  and no NULL return.
  
  MFC after:  3 days

Modified:
  head/lib/libc/stdio/fgetws.c

Modified: head/lib/libc/stdio/fgetws.c
==
--- head/lib/libc/stdio/fgetws.cMon Sep  5 05:07:40 2016
(r305411)
+++ head/lib/libc/stdio/fgetws.cMon Sep  5 06:10:51 2016
(r305412)
@@ -62,10 +62,14 @@ fgetws_l(wchar_t * __restrict ws, int n,
goto error;
}
 
+   wsp = ws;
+   if (n == 1)
+   goto ok;
+
if (fp->_r <= 0 && __srefill(fp))
/* EOF or ferror */
goto error;
-   wsp = ws;
+
sret = 0;
do {
src = fp->_p;
@@ -107,9 +111,9 @@ fgetws_l(wchar_t * __restrict ws, int n,
if (wsp == ws)
/* EOF */
goto error;
+ok:
*wsp = L'\0';
FUNLOCKFILE(fp);
-
return (ws);
 
 error:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305409 - head/lib/libc/stdio

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 04:49:58 2016
New Revision: 305409
URL: https://svnweb.freebsd.org/changeset/base/305409

Log:
  1) Prevent out of bounds access to ws[-1] (passed buffer) which happens
  when the first mb sequence is incomplete and there are not enougn chars in
  the read buffer. ws[-1] may lead to memory faults or false results, in
  case the memory here contains '\n'.
  
  2) Fix EOF checking I mess in my previos r305406 commit.
  
  MFC after:  3 days

Modified:
  head/lib/libc/stdio/fgetws.c

Modified: head/lib/libc/stdio/fgetws.c
==
--- head/lib/libc/stdio/fgetws.cMon Sep  5 04:47:31 2016
(r305408)
+++ head/lib/libc/stdio/fgetws.cMon Sep  5 04:49:58 2016
(r305409)
@@ -93,7 +93,7 @@ fgetws_l(wchar_t * __restrict ws, int n,
fp->_p = (unsigned char *)src;
n -= nconv;
wsp += nconv;
-   } while (wsp[-1] != L'\n' && n > 1 && (fp->_r > 0 ||
+   } while ((wsp == ws || wsp[-1] != L'\n') && n > 1 && (fp->_r > 0 ||
(sret = __srefill(fp)) == 0));
if (sret && !__sfeof(fp))
/* ferror */
@@ -104,7 +104,7 @@ fgetws_l(wchar_t * __restrict ws, int n,
errno = EILSEQ;
goto error;
}
-   if (sret)
+   if (wsp == ws)
/* EOF */
goto error;
*wsp = L'\0';
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305406 - head/lib/libc/stdio

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 03:37:28 2016
New Revision: 305406
URL: https://svnweb.freebsd.org/changeset/base/305406

Log:
  Fix errors handling.
  
  MFC after:  3 days

Modified:
  head/lib/libc/stdio/fgetws.c

Modified: head/lib/libc/stdio/fgetws.c
==
--- head/lib/libc/stdio/fgetws.cMon Sep  5 03:21:31 2016
(r305405)
+++ head/lib/libc/stdio/fgetws.cMon Sep  5 03:37:28 2016
(r305406)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 wchar_t *
 fgetws_l(wchar_t * __restrict ws, int n, FILE * __restrict fp, locale_t locale)
 {
+   int sret;
wchar_t *wsp;
size_t nconv;
const char *src;
@@ -56,23 +57,27 @@ fgetws_l(wchar_t * __restrict ws, int n,
ORIENT(fp, 1);
 
if (n <= 0) {
+   fp->_flags |= __SERR;
errno = EINVAL;
goto error;
}
 
if (fp->_r <= 0 && __srefill(fp))
-   /* EOF */
+   /* EOF or ferror */
goto error;
wsp = ws;
+   sret = 0;
do {
src = fp->_p;
nl = memchr(fp->_p, '\n', fp->_r);
nconv = l->__mbsnrtowcs(wsp, &src,
nl != NULL ? (nl - fp->_p + 1) : fp->_r,
n - 1, &fp->_mbstate);
-   if (nconv == (size_t)-1)
+   if (nconv == (size_t)-1) {
/* Conversion error */
+   fp->_flags |= __SERR;
goto error;
+   }
if (src == NULL) {
/*
 * We hit a null byte. Increment the character count,
@@ -89,12 +94,18 @@ fgetws_l(wchar_t * __restrict ws, int n,
n -= nconv;
wsp += nconv;
} while (wsp[-1] != L'\n' && n > 1 && (fp->_r > 0 ||
-   __srefill(fp) == 0));
-   if (wsp == ws)
-   /* EOF */
+   (sret = __srefill(fp)) == 0));
+   if (sret && !__sfeof(fp))
+   /* ferror */
goto error;
-   if (!l->__mbsinit(&fp->_mbstate))
+   if (!l->__mbsinit(&fp->_mbstate)) {
/* Incomplete character */
+   fp->_flags |= __SERR;
+   errno = EILSEQ;
+   goto error;
+   }
+   if (sret)
+   /* EOF */
goto error;
*wsp = L'\0';
FUNLOCKFILE(fp);
@@ -105,6 +116,7 @@ error:
FUNLOCKFILE(fp);
return (NULL);
 }
+
 wchar_t *
 fgetws(wchar_t * __restrict ws, int n, FILE * __restrict fp)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305404 - stable/11/lib/libc/stdio

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 02:00:35 2016
New Revision: 305404
URL: https://svnweb.freebsd.org/changeset/base/305404

Log:
  MFC r305241
  
  fgetwc(3) may set both __SEOF and __SERR at once (in case of incomplete
  sequence near EOF), so we can't just check for
  (wc == WEOF && !__sfeof(fp)) and must relay on __sferror(fp) with
  __SERR clearing/restoring.

Modified:
  stable/11/lib/libc/stdio/fgetwln.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdio/fgetwln.c
==
--- stable/11/lib/libc/stdio/fgetwln.c  Mon Sep  5 01:57:32 2016
(r305403)
+++ stable/11/lib/libc/stdio/fgetwln.c  Mon Sep  5 02:00:35 2016
(r305404)
@@ -47,11 +47,16 @@ fgetwln_l(FILE * __restrict fp, size_t *
 {
wint_t wc;
size_t len;
+   int savserr;
+
FIX_LOCALE(locale);
 
FLOCKFILE(fp);
ORIENT(fp, 1);
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
len = 0;
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
@@ -64,7 +69,12 @@ fgetwln_l(FILE * __restrict fp, size_t *
if (wc == L'\n')
break;
}
-   if (len == 0 || (wc == WEOF && !__sfeof(fp)))
+   /* fgetwc(3) may set both __SEOF and __SERR at once. */
+   if (__sferror(fp))
+   goto error;
+
+   fp->_flags |= savserr;
+   if (len == 0)
goto error;
 
FUNLOCKFILE(fp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305403 - stable/10/lib/libc/stdio

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 01:57:32 2016
New Revision: 305403
URL: https://svnweb.freebsd.org/changeset/base/305403

Log:
  MFC r305241
  
  fgetwc(3) may set both __SEOF and __SERR at once (in case of incomplete
  sequence near EOF), so we can't just check for
  (wc == WEOF && !__sfeof(fp)) and must relay on __sferror(fp) with
  __SERR clearing/restoring.

Modified:
  stable/10/lib/libc/stdio/fgetwln.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdio/fgetwln.c
==
--- stable/10/lib/libc/stdio/fgetwln.c  Mon Sep  5 00:41:17 2016
(r305402)
+++ stable/10/lib/libc/stdio/fgetwln.c  Mon Sep  5 01:57:32 2016
(r305403)
@@ -47,11 +47,16 @@ fgetwln_l(FILE * __restrict fp, size_t *
 {
wint_t wc;
size_t len;
+   int savserr;
+
FIX_LOCALE(locale);
 
FLOCKFILE(fp);
ORIENT(fp, 1);
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
len = 0;
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
@@ -64,7 +69,12 @@ fgetwln_l(FILE * __restrict fp, size_t *
if (wc == L'\n')
break;
}
-   if (len == 0 || (wc == WEOF && !__sfeof(fp)))
+   /* fgetwc(3) may set both __SEOF and __SERR at once. */
+   if (__sferror(fp))
+   goto error;
+
+   fp->_flags |= savserr;
+   if (len == 0)
goto error;
 
FUNLOCKFILE(fp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305402 - stable/11/lib/libc/net

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 00:41:17 2016
New Revision: 305402
URL: https://svnweb.freebsd.org/changeset/base/305402

Log:
  MFC r305144
  
  'addrlen' does not matter when we need to find the first non-zero bit in
  the byte from the left and 'addrlen' already counted in 'lim'.
  
  PR: 212121
  Submitted by:   herbie.robin...@stratus.com

Modified:
  stable/11/lib/libc/net/getaddrinfo.c
  stable/11/lib/libc/net/name6.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/net/getaddrinfo.c
==
--- stable/11/lib/libc/net/getaddrinfo.cMon Sep  5 00:36:52 2016
(r305401)
+++ stable/11/lib/libc/net/getaddrinfo.cMon Sep  5 00:41:17 2016
(r305402)
@@ -949,7 +949,7 @@ matchlen(struct sockaddr *src, struct so
 
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
-   while (r < addrlen * 8) {
+   while ((r & 0x80) == 0) {
match++;
r <<= 1;
}

Modified: stable/11/lib/libc/net/name6.c
==
--- stable/11/lib/libc/net/name6.c  Mon Sep  5 00:36:52 2016
(r305401)
+++ stable/11/lib/libc/net/name6.c  Mon Sep  5 00:41:17 2016
(r305402)
@@ -930,7 +930,7 @@ matchlen(struct sockaddr *src, struct so
 
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
-   while (r < addrlen * 8) {
+   while ((r & 0x80) == 0) {
match++;
r <<= 1;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305401 - stable/10/lib/libc/net

2016-09-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Sep  5 00:36:52 2016
New Revision: 305401
URL: https://svnweb.freebsd.org/changeset/base/305401

Log:
  MFC r305144
  
  'addrlen' does not matter when we need to find the first non-zero bit in
  the byte from the left and 'addrlen' already counted in 'lim'.
  
  PR: 212121
  Submitted by:   herbie.robin...@stratus.com

Modified:
  stable/10/lib/libc/net/getaddrinfo.c
  stable/10/lib/libc/net/name6.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/net/getaddrinfo.c
==
--- stable/10/lib/libc/net/getaddrinfo.cSun Sep  4 22:55:05 2016
(r305400)
+++ stable/10/lib/libc/net/getaddrinfo.cMon Sep  5 00:36:52 2016
(r305401)
@@ -931,7 +931,7 @@ matchlen(struct sockaddr *src, struct so
 
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
-   while (r < addrlen * 8) {
+   while ((r & 0x80) == 0) {
match++;
r <<= 1;
}

Modified: stable/10/lib/libc/net/name6.c
==
--- stable/10/lib/libc/net/name6.c  Sun Sep  4 22:55:05 2016
(r305400)
+++ stable/10/lib/libc/net/name6.c  Mon Sep  5 00:36:52 2016
(r305401)
@@ -930,7 +930,7 @@ matchlen(struct sockaddr *src, struct so
 
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
-   while (r < addrlen * 8) {
+   while ((r & 0x80) == 0) {
match++;
r <<= 1;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305370 - stable/11/lib/libc/stdio

2016-09-03 Thread Andrey A. Chernov
Author: ache
Date: Sun Sep  4 00:35:55 2016
New Revision: 305370
URL: https://svnweb.freebsd.org/changeset/base/305370

Log:
  MFC r305219
  
  If error happens, don't overwrite original errno comes from __mbrtowc()
  and __srefill().

Modified:
  stable/11/lib/libc/stdio/fgetwc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdio/fgetwc.c
==
--- stable/11/lib/libc/stdio/fgetwc.c   Sun Sep  4 00:34:15 2016
(r305369)
+++ stable/11/lib/libc/stdio/fgetwc.c   Sun Sep  4 00:35:55 2016
(r305370)
@@ -84,9 +84,10 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
return (WEOF);
do {
nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs);
-   if (nconv == (size_t)-1)
-   break;
-   else if (nconv == (size_t)-2)
+   if (nconv == (size_t)-1) {
+   fp->_flags |= __SERR;
+   return (WEOF);
+   } else if (nconv == (size_t)-2)
continue;
else if (nconv == 0) {
fp->_p++;
@@ -100,7 +101,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
return (wc);
}
} while (__srefill(fp) == 0);
-   fp->_flags |= __SERR;
-   errno = EILSEQ;
+   if (__sfeof(fp)) {
+   fp->_flags |= __SERR;
+   errno = EILSEQ;
+   }
return (WEOF);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305369 - stable/10/lib/libc/stdio

2016-09-03 Thread Andrey A. Chernov
Author: ache
Date: Sun Sep  4 00:34:15 2016
New Revision: 305369
URL: https://svnweb.freebsd.org/changeset/base/305369

Log:
  MFC r305219
  
  If error happens, don't overwrite original errno comes from __mbrtowc()
  and __srefill().

Modified:
  stable/10/lib/libc/stdio/fgetwc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdio/fgetwc.c
==
--- stable/10/lib/libc/stdio/fgetwc.c   Sun Sep  4 00:29:48 2016
(r305368)
+++ stable/10/lib/libc/stdio/fgetwc.c   Sun Sep  4 00:34:15 2016
(r305369)
@@ -84,9 +84,10 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
return (WEOF);
do {
nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs);
-   if (nconv == (size_t)-1)
-   break;
-   else if (nconv == (size_t)-2)
+   if (nconv == (size_t)-1) {
+   fp->_flags |= __SERR;
+   return (WEOF);
+   } else if (nconv == (size_t)-2)
continue;
else if (nconv == 0) {
fp->_p++;
@@ -100,7 +101,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
return (wc);
}
} while (__srefill(fp) == 0);
-   fp->_flags |= __SERR;
-   errno = EILSEQ;
+   if (__sfeof(fp)) {
+   fp->_flags |= __SERR;
+   errno = EILSEQ;
+   }
return (WEOF);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305365 - head/contrib/one-true-awk

2016-09-03 Thread Andrey A. Chernov
Author: ache
Date: Sat Sep  3 23:04:56 2016
New Revision: 305365
URL: https://svnweb.freebsd.org/changeset/base/305365

Log:
  The bug:
  $ echo x | awk '/[[:cntrl:]]/'
  x
  
  The NUL character in cntrl class truncates the pattern, and an empty
  pattern matches anything. The patch skips NUL as a quick fix.
  
  PR: 195792
  Submitted by:   kdrak...@zoho.com
  Approved by:b...@cs.princeton.edu (the author)
  MFC after:  3 days

Modified:
  head/contrib/one-true-awk/b.c

Modified: head/contrib/one-true-awk/b.c
==
--- head/contrib/one-true-awk/b.c   Sat Sep  3 21:41:29 2016
(r305364)
+++ head/contrib/one-true-awk/b.c   Sat Sep  3 23:04:56 2016
(r305365)
@@ -841,7 +841,7 @@ int relex(void) /* lexical analyzer for
if (cc->cc_name != NULL && prestr[1 + 
cc->cc_namelen] == ':' &&
prestr[2 + cc->cc_namelen] == ']') {
prestr += cc->cc_namelen + 3;
-   for (i = 0; i < NCHARS; i++) {
+   for (i = 1; i < NCHARS; i++) {
if (!adjbuf((char **) &buf, 
&bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
FATAL("out of space for reg 
expr %.10s...", lastre);
if (cc->cc_func(i)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305317 - stable/11/lib/libc/net

2016-09-02 Thread Andrey A. Chernov
Author: ache
Date: Sat Sep  3 01:09:22 2016
New Revision: 305317
URL: https://svnweb.freebsd.org/changeset/base/305317

Log:
  MFC r305133
  
  Apply the same qsort() usage fix as in r304911 getaddrinfo.c
  qsort() can't be stabilized with just return(-1) alone.

Modified:
  stable/11/lib/libc/net/name6.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/net/name6.c
==
--- stable/11/lib/libc/net/name6.c  Sat Sep  3 01:08:52 2016
(r305316)
+++ stable/11/lib/libc/net/name6.c  Sat Sep  3 01:09:22 2016
(r305317)
@@ -185,6 +185,7 @@ struct hp_order {
 #define aio_sa aio_un.aiou_sa
int aio_matchlen;
char *aio_h_addr;
+   int aio_initial_sequence;
 };
 
 static struct   hostent *_hpcopy(struct hostent *, int *);
@@ -711,6 +712,7 @@ _hpreorder(struct hostent *hp)
aio[i].aio_dstscope = gai_addr2scopetype(sa);
aio[i].aio_dstpolicy = match_addrselectpolicy(sa, &policyhead);
set_source(&aio[i], &policyhead);
+   aio[i].aio_initial_sequence = i;
}
 
/* perform sorting. */
@@ -1045,6 +1047,23 @@ comp_dst(const void *arg1, const void *a
}
 
/* Rule 10: Otherwise, leave the order unchanged. */
+
+   /* 
+* Note that qsort is unstable; so, we can't return zero and 
+* expect the order to be unchanged.
+* That also means we can't depend on the current position of
+* dst2 being after dst1.  We must enforce the initial order
+* with an explicit compare on the original position.
+* The qsort specification requires that "When the same objects 
+* (consisting of width bytes, irrespective of their current 
+* positions in the array) are passed more than once to the 
+* comparison function, the results shall be consistent with one 
+* another."  
+* In other words, If A < B, then we must also return B > A.
+*/
+   if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+   return(1);
+
return(-1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305316 - stable/10/lib/libc/net

2016-09-02 Thread Andrey A. Chernov
Author: ache
Date: Sat Sep  3 01:08:52 2016
New Revision: 305316
URL: https://svnweb.freebsd.org/changeset/base/305316

Log:
  MFC r305133
  
  Apply the same qsort() usage fix as in r304911 getaddrinfo.c
  qsort() can't be stabilized with just return(-1) alone.

Modified:
  stable/10/lib/libc/net/name6.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/net/name6.c
==
--- stable/10/lib/libc/net/name6.c  Sat Sep  3 00:50:18 2016
(r305315)
+++ stable/10/lib/libc/net/name6.c  Sat Sep  3 01:08:52 2016
(r305316)
@@ -186,6 +186,7 @@ struct hp_order {
 #define aio_sa aio_un.aiou_sa
int aio_matchlen;
char *aio_h_addr;
+   int aio_initial_sequence;
 };
 
 static struct   hostent *_hpcopy(struct hostent *, int *);
@@ -711,6 +712,7 @@ _hpreorder(struct hostent *hp)
aio[i].aio_dstscope = gai_addr2scopetype(sa);
aio[i].aio_dstpolicy = match_addrselectpolicy(sa, &policyhead);
set_source(&aio[i], &policyhead);
+   aio[i].aio_initial_sequence = i;
}
 
/* perform sorting. */
@@ -1045,6 +1047,23 @@ comp_dst(const void *arg1, const void *a
}
 
/* Rule 10: Otherwise, leave the order unchanged. */
+
+   /* 
+* Note that qsort is unstable; so, we can't return zero and 
+* expect the order to be unchanged.
+* That also means we can't depend on the current position of
+* dst2 being after dst1.  We must enforce the initial order
+* with an explicit compare on the original position.
+* The qsort specification requires that "When the same objects 
+* (consisting of width bytes, irrespective of their current 
+* positions in the array) are passed more than once to the 
+* comparison function, the results shall be consistent with one 
+* another."  
+* In other words, If A < B, then we must also return B > A.
+*/
+   if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+   return(1);
+
return(-1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305241 - head/lib/libc/stdio

2016-09-01 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  1 20:45:04 2016
New Revision: 305241
URL: https://svnweb.freebsd.org/changeset/base/305241

Log:
  fgetwc(3) may set both __SEOF and __SERR at once (in case of incomplete
  sequence near EOF), so we can't just check for
  (wc == WEOF && !__sfeof(fp)) and must relay on __sferror(fp) with
  __SERR clearing/restoring.
  
  MFC after:  7 days

Modified:
  head/lib/libc/stdio/fgetwln.c

Modified: head/lib/libc/stdio/fgetwln.c
==
--- head/lib/libc/stdio/fgetwln.c   Thu Sep  1 20:43:01 2016
(r305240)
+++ head/lib/libc/stdio/fgetwln.c   Thu Sep  1 20:45:04 2016
(r305241)
@@ -47,11 +47,16 @@ fgetwln_l(FILE * __restrict fp, size_t *
 {
wint_t wc;
size_t len;
+   int savserr;
+
FIX_LOCALE(locale);
 
FLOCKFILE(fp);
ORIENT(fp, 1);
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
len = 0;
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
@@ -64,7 +69,12 @@ fgetwln_l(FILE * __restrict fp, size_t *
if (wc == L'\n')
break;
}
-   if (len == 0 || (wc == WEOF && !__sfeof(fp)))
+   /* fgetwc(3) may set both __SEOF and __SERR at once. */
+   if (__sferror(fp))
+   goto error;
+
+   fp->_flags |= savserr;
+   if (len == 0)
goto error;
 
FUNLOCKFILE(fp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305219 - head/lib/libc/stdio

2016-09-01 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  1 18:12:53 2016
New Revision: 305219
URL: https://svnweb.freebsd.org/changeset/base/305219

Log:
  If error happens, don't overwrite original errno comes from __mbrtowc()
  and __srefill().
  
  MFC after:  3 days

Modified:
  head/lib/libc/stdio/fgetwc.c

Modified: head/lib/libc/stdio/fgetwc.c
==
--- head/lib/libc/stdio/fgetwc.cThu Sep  1 18:11:44 2016
(r305218)
+++ head/lib/libc/stdio/fgetwc.cThu Sep  1 18:12:53 2016
(r305219)
@@ -84,9 +84,10 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
return (WEOF);
do {
nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs);
-   if (nconv == (size_t)-1)
-   break;
-   else if (nconv == (size_t)-2)
+   if (nconv == (size_t)-1) {
+   fp->_flags |= __SERR;
+   return (WEOF);
+   } else if (nconv == (size_t)-2)
continue;
else if (nconv == 0) {
fp->_p++;
@@ -100,7 +101,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
return (wc);
}
} while (__srefill(fp) == 0);
-   fp->_flags |= __SERR;
-   errno = EILSEQ;
+   if (__sfeof(fp)) {
+   fp->_flags |= __SERR;
+   errno = EILSEQ;
+   }
return (WEOF);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305144 - head/lib/libc/net

2016-08-31 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 31 18:49:50 2016
New Revision: 305144
URL: https://svnweb.freebsd.org/changeset/base/305144

Log:
  'addrlen' does not matter when we need to find the first non-zero bit in
  the byte from the left and 'addrlen' already counted in 'lim'.
  
  PR: 212121
  Submitted by:   herbie.robin...@stratus.com
  MFC after:  7 days

Modified:
  head/lib/libc/net/getaddrinfo.c
  head/lib/libc/net/name6.c

Modified: head/lib/libc/net/getaddrinfo.c
==
--- head/lib/libc/net/getaddrinfo.c Wed Aug 31 18:37:51 2016
(r305143)
+++ head/lib/libc/net/getaddrinfo.c Wed Aug 31 18:49:50 2016
(r305144)
@@ -949,7 +949,7 @@ matchlen(struct sockaddr *src, struct so
 
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
-   while (r < addrlen * 8) {
+   while ((r & 0x80) == 0) {
match++;
r <<= 1;
}

Modified: head/lib/libc/net/name6.c
==
--- head/lib/libc/net/name6.c   Wed Aug 31 18:37:51 2016(r305143)
+++ head/lib/libc/net/name6.c   Wed Aug 31 18:49:50 2016(r305144)
@@ -930,7 +930,7 @@ matchlen(struct sockaddr *src, struct so
 
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
-   while (r < addrlen * 8) {
+   while ((r & 0x80) == 0) {
match++;
r <<= 1;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305133 - head/lib/libc/net

2016-08-31 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 31 15:47:58 2016
New Revision: 305133
URL: https://svnweb.freebsd.org/changeset/base/305133

Log:
  Apply the same qsort() usage fix as in r304911 getaddrinfo.c
  qsort() can't be stabilized with just return(-1) alone.
  
  MFC after:  3 days

Modified:
  head/lib/libc/net/name6.c

Modified: head/lib/libc/net/name6.c
==
--- head/lib/libc/net/name6.c   Wed Aug 31 15:32:52 2016(r305132)
+++ head/lib/libc/net/name6.c   Wed Aug 31 15:47:58 2016(r305133)
@@ -185,6 +185,7 @@ struct hp_order {
 #define aio_sa aio_un.aiou_sa
int aio_matchlen;
char *aio_h_addr;
+   int aio_initial_sequence;
 };
 
 static struct   hostent *_hpcopy(struct hostent *, int *);
@@ -711,6 +712,7 @@ _hpreorder(struct hostent *hp)
aio[i].aio_dstscope = gai_addr2scopetype(sa);
aio[i].aio_dstpolicy = match_addrselectpolicy(sa, &policyhead);
set_source(&aio[i], &policyhead);
+   aio[i].aio_initial_sequence = i;
}
 
/* perform sorting. */
@@ -1045,6 +1047,23 @@ comp_dst(const void *arg1, const void *a
}
 
/* Rule 10: Otherwise, leave the order unchanged. */
+
+   /* 
+* Note that qsort is unstable; so, we can't return zero and 
+* expect the order to be unchanged.
+* That also means we can't depend on the current position of
+* dst2 being after dst1.  We must enforce the initial order
+* with an explicit compare on the original position.
+* The qsort specification requires that "When the same objects 
+* (consisting of width bytes, irrespective of their current 
+* positions in the array) are passed more than once to the 
+* comparison function, the results shall be consistent with one 
+* another."  
+* In other words, If A < B, then we must also return B > A.
+*/
+   if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+   return(1);
+
return(-1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305038 - stable/11/lib/libc/net

2016-08-29 Thread Andrey A. Chernov
Author: ache
Date: Tue Aug 30 01:01:41 2016
New Revision: 305038
URL: https://svnweb.freebsd.org/changeset/base/305038

Log:
  MFC r304911
  
  The formal behavior of qsort is unstable with regard to objects that
  are equal. Unfortunately, RFC 3484 requires that otherwise equal objects
  remain in the order supplied by the DNS server. The present code attempts
  to deal with this by returning -1 for objects that are equal (i.e.,
  returns that the first parameter is less then the second parameter).
  Unfortunately, the qsort API does not state that the first parameter
  passed in is in any particular position in the list.
  
  PR: 212122
  Submitted by:   herbie.robin...@stratus.com

Modified:
  stable/11/lib/libc/net/getaddrinfo.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/net/getaddrinfo.c
==
--- stable/11/lib/libc/net/getaddrinfo.cTue Aug 30 00:57:57 2016
(r305037)
+++ stable/11/lib/libc/net/getaddrinfo.cTue Aug 30 01:01:41 2016
(r305038)
@@ -224,6 +224,7 @@ struct ai_order {
struct policyqueue *aio_dstpolicy;
struct addrinfo *aio_ai;
int aio_matchlen;
+   int aio_initial_sequence;
 };
 
 static const ns_src default_dns_files[] = {
@@ -708,6 +709,7 @@ reorder(struct addrinfo *sentinel)
aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr,
  &policyhead);
set_source(&aio[i], &policyhead);
+   aio[i].aio_initial_sequence = i;
}
 
/* perform sorting. */
@@ -1066,6 +1068,23 @@ comp_dst(const void *arg1, const void *a
}
 
/* Rule 10: Otherwise, leave the order unchanged. */
+
+   /* 
+* Note that qsort is unstable; so, we can't return zero and 
+* expect the order to be unchanged.
+* That also means we can't depend on the current position of
+* dst2 being after dst1.  We must enforce the initial order
+* with an explicit compare on the original position.
+* The qsort specification requires that "When the same objects 
+* (consisting of width bytes, irrespective of their current 
+* positions in the array) are passed more than once to the 
+* comparison function, the results shall be consistent with one 
+* another."  
+* In other words, If A < B, then we must also return B > A.
+*/
+   if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+   return(1);
+
return(-1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r305037 - stable/10/lib/libc/net

2016-08-29 Thread Andrey A. Chernov
Author: ache
Date: Tue Aug 30 00:57:57 2016
New Revision: 305037
URL: https://svnweb.freebsd.org/changeset/base/305037

Log:
  MFC r304911
  
  The formal behavior of qsort is unstable with regard to objects that
  are equal. Unfortunately, RFC 3484 requires that otherwise equal objects
  remain in the order supplied by the DNS server. The present code attempts
  to deal with this by returning -1 for objects that are equal (i.e.,
  returns that the first parameter is less then the second parameter).
  Unfortunately, the qsort API does not state that the first parameter
  passed in is in any particular position in the list.
  
  PR: 212122
  Submitted by:   herbie.robin...@stratus.com

Modified:
  stable/10/lib/libc/net/getaddrinfo.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/net/getaddrinfo.c
==
--- stable/10/lib/libc/net/getaddrinfo.cTue Aug 30 00:47:21 2016
(r305036)
+++ stable/10/lib/libc/net/getaddrinfo.cTue Aug 30 00:57:57 2016
(r305037)
@@ -207,6 +207,7 @@ struct ai_order {
struct policyqueue *aio_dstpolicy;
struct addrinfo *aio_ai;
int aio_matchlen;
+   int aio_initial_sequence;
 };
 
 static const ns_src default_dns_files[] = {
@@ -690,6 +691,7 @@ reorder(struct addrinfo *sentinel)
aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr,
  &policyhead);
set_source(&aio[i], &policyhead);
+   aio[i].aio_initial_sequence = i;
}
 
/* perform sorting. */
@@ -1048,6 +1050,23 @@ comp_dst(const void *arg1, const void *a
}
 
/* Rule 10: Otherwise, leave the order unchanged. */
+
+   /* 
+* Note that qsort is unstable; so, we can't return zero and 
+* expect the order to be unchanged.
+* That also means we can't depend on the current position of
+* dst2 being after dst1.  We must enforce the initial order
+* with an explicit compare on the original position.
+* The qsort specification requires that "When the same objects 
+* (consisting of width bytes, irrespective of their current 
+* positions in the array) are passed more than once to the 
+* comparison function, the results shall be consistent with one 
+* another."  
+* In other words, If A < B, then we must also return B > A.
+*/
+   if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+   return(1);
+
return(-1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304911 - head/lib/libc/net

2016-08-27 Thread Andrey A. Chernov
Author: ache
Date: Sat Aug 27 14:43:13 2016
New Revision: 304911
URL: https://svnweb.freebsd.org/changeset/base/304911

Log:
  The formal behavior of qsort is unstable with regard to objects that
  are equal. Unfortunately, RFC 3484 requires that otherwise equal objects
  remain in the order supplied by the DNS server. The present code attempts
  to deal with this by returning -1 for objects that are equal (i.e.,
  returns that the first parameter is less then the second parameter).
  Unfortunately, the qsort API does not state that the first parameter
  passed in is in any particular position in the list.
  
  PR: 212122
  Submitted by:   herbie.robin...@stratus.com
  MFC after:  3 days

Modified:
  head/lib/libc/net/getaddrinfo.c

Modified: head/lib/libc/net/getaddrinfo.c
==
--- head/lib/libc/net/getaddrinfo.c Sat Aug 27 13:47:52 2016
(r304910)
+++ head/lib/libc/net/getaddrinfo.c Sat Aug 27 14:43:13 2016
(r304911)
@@ -224,6 +224,7 @@ struct ai_order {
struct policyqueue *aio_dstpolicy;
struct addrinfo *aio_ai;
int aio_matchlen;
+   int aio_initial_sequence;
 };
 
 static const ns_src default_dns_files[] = {
@@ -708,6 +709,7 @@ reorder(struct addrinfo *sentinel)
aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr,
  &policyhead);
set_source(&aio[i], &policyhead);
+   aio[i].aio_initial_sequence = i;
}
 
/* perform sorting. */
@@ -1066,6 +1068,23 @@ comp_dst(const void *arg1, const void *a
}
 
/* Rule 10: Otherwise, leave the order unchanged. */
+
+   /* 
+* Note that qsort is unstable; so, we can't return zero and 
+* expect the order to be unchanged.
+* That also means we can't depend on the current position of
+* dst2 being after dst1.  We must enforce the initial order
+* with an explicit compare on the original position.
+* The qsort specification requires that "When the same objects 
+* (consisting of width bytes, irrespective of their current 
+* positions in the array) are passed more than once to the 
+* comparison function, the results shall be consistent with one 
+* another."  
+* In other words, If A < B, then we must also return B > A.
+*/
+   if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+   return(1);
+
return(-1);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304896 - stable/11/lib/libc/stdio

2016-08-27 Thread Andrey A. Chernov
Author: ache
Date: Sat Aug 27 11:07:57 2016
New Revision: 304896
URL: https://svnweb.freebsd.org/changeset/base/304896

Log:
  MFC r304607,r304641,r304819,r304811
  
  1) Don't forget to set __SERR on __slbexpand() error.
  
  2) Remove "Fast path" from fgetwc()/fputwc() since it can't detect
  encoding errors and ignores them all.
  One of affected encoding example: US-ASCII
  
  3)  Original fgetln() from 44lite return success for line tail errors,
  i.e. partial line, but set __SERR and errno in the same time, which
  is inconsistent.
  Now both OpenBSD and NetBSD return failure, i.e. no line and set error
  indicators for such case, so make our fgetln() and fgetwln()
  (as its wide version) compatible with the rest of *BSD.
  
  PR: 212033

Modified:
  stable/11/lib/libc/stdio/fgetln.c
  stable/11/lib/libc/stdio/fgetwc.c
  stable/11/lib/libc/stdio/fgetwln.c
  stable/11/lib/libc/stdio/fputwc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdio/fgetln.c
==
--- stable/11/lib/libc/stdio/fgetln.c   Sat Aug 27 11:06:06 2016
(r304895)
+++ stable/11/lib/libc/stdio/fgetln.c   Sat Aug 27 11:07:57 2016
(r304896)
@@ -139,8 +139,11 @@ fgetln(FILE *fp, size_t *lenp)
(void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
len - off);
off = len;
-   if (__srefill(fp))
-   break;  /* EOF or error: return partial line */
+   if (__srefill(fp)) {
+   if (__sfeof(fp))
+   break;
+   goto error;
+   }
if ((p = memchr((void *)fp->_p, '\n', (size_t)fp->_r)) == NULL)
continue;
 

Modified: stable/11/lib/libc/stdio/fgetwc.c
==
--- stable/11/lib/libc/stdio/fgetwc.c   Sat Aug 27 11:06:06 2016
(r304895)
+++ stable/11/lib/libc/stdio/fgetwc.c   Sat Aug 27 11:07:57 2016
(r304896)
@@ -79,18 +79,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
size_t nconv;
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
 
-   if (fp->_r <= 0 && __srefill(fp)) {
-   *nread = 0;
-   return (WEOF);
-   }
-   if (MB_CUR_MAX == 1) {
-   /* Fast path for single-byte encodings. */
-   wc = *fp->_p++;
-   fp->_r--;
-   *nread = 1;
-   return (wc);
-   }
*nread = 0;
+   if (fp->_r <= 0 && __srefill(fp))
+   return (WEOF);
do {
nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs);
if (nconv == (size_t)-1)

Modified: stable/11/lib/libc/stdio/fgetwln.c
==
--- stable/11/lib/libc/stdio/fgetwln.c  Sat Aug 27 11:06:06 2016
(r304895)
+++ stable/11/lib/libc/stdio/fgetwln.c  Sat Aug 27 11:07:57 2016
(r304896)
@@ -56,13 +56,15 @@ fgetwln_l(FILE * __restrict fp, size_t *
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
if (len * sizeof(wchar_t) >= fp->_lb._size &&
-   __slbexpand(fp, (len + GROW) * sizeof(wchar_t)))
+   __slbexpand(fp, (len + GROW) * sizeof(wchar_t))) {
+   fp->_flags |= __SERR;
goto error;
+   }
*((wchar_t *)fp->_lb._base + len++) = wc;
if (wc == L'\n')
break;
}
-   if (len == 0)
+   if (len == 0 || (wc == WEOF && !__sfeof(fp)))
goto error;
 
FUNLOCKFILE(fp);
@@ -74,6 +76,7 @@ error:
*lenp = 0;
return (NULL);
 }
+
 wchar_t *
 fgetwln(FILE * __restrict fp, size_t *lenp)
 {

Modified: stable/11/lib/libc/stdio/fputwc.c
==
--- stable/11/lib/libc/stdio/fputwc.c   Sat Aug 27 11:06:06 2016
(r304895)
+++ stable/11/lib/libc/stdio/fputwc.c   Sat Aug 27 11:07:57 2016
(r304896)
@@ -53,19 +53,9 @@ __fputwc(wchar_t wc, FILE *fp, locale_t 
size_t i, len;
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
 
-   if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
-   /*
-* Assume single-byte locale with no special encoding.
-* A more careful test would be to check
-* _CurrentRuneLocale->encoding.
-*/
-   *buf = (unsigned char)wc;
-   len = 1;
-   } else {
-   if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) 
{
-   fp->_flags |= __SERR;
-   return (WEOF);
-   }
+   if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
+

svn commit: r304893 - stable/10/lib/libc/stdio

2016-08-27 Thread Andrey A. Chernov
Author: ache
Date: Sat Aug 27 10:34:01 2016
New Revision: 304893
URL: https://svnweb.freebsd.org/changeset/base/304893

Log:
  MFC r304607,r304641,r304819,r304811
  
  1) Don't forget to set __SERR on __slbexpand() error.
  
  2) Remove "Fast path" from fgetwc()/fputwc() since it can't detect
  encoding errors and ignores them all.
  One of affected encoding example: US-ASCII
  
  3)  Original fgetln() from 44lite return success for line tail errors,
  i.e. partial line, but set __SERR and errno in the same time, which
  is inconsistent.
  Now both OpenBSD and NetBSD return failure, i.e. no line and set error
  indicators for such case, so make our fgetln() and fgetwln()
  (as its wide version) compatible with the rest of *BSD.
  
  PR: 212033

Modified:
  stable/10/lib/libc/stdio/fgetln.c
  stable/10/lib/libc/stdio/fgetwc.c
  stable/10/lib/libc/stdio/fgetwln.c
  stable/10/lib/libc/stdio/fputwc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdio/fgetln.c
==
--- stable/10/lib/libc/stdio/fgetln.c   Sat Aug 27 10:30:20 2016
(r304892)
+++ stable/10/lib/libc/stdio/fgetln.c   Sat Aug 27 10:34:01 2016
(r304893)
@@ -139,8 +139,11 @@ fgetln(FILE *fp, size_t *lenp)
(void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
len - off);
off = len;
-   if (__srefill(fp))
-   break;  /* EOF or error: return partial line */
+   if (__srefill(fp)) {
+   if (__sfeof(fp))
+   break;
+   goto error;
+   }
if ((p = memchr((void *)fp->_p, '\n', (size_t)fp->_r)) == NULL)
continue;
 

Modified: stable/10/lib/libc/stdio/fgetwc.c
==
--- stable/10/lib/libc/stdio/fgetwc.c   Sat Aug 27 10:30:20 2016
(r304892)
+++ stable/10/lib/libc/stdio/fgetwc.c   Sat Aug 27 10:34:01 2016
(r304893)
@@ -79,18 +79,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
size_t nconv;
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
 
-   if (fp->_r <= 0 && __srefill(fp)) {
-   *nread = 0;
-   return (WEOF);
-   }
-   if (MB_CUR_MAX == 1) {
-   /* Fast path for single-byte encodings. */
-   wc = *fp->_p++;
-   fp->_r--;
-   *nread = 1;
-   return (wc);
-   }
*nread = 0;
+   if (fp->_r <= 0 && __srefill(fp))
+   return (WEOF);
do {
nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs);
if (nconv == (size_t)-1)

Modified: stable/10/lib/libc/stdio/fgetwln.c
==
--- stable/10/lib/libc/stdio/fgetwln.c  Sat Aug 27 10:30:20 2016
(r304892)
+++ stable/10/lib/libc/stdio/fgetwln.c  Sat Aug 27 10:34:01 2016
(r304893)
@@ -56,13 +56,15 @@ fgetwln_l(FILE * __restrict fp, size_t *
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
if (len * sizeof(wchar_t) >= fp->_lb._size &&
-   __slbexpand(fp, (len + GROW) * sizeof(wchar_t)))
+   __slbexpand(fp, (len + GROW) * sizeof(wchar_t))) {
+   fp->_flags |= __SERR;
goto error;
+   }
*((wchar_t *)fp->_lb._base + len++) = wc;
if (wc == L'\n')
break;
}
-   if (len == 0)
+   if (len == 0 || (wc == WEOF && !__sfeof(fp)))
goto error;
 
FUNLOCKFILE(fp);
@@ -74,6 +76,7 @@ error:
*lenp = 0;
return (NULL);
 }
+
 wchar_t *
 fgetwln(FILE * __restrict fp, size_t *lenp)
 {

Modified: stable/10/lib/libc/stdio/fputwc.c
==
--- stable/10/lib/libc/stdio/fputwc.c   Sat Aug 27 10:30:20 2016
(r304892)
+++ stable/10/lib/libc/stdio/fputwc.c   Sat Aug 27 10:34:01 2016
(r304893)
@@ -53,19 +53,9 @@ __fputwc(wchar_t wc, FILE *fp, locale_t 
size_t i, len;
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
 
-   if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
-   /*
-* Assume single-byte locale with no special encoding.
-* A more careful test would be to check
-* _CurrentRuneLocale->encoding.
-*/
-   *buf = (unsigned char)wc;
-   len = 1;
-   } else {
-   if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) 
{
-   fp->_flags |= __SERR;
-   return (WEOF);
-   }
+   if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
+

svn commit: r304890 - stable/11/lib/libc/stdio

2016-08-27 Thread Andrey A. Chernov
Author: ache
Date: Sat Aug 27 10:00:36 2016
New Revision: 304890
URL: https://svnweb.freebsd.org/changeset/base/304890

Log:
  MFC r304810
  
  Don't check for __SERR which may stick from one of any previous stdio
  functions.
  __SERR is for user and the rest of stdio code do not check it
  for error sensing internally, only set it.
  In vf(w)printf.c here it is more easy to save __SERR, clear and restore it.

Modified:
  stable/11/lib/libc/stdio/getdelim.c
  stable/11/lib/libc/stdio/vfprintf.c
  stable/11/lib/libc/stdio/vfwprintf.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/stdio/getdelim.c
==
--- stable/11/lib/libc/stdio/getdelim.c Sat Aug 27 10:00:33 2016
(r304889)
+++ stable/11/lib/libc/stdio/getdelim.c Sat Aug 27 10:00:36 2016
(r304890)
@@ -125,7 +125,7 @@ getdelim(char ** __restrict linep, size_
 
if (fp->_r <= 0 && __srefill(fp)) {
/* If fp is at EOF already, we just need space for the NUL. */
-   if (__sferror(fp) || expandtofit(linep, 1, linecapp))
+   if (!__sfeof(fp) || expandtofit(linep, 1, linecapp))
goto error;
FUNLOCKFILE(fp);
(*linep)[0] = '\0';
@@ -137,7 +137,7 @@ getdelim(char ** __restrict linep, size_
if (sappend(linep, &linelen, linecapp, fp->_p, fp->_r))
goto error;
if (__srefill(fp)) {
-   if (__sferror(fp))
+   if (!__sfeof(fp))
goto error;
goto done;  /* hit EOF */
}

Modified: stable/11/lib/libc/stdio/vfprintf.c
==
--- stable/11/lib/libc/stdio/vfprintf.c Sat Aug 27 10:00:33 2016
(r304889)
+++ stable/11/lib/libc/stdio/vfprintf.c Sat Aug 27 10:00:36 2016
(r304890)
@@ -364,6 +364,7 @@ __vfprintf(FILE *fp, locale_t locale, co
int nextarg;/* 1-based argument index */
va_list orgap;  /* original argument pointer */
char *convbuf;  /* wide to multibyte conversion result */
+   int savserr;
 
static const char xdigs_lower[16] = "0123456789abcdef";
static const char xdigs_upper[16] = "0123456789ABCDEF";
@@ -460,6 +461,9 @@ __vfprintf(FILE *fp, locale_t locale, co
return (EOF);
}
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
convbuf = NULL;
fmt = (char *)fmt0;
argtable = NULL;
@@ -1031,6 +1035,8 @@ error:
free(convbuf);
if (__sferror(fp))
ret = EOF;
+   else
+   fp->_flags |= savserr;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
return (ret);

Modified: stable/11/lib/libc/stdio/vfwprintf.c
==
--- stable/11/lib/libc/stdio/vfwprintf.cSat Aug 27 10:00:33 2016
(r304889)
+++ stable/11/lib/libc/stdio/vfwprintf.cSat Aug 27 10:00:36 2016
(r304890)
@@ -444,6 +444,7 @@ __vfwprintf(FILE *fp, locale_t locale, c
int nextarg;/* 1-based argument index */
va_list orgap;  /* original argument pointer */
wchar_t *convbuf;   /* multibyte to wide conversion result */
+   int savserr;
 
static const char xdigs_lower[16] = "0123456789abcdef";
static const char xdigs_upper[16] = "0123456789ABCDEF";
@@ -536,6 +537,9 @@ __vfwprintf(FILE *fp, locale_t locale, c
return (EOF);
}
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
convbuf = NULL;
fmt = (wchar_t *)fmt0;
argtable = NULL;
@@ -1096,6 +1100,8 @@ error:
free(convbuf);
if (__sferror(fp))
ret = EOF;
+   else
+   fp->_flags |= savserr;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
return (ret);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304888 - stable/10/lib/libc/stdio

2016-08-27 Thread Andrey A. Chernov
Author: ache
Date: Sat Aug 27 09:58:06 2016
New Revision: 304888
URL: https://svnweb.freebsd.org/changeset/base/304888

Log:
  MFC r304810
  
  Don't check for __SERR which may stick from one of any previous stdio
  functions.
  __SERR is for user and the rest of stdio code do not check it
  for error sensing internally, only set it.
  In vf(w)printf.c here it is more easy to save __SERR, clear and restore it.

Modified:
  stable/10/lib/libc/stdio/getdelim.c
  stable/10/lib/libc/stdio/vfprintf.c
  stable/10/lib/libc/stdio/vfwprintf.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdio/getdelim.c
==
--- stable/10/lib/libc/stdio/getdelim.c Sat Aug 27 09:51:57 2016
(r304887)
+++ stable/10/lib/libc/stdio/getdelim.c Sat Aug 27 09:58:06 2016
(r304888)
@@ -125,7 +125,7 @@ getdelim(char ** __restrict linep, size_
 
if (fp->_r <= 0 && __srefill(fp)) {
/* If fp is at EOF already, we just need space for the NUL. */
-   if (__sferror(fp) || expandtofit(linep, 1, linecapp))
+   if (!__sfeof(fp) || expandtofit(linep, 1, linecapp))
goto error;
FUNLOCKFILE(fp);
(*linep)[0] = '\0';
@@ -137,7 +137,7 @@ getdelim(char ** __restrict linep, size_
if (sappend(linep, &linelen, linecapp, fp->_p, fp->_r))
goto error;
if (__srefill(fp)) {
-   if (__sferror(fp))
+   if (!__sfeof(fp))
goto error;
goto done;  /* hit EOF */
}

Modified: stable/10/lib/libc/stdio/vfprintf.c
==
--- stable/10/lib/libc/stdio/vfprintf.c Sat Aug 27 09:51:57 2016
(r304887)
+++ stable/10/lib/libc/stdio/vfprintf.c Sat Aug 27 09:58:06 2016
(r304888)
@@ -364,6 +364,7 @@ __vfprintf(FILE *fp, locale_t locale, co
int nextarg;/* 1-based argument index */
va_list orgap;  /* original argument pointer */
char *convbuf;  /* wide to multibyte conversion result */
+   int savserr;
 
static const char xdigs_lower[16] = "0123456789abcdef";
static const char xdigs_upper[16] = "0123456789ABCDEF";
@@ -460,6 +461,9 @@ __vfprintf(FILE *fp, locale_t locale, co
return (EOF);
}
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
convbuf = NULL;
fmt = (char *)fmt0;
argtable = NULL;
@@ -1031,6 +1035,8 @@ error:
free(convbuf);
if (__sferror(fp))
ret = EOF;
+   else
+   fp->_flags |= savserr;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
return (ret);

Modified: stable/10/lib/libc/stdio/vfwprintf.c
==
--- stable/10/lib/libc/stdio/vfwprintf.cSat Aug 27 09:51:57 2016
(r304887)
+++ stable/10/lib/libc/stdio/vfwprintf.cSat Aug 27 09:58:06 2016
(r304888)
@@ -444,6 +444,7 @@ __vfwprintf(FILE *fp, locale_t locale, c
int nextarg;/* 1-based argument index */
va_list orgap;  /* original argument pointer */
wchar_t *convbuf;   /* multibyte to wide conversion result */
+   int savserr;
 
static const char xdigs_lower[16] = "0123456789abcdef";
static const char xdigs_upper[16] = "0123456789ABCDEF";
@@ -536,6 +537,9 @@ __vfwprintf(FILE *fp, locale_t locale, c
return (EOF);
}
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
convbuf = NULL;
fmt = (wchar_t *)fmt0;
argtable = NULL;
@@ -1096,6 +1100,8 @@ error:
free(convbuf);
if (__sferror(fp))
ret = EOF;
+   else
+   fp->_flags |= savserr;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
return (ret);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304865 - stable/11/sys/sys

2016-08-26 Thread Andrey A. Chernov
Author: ache
Date: Fri Aug 26 21:28:24 2016
New Revision: 304865
URL: https://svnweb.freebsd.org/changeset/base/304865

Log:
  Bump __FreeBSD_version after LC_*_MASK fix

Modified:
  stable/11/sys/sys/param.h

Modified: stable/11/sys/sys/param.h
==
--- stable/11/sys/sys/param.h   Fri Aug 26 21:26:33 2016(r304864)
+++ stable/11/sys/sys/param.h   Fri Aug 26 21:28:24 2016(r304865)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100501  /* Master, propagated to newvers */
+#define __FreeBSD_version 1100502  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304864 - stable/10/sys/sys

2016-08-26 Thread Andrey A. Chernov
Author: ache
Date: Fri Aug 26 21:26:33 2016
New Revision: 304864
URL: https://svnweb.freebsd.org/changeset/base/304864

Log:
  Bump __FreeBSD_version after LC_*_MASK fix

Modified:
  stable/10/sys/sys/param.h

Modified: stable/10/sys/sys/param.h
==
--- stable/10/sys/sys/param.h   Fri Aug 26 21:23:38 2016(r304863)
+++ stable/10/sys/sys/param.h   Fri Aug 26 21:26:33 2016(r304864)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1003506  /* Master, propagated to newvers */
+#define __FreeBSD_version 1003507  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304863 - in stable/11: include/xlocale lib/libc/nls

2016-08-26 Thread Andrey A. Chernov
Author: ache
Date: Fri Aug 26 21:23:38 2016
New Revision: 304863
URL: https://svnweb.freebsd.org/changeset/base/304863

Log:
  MFC r304703, r304755
  
  1) _locale.h
  LC_*_MASK bit shifting order was partially broken from the initial commit
  time at year 2012. Only LC_COLLATE_MASK and LC_CTYPE_MASK are in the
  right order.
  
  The order here should match XLC_* from "xlocale_private.h" which, in turn,
  match LC_* publicly visible order from  which determines how
  locale components are stored in the structure.
  LC_*_MASK -> XLC_* translation done as "ffs(mask) - 1" in the querylocale()
  and equivalent shift loop in the newlocale(), so mapped to some wrong
  components (excluding two mentioned above).
  
  Formally the fix is ABI breakage, but old code using those masks
  never works properly in any case.
  Only newlocale() and querylocale() are affected.
  
  2) msgcat.c
  Use current locale (f.e. set by thread). It was global locale always
  previously.
  
  PR: 211743

Modified:
  stable/11/include/xlocale/_locale.h
  stable/11/lib/libc/nls/msgcat.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/include/xlocale/_locale.h
==
--- stable/11/include/xlocale/_locale.h Fri Aug 26 21:19:23 2016
(r304862)
+++ stable/11/include/xlocale/_locale.h Fri Aug 26 21:23:38 2016
(r304863)
@@ -32,12 +32,13 @@
 #ifndef _XLOCALE_LOCALE_H
 #define _XLOCALE_LOCALE_H
 
+/* Bit shifting order of LC_*_MASK should match XLC_* and LC_* order. */
 #define LC_COLLATE_MASK  (1<<0)
 #define LC_CTYPE_MASK(1<<1)
-#define LC_MESSAGES_MASK (1<<2)
-#define LC_MONETARY_MASK (1<<3)
-#define LC_NUMERIC_MASK  (1<<4)
-#define LC_TIME_MASK (1<<5)
+#define LC_MONETARY_MASK (1<<2)
+#define LC_NUMERIC_MASK  (1<<3)
+#define LC_TIME_MASK (1<<4)
+#define LC_MESSAGES_MASK (1<<5)
 #define LC_ALL_MASK  (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | 
\
  LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
 #define LC_GLOBAL_LOCALE ((locale_t)-1)

Modified: stable/11/lib/libc/nls/msgcat.c
==
--- stable/11/lib/libc/nls/msgcat.c Fri Aug 26 21:19:23 2016
(r304862)
+++ stable/11/lib/libc/nls/msgcat.c Fri Aug 26 21:23:38 2016
(r304863)
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -56,7 +55,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include "un-namespace.h"
 
-#include "../locale/setlocale.h"/* for ENCODING_LEN */
+#include "../locale/xlocale_private.h"
 
 #define _DEFAULT_NLS_PATH 
"/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"
 
@@ -115,9 +114,10 @@ catopen(const char *name, int type)
 {
struct stat sbuf;
struct catentry *np;
-   char *base, *cptr, *cptr1, *lang, *nlspath, *pathP, *pcode;
-   char *plang, *pter, *tmpptr;
+   char *base, *cptr, *cptr1, *nlspath, *pathP, *pcode;
+   char *plang, *pter;
int saverr, spcleft;
+   const char *lang, *tmpptr;
char path[PATH_MAX];
 
/* sanity checking */
@@ -129,7 +129,7 @@ catopen(const char *name, int type)
lang = NULL;
else {
if (type == NL_CAT_LOCALE)
-   lang = setlocale(LC_MESSAGES, NULL);
+   lang = querylocale(LC_MESSAGES_MASK, __get_locale());
else
lang = getenv("LANG");
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304862 - in stable/10: include/xlocale lib/libc/nls

2016-08-26 Thread Andrey A. Chernov
Author: ache
Date: Fri Aug 26 21:19:23 2016
New Revision: 304862
URL: https://svnweb.freebsd.org/changeset/base/304862

Log:
  MFC r304703, r304755
  
  1) _locale.h
  LC_*_MASK bit shifting order was partially broken from the initial commit
  time at year 2012. Only LC_COLLATE_MASK and LC_CTYPE_MASK are in the
  right order.
  
  The order here should match XLC_* from "xlocale_private.h" which, in turn,
  match LC_* publicly visible order from  which determines how
  locale components are stored in the structure.
  LC_*_MASK -> XLC_* translation done as "ffs(mask) - 1" in the querylocale()
  and equivalent shift loop in the newlocale(), so mapped to some wrong
  components (excluding two mentioned above).
  
  Formally the fix is ABI breakage, but old code using those masks
  never works properly in any case.
  Only newlocale() and querylocale() are affected.
  
  2) msgcat.c
  Use current locale (f.e. set by thread). It was global locale always
  previously.
  
  PR: 211743

Modified:
  stable/10/include/xlocale/_locale.h
  stable/10/lib/libc/nls/msgcat.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/include/xlocale/_locale.h
==
--- stable/10/include/xlocale/_locale.h Fri Aug 26 20:51:09 2016
(r304861)
+++ stable/10/include/xlocale/_locale.h Fri Aug 26 21:19:23 2016
(r304862)
@@ -32,12 +32,13 @@
 #ifndef _XLOCALE_LOCALE_H
 #define _XLOCALE_LOCALE_H
 
+/* Bit shifting order of LC_*_MASK should match XLC_* and LC_* order. */
 #define LC_COLLATE_MASK  (1<<0)
 #define LC_CTYPE_MASK(1<<1)
-#define LC_MESSAGES_MASK (1<<2)
-#define LC_MONETARY_MASK (1<<3)
-#define LC_NUMERIC_MASK  (1<<4)
-#define LC_TIME_MASK (1<<5)
+#define LC_MONETARY_MASK (1<<2)
+#define LC_NUMERIC_MASK  (1<<3)
+#define LC_TIME_MASK (1<<4)
+#define LC_MESSAGES_MASK (1<<5)
 #define LC_ALL_MASK  (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | 
\
  LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
 #define LC_GLOBAL_LOCALE ((locale_t)-1)

Modified: stable/10/lib/libc/nls/msgcat.c
==
--- stable/10/lib/libc/nls/msgcat.c Fri Aug 26 20:51:09 2016
(r304861)
+++ stable/10/lib/libc/nls/msgcat.c Fri Aug 26 21:19:23 2016
(r304862)
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -56,7 +55,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include "un-namespace.h"
 
-#include "../locale/setlocale.h"/* for ENCODING_LEN */
+#include "../locale/xlocale_private.h"
 
 #define _DEFAULT_NLS_PATH 
"/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"
 
@@ -115,9 +114,10 @@ catopen(const char *name, int type)
 {
struct stat sbuf;
struct catentry *np;
-   char *base, *cptr, *cptr1, *lang, *nlspath, *pathP, *pcode;
-   char *plang, *pter, *tmpptr;
+   char *base, *cptr, *cptr1, *nlspath, *pathP, *pcode;
+   char *plang, *pter;
int saverr, spcleft;
+   const char *lang, *tmpptr;
char path[PATH_MAX];
 
/* sanity checking */
@@ -129,7 +129,7 @@ catopen(const char *name, int type)
lang = NULL;
else {
if (type == NL_CAT_LOCALE)
-   lang = setlocale(LC_MESSAGES, NULL);
+   lang = querylocale(LC_MESSAGES_MASK, __get_locale());
else
lang = getenv("LANG");
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304819 - head/lib/libc/stdio

2016-08-25 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 25 21:14:26 2016
New Revision: 304819
URL: https://svnweb.freebsd.org/changeset/base/304819

Log:
  Original fgetln() from 44lite return sucess for line tail errors,
  i.e. partial line, but set __SERR and errno in the same time, which
  is inconsistent.
  Now both OpenBSD and NetBSD return failure, i.e. no line and set error
  indicators for such case, so make our fgetln() and fgetwln()
  (as its wide version) compatible with the rest of *BSD.
  
  PR: 212033
  MFC after:  7 days

Modified:
  head/lib/libc/stdio/fgetln.c
  head/lib/libc/stdio/fgetwln.c

Modified: head/lib/libc/stdio/fgetln.c
==
--- head/lib/libc/stdio/fgetln.cThu Aug 25 21:13:16 2016
(r304818)
+++ head/lib/libc/stdio/fgetln.cThu Aug 25 21:14:26 2016
(r304819)
@@ -139,8 +139,11 @@ fgetln(FILE *fp, size_t *lenp)
(void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
len - off);
off = len;
-   if (__srefill(fp))
-   break;  /* EOF or error: return partial line */
+   if (__srefill(fp)) {
+   if (__sfeof(fp))
+   break;
+   goto error;
+   }
if ((p = memchr((void *)fp->_p, '\n', (size_t)fp->_r)) == NULL)
continue;
 

Modified: head/lib/libc/stdio/fgetwln.c
==
--- head/lib/libc/stdio/fgetwln.c   Thu Aug 25 21:13:16 2016
(r304818)
+++ head/lib/libc/stdio/fgetwln.c   Thu Aug 25 21:14:26 2016
(r304819)
@@ -53,7 +53,6 @@ fgetwln_l(FILE * __restrict fp, size_t *
ORIENT(fp, 1);
 
len = 0;
-   /* WEOF or error: return partial line, see fgetln(3). */
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
if (len * sizeof(wchar_t) >= fp->_lb._size &&
@@ -65,7 +64,7 @@ fgetwln_l(FILE * __restrict fp, size_t *
if (wc == L'\n')
break;
}
-   if (len == 0)
+   if (len == 0 || (wc == WEOF && !__sfeof(fp)))
goto error;
 
FUNLOCKFILE(fp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304816 - stable/10/lib/libc/stdio

2016-08-25 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 25 19:55:31 2016
New Revision: 304816
URL: https://svnweb.freebsd.org/changeset/base/304816

Log:
  MFC r295632
  
  getln: We cannot expand the buffer beyond INT_MAX (_size overflows).
  
  In such cases return ENOMEM. This is a limitation of our
  implementation, alternatively you may consider getline(3).
  
  Differential Revision:  https://reviews.freebsd.org/D442 (Partial)
  Obtained from:  Apple Inc. (Libc 997.90.3)

Modified:
  stable/10/lib/libc/stdio/fgetln.3
  stable/10/lib/libc/stdio/fgetln.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdio/fgetln.3
==
--- stable/10/lib/libc/stdio/fgetln.3   Thu Aug 25 19:40:25 2016
(r304815)
+++ stable/10/lib/libc/stdio/fgetln.3   Thu Aug 25 19:55:31 2016
(r304816)
@@ -28,7 +28,7 @@
 .\" @(#)fgetln.3   8.3 (Berkeley) 4/19/94
 .\" $FreeBSD$
 .\"
-.Dd April 19, 1994
+.Dd February 15, 2016
 .Dt FGETLN 3
 .Os
 .Sh NAME
@@ -97,6 +97,9 @@ These changes are lost as soon as the po
 The argument
 .Fa stream
 is not a stream open for reading.
+.It Bq Er ENOMEM
+The internal line buffer could not be expanded due to lack of available memory,
+or because it would need to expand beyond INT_MAX in size.
 .El
 .Pp
 The

Modified: stable/10/lib/libc/stdio/fgetln.c
==
--- stable/10/lib/libc/stdio/fgetln.c   Thu Aug 25 19:40:25 2016
(r304815)
+++ stable/10/lib/libc/stdio/fgetln.c   Thu Aug 25 19:55:31 2016
(r304816)
@@ -37,6 +37,8 @@ static char sccsid[] = "@(#)fgetln.c  8.2
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -61,6 +63,10 @@ __slbexpand(FILE *fp, size_t newsize)
 #endif
if (fp->_lb._size >= newsize)
return (0);
+   if (newsize > INT_MAX) {
+   errno = ENOMEM;
+   return (-1);
+   }
if ((p = realloc(fp->_lb._base, newsize)) == NULL)
return (-1);
fp->_lb._base = p;
@@ -152,7 +158,7 @@ fgetln(FILE *fp, size_t *lenp)
}
*lenp = len;
 #ifdef notdef
-   fp->_lb._base[len] = 0;
+   fp->_lb._base[len] = '\0';
 #endif
FUNLOCKFILE(fp);
return ((char *)fp->_lb._base);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304811 - head/lib/libc/stdio

2016-08-25 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 25 17:30:00 2016
New Revision: 304811
URL: https://svnweb.freebsd.org/changeset/base/304811

Log:
  Remove "Fast path", it bypass __wcrtomb() and all its error checking.
  One of affected encoding example: US-ASCII
  
  MFC after:  7 days

Modified:
  head/lib/libc/stdio/fputwc.c

Modified: head/lib/libc/stdio/fputwc.c
==
--- head/lib/libc/stdio/fputwc.cThu Aug 25 17:13:04 2016
(r304810)
+++ head/lib/libc/stdio/fputwc.cThu Aug 25 17:30:00 2016
(r304811)
@@ -53,19 +53,9 @@ __fputwc(wchar_t wc, FILE *fp, locale_t 
size_t i, len;
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
 
-   if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
-   /*
-* Assume single-byte locale with no special encoding.
-* A more careful test would be to check
-* _CurrentRuneLocale->encoding.
-*/
-   *buf = (unsigned char)wc;
-   len = 1;
-   } else {
-   if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) 
{
-   fp->_flags |= __SERR;
-   return (WEOF);
-   }
+   if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
+   fp->_flags |= __SERR;
+   return (WEOF);
}
 
for (i = 0; i < len; i++)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304810 - head/lib/libc/stdio

2016-08-25 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 25 17:13:04 2016
New Revision: 304810
URL: https://svnweb.freebsd.org/changeset/base/304810

Log:
  Don't check for __SERR which may stick from one of any previous stdio
  functions.
  __SERR is for user and the rest of stdio code do not check it
  for error sensing internally, only set it.
  In vf(w)printf.c here it is more easy to save __SERR, clear and restore it.

Modified:
  head/lib/libc/stdio/getdelim.c
  head/lib/libc/stdio/vfprintf.c
  head/lib/libc/stdio/vfwprintf.c

Modified: head/lib/libc/stdio/getdelim.c
==
--- head/lib/libc/stdio/getdelim.c  Thu Aug 25 17:07:43 2016
(r304809)
+++ head/lib/libc/stdio/getdelim.c  Thu Aug 25 17:13:04 2016
(r304810)
@@ -125,7 +125,7 @@ getdelim(char ** __restrict linep, size_
 
if (fp->_r <= 0 && __srefill(fp)) {
/* If fp is at EOF already, we just need space for the NUL. */
-   if (__sferror(fp) || expandtofit(linep, 1, linecapp))
+   if (!__sfeof(fp) || expandtofit(linep, 1, linecapp))
goto error;
FUNLOCKFILE(fp);
(*linep)[0] = '\0';
@@ -137,7 +137,7 @@ getdelim(char ** __restrict linep, size_
if (sappend(linep, &linelen, linecapp, fp->_p, fp->_r))
goto error;
if (__srefill(fp)) {
-   if (__sferror(fp))
+   if (!__sfeof(fp))
goto error;
goto done;  /* hit EOF */
}

Modified: head/lib/libc/stdio/vfprintf.c
==
--- head/lib/libc/stdio/vfprintf.c  Thu Aug 25 17:07:43 2016
(r304809)
+++ head/lib/libc/stdio/vfprintf.c  Thu Aug 25 17:13:04 2016
(r304810)
@@ -364,6 +364,7 @@ __vfprintf(FILE *fp, locale_t locale, co
int nextarg;/* 1-based argument index */
va_list orgap;  /* original argument pointer */
char *convbuf;  /* wide to multibyte conversion result */
+   int savserr;
 
static const char xdigs_lower[16] = "0123456789abcdef";
static const char xdigs_upper[16] = "0123456789ABCDEF";
@@ -460,6 +461,9 @@ __vfprintf(FILE *fp, locale_t locale, co
return (EOF);
}
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
convbuf = NULL;
fmt = (char *)fmt0;
argtable = NULL;
@@ -1031,6 +1035,8 @@ error:
free(convbuf);
if (__sferror(fp))
ret = EOF;
+   else
+   fp->_flags |= savserr;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
return (ret);

Modified: head/lib/libc/stdio/vfwprintf.c
==
--- head/lib/libc/stdio/vfwprintf.c Thu Aug 25 17:07:43 2016
(r304809)
+++ head/lib/libc/stdio/vfwprintf.c Thu Aug 25 17:13:04 2016
(r304810)
@@ -444,6 +444,7 @@ __vfwprintf(FILE *fp, locale_t locale, c
int nextarg;/* 1-based argument index */
va_list orgap;  /* original argument pointer */
wchar_t *convbuf;   /* multibyte to wide conversion result */
+   int savserr;
 
static const char xdigs_lower[16] = "0123456789abcdef";
static const char xdigs_upper[16] = "0123456789ABCDEF";
@@ -536,6 +537,9 @@ __vfwprintf(FILE *fp, locale_t locale, c
return (EOF);
}
 
+   savserr = fp->_flags & __SERR;
+   fp->_flags &= ~__SERR;
+
convbuf = NULL;
fmt = (wchar_t *)fmt0;
argtable = NULL;
@@ -1096,6 +1100,8 @@ error:
free(convbuf);
if (__sferror(fp))
ret = EOF;
+   else
+   fp->_flags |= savserr;
if ((argtable != NULL) && (argtable != statargtable))
free (argtable);
return (ret);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304755 - head/lib/libc/nls

2016-08-24 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 24 16:44:27 2016
New Revision: 304755
URL: https://svnweb.freebsd.org/changeset/base/304755

Log:
  Use current locale (f.e. set by thread). It was global locale always
  previously.
  
  MFC after:  7 days

Modified:
  head/lib/libc/nls/msgcat.c

Modified: head/lib/libc/nls/msgcat.c
==
--- head/lib/libc/nls/msgcat.c  Wed Aug 24 16:40:29 2016(r304754)
+++ head/lib/libc/nls/msgcat.c  Wed Aug 24 16:44:27 2016(r304755)
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -56,7 +55,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include "un-namespace.h"
 
-#include "../locale/setlocale.h"/* for ENCODING_LEN */
+#include "../locale/xlocale_private.h"
 
 #define _DEFAULT_NLS_PATH 
"/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"
 
@@ -115,9 +114,10 @@ catopen(const char *name, int type)
 {
struct stat sbuf;
struct catentry *np;
-   char *base, *cptr, *cptr1, *lang, *nlspath, *pathP, *pcode;
-   char *plang, *pter, *tmpptr;
+   char *base, *cptr, *cptr1, *nlspath, *pathP, *pcode;
+   char *plang, *pter;
int saverr, spcleft;
+   const char *lang, *tmpptr;
char path[PATH_MAX];
 
/* sanity checking */
@@ -129,7 +129,7 @@ catopen(const char *name, int type)
lang = NULL;
else {
if (type == NL_CAT_LOCALE)
-   lang = setlocale(LC_MESSAGES, NULL);
+   lang = querylocale(LC_MESSAGES_MASK, __get_locale());
else
lang = getenv("LANG");
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304752 - head/sys/sys

2016-08-24 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 24 15:36:48 2016
New Revision: 304752
URL: https://svnweb.freebsd.org/changeset/base/304752

Log:
  Bump __FreeBSD_version for LC_*_MASK fix for newlocale(3) and querylocale(3)

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hWed Aug 24 15:13:42 2016(r304751)
+++ head/sys/sys/param.hWed Aug 24 15:36:48 2016(r304752)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 123  /* Master, propagated to newvers */
+#define __FreeBSD_version 124  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304703 - head/include/xlocale

2016-08-23 Thread Andrey A. Chernov
Author: ache
Date: Tue Aug 23 20:33:56 2016
New Revision: 304703
URL: https://svnweb.freebsd.org/changeset/base/304703

Log:
  LC_*_MASK bit shifting order was partially broken from the initial commit
  time at year 2012. Only LC_COLLATE_MASK and LC_CTYPE_MASK are in the
  right order.
  
  The order here should match XLC_* from "xlocale_private.h" which, in turn,
  match LC_* publicly visible order from  which determines how
  locale components are stored in the structure.
  LC_*_MASK -> XLC_* translation done as "ffs(mask) - 1" in the querylocale()
  and equivalent shift loop in the newlocale(), so mapped to some wrong
  components (excluding two mentioned above).
  
  Formally the fix is ABI breakage, but old code using those masks
  never works properly in any case.
  Only newlocale() and querylocale() are affected.
  
  MFC after:  7 days

Modified:
  head/include/xlocale/_locale.h

Modified: head/include/xlocale/_locale.h
==
--- head/include/xlocale/_locale.h  Tue Aug 23 20:04:23 2016
(r304702)
+++ head/include/xlocale/_locale.h  Tue Aug 23 20:33:56 2016
(r304703)
@@ -32,12 +32,13 @@
 #ifndef _XLOCALE_LOCALE_H
 #define _XLOCALE_LOCALE_H
 
+/* Bit shifting order of LC_*_MASK should match XLC_* and LC_* order. */
 #define LC_COLLATE_MASK  (1<<0)
 #define LC_CTYPE_MASK(1<<1)
-#define LC_MESSAGES_MASK (1<<2)
-#define LC_MONETARY_MASK (1<<3)
-#define LC_NUMERIC_MASK  (1<<4)
-#define LC_TIME_MASK (1<<5)
+#define LC_MONETARY_MASK (1<<2)
+#define LC_NUMERIC_MASK  (1<<3)
+#define LC_TIME_MASK (1<<4)
+#define LC_MESSAGES_MASK (1<<5)
 #define LC_ALL_MASK  (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | 
\
  LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
 #define LC_GLOBAL_LOCALE ((locale_t)-1)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304648 - stable/10/lib/libc/stdio

2016-08-22 Thread Andrey A. Chernov
Author: ache
Date: Tue Aug 23 00:00:06 2016
New Revision: 304648
URL: https://svnweb.freebsd.org/changeset/base/304648

Log:
  Direct commit, equal to MFC part of r295632 which is not planned for
  MFC at whole.
  Set __SERR on  __slbexpand() errors.

Modified:
  stable/10/lib/libc/stdio/fgetln.c

Modified: stable/10/lib/libc/stdio/fgetln.c
==
--- stable/10/lib/libc/stdio/fgetln.c   Mon Aug 22 22:51:10 2016
(r304647)
+++ stable/10/lib/libc/stdio/fgetln.c   Tue Aug 23 00:00:06 2016
(r304648)
@@ -159,6 +159,7 @@ fgetln(FILE *fp, size_t *lenp)
 
 error:
*lenp = 0;  /* ??? */
+   fp->_flags |= __SERR;
FUNLOCKFILE(fp);
return (NULL);  /* ??? */
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304641 - head/lib/libc/stdio

2016-08-22 Thread Andrey A. Chernov
Author: ache
Date: Mon Aug 22 22:28:41 2016
New Revision: 304641
URL: https://svnweb.freebsd.org/changeset/base/304641

Log:
  1) Back out r304607 case 2). fgetwln() as its pair fgetln() supposed to
  return partial line on any errors. See the comment in fgetln.c.
  Add corresponding comment to fgetwln() too.
  2) Rewrite r304607 case 1).
  3) Remove "Fast path" from __fgetwc_mbs() since it can't detect encoding
  errors and ignores them all.
  
  PR: 212033
  MFC after:  7 days

Modified:
  head/lib/libc/stdio/fgetwc.c
  head/lib/libc/stdio/fgetwln.c

Modified: head/lib/libc/stdio/fgetwc.c
==
--- head/lib/libc/stdio/fgetwc.cMon Aug 22 21:49:17 2016
(r304640)
+++ head/lib/libc/stdio/fgetwc.cMon Aug 22 22:28:41 2016
(r304641)
@@ -79,18 +79,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, i
size_t nconv;
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
 
-   if (fp->_r <= 0 && __srefill(fp)) {
-   *nread = 0;
-   return (WEOF);
-   }
-   if (MB_CUR_MAX == 1) {
-   /* Fast path for single-byte encodings. */
-   wc = *fp->_p++;
-   fp->_r--;
-   *nread = 1;
-   return (wc);
-   }
*nread = 0;
+   if (fp->_r <= 0 && __srefill(fp))
+   return (WEOF);
do {
nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs);
if (nconv == (size_t)-1)

Modified: head/lib/libc/stdio/fgetwln.c
==
--- head/lib/libc/stdio/fgetwln.c   Mon Aug 22 21:49:17 2016
(r304640)
+++ head/lib/libc/stdio/fgetwln.c   Mon Aug 22 22:28:41 2016
(r304641)
@@ -33,7 +33,6 @@
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
-#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -48,39 +47,32 @@ fgetwln_l(FILE * __restrict fp, size_t *
 {
wint_t wc;
size_t len;
-   int saverrno;
FIX_LOCALE(locale);
 
FLOCKFILE(fp);
ORIENT(fp, 1);
 
len = 0;
-   saverrno = errno;
-   errno = 0;
+   /* WEOF or error: return partial line, see fgetln(3). */
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
if (len * sizeof(wchar_t) >= fp->_lb._size &&
-   __slbexpand(fp, (len + GROW) * sizeof(wchar_t)))
+   __slbexpand(fp, (len + GROW) * sizeof(wchar_t))) {
+   fp->_flags |= __SERR;
goto error;
+   }
*((wchar_t *)fp->_lb._base + len++) = wc;
if (wc == L'\n')
break;
-   errno = 0;
}
-   if (wc == WEOF && errno != 0)
-   goto error;
-   if (errno == 0)
-   errno = saverrno;
if (len == 0)
-   goto eof;
+   goto error;
 
FUNLOCKFILE(fp);
*lenp = len;
return ((wchar_t *)fp->_lb._base);
 
 error:
-   fp->_flags |= __SERR;
-eof:
FUNLOCKFILE(fp);
*lenp = 0;
return (NULL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304607 - head/lib/libc/stdio

2016-08-22 Thread Andrey A. Chernov
Author: ache
Date: Mon Aug 22 15:44:54 2016
New Revision: 304607
URL: https://svnweb.freebsd.org/changeset/base/304607

Log:
  Fix error processing.
  1) Don't forget to set __SERR on __slbexpand() error.
  2) Check for __fgetwc() errors using errno. Don't check for __SERR
  as PR suggested, it user-visible flag which can stick from previous
  functions and stdio code don't check it for this purpose.
  
  PR: 212033
  MFC after:  3 days

Modified:
  head/lib/libc/stdio/fgetwln.c

Modified: head/lib/libc/stdio/fgetwln.c
==
--- head/lib/libc/stdio/fgetwln.c   Mon Aug 22 15:27:37 2016
(r304606)
+++ head/lib/libc/stdio/fgetwln.c   Mon Aug 22 15:44:54 2016
(r304607)
@@ -33,6 +33,7 @@
 __FBSDID("$FreeBSD$");
 
 #include "namespace.h"
+#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -47,12 +48,15 @@ fgetwln_l(FILE * __restrict fp, size_t *
 {
wint_t wc;
size_t len;
+   int saverrno;
FIX_LOCALE(locale);
 
FLOCKFILE(fp);
ORIENT(fp, 1);
 
len = 0;
+   saverrno = errno;
+   errno = 0;
while ((wc = __fgetwc(fp, locale)) != WEOF) {
 #defineGROW512
if (len * sizeof(wchar_t) >= fp->_lb._size &&
@@ -61,19 +65,27 @@ fgetwln_l(FILE * __restrict fp, size_t *
*((wchar_t *)fp->_lb._base + len++) = wc;
if (wc == L'\n')
break;
+   errno = 0;
}
-   if (len == 0)
+   if (wc == WEOF && errno != 0)
goto error;
+   if (errno == 0)
+   errno = saverrno;
+   if (len == 0)
+   goto eof;
 
FUNLOCKFILE(fp);
*lenp = len;
return ((wchar_t *)fp->_lb._base);
 
 error:
+   fp->_flags |= __SERR;
+eof:
FUNLOCKFILE(fp);
*lenp = 0;
return (NULL);
 }
+
 wchar_t *
 fgetwln(FILE * __restrict fp, size_t *lenp)
 {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304379 - stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8

2016-08-18 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 18 10:37:20 2016
New Revision: 304379
URL: https://svnweb.freebsd.org/changeset/base/304379

Log:
  MFC r304374
  
  Fix TAB replaced with spaces in prev. commit.

Modified:
  stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan
==
--- stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan Thu Aug 
18 10:26:15 2016(r304378)
+++ stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan Thu Aug 
18 10:37:20 2016(r304379)
@@ -35,7 +35,7 @@ Paskha=Пасха
 14 сент.   День Волха Змеевича
 22 сент.*  Поворот к зиме (осеннее равноденствие)
 10 нояб.   День Макоши
-21 нояб.День Сварога и Семаргла
+21 нояб.   День Сварога и Семаргла
  9 дек.День Дажьбога и Марены
 
 #endif /* !_ru_RU_UTF_8_pagan_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r304374 - head/usr.bin/calendar/calendars/ru_RU.UTF-8

2016-08-18 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 18 10:18:11 2016
New Revision: 304374
URL: https://svnweb.freebsd.org/changeset/base/304374

Log:
  Fix TAB replaced with spaces in prev. commit.

Modified:
  head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan

Modified: head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan
==
--- head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan  Thu Aug 18 
09:39:45 2016(r304373)
+++ head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan  Thu Aug 18 
10:18:11 2016(r304374)
@@ -35,7 +35,7 @@ Paskha=Пасха
 14 сент.   День Волха Змеевича
 22 сент.*  Поворот к зиме (осеннее равноденствие)
 10 нояб.   День Макоши
-21 нояб.День Сварога и Семаргла
+21 нояб.   День Сварога и Семаргла
  9 дек.День Дажьбога и Марены
 
 #endif /* !_ru_RU_UTF_8_pagan_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r304343 - in stable/11/usr.bin/calendar/calendars: ru_RU.KOI8-R ru_RU.UTF-8

2016-08-18 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 18 08:52:55 2016
New Revision: 304343
URL: https://svnweb.freebsd.org/changeset/base/304343

Log:
  MFC r303581
  
  Fix date

Modified:
  stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
  stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
==
--- stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military Thu Aug 
18 08:49:02 2016(r304342)
+++ stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military Thu Aug 
18 08:52:55 2016(r304343)
@@ -20,7 +20,7 @@ LANG=ru_RU.KOI8-R
  8 .      ��� � ��� � �.�. 
 � ��� �� (1812 ���)
 11 .    �� ��� ��� ��� � �.�. ��� ��� 
  �  �� (1790 ���)
 21 .    �� ��� �� �� � � ��� ��  
��� ��� ���-��  � ��� � (1380 ���)
- 7 .     �� �� � � ��� 
 �� �� � ��� �� ��  ��� (1612 
���)
+ 4 .     �� �� � � ��� 
 �� �� � ��� �� ��  ��� (1612 
���)
  1 ���. �� ��� ��� ��� � �.�.  ��� 
  �  � (1853 ���)
  5 ���. ��  � � �� 
���-�� � � � ��� ��� (1941 ���)
 24 ���. ��   ��   ��� 
� �.�.  (1790 ���)

Modified: stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military
==
--- stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military  Thu Aug 
18 08:49:02 2016(r304342)
+++ stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military  Thu Aug 
18 08:52:55 2016(r304343)
@@ -20,7 +20,7 @@ LANG=ru_RU.UTF-8
  8 сент.   День Бородинского сражения русской армии под командованием М.И. 
Кутузова с французской армией (1812 год)
 11 сент.   День победы русской эскадры под командованием Ф.Ф. Ушакова над 
турецкой эскадрой у мыса Тендра (1790 год)
 21 сент.   День победы русских полков во главе с великим князем Дмитрием 
Донским над монголо-татарскими войсками в Куликовской битве (1380 год)
- 7 нояб.   День освобождения Москвы силами народного ополчения под 
руководством Кузьмы Минина и Дмитрия Пожарского от польских интервентов (1612 
год)
+ 4 нояб.   День освобождения Москвы силами народного ополчения под 
руководством Кузьмы Минина и Дмитрия Пожарского от польских интервентов (1612 
год)
  1 дек.День победы русской эскадры под командованием П.С. Нахимова над 
турецкой эскадрой у мыса Синоп (1853 год)
  5 дек.День начала контрнаступления советских войск против 
немецко-фашистских войск в битве под Москвой (1941 год)
 24 дек.День взятия турецкой крепости Измаил русскими войсками под 
командованием А.В. Суворова (1790 год)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r304341 - stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8

2016-08-18 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 18 08:47:06 2016
New Revision: 304341
URL: https://svnweb.freebsd.org/changeset/base/304341

Log:
  MFC r303568
  
  Remove another vestige of scripted conversion

Modified:
  stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan
==
--- stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan Thu Aug 
18 08:36:24 2016(r304340)
+++ stable/11/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan Thu Aug 
18 08:47:06 2016(r304341)
@@ -35,7 +35,7 @@ Paskha=Пасха
 14 сент.   День Волха Змеевича
 22 сент.*  Поворот к зиме (осеннее равноденствие)
 10 нояб.   День Макоши
-21 нояб.   День Сварога и Семартагла
+21 нояб.День Сварога и Семаргла
  9 дек.День Дажьбога и Марены
 
 #endif /* !_ru_RU_UTF_8_pagan_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r304340 - stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R

2016-08-18 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 18 08:36:24 2016
New Revision: 304340
URL: https://svnweb.freebsd.org/changeset/base/304340

Log:
  MFC r303569
  
  Reflect CLDR timedef changes

Modified:
  stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common
  stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.holiday   
(contents, props changed)
  stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
  stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox
  stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common
==
--- stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common   Thu Aug 
18 07:43:18 2016(r304339)
+++ stable/11/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common   Thu Aug 
18 08:36:24 2016(r304340)
@@ -9,97 +9,97 @@
 
 LANG=ru_RU.KOI8-R
 
-12 ���  � ���
-13 ���  �� ��
-14 ��� �� � ���
-21 ���  �� �
-25 ���  .  
- 8 ���  �� �
-10 ���   �
- 1 ��� �  ��� ���
+12 ���. � ���
+13 ���. �� ��
+14 ���.�� � ���
+21 ���. �� �
+25 ���. .  
+ 8 .    �� �
+10 .     �
+ 1 �   �  ��� ���
 03/SunSecond    ��  � ���
-11 ���  � ��� �
-18 ���  � ���
+11 �    � ��� �
+18 �    � ���
 03/SunThird �� ,   � � 
���-� �
-27 ��� �  ��
-27 ���  �� �
- 1 ���  �
- 2 ���   ���
+27 �   �  ��
+27 �    �� �
+ 1 ���. �
+ 2 ���.  ���
 04/SunFirst ���
-12 ���  
+12 ���. 
 04/SunSecond    �  ���
-26 ���  ��  �  ��� � ���
-30 ���   ��
- 7 ���  �
-17 ��� �  
-18 ��� �  ��
-24 ���  ��  � 
-26 ���  ��� ���
-27 ��� ��  �
-28 ���  
-30 ���   ��
-31 ���  �� ��
+26 ���. ��  �  ��� � ���
+30 ���.  ��
+ 7 ���  �
+17 ��� �  
+18 ��� �  ��
+24 ���  ��  � 
+26 ���  ��� ���
+27 ��� ��  �
+28 ���  
+30 ���   ��
+31 ���  �� ��
 05/SunLast  ��
- 1 ���  �� �
- 5 ���  ���
- 6 ��� �� 
- 8 ���  ��� �
+ 1  �� �
+ 5  ���
+ 6 �� 
+ 8  ��� �
 06/SunSecond    �� �� ��
 06/SunThird  �
-22 ���  �� � �� (�� ��� � �, 1941 ���)
-27 ���  
-29 ���   � 
+22  �� � �� (�� ��� � �, 1941 
���)
+27  
+29   � 
 06/SatLast   � ���
 07/SunFirst ��  � ��� �
 07/SunSecond    ��
 07/SunSecond    �� �
 07/SunThird ��
 07/SunLast  ��- �
-28 ���   
- 6 ���  ��� �
+28   
+ 6 ���. ��� �
 08/SunFirst 
-12 ���  ��-� ���
+12 ���. ��-� ���
 08/SunSecond    �
 08/SunThird �� �
-22 ���   �
-27 ���  
+22 ���.  �
+27 ���. 
 08/SunLast  ���
- 1 ���  ��
- 2 ���  �� ���
- 3 ���   � �� � ���
- 4 ���  ��� ��  ���
+ 1 .    ��
+ 2 .    �� ���
+ 3 .     � �� � ���
+ 4 .    ��� ��  ���
 09/SunFirst ��  � �

svn commit: r304339 - in stable/11/bin/sh: . tests/expansion

2016-08-18 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 18 07:43:18 2016
New Revision: 304339
URL: https://svnweb.freebsd.org/changeset/base/304339

Log:
  MFC r302937
  
  Path generation was not according to collate
  
  Approved by:jilles

Added:
  stable/11/bin/sh/tests/expansion/pathname6.0
 - copied unchanged from r302937, head/bin/sh/tests/expansion/pathname6.0
Modified:
  stable/11/bin/sh/expand.c
  stable/11/bin/sh/tests/expansion/Makefile
  stable/11/bin/sh/tests/expansion/pathname1.0
  stable/11/bin/sh/tests/expansion/pathname2.0
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/bin/sh/expand.c
==
--- stable/11/bin/sh/expand.c   Thu Aug 18 07:32:02 2016(r304338)
+++ stable/11/bin/sh/expand.c   Thu Aug 18 07:43:18 2016(r304339)
@@ -1196,7 +1196,7 @@ expsortcmp(const void *p1, const void *p
const char *s1 = *(const char * const *)p1;
const char *s2 = *(const char * const *)p2;
 
-   return (strcmp(s1, s2));
+   return (strcoll(s1, s2));
 }
 
 

Modified: stable/11/bin/sh/tests/expansion/Makefile
==
--- stable/11/bin/sh/tests/expansion/Makefile   Thu Aug 18 07:32:02 2016
(r304338)
+++ stable/11/bin/sh/tests/expansion/Makefile   Thu Aug 18 07:43:18 2016
(r304339)
@@ -66,6 +66,7 @@ ${PACKAGE}FILES+= pathname2.0
 ${PACKAGE}FILES+=  pathname3.0
 ${PACKAGE}FILES+=  pathname4.0
 ${PACKAGE}FILES+=  pathname5.0
+${PACKAGE}FILES+=  pathname6.0
 ${PACKAGE}FILES+=  plus-minus1.0
 ${PACKAGE}FILES+=  plus-minus2.0
 ${PACKAGE}FILES+=  plus-minus3.0

Modified: stable/11/bin/sh/tests/expansion/pathname1.0
==
--- stable/11/bin/sh/tests/expansion/pathname1.0Thu Aug 18 07:32:02 
2016(r304338)
+++ stable/11/bin/sh/tests/expansion/pathname1.0Thu Aug 18 07:43:18 
2016(r304339)
@@ -1,5 +1,9 @@
 # $FreeBSD$
 
+unset LC_ALL
+LC_COLLATE=C
+export LC_COLLATE
+
 failures=0
 
 check() {

Modified: stable/11/bin/sh/tests/expansion/pathname2.0
==
--- stable/11/bin/sh/tests/expansion/pathname2.0Thu Aug 18 07:32:02 
2016(r304338)
+++ stable/11/bin/sh/tests/expansion/pathname2.0Thu Aug 18 07:43:18 
2016(r304339)
@@ -1,5 +1,9 @@
 # $FreeBSD$
 
+unset LC_ALL
+LC_COLLATE=C
+export LC_COLLATE
+
 failures=0
 
 check() {

Copied: stable/11/bin/sh/tests/expansion/pathname6.0 (from r302937, 
head/bin/sh/tests/expansion/pathname6.0)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/11/bin/sh/tests/expansion/pathname6.0Thu Aug 18 07:43:18 
2016(r304339, copy of r302937, head/bin/sh/tests/expansion/pathname6.0)
@@ -0,0 +1,29 @@
+# $FreeBSD$
+
+unset LC_ALL
+LC_COLLATE=en_US.US-ASCII
+export LC_COLLATE
+
+failures=0
+
+check() {
+   testcase=$1
+   expect=$2
+   eval "set -- $testcase"
+   actual="$*"
+   if [ "$actual" != "$expect" ]; then
+   failures=$((failures+1))
+   printf '%s\n' "For $testcase, expected $expect actual $actual"
+   fi
+}
+
+set -e
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XX)
+trap 'rm -rf $T' 0
+cd -P $T
+
+touch A B a b
+
+check '*' 'a A b B'
+
+exit $((failures != 0))
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304284 - stable/11/lib/libc/gen

2016-08-17 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 17 09:34:56 2016
New Revision: 304284
URL: https://svnweb.freebsd.org/changeset/base/304284

Log:
  MFC r302943,r302944,r303004,r303010,r303011,r303013,r303014,r303074,
  r303088,r303142,r303208,r303210,r303530,r303536,r303564,r303565,
  r303706
  
  In short:
  
  1) All situations with glob(3) error return codes are well defined by
  POSIX, so rewrite old sporadic errors processing to match those
  definitions.
  
  Including subcases:
  
  Both C99 and POSIX directly prohibits any standard function to set errno
  to 0. Breaking this rule in 2001 NetBSD hack was imported which attempts
  to workaround very limited glob(3) return codes amount.
  Use POSIX-compatible workaround now with E2BIG which can't comes from
  other functions used instead of prohibited 0.
  
  Process errors happpens in (*readdirfunc)() too, as POSIX requires.
  
  Per POSIX GLOB_NOCHECK should return original pattern,
  unmodified, if no matches found. But our code strips all '\'
  returning it. Rewrite the code to allow to return original pattern.
  
  GLOB_ERR and gl_errfunc are supposed to work only for real directories
  per POSIX, so don't act on missing or plain files for ENOENT or ENOTDIR
  (as TODO in the code suggested).
  Remove the hack in the manpage describing how to skip ENOENT and ENOTDIR
  in gl_errfunc, it is unneeded now.
  
  Per POSIX GLOB_ERR must be considered even if gl_errfunc is not set,
  old code skips it in that case.
  
  2) For near MAXPATHLEN long pathes old glob(3) code can operate on
  truncated results, prevent it in several places.
  
  3) Results was not sorted according to collate as POSIX requires.
  
  4) globtilde() forget to convert expanded user home dir from multibyte to
  wide chars. Moreover, those chars are addded as not protected, so
  can be treated as special chars.
  
  5) Backward hack for EILSEQ in g_Ctoc() was not implemented, so all
  pathes with illegal byte sequences are skipped as result, implement it now.
  
  6) GLOB_BRACE was somehow broken. First it repeatedly calls glob0() in
  globexp1() recursive calls, but glob0() was not supposed to be called
  repeatedly in the original code. It finalize results by possible adding
  original pattern for no match case, may return GLOB_NOMATCH error and
  by sorting all things. Original pattern adding or GLOB_NOMATCH error
  can happens each time glob0() called repeatedly, and sorting happens
  for one item only, all things are never sorted. Second, f.e. "a{a"
  pattern does not match "a{a" file but match "a" file instead.
  Third, some errors (f.e. for limits or overflow) can be ignored
  by GLOB_BRACE code because it forces return (0).
  
  Add non-finalizing flag to glob0() and make globexp0() wrapper around
  recursively called globexp1() to finalize things like glob0() does.
  Reorganize braces code to work correctly.
  
  7) Don't allow MB_CUR_MAX * strlen overallocation hits GLOB_LIMIT_STRING
  (ARG_MAX) limit, use final string length, not malloced space for it.

Modified:
  stable/11/lib/libc/gen/glob.3
  stable/11/lib/libc/gen/glob.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/gen/glob.3
==
--- stable/11/lib/libc/gen/glob.3   Wed Aug 17 09:24:46 2016
(r304283)
+++ stable/11/lib/libc/gen/glob.3   Wed Aug 17 09:34:56 2016
(r304284)
@@ -275,24 +275,10 @@ is
 .Pf non- Dv NULL ,
 .Fn glob
 calls
-.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) .
-This may be unintuitive: a pattern like
-.Ql */Makefile
-will try to
-.Xr stat 2
-.Ql foo/Makefile
-even if
-.Ql foo
-is not a directory, resulting in a
-call to
-.Fa errfunc .
-The error routine can suppress this action by testing for
-.Er ENOENT
-and
-.Er ENOTDIR ;
+.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) ,
 however, the
 .Dv GLOB_ERR
-flag will still cause an immediate
+flag will cause an immediate
 return when this happens.
 .Pp
 If
@@ -377,7 +363,7 @@ file
 .It Dv GLOB_NOSPACE
 An attempt to allocate memory failed, or if
 .Fa errno
-was 0
+was E2BIG,
 .Dv GLOB_LIMIT
 was specified in the flags and
 .Fa pglob\->gl_matchc

Modified: stable/11/lib/libc/gen/glob.c
==
--- stable/11/lib/libc/gen/glob.c   Wed Aug 17 09:24:46 2016
(r304283)
+++ stable/11/lib/libc/gen/glob.c   Wed Aug 17 09:34:56 2016
(r304284)
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
  * 1. Patterns with illegal byte sequences match nothing - even if
  *GLOB_NOCHECK is specified.
  * 2. Illegal byte sequences in filenames are handled by treating them as
- *single-byte characters with a value of the first byte of the sequence
+ *single-byte characters with a values of such bytes of the sequence
  *cast to wchar_t.
  * 3. State-dependent encodings are not currently supported.
  */
@@ -113,25 +113,20 @@ struct glob_limit {
size_t  

svn commit: r304278 - stable/11/usr.bin/tr

2016-08-17 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 17 09:12:02 2016
New Revision: 304278
URL: https://svnweb.freebsd.org/changeset/base/304278

Log:
  MFC r302827
  
  Optimize [Cc]flag case: don't repeatedly add the last character of
  string2 to squeeze cset when string2 reach its EOS state.

Modified:
  stable/11/usr.bin/tr/tr.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/tr/tr.c
==
--- stable/11/usr.bin/tr/tr.c   Wed Aug 17 09:10:22 2016(r304277)
+++ stable/11/usr.bin/tr/tr.c   Wed Aug 17 09:12:02 2016(r304278)
@@ -272,10 +272,11 @@ endloop:
if (Cflag && !iswrune(cnt))
continue;
if (cmap_lookup(map, cnt) == OOBCH) {
-   if (next(&s2))
+   if (next(&s2)) {
cmap_add(map, cnt, s2.lastch);
-   if (sflag)
-   cset_add(squeeze, s2.lastch);
+   if (sflag)
+   cset_add(squeeze, s2.lastch);
+   }
} else
cmap_add(map, cnt, cnt);
if ((s2.state == EOS || s2.state == INFINITE) &&
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304277 - stable/11/usr.bin/tr

2016-08-17 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 17 09:10:22 2016
New Revision: 304277
URL: https://svnweb.freebsd.org/changeset/base/304277

Log:
  MFC r302826
  
  Document incomplete support of [=equiv=] and collation for ranges.

Modified:
  stable/11/usr.bin/tr/tr.1
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/tr/tr.1
==
--- stable/11/usr.bin/tr/tr.1   Wed Aug 17 09:07:43 2016(r304276)
+++ stable/11/usr.bin/tr/tr.1   Wed Aug 17 09:10:22 2016(r304277)
@@ -334,6 +334,10 @@ should be used instead of explicit chara
 and
 .Dq Li A-Z .
 .Pp
+.Dq Li [=equiv=]
+expression and collation for ranges
+are implemented for single byte locales only.
+.Pp
 System V has historically implemented character ranges using the syntax
 .Dq Li [c-c]
 instead of the
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304276 - stable/11/contrib/tcsh

2016-08-17 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 17 09:07:43 2016
New Revision: 304276
URL: https://svnweb.freebsd.org/changeset/base/304276

Log:
  MFC r302831
  
  To mimic system glob, we definitely don't need manual upper/lower hack.
  The author clearly disagree in the comment, so this patch will be not
  submitted upstream.

Modified:
  stable/11/contrib/tcsh/glob.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/tcsh/glob.c
==
--- stable/11/contrib/tcsh/glob.c   Wed Aug 17 08:51:47 2016
(r304275)
+++ stable/11/contrib/tcsh/glob.c   Wed Aug 17 09:07:43 2016
(r304276)
@@ -142,12 +142,14 @@ globcharcoll(__Char c1, __Char c2, int c
c1 = towlower(c1);
c2 = towlower(c2);
 } else {
+#ifndef __FreeBSD__
/* This should not be here, but I'll rather leave it in than engage in
   a LC_COLLATE flamewar about a shell I don't use... */
if (iswlower(c1) && iswupper(c2))
return (1);
if (iswupper(c1) && iswlower(c2))
return (-1);
+#endif
 }
 s1[0] = c1;
 s2[0] = c2;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304275 - in stable/11/lib/libc: gen locale regex stdio

2016-08-17 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 17 08:51:47 2016
New Revision: 304275
URL: https://svnweb.freebsd.org/changeset/base/304275

Log:
  MFC r302824
  
  1) Eliminate possibility to call __*collate_range_cmp() with inclomplete
  locale (which cause core dump) by removing whole 'table' argument
  by which it passed.
  
  2) Restore __collate_range_cmp() in __sccl().
  
  3) Collating [a-z] range in regcomp() work only for single bytes locales
  (we can't do it now for other ones). In previous code only first 256
  wchars are considered and all others are just silently dropped from the
  range.

Modified:
  stable/11/lib/libc/gen/fnmatch.c
  stable/11/lib/libc/gen/glob.c
  stable/11/lib/libc/locale/collate.h
  stable/11/lib/libc/locale/collcmp.c
  stable/11/lib/libc/regex/regcomp.c
  stable/11/lib/libc/stdio/vfscanf.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libc/gen/fnmatch.c
==
--- stable/11/lib/libc/gen/fnmatch.cWed Aug 17 08:51:41 2016
(r304274)
+++ stable/11/lib/libc/gen/fnmatch.cWed Aug 17 08:51:47 2016
(r304275)
@@ -296,8 +296,8 @@ rangematch(const char *pattern, wchar_t 
 
if (table->__collate_load_error ?
c <= test && test <= c2 :
-  __wcollate_range_cmp(table, c, test) <= 0
-   && __wcollate_range_cmp(table, test, c2) <= 0
+  __wcollate_range_cmp(c, test) <= 0
+   && __wcollate_range_cmp(test, c2) <= 0
   )
ok = 1;
} else if (c == test)

Modified: stable/11/lib/libc/gen/glob.c
==
--- stable/11/lib/libc/gen/glob.c   Wed Aug 17 08:51:41 2016
(r304274)
+++ stable/11/lib/libc/gen/glob.c   Wed Aug 17 08:51:47 2016
(r304275)
@@ -832,8 +832,8 @@ match(Char *name, Char *pat, Char *paten
if ((*pat & M_MASK) == M_RNG) {
if (table->__collate_load_error ?
CHAR(c) <= CHAR(k) && CHAR(k) <= 
CHAR(pat[1]) :
-  __wcollate_range_cmp(table, 
CHAR(c), CHAR(k)) <= 0
-   && __wcollate_range_cmp(table, 
CHAR(k), CHAR(pat[1])) <= 0
+  __wcollate_range_cmp(CHAR(c), 
CHAR(k)) <= 0
+   && __wcollate_range_cmp(CHAR(k), 
CHAR(pat[1])) <= 0
   )
ok = 1;
pat += 2;

Modified: stable/11/lib/libc/locale/collate.h
==
--- stable/11/lib/libc/locale/collate.h Wed Aug 17 08:51:41 2016
(r304274)
+++ stable/11/lib/libc/locale/collate.h Wed Aug 17 08:51:47 2016
(r304275)
@@ -128,8 +128,8 @@ int __collate_load_tables(const char *);
 int__collate_equiv_value(locale_t, const wchar_t *, size_t);
 void   _collate_lookup(struct xlocale_collate *,const wchar_t *, int *, int *,
int, const int **);
-int__collate_range_cmp(struct xlocale_collate *, char, char);
-int__wcollate_range_cmp(struct xlocale_collate *, wchar_t, wchar_t);
+int__collate_range_cmp(char, char);
+int__wcollate_range_cmp(wchar_t, wchar_t);
 size_t _collate_wxfrm(struct xlocale_collate *, const wchar_t *, wchar_t *,
size_t);
 size_t _collate_sxfrm(struct xlocale_collate *, const wchar_t *, char *,

Modified: stable/11/lib/libc/locale/collcmp.c
==
--- stable/11/lib/libc/locale/collcmp.c Wed Aug 17 08:51:41 2016
(r304274)
+++ stable/11/lib/libc/locale/collcmp.c Wed Aug 17 08:51:47 2016
(r304275)
@@ -34,14 +34,13 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include "collate.h"
 
 /*
  * Compare two characters using collate
  */
 
-int __collate_range_cmp(struct xlocale_collate *table, char c1, char c2)
+int __collate_range_cmp(char c1, char c2)
 {
char s1[2], s2[2];
 
@@ -49,12 +48,10 @@ int __collate_range_cmp(struct xlocale_c
s1[1] = '\0';
s2[0] = c2;
s2[1] = '\0';
-   struct _xlocale l = {{0}};
-   l.components[XLC_COLLATE] = (struct xlocale_component *)table;
-   return (strcoll_l(s1, s2, &l));
+   return (strcoll(s1, s2));
 }
 
-int __wcollate_range_cmp(struct xlocale_collate *table, wchar_t c1, wchar_t c2)
+int __wcollate_range_cmp(wchar_t c1, wchar_t c2)
 {
wchar_t s1[2], s2[2];
 
@@ -62,7 +59,5 @@ int __wcollate_range_cmp(struct xlocale_
s1[1] = L'\0';
s2[0] = c2;
s2[1] = L'\0';
-   struct _xlocale l = {{0}};

svn commit: r304272 - stable/11/usr.bin

2016-08-17 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug 17 08:37:40 2016
New Revision: 304272
URL: https://svnweb.freebsd.org/changeset/base/304272

Log:
  MFC r303094
  
  Continuation lines with comments badly affects gprof, it is excluded from
  build on amd64 f.e.

Modified:
  stable/11/usr.bin/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/Makefile
==
--- stable/11/usr.bin/Makefile  Wed Aug 17 08:29:30 2016(r304271)
+++ stable/11/usr.bin/Makefile  Wed Aug 17 08:37:40 2016(r304272)
@@ -270,8 +270,9 @@ SUBDIR.${MK_TOOLCHAIN}+=ctags
 SUBDIR.${MK_TOOLCHAIN}+=   cxxfilt
 SUBDIR.${MK_TOOLCHAIN}+=   elfcopy
 SUBDIR.${MK_TOOLCHAIN}+=   file2c
-.if ${MACHINE_ARCH} != "aarch64" && \ # ARM64TODO gprof does not build
-${MACHINE_CPUARCH} != "riscv" # RISCVTODO gprof does not build
+# ARM64TODO gprof does not build
+# RISCVTODO gprof does not build
+.if ${MACHINE_ARCH} != "aarch64" && ${MACHINE_CPUARCH} != "riscv"
 SUBDIR.${MK_TOOLCHAIN}+=   gprof
 .endif
 SUBDIR.${MK_TOOLCHAIN}+=   indent
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r304203 - stable/10/lib/libc/gen

2016-08-16 Thread Andrey A. Chernov
Author: ache
Date: Tue Aug 16 07:14:09 2016
New Revision: 304203
URL: https://svnweb.freebsd.org/changeset/base/304203

Log:
  MFC r302943,r302944,r303004,r303010,r303011,r303013,r303014,r303074,
  r303088,r303142,r303208,r303210,r303530,r303536,r303564,r303565,
  r303706
  
  In short:
  
  1) All situations with glob(3) error return codes are well defined by
  POSIX, so rewrite old sporadic errors processing to match those
  definitions.
  
  Including subcases:
  
  Both C99 and POSIX directly prohibits any standard function to set errno
  to 0. Breaking this rule in 2001 NetBSD hack was imported which attempts
  to workaround very limited glob(3) return codes amount.
  Use POSIX-compatible workaround now with E2BIG which can't comes from
  other functions used instead of prohibited 0.
  
  Process errors happpens in (*readdirfunc)() too, as POSIX requires.
  
  Per POSIX GLOB_NOCHECK should return original pattern,
  unmodified, if no matches found. But our code strips all '\'
  returning it. Rewrite the code to allow to return original pattern.
  
  GLOB_ERR and gl_errfunc are supposed to work only for real directories
  per POSIX, so don't act on missing or plain files for ENOENT or ENOTDIR
  (as TODO in the code suggested).
  Remove the hack in the manpage describing how to skip ENOENT and ENOTDIR
  in gl_errfunc, it is unneeded now.
  
  Per POSIX GLOB_ERR must be considered even if gl_errfunc is not set,
  old code skips it in that case.
  
  2) For near MAXPATHLEN long pathes old glob(3) code can operate on
  truncated results, prevent it in several places.
  
  3) Results was not sorted according to collate as POSIX requires.
  
  4) globtilde() forget to convert expanded user home dir from multibyte to
  wide chars. Moreover, those chars are addded as not protected, so
  can be treated as special chars.
  
  5) Backward hack for EILSEQ in g_Ctoc() was not implemented, so all
  pathes with illegal byte sequences are skipped as result, implement it now.
  
  6) GLOB_BRACE was somehow broken. First it repeatedly calls glob0() in
  globexp1() recursive calls, but glob0() was not supposed to be called
  repeatedly in the original code. It finalize results by possible adding
  original pattern for no match case, may return GLOB_NOMATCH error and
  by sorting all things. Original pattern adding or GLOB_NOMATCH error
  can happens each time glob0() called repeatedly, and sorting happens
  for one item only, all things are never sorted. Second, f.e. "a{a"
  pattern does not match "a{a" file but match "a" file instead.
  Third, some errors (f.e. for limits or overflow) can be ignored
  by GLOB_BRACE code because it forces return (0).
  
  Add non-finalizing flag to glob0() and make globexp0() wrapper around
  recursively called globexp1() to finalize things like glob0() does.
  Reorganize braces code to work correctly.
  
  7) Don't allow MB_CUR_MAX * strlen overallocation hits GLOB_LIMIT_STRING
  (ARG_MAX) limit, use final string length, not malloced space for it.

Modified:
  stable/10/lib/libc/gen/glob.3
  stable/10/lib/libc/gen/glob.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/glob.3
==
--- stable/10/lib/libc/gen/glob.3   Tue Aug 16 06:40:27 2016
(r304202)
+++ stable/10/lib/libc/gen/glob.3   Tue Aug 16 07:14:09 2016
(r304203)
@@ -275,24 +275,10 @@ is
 .Pf non- Dv NULL ,
 .Fn glob
 calls
-.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) .
-This may be unintuitive: a pattern like
-.Ql */Makefile
-will try to
-.Xr stat 2
-.Ql foo/Makefile
-even if
-.Ql foo
-is not a directory, resulting in a
-call to
-.Fa errfunc .
-The error routine can suppress this action by testing for
-.Er ENOENT
-and
-.Er ENOTDIR ;
+.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) ,
 however, the
 .Dv GLOB_ERR
-flag will still cause an immediate
+flag will cause an immediate
 return when this happens.
 .Pp
 If
@@ -377,7 +363,7 @@ file
 .It Dv GLOB_NOSPACE
 An attempt to allocate memory failed, or if
 .Fa errno
-was 0
+was E2BIG,
 .Dv GLOB_LIMIT
 was specified in the flags and
 .Fa pglob\->gl_matchc

Modified: stable/10/lib/libc/gen/glob.c
==
--- stable/10/lib/libc/gen/glob.c   Tue Aug 16 06:40:27 2016
(r304202)
+++ stable/10/lib/libc/gen/glob.c   Tue Aug 16 07:14:09 2016
(r304203)
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
  * 1. Patterns with illegal byte sequences match nothing - even if
  *GLOB_NOCHECK is specified.
  * 2. Illegal byte sequences in filenames are handled by treating them as
- *single-byte characters with a value of the first byte of the sequence
+ *single-byte characters with a values of such bytes of the sequence
  *cast to wchar_t.
  * 3. State-dependent encodings are not currently supported.
  */
@@ -113,25 +113,20 @@ struct glob_limit {
size_t  

svn commit: r303706 - head/lib/libc/gen

2016-08-03 Thread Andrey A. Chernov
Author: ache
Date: Wed Aug  3 09:09:34 2016
New Revision: 303706
URL: https://svnweb.freebsd.org/changeset/base/303706

Log:
  Although the code amount is not big, move POSIX error processing into
  two sepatate functions to make glob(3) code less obscure and more simple.
  There is no needs to make them inline since it is error path which supposed
  to not happes often.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cWed Aug  3 08:57:15 2016(r303705)
+++ head/lib/libc/gen/glob.cWed Aug  3 09:09:34 2016(r303706)
@@ -177,6 +177,8 @@ static int   globexp2(const Char *, const
 static int  globfinal(glob_t *, struct glob_limit *, size_t,
 const char *);
 static int  match(Char *, Char *, Char *);
+static int  err_nomatch(glob_t *, struct glob_limit *, const char *);
+static int  err_aborted(glob_t *, int, char *);
 #ifdef DEBUG
 static void qprintf(const char *, Char *);
 #endif
@@ -217,8 +219,7 @@ glob(const char * __restrict pattern, in
while (bufnext <= bufend) {
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
-   return (globfinal(pglob, &limit,
-   pglob->gl_pathc, pattern));
+   return (err_nomatch(pglob, &limit, pattern));
else if (clen == 0) {
too_long = 0;
break;
@@ -240,8 +241,7 @@ glob(const char * __restrict pattern, in
prot = 0;
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
-   return (globfinal(pglob, &limit,
-   pglob->gl_pathc, pattern));
+   return (err_nomatch(pglob, &limit, pattern));
else if (clen == 0) {
too_long = 0;
break;
@@ -251,7 +251,7 @@ glob(const char * __restrict pattern, in
}
}
if (too_long)
-   return (globfinal(pglob, &limit, pglob->gl_pathc, pattern));
+   return (err_nomatch(pglob, &limit, pattern));
*bufnext = EOS;
 
if (flags & GLOB_BRACE)
@@ -608,20 +608,9 @@ glob0(const Char *pattern, glob_t *pglob
 static int
 globfinal(glob_t *pglob, struct glob_limit *limit, size_t oldpathc,
 const char *origpat) {
-   /*
-* If there was no match we are going to append the origpat
-* if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
-* and the origpat did not contain any magic characters
-* GLOB_NOMAGIC is there just for compatibility with csh.
-*/
-   if (pglob->gl_pathc == oldpathc) {
-   if ((pglob->gl_flags & GLOB_NOCHECK) ||
-   ((pglob->gl_flags & GLOB_NOMAGIC) &&
-   !(pglob->gl_flags & GLOB_MAGCHAR)))
-   return (globextend(NULL, pglob, limit, origpat));
-   else
-   return (GLOB_NOMATCH);
-   }
+   if (pglob->gl_pathc == oldpathc)
+   return (err_nomatch(pglob, limit, origpat));
+
if (!(pglob->gl_flags & GLOB_NOSORT))
qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
pglob->gl_pathc - oldpathc, sizeof(char *), compare);
@@ -750,16 +739,10 @@ glob3(Char *pathbuf, Char *pathend, Char
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
if (errno == ENOENT || errno == ENOTDIR)
return (0);
-   if ((pglob->gl_errfunc != NULL &&
-   pglob->gl_errfunc(buf, errno)) ||
-   (pglob->gl_flags & GLOB_ERR)) {
-   if (errno == 0)
-   errno = saverrno;
-   return (GLOB_ABORTED);
-   }
+   err = err_aborted(pglob, errno, buf);
if (errno == 0)
errno = saverrno;
-   return (0);
+   return (err);
}
 
err = 0;
@@ -809,11 +792,9 @@ glob3(Char *pathbuf, Char *pathend, Char
}
sc += clen;
}
-   if (too_long && ((pglob->gl_errfunc != NULL &&
-   pglob->gl_errfunc(buf, ENAMETOOLONG)) ||
-   (pglob->gl_flags & GLOB_ERR))) {
+   if (too_long && (err = err_aborted(pglob, ENAMETOOLONG,
+   buf))) {
errno = ENAMETOOLONG;
-   err = GLOB_ABORTED;
break;
}
if (too_long || !m

svn commit: r303582 - in stable/10/usr.bin/calendar/calendars: ru_RU.KOI8-R ru_RU.UTF-8

2016-07-31 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 31 10:37:09 2016
New Revision: 303582
URL: https://svnweb.freebsd.org/changeset/base/303582

Log:
  Direct commit of adapted r303581.
  Fix date.

Modified:
  stable/10/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
  stable/10/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military

Modified: stable/10/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
==
--- stable/10/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military Sun Jul 
31 10:15:04 2016(r303581)
+++ stable/10/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military Sun Jul 
31 10:37:09 2016(r303582)
@@ -20,7 +20,7 @@ LANG=ru_RU.KOI8-R
  8 ���    ��� � ��� � �.�. 
 � ��� �� (1812 ���)
 11 ���  �� ��� ��� ��� � �.�. ��� ���  
 �  �� (1790 ���)
 21 ���  �� ��� �� �� � � ��� ��  ��� 
��� ���-��  � ��� � (1380 ���)
- 7 ���   �� �� � � ���  
�� �� � ��� �� ��  ��� (1612 ���)
+ 4 ���   �� �� � � ���  
�� �� � ��� �� ��  ��� (1612 ���)
  1 ���  �� ��� ��� ��� � �.�.  ��� 
  �  � (1853 ���)
  5 ���  ��  � � �� ���-�� 
� � � ��� ��� (1941 ���)
 24 ���  ��   ��   ��� 
� �.�.  (1790 ���)

Modified: stable/10/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military
==
--- stable/10/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military  Sun Jul 
31 10:15:04 2016(r303581)
+++ stable/10/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military  Sun Jul 
31 10:37:09 2016(r303582)
@@ -20,7 +20,7 @@ LANG=ru_RU.UTF-8
  8 сен День Бородинского сражения русской армии под командованием М.И. 
Кутузова с французской армией (1812 год)
 11 сен День победы русской эскадры под командованием Ф.Ф. Ушакова над турецкой 
эскадрой у мыса Тендра (1790 год)
 21 сен День победы русских полков во главе с великим князем Дмитрием Донским 
над монголо-татарскими войсками в Куликовской битве (1380 год)
- 7 ноя День освобождения Москвы силами народного ополчения под руководством 
Кузьмы Минина и Дмитрия Пожарского от польских интервентов (1612 год)
+ 4 ноя День освобождения Москвы силами народного ополчения под руководством 
Кузьмы Минина и Дмитрия Пожарского от польских интервентов (1612 год)
  1 дек День победы русской эскадры под командованием П.С. Нахимова над 
турецкой эскадрой у мыса Синоп (1853 год)
  5 дек День начала контрнаступления советских войск против немецко-фашистских 
войск в битве под Москвой (1941 год)
 24 дек День взятия турецкой крепости Измаил русскими войсками под 
командованием А.В. Суворова (1790 год)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r303581 - in head/usr.bin/calendar/calendars: ru_RU.KOI8-R ru_RU.UTF-8

2016-07-31 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 31 10:15:04 2016
New Revision: 303581
URL: https://svnweb.freebsd.org/changeset/base/303581

Log:
  Fix date

Modified:
  head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
  head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military

Modified: head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
==
--- head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military  Sun Jul 
31 08:05:15 2016(r303580)
+++ head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military  Sun Jul 
31 10:15:04 2016(r303581)
@@ -20,7 +20,7 @@ LANG=ru_RU.KOI8-R
  8 .      ��� � ��� � �.�. 
 � ��� �� (1812 ���)
 11 .    �� ��� ��� ��� � �.�. ��� ��� 
  �  �� (1790 ���)
 21 .    �� ��� �� �� � � ��� ��  
��� ��� ���-��  � ��� � (1380 ���)
- 7 .     �� �� � � ��� 
 �� �� � ��� �� ��  ��� (1612 
���)
+ 4 .     �� �� � � ��� 
 �� �� � ��� �� ��  ��� (1612 
���)
  1 ���. �� ��� ��� ��� � �.�.  ��� 
  �  � (1853 ���)
  5 ���. ��  � � �� 
���-�� � � � ��� ��� (1941 ���)
 24 ���. ��   ��   ��� 
� �.�.  (1790 ���)

Modified: head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military
==
--- head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military   Sun Jul 
31 08:05:15 2016(r303580)
+++ head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.military   Sun Jul 
31 10:15:04 2016(r303581)
@@ -20,7 +20,7 @@ LANG=ru_RU.UTF-8
  8 сент.   День Бородинского сражения русской армии под командованием М.И. 
Кутузова с французской армией (1812 год)
 11 сент.   День победы русской эскадры под командованием Ф.Ф. Ушакова над 
турецкой эскадрой у мыса Тендра (1790 год)
 21 сент.   День победы русских полков во главе с великим князем Дмитрием 
Донским над монголо-татарскими войсками в Куликовской битве (1380 год)
- 7 нояб.   День освобождения Москвы силами народного ополчения под 
руководством Кузьмы Минина и Дмитрия Пожарского от польских интервентов (1612 
год)
+ 4 нояб.   День освобождения Москвы силами народного ополчения под 
руководством Кузьмы Минина и Дмитрия Пожарского от польских интервентов (1612 
год)
  1 дек.День победы русской эскадры под командованием П.С. Нахимова над 
турецкой эскадрой у мыса Синоп (1853 год)
  5 дек.День начала контрнаступления советских войск против 
немецко-фашистских войск в битве под Москвой (1941 год)
 24 дек.День взятия турецкой крепости Измаил русскими войсками под 
командованием А.В. Суворова (1790 год)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r303569 - head/usr.bin/calendar/calendars/ru_RU.KOI8-R

2016-07-30 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 31 03:26:53 2016
New Revision: 303569
URL: https://svnweb.freebsd.org/changeset/base/303569

Log:
  Reflect CLDR timedef changes

Modified:
  head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common
  head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.holiday   (contents, 
props changed)
  head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.military
  head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox
  head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan

Modified: head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common
==
--- head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.commonSun Jul 
31 03:11:10 2016(r303568)
+++ head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.commonSun Jul 
31 03:26:53 2016(r303569)
@@ -9,97 +9,97 @@
 
 LANG=ru_RU.KOI8-R
 
-12 ���  � ���
-13 ���  �� ��
-14 ��� �� � ���
-21 ���  �� �
-25 ���  .  
- 8 ���  �� �
-10 ���   �
- 1 ��� �  ��� ���
+12 ���. � ���
+13 ���. �� ��
+14 ���.�� � ���
+21 ���. �� �
+25 ���. .  
+ 8 .    �� �
+10 .     �
+ 1 �   �  ��� ���
 03/SunSecond    ��  � ���
-11 ���  � ��� �
-18 ���  � ���
+11 �    � ��� �
+18 �    � ���
 03/SunThird �� ,   � � 
���-� �
-27 ��� �  ��
-27 ���  �� �
- 1 ���  �
- 2 ���   ���
+27 �   �  ��
+27 �    �� �
+ 1 ���. �
+ 2 ���.  ���
 04/SunFirst ���
-12 ���  
+12 ���. 
 04/SunSecond    �  ���
-26 ���  ��  �  ��� � ���
-30 ���   ��
- 7 ���  �
-17 ��� �  
-18 ��� �  ��
-24 ���  ��  � 
-26 ���  ��� ���
-27 ��� ��  �
-28 ���  
-30 ���   ��
-31 ���  �� ��
+26 ���. ��  �  ��� � ���
+30 ���.  ��
+ 7 ���  �
+17 ��� �  
+18 ��� �  ��
+24 ���  ��  � 
+26 ���  ��� ���
+27 ��� ��  �
+28 ���  
+30 ���   ��
+31 ���  �� ��
 05/SunLast  ��
- 1 ���  �� �
- 5 ���  ���
- 6 ��� �� 
- 8 ���  ��� �
+ 1  �� �
+ 5  ���
+ 6 �� 
+ 8  ��� �
 06/SunSecond    �� �� ��
 06/SunThird  �
-22 ���  �� � �� (�� ��� � �, 1941 ���)
-27 ���  
-29 ���   � 
+22  �� � �� (�� ��� � �, 1941 
���)
+27  
+29   � 
 06/SatLast   � ���
 07/SunFirst ��  � ��� �
 07/SunSecond    ��
 07/SunSecond    �� �
 07/SunThird ��
 07/SunLast  ��- �
-28 ���   
- 6 ���  ��� �
+28   
+ 6 ���. ��� �
 08/SunFirst 
-12 ���  ��-� ���
+12 ���. ��-� ���
 08/SunSecond    �
 08/SunThird �� �
-22 ���   �
-27 ���  
+22 ���.  �
+27 ���. 
 08/SunLast  ���
- 1 ���  ��
- 2 ���  �� ���
- 3 ���   � �� � ���
- 4 ���  ��� ��  ���
+ 1 .    ��
+ 2 .    �� ���
+ 3 .     � �� � ���
+ 4 .    ��� ��  ���
 09/SunFirst ��  � ��� ��
 09/SunSecond    
 09/SunThird �� 
-28 ��� ���

svn commit: r303568 - head/usr.bin/calendar/calendars/ru_RU.UTF-8

2016-07-30 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 31 03:11:10 2016
New Revision: 303568
URL: https://svnweb.freebsd.org/changeset/base/303568

Log:
  Remove another vestige of scripted conversion

Modified:
  head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan

Modified: head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan
==
--- head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan  Sun Jul 31 
02:54:27 2016(r303567)
+++ head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.pagan  Sun Jul 31 
03:11:10 2016(r303568)
@@ -35,7 +35,7 @@ Paskha=Пасха
 14 сент.   День Волха Змеевича
 22 сент.*  Поворот к зиме (осеннее равноденствие)
 10 нояб.   День Макоши
-21 нояб.   День Сварога и Семартагла
+21 нояб.День Сварога и Семаргла
  9 дек.День Дажьбога и Марены
 
 #endif /* !_ru_RU_UTF_8_pagan_ */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r303566 - head/usr.bin/calendar/calendars/ru_RU.UTF-8

2016-07-30 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 31 02:43:45 2016
New Revision: 303566
URL: https://svnweb.freebsd.org/changeset/base/303566

Log:
  Remove vestige of scripted conversion

Modified:
  head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.common

Modified: head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.common
==
--- head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.common Sun Jul 31 
02:28:50 2016(r303565)
+++ head/usr.bin/calendar/calendars/ru_RU.UTF-8/calendar.common Sun Jul 31 
02:43:45 2016(r303566)
@@ -84,7 +84,7 @@ LANG=ru_RU.UTF-8
 25 окт.День таможенника
 30 окт.День памяти жертв политических репрессий
 10/SunLast День работников автомобильного транспорта
- 7 нояб.   День окт.ябрьской революции 1917 года
+ 7 нояб.   День октябрьской революции 1917 года
  9 нояб.   Всемирный день качества
 10 нояб.   День милиции
 16 нояб.   День морской пехоты
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

svn commit: r303565 - head/lib/libc/gen

2016-07-30 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 31 02:28:50 2016
New Revision: 303565
URL: https://svnweb.freebsd.org/changeset/base/303565

Log:
  In addition to prev. commit. Since potentially glob2() can return error
  without setting errno, restore errno before its call.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSun Jul 31 01:14:06 2016(r303564)
+++ head/lib/libc/gen/glob.cSun Jul 31 02:28:50 2016(r303565)
@@ -821,6 +821,8 @@ glob3(Char *pathbuf, Char *pathend, Char
errno = 0;
continue;
}
+   if (errno == 0)
+   errno = saverrno;
err = glob2(pathbuf, --dc, pathend_last, restpattern,
pglob, limit);
if (err)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303564 - head/lib/libc/gen

2016-07-30 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 31 01:14:06 2016
New Revision: 303564
URL: https://svnweb.freebsd.org/changeset/base/303564

Log:
  Both C99 and POSIX directly prohibits any standard function to set errno
  to 0. Breaking this rule in 2001 NetBSD hack was imported which attempts
  to workaround very limited glob() return codes amount. Use POSIX-compatible
  workaround now with E2BIG which can't comes from other functions used
  instead of prohibited 0.

Modified:
  head/lib/libc/gen/glob.3
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.3
==
--- head/lib/libc/gen/glob.3Sat Jul 30 22:23:31 2016(r303563)
+++ head/lib/libc/gen/glob.3Sun Jul 31 01:14:06 2016(r303564)
@@ -363,7 +363,7 @@ file
 .It Dv GLOB_NOSPACE
 An attempt to allocate memory failed, or if
 .Fa errno
-was 0
+was E2BIG,
 .Dv GLOB_LIMIT
 was specified in the flags and
 .Fa pglob\->gl_matchc

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSat Jul 30 22:23:31 2016(r303563)
+++ head/lib/libc/gen/glob.cSun Jul 31 01:14:06 2016(r303564)
@@ -270,7 +270,7 @@ globexp0(const Char *pattern, glob_t *pg
if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) {
if ((pglob->gl_flags & GLOB_LIMIT) &&
limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
return (glob0(pattern, pglob, limit, origpat));
@@ -297,7 +297,7 @@ globexp1(const Char *pattern, glob_t *pg
if ((ptr = g_strchr(pattern, LBRACE)) != NULL) {
if ((pglob->gl_flags & GLOB_LIMIT) &&
limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
return (globexp2(ptr, pattern, pglob, limit));
@@ -538,7 +538,7 @@ glob0(const Char *pattern, glob_t *pglob
 
qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
if (qpatnext == NULL) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
oldpathc = pglob->gl_pathc;
@@ -672,7 +672,7 @@ glob2(Char *pathbuf, Char *pathend, Char
 
if ((pglob->gl_flags & GLOB_LIMIT) &&
limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
if ((pglob->gl_flags & GLOB_MARK) &&
@@ -682,7 +682,7 @@ glob2(Char *pathbuf, Char *pathend, Char
g_stat(pathbuf, &sb, pglob) == 0 &&
S_ISDIR(sb.st_mode {
if (pathend + 1 > pathend_last) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
*pathend++ = SEP;
@@ -699,7 +699,7 @@ glob2(Char *pathbuf, Char *pathend, Char
if (ismeta(*p))
anymeta = 1;
if (q + 1 > pathend_last) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
*q++ = *p++;
@@ -710,7 +710,7 @@ glob2(Char *pathbuf, Char *pathend, Char
pattern = p;
while (UNPROT(*pattern) == SEP) {
if (pathend + 1 > pathend_last) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
*pathend++ = *pattern++;
@@ -729,30 +729,36 @@ glob3(Char *pathbuf, Char *pathend, Char
 {
struct dirent *dp;
DIR *dirp;
-   int err, too_long, saverrno;
+   int err, too_long, saverrno, saverrno2;
char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
struct dirent *(*readdirfunc)(DIR *);
 
if (pathend > pathend_last) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
*pathend = EOS;
if (pglob->gl_errfunc != NULL &&
g_Ctoc(pathbuf, buf, sizeof(buf))) {
-   errno = 0;
+   errno = E2BIG;
return (GLOB_NOSPACE);
}
 
+   saverrno = errno;
errno = 0;
if ((dirp = g_opendir(pathbuf, p

svn commit: r303536 - head/lib/libc/gen

2016-07-29 Thread Andrey A. Chernov
Author: ache
Date: Sat Jul 30 03:11:54 2016
New Revision: 303536
URL: https://svnweb.freebsd.org/changeset/base/303536

Log:
  Rework r303074 case 4. Don't immediatelly skip directory entries which
  cause MAXPATHLEN exceeded. Process them first through gl_errfunc() and
  GLOB_ERR.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSat Jul 30 03:11:53 2016(r303535)
+++ head/lib/libc/gen/glob.cSat Jul 30 03:11:54 2016(r303536)
@@ -803,6 +803,13 @@ glob3(Char *pathbuf, Char *pathend, Char
}
sc += clen;
}
+   if (too_long && ((pglob->gl_errfunc != NULL &&
+   pglob->gl_errfunc(buf, ENAMETOOLONG)) ||
+   (pglob->gl_flags & GLOB_ERR))) {
+   errno = ENAMETOOLONG;
+   err = GLOB_ABORTED;
+   break;
+   }
if (too_long || !match(pathend, pattern, restpattern)) {
*pathend = EOS;
errno = 0;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303530 - head/lib/libc/gen

2016-07-29 Thread Andrey A. Chernov
Author: ache
Date: Sat Jul 30 02:09:11 2016
New Revision: 303530
URL: https://svnweb.freebsd.org/changeset/base/303530

Log:
  Reset errno for readdirfunc() before contunue.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSat Jul 30 01:16:06 2016(r303529)
+++ head/lib/libc/gen/glob.cSat Jul 30 02:09:11 2016(r303530)
@@ -781,8 +781,10 @@ glob3(Char *pathbuf, Char *pathend, Char
}
 
/* Initial DOT must be matched literally. */
-   if (dp->d_name[0] == '.' && UNPROT(*pattern) != DOT)
+   if (dp->d_name[0] == '.' && UNPROT(*pattern) != DOT) {
+   errno = 0;
continue;
+   }
memset(&mbs, 0, sizeof(mbs));
dc = pathend;
sc = dp->d_name;
@@ -803,6 +805,7 @@ glob3(Char *pathbuf, Char *pathend, Char
}
if (too_long || !match(pathend, pattern, restpattern)) {
*pathend = EOS;
+   errno = 0;
continue;
}
err = glob2(pathbuf, --dc, pathend_last, restpattern,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303210 - head/lib/libc/gen

2016-07-22 Thread Andrey A. Chernov
Author: ache
Date: Sat Jul 23 03:49:02 2016
New Revision: 303210
URL: https://svnweb.freebsd.org/changeset/base/303210

Log:
  1) POSIX defines well when GLOB_NOMATCH or original pattern
  (instead) should be returned, so we can't return GLOB_NOMATCH blindly
  just because we dislike something in the pattern.
  
  2) Remove extra condition.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSat Jul 23 02:27:42 2016(r303209)
+++ head/lib/libc/gen/glob.cSat Jul 23 03:49:02 2016(r303210)
@@ -217,7 +217,8 @@ glob(const char * __restrict pattern, in
while (bufnext <= bufend) {
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
-   return (GLOB_NOMATCH);
+   return (globfinal(pglob, &limit,
+   pglob->gl_pathc, pattern));
else if (clen == 0) {
too_long = 0;
break;
@@ -239,7 +240,8 @@ glob(const char * __restrict pattern, in
prot = 0;
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
-   return (GLOB_NOMATCH);
+   return (globfinal(pglob, &limit,
+   pglob->gl_pathc, pattern));
else if (clen == 0) {
too_long = 0;
break;
@@ -249,7 +251,7 @@ glob(const char * __restrict pattern, in
}
}
if (too_long)
-   return (GLOB_NOMATCH);
+   return (globfinal(pglob, &limit, pglob->gl_pathc, pattern));
*bufnext = EOS;
 
if (flags & GLOB_BRACE)
@@ -613,9 +615,9 @@ globfinal(glob_t *pglob, struct glob_lim
 * GLOB_NOMAGIC is there just for compatibility with csh.
 */
if (pglob->gl_pathc == oldpathc) {
-   if (origpat != NULL && ((pglob->gl_flags & GLOB_NOCHECK) ||
+   if ((pglob->gl_flags & GLOB_NOCHECK) ||
((pglob->gl_flags & GLOB_NOMAGIC) &&
-   !(pglob->gl_flags & GLOB_MAGCHAR
+   !(pglob->gl_flags & GLOB_MAGCHAR)))
return (globextend(NULL, pglob, limit, origpat));
else
return (GLOB_NOMATCH);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303208 - head/lib/libc/gen

2016-07-22 Thread Andrey A. Chernov
Author: ache
Date: Sat Jul 23 01:21:58 2016
New Revision: 303208
URL: https://svnweb.freebsd.org/changeset/base/303208

Log:
  1) We need the original pattern (in the next round of changes) not only in
  case it fully constructed, but for half-constructed too, so have no
  other choice to pass original pattern from glob() down to globextend()
  instead of attempt to reconstruct I implement previously.
  
  2) Instead of copy&paste the same big enough code, make function for it:
  globfinal().

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cFri Jul 22 23:13:25 2016(r303207)
+++ head/lib/libc/gen/glob.cSat Jul 23 01:21:58 2016(r303208)
@@ -145,11 +145,12 @@ typedef uint_fast64_t Char;
 #defineM_RNG   META(L'-')
 #defineM_SET   META(L'[')
 #defineismeta(c)   (((c)&M_QUOTE) != 0)
+#ifdef DEBUG
 #defineisprot(c)   (((c)&M_PROTECT) != 0)
-
+#endif
 
 static int  compare(const void *, const void *);
-static int  g_Ctoc(const Char *, char *, size_t, int);
+static int  g_Ctoc(const Char *, char *, size_t);
 static int  g_lstat(Char *, struct stat *, glob_t *);
 static DIR *g_opendir(Char *, glob_t *);
 static const Char *g_strchr(const Char *, wchar_t);
@@ -157,19 +158,24 @@ static const Char *g_strchr(const Char *
 static Char*g_strcat(Char *, const Char *);
 #endif
 static int  g_stat(Char *, struct stat *, glob_t *);
-static int  glob0(const Char *, glob_t *, struct glob_limit *, int);
+static int  glob0(const Char *, glob_t *, struct glob_limit *,
+const char *);
 static int  glob1(Char *, glob_t *, struct glob_limit *);
 static int  glob2(Char *, Char *, Char *, Char *, glob_t *,
 struct glob_limit *);
 static int  glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
 struct glob_limit *);
-static int  globextend(const Char *, glob_t *, struct glob_limit *, int);
+static int  globextend(const Char *, glob_t *, struct glob_limit *,
+const char *);
 static const Char *
 globtilde(const Char *, Char *, size_t, glob_t *);
-static int  globexp0(const Char *, glob_t *, struct glob_limit *);
+static int  globexp0(const Char *, glob_t *, struct glob_limit *,
+const char *);
 static int  globexp1(const Char *, glob_t *, struct glob_limit *);
 static int  globexp2(const Char *, const Char *, glob_t *,
 struct glob_limit *);
+static int  globfinal(glob_t *, struct glob_limit *, size_t,
+const char *);
 static int  match(Char *, Char *, Char *);
 #ifdef DEBUG
 static void qprintf(const char *, Char *);
@@ -247,14 +253,14 @@ glob(const char * __restrict pattern, in
*bufnext = EOS;
 
if (flags & GLOB_BRACE)
-   return (globexp0(patbuf, pglob, &limit));
+   return (globexp0(patbuf, pglob, &limit, pattern));
else
-   return (glob0(patbuf, pglob, &limit, 1));
+   return (glob0(patbuf, pglob, &limit, pattern));
 }
 
 static int
-globexp0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
-{
+globexp0(const Char *pattern, glob_t *pglob, struct glob_limit *limit,
+const char *origpat) {
int rv;
size_t oldpathc;
 
@@ -265,31 +271,15 @@ globexp0(const Char *pattern, glob_t *pg
errno = 0;
return (GLOB_NOSPACE);
}
-   return (glob0(pattern, pglob, limit, 1));
+   return (glob0(pattern, pglob, limit, origpat));
}
 
oldpathc = pglob->gl_pathc;
 
if ((rv = globexp1(pattern, pglob, limit)) != 0)
return rv;
-   /*
-* If there was no match we are going to append the pattern
-* if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
-* and the pattern did not contain any magic characters
-* GLOB_NOMAGIC is there just for compatibility with csh.
-*/
-   if (pglob->gl_pathc == oldpathc) {
-   if (((pglob->gl_flags & GLOB_NOCHECK) ||
-   ((pglob->gl_flags & GLOB_NOMAGIC) &&
-   !(pglob->gl_flags & GLOB_MAGCHAR
-   return (globextend(pattern, pglob, limit, 1));
-   else
-   return (GLOB_NOMATCH);
-   }
-   if (!(pglob->gl_flags & GLOB_NOSORT))
-   qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
-   pglob->gl_pathc - oldpathc, sizeof(char *), compare);
-   return (0);
+
+   return (globfinal(pglob, limit, oldpathc, origpat));
 }
 
 /*
@@ -311,7 +301,7 @@ globexp1(const Char *pattern, glob_t *pg
return (globexp2(ptr, pattern, pglob, limit));
}
 
-   return (glob0(pattern, pglob, limit, 0));
+   return (glob0(pattern, pglob, limit, NULL));
 }
 
 
@@ -359,7 +349,7 @@

svn commit: r303201 - stable/10/usr.bin/tr

2016-07-22 Thread Andrey A. Chernov
Author: ache
Date: Fri Jul 22 19:36:11 2016
New Revision: 303201
URL: https://svnweb.freebsd.org/changeset/base/303201

Log:
  MFC: r302827
  
  Optimize [Cc]flag case: don't repeatedly add the last character of
  string2 to squeeze cset when string2 reach its EOS state.

Modified:
  stable/10/usr.bin/tr/tr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/tr/tr.c
==
--- stable/10/usr.bin/tr/tr.c   Fri Jul 22 19:34:43 2016(r303200)
+++ stable/10/usr.bin/tr/tr.c   Fri Jul 22 19:36:11 2016(r303201)
@@ -272,10 +272,11 @@ endloop:
if (Cflag && !iswrune(cnt))
continue;
if (cmap_lookup(map, cnt) == OOBCH) {
-   if (next(&s2))
+   if (next(&s2)) {
cmap_add(map, cnt, s2.lastch);
-   if (sflag)
-   cset_add(squeeze, s2.lastch);
+   if (sflag)
+   cset_add(squeeze, s2.lastch);
+   }
} else
cmap_add(map, cnt, cnt);
if ((s2.state == EOS || s2.state == INFINITE) &&
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303200 - stable/10/usr.bin/tr

2016-07-22 Thread Andrey A. Chernov
Author: ache
Date: Fri Jul 22 19:34:43 2016
New Revision: 303200
URL: https://svnweb.freebsd.org/changeset/base/303200

Log:
  MFC: r302826
  
  Document incomplete support of [=equiv=] and collation for ranges.

Modified:
  stable/10/usr.bin/tr/tr.1
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/tr/tr.1
==
--- stable/10/usr.bin/tr/tr.1   Fri Jul 22 19:28:23 2016(r303199)
+++ stable/10/usr.bin/tr/tr.1   Fri Jul 22 19:34:43 2016(r303200)
@@ -334,6 +334,10 @@ should be used instead of explicit chara
 and
 .Dq Li A-Z .
 .Pp
+.Dq Li [=equiv=]
+expression and collation for ranges
+are implemented for single byte locales only.
+.Pp
 System V has historically implemented character ranges using the syntax
 .Dq Li [c-c]
 instead of the
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303191 - stable/10/lib/libc/locale

2016-07-22 Thread Andrey A. Chernov
Author: ache
Date: Fri Jul 22 16:48:39 2016
New Revision: 303191
URL: https://svnweb.freebsd.org/changeset/base/303191

Log:
  Forget to merge this changes in prev. MFC

Modified:
  stable/10/lib/libc/locale/collcmp.c

Modified: stable/10/lib/libc/locale/collcmp.c
==
--- stable/10/lib/libc/locale/collcmp.c Fri Jul 22 16:15:35 2016
(r303190)
+++ stable/10/lib/libc/locale/collcmp.c Fri Jul 22 16:48:39 2016
(r303191)
@@ -42,10 +42,12 @@ __FBSDID("$FreeBSD$");
 
 int __collate_range_cmp(char c1, char c2)
 {
-   static char s1[2], s2[2];
+   char s1[2], s2[2];
 
s1[0] = c1;
+   s1[1] = '\0';
s2[0] = c2;
+   s2[1] = '\0';
return (strcoll(s1, s2));
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303185 - in stable/10/lib/libc: gen locale regex stdio

2016-07-22 Thread Andrey A. Chernov
Author: ache
Date: Fri Jul 22 14:24:17 2016
New Revision: 303185
URL: https://svnweb.freebsd.org/changeset/base/303185

Log:
  MFC: r302824
  
  1) Eliminate possibility to call __*collate_range_cmp() with inclomplete
  locale (which cause core dump) by removing whole 'table' argument
  by which it passed.
  
  2) Restore __collate_range_cmp() in __sccl().
  
  3) Collating [a-z] range in regcomp() works for single byte locales only
  (we can't do it for other ones). In previous state only first 256
  wide chars are considered and all others are just silently dropped from the
  range.

Modified:
  stable/10/lib/libc/gen/fnmatch.c
  stable/10/lib/libc/gen/glob.c
  stable/10/lib/libc/locale/collate.h
  stable/10/lib/libc/locale/collcmp.c
  stable/10/lib/libc/regex/regcomp.c
  stable/10/lib/libc/stdio/vfscanf.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/fnmatch.c
==
--- stable/10/lib/libc/gen/fnmatch.cFri Jul 22 12:55:31 2016
(r303184)
+++ stable/10/lib/libc/gen/fnmatch.cFri Jul 22 14:24:17 2016
(r303185)
@@ -304,8 +304,8 @@ rangematch(pattern, test, flags, newp, p
 
if (table->__collate_load_error ?
c <= test && test <= c2 :
-  __collate_range_cmp(table, c, test) <= 0
-   && __collate_range_cmp(table, test, c2) <= 0
+  __wcollate_range_cmp(c, test) <= 0
+   && __wcollate_range_cmp(test, c2) <= 0
   )
ok = 1;
} else if (c == test)

Modified: stable/10/lib/libc/gen/glob.c
==
--- stable/10/lib/libc/gen/glob.c   Fri Jul 22 12:55:31 2016
(r303184)
+++ stable/10/lib/libc/gen/glob.c   Fri Jul 22 14:24:17 2016
(r303185)
@@ -836,8 +836,8 @@ match(Char *name, Char *pat, Char *paten
if ((*pat & M_MASK) == M_RNG) {
if (table->__collate_load_error ?
CHAR(c) <= CHAR(k) && CHAR(k) <= 
CHAR(pat[1]) :
-  __collate_range_cmp(table, 
CHAR(c), CHAR(k)) <= 0
-   && __collate_range_cmp(table, 
CHAR(k), CHAR(pat[1])) <= 0
+  __wcollate_range_cmp(CHAR(c), 
CHAR(k)) <= 0
+   && __wcollate_range_cmp(CHAR(k), 
CHAR(pat[1])) <= 0
   )
ok = 1;
pat += 2;

Modified: stable/10/lib/libc/locale/collate.h
==
--- stable/10/lib/libc/locale/collate.h Fri Jul 22 12:55:31 2016
(r303184)
+++ stable/10/lib/libc/locale/collate.h Fri Jul 22 14:24:17 2016
(r303185)
@@ -72,7 +72,8 @@ u_char*__collate_strdup(u_char *);
 u_char *__collate_substitute(struct xlocale_collate *, const u_char *);
 int__collate_load_tables(const char *);
 void   __collate_lookup(struct xlocale_collate *, const u_char *, int *, int 
*, int *);
-int__collate_range_cmp(struct xlocale_collate *, int, int);
+int__collate_range_cmp(char, char);
+int__wcollate_range_cmp(wchar_t, wchar_t);
 #ifdef COLLATE_DEBUG
 void   __collate_print_tables(void);
 #endif

Modified: stable/10/lib/libc/locale/collcmp.c
==
--- stable/10/lib/libc/locale/collcmp.c Fri Jul 22 12:55:31 2016
(r303184)
+++ stable/10/lib/libc/locale/collcmp.c Fri Jul 22 14:24:17 2016
(r303185)
@@ -33,20 +33,29 @@
 __FBSDID("$FreeBSD$");
 
 #include 
-#include 
+#include 
 #include "collate.h"
 
 /*
  * Compare two characters using collate
  */
 
-int __collate_range_cmp(struct xlocale_collate *table, int c1, int c2)
+int __collate_range_cmp(char c1, char c2)
 {
static char s1[2], s2[2];
 
s1[0] = c1;
s2[0] = c2;
-   struct _xlocale l = {{0}};
-   l.components[XLC_COLLATE] = (struct xlocale_component *)table;
-   return (strcoll_l(s1, s2, &l));
+   return (strcoll(s1, s2));
+}
+
+int __wcollate_range_cmp(wchar_t c1, wchar_t c2)
+{
+   wchar_t s1[2], s2[2];
+
+   s1[0] = c1;
+   s1[1] = L'\0';
+   s2[0] = c2;
+   s2[1] = L'\0';
+   return (wcscoll(s1, s2));
 }

Modified: stable/10/lib/libc/regex/regcomp.c
==
--- stable/10/lib/libc/regex/regcomp.c  Fri Jul 22 12:55:31 2016
(r303184)
+++ stable/10/lib/libc/regex/regcomp.c  Fri Jul 22 14:24:17 2016
(r303185)
@@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
 #include

svn commit: r303142 - head/lib/libc/gen

2016-07-21 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul 21 12:53:36 2016
New Revision: 303142
URL: https://svnweb.freebsd.org/changeset/base/303142

Log:
  1) GLOB_BRACE was somewhat broken. First it repeatedly calls glob0() in
  globexp1() recursive calls, but glob0() was not supposed to be called
  repeatedly in the original code. It finalize results by possible adding
  original pattern for no match case, may return GLOB_NOMATCH error and
  by sorting all things. Original pattern adding or GLOB_NOMATCH error
  can happens each time glob0() called repeatedly, and sorting happens
  for one item only, all things are never sorted. Second, f.e. "a{a"
  pattern does not match "a{a" file but match "a" file instead
  (just one example, there are many). Third, some errors (f.e. for limits
  or overflow) can be ignored by GLOB_BRACE code because it forces return (0).
  Add non-finalizing flag to glob0() and make globexp0() wrapper around
  recursively called globexp1() to finalize things like glob0() does.
  Reorganize braces code to work correctly.
  
  2) Don't allow MB_CUR_MAX * strlen overallocation hits GLOB_LIMIT_STRING
  (ARG_MAX) limit, use final string length, not malloced space for it.
  
  3) Revive DEBUG-ifdefed section.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cThu Jul 21 12:50:23 2016(r303141)
+++ head/lib/libc/gen/glob.cThu Jul 21 12:53:36 2016(r303142)
@@ -128,8 +128,6 @@ struct glob_limit {
 #defineRBRACE  L'}'
 #defineCOMMA   L','
 
-#ifndef DEBUG
-
 #defineM_QUOTE 0x80ULL
 #defineM_PROTECT   0x40ULL
 #defineM_MASK  0xffULL
@@ -137,18 +135,6 @@ struct glob_limit {
 
 typedef uint_fast64_t Char;
 
-#else
-
-#defineM_QUOTE 0x80
-#defineM_PROTECT   0x40
-#defineM_MASK  0xff
-#defineM_CHAR  0x7f
-
-typedef char Char;
-
-#endif
-
-
 #defineCHAR(c) ((Char)((c)&M_CHAR))
 #defineMETA(c) ((Char)((c)|M_QUOTE))
 #defineUNPROT(c)   ((c) & ~M_PROTECT)
@@ -171,7 +157,7 @@ static const Char *g_strchr(const Char *
 static Char*g_strcat(Char *, const Char *);
 #endif
 static int  g_stat(Char *, struct stat *, glob_t *);
-static int  glob0(const Char *, glob_t *, struct glob_limit *);
+static int  glob0(const Char *, glob_t *, struct glob_limit *, int);
 static int  glob1(Char *, glob_t *, struct glob_limit *);
 static int  glob2(Char *, Char *, Char *, Char *, glob_t *,
 struct glob_limit *);
@@ -180,8 +166,9 @@ static int   glob3(Char *, Char *, Char *
 static int  globextend(const Char *, glob_t *, struct glob_limit *, int);
 static const Char *
 globtilde(const Char *, Char *, size_t, glob_t *);
+static int  globexp0(const Char *, glob_t *, struct glob_limit *);
 static int  globexp1(const Char *, glob_t *, struct glob_limit *);
-static int  globexp2(const Char *, const Char *, glob_t *, int *,
+static int  globexp2(const Char *, const Char *, glob_t *,
 struct glob_limit *);
 static int  match(Char *, Char *, Char *);
 #ifdef DEBUG
@@ -260,9 +247,49 @@ glob(const char * __restrict pattern, in
*bufnext = EOS;
 
if (flags & GLOB_BRACE)
-   return (globexp1(patbuf, pglob, &limit));
+   return (globexp0(patbuf, pglob, &limit));
else
-   return (glob0(patbuf, pglob, &limit));
+   return (glob0(patbuf, pglob, &limit, 1));
+}
+
+static int
+globexp0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
+{
+   int rv;
+   size_t oldpathc;
+
+   /* Protect a single {}, for find(1), like csh */
+   if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) {
+   if ((pglob->gl_flags & GLOB_LIMIT) &&
+   limit->l_brace_cnt++ >= GLOB_LIMIT_BRACE) {
+   errno = 0;
+   return (GLOB_NOSPACE);
+   }
+   return (glob0(pattern, pglob, limit, 1));
+   }
+
+   oldpathc = pglob->gl_pathc;
+
+   if ((rv = globexp1(pattern, pglob, limit)) != 0)
+   return rv;
+   /*
+* If there was no match we are going to append the pattern
+* if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
+* and the pattern did not contain any magic characters
+* GLOB_NOMAGIC is there just for compatibility with csh.
+*/
+   if (pglob->gl_pathc == oldpathc) {
+   if (((pglob->gl_flags & GLOB_NOCHECK) ||
+   ((pglob->gl_flags & GLOB_NOMAGIC) &&
+   !(pglob->gl_flags & GLOB_MAGCHAR
+   return (globextend(pattern, pglob, limit, 1));
+   else
+   return (GLOB_NOMATCH);
+   }
+   if (!(pg

svn commit: r303094 - head/usr.bin

2016-07-20 Thread Andrey A. Chernov
Author: ache
Date: Wed Jul 20 15:59:37 2016
New Revision: 303094
URL: https://svnweb.freebsd.org/changeset/base/303094

Log:
  Continuation lines with comments badly affects gprof, it is excluded from
  build on amd64 f.e.

Modified:
  head/usr.bin/Makefile

Modified: head/usr.bin/Makefile
==
--- head/usr.bin/Makefile   Wed Jul 20 15:07:52 2016(r303093)
+++ head/usr.bin/Makefile   Wed Jul 20 15:59:37 2016(r303094)
@@ -270,8 +270,9 @@ SUBDIR.${MK_TOOLCHAIN}+=ctags
 SUBDIR.${MK_TOOLCHAIN}+=   cxxfilt
 SUBDIR.${MK_TOOLCHAIN}+=   elfcopy
 SUBDIR.${MK_TOOLCHAIN}+=   file2c
-.if ${MACHINE_ARCH} != "aarch64" && \ # ARM64TODO gprof does not build
-${MACHINE_CPUARCH} != "riscv" # RISCVTODO gprof does not build
+# ARM64TODO gprof does not build
+# RISCVTODO gprof does not build
+.if ${MACHINE_ARCH} != "aarch64" && ${MACHINE_CPUARCH} != "riscv"
 SUBDIR.${MK_TOOLCHAIN}+=   gprof
 .endif
 SUBDIR.${MK_TOOLCHAIN}+=   indent
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303088 - head/lib/libc/gen

2016-07-20 Thread Andrey A. Chernov
Author: ache
Date: Wed Jul 20 12:46:21 2016
New Revision: 303088
URL: https://svnweb.freebsd.org/changeset/base/303088

Log:
  In addition to r303074 case 1, search for protected L'/' too in globtilde()

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cWed Jul 20 11:23:06 2016(r303087)
+++ head/lib/libc/gen/glob.cWed Jul 20 12:46:21 2016(r303088)
@@ -126,7 +126,6 @@ struct glob_limit {
 #defineTILDE   L'~'
 #defineLBRACE  L'{'
 #defineRBRACE  L'}'
-#defineSLASH   L'/'
 #defineCOMMA   L','
 
 #ifndef DEBUG
@@ -427,10 +426,10 @@ globtilde(const Char *pattern, Char *pat
 */
eb = &patbuf[patbuf_len - 1];
for (p = pattern + 1, b = patbuf;
-   b < eb && *p != EOS && *p != SLASH; *b++ = *p++)
+   b < eb && *p != EOS && UNPROT(*p) != SEP; *b++ = *p++)
continue;
 
-   if (*p != EOS && *p != SLASH)
+   if (*p != EOS && UNPROT(*p) != SEP)
return (NULL);
 
*b = EOS;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303074 - head/lib/libc/gen

2016-07-20 Thread Andrey A. Chernov
Author: ache
Date: Wed Jul 20 07:30:44 2016
New Revision: 303074
URL: https://svnweb.freebsd.org/changeset/base/303074

Log:
  1) Per POSIX (and glibc) GLOB_NOCHECK should return original pattern,
  unmodified, if no matches found. But our original code strips all '\'
  returning it. Rewrite the code to allow to reconstruct exact the
  original pattern with backslashes for this case.
  
  2) Prevent to use truncated pattern if MAXPATHLEN exceeded, return
  GLOB_NOMATCH instead.
  
  3) Fix few end loop conditions filling Char arrays with mbrtowc(),
  MB_CUR_MAX is unneeded in two places and condition is less by one
  in other place.
  
  4) Prevent to use truncated filenames match if MAXPATHLEN exceeded,
  skip such directory entries.
  
  5) Don't end *pathend with L'/' in glob3() if limit is reached, this
  change will be not visible since error is returned.
  
  6) If error happens in (*readdirfunc)(), do the same GLOB_ABORTED
  processing as for g_opendir() as POSIX requires.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cWed Jul 20 06:29:26 2016(r303073)
+++ head/lib/libc/gen/glob.cWed Jul 20 07:30:44 2016(r303074)
@@ -152,6 +152,7 @@ typedef char Char;
 
 #defineCHAR(c) ((Char)((c)&M_CHAR))
 #defineMETA(c) ((Char)((c)|M_QUOTE))
+#defineUNPROT(c)   ((c) & ~M_PROTECT)
 #defineM_ALL   META(L'*')
 #defineM_END   META(L']')
 #defineM_NOT   META(L'!')
@@ -159,10 +160,11 @@ typedef char Char;
 #defineM_RNG   META(L'-')
 #defineM_SET   META(L'[')
 #defineismeta(c)   (((c)&M_QUOTE) != 0)
+#defineisprot(c)   (((c)&M_PROTECT) != 0)
 
 
 static int  compare(const void *, const void *);
-static int  g_Ctoc(const Char *, char *, size_t);
+static int  g_Ctoc(const Char *, char *, size_t, int);
 static int  g_lstat(Char *, struct stat *, glob_t *);
 static DIR *g_opendir(Char *, glob_t *);
 static const Char *g_strchr(const Char *, wchar_t);
@@ -176,7 +178,7 @@ static int   glob2(Char *, Char *, Char *
 struct glob_limit *);
 static int  glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
 struct glob_limit *);
-static int  globextend(const Char *, glob_t *, struct glob_limit *);
+static int  globextend(const Char *, glob_t *, struct glob_limit *, int);
 static const Char *
 globtilde(const Char *, Char *, size_t, glob_t *);
 static int  globexp1(const Char *, glob_t *, struct glob_limit *);
@@ -197,6 +199,7 @@ glob(const char * __restrict pattern, in
mbstate_t mbs;
wchar_t wc;
size_t clen;
+   int too_long;
 
patnext = pattern;
if (!(flags & GLOB_APPEND)) {
@@ -216,24 +219,27 @@ glob(const char * __restrict pattern, in
 
bufnext = patbuf;
bufend = bufnext + MAXPATHLEN - 1;
+   too_long = 1;
if (flags & GLOB_NOESCAPE) {
memset(&mbs, 0, sizeof(mbs));
-   while (bufend - bufnext >= MB_CUR_MAX) {
+   while (bufnext <= bufend) {
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
return (GLOB_NOMATCH);
-   else if (clen == 0)
+   else if (clen == 0) {
+   too_long = 0;
break;
+   }
*bufnext++ = wc;
patnext += clen;
}
} else {
/* Protect the quoted characters. */
memset(&mbs, 0, sizeof(mbs));
-   while (bufend - bufnext >= MB_CUR_MAX) {
+   while (bufnext <= bufend) {
if (*patnext == '\\') {
if (*++patnext == '\0') {
-   *bufnext++ = QUOTE | M_PROTECT;
+   *bufnext++ = QUOTE;
continue;
}
prot = M_PROTECT;
@@ -242,13 +248,16 @@ glob(const char * __restrict pattern, in
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
if (clen == (size_t)-1 || clen == (size_t)-2)
return (GLOB_NOMATCH);
-   else if (clen == 0)
+   else if (clen == 0) {
+   too_long = 0;
break;
-   *bufnext++ = wc | ((wc != DOT && wc != SEP) ?
-   prot : 0);
+   }
+   *bufnext++ = wc | prot;
patnext += clen;
  

svn commit: r303014 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 19 00:25:27 2016
New Revision: 303014
URL: https://svnweb.freebsd.org/changeset/base/303014

Log:
  1) Don't protect \/ and \. even if user say so. They are not special chars
  in any case and needed for further processing. For ~ expansion too.
  
  2) Don't terminate *pathend with / when GLOB_LIMIT_STAT is reached, it will
  be not visible outside in any case since error is returned.
  
  3) Cosmetic: change if expression to better reflect its semantic.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 20:24:13 2016(r303013)
+++ head/lib/libc/gen/glob.cTue Jul 19 00:25:27 2016(r303014)
@@ -244,7 +244,8 @@ glob(const char * __restrict pattern, in
return (GLOB_NOMATCH);
else if (clen == 0)
break;
-   *bufnext++ = wc | prot;
+   *bufnext++ = wc | ((wc != DOT && wc != SEP) ?
+   prot : 0);
patnext += clen;
}
}
@@ -478,8 +479,8 @@ globtilde(const Char *pattern, Char *pat
return (NULL);
 
dc = wbuf;
-   for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++ | M_PROTECT)
-   continue;
+   for (b = patbuf; b < eb && *dc != EOS; b++, dc++)
+   *b = *dc | ((*dc != DOT && *dc != SEP) ? M_PROTECT : 0);
if (*dc != EOS)
return (NULL);
 
@@ -642,10 +643,6 @@ glob2(Char *pathbuf, Char *pathend, Char
if ((pglob->gl_flags & GLOB_LIMIT) &&
limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
errno = 0;
-   if (pathend + 1 > pathend_last)
-   return (GLOB_NOSPACE);
-   *pathend++ = SEP;
-   *pathend = EOS;
return (GLOB_NOSPACE);
}
if (((pglob->gl_flags & GLOB_MARK) &&
@@ -886,7 +883,7 @@ match(Char *name, Char *pat, Char *paten
ok = 0;
if ((k = *name++) == EOS)
return (0);
-   if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
+   if ((negate_range = ((*pat & M_MASK) == M_NOT)) != 0)
++pat;
while (((c = *pat++) & M_MASK) != M_END)
if ((*pat & M_MASK) == M_RNG) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303013 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 20:24:13 2016
New Revision: 303013
URL: https://svnweb.freebsd.org/changeset/base/303013

Log:
  g_Ctoc() conversion buffers are smaller than needed up to MB_CUR_MAX - 1
  since whole conversion needs a room for (len >= MB_CUR_MAX). It is no
  difference when MB_CUR_MAX == 1, but for multi-byte locales last few chars
  ('\0' and before) may need just one byte, and the rest of MB_CUR_MAX - 1
  space becomes unavailable in the MAXPATHLEN-sized buffer, which cause
  conversion error on near MAXPATHLEN long pathes.
  
  Increase g_Ctoc() conversion buffers to MB_LEN_MAX - 1.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 19:46:31 2016(r303012)
+++ head/lib/libc/gen/glob.cMon Jul 18 20:24:13 2016(r303013)
@@ -702,7 +702,7 @@ glob3(Char *pathbuf, Char *pathend, Char
struct dirent *dp;
DIR *dirp;
int err;
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
struct dirent *(*readdirfunc)(DIR *);
 
@@ -933,7 +933,7 @@ globfree(glob_t *pglob)
 static DIR *
 g_opendir(Char *str, glob_t *pglob)
 {
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
if (*str == EOS)
strcpy(buf, ".");
@@ -953,7 +953,7 @@ g_opendir(Char *str, glob_t *pglob)
 static int
 g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
 {
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
if (g_Ctoc(fn, buf, sizeof(buf))) {
errno = ENAMETOOLONG;
@@ -967,7 +967,7 @@ g_lstat(Char *fn, struct stat *sb, glob_
 static int
 g_stat(Char *fn, struct stat *sb, glob_t *pglob)
 {
-   char buf[MAXPATHLEN];
+   char buf[MAXPATHLEN + MB_LEN_MAX - 1];
 
if (g_Ctoc(fn, buf, sizeof(buf))) {
errno = ENAMETOOLONG;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303011 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 19:20:49 2016
New Revision: 303011
URL: https://svnweb.freebsd.org/changeset/base/303011

Log:
  Change patch from r303004 case 3. According to POSIX gl_errfunc should be
  called first, then GLOB_ERR should be considered.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 18:24:31 2016(r303010)
+++ head/lib/libc/gen/glob.cMon Jul 18 19:20:49 2016(r303011)
@@ -714,9 +714,7 @@ glob3(Char *pathbuf, Char *pathend, Char
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
if (errno == ENOENT || errno == ENOTDIR)
return (0);
-   if (pglob->gl_flags & GLOB_ERR)
-   return (GLOB_ABORTED);
-   if (pglob->gl_errfunc) {
+   if (pglob->gl_errfunc != NULL) {
if (g_Ctoc(pathbuf, buf, sizeof(buf))) {
errno = 0;
return (GLOB_NOSPACE);
@@ -724,6 +722,8 @@ glob3(Char *pathbuf, Char *pathend, Char
if (pglob->gl_errfunc(buf, errno))
return (GLOB_ABORTED);
}
+   if (pglob->gl_flags & GLOB_ERR)
+   return (GLOB_ABORTED);
return (0);
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303010 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 18:24:31 2016
New Revision: 303010
URL: https://svnweb.freebsd.org/changeset/base/303010

Log:
  1) Add all characters from ~ expansion as protected to be not interpreted
  as pattern meta chars.
  
  2) GLOB_ERR and gl_errfunc are supposed to work only for real directories
  per POSIX, so don't act on missing or plain files, for ENOENT or ENOTDIR
  (as TODO in the code suggested).
  
  3) Remove the hack in the manpage describing how to skip ENOENT and ENOTDIR
  in gl_errfunc, it is unneeded now.
  
  4) Set errno to ENAMETOOLONG if g_Ctoc() expansion fails in g_opendir(),
  as in other places in the code which are wrappers around system functions.

Modified:
  head/lib/libc/gen/glob.3
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.3
==
--- head/lib/libc/gen/glob.3Mon Jul 18 16:58:47 2016(r303009)
+++ head/lib/libc/gen/glob.3Mon Jul 18 18:24:31 2016(r303010)
@@ -275,24 +275,10 @@ is
 .Pf non- Dv NULL ,
 .Fn glob
 calls
-.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) .
-This may be unintuitive: a pattern like
-.Ql */Makefile
-will try to
-.Xr stat 2
-.Ql foo/Makefile
-even if
-.Ql foo
-is not a directory, resulting in a
-call to
-.Fa errfunc .
-The error routine can suppress this action by testing for
-.Er ENOENT
-and
-.Er ENOTDIR ;
+.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) ,
 however, the
 .Dv GLOB_ERR
-flag will still cause an immediate
+flag will cause an immediate
 return when this happens.
 .Pp
 If

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 16:58:47 2016(r303009)
+++ head/lib/libc/gen/glob.cMon Jul 18 18:24:31 2016(r303010)
@@ -478,7 +478,7 @@ globtilde(const Char *pattern, Char *pat
return (NULL);
 
dc = wbuf;
-   for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++)
+   for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++ | M_PROTECT)
continue;
if (*dc != EOS)
return (NULL);
@@ -712,7 +712,8 @@ glob3(Char *pathbuf, Char *pathend, Char
*pathend = EOS;
 
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
-   /* TODO: don't call for ENOENT or ENOTDIR? */
+   if (errno == ENOENT || errno == ENOTDIR)
+   return (0);
if (pglob->gl_flags & GLOB_ERR)
return (GLOB_ABORTED);
if (pglob->gl_errfunc) {
@@ -937,8 +938,10 @@ g_opendir(Char *str, glob_t *pglob)
if (*str == EOS)
strcpy(buf, ".");
else {
-   if (g_Ctoc(str, buf, sizeof(buf)))
+   if (g_Ctoc(str, buf, sizeof(buf))) {
+   errno = ENAMETOOLONG;
return (NULL);
+   }
}
 
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r303004 - head/lib/libc/gen

2016-07-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 18 16:06:21 2016
New Revision: 303004
URL: https://svnweb.freebsd.org/changeset/base/303004

Log:
  1) POSIX defines well when GLOB_ABORTED can be returned (only for directory
  open/read errors and with GLOB_ERR and gl_errfunc processing), so we can't
  blindly return it on any MAXPATHLEN overflow. Even our manpage disagrees
  with such GLOB_ABORTED usage. Use GLOB_NOSPACE for that now with errno is
  set to 0 as for limits.
  
  2) Return GLOB_NOSPACE when valid ~ expansion can't happens due to
  MAXPATHLEN overflow too.
  
  3) POSIX (and our manpage) says, if GLOB_ERR is set, GLOB_ABORTED should
  be returned immediatelly, without using gl_errfunc. Implement it now.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cMon Jul 18 15:50:54 2016(r303003)
+++ head/lib/libc/gen/glob.cMon Jul 18 16:06:21 2016(r303004)
@@ -421,7 +421,7 @@ globtilde(const Char *pattern, Char *pat
continue;
 
if (*p != EOS && *p != SLASH)
-   return (pattern);
+   return (NULL);
 
*b = EOS;
h = NULL;
@@ -446,8 +446,9 @@ globtilde(const Char *pattern, Char *pat
/*
 * Expand a ~user
 */
-   if (g_Ctoc(patbuf, (char *)wbuf, sizeof(wbuf)) ||
-   (pwd = getpwnam((char *)wbuf)) == NULL)
+   if (g_Ctoc(patbuf, (char *)wbuf, sizeof(wbuf)))
+   return (NULL);
+   if ((pwd = getpwnam((char *)wbuf)) == NULL)
return (pattern);
else
h = pwd->pw_dir;
@@ -474,13 +475,13 @@ globtilde(const Char *pattern, Char *pat
sc += clen;
}
if (too_long)
-   return (pattern);
+   return (NULL);
 
dc = wbuf;
for (b = patbuf; b < eb && *dc != EOS; *b++ = *dc++)
continue;
if (*dc != EOS)
-   return (pattern);
+   return (NULL);
 
/* Append the rest of the pattern */
if (*p != EOS) {
@@ -492,7 +493,7 @@ globtilde(const Char *pattern, Char *pat
}
}
if (too_long)
-   return (pattern);
+   return (NULL);
} else
*b = EOS;
 
@@ -515,6 +516,10 @@ glob0(const Char *pattern, glob_t *pglob
Char *bufnext, c, patbuf[MAXPATHLEN];
 
qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
+   if (qpatnext == NULL) {
+   errno = 0;
+   return (GLOB_NOSPACE);
+   }
oldpathc = pglob->gl_pathc;
bufnext = patbuf;
 
@@ -638,7 +643,7 @@ glob2(Char *pathbuf, Char *pathend, Char
limit->l_stat_cnt++ >= GLOB_LIMIT_STAT) {
errno = 0;
if (pathend + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   return (GLOB_NOSPACE);
*pathend++ = SEP;
*pathend = EOS;
return (GLOB_NOSPACE);
@@ -648,8 +653,10 @@ glob2(Char *pathbuf, Char *pathend, Char
|| (S_ISLNK(sb.st_mode) &&
(g_stat(pathbuf, &sb, pglob) == 0) &&
S_ISDIR(sb.st_mode {
-   if (pathend + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   if (pathend + 1 > pathend_last) {
+   errno = 0;
+   return (GLOB_NOSPACE);
+   }
*pathend++ = SEP;
*pathend = EOS;
}
@@ -663,8 +670,10 @@ glob2(Char *pathbuf, Char *pathend, Char
while (*p != EOS && *p != SEP) {
if (ismeta(*p))
anymeta = 1;
-   if (q + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   if (q + 1 > pathend_last) {
+   errno = 0;
+   return (GLOB_NOSPACE);
+   }
*q++ = *p++;
}
 
@@ -672,8 +681,10 @@ glob2(Char *pathbuf, Char *pathend, Char
pathend = q;
pattern = p;
while (*pattern == SEP) {
-   if (pathend + 1 > pathend_last)
-   return (GLOB_ABORTED);
+   if (pathend + 1 > pathend_last) {
+   

svn commit: r302948 - head/lib/libc/gen

2016-07-17 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 17 13:10:57 2016
New Revision: 302948
URL: https://svnweb.freebsd.org/changeset/base/302948

Log:
  Reflect pathnames sorting in collation order.

Modified:
  head/lib/libc/gen/glob.3

Modified: head/lib/libc/gen/glob.3
==
--- head/lib/libc/gen/glob.3Sun Jul 17 12:45:58 2016(r302947)
+++ head/lib/libc/gen/glob.3Sun Jul 17 13:10:57 2016(r302948)
@@ -194,7 +194,7 @@ If
 is set, backslash escaping is disabled.
 .It Dv GLOB_NOSORT
 By default, the pathnames are sorted in ascending
-.Tn ASCII
+collation
 order;
 this flag prevents that sorting (speeding up
 .Fn glob ) .
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302944 - head/lib/libc/gen

2016-07-17 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 17 11:25:24 2016
New Revision: 302944
URL: https://svnweb.freebsd.org/changeset/base/302944

Log:
  In g_Ctoc() apply CHAR() macro to *str to strip all flags. It gains nothing
  right now, but some architectures theoretically may 64-bit wchar_t and the
  code looks more correct.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSun Jul 17 09:39:59 2016(r302943)
+++ head/lib/libc/gen/glob.cSun Jul 17 11:25:24 2016(r302944)
@@ -979,14 +979,14 @@ g_Ctoc(const Char *str, char *buf, size_
 
memset(&mbs, 0, sizeof(mbs));
while (len >= MB_CUR_MAX) {
-   clen = wcrtomb(buf, *str, &mbs);
+   clen = wcrtomb(buf, CHAR(*str), &mbs);
if (clen == (size_t)-1) {
/* XXX See initial comment #2. */
-   *buf = (char)*str;
+   *buf = (char)CHAR(*str);
clen = 1;
memset(&mbs, 0, sizeof(mbs));
}
-   if (*buf == '\0')
+   if (CHAR(*str) == EOS)
return (0);
str++;
buf += clen;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302943 - head/lib/libc/gen

2016-07-17 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 17 09:39:59 2016
New Revision: 302943
URL: https://svnweb.freebsd.org/changeset/base/302943

Log:
  1) This file full of direct char <-> wchar_t assignment, not converted, cut
  them down. This hack still remains:
   * 2. Illegal byte sequences in filenames are handled by treating them as
   *single-byte characters with a values of such bytes of the sequence
   *cast to wchar_t.
  
  2) Reword the comment in the hack above to reflect implementation.
  
  3) Protect signed wchar_t from sign extension when a signed char is assigned
  to it in the hack above.
  
  3) Corresponding backward hack in g_Ctoc() was not implemented, so all
  pathes with illegal byte sequences are skipped as result, implement it now.
  
  4) globtilde() forget to convert expanded user home dir from multibyte to
  wchar.
  
  5) Protect globtilde() from long expansion truncation.
  
  6) Results was not sorted according to collate as POSIX requires.

Modified:
  head/lib/libc/gen/glob.c

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSun Jul 17 08:31:21 2016(r302942)
+++ head/lib/libc/gen/glob.cSun Jul 17 09:39:59 2016(r302943)
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
  * 1. Patterns with illegal byte sequences match nothing - even if
  *GLOB_NOCHECK is specified.
  * 2. Illegal byte sequences in filenames are handled by treating them as
- *single-byte characters with a value of the first byte of the sequence
+ *single-byte characters with a values of such bytes of the sequence
  *cast to wchar_t.
  * 3. State-dependent encodings are not currently supported.
  */
@@ -113,23 +113,21 @@ struct glob_limit {
size_t  l_string_cnt;
 };
 
-#defineDOLLAR  '$'
-#defineDOT '.'
-#defineEOS '\0'
-#defineLBRACKET'['
-#defineNOT '!'
-#defineQUESTION'?'
-#defineQUOTE   '\\'
-#defineRANGE   '-'
-#defineRBRACKET']'
-#defineSEP '/'
-#defineSTAR'*'
-#defineTILDE   '~'
-#defineUNDERSCORE  '_'
-#defineLBRACE  '{'
-#defineRBRACE  '}'
-#defineSLASH   '/'
-#defineCOMMA   ','
+#defineDOT L'.'
+#defineEOS L'\0'
+#defineLBRACKETL'['
+#defineNOT L'!'
+#defineQUESTIONL'?'
+#defineQUOTE   L'\\'
+#defineRANGE   L'-'
+#defineRBRACKETL']'
+#defineSEP L'/'
+#defineSTARL'*'
+#defineTILDE   L'~'
+#defineLBRACE  L'{'
+#defineRBRACE  L'}'
+#defineSLASH   L'/'
+#defineCOMMA   L','
 
 #ifndef DEBUG
 
@@ -154,12 +152,12 @@ typedef char Char;
 
 #defineCHAR(c) ((Char)((c)&M_CHAR))
 #defineMETA(c) ((Char)((c)|M_QUOTE))
-#defineM_ALL   META('*')
-#defineM_END   META(']')
-#defineM_NOT   META('!')
-#defineM_ONE   META('?')
-#defineM_RNG   META('-')
-#defineM_SET   META('[')
+#defineM_ALL   META(L'*')
+#defineM_END   META(L']')
+#defineM_NOT   META(L'!')
+#defineM_ONE   META(L'?')
+#defineM_RNG   META(L'-')
+#defineM_SET   META(L'[')
 #defineismeta(c)   (((c)&M_QUOTE) != 0)
 
 
@@ -233,8 +231,8 @@ glob(const char * __restrict pattern, in
/* Protect the quoted characters. */
memset(&mbs, 0, sizeof(mbs));
while (bufend - bufnext >= MB_CUR_MAX) {
-   if (*patnext == QUOTE) {
-   if (*++patnext == EOS) {
+   if (*patnext == '\\') {
+   if (*++patnext == '\0') {
*bufnext++ = QUOTE | M_PROTECT;
continue;
}
@@ -401,9 +399,15 @@ static const Char *
 globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
 {
struct passwd *pwd;
-   char *h;
+   char *h, *sc;
const Char *p;
Char *b, *eb;
+   wchar_t wc;
+   wchar_t wbuf[MAXPATHLEN];
+   wchar_t *wbufend, *dc;
+   size_t clen;
+   mbstate_t mbs;
+   int too_long;
 
if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
return (pattern);
@@ -412,13 +416,17 @@ globtilde(const Char *pattern, Char *pat
 * Copy up to the end of the string or / 
 */
eb = &patbuf[patbuf_len - 1];
-   for (p = pattern + 1, h = (char *) pa

svn commit: r302937 - in head/bin/sh: . tests/expansion

2016-07-16 Thread Andrey A. Chernov
Author: ache
Date: Sat Jul 16 13:26:18 2016
New Revision: 302937
URL: https://svnweb.freebsd.org/changeset/base/302937

Log:
  Path generation was not according to collate
  
  Approved by:jilles

Added:
  head/bin/sh/tests/expansion/pathname6.0   (contents, props changed)
Modified:
  head/bin/sh/expand.c
  head/bin/sh/tests/expansion/Makefile
  head/bin/sh/tests/expansion/pathname1.0
  head/bin/sh/tests/expansion/pathname2.0

Modified: head/bin/sh/expand.c
==
--- head/bin/sh/expand.cSat Jul 16 13:24:58 2016(r302936)
+++ head/bin/sh/expand.cSat Jul 16 13:26:18 2016(r302937)
@@ -1196,7 +1196,7 @@ expsortcmp(const void *p1, const void *p
const char *s1 = *(const char * const *)p1;
const char *s2 = *(const char * const *)p2;
 
-   return (strcmp(s1, s2));
+   return (strcoll(s1, s2));
 }
 
 

Modified: head/bin/sh/tests/expansion/Makefile
==
--- head/bin/sh/tests/expansion/MakefileSat Jul 16 13:24:58 2016
(r302936)
+++ head/bin/sh/tests/expansion/MakefileSat Jul 16 13:26:18 2016
(r302937)
@@ -66,6 +66,7 @@ ${PACKAGE}FILES+= pathname2.0
 ${PACKAGE}FILES+=  pathname3.0
 ${PACKAGE}FILES+=  pathname4.0
 ${PACKAGE}FILES+=  pathname5.0
+${PACKAGE}FILES+=  pathname6.0
 ${PACKAGE}FILES+=  plus-minus1.0
 ${PACKAGE}FILES+=  plus-minus2.0
 ${PACKAGE}FILES+=  plus-minus3.0

Modified: head/bin/sh/tests/expansion/pathname1.0
==
--- head/bin/sh/tests/expansion/pathname1.0 Sat Jul 16 13:24:58 2016
(r302936)
+++ head/bin/sh/tests/expansion/pathname1.0 Sat Jul 16 13:26:18 2016
(r302937)
@@ -1,5 +1,9 @@
 # $FreeBSD$
 
+unset LC_ALL
+LC_COLLATE=C
+export LC_COLLATE
+
 failures=0
 
 check() {

Modified: head/bin/sh/tests/expansion/pathname2.0
==
--- head/bin/sh/tests/expansion/pathname2.0 Sat Jul 16 13:24:58 2016
(r302936)
+++ head/bin/sh/tests/expansion/pathname2.0 Sat Jul 16 13:26:18 2016
(r302937)
@@ -1,5 +1,9 @@
 # $FreeBSD$
 
+unset LC_ALL
+LC_COLLATE=C
+export LC_COLLATE
+
 failures=0
 
 check() {

Added: head/bin/sh/tests/expansion/pathname6.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/bin/sh/tests/expansion/pathname6.0 Sat Jul 16 13:26:18 2016
(r302937)
@@ -0,0 +1,29 @@
+# $FreeBSD$
+
+unset LC_ALL
+LC_COLLATE=en_US.US-ASCII
+export LC_COLLATE
+
+failures=0
+
+check() {
+   testcase=$1
+   expect=$2
+   eval "set -- $testcase"
+   actual="$*"
+   if [ "$actual" != "$expect" ]; then
+   failures=$((failures+1))
+   printf '%s\n' "For $testcase, expected $expect actual $actual"
+   fi
+}
+
+set -e
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XX)
+trap 'rm -rf $T' 0
+cd -P $T
+
+touch A B a b
+
+check '*' 'a A b B'
+
+exit $((failures != 0))
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302833 - head/gnu/usr.bin/grep

2016-07-14 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul 14 09:47:49 2016
New Revision: 302833
URL: https://svnweb.freebsd.org/changeset/base/302833

Log:
  Back out non-collating [a-z] ranges.
  Instead of changing the whole course to another POSIX-permitted way
  for consistency and uniformity I decide to completely ignore missing
  regex fucntionality and focus on fixing bugs in what we have now,
  too many small obstacles we have choicing other way, counting ports.
  Corresponding libc changes are backed out in r302824.

Modified:
  head/gnu/usr.bin/grep/dfa.c

Modified: head/gnu/usr.bin/grep/dfa.c
==
--- head/gnu/usr.bin/grep/dfa.c Thu Jul 14 09:45:07 2016(r302832)
+++ head/gnu/usr.bin/grep/dfa.c Thu Jul 14 09:47:49 2016(r302833)
@@ -2547,13 +2547,8 @@ match_mb_charset (struct dfa *d, int s, 
   wcbuf[2] = work_mbc->range_sts[i];
   wcbuf[4] = work_mbc->range_ends[i];
 
-#ifdef __FreeBSD__
-  if (wcscmp(wcbuf, wcbuf+2) >= 0 &&
- wcscmp(wcbuf+4, wcbuf) >= 0)
-#else
   if (wcscoll(wcbuf, wcbuf+2) >= 0 &&
  wcscoll(wcbuf+4, wcbuf) >= 0)
-#endif
goto charset_matched;
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302832 - head/contrib/libgnuregex

2016-07-14 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul 14 09:45:07 2016
New Revision: 302832
URL: https://svnweb.freebsd.org/changeset/base/302832

Log:
  Back out non-collating [a-z] ranges.
  Instead of changing the whole course to another POSIX-permitted way
  for consistency and uniformity I decide to completely ignore missing
  regex fucntionality and focus on fixing bugs in what we have now,
  too many small obstacles we have choicing other way, counting ports.
  Corresponding libc changes are backed out in r302824.

Modified:
  head/contrib/libgnuregex/regcomp.c
  head/contrib/libgnuregex/regexec.c

Modified: head/contrib/libgnuregex/regcomp.c
==
--- head/contrib/libgnuregex/regcomp.c  Thu Jul 14 09:40:42 2016
(r302831)
+++ head/contrib/libgnuregex/regcomp.c  Thu Jul 14 09:45:07 2016
(r302832)
@@ -2664,11 +2664,7 @@ build_range_exp (bitset_t sbcset, bracke
   return REG_ECOLLATE;
 cmp_buf[0] = start_wc;
 cmp_buf[4] = end_wc;
-#ifdef __FreeBSD__
-if (wcscmp (cmp_buf, cmp_buf + 4) > 0)
-#else
 if (wcscoll (cmp_buf, cmp_buf + 4) > 0)
-#endif
   return REG_ERANGE;
 
 /* Got valid collation sequence values, add them as a new entry.
@@ -2710,13 +2706,8 @@ build_range_exp (bitset_t sbcset, bracke
 for (wc = 0; wc < SBC_MAX; ++wc)
   {
cmp_buf[2] = wc;
-#ifdef __FreeBSD__
-   if (wcscmp (cmp_buf, cmp_buf + 2) <= 0
-   && wcscmp (cmp_buf + 2, cmp_buf + 4) <= 0)
-#else
if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
&& wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
-#endif
  bitset_set (sbcset, wc);
   }
   }

Modified: head/contrib/libgnuregex/regexec.c
==
--- head/contrib/libgnuregex/regexec.c  Thu Jul 14 09:40:42 2016
(r302831)
+++ head/contrib/libgnuregex/regexec.c  Thu Jul 14 09:45:07 2016
(r302832)
@@ -3964,13 +3964,8 @@ check_node_accept_bytes (const re_dfa_t 
{
  cmp_buf[0] = cset->range_starts[i];
  cmp_buf[4] = cset->range_ends[i];
-#ifdef __FreeBSD__
- if (wcscmp (cmp_buf, cmp_buf + 2) <= 0
- && wcscmp (cmp_buf + 2, cmp_buf + 4) <= 0)
-#else
  if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
  && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
-#endif
{
  match_len = char_len;
  goto check_node_accept_bytes_match;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302831 - head/contrib/tcsh

2016-07-14 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul 14 09:40:42 2016
New Revision: 302831
URL: https://svnweb.freebsd.org/changeset/base/302831

Log:
  To mimic system glob, we definitely don't need manual upper/lower hack.
  The author clearly disagree in the comment, so this patch will be not
  submitted upstream.

Modified:
  head/contrib/tcsh/glob.c

Modified: head/contrib/tcsh/glob.c
==
--- head/contrib/tcsh/glob.cThu Jul 14 09:37:16 2016(r302830)
+++ head/contrib/tcsh/glob.cThu Jul 14 09:40:42 2016(r302831)
@@ -142,12 +142,14 @@ globcharcoll(__Char c1, __Char c2, int c
c1 = towlower(c1);
c2 = towlower(c2);
 } else {
+#ifndef __FreeBSD__
/* This should not be here, but I'll rather leave it in than engage in
   a LC_COLLATE flamewar about a shell I don't use... */
if (iswlower(c1) && iswupper(c2))
return (1);
if (iswupper(c1) && iswlower(c2))
return (-1);
+#endif
 }
 s1[0] = c1;
 s2[0] = c2;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302830 - head/contrib/tcsh

2016-07-14 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul 14 09:37:16 2016
New Revision: 302830
URL: https://svnweb.freebsd.org/changeset/base/302830

Log:
  Back out non-collating [a-z] ranges.
  Instead of changing the whole course to another POSIX-permitted way
  for consistency and uniformity I decide to completely ignore missing
  regex fucntionality and focus on fixing bugs in what we have now,
  too many small obstacles we have choicing other way, counting ports.
  Corresponding libc changes are backed out in r302824.

Modified:
  head/contrib/tcsh/glob.c

Modified: head/contrib/tcsh/glob.c
==
--- head/contrib/tcsh/glob.cThu Jul 14 09:34:42 2016(r302829)
+++ head/contrib/tcsh/glob.cThu Jul 14 09:37:16 2016(r302830)
@@ -142,23 +142,17 @@ globcharcoll(__Char c1, __Char c2, int c
c1 = towlower(c1);
c2 = towlower(c2);
 } else {
-#ifndef __FreeBSD__
/* This should not be here, but I'll rather leave it in than engage in
   a LC_COLLATE flamewar about a shell I don't use... */
if (iswlower(c1) && iswupper(c2))
return (1);
if (iswupper(c1) && iswlower(c2))
return (-1);
-#endif
 }
 s1[0] = c1;
 s2[0] = c2;
 s1[1] = s2[1] = '\0';
-#ifdef __FreeBSD__
-return wcscmp(s1, s2);
-#else
 return wcscoll(s1, s2);
-#endif
 # else /* not WIDE_STRINGS */
 char s1[2], s2[2];
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   >