1/* Implement string-related runtime actions for CHILL. 2 Copyright (C) 1992,1993 Free Software Foundation, Inc. 3 Author: Bill Cox 4 5This file is part of GNU CC. 6 7GNU CC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GNU CC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GNU CC; see the file COPYING. If not, write to 19the Free Software Foundation, 59 Temple Place - Suite 330, 20Boston, MA 02111-1307, USA. */ 21 22/* As a special exception, if you link this library with other files, 23 some of which are compiled with GCC, to produce an executable, 24 this library does not by itself cause the resulting executable 25 to be covered by the GNU General Public License. 26 This exception does not however invalidate any other reasons why 27 the executable file might be covered by the GNU General Public License. */ 28 29#define MIN(a, b) ((a) < (b) ? (a) : (b)) 30 31extern void cause_exception (char *exname, char *file, int lineno); 32 33/* 34 * function __concatstring 35 * 36 * parameters: 37 * OUT - pointer to output string 38 * S1 - pointer to left string 39 * LEN1 - length of left string 40 * S2 - pointer to right string 41 * LEN2 - length of right string 42 * 43 * returns: 44 * pointer to OUT string 45 * 46 * exceptions: 47 * none 48 * 49 * abstract: 50 * concatenates two character strings into the output string 51 * 52 */ 53 54char * 55__concatstring (out, s1, len1, s2, len2) 56 char *out, *s1; 57 int len1; 58 char *s2; 59 int len2; 60{ 61 if (out) 62 { 63 if (s2 /* Check for overlap between s2 and out. */ 64 && ((s2 >= out && s2 < (out + len1 + len2)) 65 || (s2 + len2 > out && s2 <= out + len1))) 66 { 67 char *tmp = alloca (len2); 68 memcpy (tmp, s2, len2); 69 s2 = tmp; 70 } 71 if (s1) 72 memmove (out, s1, len1); 73 if (s2) 74 memcpy (&out[len1], s2, len2); 75 } 76 return out; 77} 78