svn commit: r196750 - head/contrib/ee

2009-09-01 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep  2 04:26:34 2009
New Revision: 196750
URL: http://svn.freebsd.org/changeset/base/196750

Log:
  1) Use isprint() instead of hardcoded values to detect non-printable.
  2) Use (unsigned char) cast in waddch() calls.
  It fix highlighting bug: sign extension of 8bit to the attributes area.
  3) Use setlocale() in any case.

Modified:
  head/contrib/ee/ee.c

Modified: head/contrib/ee/ee.c
==
--- head/contrib/ee/ee.cWed Sep  2 03:03:53 2009(r196749)
+++ head/contrib/ee/ee.cWed Sep  2 04:26:34 2009(r196750)
@@ -726,7 +726,7 @@ int character;  /* new character
*/
}
*point = character; /* insert new character */
wclrtoeol(text_win);
-   if (((character >= 0) && (character < ' ')) || (character >= 127)) /* 
check for TAB character*/
+   if (!isprint((unsigned char)character)) /* check for TAB character*/
{
scr_pos = scr_horz += out_char(text_win, character, scr_horz);
point++;
@@ -734,7 +734,7 @@ int character;  /* new character
*/
}
else
{
-   waddch(text_win, character);
+   waddch(text_win, (unsigned char)character);
scr_pos = ++scr_horz;
point++;
position ++;
@@ -969,17 +969,17 @@ int column;
}
else
{
-   waddch(window, (char)character );
+   waddch(window, (unsigned char)character );
return(1);
}
}
else
{
-   waddch(window, (char)character);
+   waddch(window, (unsigned char)character);
return(1);
}
for (i2 = 0; (string[i2] != '\0') && (((column+i2+1)-horiz_offset) < 
last_col); i2++)
-   waddch(window, string[i2]);
+   waddch(window, (unsigned char)string[i2]);
return(strlen(string));
 }
 
@@ -1044,7 +1044,7 @@ int length;   /* length (in bytes) of line
wclrtoeol(text_win);
while ((posit < length) && (column <= last_col))
{
-   if ((*temp < 32) || (*temp >= 127))
+   if (!isprint(*temp))
{
column += len_char(*temp, abs_column);
abs_column += out_char(text_win, *temp, abs_column);
@@ -1923,13 +1923,13 @@ int advance;/* if true, skip leading s
}
*nam_str = in;
g_pos++;
-   if (((in < ' ') || (in > 126)) && (g_horz < (last_col - 
1)))
+   if (!isprint((unsigned char)in) && (g_horz < (last_col 
- 1)))
g_horz += out_char(com_win, in, g_horz);
else
{
g_horz++;
if (g_horz < (last_col - 1))
-   waddch(com_win, in);
+   waddch(com_win, (unsigned char)in);
}
nam_str++;
}
@@ -5085,8 +5085,8 @@ strings_init()
 {
int counter;
 
-#ifndef NO_CATGETS
setlocale(LC_ALL, "");
+#ifndef NO_CATGETS
catalog = catopen("ee", NL_CAT_LOCALE);
 #endif /* NO_CATGETS */
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196751 - head/contrib/ee

2009-09-01 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep  2 04:43:46 2009
New Revision: 196751
URL: http://svn.freebsd.org/changeset/base/196751

Log:
  Move  out of NO_CATGETS define too (as setlocale() in prev.
  commit)

Modified:
  head/contrib/ee/ee.c

Modified: head/contrib/ee/ee.c
==
--- head/contrib/ee/ee.cWed Sep  2 04:26:34 2009(r196750)
+++ head/contrib/ee/ee.cWed Sep  2 04:43:46 2009(r196751)
@@ -83,6 +83,7 @@ char *version = "@(#) ee, version "  EE_
 #include 
 #include 
 #include 
+#include 
 
 #ifdef HAS_SYS_WAIT
 #include 
@@ -100,9 +101,7 @@ char *version = "@(#) ee, version "  EE_
 #include 
 #endif
 
-
 #ifndef NO_CATGETS
-#include 
 #include 
 
 nl_catd catalog;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2009-09-01 Thread Andrey A. Chernov
Author: ache
Date: Wed Sep  2 04:56:30 2009
New Revision: 196752
URL: http://svn.freebsd.org/changeset/base/196752

Log:
  Use (unsigned char) cast for ctype macro

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

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cWed Sep  2 04:43:46 2009
(r196751)
+++ head/lib/libc/stdtime/strptime.cWed Sep  2 04:56:30 2009
(r196752)
@@ -529,7 +529,7 @@ label:
buf++;
i = 0;
for (len = 4; len > 0; len--) {
-   if (isdigit((int)*buf)) {
+   if (isdigit((unsigned char)*buf)) {
i *= 10;
i += *buf - '0';
buf++;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196788 - head/share/colldef

2009-09-03 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  3 16:53:11 2009
New Revision: 196788
URL: http://svn.freebsd.org/changeset/base/196788

Log:
  Add lv_LV, move lt_LT to common part

Added:
  head/share/colldef/la_LN.ISO8859-13.src
 - copied, changed from r196787, head/share/colldef/lt_LT.ISO8859-13.src
Deleted:
  head/share/colldef/lt_LT.ISO8859-13.src
Modified:
  head/share/colldef/Makefile

Modified: head/share/colldef/Makefile
==
--- head/share/colldef/Makefile Thu Sep  3 16:34:20 2009(r196787)
+++ head/share/colldef/Makefile Thu Sep  3 16:53:11 2009(r196788)
@@ -20,6 +20,7 @@ LOCALES=  bg_BG.CP1251 \
is_IS.ISO8859-15 \
kk_KZ.PT154 \
la_LN.ISO8859-1 \
+   la_LN.ISO8859-13 \
la_LN.ISO8859-15 \
la_LN.ISO8859-2 \
la_LN.ISO8859-4 \
@@ -27,7 +28,6 @@ LOCALES=  bg_BG.CP1251 \
no_NO.ISO8859-1 \
no_NO.ISO8859-15 \
lt_LT.ISO8859-4 \
-   lt_LT.ISO8859-13 \
pl_PL.ISO8859-2 \
ru_RU.CP1251 \
ru_RU.CP866 \
@@ -62,7 +62,7 @@ ${locale}.out: map.${locale:E}
 CLEANFILES=${FILES}
 
 ENCODINGS= Big5 Big5HKSCS CP949 eucCN eucJP eucKR GB18030 GB2312 GBK \
-   ISO8859-1 ISO8859-2 ISO8859-15 SJIS US-ASCII UTF-8
+   ISO8859-1 ISO8859-2 ISO8859-13 ISO8859-15 SJIS US-ASCII UTF-8
 
 ISO8859-1_Big5=is_IS:zh_TW
 ISO8859-1_ISO8859-1= ${ISO8859-15_ISO8859-15} pt_PT:pt_BR
@@ -78,6 +78,9 @@ ISO8859-15_ISO8859-15= \
 LATIN2LINKS=hu_HU ro_RO sr_YU
 ISO8859-2_ISO8859-2= ${LATIN2LINKS:C/^/la_LN:/} cs_CZ:sk_SK
 
+LATIN13LINKS=  lt_LT lv_LV
+ISO8859-13_ISO8859-13= ${LATIN13LINKS:C/^/la_LN:/}
+
 US-ASCII_Big5HKSCS= la_LN:zh_HK
 US-ASCII_CP949=la_LN:ko_KR
 US-ASCII_eucCN=la_LN:zh_CN
@@ -95,7 +98,7 @@ UTF8LINKS=af_ZA am_ET be_BY bg_BG ca_AD
da_DK de_AT de_CH de_DE \
el_GR en_AU en_CA en_GB en_IE en_NZ en_US es_ES et_EE eu_ES \
fi_FI fr_BE fr_CA fr_CH fr_FR he_IL hr_HR hu_HU hy_AM \
-   is_IS it_CH it_IT ja_JP kk_KZ ko_KR lt_LT mn_MN \
+   is_IS it_CH it_IT ja_JP kk_KZ ko_KR lt_LT lv_LV mn_MN \
nb_NO nl_BE nl_NL nn_NO no_NO pl_PL pt_BR pt_PT \
ro_RO ru_RU sk_SK sl_SI sr_YU sv_SE tr_TR uk_UA zh_CN zh_HK \
zh_TW

Copied and modified: head/share/colldef/la_LN.ISO8859-13.src (from r196787, 
head/share/colldef/lt_LT.ISO8859-13.src)
==
--- head/share/colldef/lt_LT.ISO8859-13.src Thu Sep  3 16:34:20 2009
(r196787, copy source)
+++ head/share/colldef/la_LN.ISO8859-13.src Thu Sep  3 16:53:11 2009
(r196788)
@@ -1,4 +1,4 @@
-# Lithuanian (backward compatible with ASCII)
+# Latin-7 / Baltic Rim (backward compatible with ASCII)
 #
 # $FreeBSD$
 #
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196784 - head/etc/mtree

2009-09-03 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  3 16:25:25 2009
New Revision: 196784
URL: http://svn.freebsd.org/changeset/base/196784

Log:
  Add la_LN.ISO8859-13 and lv_LV

Modified:
  head/etc/mtree/BSD.usr.dist

Modified: head/etc/mtree/BSD.usr.dist
==
--- head/etc/mtree/BSD.usr.dist Thu Sep  3 16:24:21 2009(r196783)
+++ head/etc/mtree/BSD.usr.dist Thu Sep  3 16:25:25 2009(r196784)
@@ -553,6 +553,8 @@
 ..
 la_LN.ISO8859-1
 ..
+la_LN.ISO8859-13
+..
 la_LN.ISO8859-15
 ..
 la_LN.ISO8859-2
@@ -567,6 +569,10 @@
 ..
 lt_LT.UTF-8
 ..
+lv_LV.ISO8859-13
+..
+lv_LV.UTF-8
+..
 mn_MN.UTF-8
 ..
 nb_NO.ISO8859-1
@@ -1077,6 +1083,8 @@
 ..
 la_LN.ISO8859-1
 ..
+la_LN.ISO8859-13
+..
 la_LN.ISO8859-15
 ..
 la_LN.ISO8859-2
@@ -1091,6 +1099,10 @@
 ..
 lt_LT.UTF-8
 ..
+lv_LV.ISO8859-13
+..
+lv_LV.UTF-8
+..
 mn_MN.UTF-8
 ..
 nl_BE.ISO8859-1
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196790 - head/share/mklocale

2009-09-03 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  3 17:12:45 2009
New Revision: 196790
URL: http://svn.freebsd.org/changeset/base/196790

Log:
  Add lv_LV, move lt_LT to common part

Added:
  head/share/mklocale/la_LN.ISO8859-13.src
 - copied unchanged from r196789, head/share/mklocale/lt_LT.ISO8859-13.src
Deleted:
  head/share/mklocale/lt_LT.ISO8859-13.src
Modified:
  head/share/mklocale/Makefile

Modified: head/share/mklocale/Makefile
==
--- head/share/mklocale/MakefileThu Sep  3 17:04:42 2009
(r196789)
+++ head/share/mklocale/MakefileThu Sep  3 17:12:45 2009
(r196790)
@@ -13,11 +13,11 @@ LOCALES=UTF-8 \
ko_KR.CP949 \
ko_KR.eucKR \
la_LN.ISO8859-1 \
+   la_LN.ISO8859-13 \
la_LN.ISO8859-15 \
la_LN.ISO8859-2 \
la_LN.ISO8859-4 \
la_LN.US-ASCII \
-   lt_LT.ISO8859-13 \
ru_RU.CP866 \
ru_RU.ISO8859-5 \
ru_RU.KOI8-R \
@@ -47,7 +47,7 @@ FILESDIR_${locale}.out= ${LOCALEDIR}/${l
 CLEANFILES=${FILES}
 
 ENCODINGS=  CP1251 ISO8859-1 ISO8859-2 ISO8859-4 ISO8859-5 \
-   ISO8859-15 US-ASCII UTF-8
+   ISO8859-13 ISO8859-15 US-ASCII UTF-8
 
 ASCIILINKS=en_AU en_CA en_GB en_NZ en_US
 US-ASCII_US-ASCII= ${ASCIILINKS:C/^/la_LN:/}
@@ -71,6 +71,9 @@ ISO8859-4_ISO8859-4= ${LATIN4LINKS:C/^/l
 LATIN5LINKS=   sr_YU uk_UA be_BY
 ISO8859-5_ISO8859-5= ${LATIN5LINKS:C/^/ru_RU:/}
 
+LATIN13LINKS=  lt_LT lv_LV
+ISO8859-13_ISO8859-13= ${LATIN13LINKS:C/^/la_LN:/}
+
 CP1251LINKS=ru_RU be_BY uk_UA
 CP1251_CP1251= ${CP1251LINKS:C/^/bg_BG:/}
 
@@ -79,7 +82,7 @@ UTF8LINKS=af_ZA be_BY bg_BG ca_AD ca_ES
en_AU en_CA en_GB en_IE en_NZ en_US es_ES et_EE eu_ES fi_FI \
fr_BE \
fr_CA fr_CH fr_FR he_IL hr_HR hu_HU hy_AM is_IS it_CH it_IT \
-   ja_JP kk_KZ ko_KR lt_LT mn_MN \
+   ja_JP kk_KZ ko_KR lt_LT lv_LV mn_MN \
nb_NO nl_BE nl_NL nn_NO no_NO pl_PL pt_BR pt_PT \
ro_RO ru_RU sk_SK sl_SI sr_YU sv_SE tr_TR uk_UA zh_CN zh_HK \
zh_TW

Copied: head/share/mklocale/la_LN.ISO8859-13.src (from r196789, 
head/share/mklocale/lt_LT.ISO8859-13.src)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/mklocale/la_LN.ISO8859-13.srcThu Sep  3 17:12:45 2009
(r196790, copy of r196789, head/share/mklocale/lt_LT.ISO8859-13.src)
@@ -0,0 +1,49 @@
+/*
+ * LOCALE_CTYPE for the iso_8859_13 Locale
+ *
+ * $FreeBSD$
+ */
+
+ENCODING   "NONE"
+VARIABLEISO 8859-13 Latin-7 character set
+
+#
+# This is a comment
+#
+ALPHA  'A' - 'Z' 'a' - 'z' 
+ALPHA  0xaa 0xba 0xc0 - 0xd6 0xd8 - 0xde 0xe0 - 0xf6 0xf8 - 0xfe
+CONTROL0x00 - 0x1f 0x7f - 0x9f
+DIGIT  '0' - '9'
+GRAPH   0x21 - 0x7e 0xa1 - 0xff
+LOWER  'a' - 'z' 
+LOWER  0xba 0xdf - 0xf6 0xf8 - 0xfe 
+PUNCT  0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e 
+PUNCT  0xa1 - 0xa9 0xab - 0xb9 0xbb -0xbf 0xd7 0xdf 0xf7 0xff
+SPACE  0x09 - 0x0d 0x20 0xa0
+UPPER  'A' - 'Z' 
+UPPER  0xaa 0xc0 - 0xd6 0xd8 - 0xde
+XDIGIT  '0' - '9' 'a' - 'f' 'A' - 'F'
+BLANK  ' ' '\t' 0xa0
+PRINT  0x20 - 0x7e 0xa0 - 0xff
+
+MAPLOWER   <'A' - 'Z' : 'a'>
+MAPLOWER   <'a' - 'z' : 'a'>
+MAPLOWER   <0xaa 0xba>
+MAPLOWER   <0xba 0xba>
+MAPLOWER   <0xc0 - 0xd6 : 0xe0>
+MAPLOWER   <0xd8 - 0xde : 0xf8>
+MAPLOWER   <0xe0 - 0xf6 : 0xe0>
+MAPLOWER   <0xf8 - 0xfe : 0xf8>
+
+MAPUPPER   <'A' - 'Z' : 'A'>
+MAPUPPER   <'a' - 'z' : 'A'>
+MAPUPPER   <0xaa 0xaa>
+MAPUPPER   <0xba 0xaa>
+MAPUPPER   <0xc0 - 0xd6 : 0xc0>
+MAPUPPER   <0xd8 - 0xdf : 0xd8>
+MAPUPPER   <0xe0 - 0xf6 : 0xc0>
+MAPUPPER   <0xf8 - 0xfe : 0xd8>
+
+TODIGIT<'0' - '9' : 0>
+TODIGIT<'A' - 'F' : 10>
+TODIGIT<'a' - 'f' : 10>
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196792 - head/share/numericdef

2009-09-03 Thread Andrey A. Chernov
Author: ache
Date: Thu Sep  3 17:37:23 2009
New Revision: 196792
URL: http://svn.freebsd.org/changeset/base/196792

Log:
  Add lv_LV

Modified:
  head/share/numericdef/Makefile

Modified: head/share/numericdef/Makefile
==
--- head/share/numericdef/Makefile  Thu Sep  3 17:13:54 2009
(r196791)
+++ head/share/numericdef/Makefile  Thu Sep  3 17:37:23 2009
(r196792)
@@ -107,7 +107,8 @@ ISO8859-5_CP1251= uk_UA
 ISO8859-7_UTF-8= el_GR
 ISO8859-9_UTF-8= tr_TR
 ISO8859-13_ISO8859-4= lt_LT
-ISO8859-13_UTF-8= lt_LT
+ISO8859-13_ISO8859-13= lt_LT:lv_LV
+ISO8859-13_UTF-8= lt_LT lt_LT:lv_LV
 ISO8859-15_UTF-8= et_EE
 KOI8-R_CP1251= ru_RU
 KOI8-R_CP866=  ru_RU
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196812 - head/share/monetdef

2009-09-03 Thread Andrey A. Chernov
Author: ache
Date: Fri Sep  4 05:54:45 2009
New Revision: 196812
URL: http://svn.freebsd.org/changeset/base/196812

Log:
  Add lv_LV
  
  PR: 105100
  Submitted by:   Aldis Berjoza 

Added:
  head/share/monetdef/lv_LV.ISO8859-13.src   (contents, props changed)
Modified:
  head/share/monetdef/Makefile

Modified: head/share/monetdef/Makefile
==
--- head/share/monetdef/MakefileFri Sep  4 05:40:06 2009
(r196811)
+++ head/share/monetdef/MakefileFri Sep  4 05:54:45 2009
(r196812)
@@ -44,6 +44,7 @@ LOCALES=  af_ZA.ISO8859-1 \
ko_KR.eucKR \
ko_KR.UTF-8 \
lt_LT.ISO8859-13 \
+   lv_LV.ISO8859-13 \
mn_MN.UTF-8 \
nl_BE.ISO8859-1 \
nl_NL.ISO8859-1 \
@@ -117,7 +118,7 @@ ISO8859-2_UTF-8= hr_HR hu_HU ro_RO sk_SK
 ISO8859-7_UTF-8= el_GR
 ISO8859-9_UTF-8= tr_TR
 ISO8859-13_ISO8859-4= lt_LT
-ISO8859-13_UTF-8= lt_LT
+ISO8859-13_UTF-8= lt_LT lv_LV
 ISO8859-15_ISO8859-15= es_ES:eu_ES
 ISO8859-15_UTF-8= et_EE
 UTF-8_Big5HKSCS= zh_HK

Added: head/share/monetdef/lv_LV.ISO8859-13.src
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/monetdef/lv_LV.ISO8859-13.srcFri Sep  4 05:54:45 2009
(r196812)
@@ -0,0 +1,36 @@
+# $FreeBSD$
+#
+# WARNING: spaces may be essential at the end of lines
+# WARNING: empty lines are essential too
+#
+# int_curr_symbol (last character always SPACE)
+LVL 
+# currency_symbol
+Ls
+# mon_decimal_point
+,
+# mon_thousands_sep
+ 
+# mon_grouping, separated by ;
+3;3
+# positive_sign
+
+# negative_sign
+-
+# int_frac_digits
+2
+# frac_digits
+2
+# p_cs_precedes
+0
+# p_sep_by_space
+1
+# n_cs_precedes
+0
+# n_sep_by_space
+1
+# p_sign_posn
+1
+# n_sign_posn
+1
+# EOF
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196813 - head/share/msgdef

2009-09-03 Thread Andrey A. Chernov
Author: ache
Date: Fri Sep  4 06:19:37 2009
New Revision: 196813
URL: http://svn.freebsd.org/changeset/base/196813

Log:
  Add lv_LV
  
  PR: 105100
  Submitted by:   Aldis Berjoza 

Added:
  head/share/msgdef/lv_LV.ISO8859-13.src   (contents, props changed)
  head/share/msgdef/lv_LV.UTF-8.src   (contents, props changed)
Modified:
  head/share/msgdef/Makefile

Modified: head/share/msgdef/Makefile
==
--- head/share/msgdef/Makefile  Fri Sep  4 05:54:45 2009(r196812)
+++ head/share/msgdef/Makefile  Fri Sep  4 06:19:37 2009(r196813)
@@ -40,6 +40,8 @@ LOCALES=  af_ZA.ISO8859-1 \
ko_KR.UTF-8 \
ko_KR.eucKR \
lt_LT.ISO8859-13 \
+   lv_LV.ISO8859-13 \
+   lv_LV.UTF-8 \
mn_MN.UTF-8 \
nl_NL.ISO8859-1 \
no_NO.ISO8859-1 \

Added: head/share/msgdef/lv_LV.ISO8859-13.src
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/msgdef/lv_LV.ISO8859-13.src  Fri Sep  4 06:19:37 2009
(r196813)
@@ -0,0 +1,14 @@
+# $FreeBSD$
+#
+# WARNING: spaces may be essential at the end of lines
+# WARNING: empty lines are essential too
+#
+# yesexpr
+^[jJyY].*
+# noexpr
+^[nN].*
+# yesstr
+j�
+# nostr
+n�
+# EOF

Added: head/share/msgdef/lv_LV.UTF-8.src
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/msgdef/lv_LV.UTF-8.src   Fri Sep  4 06:19:37 2009
(r196813)
@@ -0,0 +1,14 @@
+# $FreeBSD$
+#
+# WARNING: spaces may be essential at the end of lines
+# WARNING: empty lines are essential too
+#
+# yesexpr
+^[jJyY].*
+# noexpr
+^[nN].*
+# yesstr
+jā
+# nostr
+nē
+# EOF
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196814 - head/share/timedef

2009-09-03 Thread Andrey A. Chernov
Author: ache
Date: Fri Sep  4 06:26:40 2009
New Revision: 196814
URL: http://svn.freebsd.org/changeset/base/196814

Log:
  Add lv_LV
  
  PR: 105100
  Submitted by:   Aldis Berjoza 

Added:
  head/share/timedef/lv_LV.ISO8859-13.src   (contents, props changed)
  head/share/timedef/lv_LV.UTF-8.src   (contents, props changed)
Modified:
  head/share/timedef/Makefile

Modified: head/share/timedef/Makefile
==
--- head/share/timedef/Makefile Fri Sep  4 06:19:37 2009(r196813)
+++ head/share/timedef/Makefile Fri Sep  4 06:26:40 2009(r196814)
@@ -53,6 +53,8 @@ LOCALES=  am_ET.UTF-8 \
lt_LT.ISO8859-4 \
lt_LT.ISO8859-13 \
lt_LT.UTF-8 \
+   lv_LV.ISO8859-13 \
+   lv_LV.UTF-8 \
mn_MN.UTF-8 \
nb_NO.ISO8859-1 \
nb_NO.UTF-8 \

Added: head/share/timedef/lv_LV.ISO8859-13.src
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/timedef/lv_LV.ISO8859-13.src Fri Sep  4 06:26:40 2009
(r196814)
@@ -0,0 +1,101 @@
+# $FreeBSD$
+# WARNING: spaces may be essential at the end of lines
+# WARNING: empty lines are essential too
+#
+# Short month names
+#
+Jan
+Feb
+Mar
+Apr
+Mai
+J�n
+J�l
+Aug
+Sep
+Okt
+Nov
+Dec
+#
+# Long month names
+#
+janv�ris
+febru�ris
+marts
+apr�lis
+maijs
+j�nijs
+j�lijs
+augusts
+septembris
+oktobris
+novembris
+decembris
+#
+# Short weekday names
+#
+Sv
+Pr
+Ot
+Tr
+Ct
+Pk
+Ss
+#
+# Long weekday names
+#
+Sv�tdiena
+Pirmdiena
+Otrdiena
+Tre�diena
+Ceturtdiena
+Piektdiena
+Sestdiena
+#
+# X_fmt
+#
+%H:%M:%S
+#
+# x_fmt
+#
+%d/%m/%Y
+#
+# c_fmt
+# %A, %Y m. %B %e d. %T
+%e. %b, %Y. gads %X
+#
+# am
+#
+
+#
+# pm
+#
+
+#
+# date_fmt
+#
+%A, %Y. gada %e. %B %T %Z
+#
+# Long month names in alternative form
+#
+janv�ris
+febru�ris
+marts
+apr�lis
+maijs
+j�nijs
+j�lijs
+augusts
+septembris
+oktobris
+novembris
+decembris
+#
+# md_order
+#
+md
+#
+# ampm_fmt
+#
+
+# EOF

Added: head/share/timedef/lv_LV.UTF-8.src
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/timedef/lv_LV.UTF-8.src  Fri Sep  4 06:26:40 2009
(r196814)
@@ -0,0 +1,101 @@
+# $FreeBSD$
+# WARNING: spaces may be essential at the end of lines
+# WARNING: empty lines are essential too
+#
+# Short month names
+#
+Jan
+Feb
+Mar
+Apr
+Mai
+Jūn
+Jūl
+Aug
+Sep
+Okt
+Nov
+Dec
+#
+# Long month names
+#
+janvāris
+februāris
+marts
+aprīlis
+maijs
+jūnijs
+jūlijs
+augusts
+septembris
+oktobris
+novembris
+decembris
+#
+# Short weekday names
+#
+Sv
+Pr
+Ot
+Tr
+Ct
+Pk
+Ss
+#
+# Long weekday names
+#
+Svētdiena
+Pirmdiena
+Otrdiena
+Trešdiena
+Ceturtdiena
+Piektdiena
+Sestdiena
+#
+# X_fmt
+#
+%H:%M:%S
+#
+# x_fmt
+#
+%d/%m/%Y
+#
+# c_fmt
+# %A, %Y m. %B %e d. %T
+%e. %b, %Y. gads %X
+#
+# am
+#
+
+#
+# pm
+#
+
+#
+# date_fmt
+#
+%A, %Y. gada %e. %B %T %Z
+#
+# Long month names in alternative form
+#
+janvāris
+februāris
+marts
+aprīlis
+maijs
+jūnijs
+jūlijs
+augusts
+septembris
+oktobris
+novembris
+decembris
+#
+# md_order
+#
+md
+#
+# ampm_fmt
+#
+
+# EOF
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196818 - head/contrib/ee

2009-09-04 Thread Andrey A. Chernov
Author: ache
Date: Fri Sep  4 07:42:13 2009
New Revision: 196818
URL: http://svn.freebsd.org/changeset/base/196818

Log:
  1) Remove single occurance of HAS_CTYPE ifdef, ctype functions
  used here for a long time and needs their header in anycase.
  2) Add (unsigned char) casts to more ctype macros.
  3) Simplify menu input handling using ctype instead of range unguarded
  hardcoded tricks.

Modified:
  head/contrib/ee/ee.c

Modified: head/contrib/ee/ee.c
==
--- head/contrib/ee/ee.cFri Sep  4 07:33:17 2009(r196817)
+++ head/contrib/ee/ee.cFri Sep  4 07:42:13 2009(r196818)
@@ -72,10 +72,7 @@ char *version = "@(#) ee, version "  EE_
 #include 
 #endif
 
-#ifdef HAS_CTYPE
 #include 
-#endif
-
 #include 
 #include 
 #include 
@@ -1973,7 +1970,7 @@ int sensitive;
}
else
{
-   if (toupper(*strng1) != toupper(*strng2))
+   if (toupper((unsigned char)*strng1) != 
toupper((unsigned char)*strng2))
equal = FALSE;
}
strng1++;
@@ -2445,7 +2442,7 @@ int noverify;
if ((text_changes) && (!noverify))
{
ans = get_string(changes_made_prompt, TRUE);
-   if (toupper(*ans) == toupper(*yes_char))
+   if (toupper((unsigned char)*ans) == toupper((unsigned 
char)*yes_char))
text_changes = FALSE;
else
return(0);
@@ -2522,7 +2519,7 @@ int warn_if_exists;
if ((temp_fp = fopen(file_name, "r")))
{
tmp_point = get_string(file_exists_prompt, TRUE);
-   if (toupper(*tmp_point) == toupper(*yes_char))
+   if (toupper((unsigned char)*tmp_point) == 
toupper((unsigned char)*yes_char))
write_flag = TRUE;
else 
write_flag = FALSE;
@@ -3437,14 +3434,13 @@ struct menu_entries menu_list[];
if (input == -1)
exit(0);
 
-   if (((tolower(input) >= 'a') && (tolower(input) <= 'z')) || 
-   ((input >= '0') && (input <= '9')))
+   if (isascii(input) && isalnum(input))
{
-   if ((tolower(input) >= 'a') && (tolower(input) <= 'z'))
+   if (isalpha(input))
{
temp = 1 + tolower(input) - 'a';
}
-   else if ((input >= '0') && (input <= '9'))
+   else if (isdigit(input))
{
temp = (2 + 'z' - 'a') + (input - '0');
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r196819 - head/usr.bin/ee

2009-09-04 Thread Andrey A. Chernov
Author: ache
Date: Fri Sep  4 07:44:27 2009
New Revision: 196819
URL: http://svn.freebsd.org/changeset/base/196819

Log:
  Remove single occurance of HAS_CTYPE ifdef, ctype functions
  used here for a long time and needs their header in anycase.

Modified:
  head/usr.bin/ee/Makefile

Modified: head/usr.bin/ee/Makefile
==
--- head/usr.bin/ee/MakefileFri Sep  4 07:42:13 2009(r196818)
+++ head/usr.bin/ee/MakefileFri Sep  4 07:44:27 2009(r196819)
@@ -3,7 +3,7 @@
 .PATH: ${.CURDIR}/../../contrib/ee
 
 CFLAGS+= -DHAS_NCURSES -DHAS_UNISTD -DHAS_STDARG -DHAS_STDLIB \
--DHAS_CTYPE -DHAS_SYS_WAIT
+-DHAS_SYS_WAIT
 
 PROG=  ee
 LINKS= ${BINDIR}/ee ${BINDIR}/ree ${BINDIR}/ee ${BINDIR}/edit
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r226889 - head/usr.bin/sed

2011-10-28 Thread Andrey A. Chernov
Author: ache
Date: Fri Oct 28 20:28:13 2011
New Revision: 226889
URL: http://svn.freebsd.org/changeset/base/226889

Log:
  Update '}' description to reflect reality (and POSIX)
  
  PR: 96236
  Submitted by:   "Andreas Kohn" 
  MFC after:  7 days

Modified:
  head/usr.bin/sed/sed.1

Modified: head/usr.bin/sed/sed.1
==
--- head/usr.bin/sed/sed.1  Fri Oct 28 20:00:30 2011(r226888)
+++ head/usr.bin/sed/sed.1  Fri Oct 28 20:28:13 2011(r226889)
@@ -343,7 +343,7 @@ can be preceded by white space and can b
 The function can be preceded by white space.
 The terminating
 .Dq }
-must be preceded by a newline or optional white space.
+must be preceded by a newline and optional white space.
 .Pp
 .Bl -tag -width "XX" -compact
 .It [2addr] function-list
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r226895 - head/usr.bin/sed

2011-10-28 Thread Andrey A. Chernov
Author: ache
Date: Sat Oct 29 06:13:47 2011
New Revision: 226895
URL: http://svn.freebsd.org/changeset/base/226895

Log:
  Reword '}' description to sound more clear.
  
  Submitted by:   dougb
  MFC after:  7 days

Modified:
  head/usr.bin/sed/sed.1

Modified: head/usr.bin/sed/sed.1
==
--- head/usr.bin/sed/sed.1  Sat Oct 29 06:13:44 2011(r226894)
+++ head/usr.bin/sed/sed.1  Sat Oct 29 06:13:47 2011(r226895)
@@ -343,7 +343,7 @@ can be preceded by white space and can b
 The function can be preceded by white space.
 The terminating
 .Dq }
-must be preceded by a newline and optional white space.
+must be preceded by a newline, and may also be preceded by white space.
 .Pp
 .Bl -tag -width "XX" -compact
 .It [2addr] function-list
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r227076 - stable/9/usr.bin/sed

2011-11-04 Thread Andrey A. Chernov
Author: ache
Date: Fri Nov  4 11:14:04 2011
New Revision: 227076
URL: http://svn.freebsd.org/changeset/base/227076

Log:
  MFC r226889,226895:
  
  "or" word in '}' description gives false impression that newline can be
  replaced by space. Reflect reality and POSIX.
  
  PR: 96236
  Submitted by:   dougb
  Approved by:re (kib)

Modified:
  stable/9/usr.bin/sed/sed.1
Directory Properties:
  stable/9/usr.bin/sed/   (props changed)

Modified: stable/9/usr.bin/sed/sed.1
==
--- stable/9/usr.bin/sed/sed.1  Fri Nov  4 09:19:18 2011(r227075)
+++ stable/9/usr.bin/sed/sed.1  Fri Nov  4 11:14:04 2011(r227076)
@@ -343,7 +343,7 @@ can be preceded by white space and can b
 The function can be preceded by white space.
 The terminating
 .Dq }
-must be preceded by a newline or optional white space.
+must be preceded by a newline, and may also be preceded by white space.
 .Pp
 .Bl -tag -width "XX" -compact
 .It [2addr] function-list
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r252608 - in head: include lib/libc/stdlib

2013-07-03 Thread Andrey A. Chernov
Author: ache
Date: Wed Jul  3 21:21:54 2013
New Revision: 252608
URL: http://svnweb.freebsd.org/changeset/base/252608

Log:
  1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,
  but ACM formula we use have internal state (and return value) in the
  [1, 0x7ffe] range, so our RAND_MAX (0x7fff) is never reached
  because it is off by one, zero is not reached too.
  
  Correct both RAND_MAX and rand(3) return value, shifting last one
  to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffd(=new RAND_MAX)]
  range.
  
  2) Add a checks for not overflowing on too big seeds. It may happens on
  the machines, where sizeof(unsigned int) > 32 bits.
  
  Reviewed by:bde [1]
  MFC after:  2 weeks

