-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path306.c
74 lines (63 loc) · 2.04 KB
/
306.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* File - sub_306.c Created 09.03.2019 Last Modified 11.05.2020
*/
#include "stdio.h"
#include <stdlib.h>
#include <ctype.h>
#include "cgen.h"
/*********************************************************
* sub_306 v1 OK+ Used in: sub_6D1, sub_793, sub_B19,
* sub_E43, sub_17E0, sub_19C1,
* sub_4192
* get_token No code matching
*********************************************************/
char * sub_306() {
int ch, mark;
register char * ptr;
#ifdef DEBUG
printf("\tsub_306()");
#endif
mark = 0;
for(;;) {
ptr = buffer;
/* do {
if((ch = getchar()) == EOF) break;
} while((isspace(ch)) != 0);
if(ch == EOF) return (-1);
*/
do {
if((ch = getchar()) == EOF)
return (char *)EOF; /* Read characters until */
} while(isspace(ch) != 0); /* detection of white-space */
*(ptr++) = ch; /* Put character in buffer */
do {
*(ptr++) = ch = getchar();
if(ch == EOF) break; /* Get and put in buffer */
} while(isspace(ch) == 0); /* white-space character */
ptr += (-1); /* Put 0 in the place */
*ptr = 0; /* of the last character */
if(*buffer == '"') { /* If 1 character in buffer */
lineno = atoi(buffer+1); /* is '"' assign lineno value */
mark=(ch != '\n') ? 1 : 0; /* If detected newline set mark */
continue; /* Parse next line */
}
if (mark != 0) { /* If '\n' is not encountered */
/* copy program name to buffer */
strncpy(progname, buffer, sizeof(progname)-1);
mark = 0; /* clear mark and */
continue; /* parse next line */
}
if(*buffer != ';' /* If 1 or 2 character of */
|| *(buffer+1) != ';') { /* buffer contains ';' */
#ifdef DEBUG
printf("\t\tReturn \"%s\"\n", buffer);
#endif
return buffer; /* return buffer addr */
}
do {
ch = getchar(); /* Read and */
putchar(ch); /* print characters */
} while (ch != '\n'); /* not yet detected newline */
} /* Parse next line */
}
/* End of file sub_306.c */