summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/strxfrm.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-06-09 14:56:08 +0000
committerache <ache@FreeBSD.org>1996-06-09 14:56:08 +0000
commitec6853868b71426ea726e839f93e1cc8f3c5b761 (patch)
treeb328dc5a7b9ebe2656d1aaacc4c7a2a0c75a8664 /lib/libc/string/strxfrm.c
parent2fe7739b977266bf3a61a8078e5a5ffb70b3cc6d (diff)
downloadFreeBSD-src-ec6853868b71426ea726e839f93e1cc8f3c5b761.zip
FreeBSD-src-ec6853868b71426ea726e839f93e1cc8f3c5b761.tar.gz
Use better approximation if collate info not available.
Fix bug: strxfrm+strcmp != strcoll, if collate info not available
Diffstat (limited to 'lib/libc/string/strxfrm.c')
-rw-r--r--lib/libc/string/strxfrm.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c
index eb02c13..236c3ac 100644
--- a/lib/libc/string/strxfrm.c
+++ b/lib/libc/string/strxfrm.c
@@ -24,11 +24,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: strxfrm.c,v 1.3 1995/02/18 01:39:00 ache Exp $
+ * $Id: strxfrm.c,v 1.4 1995/02/18 11:36:33 ache Exp $
*/
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "collate.h"
size_t
@@ -50,14 +51,25 @@ strxfrm(dest, src, len)
if (__collate_load_error) {
size_t slen = strlen(src);
+ u_char *us;
- if (slen < len) {
+ if (slen < len)
strcpy(d, src);
- return slen;
+ else {
+ slen = len - 1;
+ strncpy(d, src, slen);
+ d[slen] = '\0';
}
- strncpy(d, src, len - 1);
- d[len - 1] = '\0';
- return len - 1;
+ for (us = d; *us; us++) {
+ if (isupper(*us)) {
+ if (tolower(*us) < *us)
+ *us = tolower(*us) - 1;
+ /* assume it not started from 0 */
+ else
+ *us = tolower(*us);
+ }
+ }
+ return slen;
}
ss = s = __collate_substitute(src);
OpenPOWER on IntegriCloud