Modified:
  head/include/stdlib.h
  head/lib/libc/stdlib/rand.c

Modified: head/include/stdlib.h
==
--- head/include/stdlib.h   Wed Jul  3 21:14:57 2013(r252607)
+++ head/include/stdlib.h   Wed Jul  3 21:21:54 2013(r252608)
@@ -69,7 +69,7 @@ typedef struct {
 #defineEXIT_FAILURE1
 #defineEXIT_SUCCESS0
 
-#defineRAND_MAX0x7fff
+#defineRAND_MAX0x7ffd
 
 __BEGIN_DECLS
 #ifdef _XLOCALE_H_

Modified: head/lib/libc/stdlib/rand.c
==
--- head/lib/libc/stdlib/rand.c Wed Jul  3 21:14:57 2013(r252607)
+++ head/lib/libc/stdlib/rand.c Wed Jul  3 21:21:54 2013(r252608)
@@ -67,15 +67,15 @@ do_rand(unsigned long *ctx)
  */
long hi, lo, x;
 
-   /* Can't be initialized with 0, so use another value. */
-   if (*ctx == 0)
-   *ctx = 123459876;
+   /* Must be in [1, 0x7ffe] range at this point. */
hi = *ctx / 127773;
lo = *ctx % 127773;
x = 16807 * lo - 2836 * hi;
if (x < 0)
x += 0x7fff;
-   return ((*ctx = x) % ((u_long)RAND_MAX + 1));
+   *ctx = x;
+   /* Transform to [0, 0x7ffd] range. */
+   return (x - 1);
 #endif  /* !USE_WEAK_SEEDING */
 }
 
@@ -84,6 +84,10 @@ int
 rand_r(unsigned int *ctx)
 {
u_long val = (u_long) *ctx;
+#ifndef USE_WEAK_SEEDING
+   /* Transform to [1, 0x7ffe] range. */
+   val = (val % 0x7ffe) + 1;
+#endif
int r = do_rand(&val);
 
*ctx = (unsigned int) val;
@@ -104,6 +108,10 @@ srand(seed)
 u_int seed;
 {
next = seed;
+#ifndef USE_WEAK_SEEDING
+   /* Transform to [1, 0x7ffe] range. */
+   next = (next % 0x7ffe) + 1;
+#endif
 }
 
 
@@ -125,6 +133,10 @@ sranddev()
mib[0] = CTL_KERN;
mib[1] = KERN_ARND;
sysctl(mib, 2, (void *)&next, &len, NULL, 0);
+#ifndef USE_WEAK_SEEDING
+   /* Transform to [1, 0x7ffe] range. */
+   next = (next % 0x7ffe) + 1;
+#endif
 }
 
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r252648 - head/lib/libc/stdlib

2013-07-03 Thread Andrey A. Chernov
Author: ache
Date: Wed Jul  3 23:27:04 2013
New Revision: 252648
URL: http://svnweb.freebsd.org/changeset/base/252648

Log:
  In addition to prev. commit, for repeated rand_r(3) calls don't forget
  to compensate back at the end incremented at the start internal
  state.
  
  MFC after:  2 weeks

Modified:
  head/lib/libc/stdlib/rand.c

Modified: head/lib/libc/stdlib/rand.c
==
--- head/lib/libc/stdlib/rand.c Wed Jul  3 23:24:53 2013(r252647)
+++ head/lib/libc/stdlib/rand.c Wed Jul  3 23:27:04 2013(r252648)
@@ -90,7 +90,11 @@ rand_r(unsigned int *ctx)
 #endif
int r = do_rand(&val);
 
-   *ctx = (unsigned int) val;
+#ifdef  USE_WEAK_SEEDING
+   *ctx = (unsigned int)val;
+#else
+   *ctx = (unsigned int)(val - 1);
+#endif
return (r);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r252668 - head/lib/libc/stdlib

2013-07-03 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul  4 00:02:10 2013
New Revision: 252668
URL: http://svnweb.freebsd.org/changeset/base/252668

Log:
  After fixing ranges restore POSIX requirement: rand() call without
  srand() must be the same as srand(1); rand();
  (yet one increment)

Modified:
  head/lib/libc/stdlib/rand.c

Modified: head/lib/libc/stdlib/rand.c
==
--- head/lib/libc/stdlib/rand.c Thu Jul  4 00:00:59 2013(r252667)
+++ head/lib/libc/stdlib/rand.c Thu Jul  4 00:02:10 2013(r252668)
@@ -99,7 +99,12 @@ rand_r(unsigned int *ctx)
 }
 
 
-static u_long next = 1;
+static u_long next =
+#ifdef  USE_WEAK_SEEDING
+1;
+#else
+2;
+#endif
 
 int
 rand()
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r252698 - head/lib/libc/stdlib

2013-07-04 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul  4 12:35:39 2013
New Revision: 252698
URL: http://svnweb.freebsd.org/changeset/base/252698

Log:
  Style fix noted by bde@

Modified:
  head/lib/libc/stdlib/rand.c

Modified: head/lib/libc/stdlib/rand.c
==
--- head/lib/libc/stdlib/rand.c Thu Jul  4 12:27:10 2013(r252697)
+++ head/lib/libc/stdlib/rand.c Thu Jul  4 12:35:39 2013(r252698)
@@ -83,12 +83,16 @@ do_rand(unsigned long *ctx)
 int
 rand_r(unsigned int *ctx)
 {
-   u_long val = (u_long) *ctx;
-#ifndef USE_WEAK_SEEDING
+   u_long val;
+   int r;
+
+#ifdef  USE_WEAK_SEEDING
+   val = *ctx;
+#else
/* Transform to [1, 0x7ffe] range. */
-   val = (val % 0x7ffe) + 1;
+   val = (*ctx % 0x7ffe) + 1;
 #endif
-   int r = do_rand(&val);
+   r = do_rand(&val);
 
 #ifdef  USE_WEAK_SEEDING
*ctx = (unsigned int)val;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r253607 - in stable/9: include lib/libc/stdlib

2013-07-24 Thread Andrey A. Chernov
Author: ache
Date: Wed Jul 24 10:12:50 2013
New Revision: 253607
URL: http://svnweb.freebsd.org/changeset/base/253607

Log:
  1) POSIX requires rand(3) return values to be in the [0, RAND_MAX]
  range, but ACM formula we use have internal state (and return value) in
  the [1, 0x7ffe] range, so our RAND_MAX (0x7fff) is never reached
  because it is off by one, zero is not reached too.
  
  Correct both RAND_MAX and rand(3) return value, shifting last one
  to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffd(=new
  RAND_MAX)] range.
  
  2) Add a checks for not overflowing on too big seeds. It may happens on
  the machines, where sizeof(unsigned int) > 32 bits.
  
  This change is binary compatible because range is reduced, not expanded,
  so no bump is needed.
  
  Reviewed by:bde
  Approved by:re (glebius)

Modified:
  stable/9/include/stdlib.h
  stable/9/lib/libc/stdlib/rand.c
Directory Properties:
  stable/9/include/   (props changed)
  stable/9/lib/libc/   (props changed)

Modified: stable/9/include/stdlib.h
==
--- stable/9/include/stdlib.h   Wed Jul 24 09:59:16 2013(r253606)
+++ stable/9/include/stdlib.h   Wed Jul 24 10:12:50 2013(r253607)
@@ -69,7 +69,7 @@ typedef struct {
 #defineEXIT_FAILURE1
 #defineEXIT_SUCCESS0
 
-#defineRAND_MAX0x7fff
+#defineRAND_MAX0x7ffd
 
 __BEGIN_DECLS
 #ifdef _XLOCALE_H_

Modified: stable/9/lib/libc/stdlib/rand.c
==
--- stable/9/lib/libc/stdlib/rand.c Wed Jul 24 09:59:16 2013
(r253606)
+++ stable/9/lib/libc/stdlib/rand.c Wed Jul 24 10:12:50 2013
(r253607)
@@ -67,15 +67,15 @@ do_rand(unsigned long *ctx)
  */
long hi, lo, x;
 
-   /* Can't be initialized with 0, so use another value. */
-   if (*ctx == 0)
-   *ctx = 123459876;
+   /* Must be in [1, 0x7ffe] range at this point. */
hi = *ctx / 127773;
lo = *ctx % 127773;
x = 16807 * lo - 2836 * hi;
if (x < 0)
x += 0x7fff;
-   return ((*ctx = x) % ((u_long)RAND_MAX + 1));
+   *ctx = x;
+   /* Transform to [0, 0x7ffd] range. */
+   return (x - 1);
 #endif  /* !USE_WEAK_SEEDING */
 }
 
@@ -83,15 +83,32 @@ do_rand(unsigned long *ctx)
 int
 rand_r(unsigned int *ctx)
 {
-   u_long val = (u_long) *ctx;
-   int r = do_rand(&val);
+   u_long val;
+   int r;
 
-   *ctx = (unsigned int) val;
+#ifdef  USE_WEAK_SEEDING
+   val = *ctx;
+#else
+   /* Transform to [1, 0x7ffe] range. */
+   val = (*ctx % 0x7ffe) + 1;
+#endif
+   r = do_rand(&val);
+
+#ifdef  USE_WEAK_SEEDING
+   *ctx = (unsigned int)val;
+#else
+   *ctx = (unsigned int)(val - 1);
+#endif
return (r);
 }
 
 
-static u_long next = 1;
+static u_long next =
+#ifdef  USE_WEAK_SEEDING
+1;
+#else
+2;
+#endif
 
 int
 rand()
@@ -104,6 +121,10 @@ srand(seed)
 u_int seed;
 {
next = seed;
+#ifndef USE_WEAK_SEEDING
+   /* Transform to [1, 0x7ffe] range. */
+   next = (next % 0x7ffe) + 1;
+#endif
 }
 
 
@@ -125,6 +146,10 @@ sranddev()
mib[0] = CTL_KERN;
mib[1] = KERN_ARND;
sysctl(mib, 2, (void *)&next, &len, NULL, 0);
+#ifndef USE_WEAK_SEEDING
+   /* Transform to [1, 0x7ffe] range. */
+   next = (next % 0x7ffe) + 1;
+#endif
 }
 
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r249631 - in head/sys: dev/random libkern sys

2013-04-18 Thread Andrey A. Chernov
Author: ache
Date: Fri Apr 19 00:30:52 2013
New Revision: 249631
URL: http://svnweb.freebsd.org/changeset/base/249631

Log:
  Attempt to mitigate poor initialization of arc4 by one-shot
  reinitialization from yarrow right after good entropy is harvested.
  
  Approved by:secteam (delphij)
  MFC after:  1 week

Modified:
  head/sys/dev/random/randomdev_soft.c
  head/sys/libkern/arc4random.c
  head/sys/sys/libkern.h

Modified: head/sys/dev/random/randomdev_soft.c
==
--- head/sys/dev/random/randomdev_soft.cThu Apr 18 23:20:16 2013
(r249630)
+++ head/sys/dev/random/randomdev_soft.cFri Apr 19 00:30:52 2013
(r249631)
@@ -367,6 +367,8 @@ random_yarrow_unblock(void)
selwakeuppri(&random_systat.rsel, PUSER);
wakeup(&random_systat);
}
+   (void)atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_NONE,
+   ARC4_ENTR_HAVE);
 }
 
 static int

Modified: head/sys/libkern/arc4random.c
==
--- head/sys/libkern/arc4random.c   Thu Apr 18 23:20:16 2013
(r249630)
+++ head/sys/libkern/arc4random.c   Fri Apr 19 00:30:52 2013
(r249631)
@@ -24,6 +24,8 @@ __FBSDID("$FreeBSD$");
 #defineARC4_RESEED_SECONDS 300
 #defineARC4_KEYBYTES (256 / 8)
 
+int arc4rand_iniseed_state = ARC4_ENTR_NONE;
+
 static u_int8_t arc4_i, arc4_j;
 static int arc4_numruns = 0;
 static u_int8_t arc4_sbox[256];
@@ -130,7 +132,8 @@ arc4rand(void *ptr, u_int len, int resee
struct timeval tv;
 
getmicrouptime(&tv);
-   if (reseed || 
+   if (atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_HAVE,
+   ARC4_ENTR_SEED) || reseed ||
   (arc4_numruns > ARC4_RESEED_BYTES) ||
   (tv.tv_sec > arc4_t_reseed))
arc4_randomstir();

Modified: head/sys/sys/libkern.h
==
--- head/sys/sys/libkern.h  Thu Apr 18 23:20:16 2013(r249630)
+++ head/sys/sys/libkern.h  Fri Apr 19 00:30:52 2013(r249631)
@@ -70,6 +70,11 @@ static __inline int abs(int a) { return 
 static __inline long labs(long a) { return (a < 0 ? -a : a); }
 static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); }
 
+#defineARC4_ENTR_NONE  0   /* Don't have entropy yet. */
+#defineARC4_ENTR_HAVE  1   /* Have entropy. */
+#defineARC4_ENTR_SEED  2   /* Reseeding. */
+extern int arc4rand_iniseed_state;
+
 /* Prototypes for non-quad routines. */
 struct malloc_type;
 uint32_t arc4random(void);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r249915 - in stable/9/sys: dev/random libkern sys

2013-04-25 Thread Andrey A. Chernov
Author: ache
Date: Fri Apr 26 01:56:58 2013
New Revision: 249915
URL: http://svnweb.freebsd.org/changeset/base/249915

Log:
  MFC r249631
  
  Attempt to mitigate poor initialization of arc4 by one-shot
  reinitialization from yarrow right after good entropy is harvested.
  
  Approved by:secteam (delphij)

