1 |
/* |
/* |
2 |
* Copyright (c) 2002 Tama Communications Corporation |
* Copyright (c) 2002, 2004 Tama Communications Corporation |
3 |
* |
* |
4 |
* This file is part of GNU GLOBAL. |
* This file is part of GNU GLOBAL. |
5 |
* |
* |
145 |
* linetable_get: get a line from table. |
* linetable_get: get a line from table. |
146 |
* |
* |
147 |
* i) lineno line number of the line |
* i) lineno line number of the line |
148 |
|
* o) offset offset of the line |
149 |
|
* if offset == NULL, nothing returned. |
150 |
* r) line pointer |
* r) line pointer |
151 |
*/ |
*/ |
152 |
char * |
char * |
153 |
linetable_get(lineno) |
linetable_get(lineno, offset) |
154 |
int lineno; |
int lineno; |
155 |
|
int *offset; |
156 |
{ |
{ |
157 |
|
int addr; |
158 |
|
|
159 |
if (lineno-- <= 0) |
if (lineno-- <= 0) |
160 |
return NULL; |
return NULL; |
161 |
if (lineno > active_lines) |
if (lineno > active_lines) |
162 |
return NULL; |
return NULL; |
163 |
return filebuf + linetable[lineno]; |
addr = linetable[lineno]; |
164 |
|
if (offset) |
165 |
|
*offset = addr; |
166 |
|
return filebuf + addr; |
167 |
} |
} |
168 |
/* |
/* |
169 |
* linetable_close: close line table. |
* linetable_close: close line table. |
188 |
FILE *op; |
FILE *op; |
189 |
int lineno; |
int lineno; |
190 |
{ |
{ |
191 |
char *s = linetable_get(lineno); |
char *s = linetable_get(lineno, NULL); |
192 |
if (s == NULL) |
if (s == NULL) |
193 |
return; |
return; |
194 |
while (*s != '\n') |
while (*s != '\n') |