-
Notifications
You must be signed in to change notification settings - Fork 256
/
Copy pathfchtak.c
47 lines (42 loc) · 1.03 KB
/
fchtak.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* $Id$ */
#include "kerngen/pilot.h"
/*> ROUTINE FCHTAK
CERN PROGLIB# FCHTAK .VERSION KERNFOR 4.31 911111
ORIG. 22/02/91, JZ
copy a Fortran character string
to allocated memory zero-terminated,
return the memory pointer
*/
#include <stdio.h>
#include <stdlib.h>
#include "kerngen/fortchar.h"
char *fchtak(ftext,lgtext)
#if defined(CERNLIB_QMCRY)
_fcd ftext;
#endif
#if !defined(CERNLIB_QMCRY)
char *ftext;
#endif
int lgtext;
{
/* char *malloc(); */
char *ptalc, *ptuse;
char *utext;
int nalc;
int ntx, jcol;
nalc = lgtext + 8;
ptalc = (char*)malloc (nalc);
if (ptalc == NULL) goto exit;
#if defined(CERNLIB_QMCRY)
utext = _fcdtocp(ftext);
#endif
#if !defined(CERNLIB_QMCRY)
utext = ftext;
#endif
ptuse = ptalc;
ntx = lgtext;
for (jcol = 0; jcol < ntx; jcol++) *ptuse++ = *utext++;
*ptuse = '\0';
exit: return ptalc;
}
/*> END <----------------------------------------------------------*/