1439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin/*
2439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * The authors of this software are Rob Pike and Ken Thompson.
3439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin *              Copyright (c) 2002 by Lucent Technologies.
4439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * Permission to use, copy, modify, and distribute this software for any
5439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * purpose without fee is hereby granted, provided that this entire notice
6439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * is included in all copies of any software which is or includes a copy
7439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * or modification of this software and in all copies of the supporting
8439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * documentation for such software.
9439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
1096039b7897bb8b5853e91404d97abca72d933c69Alexander Gutkin * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
1196039b7897bb8b5853e91404d97abca72d933c69Alexander Gutkin * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
12439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
13439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin */
14439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin#include <stdarg.h>
15439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin#include <string.h>
16439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin#include "utf.h"
1796039b7897bb8b5853e91404d97abca72d933c69Alexander Gutkin#include "utfdef.h"
18439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin
19439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander GutkinRune*
2096039b7897bb8b5853e91404d97abca72d933c69Alexander Gutkinrunestrncat(Rune *s1, const Rune *s2, long n)
21439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin{
22439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin	Rune *os1;
23439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin
24439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin	os1 = s1;
2596039b7897bb8b5853e91404d97abca72d933c69Alexander Gutkin	s1 = (Rune*)runestrchr(s1, 0);
2696039b7897bb8b5853e91404d97abca72d933c69Alexander Gutkin	while((*s1++ = *s2++) != 0)
27439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin		if(--n < 0) {
28439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin			s1[-1] = 0;
29439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin			break;
30439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin		}
31439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin	return os1;
32439f3d1f87279a8be383ee01ef98cb9a5ca68573Alexander Gutkin}
33