aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/sort
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2015-04-07 01:17:29 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2015-04-07 01:17:29 +0000
commitb904ab99bc3a9be6772d6af0d1bf97e625e93a4c (patch)
tree12d98ea0d216266172e44276683f31c93a8a9936 /usr.bin/sort
parent2df04ab49b50f582515659594fdf0d9806bf9d62 (diff)
Notes
Diffstat (limited to 'usr.bin/sort')
-rw-r--r--usr.bin/sort/bwstring.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/usr.bin/sort/bwstring.c b/usr.bin/sort/bwstring.c
index a4656b874137..fc30b56ae885 100644
--- a/usr.bin/sort/bwstring.c
+++ b/usr.bin/sort/bwstring.c
@@ -65,18 +65,12 @@ initialise_months(void)
for (int i = 0; i < 12; i++) {
cmonths[i] = NULL;
tmp = (unsigned char *) nl_langinfo(item[i]);
- if (tmp == NULL)
- continue;
if (debug_sort)
printf("month[%d]=%s\n", i, tmp);
- len = strlen((char*)tmp);
- if (len < 1)
+ if (*tmp == '\0')
continue;
- while (isblank(*tmp))
- ++tmp;
- m = sort_malloc(len + 1);
- memcpy(m, tmp, len + 1);
- m[len] = '\0';
+ m = sort_strdup(tmp);
+ len = strlen(tmp);
for (unsigned int j = 0; j < len; j++)
m[j] = toupper(m[j]);
cmonths[i] = m;
@@ -91,18 +85,17 @@ initialise_months(void)
for (int i = 0; i < 12; i++) {
wmonths[i] = NULL;
tmp = (unsigned char *) nl_langinfo(item[i]);
- if (tmp == NULL)
- continue;
if (debug_sort)
printf("month[%d]=%s\n", i, tmp);
- len = strlen((char*)tmp);
- if (len < 1)
+ if (*tmp == '\0')
continue;
- while (isblank(*tmp))
- ++tmp;
+ len = strlen(tmp);
m = sort_malloc(SIZEOF_WCHAR_STRING(len + 1));
- if (mbstowcs(m, (char*)tmp, len) == ((size_t) -1))
+ if (mbstowcs(m, (char*)tmp, len) ==
+ ((size_t) - 1)) {
+ sort_free(m);
continue;
+ }
m[len] = L'\0';
for (unsigned int j = 0; j < len; j++)
m[j] = towupper(m[j]);