1 /* $Id: $ */
2 
3 /* Copyright (C) 1997 Sverre Hvammen Johansen and Terje Mjoes,
4  * Department of Informatics, University of Oslo.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #include "cim.h"
21 #include "limit.h"
22 
23 /******************************************************************************
24                                    TEXT CONCAT                               */
25 
26 __txtvp
__rconc(as,t1x,t2x)27 __rconc (as, t1x, t2x)
28      __txtvp t1x,
29        t2x;
30      long as;
31 {
32   long i,
33     j = 0,
34     length;
35   if (t1x->obj == __NULL && t2x->obj == __NULL)
36     {
37       __et.obj = __NULL;
38       __et.pos = __et.start = __et.length = 0;
39     }
40   else
41     {
42       __t1 = *t1x;
43       __t2 = *t2x;
44       __as = as;
45       length = (long) __t1.length + (long) __t2.length;
46       if (length >= MAX_TEXT_CHAR)
47 	__rerror ("Conc: Resulting text too long");
48       __et.obj = (__textref) __ralloc (((long) sizeof (__th) + length + 1));
49       /* En ekstra byte |nsker */
50       __et.obj->h.size = __et.length = length;	/* plass til
51 								 * '\0' */
52       __et.obj->h.konstant = __FALSE;
53       __et.obj->h.pp = (__pty) __TEXT;
54       __as = 0;
55       __et.pos = __et.start = 1;
56       for (i = __t1.start; i < (long) (__t1.start + __t1.length); i++)
57 	__et.obj->string[j++] = __t1.obj->string[i - 1];
58       for (i = __t2.start; i < (long) (__t2.start + __t2.length); i++)
59 	__et.obj->string[j++] = __t2.obj->string[i - 1];
60 
61       __et.obj->string[j++] = '\0';	/* Avslutter med \0 */
62       __t1.obj = __t2.obj = __NULL;
63     }
64   return (&__et);
65 }
66