svn commit: r238859 - projects/arm_eabi/usr.bin/sort

Andrew Turner andrew at FreeBSD.org
Sat Jul 28 07:42:31 UTC 2012


Author: andrew
Date: Sat Jul 28 07:42:30 2012
New Revision: 238859
URL: http://svn.freebsd.org/changeset/base/238859

Log:
  Allow sort to compile on ARM by fixing the wchar_t/wint_t type used

Modified:
  projects/arm_eabi/usr.bin/sort/bwstring.c
  projects/arm_eabi/usr.bin/sort/coll.c
  projects/arm_eabi/usr.bin/sort/coll.h
  projects/arm_eabi/usr.bin/sort/sort.h

Modified: projects/arm_eabi/usr.bin/sort/bwstring.c
==============================================================================
--- projects/arm_eabi/usr.bin/sort/bwstring.c	Sat Jul 28 07:28:08 2012	(r238858)
+++ projects/arm_eabi/usr.bin/sort/bwstring.c	Sat Jul 28 07:42:30 2012	(r238859)
@@ -479,7 +479,7 @@ bwsfwrite(struct bwstring *bws, FILE *f,
 struct bwstring *
 bwsfgetln(FILE *f, size_t *len, bool zero_ended, struct reader_buffer *rb)
 {
-	wchar_t eols;
+	wint_t eols;
 
 	eols = zero_ended ? btowc('\0') : btowc('\n');
 
@@ -494,7 +494,7 @@ bwsfgetln(FILE *f, size_t *len, bool zer
 			return (NULL);
 		}
 		if (*len > 0) {
-			if (ret[*len - 1] == eols)
+			if (ret[*len - 1] == (wchar_t)eols)
 				--(*len);
 		}
 		return (bwssbdup(ret, *len));
@@ -516,8 +516,6 @@ bwsfgetln(FILE *f, size_t *len, bool zer
 		return (bwscsbdup(ret, *len));
 
 	} else {
-		wchar_t c = 0;
-
 		*len = 0;
 
 		if (feof(f))
@@ -532,6 +530,8 @@ bwsfgetln(FILE *f, size_t *len, bool zer
 
 		if (MB_CUR_MAX == 1)
 			while (!feof(f)) {
+				int c;
+
 				c = fgetc(f);
 
 				if (c == EOF) {
@@ -553,6 +553,8 @@ bwsfgetln(FILE *f, size_t *len, bool zer
 			}
 		else
 			while (!feof(f)) {
+				wint_t c = 0;
+
 				c = fgetwc(f);
 
 				if (c == WEOF) {

Modified: projects/arm_eabi/usr.bin/sort/coll.c
==============================================================================
--- projects/arm_eabi/usr.bin/sort/coll.c	Sat Jul 28 07:28:08 2012	(r238858)
+++ projects/arm_eabi/usr.bin/sort/coll.c	Sat Jul 28 07:42:30 2012	(r238859)
@@ -47,11 +47,11 @@ __FBSDID("$FreeBSD$");
 struct key_specs *keys;
 size_t keys_num = 0;
 
-wchar_t symbol_decimal_point = L'.';
+wint_t symbol_decimal_point = L'.';
 /* there is no default thousands separator in collate rules: */
-wchar_t symbol_thousands_sep = 0;
-wchar_t symbol_negative_sign = L'-';
-wchar_t symbol_positive_sign = L'+';
+wint_t symbol_thousands_sep = 0;
+wint_t symbol_negative_sign = L'-';
+wint_t symbol_positive_sign = L'+';
 
 static int wstrcoll(struct key_value *kv1, struct key_value *kv2, size_t offset);
 static int gnumcoll(struct key_value*, struct key_value *, size_t offset);
@@ -277,7 +277,7 @@ skip_fields_to_start(const struct bwstri
 		size_t cpos = 0;
 
 		while (cpos < BWSLEN(s)) {
-			if (BWS_GET(s,cpos) == sort_opts_vals.field_sep) {
+			if (BWS_GET(s,cpos) == (wchar_t)sort_opts_vals.field_sep) {
 				--fields;
 				if (fields <= 1)
 					return (cpos + 1);
@@ -328,7 +328,7 @@ find_field_end(const struct bwstring *s,
 			next_field_start = skip_fields_to_start(s, f2 + 1,
 			    &empty_field);
 			if ((next_field_start > 0) && sort_opts_vals.tflag &&
-			    (sort_opts_vals.field_sep == BWS_GET(s,
+			    ((wchar_t)sort_opts_vals.field_sep == BWS_GET(s,
 			    next_field_start - 1)))
 				--next_field_start;
 		} else
@@ -711,7 +711,7 @@ read_number(struct bwstring *s0, int *si
 	while (iswblank(bws_get_iter_value(s)))
 		s = bws_iterator_inc(s, 1);
 
-	if (bws_get_iter_value(s) == symbol_negative_sign) {
+	if (bws_get_iter_value(s) == (wchar_t)symbol_negative_sign) {
 		*sign = -1;
 		s = bws_iterator_inc(s, 1);
 	}
@@ -727,7 +727,7 @@ read_number(struct bwstring *s0, int *si
 			s = bws_iterator_inc(s, 1);
 			*main_len += 1;
 		} else if (symbol_thousands_sep &&
-		    (bws_get_iter_value(s) == symbol_thousands_sep))
+		    (bws_get_iter_value(s) == (wchar_t)symbol_thousands_sep))
 			s = bws_iterator_inc(s, 1);
 		else
 			break;
@@ -735,7 +735,7 @@ read_number(struct bwstring *s0, int *si
 
 	smain[*main_len] = 0;
 
-	if (bws_get_iter_value(s) == symbol_decimal_point) {
+	if (bws_get_iter_value(s) == (wchar_t)symbol_decimal_point) {
 		s = bws_iterator_inc(s, 1);
 		while (iswdigit(bws_get_iter_value(s)) &&
 		    *frac_len < MAX_NUM_SIZE) {

Modified: projects/arm_eabi/usr.bin/sort/coll.h
==============================================================================
--- projects/arm_eabi/usr.bin/sort/coll.h	Sat Jul 28 07:28:08 2012	(r238858)
+++ projects/arm_eabi/usr.bin/sort/coll.h	Sat Jul 28 07:42:30 2012	(r238859)
@@ -133,12 +133,12 @@ extern struct key_specs *keys;
 extern size_t keys_num;
 
 /*
- * Main localised symbols
+ * Main localised symbols. These must be wint_t as they may hold WEOF.
  */
-extern wchar_t symbol_decimal_point;
-extern wchar_t symbol_thousands_sep;
-extern wchar_t symbol_negative_sign;
-extern wchar_t symbol_positive_sign;
+extern wint_t symbol_decimal_point;
+extern wint_t symbol_thousands_sep;
+extern wint_t symbol_negative_sign;
+extern wint_t symbol_positive_sign;
 
 /* funcs */
 

Modified: projects/arm_eabi/usr.bin/sort/sort.h
==============================================================================
--- projects/arm_eabi/usr.bin/sort/sort.h	Sat Jul 28 07:28:08 2012	(r238858)
+++ projects/arm_eabi/usr.bin/sort/sort.h	Sat Jul 28 07:42:30 2012	(r238859)
@@ -77,7 +77,7 @@ extern MD5_CTX md5_ctx;
  */
 struct sort_opts
 {
-	wchar_t		field_sep;
+	wint_t		field_sep;
 	int		sort_method;
 	bool		cflag;
 	bool		csilentflag;


More information about the svn-src-projects mailing list