File: lref_parse.c

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,284 kB
  • sloc: ansic: 328,861; asm: 5,182; csh: 5,102; sh: 1,918; awk: 291; makefile: 69; sed: 13
file content (63 lines) | stat: -rw-r--r-- 1,768 bytes parent folder | download | duplicates (4)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/****************************************************************
 *								*
 *	Copyright 2001, 2007 Fidelity Information Services, Inc	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

#include "mdef.h"

#include "gtm_string.h"
#include "gtm_stdlib.h"

#include <rtnhdr.h>
#include "startup.h"
#include "gtm_startup.h"

/* parse an entry reference string into routine, label & offset */
void lref_parse(unsigned char *label_ref, mstr* routine, mstr* label, int* offset)
{
	unsigned char 	ch, *c, *c1;
	int 		i, label_len;
	error_def	(ERR_RUNPARAMERR);

	routine->addr = label->addr = (char *)label_ref;
	*offset = 0;
	label_len = STRLEN((const char *)label_ref);
	for (i = 0, c = label_ref;  i < label_len;  i++)
	{
		ch = *c++;
		if (ch == '^'  ||  ch == '+')
		{
			label->len = i;

			if (ch == '+')
			{
				*offset = (int)STRTOL((const char *)c, (char**)&c1, 10);
				if (c == c1 ||*c1 != '^')
					rts_error(VARLSTCNT(1) ERR_RUNPARAMERR);
				c = c1 + 1;
			}
			routine->addr = (char *)c;
			routine->len = INTCAST(label_ref + label_len - c);
			break;
		}
	}
	if (routine->addr == (char *)label_ref)
	{
		routine->len = label_len;
		routine->addr = (char *)label_ref;
		label->len = 0;
	}
	if (!is_ident(routine))
		rts_error(VARLSTCNT(1) ERR_RUNPARAMERR);
	if (label->len && !is_ident(label))
		rts_error(VARLSTCNT(1) ERR_RUNPARAMERR);

	routine->len = routine->len > MAX_MIDENT_LEN ? MAX_MIDENT_LEN : routine->len;
	label->len = label->len > MAX_MIDENT_LEN ? MAX_MIDENT_LEN : label->len;
}