Modified:
  stable/9/sys/dev/random/randomdev_soft.c
  stable/9/sys/libkern/arc4random.c
  stable/9/sys/sys/libkern.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/dev/random/randomdev_soft.c
==
--- stable/9/sys/dev/random/randomdev_soft.cFri Apr 26 00:53:34 2013
(r249914)
+++ stable/9/sys/dev/random/randomdev_soft.cFri Apr 26 01:56:58 2013
(r249915)
@@ -366,6 +366,8 @@ random_yarrow_unblock(void)
selwakeuppri(&random_systat.rsel, PUSER);
wakeup(&random_systat);
}
+   (void)atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_NONE,
+   ARC4_ENTR_HAVE);
 }
 
 static int

Modified: stable/9/sys/libkern/arc4random.c
==
--- stable/9/sys/libkern/arc4random.c   Fri Apr 26 00:53:34 2013
(r249914)
+++ stable/9/sys/libkern/arc4random.c   Fri Apr 26 01:56:58 2013
(r249915)
@@ -24,6 +24,8 @@ __FBSDID("$FreeBSD$");
 #defineARC4_RESEED_SECONDS 300
 #defineARC4_KEYBYTES (256 / 8)
 
+int arc4rand_iniseed_state = ARC4_ENTR_NONE;
+
 static u_int8_t arc4_i, arc4_j;
 static int arc4_numruns = 0;
 static u_int8_t arc4_sbox[256];
@@ -130,7 +132,8 @@ arc4rand(void *ptr, u_int len, int resee
struct timeval tv;
 
getmicrouptime(&tv);
-   if (reseed || 
+   if (atomic_cmpset_int(&arc4rand_iniseed_state, ARC4_ENTR_HAVE,
+   ARC4_ENTR_SEED) || reseed ||
   (arc4_numruns > ARC4_RESEED_BYTES) ||
   (tv.tv_sec > arc4_t_reseed))
arc4_randomstir();

Modified: stable/9/sys/sys/libkern.h
==
--- stable/9/sys/sys/libkern.h  Fri Apr 26 00:53:34 2013(r249914)
+++ stable/9/sys/sys/libkern.h  Fri Apr 26 01:56:58 2013(r249915)
@@ -70,6 +70,11 @@ static __inline int abs(int a) { return 
 static __inline long labs(long a) { return (a < 0 ? -a : a); }
 static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); }
 
+#defineARC4_ENTR_NONE  0   /* Don't have entropy yet. */
+#defineARC4_ENTR_HAVE  1   /* Have entropy. */
+#defineARC4_ENTR_SEED  2   /* Reseeding. */
+extern int arc4rand_iniseed_state;
+
 /* Prototypes for non-quad routines. */
 struct malloc_type;
 uint32_t arc4random(void);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r262689 - head/share/mk

2014-03-02 Thread Andrey A. Chernov
Author: ache
Date: Sun Mar  2 13:12:06 2014
New Revision: 262689
URL: http://svnweb.freebsd.org/changeset/base/262689

Log:
  Add fetch and patch to .PHONY and .NOTMAIN only if PORTNAME is defined.
  Unconditional addition cause real fetch(1) and patch(1) programs are
  builded every time.
  
  MFC after:  1 week

Modified:
  head/share/mk/bsd.sys.mk

Modified: head/share/mk/bsd.sys.mk
==
--- head/share/mk/bsd.sys.mkSun Mar  2 12:15:26 2014(r262688)
+++ head/share/mk/bsd.sys.mkSun Mar  2 13:12:06 2014(r262689)
@@ -155,11 +155,15 @@ CFLAGS+=  ${CWARNFLAGS}
 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
beforelinking build build-tools buildfiles buildincludes \
checkdpadd clean cleandepend cleandir cleanobj configure \
-   depend dependall distclean distribute exe extract fetch \
+   depend dependall distclean distribute exe extract \
html includes install installfiles installincludes lint \
-   obj objlink objs objwarn patch realall realdepend \
+   obj objlink objs objwarn realall realdepend \
realinstall regress subdir-all subdir-depend subdir-install \
tags whereobj
 
+.if defined(PORTNAME)
+PHONY_NOTMAIN+=fetch patch
+.endif
+
 .PHONY: ${PHONY_NOTMAIN}
 .NOTMAIN: ${PHONY_NOTMAIN}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r262964 - stable/10/share/mk

2014-03-09 Thread Andrey A. Chernov
Author: ache
Date: Sun Mar  9 23:47:34 2014
New Revision: 262964
URL: http://svnweb.freebsd.org/changeset/base/262964

Log:
  MFC r262689:
  
  Add fetch and patch to .PHONY and .NOTMAIN only if PORTNAME is defined.
  Unconditional addition cause real fetch(1) and patch(1) programs are
  builded every time.

Modified:
  stable/10/share/mk/bsd.sys.mk
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/mk/bsd.sys.mk
==
--- stable/10/share/mk/bsd.sys.mk   Sun Mar  9 22:38:11 2014
(r262963)
+++ stable/10/share/mk/bsd.sys.mk   Sun Mar  9 23:47:34 2014
(r262964)
@@ -151,11 +151,15 @@ CFLAGS+=  ${CWARNFLAGS}
 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
beforelinking build build-tools buildfiles buildincludes \
checkdpadd clean cleandepend cleandir cleanobj configure \
-   depend dependall distclean distribute exe extract fetch \
+   depend dependall distclean distribute exe extract \
html includes install installfiles installincludes lint \
-   obj objlink objs objwarn patch realall realdepend \
+   obj objlink objs objwarn realall realdepend \
realinstall regress subdir-all subdir-depend subdir-install \
tags whereobj
 
+.if defined(PORTNAME)
+PHONY_NOTMAIN+=fetch patch
+.endif
+
 .PHONY: ${PHONY_NOTMAIN}
 .NOTMAIN: ${PHONY_NOTMAIN}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r253810 - head/usr.bin/grep/regex

2013-07-30 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 30 18:16:43 2013
New Revision: 253810
URL: http://svnweb.freebsd.org/changeset/base/253810

Log:
  grep -i does not work for simple patterns and single byte locales, like
LANG=ru_RU.KOI8-R grep -i 
  Fix it.
  
  MFC after:  3 days

Modified:
  head/usr.bin/grep/regex/tre-fastmatch.c

Modified: head/usr.bin/grep/regex/tre-fastmatch.c
==
--- head/usr.bin/grep/regex/tre-fastmatch.c Tue Jul 30 17:35:06 2013
(r253809)
+++ head/usr.bin/grep/regex/tre-fastmatch.c Tue Jul 30 18:16:43 2013
(r253810)
@@ -395,7 +395,7 @@ static int  fastcmp(const fastmatch_t *fg
if (p == NULL)  \
  return REG_ESPACE;\
for (unsigned int i = 0; i < plen; i++) \
- p[i] = tolower(pat[i]);   \
+ p[i] = tolower((unsigned char)pat[i]);\
_CALC_BMGS(arr, p, plen);   \
xfree(p);   \
  } \
@@ -1030,7 +1030,7 @@ fastcmp(const fastmatch_t *fg, const voi
continue;
 
  /* Compare */
- if (fg->icase ? (tolower(pat_byte[i]) == tolower(str_byte[i]))
+ if (fg->icase ? (tolower((unsigned char)pat_byte[i]) == 
tolower((unsigned char)str_byte[i]))
: (pat_byte[i] == str_byte[i]))
  continue;
   }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r253888 - stable/9/usr.bin/grep/regex

2013-08-02 Thread Andrey A. Chernov
Author: ache
Date: Fri Aug  2 17:13:29 2013
New Revision: 253888
URL: http://svnweb.freebsd.org/changeset/base/253888

Log:
  MFC r253810
  
  grep -i does not work for simple patterns and single byte locales, like
LANG=ru_RU.KOI8-R grep -i 
  Fix it.
  
  Approved by:re (delphij,kib)

Modified:
  stable/9/usr.bin/grep/regex/tre-fastmatch.c
Directory Properties:
  stable/9/usr.bin/grep/   (props changed)

Modified: stable/9/usr.bin/grep/regex/tre-fastmatch.c
==
--- stable/9/usr.bin/grep/regex/tre-fastmatch.c Fri Aug  2 14:44:11 2013
(r253887)
+++ stable/9/usr.bin/grep/regex/tre-fastmatch.c Fri Aug  2 17:13:29 2013
(r253888)
@@ -395,7 +395,7 @@ static int  fastcmp(const fastmatch_t *fg
if (p == NULL)  \
  return REG_ESPACE;\
for (unsigned int i = 0; i < plen; i++) \
- p[i] = tolower(pat[i]);   \
+ p[i] = tolower((unsigned char)pat[i]);\
_CALC_BMGS(arr, p, plen);   \
xfree(p);   \
  } \
@@ -1030,7 +1030,7 @@ fastcmp(const fastmatch_t *fg, const voi
continue;
 
  /* Compare */
- if (fg->icase ? (tolower(pat_byte[i]) == tolower(str_byte[i]))
+ if (fg->icase ? (tolower((unsigned char)pat_byte[i]) == 
tolower((unsigned char)str_byte[i]))
: (pat_byte[i] == str_byte[i]))
  continue;
   }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2013-08-08 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug  8 09:04:02 2013
New Revision: 254091
URL: http://svnweb.freebsd.org/changeset/base/254091

Log:
  According to POSIX \ in the fnmatch(3) pattern should escape
  any character including '\0', but our version replace escaped '\0'
  with '\\'.
  I.e. fnmatch("\\", "\\", 0) should not match while fnmatch("\\", "", 0)
  should (Linux and NetBSD does the same). Was vice versa.
  
  PR: 181129
  MFC after:  1 week

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

Modified: head/lib/libc/gen/fnmatch.c
==
--- head/lib/libc/gen/fnmatch.c Thu Aug  8 06:15:58 2013(r254090)
+++ head/lib/libc/gen/fnmatch.c Thu Aug  8 09:04:02 2013(r254091)
@@ -194,8 +194,6 @@ fnmatch1(pattern, string, stringstart, f
&patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (FNM_NOMATCH);
-   if (pclen == 0)
-   pc = '\\';
pattern += pclen;
}
/* FALLTHROUGH */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2013-08-08 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug  8 11:53:47 2013
New Revision: 254093
URL: http://svnweb.freebsd.org/changeset/base/254093

Log:
  Part of r245761 makes "grep -D skip" broken for pipes, i.e.
echo xxx | grep -D skip xxx
  returns nothing. Instead of just removing added S_ISFIFO condition
  (originally absent in this version of grep), make it work as latest
  GNU version does: don't skip directories and devices if fd == STDIN_FILENO.

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

Modified: head/gnu/usr.bin/grep/grep.c
==
--- head/gnu/usr.bin/grep/grep.cThu Aug  8 11:24:25 2013
(r254092)
+++ head/gnu/usr.bin/grep/grep.cThu Aug  8 11:53:47 2013
(r254093)
@@ -301,14 +301,16 @@ reset (int fd, char const *file, struct 
   error (0, errno, "fstat");
   return 0;
 }
-  if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
-return 0;
+  if (fd != STDIN_FILENO) {
+if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
+  return 0;
 #ifndef DJGPP
-  if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || 
S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || 
S_ISFIFO(stats->stat.st_mode)))
+if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || 
S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || 
S_ISFIFO(stats->stat.st_mode)))
 #else
-  if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || 
S_ISBLK(stats->stat.st_mode)))
+if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || 
S_ISBLK(stats->stat.st_mode)))
 #endif
-return 0;
+  return 0;
+  }
   if (
   BZflag ||
 #if HAVE_LIBZ > 0
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r254353 - stable/9/lib/libc/gen

2013-08-14 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 15 04:27:10 2013
New Revision: 254353
URL: http://svnweb.freebsd.org/changeset/base/254353

Log:
  MFC: r254091
  
  According to POSIX \ in the fnmatch(3) pattern should escape
  any character including '\0', but our version replace escaped '\0'
  with '\\'.
  I.e. fnmatch("\\", "\\", 0) should not match while fnmatch("\\", "", 0)
  should (Linux and NetBSD does the same). Was vice versa.
  
  PR: 181129

Modified:
  stable/9/lib/libc/gen/fnmatch.c
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/gen/fnmatch.c
==
--- stable/9/lib/libc/gen/fnmatch.c Thu Aug 15 04:25:16 2013
(r254352)
+++ stable/9/lib/libc/gen/fnmatch.c Thu Aug 15 04:27:10 2013
(r254353)
@@ -194,8 +194,6 @@ fnmatch1(pattern, string, stringstart, f
&patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (FNM_NOMATCH);
-   if (pclen == 0)
-   pc = '\\';
pattern += pclen;
}
/* FALLTHROUGH */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r261146 - head/usr.sbin/cron/cron

2014-01-24 Thread Andrey A. Chernov
Author: ache
Date: Sat Jan 25 02:16:09 2014
New Revision: 261146
URL: http://svnweb.freebsd.org/changeset/base/261146

Log:
  Bad timespec_subtract() calculations produce negative tv_nsec on i386
  which cause EINVAL returned from nanosleep() which cause loop in
  cron_sleep() and making all cron jobs to start about 30 seconds earlier
  (which cause f.e. logfiles rotation by newsyslog delayed by 1 hour).
  
  Use simple and proved calculations from kernel's timespecsub() instead.
  
  MFC after:  3 days

Modified:
  head/usr.sbin/cron/cron/cron.c

Modified: head/usr.sbin/cron/cron/cron.c
==
--- head/usr.sbin/cron/cron/cron.c  Sat Jan 25 01:58:15 2014
(r261145)
+++ head/usr.sbin/cron/cron/cron.c  Sat Jan 25 02:16:09 2014
(r261146)
@@ -376,30 +376,17 @@ cron_sync(int secres) {
}
 }
 
-static int
+static void
 timespec_subtract(struct timespec *result, struct timespec *x,
 struct timespec *y)
 {
-   time_t nsec;
-
-   /* Perform the carry for the later subtraction by updating y. */
-   if (x->tv_nsec < y->tv_nsec) {
-   nsec = (y->tv_nsec - x->tv_nsec) / 1000 + 1;
-   y->tv_nsec -= 10 * nsec;
-   y->tv_sec += nsec;
-   }
-   if (x->tv_nsec - y->tv_nsec > 10) {
-   nsec = (x->tv_nsec - y->tv_nsec) / 10;
-   y->tv_nsec += 10 * nsec;
-   y->tv_sec -= nsec;
-   }
- 
-   /* tv_nsec is certainly positive. */
-   result->tv_sec = x->tv_sec - y->tv_sec;
-   result->tv_nsec = x->tv_nsec - y->tv_nsec;
- 
-   /* Return True if result is negative. */
-   return (x->tv_sec < y->tv_sec);
+   *result = *x;
+   result->tv_sec -= y->tv_sec;
+   result->tv_nsec -= y->tv_nsec;
+   if (result->tv_nsec < 0) {
+   result->tv_sec--;
+   result->tv_nsec += 10;
+   }
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r261231 - stable/10/usr.sbin/cron/cron

2014-01-28 Thread Andrey A. Chernov
Author: ache
Date: Tue Jan 28 13:29:54 2014
New Revision: 261231
URL: http://svnweb.freebsd.org/changeset/base/261231

Log:
  MFC: r261146
  
  Bad timespec_subtract() calculations produce negative tv_nsec on i386
  which cause EINVAL returned from nanosleep() which cause loop in
  cron_sleep() and making all cron jobs to start about 30 seconds earlier
  (which cause f.e. logfiles rotation by newsyslog delayed by 1 hour).
  
  Use simple and proved calculations from kernel's timespecsub() instead.

Modified:
  stable/10/usr.sbin/cron/cron/cron.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/cron/cron/cron.c
==
--- stable/10/usr.sbin/cron/cron/cron.c Tue Jan 28 12:48:17 2014
(r261230)
+++ stable/10/usr.sbin/cron/cron/cron.c Tue Jan 28 13:29:54 2014
(r261231)
@@ -376,30 +376,17 @@ cron_sync(int secres) {
}
 }
 
