Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
@@ -18,10 +18,11 @@
*
* CDDL HEADER END
*/
/*
+ * Copyright 2013 Garrett D'Amore <garrett@damore.org>
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
@@ -28,10 +29,13 @@
#include "lint.h"
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
+#include <locale.h>
+#include "lctype.h"
+#include "localeimpl.h"
/*
* strcasestr() locates the first occurrence in the string s1 of the
* sequence of characters (excluding the terminating null character)
* in the string s2, ignoring case. strcasestr() returns a pointer
@@ -38,13 +42,13 @@
* to the located string, or a null pointer if the string is not found.
* If s2 is empty, the function returns s1.
*/
char *
-strcasestr(const char *s1, const char *s2)
+strcasestr_l(const char *s1, const char *s2, locale_t loc)
{
- int *cm = __trans_lower;
+ const int *cm = loc->ctype->lc_trans_lower;
const uchar_t *us1 = (const uchar_t *)s1;
const uchar_t *us2 = (const uchar_t *)s2;
const uchar_t *tptr;
int c;
@@ -64,6 +68,12 @@
c = cm[*us2];
}
}
return (NULL);
+}
+
+char *
+strcasestr(const char *s1, const char *s2)
+{
+ return (strcasestr_l(s1, s2, uselocale(NULL)));
}