Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
*** 18,27 ****
--- 18,28 ----
*
* 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,37 ****
--- 29,41 ----
#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,50 ****
* 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)
{
! int *cm = __trans_lower;
const uchar_t *us1 = (const uchar_t *)s1;
const uchar_t *us2 = (const uchar_t *)s2;
const uchar_t *tptr;
int c;
--- 42,54 ----
* to the located string, or a null pointer if the string is not found.
* If s2 is empty, the function returns s1.
*/
char *
! strcasestr_l(const char *s1, const char *s2, locale_t loc)
{
! 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,69 ****
--- 68,79 ----
c = cm[*us2];
}
}
return (NULL);
+ }
+
+ char *
+ strcasestr(const char *s1, const char *s2)
+ {
+ return (strcasestr_l(s1, s2, uselocale(NULL)));
}