Rename stream2 method "gets" to "getline"

because FORTIFY re#defines gets, and this gets is something different.
This commit is contained in:
Olaf Seibert
2022-01-05 22:29:03 +01:00
parent a0add7154f
commit 8d7414d7c3
5 changed files with 34 additions and 37 deletions

View File

@@ -45,7 +45,7 @@ static int assemble(
int local; /* Whether a label is a local label or int local; /* Whether a label is a local label or
not */ not */
line = stack_gets(stack); line = stack_getline(stack);
if (line == NULL) if (line == NULL)
return -1; /* Return code for EOF. */ return -1; /* Return code for EOF. */
@@ -522,7 +522,7 @@ static int assemble(
cp += strcspn(cp, quote); cp += strcspn(cp, quote);
if (*cp == quote[0]) if (*cp == quote[0])
break; /* Found closing quote */ break; /* Found closing quote */
cp = stack_gets(stack); /* Read next input line */ cp = stack_getline(stack); /* Read next input line */
if (cp == NULL) if (cp == NULL)
break; /* EOF */ break; /* EOF */
} }
@@ -641,7 +641,7 @@ static int assemble(
for (;;) { for (;;) {
char *mlabel; char *mlabel;
maccp = macstr->vtbl->gets(macstr); maccp = macstr->vtbl->getline(macstr);
if (maccp == NULL) if (maccp == NULL)
break; break;
mlabel = get_symbol(maccp, &maccp, NULL); mlabel = get_symbol(maccp, &maccp, NULL);

View File

@@ -40,7 +40,7 @@ void macro_stream_delete(
} }
STREAM_VTBL macro_stream_vtbl = { STREAM_VTBL macro_stream_vtbl = {
macro_stream_delete, buffer_stream_gets, buffer_stream_rewind macro_stream_delete, buffer_stream_getline, buffer_stream_rewind
}; };
STREAM *new_macro_stream( STREAM *new_macro_stream(
@@ -85,7 +85,7 @@ void read_body(
char *nextline; char *nextline;
char *cp; char *cp;
nextline = stack_gets(stack); /* Now read the line */ nextline = stack_getline(stack); /* Now read the line */
if (nextline == NULL) { /* End of file. */ if (nextline == NULL) { /* End of file. */
report(stack->top, "Macro body of '%s' not closed\n", name); report(stack->top, "Macro body of '%s' not closed\n", name);
break; break;

View File

@@ -27,11 +27,11 @@ typedef struct rept_stream {
expansion */ expansion */
} REPT_STREAM; } REPT_STREAM;
/* rept_stream_gets gets a line from a repeat stream. At the end of /* rept_stream_getline gets a line from a repeat stream. At the end of
each count, the coutdown is decreated and the stream is reset to each count, the coutdown is decreated and the stream is reset to
its beginning. */ its beginning. */
char *rept_stream_gets( char *rept_stream_getline(
STREAM *str) STREAM *str)
{ {
REPT_STREAM *rstr = (REPT_STREAM *) str; REPT_STREAM *rstr = (REPT_STREAM *) str;
@@ -41,7 +41,7 @@ char *rept_stream_gets(
if (rstr->count <= 0) if (rstr->count <= 0)
return NULL; return NULL;
if ((cp = buffer_stream_gets(str)) != NULL) if ((cp = buffer_stream_getline(str)) != NULL)
return cp; return cp;
buffer_stream_rewind(str); buffer_stream_rewind(str);
@@ -64,7 +64,7 @@ void rept_stream_delete(
/* The VTBL */ /* The VTBL */
STREAM_VTBL rept_stream_vtbl = { STREAM_VTBL rept_stream_vtbl = {
rept_stream_delete, rept_stream_gets, buffer_stream_rewind rept_stream_delete, rept_stream_getline, buffer_stream_rewind
}; };
/* expand_rept is called when a .REPT is encountered in the input. */ /* expand_rept is called when a .REPT is encountered in the input. */
@@ -135,11 +135,11 @@ typedef struct irp_stream {
int savecond; /* Saved conditional level */ int savecond; /* Saved conditional level */
} IRP_STREAM; } IRP_STREAM;
/* irp_stream_gets expands the IRP as the stream is read. */ /* irp_stream_getline expands the IRP as the stream is read. */
/* Each time an iteration is exhausted, the next iteration is /* Each time an iteration is exhausted, the next iteration is
generated. */ generated. */
char *irp_stream_gets( char *irp_stream_getline(
STREAM *str) STREAM *str)
{ {
IRP_STREAM *istr = (IRP_STREAM *) str; IRP_STREAM *istr = (IRP_STREAM *) str;
@@ -148,7 +148,7 @@ char *irp_stream_gets(
ARG *arg; ARG *arg;
for (;;) { for (;;) {
if ((cp = buffer_stream_gets(str)) != NULL) if ((cp = buffer_stream_getline(str)) != NULL)
return cp; return cp;
cp = istr->items + istr->offset; cp = istr->items + istr->offset;
@@ -190,7 +190,7 @@ void irp_stream_delete(
} }
STREAM_VTBL irp_stream_vtbl = { STREAM_VTBL irp_stream_vtbl = {
irp_stream_delete, irp_stream_gets, buffer_stream_rewind irp_stream_delete, irp_stream_getline, buffer_stream_rewind
}; };
/* expand_irp is called when a .IRP is encountered in the input. */ /* expand_irp is called when a .IRP is encountered in the input. */
@@ -266,10 +266,10 @@ typedef struct irpc_stream {
int savecond; /* conditional stack at invocation */ int savecond; /* conditional stack at invocation */
} IRPC_STREAM; } IRPC_STREAM;
/* irpc_stream_gets - same comments apply as with irp_stream_gets, but /* irpc_stream_getline - same comments apply as with irp_stream_getline, but
the substitution is character-by-character */ the substitution is character-by-character */
char *irpc_stream_gets( char *irpc_stream_getline(
STREAM *str) STREAM *str)
{ {
IRPC_STREAM *istr = (IRPC_STREAM *) str; IRPC_STREAM *istr = (IRPC_STREAM *) str;
@@ -278,7 +278,7 @@ char *irpc_stream_gets(
ARG *arg; ARG *arg;
for (;;) { for (;;) {
if ((cp = buffer_stream_gets(str)) != NULL) if ((cp = buffer_stream_getline(str)) != NULL)
return cp; return cp;
cp = istr->items + istr->offset; cp = istr->items + istr->offset;
@@ -320,7 +320,7 @@ void irpc_stream_delete(
} }
STREAM_VTBL irpc_stream_vtbl = { STREAM_VTBL irpc_stream_vtbl = {
irpc_stream_delete, irpc_stream_gets, buffer_stream_rewind irpc_stream_delete, irpc_stream_getline, buffer_stream_rewind
}; };
/* expand_irpc - called when .IRPC is encountered in the input */ /* expand_irpc - called when .IRPC is encountered in the input */

View File

@@ -172,9 +172,9 @@ void stream_delete(
/* *** class BUFFER_STREAM implementation */ /* *** class BUFFER_STREAM implementation */
/* STREAM::gets for a buffer stream */ /* STREAM::getline for a buffer stream */
char *buffer_stream_gets( char *buffer_stream_getline(
STREAM *str) STREAM *str)
{ {
char *nl; char *nl;
@@ -228,7 +228,7 @@ void buffer_stream_rewind(
/* BUFFER_STREAM vtbl */ /* BUFFER_STREAM vtbl */
STREAM_VTBL buffer_stream_vtbl = { STREAM_VTBL buffer_stream_vtbl = {
buffer_stream_delete, buffer_stream_gets, buffer_stream_rewind buffer_stream_delete, buffer_stream_getline, buffer_stream_rewind
}; };
void buffer_stream_construct( void buffer_stream_construct(
@@ -271,9 +271,9 @@ STREAM *new_buffer_stream(
/* *** FILE_STREAM implementation */ /* *** FILE_STREAM implementation */
/* Implement STREAM::gets for a file stream */ /* Implement STREAM::getline for a file stream */
static char *file_gets( static char *file_getline(
STREAM *str) STREAM *str)
{ {
int i, int i,
@@ -332,7 +332,7 @@ void file_rewind(
} }
static STREAM_VTBL file_stream_vtbl = { static STREAM_VTBL file_stream_vtbl = {
file_destroy, file_gets, file_rewind file_destroy, file_getline, file_rewind
}; };
/* Prepare and open a stream from a file. */ /* Prepare and open a stream from a file. */
@@ -391,11 +391,11 @@ void stack_push(
stack->top = str; stack->top = str;
} }
/* stack_gets calls vtbl->gets for the topmost stack entry. When /* stack_getline calls vtbl->getline for the topmost stack entry. When
topmost streams indicate they're exhausted, they are popped and topmost streams indicate they're exhausted, they are popped and
deleted, until the stack is exhausted. */ deleted, until the stack is exhausted. */
char *stack_gets( char *stack_getline(
STACK *stack) STACK *stack)
{ {
char *line; char *line;
@@ -403,7 +403,7 @@ char *stack_gets(
if (stack->top == NULL) if (stack->top == NULL)
return NULL; return NULL;
while ((line = stack->top->vtbl->gets(stack->top)) == NULL) { while ((line = stack->top->vtbl->getline(stack->top)) == NULL) {
stack_pop(stack); stack_pop(stack);
if (stack->top == NULL) if (stack->top == NULL)
return NULL; return NULL;

View File

@@ -40,15 +40,12 @@ DAMAGE.
struct stream; struct stream;
typedef struct stream_vtbl { typedef struct stream_vtbl {
void ( void (*delete)(
*delete) ( struct stream *stream); /* Destructor */
struct stream * stream); /* Destructor */ char *(*getline)(
char *( struct stream *stream); /* "getline" function */
*gets) ( void (*rewind)(
struct stream * stream); /* "gets" function */ struct stream *stream); /* "rewind" function */
void (
*rewind) (
struct stream * stream); /* "rewind" function */
} STREAM_VTBL; } STREAM_VTBL;
typedef struct stream { typedef struct stream {
@@ -114,7 +111,7 @@ void buffer_stream_construct(
BUFFER_STREAM * bstr, BUFFER_STREAM * bstr,
BUFFER *buf, BUFFER *buf,
char *name); char *name);
char *buffer_stream_gets( char *buffer_stream_getline(
STREAM *str); STREAM *str);
void buffer_stream_delete( void buffer_stream_delete(
STREAM *str); STREAM *str);
@@ -131,7 +128,7 @@ void stack_push(
STREAM *str); STREAM *str);
void stack_pop( void stack_pop(
STACK *stack); STACK *stack);
char *stack_gets( char *stack_getline(
STACK *stack); STACK *stack);
#endif /* STREAM2_H */ #endif /* STREAM2_H */