Minor optimization.

This commit is contained in:
Andrey A. Chernov 1995-02-18 11:36:33 +00:00
parent 590d3b8680
commit e96a21509f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=6544

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: strxfrm.c,v 1.2 1995/02/16 17:01:11 ache Exp $ * $Id: strxfrm.c,v 1.3 1995/02/18 01:39:00 ache Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
@ -49,13 +49,15 @@ strxfrm(dest, src, len)
} }
if (__collate_load_error) { if (__collate_load_error) {
size_t slen, ncopy; size_t slen = strlen(src);
slen = strlen(src); if (slen < len) {
ncopy = slen < len ? slen : len - 1; strcpy(d, src);
(void)memcpy(d, src, ncopy); return slen;
d[ncopy] = '\0'; }
return ncopy; strncpy(d, src, len - 1);
d[len - 1] = '\0';
return len - 1;
} }
ss = s = __collate_substitute(src); ss = s = __collate_substitute(src);