-static int
+static void
 timespec_subtract(struct timespec *result, struct timespec *x,
 struct timespec *y)
 {
-   time_t nsec;
-
-   /* Perform the carry for the later subtraction by updating y. */
-   if (x->tv_nsec < y->tv_nsec) {
-   nsec = (y->tv_nsec - x->tv_nsec) / 1000 + 1;
-   y->tv_nsec -= 10 * nsec;
-   y->tv_sec += nsec;
-   }
-   if (x->tv_nsec - y->tv_nsec > 10) {
-   nsec = (x->tv_nsec - y->tv_nsec) / 10;
-   y->tv_nsec += 10 * nsec;
-   y->tv_sec -= nsec;
-   }
- 
-   /* tv_nsec is certainly positive. */
-   result->tv_sec = x->tv_sec - y->tv_sec;
-   result->tv_nsec = x->tv_nsec - y->tv_nsec;
- 
-   /* Return True if result is negative. */
-   return (x->tv_sec < y->tv_sec);
+   *result = *x;
+   result->tv_sec -= y->tv_sec;
+   result->tv_nsec -= y->tv_nsec;
+   if (result->tv_nsec < 0) {
+   result->tv_sec--;
+   result->tv_nsec += 10;
+   }
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r244362 - head/gnu/usr.bin/binutils/as

2012-12-17 Thread Andrey A. Chernov
Author: ache
Date: Mon Dec 17 19:17:10 2012
New Revision: 244362
URL: http://svnweb.freebsd.org/changeset/base/244362

Log:
  Fix:
  line 11: Malformed conditional
  (${TARGET} == "arm" || ${TARGET_ARCH} == "powerpc64")

Modified:
  head/gnu/usr.bin/binutils/as/Makefile

Modified: head/gnu/usr.bin/binutils/as/Makefile
==
--- head/gnu/usr.bin/binutils/as/Makefile   Mon Dec 17 19:00:52 2012
(r244361)
+++ head/gnu/usr.bin/binutils/as/Makefile   Mon Dec 17 19:17:10 2012
(r244362)
@@ -8,7 +8,7 @@
 
 .PATH: ${SRCDIR}/gas ${SRCDIR}/gas/config
 
-.if ${TARGET} == "arm" || ${TARGET_ARCH} == "powerpc64"
+.if ${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "powerpc64"
 NO_WERROR.clang=
 .endif
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r244377 - head/gnu/usr.bin/binutils/as

2012-12-17 Thread Andrey A. Chernov
Author: ache
Date: Tue Dec 18 04:44:36 2012
New Revision: 244377
URL: http://svnweb.freebsd.org/changeset/base/244377

Log:
  More correct version of prev. fix.

Modified:
  head/gnu/usr.bin/binutils/as/Makefile

Modified: head/gnu/usr.bin/binutils/as/Makefile
==
--- head/gnu/usr.bin/binutils/as/Makefile   Tue Dec 18 04:38:34 2012
(r244376)
+++ head/gnu/usr.bin/binutils/as/Makefile   Tue Dec 18 04:44:36 2012
(r244377)
@@ -8,7 +8,7 @@
 
 .PATH: ${SRCDIR}/gas ${SRCDIR}/gas/config
 
-.if ${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "powerpc64"
+.if ${TARGET_ARCH:Marm*} || ${TARGET_ARCH} == "powerpc64"
 NO_WERROR.clang=
 .endif
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r241137 - head/lib/libc/stdlib

2012-10-02 Thread Andrey A. Chernov
Author: ache
Date: Tue Oct  2 17:44:08 2012
New Revision: 241137
URL: http://svn.freebsd.org/changeset/base/241137

Log:
  Using putenv() and later direct pointer contents modification it is possibe
  to craft environment variables with similar names like that:
  a=1
  a=2
  ...
  unsetenv("a") should remove them all to make later getenv("a") impossible.
  Fix it to do so (this is GNU autoconf test #3 failure too).
  
  PR: 172273
  MFC after:  1 week

Modified:
  head/lib/libc/stdlib/getenv.c

Modified: head/lib/libc/stdlib/getenv.c
==
--- head/lib/libc/stdlib/getenv.c   Tue Oct  2 17:05:20 2012
(r241136)
+++ head/lib/libc/stdlib/getenv.c   Tue Oct  2 17:44:08 2012
(r241137)
@@ -675,11 +675,13 @@ unsetenv(const char *name)
 
/* Deactivate specified variable. */
envNdx = envVarsTotal - 1;
-   if (__findenv(name, nameLen, &envNdx, true) != NULL) {
+   /* Remove all occurrences. */
+   while (__findenv(name, nameLen, &envNdx, true) != NULL) {
envVars[envNdx].active = false;
if (envVars[envNdx].putenv)
__remove_putenv(envNdx);
__rebuild_environ(envActive - 1);
+   envNdx = envVarsTotal - 1;
}
 
return (0);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r241154 - head/lib/libc/stdlib

2012-10-02 Thread Andrey A. Chernov
Author: ache
Date: Wed Oct  3 04:46:58 2012
New Revision: 241154
URL: http://svn.freebsd.org/changeset/base/241154

Log:
  Optimize prev. commit for speed.
  1) Don't iterate the loop from the environment array beginning each time,
  iterate it under the last place we deactivate instead.
  2) Call __rebuild_environ() not on each iteration but once, only at the end
  of whole loop (of course, only in case if something is changed).
  
  MFC after:  1 week

Modified:
  head/lib/libc/stdlib/getenv.c

Modified: head/lib/libc/stdlib/getenv.c
==
--- head/lib/libc/stdlib/getenv.c   Wed Oct  3 04:22:39 2012
(r241153)
+++ head/lib/libc/stdlib/getenv.c   Wed Oct  3 04:46:58 2012
(r241154)
@@ -662,6 +662,7 @@ unsetenv(const char *name)
 {
int envNdx;
size_t nameLen;
+   int newEnvActive;
 
/* Check for malformed name. */
if (name == NULL || (nameLen = __strleneq(name)) == 0) {
@@ -674,15 +675,18 @@ unsetenv(const char *name)
return (-1);
 
/* Deactivate specified variable. */
-   envNdx = envVarsTotal - 1;
/* Remove all occurrences. */
+   envNdx = envVarsTotal - 1;
+   newEnvActive = envActive;
while (__findenv(name, nameLen, &envNdx, true) != NULL) {
envVars[envNdx].active = false;
if (envVars[envNdx].putenv)
__remove_putenv(envNdx);
-   __rebuild_environ(envActive - 1);
-   envNdx = envVarsTotal - 1;
+   envNdx--;
+   newEnvActive--;
}
+   if (newEnvActive != envActive)
+   __rebuild_environ(newEnvActive);
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r241483 - stable/9/lib/libc/stdlib

2012-10-12 Thread Andrey A. Chernov
Author: ache
Date: Fri Oct 12 13:17:19 2012
New Revision: 241483
URL: http://svn.freebsd.org/changeset/base/241483

Log:
  MFC r241137,r241154
  
  Using putenv() and later direct pointer contents modification it is possibe
  to craft environment variables with similar names like that:
  a=1
  a=2
  ...
  unsetenv("a") should remove them all to make later getenv("a") impossible.
  Fix it to do so (this is GNU autoconf test #3 failure too).
  
  PR: 172273

Modified:
  stable/9/lib/libc/stdlib/getenv.c
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/stdlib/getenv.c
==
--- stable/9/lib/libc/stdlib/getenv.c   Fri Oct 12 12:27:30 2012
(r241482)
+++ stable/9/lib/libc/stdlib/getenv.c   Fri Oct 12 13:17:19 2012
(r241483)
@@ -662,6 +662,7 @@ unsetenv(const char *name)
 {
int envNdx;
size_t nameLen;
+   int newEnvActive;
 
/* Check for malformed name. */
if (name == NULL || (nameLen = __strleneq(name)) == 0) {
@@ -674,13 +675,18 @@ unsetenv(const char *name)
return (-1);
 
/* Deactivate specified variable. */
+   /* Remove all occurrences. */
envNdx = envVarsTotal - 1;
-   if (__findenv(name, nameLen, &envNdx, true) != NULL) {
+   newEnvActive = envActive;
+   while (__findenv(name, nameLen, &envNdx, true) != NULL) {
envVars[envNdx].active = false;
if (envVars[envNdx].putenv)
__remove_putenv(envNdx);
-   __rebuild_environ(envActive - 1);
+   envNdx--;
+   newEnvActive--;
}
+   if (newEnvActive != envActive)
+   __rebuild_environ(newEnvActive);
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r237777 - head/usr.sbin/vidcontrol

2012-06-29 Thread Andrey A. Chernov
Author: ache
Date: Fri Jun 29 12:55:36 2012
New Revision: 23
URL: http://svn.freebsd.org/changeset/base/23

Log:
  Call set_terminal_mode() after video mode change, not before, because
  video mode change always reset terminal mode to xterm.
  It allows things like 'vidcontrol -T cons25 80x30' works as supposed,
  and allows 'allscreens_flags="-T cons25 80x30"' in /etc/rc.conf too.
  
  MFC after:  1 week

Modified:
  head/usr.sbin/vidcontrol/vidcontrol.c

Modified: head/usr.sbin/vidcontrol/vidcontrol.c
==
--- head/usr.sbin/vidcontrol/vidcontrol.c   Fri Jun 29 12:11:31 2012
(r237776)
+++ head/usr.sbin/vidcontrol/vidcontrol.c   Fri Jun 29 12:55:36 2012
(r23)
@@ -1192,15 +1192,13 @@ set_terminal_mode(char *arg)
fprintf(stderr, "\033[=T");
else if (strcmp(arg, "cons25") == 0)
fprintf(stderr, "\033[=1T");
-   else
-   usage();
 }
 
 
 int
 main(int argc, char **argv)
 {
-   char*font, *type;
+   char*font, *type, *termmode;
int dumpmod, dumpopt, opt;
int reterr;
 
@@ -1212,6 +1210,7 @@ main(int argc, char **argv)
err(1, "must be on a virtual console");
dumpmod = 0;
dumpopt = DUMP_FBF;
+   termmode = NULL;
while ((opt = getopt(argc, argv,
"b:Cc:df:g:h:Hi:l:LM:m:pPr:S:s:T:t:x")) != -1)
switch(opt) {
@@ -1283,7 +1282,10 @@ main(int argc, char **argv)
set_console(optarg);
break;
case 'T':
-   set_terminal_mode(optarg);
+   if (strcmp(optarg, "xterm") != 0 &&
+   strcmp(optarg, "cons25") != 0)
+   usage();
+   termmode = optarg;
break;
case 't':
set_screensaver_timeout(optarg);
@@ -1306,6 +1308,8 @@ main(int argc, char **argv)
}
 
video_mode(argc, argv, &optind);
+   if (termmode != NULL)
+   set_terminal_mode(termmode);
 
get_normal_colors(argc, argv, &optind);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r238158 - stable/9/usr.sbin/vidcontrol

2012-07-05 Thread Andrey A. Chernov
Author: ache
Date: Fri Jul  6 01:32:53 2012
New Revision: 238158
URL: http://svn.freebsd.org/changeset/base/238158

Log:
  MFC r23
  
  Call set_terminal_mode() after video mode change, not before, because
  video mode change always reset terminal mode to xterm.
  It allows things like 'vidcontrol -T cons25 80x30' works as supposed,
  and allows 'allscreens_flags="-T cons25 80x30"' in /etc/rc.conf too.
  
  Approved by:re (hrs)

Modified:
  stable/9/usr.sbin/vidcontrol/vidcontrol.c
Directory Properties:
  stable/9/usr.sbin/vidcontrol/   (props changed)

Modified: stable/9/usr.sbin/vidcontrol/vidcontrol.c
==
--- stable/9/usr.sbin/vidcontrol/vidcontrol.c   Fri Jul  6 00:58:27 2012
(r238157)
+++ stable/9/usr.sbin/vidcontrol/vidcontrol.c   Fri Jul  6 01:32:53 2012
(r238158)
@@ -1194,15 +1194,13 @@ set_terminal_mode(char *arg)
fprintf(stderr, "\033[=T");
else if (strcmp(arg, "cons25") == 0)
fprintf(stderr, "\033[=1T");
-   else
-   usage();
 }
 
 
 int
 main(int argc, char **argv)
 {
-   char*font, *type;
+   char*font, *type, *termmode;
int dumpmod, dumpopt, opt;
int reterr;
 
@@ -1214,6 +1212,7 @@ main(int argc, char **argv)
err(1, "must be on a virtual console");
dumpmod = 0;
dumpopt = DUMP_FBF;
+   termmode = NULL;
while ((opt = getopt(argc, argv,
"b:Cc:df:g:h:Hi:l:LM:m:pPr:S:s:T:t:x")) != -1)
switch(opt) {
@@ -1285,7 +1284,10 @@ main(int argc, char **argv)
set_console(optarg);
break;
case 'T':
-   set_terminal_mode(optarg);
+   if (strcmp(optarg, "xterm") != 0 &&
+   strcmp(optarg, "cons25") != 0)
+   usage();
+   termmode = optarg;
break;
case 't':
set_screensaver_timeout(optarg);
@@ -1308,6 +1310,8 @@ main(int argc, char **argv)
}
 
video_mode(argc, argv, &optind);
+   if (termmode != NULL)
+   set_terminal_mode(termmode);
 
get_normal_colors(argc, argv, &optind);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r238741 - head/lib/libelf

2012-07-24 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 24 16:03:28 2012
New Revision: 238741
URL: http://svn.freebsd.org/changeset/base/238741

Log:
  Don't ever build files depending on the directory where they are placed in.
  It is obvious that its modification time will change with each such file
  builded.
  This bug cause whole libelf to rebuild itself each second make run
  (and relink that files on each first make run) in the loop.

Modified:
  head/lib/libelf/Makefile

Modified: head/lib/libelf/Makefile
==
--- head/lib/libelf/MakefileTue Jul 24 13:32:49 2012(r238740)
+++ head/lib/libelf/MakefileTue Jul 24 16:03:28 2012(r238741)
@@ -68,11 +68,9 @@ CLEANFILES=  ${GENSRCS}
 CLEANDIRS= sys
 CFLAGS+=   -I${.CURDIR} -I.
 
-sys/elf32.h sys/elf64.h sys/elf_common.h: sys
-   ln -sf ${.CURDIR}/../../sys/${.TARGET} ${.TARGET}
-
-sys:
+sys/elf32.h sys/elf64.h sys/elf_common.h: ${.CURDIR}/../../sys/${.TARGET}
mkdir -p ${.OBJDIR}/sys
+   ln -sf ${.CURDIR}/../../sys/${.TARGET} ${.TARGET}
 
 SHLIB_MAJOR=   1
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r238795 - in head/sys/boot: ficl zfs

2012-07-26 Thread Andrey A. Chernov
Author: ache
Date: Thu Jul 26 10:10:54 2012
New Revision: 238795
URL: http://svn.freebsd.org/changeset/base/238795

Log:
  Try to avoid all files dependence on the modification time of the large and
  often modified directory created symbolic links points to - it cause
  unnecessary full rebuilds each time make runs when directory is changed.
  So do it only if symbolic link does not exists, which usually means that
  objdir is clean anyway.
  
  MFC after:  1 week

Modified:
  head/sys/boot/ficl/Makefile
  head/sys/boot/zfs/Makefile

Modified: head/sys/boot/ficl/Makefile
==
--- head/sys/boot/ficl/Makefile Thu Jul 26 09:27:00 2012(r238794)
+++ head/sys/boot/ficl/Makefile Thu Jul 26 10:10:54 2012(r238795)
@@ -54,9 +54,11 @@ softcore.c: ${SOFTWORDS} softcore.awk
| awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET}
 
 .if ${MACHINE_CPUARCH} == "amd64"
+.if !exists(machine)
 ${SRCS:M*.c:R:S/$/.o/g}: machine
 
 beforedepend ${OBJS}: machine
+.endif
 
 machine:
ln -sf ${.CURDIR}/../../i386/include machine

Modified: head/sys/boot/zfs/Makefile
==
--- head/sys/boot/zfs/Makefile  Thu Jul 26 09:27:00 2012(r238794)
+++ head/sys/boot/zfs/Makefile  Thu Jul 26 10:10:54 2012(r238795)
@@ -33,5 +33,7 @@ machine:
 .include 
 
 .if ${MACHINE_CPUARCH} == "amd64"
+.if !exists(machine)
 beforedepend ${OBJS}: machine
 .endif
+.endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r238992 - in stable/9/sys/boot: ficl zfs

2012-08-02 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug  2 15:13:12 2012
New Revision: 238992
URL: http://svn.freebsd.org/changeset/base/238992

Log:
  MFC r238795
  
  Try to avoid all files dependence on the modification time of the large
  and often modified directory created symbolic links points to - it cause
  unnecessary full rebuilds each time make runs when directory is changed.
  So do it only if symbolic link does not exists, which usually means that
  objdir is clean anyway.
  
  Approved by:re (kib)

Modified:
  stable/9/sys/boot/ficl/Makefile
  stable/9/sys/boot/zfs/Makefile
Directory Properties:
  stable/9/sys/boot/   (props changed)

Modified: stable/9/sys/boot/ficl/Makefile
==
--- stable/9/sys/boot/ficl/Makefile Thu Aug  2 15:05:34 2012
(r238991)
+++ stable/9/sys/boot/ficl/Makefile Thu Aug  2 15:13:12 2012
(r238992)
@@ -54,9 +54,11 @@ softcore.c: ${SOFTWORDS} softcore.awk
| awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET}
 
 .if ${MACHINE_CPUARCH} == "amd64"
+.if !exists(machine)
 ${SRCS:M*.c:R:S/$/.o/g}: machine
 
 beforedepend ${OBJS}: machine
+.endif
 
 machine:
ln -sf ${.CURDIR}/../../i386/include machine

Modified: stable/9/sys/boot/zfs/Makefile
==
--- stable/9/sys/boot/zfs/Makefile  Thu Aug  2 15:05:34 2012
(r238991)
+++ stable/9/sys/boot/zfs/Makefile  Thu Aug  2 15:13:12 2012
(r238992)
@@ -33,5 +33,7 @@ machine:
 .include 
 
 .if ${MACHINE_CPUARCH} == "amd64"
+.if !exists(machine)
 beforedepend ${OBJS}: machine
 .endif
+.endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r236582 - head/lib/libc/stdlib

2012-06-04 Thread Andrey A. Chernov
Author: ache
Date: Mon Jun  4 21:34:49 2012
New Revision: 236582
URL: http://svn.freebsd.org/changeset/base/236582

Log:
  1) IEEE Std 1003.1-2008, "errno" section, is explicit that
  
  "The setting of errno after a successful call to a function is
  unspecified unless the description of that function specifies that
  errno shall not be modified."
  
  However, free() in IEEE Std 1003.1-2008 does not mention its interaction
  with errno, so MAY modify it after successful call
  (it depends on particular free() implementation, OS-specific, etc.).
  
  So, save errno across free() calls to make code portable and
  POSIX-conformant.
  
  2) Remove unused serrno assignment.
  
  MFC after:  1 week

Modified:
  head/lib/libc/stdlib/realpath.c

Modified: head/lib/libc/stdlib/realpath.c
==
--- head/lib/libc/stdlib/realpath.c Mon Jun  4 20:56:40 2012
(r236581)
+++ head/lib/libc/stdlib/realpath.c Mon Jun  4 21:34:49 2012
(r236582)
@@ -65,7 +65,6 @@ realpath(const char * __restrict path, c
errno = ENOENT;
return (NULL);
}
-   serrno = errno;
if (resolved == NULL) {
resolved = malloc(PATH_MAX);
if (resolved == NULL)
@@ -83,9 +82,11 @@ realpath(const char * __restrict path, c
left_len = strlcpy(left, path + 1, sizeof(left));
} else {
if (getcwd(resolved, PATH_MAX) == NULL) {
-   if (m)
+   if (m) {
+   serrno = errno;
free(resolved);
-   else {
+   errno = serrno;
+   } else {
resolved[0] = '.';
resolved[1] = '\0';
}
@@ -143,8 +144,11 @@ realpath(const char * __restrict path, c
 * occurence to not implement lookahead.
 */
if (lstat(resolved, &sb) != 0) {
-   if (m)
+   if (m) {
+   serrno = errno;
free(resolved);
+   errno = serrno;
+   }
return (NULL);
}
if (!S_ISDIR(sb.st_mode)) {
@@ -184,8 +188,11 @@ realpath(const char * __restrict path, c
if (lstat(resolved, &sb) != 0) {
if (errno != ENOENT || p != NULL)
errno = ENOTDIR;
-   if (m)
+   if (m) {
+   serrno = errno;
free(resolved);
+   errno = serrno;
+   }
return (NULL);
}
if (S_ISLNK(sb.st_mode)) {
@@ -197,8 +204,11 @@ realpath(const char * __restrict path, c
}
slen = readlink(resolved, symlink, sizeof(symlink) - 1);
if (slen < 0) {
-   if (m)
+   if (m) {
+   serrno = errno;
free(resolved);
+   errno = serrno;
+   }
return (NULL);
}
symlink[slen] = '\0';
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r236618 - head/lib/libc/stdlib

2012-06-05 Thread Andrey A. Chernov
Author: ache
Date: Tue Jun  5 16:16:33 2012
New Revision: 236618
URL: http://svn.freebsd.org/changeset/base/236618

Log:
  1) Although unpublished version of standard
  http://austingroupbugs.net/view.php?id=385#c713
  (Resolved state) recommend this way for the current standard (called
  "earlier" in the text)
  
  "However, earlier versions of this standard did not require this, and the
  same example had to be written as:
  
  // buf was obtained by malloc(buflen)
  ret = write(fd, buf, buflen);
  if (ret < 0) {
  int save = errno;
  free(buf);
  errno = save;
  return ret;
  }
  "
  
  from feedback I have for previous commit it seems that many people prefer
  to avoid mass code change needed for current standard compliance
  and prefer to track unpublished standard instead, which requires now
  that free() itself must save errno, not its usage code.
  
  So, I back out "save errno across free()" part of previous commit,
  and will fill PR for changing free() isntead.
  
  2) Remove now unused serrno.
  
  MFC after:  1 week

Modified:
  head/lib/libc/stdlib/realpath.c

Modified: head/lib/libc/stdlib/realpath.c
==
--- head/lib/libc/stdlib/realpath.c Tue Jun  5 14:19:59 2012
(r236617)
+++ head/lib/libc/stdlib/realpath.c Tue Jun  5 16:16:33 2012
(r236618)
@@ -54,7 +54,7 @@ realpath(const char * __restrict path, c
char *p, *q, *s;
size_t left_len, resolved_len;
unsigned symlinks;
-   int m, serrno, slen;
+   int m, slen;
char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
 
if (path == NULL) {
@@ -82,11 +82,9 @@ realpath(const char * __restrict path, c
left_len = strlcpy(left, path + 1, sizeof(left));
} else {
if (getcwd(resolved, PATH_MAX) == NULL) {
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   } else {
+   else {
resolved[0] = '.';
resolved[1] = '\0';
}
@@ -144,11 +142,8 @@ realpath(const char * __restrict path, c
 * occurence to not implement lookahead.
 */
if (lstat(resolved, &sb) != 0) {
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   }
return (NULL);
}
if (!S_ISDIR(sb.st_mode)) {
@@ -188,11 +183,8 @@ realpath(const char * __restrict path, c
if (lstat(resolved, &sb) != 0) {
if (errno != ENOENT || p != NULL)
errno = ENOTDIR;
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   }
return (NULL);
}
if (S_ISLNK(sb.st_mode)) {
@@ -204,11 +196,8 @@ realpath(const char * __restrict path, c
}
slen = readlink(resolved, symlink, sizeof(symlink) - 1);
if (slen < 0) {
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   }
return (NULL);
}
symlink[slen] = '\0';
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r236885 - stable/9/lib/libc/stdlib

2012-06-11 Thread Andrey A. Chernov
Author: ache
Date: Mon Jun 11 11:59:29 2012
New Revision: 236885
URL: http://svn.freebsd.org/changeset/base/236885

Log:
  MFC 236582,236618 - remove unused serrno variable

Modified:
  stable/9/lib/libc/stdlib/realpath.c   (contents, props changed)

Modified: stable/9/lib/libc/stdlib/realpath.c
==
--- stable/9/lib/libc/stdlib/realpath.c Mon Jun 11 11:35:22 2012
(r236884)
+++ stable/9/lib/libc/stdlib/realpath.c Mon Jun 11 11:59:29 2012
(r236885)
@@ -54,7 +54,7 @@ realpath(const char * __restrict path, c
char *p, *q, *s;
size_t left_len, resolved_len;
unsigned symlinks;
-   int m, serrno, slen;
+   int m, slen;
char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
 
if (path == NULL) {
@@ -65,7 +65,6 @@ realpath(const char * __restrict path, c
errno = ENOENT;
return (NULL);
}
-   serrno = errno;
if (resolved == NULL) {
resolved = malloc(PATH_MAX);
if (resolved == NULL)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r236978 - stable/9/lib/libc/stdlib

2012-06-12 Thread Andrey A. Chernov
Author: ache
Date: Wed Jun 13 00:12:47 2012
New Revision: 236978
URL: http://svn.freebsd.org/changeset/base/236978

Log:
  Forget to propogate mergeinfo to directories

Modified:
Directory Properties:
  stable/9/lib/libc/   (props changed)
  stable/9/lib/libc/stdlib/realpath.c   (props changed)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r246913 - head/etc

2013-02-17 Thread Andrey A. Chernov
Author: ache
Date: Sun Feb 17 13:06:59 2013
New Revision: 246913
URL: http://svnweb.freebsd.org/changeset/base/246913

Log:
  In 'make hierarchy' don't install /sys/sys pointing to usr/src/sys
  but just /sys pointing there

Modified:
  head/etc/Makefile

Modified: head/etc/Makefile
==
--- head/etc/Makefile   Sun Feb 17 11:58:30 2013(r246912)
+++ head/etc/Makefile   Sun Feb 17 13:06:59 2013(r246913)
@@ -354,7 +354,7 @@ distrib-dirs:
${METALOG.add} ; \
done; true
 .endif
-   ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
+   ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/
cd ${DESTDIR}/usr/share/man; \
for mandir in man*; do \
${INSTALL_SYMLINK} ../$$mandir \
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r247162 - head/etc

2013-02-22 Thread Andrey A. Chernov
Author: ache
Date: Fri Feb 22 19:57:18 2013
New Revision: 247162
URL: http://svnweb.freebsd.org/changeset/base/247162

Log:
  Back out prev. change preventing /sys/sys symlink. It appears my install
  was not very recent and not acts like 'ln -h'

Modified:
  head/etc/Makefile

Modified: head/etc/Makefile
==
--- head/etc/Makefile   Fri Feb 22 19:53:12 2013(r247161)
+++ head/etc/Makefile   Fri Feb 22 19:57:18 2013(r247162)
@@ -354,7 +354,7 @@ distrib-dirs:
${METALOG.add} ; \
done; true
 .endif
-   ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/
+   ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
cd ${DESTDIR}/usr/share/man; \
for mandir in man*; do \
${INSTALL_SYMLINK} ../$$mandir \
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r239477 - head/contrib/openresolv

2012-08-20 Thread Andrey A. Chernov
Author: ache
Date: Tue Aug 21 06:14:08 2012
New Revision: 239477
URL: http://svn.freebsd.org/changeset/base/239477

Log:
  According to resolvconf.conf(5) manpage and sources, there is no
  'nameservers' option which used in examples in resolvconf.conf(5),
  it spelled 'name_servers', so fix examples.

Modified:
  head/contrib/openresolv/resolvconf.conf.5.in

Modified: head/contrib/openresolv/resolvconf.conf.5.in
==
--- head/contrib/openresolv/resolvconf.conf.5.inTue Aug 21 06:09:43 
2012(r239476)
+++ head/contrib/openresolv/resolvconf.conf.5.inTue Aug 21 06:14:08 
2012(r239477)
@@ -113,7 +113,7 @@ This file tells dnsmasq which nameserver
 This file tells dnsmasq which nameservers to use for global lookups.
 .Pp
 Example resolvconf.conf for dnsmasq:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 dnsmasq_conf=/etc/dnsmasq-conf.conf
 .D1 dnsmasq_resolv=/etc/dnsmasq-resolv.conf
 .Pp
@@ -129,7 +129,7 @@ Include this file in the named global sc
 This file tells named which nameservers to use for specific domains.
 .Pp
 Example resolvconf.conf for named:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 named_options=/etc/named-options.conf
 .D1 named_zones=/etc/named-zones.conf
 .Pp
@@ -152,7 +152,7 @@ If this variable is not set then it's wr
 .Pa pdnsd_conf .
 .Pp
 Example resolvconf.conf for pdnsd:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 pdnsd_conf=/etc/pdnsd.conf
 .D1 # pdnsd_resolv=/etc/pdnsd-resolv.conf
 .Pp
@@ -171,7 +171,7 @@ Example pdnsd.conf:
 This file tells unbound about specific and global nameservers.
 .Pp
 Example resolvconf.conf for unbound:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 unbound_conf=/etc/unbound-resolvconf.conf
 .Pp
 Example unbound.conf:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r239708 - stable/9/contrib/openresolv

2012-08-25 Thread Andrey A. Chernov
Author: ache
Date: Sun Aug 26 05:20:32 2012
New Revision: 239708
URL: http://svn.freebsd.org/changeset/base/239708

Log:
  MFC r239477
  
  According to resolvconf.conf(5) manpage and sources, there is no
  'nameservers' option which used in examples in resolvconf.conf(5),
  it spelled 'name_servers', so fix examples.

Modified:
  stable/9/contrib/openresolv/resolvconf.conf.5.in
Directory Properties:
  stable/9/contrib/openresolv/   (props changed)

Modified: stable/9/contrib/openresolv/resolvconf.conf.5.in
==
--- stable/9/contrib/openresolv/resolvconf.conf.5.inSun Aug 26 05:11:52 
2012(r239707)
+++ stable/9/contrib/openresolv/resolvconf.conf.5.inSun Aug 26 05:20:32 
2012(r239708)
@@ -113,7 +113,7 @@ This file tells dnsmasq which nameserver
 This file tells dnsmasq which nameservers to use for global lookups.
 .Pp
 Example resolvconf.conf for dnsmasq:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 dnsmasq_conf=/etc/dnsmasq-conf.conf
 .D1 dnsmasq_resolv=/etc/dnsmasq-resolv.conf
 .Pp
@@ -129,7 +129,7 @@ Include this file in the named global sc
 This file tells named which nameservers to use for specific domains.
 .Pp
 Example resolvconf.conf for named:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 named_options=/etc/named-options.conf
 .D1 named_zones=/etc/named-zones.conf
 .Pp
@@ -152,7 +152,7 @@ If this variable is not set then it's wr
 .Pa pdnsd_conf .
 .Pp
 Example resolvconf.conf for pdnsd:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 pdnsd_conf=/etc/pdnsd.conf
 .D1 # pdnsd_resolv=/etc/pdnsd-resolv.conf
 .Pp
@@ -171,7 +171,7 @@ Example pdnsd.conf:
 This file tells unbound about specific and global nameservers.
 .Pp
 Example resolvconf.conf for unbound:
-.D1 nameservers=127.0.0.1
+.D1 name_servers=127.0.0.1
 .D1 unbound_conf=/etc/unbound-resolvconf.conf
 .Pp
 Example unbound.conf:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r210853 - head/lib/libc/stdlib

2010-08-04 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug  5 01:39:25 2010
New Revision: 210853
URL: http://svn.freebsd.org/changeset/base/210853

Log:
  Comment out IEEE Std 1003.1-2001 conformance proclaimed too early,
  see problems described in the comment to:
  http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/128933

Modified:
  head/lib/libc/stdlib/realpath.3

Modified: head/lib/libc/stdlib/realpath.3
==
--- head/lib/libc/stdlib/realpath.3 Wed Aug  4 21:02:04 2010
(r210852)
+++ head/lib/libc/stdlib/realpath.3 Thu Aug  5 01:39:25 2010
(r210853)
@@ -111,11 +111,11 @@ and
 .Xr getcwd 3 .
 .Sh SEE ALSO
 .Xr getcwd 3
-.Sh STANDARDS
-The
-.Fn realpath
-function conforms to
-.St -p1003.1-2001 .
+.\" .Sh STANDARDS
+.\" The
+.\" .Fn realpath
+.\" function conforms to
+.\" .St -p1003.1-2001 .
 .Sh HISTORY
 The
 .Fn realpath
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2010-01-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jan 18 10:17:51 2010
New Revision: 202556
URL: http://svn.freebsd.org/changeset/base/202556

Log:
  a) Use strcoll() in opendir() and alphasort() as POSIX 2008 requires.
 It also matches now how our 'ls' works for years.
  
  b) Remove comment expressed 2 fears:
   1) One just simple describe how strcoll() works in _any_ context,
   not for directories only. Are we plan to remove strcoll() from everything
   just because it is little more complex than strcmp()? I doubt, and
   directories give nothing different here. Moreover, strcoll() used
   in 'ls' for years and nobody complaints yet.
  
   2) Plain wrong statement about undefined strcoll() behaviour. strcoll()
   always gives predictable results, falling back to strcmp() on any
   trouble, see strcoll(3).
  
  No objections from -current list discussion.

Modified:
  head/lib/libc/gen/opendir.c
  head/lib/libc/gen/scandir.c

Modified: head/lib/libc/gen/opendir.c
==
--- head/lib/libc/gen/opendir.c Mon Jan 18 09:41:54 2010(r202555)
+++ head/lib/libc/gen/opendir.c Mon Jan 18 10:17:51 2010(r202556)
@@ -94,13 +94,13 @@ __opendir2(const char *name, int flags)
 
 /*
  * POSIX 2008 and XSI 7 require alphasort() to call strcoll() for
- * directory entries ordering.  Use local copy that uses strcmp().
+ * directory entries ordering.
  */
 static int
 opendir_alphasort(const void *p1, const void *p2)
 {
 
-   return (strcmp((*(const struct dirent **)p1)->d_name,
+   return (strcoll((*(const struct dirent **)p1)->d_name,
(*(const struct dirent **)p2)->d_name));
 }
 

Modified: head/lib/libc/gen/scandir.c
==
--- head/lib/libc/gen/scandir.c Mon Jan 18 09:41:54 2010(r202555)
+++ head/lib/libc/gen/scandir.c Mon Jan 18 10:17:51 2010(r202556)
@@ -127,17 +127,13 @@ fail:
 /*
  * Alphabetic order comparison routine for those who want it.
  *
- * XXXKIB POSIX 2008 requires the alphasort() to use strcoll().  Keep
- * strcmp() for now, since environment locale settings could have no
- * relevance for the byte sequence of the file name. Moreover, it
- * might be even invalid sequence in current locale, and then
- * behaviour of alphasort would be undefined.
+ * POSIX 2008 requires the alphasort() to use strcoll().
  */
 int
 alphasort(const struct dirent **d1, const struct dirent **d2)
 {
 
-   return (strcmp((*d1)->d_name, (*d2)->d_name));
+   return (strcoll((*d1)->d_name, (*d2)->d_name));
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2010-01-18 Thread Andrey A. Chernov
Author: ache
Date: Mon Jan 18 13:44:44 2010
New Revision: 202572
URL: http://svn.freebsd.org/changeset/base/202572

Log:
  Double checking my commit I found that comment saying that
  POSIX 2008 and XSI 7require strcoll() for opendir() is not true.
  I can't find such requirement in POSIX 2008 and XSI 7.
  
  So, back out that part of my commit, returning old strcmp(), and remove
  this misleading comment.

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

Modified: head/lib/libc/gen/opendir.c
==
--- head/lib/libc/gen/opendir.c Mon Jan 18 13:38:45 2010(r202571)
+++ head/lib/libc/gen/opendir.c Mon Jan 18 13:44:44 2010(r202572)
@@ -92,15 +92,11 @@ __opendir2(const char *name, int flags)
return __opendir_common(fd, name, flags);
 }
 
-/*
- * POSIX 2008 and XSI 7 require alphasort() to call strcoll() for
- * directory entries ordering.
- */
 static int
-opendir_alphasort(const void *p1, const void *p2)
+opendir_sort(const void *p1, const void *p2)
 {
 
-   return (strcoll((*(const struct dirent **)p1)->d_name,
+   return (strcmp((*(const struct dirent **)p1)->d_name,
(*(const struct dirent **)p2)->d_name));
 }
 
@@ -253,7 +249,7 @@ __opendir_common(int fd, const char *nam
 * This sort must be stable.
 */
mergesort(dpv, n, sizeof(*dpv),
-   opendir_alphasort);
+   opendir_sort);
 
dpv[n] = NULL;
xp = NULL;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2010-01-19 Thread Andrey A. Chernov
Author: ache
Date: Wed Jan 20 07:27:56 2010
New Revision: 202677
URL: http://svn.freebsd.org/changeset/base/202677

Log:
  Style: remove extra empty line in the comment.
  
  Pointed by: bde

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

Modified: head/lib/libc/gen/scandir.c
==
--- head/lib/libc/gen/scandir.c Wed Jan 20 06:30:40 2010(r202676)
+++ head/lib/libc/gen/scandir.c Wed Jan 20 07:27:56 2010(r202677)
@@ -126,7 +126,6 @@ fail:
 
 /*
  * Alphabetic order comparison routine for those who want it.
- *
  * POSIX 2008 requires the alphasort() to use strcoll().
  */
 int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2010-01-19 Thread Andrey A. Chernov
Author: ache
Date: Wed Jan 20 07:36:29 2010
New Revision: 202679
URL: http://svn.freebsd.org/changeset/base/202679

Log:
  Style: rename internal function to opendir_compar()
  
  Pointed by: bde

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

Modified: head/lib/libc/gen/opendir.c
==
--- head/lib/libc/gen/opendir.c Wed Jan 20 07:28:14 2010(r202678)
+++ head/lib/libc/gen/opendir.c Wed Jan 20 07:36:29 2010(r202679)
@@ -93,7 +93,7 @@ __opendir2(const char *name, int flags)
 }
 
 static int
-opendir_sort(const void *p1, const void *p2)
+opendir_compar(const void *p1, const void *p2)
 {
 
return (strcmp((*(const struct dirent **)p1)->d_name,
@@ -249,7 +249,7 @@ __opendir_common(int fd, const char *nam
 * This sort must be stable.
 */
mergesort(dpv, n, sizeof(*dpv),
-   opendir_sort);
+   opendir_compar);
 
dpv[n] = NULL;
xp = NULL;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2010-01-20 Thread Andrey A. Chernov
Author: ache
Date: Wed Jan 20 11:55:14 2010
New Revision: 202691
URL: http://svn.freebsd.org/changeset/base/202691

Log:
  For alphasort() add reference to strcoll(3)

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

Modified: head/lib/libc/gen/scandir.3
==
--- head/lib/libc/gen/scandir.3 Wed Jan 20 10:21:04 2010(r202690)
+++ head/lib/libc/gen/scandir.3 Wed Jan 20 11:55:14 2010(r202691)
@@ -81,7 +81,8 @@ The
 function
 is a routine which can be used for the
 .Fa compar
-argument to sort the array alphabetically.
+argument to sort the array alphabetically using
+.Xr strcoll 3 .
 .Pp
 The memory allocated for the array can be deallocated with
 .Xr free 3 ,
@@ -94,7 +95,8 @@ cannot allocate enough memory to hold al
 .Xr directory 3 ,
 .Xr malloc 3 ,
 .Xr qsort 3 ,
-.Xr dir 5
+.Xr dir 5 ,
+.Xr strcoll 3
 .Sh HISTORY
 The
 .Fn scandir
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2010-01-20 Thread Andrey A. Chernov
Author: ache
Date: Wed Jan 20 11:59:46 2010
New Revision: 202693
URL: http://svn.freebsd.org/changeset/base/202693

Log:
  Style: reword comment.
  
  Submitted by:   bde

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

Modified: head/lib/libc/gen/scandir.c
==
--- head/lib/libc/gen/scandir.c Wed Jan 20 11:58:04 2010(r202692)
+++ head/lib/libc/gen/scandir.c Wed Jan 20 11:59:46 2010(r202693)
@@ -126,7 +126,7 @@ fail:
 
 /*
  * Alphabetic order comparison routine for those who want it.
- * POSIX 2008 requires the alphasort() to use strcoll().
+ * POSIX 2008 requires that alphasort() uses strcoll().
  */
 int
 alphasort(const struct dirent **d1, const struct dirent **d2)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r184161 - head/sys/i386/i386

2008-10-22 Thread Andrey A. Chernov
Author: ache
Date: Wed Oct 22 14:45:30 2008
New Revision: 184161
URL: http://svn.freebsd.org/changeset/base/184161

Log:
  Fix compiler error with missing/unneded ')'

Modified:
  head/sys/i386/i386/identcpu.c

Modified: head/sys/i386/i386/identcpu.c
==
--- head/sys/i386/i386/identcpu.c   Wed Oct 22 10:12:21 2008
(r184160)
+++ head/sys/i386/i386/identcpu.c   Wed Oct 22 14:45:30 2008
(r184161)
@@ -842,9 +842,9 @@ printcpuinfo(void)
cpu_feature &= ~CPUID_HTT;
 
if (!tsc_is_invariant &&
-   (strcmp(cpu_vendor, "AuthenticAMD") == 0 &&
-   (amd_pminfo & AMDPM_TSC_INVARIANT) != 0 ||
-   I386_CPU_FAMILY(cpu_id) >= 0x10))) {
+   ((strcmp(cpu_vendor, "AuthenticAMD") == 0 &&
+   (amd_pminfo & AMDPM_TSC_INVARIANT) != 0) ||
+   I386_CPU_FAMILY(cpu_id) >= 0x10)) {
tsc_is_invariant = 1;
printf("\n  P-state invariant TSC");
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r185045 - head/sys/boot/i386/loader

2008-11-17 Thread Andrey A. Chernov
Author: ache
Date: Tue Nov 18 03:55:55 2008
New Revision: 185045
URL: http://svn.freebsd.org/changeset/base/185045

Log:
  Fix building without ZFS (can't find library)

Modified:
  head/sys/boot/i386/loader/Makefile

Modified: head/sys/boot/i386/loader/Makefile
==
--- head/sys/boot/i386/loader/Makefile  Tue Nov 18 03:43:02 2008
(r185044)
+++ head/sys/boot/i386/loader/Makefile  Tue Nov 18 03:55:55 2008
(r185045)
@@ -21,6 +21,8 @@ LIBFIREWIRE=  ${.OBJDIR}/../libfirewire/l
 .if defined(LOADER_ZFS_SUPPORT)
 CFLAGS+=   -DLOADER_ZFS_SUPPORT
 LIBZFS=${.OBJDIR}/../../zfs/libzfsboot.a
+.else
+LIBZFS=
 .endif
 
 # Enable PXE TFTP or NFS support, not both.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r207701 - head/usr.bin/calendar

2010-05-06 Thread Andrey A. Chernov
Author: ache
Date: Thu May  6 16:37:50 2010
New Revision: 207701
URL: http://svn.freebsd.org/changeset/base/207701

Log:
  Fix recent space skipping:
  1) add missing (unsigned char) cast to ctype() macro
  2) fix off-by-one error causing last letter always doubled

Modified:
  head/usr.bin/calendar/io.c

Modified: head/usr.bin/calendar/io.c
==
--- head/usr.bin/calendar/io.c  Thu May  6 15:52:08 2010(r207700)
+++ head/usr.bin/calendar/io.c  Thu May  6 16:37:50 2010(r207701)
@@ -155,8 +155,8 @@ cal(void)
}
 
/* Get rid of leading spaces (non-standard) */
-   while (isspace(buf[0]))
-   memcpy(buf, buf + 1, strlen(buf) - 1);
+   while (isspace((unsigned char)buf[0]))
+   memcpy(buf, buf + 1, strlen(buf));
 
/* No tab in the line, then not a valid line */
if ((pp = strchr(buf, '\t')) == NULL)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r207703 - head/usr.bin/calendar

2010-05-06 Thread Andrey A. Chernov
Author: ache
Date: Thu May  6 16:54:46 2010
New Revision: 207703
URL: http://svn.freebsd.org/changeset/base/207703

Log:
  While I am here, add more missing (unsigned char) casts to ctype() macros

Modified:
  head/usr.bin/calendar/io.c
  head/usr.bin/calendar/parsedata.c

Modified: head/usr.bin/calendar/io.c
==
--- head/usr.bin/calendar/io.c  Thu May  6 16:39:43 2010(r207702)
+++ head/usr.bin/calendar/io.c  Thu May  6 16:54:46 2010(r207703)
@@ -163,7 +163,7 @@ cal(void)
continue;
 
/* Trim spaces in front of the tab */
-   while (isspace(pp[-1]))
+   while (isspace((unsigned char)pp[-1]))
pp--;
 
p = *pp;

Modified: head/usr.bin/calendar/parsedata.c
==
--- head/usr.bin/calendar/parsedata.c   Thu May  6 16:39:43 2010
(r207702)
+++ head/usr.bin/calendar/parsedata.c   Thu May  6 16:54:46 2010
(r207703)
@@ -872,7 +872,7 @@ isonlydigits(char *s, int nostar)
for (i = 0; s[i] != '\0'; i++) {
if (nostar == 0 && s[i] == '*' && s[i + 1] == '\0')
return 1;
-   if (!isdigit(s[i]))
+   if (!isdigit((unsigned char)s[i]))
return (0);
}
return (1);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r204803 - head/usr.bin/uniq

2010-03-06 Thread Andrey A. Chernov
Author: ache
Date: Sat Mar  6 19:21:57 2010
New Revision: 204803
URL: http://svn.freebsd.org/changeset/base/204803

Log:
  1) Rewrite input processing to not exit with error on the first EILSEQ found
  in the input data but fallback to "binary equal" check instead.
  
  POSIX says: "The input file shall be a text file", nothing more,
  so the text file with illegal sequence is valid input.
  BTW, GNU sort does not fails on EILSEQ too.
  
  2) Speedup input processing a bit in complex cases like skipping fields,
  chars or ignore case.
  
  3) Enforce the implied LINE_MAX limit (from POSIX definition of "text file"
  and POSIX uniq(1) description).

Modified:
  head/usr.bin/uniq/uniq.c

Modified: head/usr.bin/uniq/uniq.c
==
--- head/usr.bin/uniq/uniq.cSat Mar  6 17:31:09 2010(r204802)
+++ head/usr.bin/uniq/uniq.cSat Mar  6 19:21:57 2010(r204803)
@@ -60,31 +60,25 @@ static const char rcsid[] =
 #include 
 #include 
 
-#defineINITLINELEN (LINE_MAX + 1)
-#defineMAXLINELEN  ((SIZE_MAX / sizeof(wchar_t)) / 2)
-
-int cflag, dflag, uflag;
+int cflag, dflag, uflag, iflag;
 int numchars, numfields, repeats;
 
 FILE   *file(const char *, const char *);
-wchar_t*getline(wchar_t *, size_t *, FILE *);
-voidshow(FILE *, wchar_t *);
+wchar_t*convert(wchar_t *, const char *);
+char   *getlinemax(char *, FILE *);
+voidshow(FILE *, const char *);
 wchar_t*skip(wchar_t *);
 voidobsolete(char *[]);
 static void usage(void);
-int  wcsicoll(wchar_t *, wchar_t *);
 
 int
 main (int argc, char *argv[])
 {
-   wchar_t *t1, *t2;
+   wchar_t *tprev, *tthis, *wprev, *wthis, *wp;
FILE *ifp, *ofp;
-   int ch, b1;
-   size_t prevbuflen, thisbuflen;
-   wchar_t *prevline, *thisline;
-   char *p;
+   int ch, comp;
+   char *prevline, *thisline, *p;
const char *ifn;
-   int iflag = 0, comp;
 
(void) setlocale(LC_ALL, "");
 
@@ -139,48 +133,47 @@ main (int argc, char *argv[])
if (argc > 1)
ofp = file(argv[1], "w");
 
-   prevbuflen = INITLINELEN;
-   thisbuflen = INITLINELEN;
-   prevline = malloc(prevbuflen * sizeof(*prevline));
-   thisline = malloc(thisbuflen * sizeof(*thisline));
-   if (prevline == NULL || thisline == NULL)
+   prevline = malloc(LINE_MAX);
+   thisline = malloc(LINE_MAX);
+   wprev = malloc(LINE_MAX * sizeof(*wprev));
+   wthis = malloc(LINE_MAX * sizeof(*wthis));
+   if (prevline == NULL || thisline == NULL ||
+   wprev == NULL || wthis == NULL)
err(1, "malloc");
 
-   if ((prevline = getline(prevline, &prevbuflen, ifp)) == NULL) {
+   if ((prevline = getlinemax(prevline, ifp)) == NULL) {
if (ferror(ifp))
err(1, "%s", ifn);
exit(0);
}
+   tprev = convert(wprev, prevline);
+
if (!cflag && uflag && dflag)
show(ofp, prevline);
 
-   while ((thisline = getline(thisline, &thisbuflen, ifp)) != NULL) {
-   /* If requested get the chosen fields + character offsets. */
-   if (numfields || numchars) {
-   t1 = skip(thisline);
-   t2 = skip(prevline);
-   } else {
-   t1 = thisline;
-   t2 = prevline;
-   }
+   while ((thisline = getlinemax(thisline, ifp)) != NULL) {
+   tthis = convert(wthis, thisline);
 
-   /* If different, print; set previous to new value. */
-   if (iflag)
-   comp = wcsicoll(t1, t2);
+   if (tthis == NULL && tprev == NULL)
+   comp = strcmp(thisline, prevline);
+   else if (tthis == NULL || tprev == NULL)
+   comp = 1;
else
-   comp = wcscoll(t1, t2);
+   comp = wcscoll(tthis, tprev);
 
if (comp) {
+   /* If different, print; set previous to new value. */
if (cflag || !dflag || !uflag)
show(ofp, prevline);
-   t1 = prevline;
-   b1 = prevbuflen;
+   p = prevline;
+   wp = wprev;
prevline = thisline;
-   prevbuflen = thisbuflen;
+   wprev = wthis;
+   tprev = tthis;
if (!cflag && uflag && dflag)
show(ofp, prevline);
-   thisline = t1;
-   thisbuflen = b1;
+   thisline = p;
+   wthis = wp;
repeats = 0;
} else
++repeats;
@@ -192,44 +185,61 @@ main 

svn commit: r204811 - head/usr.bin/uniq

2010-03-06 Thread Andrey A. Chernov
Author: ache
Date: Sat Mar  6 22:38:38 2010
New Revision: 204811
URL: http://svn.freebsd.org/changeset/base/204811

Log:
  Remove vestiges of old %-format which prevents build on amd64

Modified:
  head/usr.bin/uniq/uniq.c

Modified: head/usr.bin/uniq/uniq.c
==
--- head/usr.bin/uniq/uniq.cSat Mar  6 22:04:45 2010(r204810)
+++ head/usr.bin/uniq/uniq.cSat Mar  6 22:38:38 2010(r204811)
@@ -195,7 +195,7 @@ getlinemax(char *buf, FILE *fp)
while ((ch = getc(fp)) != EOF && ch != '\n') {
buf[bufpos++] = ch;
if (bufpos >= LINE_MAX)
-   errx(1, "Maximum line length (%zu) exceeded",
+   errx(1, "Maximum line length (%d) exceeded",
 LINE_MAX);
}
buf[bufpos] = '\0';
@@ -210,7 +210,7 @@ convert(wchar_t *buf, const char *str)
wchar_t *p, *ret;
 
if ((n = mbstowcs(buf, str, LINE_MAX)) == LINE_MAX)
-   errx(1, "Maximum line length (%zu) exceeded", LINE_MAX);
+   errx(1, "Maximum line length (%d) exceeded", LINE_MAX);
else if (n != (size_t)-1) {
/* If requested get the chosen fields + character offsets. */
if (numfields || numchars)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r204876 - head/usr.bin/uniq

2010-03-08 Thread Andrey A. Chernov
Author: ache
Date: Mon Mar  8 19:40:22 2010
New Revision: 204876
URL: http://svn.freebsd.org/changeset/base/204876

Log:
  1) Reimplement (differently) unlimited line length restricted in prev.
  commit.
  
  2) Honor missing the very last \n (if absent) on output.

Modified:
  head/usr.bin/uniq/uniq.c

Modified: head/usr.bin/uniq/uniq.c
==
--- head/usr.bin/uniq/uniq.cMon Mar  8 18:51:28 2010(r204875)
+++ head/usr.bin/uniq/uniq.cMon Mar  8 19:40:22 2010(r204876)
@@ -53,6 +53,7 @@ static const char rcsid[] =
 #include 
 #include 
 #include 
+#define _WITH_GETLINE
 #include 
 #include 
 #include 
@@ -64,8 +65,8 @@ int cflag, dflag, uflag, iflag;
 int numchars, numfields, repeats;
 
 FILE   *file(const char *, const char *);
-wchar_t*convert(wchar_t *, const char *);
-char   *getlinemax(char *, FILE *);
+wchar_t*convert(const char *);
+int inlcmp(const char *, const char *);
 voidshow(FILE *, const char *);
 wchar_t*skip(wchar_t *);
 voidobsolete(char *[]);
@@ -74,9 +75,10 @@ static void   usage(void);
 int
 main (int argc, char *argv[])
 {
-   wchar_t *tprev, *tthis, *wprev, *wthis, *wp;
+   wchar_t *tprev, *tthis;
FILE *ifp, *ofp;
int ch, comp;
+   size_t prevbuflen, thisbuflen, b1;
char *prevline, *thisline, *p;
const char *ifn;
 
@@ -133,29 +135,27 @@ main (int argc, char *argv[])
if (argc > 1)
ofp = file(argv[1], "w");
 
-   prevline = malloc(LINE_MAX);
-   thisline = malloc(LINE_MAX);
-   wprev = malloc(LINE_MAX * sizeof(*wprev));
-   wthis = malloc(LINE_MAX * sizeof(*wthis));
-   if (prevline == NULL || thisline == NULL ||
-   wprev == NULL || wthis == NULL)
-   err(1, "malloc");
+   prevbuflen = thisbuflen = 0;
+   prevline = thisline = NULL;
 
-   if ((prevline = getlinemax(prevline, ifp)) == NULL) {
+   if (getline(&prevline, &prevbuflen, ifp) < 0) {
if (ferror(ifp))
err(1, "%s", ifn);
exit(0);
}
-   tprev = convert(wprev, prevline);
+   tprev = convert(prevline);
 
if (!cflag && uflag && dflag)
show(ofp, prevline);
 
-   while ((thisline = getlinemax(thisline, ifp)) != NULL) {
-   tthis = convert(wthis, thisline);
+   tthis = NULL;
+   while (getline(&thisline, &thisbuflen, ifp) >= 0) {
+   if (tthis != NULL)
+   free(tthis);
+   tthis = convert(thisline);
 
if (tthis == NULL && tprev == NULL)
-   comp = strcmp(thisline, prevline);
+   comp = inlcmp(thisline, prevline);
else if (tthis == NULL || tprev == NULL)
comp = 1;
else
@@ -166,14 +166,17 @@ main (int argc, char *argv[])
if (cflag || !dflag || !uflag)
show(ofp, prevline);
p = prevline;
-   wp = wprev;
+   b1 = prevbuflen;
prevline = thisline;
-   wprev = wthis;
+   prevbuflen = thisbuflen;
+   if (tprev != NULL)
+   free(tprev);
tprev = tthis;
if (!cflag && uflag && dflag)
show(ofp, prevline);
thisline = p;
-   wthis = wp;
+   thisbuflen = b1;
+   tthis = NULL;
repeats = 0;
} else
++repeats;
@@ -185,46 +188,54 @@ main (int argc, char *argv[])
exit(0);
 }
 
-char *
-getlinemax(char *buf, FILE *fp)
+wchar_t *
+convert(const char *str)
 {
-   size_t bufpos;
-   int ch;
+   size_t n;
+   wchar_t *buf, *ret, *p;
+
+   if ((n = mbstowcs(NULL, str, 0)) == (size_t)-1)
+   return (NULL);
+   if ((buf = malloc((n + 1) * sizeof(*buf))) == NULL)
+   err(1, "malloc");
+   if (mbstowcs(buf, str, n + 1) != n)
+   errx(1, "internal mbstowcs() error");
+   /* The last line may not end with \n. */
+   if (n > 0 && buf[n - 1] == L'\n')
+   buf[n - 1] = L'\0';
+
+   /* If requested get the chosen fields + character offsets. */
+   if (numfields || numchars) {
+   if ((ret = wcsdup(skip(buf))) == NULL)
+   err(1, "wcsdup");
+   free(buf);
+   } else
+   ret = buf;
 
-   bufpos = 0;
-   while ((ch = getc(fp)) != EOF && ch != '\n') {
-   buf[bufpos++] = ch;
-   if (bufpos >= LINE_MAX)
-   errx(1, "Maximum line length (%d) exceeded",
-LINE_MAX);
+   i

svn commit: r204896 - head/usr.bin/comm

2010-03-08 Thread Andrey A. Chernov
Author: ache
Date: Mon Mar  8 22:27:46 2010
New Revision: 204896
URL: http://svn.freebsd.org/changeset/base/204896

Log:
  Rewrite input processing to not exit with error on the first EILSEQ found
  in the input data but fallback to "binary comparison" instead.
  
  POSIX says: "The input files shall be text files", nothing more,
  so the text file with illegal sequence is valid input.
  BTW, GNU sort does not fails on EILSEQ too.

Modified:
  head/usr.bin/comm/comm.c

Modified: head/usr.bin/comm/comm.c
==
--- head/usr.bin/comm/comm.cMon Mar  8 21:42:19 2010(r204895)
+++ head/usr.bin/comm/comm.cMon Mar  8 22:27:46 2010(r204896)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#define _WITH_GETLINE
 #include 
 #include 
 #include 
@@ -60,40 +61,31 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#defineINITLINELEN (LINE_MAX + 1)
-#defineMAXLINELEN  ((SIZE_MAX / sizeof(wchar_t)) / 2)
-
-const wchar_t *tabs[] = { L"", L"\t", L"\t\t" };
+int iflag;
+const char *tabs[] = { "", "\t", "\t\t" };
 
 FILE   *file(const char *);
-wchar_t*getline(wchar_t *, size_t *, FILE *);
-void   show(FILE *, const char *, const wchar_t *, wchar_t *, size_t *);
-int wcsicoll(const wchar_t *, const wchar_t *);
+wchar_t*convert(const char *);
+void   show(FILE *, const char *, const char *, char **, size_t *);
 static voidusage(void);
 
 int
 main(int argc, char *argv[])
 {
int comp, read1, read2;
-   int ch, flag1, flag2, flag3, iflag;
+   int ch, flag1, flag2, flag3;
FILE *fp1, *fp2;
-   const wchar_t *col1, *col2, *col3;
+   const char *col1, *col2, *col3;
size_t line1len, line2len;
-   wchar_t *line1, *line2;
-   const wchar_t **p;
-
-   flag1 = flag2 = flag3 = 1;
-   iflag = 0;
-
-   line1len = INITLINELEN;
-   line2len = INITLINELEN;
-   line1 = malloc(line1len * sizeof(*line1));
-   line2 = malloc(line2len * sizeof(*line2));
-   if (line1 == NULL || line2 == NULL)
-   err(1, "malloc");
+   char *line1, *line2;
+   ssize_t n1, n2;
+   wchar_t *tline1, *tline2;
+   const char **p;
 
(void) setlocale(LC_ALL, "");
 
+   flag1 = flag2 = flag3 = 1;
+
while ((ch = getopt(argc, argv, "123i")) != -1)
switch(ch) {
case '1':
@@ -131,41 +123,57 @@ main(int argc, char *argv[])
if (flag3)
col3 = *p;
 
+   line1len = line2len = 0;
+   line1 = line2 = NULL;
+   n1 = n2 = -1;
+
for (read1 = read2 = 1;;) {
/* read next line, check for EOF */
if (read1) {
-   line1 = getline(line1, &line1len, fp1);
-   if (line1 == NULL && ferror(fp1))
+   n1 = getline(&line1, &line1len, fp1);
+   if (n1 < 0 && ferror(fp1))
err(1, "%s", argv[0]);
+   if (n1 > 0 && line1[n1 - 1] == '\n')
+   line1[n1 - 1] = '\0';
+
}
if (read2) {
-   line2 = getline(line2, &line2len, fp2);
-   if (line2 == NULL && ferror(fp2))
+   n2 = getline(&line2, &line2len, fp2);
+   if (n2 < 0 && ferror(fp2))
err(1, "%s", argv[1]);
+   if (n2 > 0 && line2[n2 - 1] == '\n')
+   line2[n2 - 1] = '\0';
}
 
/* if one file done, display the rest of the other file */
-   if (line1 == NULL) {
-   if (line2 != NULL && col2 != NULL)
-   show(fp2, argv[1], col2, line2, &line2len);
+   if (n1 < 0) {
+   if (n2 >= 0 && col2 != NULL)
+   show(fp2, argv[1], col2, &line2, &line2len);
break;
}
-   if (line2 == NULL) {
-   if (line1 != NULL && col1 != NULL)
-   show(fp1, argv[0], col1, line1, &line1len);
+   if (n2 < 0) {
+   if (n1 >= 0 && col1 != NULL)
+   show(fp1, argv[0], col1, &line1, &line1len);
break;
}
 
-   /* lines are the same */
-   if(iflag)
-   comp = wcsicoll(line1, line2);
+   tline2 = NULL;
+   if ((tline1 = convert(line1)) != NULL)
+   tline2 = convert(line2);
+   if (tline1 == NULL || tline2 == NULL)
+   comp = strcmp(line1, line2);
else
-   comp = wcscoll(line1, line2);
+   comp = wcscoll(tline1, tline2);
+   if 

svn commit: r204927 - head/usr.bin/uniq

2010-03-09 Thread Andrey A. Chernov
Author: ache
Date: Tue Mar  9 21:06:01 2010
New Revision: 204927
URL: http://svn.freebsd.org/changeset/base/204927

Log:
  Add SIZE_MAX overflow check

Modified:
  head/usr.bin/uniq/uniq.c

Modified: head/usr.bin/uniq/uniq.c
==
--- head/usr.bin/uniq/uniq.cTue Mar  9 21:01:12 2010(r204926)
+++ head/usr.bin/uniq/uniq.cTue Mar  9 21:06:01 2010(r204927)
@@ -196,6 +196,8 @@ convert(const char *str)
 
if ((n = mbstowcs(NULL, str, 0)) == (size_t)-1)
return (NULL);
+   if (SIZE_MAX / sizeof(*buf) < n + 1)
+   errx(1, "conversion buffer length overflow");
if ((buf = malloc((n + 1) * sizeof(*buf))) == NULL)
err(1, "malloc");
if (mbstowcs(buf, str, n + 1) != n)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r204928 - head/usr.bin/comm

2010-03-09 Thread Andrey A. Chernov
Author: ache
Date: Tue Mar  9 21:06:17 2010
New Revision: 204928
URL: http://svn.freebsd.org/changeset/base/204928

Log:
  Add SIZE_MAX overflow check

Modified:
  head/usr.bin/comm/comm.c

Modified: head/usr.bin/comm/comm.c
==
--- head/usr.bin/comm/comm.cTue Mar  9 21:06:01 2010(r204927)
+++ head/usr.bin/comm/comm.cTue Mar  9 21:06:17 2010(r204928)
@@ -201,6 +201,8 @@ convert(const char *str)
 
if ((n = mbstowcs(NULL, str, 0)) == (size_t)-1)
return (NULL);
+   if (SIZE_MAX / sizeof(*buf) < n + 1)
+   errx(1, "conversion buffer length overflow");
if ((buf = malloc((n + 1) * sizeof(*buf))) == NULL)
err(1, "malloc");
if (mbstowcs(buf, str, n + 1) != n)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r267756 - head/lib/libc/stdlib

2014-06-22 Thread Andrey A. Chernov
Author: ache
Date: Sun Jun 22 21:54:57 2014
New Revision: 267756
URL: http://svnweb.freebsd.org/changeset/base/267756

Log:
  Merge intermediate OpenBSD v1.25 changes (almost identical to ours)
  to reduce diff and bump OpenBSD patch level to v1.26.
  
  MFC after:  2 weeks

Modified:
  head/lib/libc/stdlib/getopt_long.c

Modified: head/lib/libc/stdlib/getopt_long.c
==
--- head/lib/libc/stdlib/getopt_long.c  Sun Jun 22 21:37:27 2014
(r267755)
+++ head/lib/libc/stdlib/getopt_long.c  Sun Jun 22 21:54:57 2014
(r267756)
@@ -1,4 +1,4 @@
-/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $*/
+/* $OpenBSD: getopt_long.c,v 1.26 2013/06/08 22:47:56 millert Exp $
*/
 /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $  */
 
 /*
@@ -248,7 +248,7 @@ parse_long_options(char * const *nargv, 
if (short_too && current_argv_len == 1)
continue;
 
-   if (match == -1)/* first partial match */
+   if (match == -1)/* first partial match */
match = i;
else if ((flags & FLAG_LONGONLY) ||
 long_options[i].has_arg !=
@@ -359,37 +359,31 @@ getopt_internal(int nargc, char * const 
 {
char *oli;  /* option letter list index */
int optchar, short_too;
-   int posixly_correct;/* no static, can be changed on the fly */
+   static int posixly_correct = -1;
 
if (options == NULL)
return (-1);
 
/*
+* XXX Some GNU programs (like cvs) set optind to 0 instead of
+* XXX using optreset.  Work around this braindamage.
+*/
+   if (optind == 0)
+   optind = optreset = 1;
+
+   /*
 * Disable GNU extensions if POSIXLY_CORRECT is set or options
 * string begins with a '+'.
 */
-   posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
-#ifdef GNU_COMPATIBLE
+   if (posixly_correct == -1 || optreset)
+   posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
if (*options == '-')
flags |= FLAG_ALLARGS;
else if (posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
-#else
-   if (posixly_correct || *options == '+')
-   flags &= ~FLAG_PERMUTE;
-   else if (*options == '-')
-   flags |= FLAG_ALLARGS;
-#endif
if (*options == '+' || *options == '-')
options++;
 
-   /*
-* XXX Some GNU programs (like cvs) set optind to 0 instead of
-* XXX using optreset.  Work around this braindamage.
-*/
-   if (optind == 0)
-   optind = optreset = 1;
-
optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r267758 - head

2014-06-22 Thread Andrey A. Chernov
Author: ache
Date: Mon Jun 23 00:54:56 2014
New Revision: 267758
URL: http://svnweb.freebsd.org/changeset/base/267758

Log:
  Change suggestion how to set MAKESYSPATH as broken incremental build
  workaround. Magic ".../share/mk" (search directories up to /)
  does not work for f.e. /usr/src/gnu/lib/libgcc because the path
  inside is starting from /usr/obj hierarchy and ends up in
  /usr/share/mk, not in the /usr/src/share/mk where src.opts.mk is.
  IMHO proper fixing of incremental build is needed urgently.

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Sun Jun 22 23:40:20 2014(r267757)
+++ head/UPDATING   Mon Jun 23 00:54:56 2014(r267758)
@@ -67,7 +67,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
behavior back, you can .include /etc/src.conf from /etc/make.conf
(which is still global and isn't changed). This also changes the
behavior of incremental builds inside the tree of individual
-   directories. Set MAKESYSPATH to ".../share/mk" to do that.
+   directories. Set MAKESYSPATH to "/usr/src/share/mk" to do that.
Although this has survived make universe and some upgrade scenarios,
other upgrade scenarios may have broken. At least one form of
temporary breakage was fixed with MAKESYSPATH settings for buildworld
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r268355 - stable/10/lib/libc/stdlib

2014-07-06 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul  7 05:31:50 2014
New Revision: 268355
URL: http://svnweb.freebsd.org/changeset/base/268355

Log:
  MFC 267756:
  
  Merge intermediate OpenBSD v1.25 changes (almost identical to ours)
  to reduce diff and bump OpenBSD patch level to v1.26.

Modified:
  stable/10/lib/libc/stdlib/getopt_long.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdlib/getopt_long.c
==
--- stable/10/lib/libc/stdlib/getopt_long.c Mon Jul  7 05:17:16 2014
(r268354)
+++ stable/10/lib/libc/stdlib/getopt_long.c Mon Jul  7 05:31:50 2014
(r268355)
@@ -1,4 +1,4 @@
-/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $*/
+/* $OpenBSD: getopt_long.c,v 1.26 2013/06/08 22:47:56 millert Exp $
*/
 /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $  */
 
 /*
@@ -248,7 +248,7 @@ parse_long_options(char * const *nargv, 
if (short_too && current_argv_len == 1)
continue;
 
-   if (match == -1)/* first partial match */
+   if (match == -1)/* first partial match */
match = i;
else if ((flags & FLAG_LONGONLY) ||
 long_options[i].has_arg !=
@@ -359,37 +359,31 @@ getopt_internal(int nargc, char * const 
 {
char *oli;  /* option letter list index */
int optchar, short_too;
-   int posixly_correct;/* no static, can be changed on the fly */
+   static int posixly_correct = -1;
 
if (options == NULL)
return (-1);
 
/*
+* XXX Some GNU programs (like cvs) set optind to 0 instead of
+* XXX using optreset.  Work around this braindamage.
+*/
+   if (optind == 0)
+   optind = optreset = 1;
+
+   /*
 * Disable GNU extensions if POSIXLY_CORRECT is set or options
 * string begins with a '+'.
 */
-   posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
-#ifdef GNU_COMPATIBLE
+   if (posixly_correct == -1 || optreset)
+   posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
if (*options == '-')
flags |= FLAG_ALLARGS;
else if (posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
-#else
-   if (posixly_correct || *options == '+')
-   flags &= ~FLAG_PERMUTE;
-   else if (*options == '-')
-   flags |= FLAG_ALLARGS;
-#endif
if (*options == '+' || *options == '-')
options++;
 
-   /*
-* XXX Some GNU programs (like cvs) set optind to 0 instead of
-* XXX using optreset.  Work around this braindamage.
-*/
-   if (optind == 0)
-   optind = optreset = 1;
-
optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-07-22 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 22 19:55:25 2014
New Revision: 268991
URL: http://svnweb.freebsd.org/changeset/base/268991

Log:
  Checking for __SAPP alone is not enough because it is emulated O_APPEND
  only, so works for only special fdopen() case. Add real O_APPEND too.

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

Modified: head/lib/libc/stdio/ftell.c
==
--- head/lib/libc/stdio/ftell.c Tue Jul 22 19:54:22 2014(r268990)
+++ head/lib/libc/stdio/ftell.c Tue Jul 22 19:55:25 2014(r268991)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -118,7 +119,7 @@ _ftello(FILE *fp, fpos_t *offset)
if (HASUB(fp))
pos -= fp->_r;  /* Can be negative at this point. */
} else if ((fp->_flags & __SWR) && fp->_p != NULL) {
-   if (fp->_flags & __SAPP) {
+   if (fp->_flags & (__SAPP|O_APPEND)) {
pos = _sseek(fp, (fpos_t)0, SEEK_END);
if (pos == -1)
return (1);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-07-22 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 22 20:13:46 2014
New Revision: 268992
URL: http://svnweb.freebsd.org/changeset/base/268992

Log:
  Back the whole change out until I figure out how to obtain O_APPEND,
  it can't be used in this field at all.

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

Modified: head/lib/libc/stdio/ftell.c
==
--- head/lib/libc/stdio/ftell.c Tue Jul 22 19:55:25 2014(r268991)
+++ head/lib/libc/stdio/ftell.c Tue Jul 22 20:13:46 2014(r268992)
@@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include 
 #include 
-#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -119,11 +118,6 @@ _ftello(FILE *fp, fpos_t *offset)
if (HASUB(fp))
pos -= fp->_r;  /* Can be negative at this point. */
} else if ((fp->_flags & __SWR) && fp->_p != NULL) {
-   if (fp->_flags & (__SAPP|O_APPEND)) {
-   pos = _sseek(fp, (fpos_t)0, SEEK_END);
-   if (pos == -1)
-   return (1);
-   }
/*
 * Writing.  Any buffered characters cause the
 * position to be greater than that in the
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-07-22 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 22 22:49:37 2014
New Revision: 268997
URL: http://svnweb.freebsd.org/changeset/base/268997

Log:
  For "a"-mode files and rewind/fseek + fwrite combination return meaningful
  value now, like Apple does, but avoid their __sflush physical write
  performance degradation as much as possible.

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

Modified: head/lib/libc/stdio/ftell.c
==
--- head/lib/libc/stdio/ftell.c Tue Jul 22 22:39:59 2014(r268996)
+++ head/lib/libc/stdio/ftell.c Tue Jul 22 22:49:37 2014(r268997)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -87,6 +88,7 @@ _ftello(FILE *fp, fpos_t *offset)
 {
fpos_t pos;
size_t n;
+   int dflags;
 
if (fp->_seek == NULL) {
errno = ESPIPE; /* historic practice */
@@ -118,6 +120,22 @@ _ftello(FILE *fp, fpos_t *offset)
if (HASUB(fp))
pos -= fp->_r;  /* Can be negative at this point. */
} else if ((fp->_flags & __SWR) && fp->_p != NULL) {
+   dflags = 0;
+   if (fp->_flags & __SAPP)
+   dflags = O_APPEND;
+   else if (fp->_file != -1 &&
+(dflags = _fcntl(fp->_file, F_GETFL)) < 0)
+   return (1);
+   if ((dflags & O_APPEND) &&
+   (pos = _sseek(fp, (fpos_t)0, SEEK_END)) == -1) {
+   if ((fp->_flags & __SOPT) || __sflush(fp) ||
+   (pos = _sseek(fp, (fpos_t)0, SEEK_CUR)) == -1)
+   return (1);
+   else {
+   *offset = pos;
+   return (0);
+   }
+   }
/*
 * Writing.  Any buffered characters cause the
 * position to be greater than that in the
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-07-26 Thread Andrey A. Chernov
Author: ache
Date: Sat Jul 26 08:41:03 2014
New Revision: 269116
URL: http://svnweb.freebsd.org/changeset/base/269116

Log:
  In the "Too many open files" edge cases don't try to preserve old
  number for non-std* descriptors, but close old file and retry.
  
  Obtained from:  inspired by Apple's change from pfg@
  MFC after:  2 weeks

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

Modified: head/lib/libc/stdio/freopen.c
==
--- head/lib/libc/stdio/freopen.c   Sat Jul 26 07:40:31 2014
(r269115)
+++ head/lib/libc/stdio/freopen.c   Sat Jul 26 08:41:03 2014
(r269116)
@@ -151,6 +151,14 @@ freopen(const char * __restrict file, co
 
/* Get a new descriptor to refer to the new file. */
f = _open(file, oflags, DEFFILEMODE);
+   /* If out of fd's close the old one and try again. */
+   if (f < 0 && isopen && wantfd > STDERR_FILENO &&
+   (errno == ENFILE || errno == EMFILE)) {
+   (void) (*fp->_close)(fp->_cookie);
+   isopen = 0;
+   wantfd = -1;
+   f = _open(file, oflags, DEFFILEMODE);
+   }
sverrno = errno;
 
 finish:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-10-05 Thread Andrey A. Chernov
Author: ache
Date: Sun Oct  5 07:29:50 2014
New Revision: 272562
URL: https://svnweb.freebsd.org/changeset/base/272562

Log:
  1) For %Z format, understand "UTC" name too.
  2) Return NULL if timegm() fails, because it means we can convert
  what we have in GMT to local time needed.

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

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cSun Oct  5 07:27:05 2014
(r272561)
+++ head/lib/libc/stdtime/strptime.cSun Oct  5 07:29:50 2014
(r272562)
@@ -552,7 +552,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;
@@ -674,6 +675,9 @@ strptime_l(const char * __restrict buf, 
ret = _strptime(buf, fmt, tm, &gmt, loc);
if (ret && gmt) {
time_t t = timegm(tm);
+
+   if (t == -1)
+   return (NULL);
localtime_r(&t, tm);
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-10-06 Thread Andrey A. Chernov
Author: ache
Date: Tue Oct  7 06:02:08 2014
New Revision: 272678
URL: https://svnweb.freebsd.org/changeset/base/272678

Log:
  Back out timegm error check from r272562.
  
  POSIX treats negative time_t as undefined (i.e. may be valid too,
  depends on system's policy we don't have) and we don't set EOVERFLOW
  in mktime/timegm as POSIX requires to surely distinguish -1 return
  as valid negative time from -1 as error return.

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

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cTue Oct  7 06:00:32 2014
(r272677)
+++ head/lib/libc/stdtime/strptime.cTue Oct  7 06:02:08 2014
(r272678)
@@ -676,8 +676,6 @@ strptime_l(const char * __restrict buf, 
if (ret && gmt) {
time_t t = timegm(tm);
 
-   if (t == -1)
-   return (NULL);
localtime_r(&t, tm);
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-10-06 Thread Andrey A. Chernov
Author: ache
Date: Tue Oct  7 06:34:05 2014
New Revision: 272679
URL: https://svnweb.freebsd.org/changeset/base/272679

Log:
  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)
  
  PR: 93197

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

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cTue Oct  7 06:02:08 2014
(r272678)
+++ head/lib/libc/stdtime/strptime.cTue Oct  7 06:34:05 2014
(r272679)
@@ -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);
@@ -600,6 +596,9 @@ label:
while (isspace_l((unsigned char)*buf, locale))
buf++;
break;
+
+   default:
+   return (NULL);
}
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-10-19 Thread Andrey A. Chernov
Author: ache
Date: Sun Oct 19 21:16:24 2014
New Revision: 273290
URL: https://svnweb.freebsd.org/changeset/base/273290

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

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   Sun Oct 19 21:07:35 2014
(r273289)
+++ stable/10/lib/libc/stdtime/strptime.c   Sun Oct 19 21:16:24 2014
(r273290)
@@ -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
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-08-06 Thread Andrey A . Chernov
Author: ache
Date: Wed Aug  6 10:33:43 2014
New Revision: 269623
URL: http://svnweb.freebsd.org/changeset/base/269623

Log:
  MFC: r268997
  
  For "a"-mode files and rewind/fseek + fwrite combination return meaningful
  value now, like Apple does, but avoid their __sflush physical write
  performance degradation as much as possible.

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

Modified: stable/10/lib/libc/stdio/ftell.c
==
--- stable/10/lib/libc/stdio/ftell.cWed Aug  6 08:54:31 2014
(r269622)
+++ stable/10/lib/libc/stdio/ftell.cWed Aug  6 10:33:43 2014
(r269623)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include "namespace.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "un-namespace.h"
@@ -87,6 +88,7 @@ _ftello(FILE *fp, fpos_t *offset)
 {
fpos_t pos;
size_t n;
+   int dflags;
 
if (fp->_seek == NULL) {
errno = ESPIPE; /* historic practice */
@@ -118,6 +120,22 @@ _ftello(FILE *fp, fpos_t *offset)
if (HASUB(fp))
pos -= fp->_r;  /* Can be negative at this point. */
} else if ((fp->_flags & __SWR) && fp->_p != NULL) {
+   dflags = 0;
+   if (fp->_flags & __SAPP)
+   dflags = O_APPEND;
+   else if (fp->_file != -1 &&
+(dflags = _fcntl(fp->_file, F_GETFL)) < 0)
+   return (1);
+   if ((dflags & O_APPEND) &&
+   (pos = _sseek(fp, (fpos_t)0, SEEK_END)) == -1) {
+   if ((fp->_flags & __SOPT) || __sflush(fp) ||
+   (pos = _sseek(fp, (fpos_t)0, SEEK_CUR)) == -1)
+   return (1);
+   else {
+   *offset = pos;
+   return (0);
+   }
+   }
/*
 * Writing.  Any buffered characters cause the
 * position to be greater than that in the
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2014-08-06 Thread Andrey A . Chernov
Author: ache
Date: Wed Aug  6 10:38:06 2014
New Revision: 269624
URL: http://svnweb.freebsd.org/changeset/base/269624

Log:
  MFC: r269116
  
  In the "Too many open files" edge cases don't try to preserve old
  number for non-std* descriptors, but close old file and retry.
  
  Obtained from:  inspired by Apple's change from pfg@

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

Modified: stable/10/lib/libc/stdio/freopen.c
==
--- stable/10/lib/libc/stdio/freopen.c  Wed Aug  6 10:33:43 2014
(r269623)
+++ stable/10/lib/libc/stdio/freopen.c  Wed Aug  6 10:38:06 2014
(r269624)
@@ -150,6 +150,14 @@ freopen(const char * __restrict file, co
 
/* Get a new descriptor to refer to the new file. */
f = _open(file, oflags, DEFFILEMODE);
+   /* If out of fd's close the old one and try again. */
+   if (f < 0 && isopen && wantfd > STDERR_FILENO &&
+   (errno == ENFILE || errno == EMFILE)) {
+   (void) (*fp->_close)(fp->_cookie);
+   isopen = 0;
+   wantfd = -1;
+   f = _open(file, oflags, DEFFILEMODE);
+   }
sverrno = errno;
 
 finish:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r269806 - in head/contrib/opie: . libopie

2014-08-11 Thread Andrey A . Chernov
Author: ache
Date: Mon Aug 11 12:26:48 2014
New Revision: 269806
URL: http://svnweb.freebsd.org/changeset/base/269806

Log:
  Fix too long (seed length >12 chars) challenge handling.
  1) " ext" length should be included into OPIE_CHALLENGE_MAX (as all places
  of opie code expects that).
  2) Overflow check in challenge.c is off by 1 even with corrected
  OPIE_CHALLENGE_MAX
  3) When fallback to randomchallenge() happens and rval is 0 (i.e.
  challenge is too long), its value should be set to error state too.
  
  To demonstrate the bug, run opiepasswd with valid seed:
  opiepasswd -s 1234567890123456
  and notice that it falls back to randomchallenge() (i.e. no
  1234567890123456 in the prompt).
  
  PR: 191511
  Submitted by:   mitsurur...@gmail.com (partially)
  MFC after:  1 week

Modified:
  head/contrib/opie/libopie/challenge.c
  head/contrib/opie/opie.h

Modified: head/contrib/opie/libopie/challenge.c
==
--- head/contrib/opie/libopie/challenge.c   Mon Aug 11 08:58:35 2014
(r269805)
+++ head/contrib/opie/libopie/challenge.c   Mon Aug 11 12:26:48 2014
(r269806)
@@ -68,7 +68,9 @@ int opiechallenge FUNCTION((mp, name, ss
   }
 
   if (rval ||
-(snprintf(ss, OPIE_CHALLENGE_MAX, "otp-%s %d %s ext", algids[MDX], 
mp->opie_n - 1, mp->opie_seed) >= OPIE_CHALLENGE_MAX)) {
+(snprintf(ss, OPIE_CHALLENGE_MAX+1, "otp-%s %d %s ext", algids[MDX], 
mp->opie_n - 1, mp->opie_seed) >= OPIE_CHALLENGE_MAX+1)) {
+if (!rval)
+  rval = 1;
 opierandomchallenge(ss);
 memset(mp, 0, sizeof(*mp));
   }

Modified: head/contrib/opie/opie.h
==
--- head/contrib/opie/opie.hMon Aug 11 08:58:35 2014(r269805)
+++ head/contrib/opie/opie.hMon Aug 11 12:26:48 2014(r269806)
@@ -72,8 +72,8 @@ struct opie {
 /* Max length of hash algorithm name (md4/md5) */
 #define OPIE_HASHNAME_MAX 3
 
-/* Maximum length of a challenge (otp-md?  seed) */
-#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX)
+/* Maximum length of a challenge (otp-md?  seed ext) */
+#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX+1+3)
 
 /* Maximum length of a response that we allow */
 #define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r269809 - head/contrib/opie

2014-08-11 Thread Andrey A . Chernov
Author: ache
Date: Mon Aug 11 13:36:02 2014
New Revision: 269809
URL: http://svnweb.freebsd.org/changeset/base/269809

Log:
  When sha1 support was added, they forget to increase OPIE_HASHNAME_MAX
  
  MFC after:  1 week

Modified:
  head/contrib/opie/opie.h

Modified: head/contrib/opie/opie.h
==
--- head/contrib/opie/opie.hMon Aug 11 13:12:18 2014(r269808)
+++ head/contrib/opie/opie.hMon Aug 11 13:36:02 2014(r269809)
@@ -69,8 +69,8 @@ struct opie {
 /* Maximum length of a seed */
 #define OPIE_SEED_MAX 16
 
-/* Max length of hash algorithm name (md4/md5) */
-#define OPIE_HASHNAME_MAX 3
+/* Max length of hash algorithm name (md4/md5/sha1) */
+#define OPIE_HASHNAME_MAX 4
 
 /* Maximum length of a challenge (otp-md?  seed ext) */
 #define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX+1+3)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r269810 - head/usr.bin/opiekey

2014-08-11 Thread Andrey A . Chernov
Author: ache
Date: Mon Aug 11 14:37:57 2014
New Revision: 269810
URL: http://svnweb.freebsd.org/changeset/base/269810

Log:
  Link otp-sha1 to match real challenge prompt, not otp-sha
  
  MFC after:  1 week

Modified:
  head/usr.bin/opiekey/Makefile

Modified: head/usr.bin/opiekey/Makefile
==
--- head/usr.bin/opiekey/Makefile   Mon Aug 11 13:36:02 2014
(r269809)
+++ head/usr.bin/opiekey/Makefile   Mon Aug 11 14:37:57 2014
(r269810)
@@ -15,9 +15,9 @@ LDADD=-lopie -lmd
 
 LINKS= ${BINDIR}/opiekey ${BINDIR}/otp-md4
 LINKS+=${BINDIR}/opiekey ${BINDIR}/otp-md5
-LINKS+=${BINDIR}/opiekey ${BINDIR}/otp-sha
+LINKS+=${BINDIR}/opiekey ${BINDIR}/otp-sha1
 
-MLINKS=opiekey.1 otp-md4.1 opiekey.1 otp-md5.1 opiekey.1 otp-sha.1
+MLINKS=opiekey.1 otp-md4.1 opiekey.1 otp-md5.1 opiekey.1 otp-sha1.1
 
 .PATH: ${OPIE_DIST}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r269811 - head/contrib/opie

2014-08-11 Thread Andrey A . Chernov
Author: ache
Date: Mon Aug 11 14:46:09 2014
New Revision: 269811
URL: http://svnweb.freebsd.org/changeset/base/269811

Log:
  Last '/' for program name, not first one
  
  MFC after:  1 week

Modified:
  head/contrib/opie/opiekey.c

Modified: head/contrib/opie/opiekey.c
==
--- head/contrib/opie/opiekey.c Mon Aug 11 14:37:57 2014(r269810)
+++ head/contrib/opie/opiekey.c Mon Aug 11 14:46:09 2014(r269811)
@@ -145,7 +145,7 @@ int main FUNCTION((argc, argv), int argc
   int type = RESPONSE_STANDARD;
   int force = 0;
 
-  if (slash = strchr(argv[0], '/'))
+  if (slash = strrchr(argv[0], '/'))
 slash++;
   else
 slash = argv[0];
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r269815 - head

2014-08-11 Thread Andrey A . Chernov
Author: ache
Date: Mon Aug 11 15:41:55 2014
New Revision: 269815
URL: http://svnweb.freebsd.org/changeset/base/269815

Log:
  Add otp-sha
  
  MFC after:  1 week

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Mon Aug 11 15:37:02 2014(r269814)
+++ head/ObsoleteFiles.inc  Mon Aug 11 15:41:55 2014(r269815)
@@ -38,6 +38,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20140811: otp-sha renamed to otp-sha1
+OLD_FILES+=usr/bin/otp-sha
+OLD_FILES+=usr/share/man/man1/otp-sha.1.gz
 # 20140807: Remove private lib files that should not be installed.
 OLD_FILES+=usr/lib/private/libatf-c.a
 OLD_FILES+=usr/lib/private/libatf-c.so
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r269875 - head/lib/libpam/modules/pam_opie

2014-08-12 Thread Andrey A . Chernov
Author: ache
Date: Tue Aug 12 13:28:46 2014
New Revision: 269875
URL: http://svnweb.freebsd.org/changeset/base/269875

Log:
  According to opie code and even direct mention in opie(4) challenge buffer
  size must be OPIE_CHALLENGE_MAX + 1, not OPIE_CHALLENGE_MAX
  
  Reviewed by:des
  MFC after:  1 week

Modified:
  head/lib/libpam/modules/pam_opie/pam_opie.c

Modified: head/lib/libpam/modules/pam_opie/pam_opie.c
==
--- head/lib/libpam/modules/pam_opie/pam_opie.c Tue Aug 12 13:13:11 2014
(r269874)
+++ head/lib/libpam/modules/pam_opie/pam_opie.c Tue Aug 12 13:28:46 2014
(r269875)
@@ -62,7 +62,7 @@ pam_sm_authenticate(pam_handle_t *pamh, 
struct passwd *pwd;
int retval, i;
const char *(promptstr[]) = { "%s\nPassword: ", "%s\nPassword [echo 
on]: "};
-   char challenge[OPIE_CHALLENGE_MAX];
+   char challenge[OPIE_CHALLENGE_MAX + 1];
char principal[OPIE_PRINCIPAL_MAX];
const char *user;
char *response;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r269961 - in head: . lib/libopie

2014-08-13 Thread Andrey A. Chernov
Author: ache
Date: Thu Aug 14 04:42:09 2014
New Revision: 269961
URL: http://svnweb.freebsd.org/changeset/base/269961

Log:
  Bump version because challenge buffer size changed
  
  MFC after:  1 week

Modified:
  head/ObsoleteFiles.inc
  head/lib/libopie/Makefile

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Aug 14 04:21:31 2014(r269960)
+++ head/ObsoleteFiles.inc  Thu Aug 14 04:42:09 2014(r269961)
@@ -38,6 +38,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20140814: libopie version bump
+OLD_LIBS+=usr/lib/libopie.so.7
+OLD_LIBS+=usr/lib32/libopie.so.7
 # 20140811: otp-sha renamed to otp-sha1
 OLD_FILES+=usr/bin/otp-sha
 OLD_FILES+=usr/share/man/man1/otp-sha.1.gz

Modified: head/lib/libopie/Makefile
==
--- head/lib/libopie/Makefile   Thu Aug 14 04:21:31 2014(r269960)
+++ head/lib/libopie/Makefile   Thu Aug 14 04:42:09 2014(r269961)
@@ -4,7 +4,7 @@
 #
 OPIE_DIST?=${.CURDIR}/../../contrib/opie
 DIST_DIR=  ${OPIE_DIST}/${.CURDIR:T}
-SHLIB_MAJOR=7
+SHLIB_MAJOR=8
 
 KEYFILE?=  \"/etc/opiekeys\"
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r270120 - in stable/10: contrib/opie contrib/opie/libopie usr.bin/opiekey

2014-08-17 Thread Andrey A. Chernov
Author: ache
Date: Mon Aug 18 02:13:45 2014
New Revision: 270120
URL: http://svnweb.freebsd.org/changeset/base/270120

Log:
  MFC: r269806,r269809,r269811,r269810
  
  r269806:
  Fix too long (seed length >12 chars) challenge handling.
  1) " ext" length should be included into OPIE_CHALLENGE_MAX (as all places
  of opie code expects that).
  2) Overflow check in challenge.c is off by 1 even with corrected
  OPIE_CHALLENGE_MAX
  3) When fallback to randomchallenge() happens and rval is 0 (i.e.
  challenge is too long), its value should be set to error state too.
  
  To demonstrate the bug, run opiepasswd with valid seed:
  opiepasswd -s 1234567890123456
  and notice that it falls back to randomchallenge() (i.e. no
  1234567890123456 in the prompt).
  
  r269809:
  When sha1 support was added, they forget to increase OPIE_HASHNAME_MAX
  
  r269811:
  Last '/' for program name, not first one.
  
  r269810:
  Link otp-sha1 to match real challenge prompt, not otp-sha.
  
  PR: 191511
  Submitted by: mitsurur...@gmail.com (partially, PR 269806)

Modified:
  stable/10/contrib/opie/libopie/challenge.c
  stable/10/contrib/opie/opie.h
  stable/10/contrib/opie/opiekey.c
  stable/10/usr.bin/opiekey/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/opie/libopie/challenge.c
==
--- stable/10/contrib/opie/libopie/challenge.c  Mon Aug 18 01:49:42 2014
(r270119)
+++ stable/10/contrib/opie/libopie/challenge.c  Mon Aug 18 02:13:45 2014
(r270120)
@@ -68,7 +68,9 @@ int opiechallenge FUNCTION((mp, name, ss
   }
 
   if (rval ||
-(snprintf(ss, OPIE_CHALLENGE_MAX, "otp-%s %d %s ext", algids[MDX], 
mp->opie_n - 1, mp->opie_seed) >= OPIE_CHALLENGE_MAX)) {
+(snprintf(ss, OPIE_CHALLENGE_MAX+1, "otp-%s %d %s ext", algids[MDX], 
mp->opie_n - 1, mp->opie_seed) >= OPIE_CHALLENGE_MAX+1)) {
+if (!rval)
+  rval = 1;
 opierandomchallenge(ss);
 memset(mp, 0, sizeof(*mp));
   }

Modified: stable/10/contrib/opie/opie.h
==
--- stable/10/contrib/opie/opie.h   Mon Aug 18 01:49:42 2014
(r270119)
+++ stable/10/contrib/opie/opie.h   Mon Aug 18 02:13:45 2014
(r270120)
@@ -69,11 +69,11 @@ struct opie {
 /* Maximum length of a seed */
 #define OPIE_SEED_MAX 16
 
-/* Max length of hash algorithm name (md4/md5) */
-#define OPIE_HASHNAME_MAX 3
+/* Max length of hash algorithm name (md4/md5/sha1) */
+#define OPIE_HASHNAME_MAX 4
 
-/* Maximum length of a challenge (otp-md?  seed) */
-#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX)
+/* Maximum length of a challenge (otp-md?  seed ext) */
+#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX+1+3)
 
 /* Maximum length of a response that we allow */
 #define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19)

Modified: stable/10/contrib/opie/opiekey.c
==
--- stable/10/contrib/opie/opiekey.cMon Aug 18 01:49:42 2014
(r270119)
+++ stable/10/contrib/opie/opiekey.cMon Aug 18 02:13:45 2014
(r270120)
@@ -144,7 +144,7 @@ int main FUNCTION((argc, argv), int argc
   int type = RESPONSE_STANDARD;
   int force = 0;
 
-  if (slash = strchr(argv[0], '/'))
+  if (slash = strrchr(argv[0], '/'))
 slash++;
   else
 slash = argv[0];

Modified: stable/10/usr.bin/opiekey/Makefile
==
--- stable/10/usr.bin/opiekey/Makefile  Mon Aug 18 01:49:42 2014
(r270119)
+++ stable/10/usr.bin/opiekey/Makefile  Mon Aug 18 02:13:45 2014
(r270120)
@@ -15,9 +15,9 @@ LDADD=-lopie -lmd
 
 LINKS= ${BINDIR}/opiekey ${BINDIR}/otp-md4
 LINKS+=${BINDIR}/opiekey ${BINDIR}/otp-md5
-LINKS+=${BINDIR}/opiekey ${BINDIR}/otp-sha
+LINKS+=${BINDIR}/opiekey ${BINDIR}/otp-sha1
 
-MLINKS=opiekey.1 otp-md4.1 opiekey.1 otp-md5.1 opiekey.1 otp-sha.1
+MLINKS=opiekey.1 otp-md4.1 opiekey.1 otp-md5.1 opiekey.1 otp-sha1.1
 
 .PATH: ${OPIE_DIST}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r270121 - stable/10

2014-08-17 Thread Andrey A. Chernov
Author: ache
Date: Mon Aug 18 02:32:48 2014
New Revision: 270121
URL: http://svnweb.freebsd.org/changeset/base/270121

Log:
  Direct commit to stable/10 reflecting r269815 because rest can't be merged
  
  Add otp-sha

Modified:
  stable/10/ObsoleteFiles.inc

Modified: stable/10/ObsoleteFiles.inc
==
--- stable/10/ObsoleteFiles.inc Mon Aug 18 02:13:45 2014(r270120)
+++ stable/10/ObsoleteFiles.inc Mon Aug 18 02:32:48 2014(r270121)
@@ -38,6 +38,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20140811: otp-sha renamed to otp-sha1
+OLD_FILES+=usr/bin/otp-sha
+OLD_FILES+=usr/share/man/man1/otp-sha.1.gz
 # 20140812: example files removed
 OLD_FILES+=usr/share/examples/libusb20/aux.c
 OLD_FILES+=usr/share/examples/libusb20/aux.h
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r270122 - in stable/10: . lib/libopie

2014-08-17 Thread Andrey A. Chernov
Author: ache
Date: Mon Aug 18 02:42:23 2014
New Revision: 270122
URL: http://svnweb.freebsd.org/changeset/base/270122

Log:
  Direct commit to stable/10 reflecting r269961 because the rest can't be
  merged.
  
  Bump version because challenge buffer size changed.

Modified:
  stable/10/ObsoleteFiles.inc
  stable/10/lib/libopie/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/ObsoleteFiles.inc
==
--- stable/10/ObsoleteFiles.inc Mon Aug 18 02:32:48 2014(r270121)
+++ stable/10/ObsoleteFiles.inc Mon Aug 18 02:42:23 2014(r270122)
@@ -38,6 +38,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20140814: libopie version bump
+OLD_LIBS+=usr/lib/libopie.so.7
+OLD_LIBS+=usr/lib32/libopie.so.7
 # 20140811: otp-sha renamed to otp-sha1
 OLD_FILES+=usr/bin/otp-sha
 OLD_FILES+=usr/share/man/man1/otp-sha.1.gz

Modified: stable/10/lib/libopie/Makefile
==
--- stable/10/lib/libopie/Makefile  Mon Aug 18 02:32:48 2014
(r270121)
+++ stable/10/lib/libopie/Makefile  Mon Aug 18 02:42:23 2014
(r270122)
@@ -4,7 +4,7 @@
 #
 OPIE_DIST?=${.CURDIR}/../../contrib/opie
 DIST_DIR=  ${OPIE_DIST}/${.CURDIR:T}
-SHLIB_MAJOR=7
+SHLIB_MAJOR=8
 
 KEYFILE?=  \"/etc/opiekeys\"
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r270125 - stable/10/lib/libpam/modules/pam_opie

2014-08-17 Thread Andrey A. Chernov
Author: ache
Date: Mon Aug 18 03:06:49 2014
New Revision: 270125
URL: http://svnweb.freebsd.org/changeset/base/270125

Log:
  MFC: r269875
  
  According to opie code and even direct mention in opie(4) challenge buffer
  size must be OPIE_CHALLENGE_MAX + 1, not OPIE_CHALLENGE_MAX
  
  Reviewed by:des

Modified:
  stable/10/lib/libpam/modules/pam_opie/pam_opie.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libpam/modules/pam_opie/pam_opie.c
==
--- stable/10/lib/libpam/modules/pam_opie/pam_opie.cMon Aug 18 02:45:06 
2014(r270124)
+++ stable/10/lib/libpam/modules/pam_opie/pam_opie.cMon Aug 18 03:06:49 
2014(r270125)
@@ -62,7 +62,7 @@ pam_sm_authenticate(pam_handle_t *pamh, 
struct passwd *pwd;
int retval, i;
const char *(promptstr[]) = { "%s\nPassword: ", "%s\nPassword [echo 
on]: "};
-   char challenge[OPIE_CHALLENGE_MAX];
+   char challenge[OPIE_CHALLENGE_MAX + 1];
char principal[OPIE_PRINCIPAL_MAX];
const char *user;
char *response;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r301443 - stable/10/lib/libc/stdlib

2016-06-05 Thread Andrey A. Chernov
Author: ache
Date: Sun Jun  5 13:39:31 2016
New Revision: 301443
URL: https://svnweb.freebsd.org/changeset/base/301443

Log:
  MFC: r300953
  
  1) Unifdef USE_WEAK_SEEDING it is too obsolete to support and makes reading
  harder.
  
  2) ACM paper require seed to be in [1, 2^31-2] range, so use the same range
  shifting as already done for rand(3). Also protect srandomdev() + TYPE_0 case
  (non default) from negative seeds.
  
  3) Don't check for valid "type" range in setstate(), it is always valid as
  calculated. Instead add a check that rear pointer not exceeed end pointer.
  
  MFC: r300965
  
  Micro optimize: C standard guarantees that right shift for unsigned value
  fills left bits with zero, and we have exact 32bit unsigned value
  (uint32_t), so there is no reason to add "& 0x7fff" here.

Modified:
  stable/10/lib/libc/stdlib/random.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdlib/random.c
==
--- stable/10/lib/libc/stdlib/random.c  Sun Jun  5 11:56:03 2016
(r301442)
+++ stable/10/lib/libc/stdlib/random.c  Sun Jun  5 13:39:31 2016
(r301443)
@@ -137,11 +137,7 @@ __FBSDID("$FreeBSD$");
  */
 #defineMAX_TYPES   5   /* max number of types above */
 
-#ifdef  USE_WEAK_SEEDING
-#define NSHUFF 0
-#else   /* !USE_WEAK_SEEDING */
 #define NSHUFF 50   /* to drop some "seed -> 1st value" linearity */
-#endif  /* !USE_WEAK_SEEDING */
 
 static const int degrees[MAX_TYPES] =  { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
 static const int seps [MAX_TYPES] ={ SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
@@ -162,23 +158,12 @@ static const int seps [MAX_TYPES] =   { SE
 
 static uint32_t randtbl[DEG_3 + 1] = {
TYPE_3,
-#ifdef  USE_WEAK_SEEDING
-/* Historic implementation compatibility */
-/* The random sequences do not vary much with the seed */
-   0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5,
-   0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
-   0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88,
-   0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
-   0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b,
-   0x27fb47b9,
-#else   /* !USE_WEAK_SEEDING */
-   0x991539b1, 0x16a5bce3, 0x6774a4cd, 0x3e01511e, 0x4e508aaa, 0x61048c05,
-   0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454,
-   0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471,
-   0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1,
-   0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41,
-   0xf3bec5da
-#endif  /* !USE_WEAK_SEEDING */
+   0x2cf41758, 0x27bb3711, 0x4916d4d1, 0x7b02f59f, 0x9b8e28eb, 0xc0e80269,
+   0x696f5c16, 0x878f1ff5, 0x52d9c07f, 0x916a06cd, 0xb50b3a20, 0x2776970a,
+   0xee4eb2a6, 0xe94640ec, 0xb1d65612, 0x9d1ed968, 0x1043f6b7, 0xa3432a76,
+   0x17eacbb9, 0x3c09e2eb, 0x4f8c2b3,  0x708a1f57, 0xee341814, 0x95d0e4d2,
+   0xb06f216c, 0x8bd2e72e, 0x8f7c38d7, 0xcfc6a8fc, 0x2a59495,  0xa20d2a69,
+   0xe29d12d1
 };
 
 /*
@@ -215,16 +200,8 @@ static int rand_sep = SEP_3;
 static uint32_t *end_ptr = &randtbl[DEG_3 + 1];
 
 static inline uint32_t
-good_rand(int32_t x)
+good_rand(uint32_t ctx)
 {
-#ifdef  USE_WEAK_SEEDING
-/*
- * Historic implementation compatibility.
- * The random sequences do not vary much with the seed,
- * even with overflowing.
- */
-   return (1103515245 * x + 12345);
-#else   /* !USE_WEAK_SEEDING */
 /*
  * Compute x = (7^5 * x) mod (2^31 - 1)
  * wihout overflowing 31 bits:
@@ -233,18 +210,17 @@ good_rand(int32_t x)
  * Park and Miller, Communications of the ACM, vol. 31, no. 10,
  * October 1988, p. 1195.
  */
-   int32_t hi, lo;
+   int32_t hi, lo, x;
 
-   /* Can't be initialized with 0, so use another value. */
-   if (x == 0)
-   x = 123459876;
+   /* Transform to [1, 0x7ffe] range. */
+   x = (ctx % 0x7ffe) + 1;
hi = x / 127773;
lo = x % 127773;
x = 16807 * lo - 2836 * hi;
if (x < 0)
x += 0x7fff;
-   return (x);
-#endif  /* !USE_WEAK_SEEDING */
+   /* Transform to [0, 0x7ffd] range. */
+   return (x - 1);
 }
 
 /*
@@ -404,16 +380,8 @@ setstate(char *arg_state)
uint32_t rear = new_state[0] / MAX_TYPES;
char *ostate = (char *)(&state[-1]);
 
-   switch(type) {
-   case TYPE_0:
-   case TYPE_1:
-   case TYPE_2:
-   case TYPE_3:
-   case TYPE_4:
-   break;
-   default:
+   if (type != TYPE_0 && rear >= degrees[type])
return (NULL);
-   }
if (rand_type == TYPE_0)
state[-1] = rand_type;
else
@@ -455,14 +423,14 @@ random(void)
 
if (rand_type == TYPE_0) {
  

svn commit: r301444 - stable/10/lib/libc/stdlib

2016-06-05 Thread Andrey A. Chernov
Author: ache
Date: Sun Jun  5 14:04:54 2016
New Revision: 301444
URL: https://svnweb.freebsd.org/changeset/base/301444

Log:
  Prepare for merge of r300956. One year old r288030 which fix prototypes
  can't be merged without conflicts and require merging of other versions
  too and I don't want to go deep in that unmerged commits chain.

Modified:
  stable/10/lib/libc/stdlib/rand.c

Modified: stable/10/lib/libc/stdlib/rand.c
==
--- stable/10/lib/libc/stdlib/rand.cSun Jun  5 13:39:31 2016
(r301443)
+++ stable/10/lib/libc/stdlib/rand.cSun Jun  5 14:04:54 2016
(r301444)
@@ -111,14 +111,13 @@ static u_long next =
 #endif
 
 int
-rand()
+rand(void)
 {
return (do_rand(&next));
 }
 
 void
-srand(seed)
-u_int seed;
+srand(u_int seed)
 {
next = seed;
 #ifndef USE_WEAK_SEEDING
@@ -136,7 +135,7 @@ u_int seed;
  * data from the kernel.
  */
 void
-sranddev()
+sranddev(void)
 {
int mib[2];
size_t len;
___
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: r301445 - stable/10/lib/libc/stdlib

2016-06-05 Thread Andrey A. Chernov
Author: ache
Date: Sun Jun  5 14:31:36 2016
New Revision: 301445
URL: https://svnweb.freebsd.org/changeset/base/301445

Log:
  MFC: r300956
  
  1) Unifdef USE_WEAK_SEEDING since it is too obsolete to support and makes
  reading hard.
  
  2) Instead of doing range transformation in each and every function here,
  do it single time directly in do_rand(). One "mod" operation overhead is not
  a big deal, but the code looks nicer and possible future functions additions
  or PRNG change do not miss range transformations neither have unneeded ones.
  
  3) Use POSIX argument types for visible functions (cosmetic).

Modified:
  stable/10/lib/libc/stdlib/rand.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdlib/rand.c
==
--- stable/10/lib/libc/stdlib/rand.cSun Jun  5 14:04:54 2016
(r301444)
+++ stable/10/lib/libc/stdlib/rand.cSun Jun  5 14:31:36 2016
(r301445)
@@ -49,14 +49,6 @@ __FBSDID("$FreeBSD$");
 static int
 do_rand(unsigned long *ctx)
 {
-#ifdef  USE_WEAK_SEEDING
-/*
- * Historic implementation compatibility.
- * The random sequences do not vary much with the seed,
- * even with overflowing.
- */
-   return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
-#else   /* !USE_WEAK_SEEDING */
 /*
  * Compute x = (7^5 * x) mod (2^31 - 1)
  * without overflowing 31 bits:
@@ -67,48 +59,34 @@ do_rand(unsigned long *ctx)
  */
long hi, lo, x;
 
-   /* Must be in [1, 0x7ffe] range at this point. */
-   hi = *ctx / 127773;
-   lo = *ctx % 127773;
+   /* Transform to [1, 0x7ffe] range. */
+   x = (*ctx % 0x7ffe) + 1;
+   hi = x / 127773;
+   lo = x % 127773;
x = 16807 * lo - 2836 * hi;
if (x < 0)
x += 0x7fff;
-   *ctx = x;
/* Transform to [0, 0x7ffd] range. */
-   return (x - 1);
-#endif  /* !USE_WEAK_SEEDING */
+   x--;
+   *ctx = x;
+   return (x);
 }
 
 
 int
-rand_r(unsigned int *ctx)
+rand_r(unsigned *ctx)
 {
u_long val;
int r;
 
-#ifdef  USE_WEAK_SEEDING
val = *ctx;
-#else
-   /* Transform to [1, 0x7ffe] range. */
-   val = (*ctx % 0x7ffe) + 1;
-#endif
r = do_rand(&val);
-
-#ifdef  USE_WEAK_SEEDING
-   *ctx = (unsigned int)val;
-#else
-   *ctx = (unsigned int)(val - 1);
-#endif
+   *ctx = (unsigned)val;
return (r);
 }
 
 
-static u_long next =
-#ifdef  USE_WEAK_SEEDING
-1;
-#else
-2;
-#endif
+static u_long next = 1;
 
 int
 rand(void)
@@ -117,13 +95,9 @@ rand(void)
 }
 
 void
-srand(u_int seed)
+srand(unsigned seed)
 {
next = seed;
-#ifndef USE_WEAK_SEEDING
-   /* Transform to [1, 0x7ffe] range. */
-   next = (next % 0x7ffe) + 1;
-#endif
 }
 
 
@@ -145,10 +119,6 @@ sranddev(void)
mib[0] = CTL_KERN;
mib[1] = KERN_ARND;
sysctl(mib, 2, (void *)&next, &len, NULL, 0);
-#ifndef USE_WEAK_SEEDING
-   /* Transform to [1, 0x7ffe] range. */
-   next = (next % 0x7ffe) + 1;
-#endif
 }
 
 
___
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: r301448 - head/lib/libc/stdlib

2016-06-05 Thread Andrey A. Chernov
Author: ache
Date: Sun Jun  5 15:46:14 2016
New Revision: 301448
URL: https://svnweb.freebsd.org/changeset/base/301448

Log:
  Reflect error indication according to POSIX and what those functions
  currently do.

Modified:
  head/lib/libc/stdlib/random.3

Modified: head/lib/libc/stdlib/random.3
==
--- head/lib/libc/stdlib/random.3   Sun Jun  5 15:05:53 2016
(r301447)
+++ head/lib/libc/stdlib/random.3   Sun Jun  5 15:46:14 2016
(r301448)
@@ -174,8 +174,8 @@ If
 .Fn initstate
 is called with less than 8 bytes of state information, or if
 .Fn setstate
-detects that the state information has been garbled, error
-messages are printed on the standard error output.
+detects that the state information has been garbled,
+NULL is returned.
 .Sh SEE ALSO
 .Xr arc4random 3 ,
 .Xr lrand48 3 ,
___
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: r301454 - stable/10/lib/libc/stdlib

2016-06-05 Thread Andrey A. Chernov
Author: ache
Date: Sun Jun  5 16:21:53 2016
New Revision: 301454
URL: https://svnweb.freebsd.org/changeset/base/301454

Log:
  MFC: r301448
  
  Reflect error indication according to POSIX and what those functions
  currently do.

Modified:
  stable/10/lib/libc/stdlib/random.3
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdlib/random.3
==
--- stable/10/lib/libc/stdlib/random.3  Sun Jun  5 16:20:12 2016
(r301453)
+++ stable/10/lib/libc/stdlib/random.3  Sun Jun  5 16:21:53 2016
(r301454)
@@ -175,8 +175,8 @@ If
 .Fn initstate
 is called with less than 8 bytes of state information, or if
 .Fn setstate
-detects that the state information has been garbled, error
-messages are printed on the standard error output.
+detects that the state information has been garbled,
+NULL is returned.
 .Sh SEE ALSO
 .Xr arc4random 3 ,
 .Xr lrand48 3 ,
___
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: r301459 - stable/10/lib/libc/stdlib

2016-06-05 Thread Andrey A. Chernov
Author: ache
Date: Sun Jun  5 18:11:52 2016
New Revision: 301459
URL: https://svnweb.freebsd.org/changeset/base/301459

Log:
  MFC: r301115
  
  Don't use fixup for C99 and up, the compiler result is already correct.
  
  Suggested by: bde

Modified:
  stable/10/lib/libc/stdlib/div.c
  stable/10/lib/libc/stdlib/imaxdiv.c
  stable/10/lib/libc/stdlib/ldiv.c
  stable/10/lib/libc/stdlib/lldiv.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/stdlib/div.c
==
--- stable/10/lib/libc/stdlib/div.c Sun Jun  5 17:31:36 2016
(r301458)
+++ stable/10/lib/libc/stdlib/div.c Sun Jun  5 18:11:52 2016
(r301459)
@@ -46,6 +46,7 @@ div(num, denom)
 
r.quot = num / denom;
r.rem = num % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
/*
 * The ANSI standard says that |r.quot| <= |n/d|, where
 * n/d is to be computed in infinite precision.  In other
@@ -73,5 +74,6 @@ div(num, denom)
r.quot++;
r.rem -= denom;
}
+#endif
return (r);
 }

Modified: stable/10/lib/libc/stdlib/imaxdiv.c
==
--- stable/10/lib/libc/stdlib/imaxdiv.c Sun Jun  5 17:31:36 2016
(r301458)
+++ stable/10/lib/libc/stdlib/imaxdiv.c Sun Jun  5 18:11:52 2016
(r301459)
@@ -37,9 +37,11 @@ imaxdiv(intmax_t numer, intmax_t denom)
 
retval.quot = numer / denom;
retval.rem = numer % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
if (numer >= 0 && retval.rem < 0) {
retval.quot++;
retval.rem -= denom;
}
+#endif
return (retval);
 }

Modified: stable/10/lib/libc/stdlib/ldiv.c
==
--- stable/10/lib/libc/stdlib/ldiv.cSun Jun  5 17:31:36 2016
(r301458)
+++ stable/10/lib/libc/stdlib/ldiv.cSun Jun  5 18:11:52 2016
(r301459)
@@ -48,9 +48,11 @@ ldiv(num, denom)
 
r.quot = num / denom;
r.rem = num % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
if (num >= 0 && r.rem < 0) {
r.quot++;
r.rem -= denom;
}
+#endif
return (r);
 }

Modified: stable/10/lib/libc/stdlib/lldiv.c
==
--- stable/10/lib/libc/stdlib/lldiv.c   Sun Jun  5 17:31:36 2016
(r301458)
+++ stable/10/lib/libc/stdlib/lldiv.c   Sun Jun  5 18:11:52 2016
(r301459)
@@ -37,9 +37,11 @@ lldiv(long long numer, long long denom)
 
retval.quot = numer / denom;
retval.rem = numer % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
if (numer >= 0 && retval.rem < 0) {
retval.quot++;
retval.rem -= denom;
}
+#endif
return (retval);
 }
___
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: r302512 - in head/lib/libc: gen locale regex stdio

2016-07-09 Thread Andrey A. Chernov
Author: ache
Date: Sun Jul 10 03:49:38 2016
New Revision: 302512
URL: https://svnweb.freebsd.org/changeset/base/302512

Log:
  Remove broken support for collation in [a-z] type ranges.
  Only first 256 wide chars are considered currently, all other are just
  dropped from the range. Proper implementation require reverse tables
  database lookup, since objects are really big as max UTF-8 (1114112
  code points), so just the same scanning as it was for 256 chars will
  slow things down.
  
  POSIX does not require collation for [a-z] type ranges and does not
  prohibit it for non-POSIX locales. POSIX require collation for ranges
  only for POSIX (or C) locale which is equal to ASCII and binary for
  other chars, so we already have it.
  
  No other *BSD implements collation for [a-z] type ranges.
  
  Restore ABI compatibility with unused now __collate_range_cmp() which
  is visible from outside (will be removed later).

Modified:
  head/lib/libc/gen/fnmatch.c
  head/lib/libc/gen/glob.c
  head/lib/libc/locale/collate.h
  head/lib/libc/locale/collcmp.c
  head/lib/libc/regex/regcomp.c
  head/lib/libc/stdio/vfscanf.c

Modified: head/lib/libc/gen/fnmatch.c
==
--- head/lib/libc/gen/fnmatch.c Sun Jul 10 02:46:20 2016(r302511)
+++ head/lib/libc/gen/fnmatch.c Sun Jul 10 03:49:38 2016(r302512)
@@ -63,8 +63,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include "collate.h"
-
 #defineEOS '\0'
 
 #define RANGE_MATCH 1
@@ -238,8 +236,6 @@ rangematch(const char *pattern, wchar_t 
wchar_t c, c2;
size_t pclen;
const char *origpat;
-   struct xlocale_collate *table =
-   (struct 
xlocale_collate*)__get_locale()->components[XLC_COLLATE];
 
/*
 * A bracket expression starting with an unquoted circumflex
@@ -294,11 +290,7 @@ rangematch(const char *pattern, wchar_t 
if (flags & FNM_CASEFOLD)
c2 = towlower(c2);
 
-   if (table->__collate_load_error ?
-   c <= test && test <= c2 :
-  __wcollate_range_cmp(table, c, test) <= 0
-   && __wcollate_range_cmp(table, test, c2) <= 0
-  )
+   if (c <= test && test <= c2)
ok = 1;
} else if (c == test)
ok = 1;

Modified: head/lib/libc/gen/glob.c
==
--- head/lib/libc/gen/glob.cSun Jul 10 02:46:20 2016(r302511)
+++ head/lib/libc/gen/glob.cSun Jul 10 03:49:38 2016(r302512)
@@ -92,8 +92,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include "collate.h"
-
 /*
  * glob(3) expansion limits. Stop the expansion if any of these limits
  * is reached. This caps the runtime in the face of DoS attacks. See
@@ -804,8 +802,6 @@ match(Char *name, Char *pat, Char *paten
 {
int ok, negate_range;
Char c, k;
-   struct xlocale_collate *table =
-   (struct 
xlocale_collate*)__get_locale()->components[XLC_COLLATE];
 
while (pat < patend) {
c = *pat++;
@@ -830,11 +826,7 @@ match(Char *name, Char *pat, Char *paten
++pat;
while (((c = *pat++) & M_MASK) != M_END)
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
-  )
+   if (CHAR(c) <= CHAR(k) && CHAR(k) <= 
CHAR(pat[1]))
ok = 1;
pat += 2;
} else if (c == k)

Modified: head/lib/libc/locale/collate.h
==
--- head/lib/libc/locale/collate.h  Sun Jul 10 02:46:20 2016
(r302511)
+++ head/lib/libc/locale/collate.h  Sun Jul 10 03:49:38 2016
(r302512)
@@ -128,8 +128,7 @@ 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(int, int);
 size_t _collate_wxfrm(struct xlocale_collate *, const wchar_t *, wchar_t *,
size_t);
 size_t _collat

svn commit: r302594 - head/usr.bin/tr

2016-07-11 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 11 21:23:50 2016
New Revision: 302594
URL: https://svnweb.freebsd.org/changeset/base/302594

Log:
  1) Following r302512 (remove collation support for [a-z]-ranges in libc)
  remove collation support for a-z ranges here too.
  It was implemented for single byte locales only in any case.
  
  2) Reduce [Cc]flag loop to WCHAR_MAX, WINT_MAX here includes WEOF which is
  not a character.
  
  3) Optimize [Cc]flag case: don't repeatedly add the last character of
  string2 to squeeze cset when string2 reach its EOS state.
  
  4) Reflect in the manpage that [=equiv=] is implemented for single
  byte locales only.

Modified:
  head/usr.bin/tr/str.c
  head/usr.bin/tr/tr.1
  head/usr.bin/tr/tr.c

Modified: head/usr.bin/tr/str.c
==
--- head/usr.bin/tr/str.c   Mon Jul 11 20:15:46 2016(r302593)
+++ head/usr.bin/tr/str.c   Mon Jul 11 21:23:50 2016(r302594)
@@ -53,7 +53,7 @@ static int  backslash(STR *, int *);
 static int bracket(STR *);
 static voidgenclass(STR *);
 static voidgenequiv(STR *);
-static int  genrange(STR *, int);
+static int genrange(STR *);
 static voidgenseq(STR *);
 
 wint_t
@@ -93,7 +93,7 @@ next(STR *s)
}
 
/* We can start a range at any time. */
-   if (s->str[0] == '-' && genrange(s, is_octal))
+   if (s->str[0] == '-' && genrange(s))
return (next(s));
return (1);
case RANGE:
@@ -237,18 +237,16 @@ genequiv(STR *s)
 }
 
 static int
-genrange(STR *s, int was_octal)
+genrange(STR *s)
 {
-   int stopval, octal;
+   int stopval;
char *savestart;
-   int n, cnt, *p;
size_t clen;
wchar_t wc;
 
-   octal = 0;
savestart = s->str;
if (*++s->str == '\\')
-   stopval = backslash(s, &octal);
+   stopval = backslash(s, NULL);
else {
clen = mbrtowc(&wc, s->str, MB_LEN_MAX, NULL);
if (clen == (size_t)-1 || clen == (size_t)-2)
@@ -256,37 +254,13 @@ genrange(STR *s, int was_octal)
stopval = wc;
s->str += clen;
}
-   /*
-* XXX Characters are not ordered according to collating sequence in
-* multibyte locales.
-*/
-   if (octal || was_octal || MB_CUR_MAX > 1) {
-   if (stopval < s->lastch) {
-   s->str = savestart;
-   return (0);
-   }
-   s->cnt = stopval - s->lastch + 1;
-   s->state = RANGE;
-   --s->lastch;
-   return (1);
-   }
-   if (charcoll((const void *)&stopval, (const void *)&(s->lastch)) < 0) {
+   if (stopval < s->lastch) {
s->str = savestart;
return (0);
}
-   if ((s->set = p = malloc((NCHARS_SB + 1) * sizeof(int))) == NULL)
-   err(1, "genrange() malloc");
-   for (cnt = 0; cnt < NCHARS_SB; cnt++)
-   if (charcoll((const void *)&cnt, (const void *)&(s->lastch)) >= 
0 &&
-   charcoll((const void *)&cnt, (const void *)&stopval) <= 0)
-   *p++ = cnt;
-   *p = OOBCH;
-   n = p - s->set;
-
-   s->cnt = 0;
-   s->state = SET;
-   if (n > 1)
-   mergesort(s->set, n, sizeof(*(s->set)), charcoll);
+   s->cnt = stopval - s->lastch + 1;
+   s->state = RANGE;
+   --s->lastch;
return (1);
 }
 

Modified: head/usr.bin/tr/tr.1
==
--- head/usr.bin/tr/tr.1Mon Jul 11 20:15:46 2016(r302593)
+++ head/usr.bin/tr/tr.1Mon Jul 11 21:23:50 2016(r302594)
@@ -164,14 +164,6 @@ as defined by the collation sequence.
 If either or both of the range endpoints are octal sequences, it
 represents the range of specific coded values between the
 range endpoints, inclusive.
-.Pp
-.Bf Em
-See the
-.Sx COMPATIBILITY
-section below for an important note regarding
-differences in the way the current
-implementation interprets range expressions differently from
-previous implementations.
 .Ef
 .It [:class:]
 Represents all characters belonging to the defined character class.
@@ -307,22 +299,16 @@ Remove diacritical marks from all accent
 .Pp
 .Dl "tr \*q[=e=]\*q \*qe\*q"
 .Sh COMPATIBILITY
-Previous
 .Fx
 implementations of
 .Nm
 did not order characters in range expressions according to the current
-locale's collation order, making it possible to convert unaccented Latin
-characters (esp.\& as found in English text) from upper to lower case using
+locale's collation order, making it possible to convert accented Latin
+characters from upper to lower case using
 the traditional
 .Ux
 idiom of
 .Dq Li "tr A-Z a-z" .
-Since
-.Nm
-now obeys the locale's collation order, this idiom may not produce
-correct results when

svn commit: r302599 - head/usr.bin/tr

2016-07-11 Thread Andrey A. Chernov
Author: ache
Date: Mon Jul 11 23:06:11 2016
New Revision: 302599
URL: https://svnweb.freebsd.org/changeset/base/302599

Log:
  Cast WCHAR_MAX to wint_t, it can be unsigned on some systems.

Modified:
  head/usr.bin/tr/tr.c

Modified: head/usr.bin/tr/tr.c
==
--- head/usr.bin/tr/tr.cMon Jul 11 23:01:58 2016(r302598)
+++ head/usr.bin/tr/tr.cMon Jul 11 23:06:11 2016(r302599)
@@ -266,7 +266,7 @@ endloop:
 */
s2.str = argv[1];
s2.state = NORMAL;
-   for (cnt = 0; cnt <= WCHAR_MAX; cnt++) {
+   for (cnt = 0; cnt <= (wint_t)WCHAR_MAX; cnt++) {
if (Cflag && !iswrune(cnt))
continue;
if (cmap_lookup(map, cnt) == OOBCH) {
___
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: r302601 - in head/sys: arm/include arm64/include

2016-07-11 Thread Andrey A. Chernov
Author: ache
Date: Tue Jul 12 00:37:48 2016
New Revision: 302601
URL: https://svnweb.freebsd.org/changeset/base/302601

Log:
  I don't know why unsigned int is choosed for wchar_t here, but WCHAR_MAX
  should be <= WINT_MAX. It is bigger, __UINT_MAX > INT32_MAX

Modified:
  head/sys/arm/include/_types.h
  head/sys/arm64/include/_types.h

Modified: head/sys/arm/include/_types.h
==
--- head/sys/arm/include/_types.h   Mon Jul 11 23:15:54 2016
(r302600)
+++ head/sys/arm/include/_types.h   Tue Jul 12 00:37:48 2016
(r302601)
@@ -107,7 +107,7 @@ typedef __uint32_t  __vm_size_t;
 
 typedefunsigned int___wchar_t;
 #define__WCHAR_MIN 0   /* min value for a wchar_t */
-#define__WCHAR_MAX __UINT_MAX  /* max value for a wchar_t */
+#define__WCHAR_MAX __INT_MAX   /* max for a wchar_t <= 
WINT_MAX */
 
 /*
  * Unusual type definitions.

Modified: head/sys/arm64/include/_types.h
==
--- head/sys/arm64/include/_types.h Mon Jul 11 23:15:54 2016
(r302600)
+++ head/sys/arm64/include/_types.h Tue Jul 12 00:37:48 2016
(r302601)
@@ -95,7 +95,7 @@ typedef   __uint64_t  __vm_size_t;
 typedefunsigned int___wchar_t;
 
 #define__WCHAR_MIN 0   /* min value for a wchar_t */
-#define__WCHAR_MAX __UINT_MAX  /* max value for a wchar_t */
+#define__WCHAR_MAX __INT_MAX   /* max for a wchar_t <= 
WINT_MAX */
 
 /*
  * Unusual type definitions.
___
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   >