* app.c (do_scrub_chars): In MRI mode, silently end quoted strings

at newline characters.  In MRI mode, always keep spaces in the
	operands field.  In MRI mode, treat a line comment character as a
	regular comment character following a space.
	* cond.c (ignore_input): Use strncasecmp rather than strncmp when
	looking for special pseudo-ops.
	* read.c (cons_worker): In MRI mode, the expressions stop at the
	first unquoted space.
	(equals): Likewise.
This commit is contained in:
Ian Lance Taylor 1995-09-07 01:17:16 +00:00
parent fca4042a3a
commit 86038ada17
4 changed files with 919 additions and 538 deletions

View File

@ -1,3 +1,28 @@
Wed Sep 6 21:13:06 1995 Ian Lance Taylor <ian@cygnus.com>
* app.c (do_scrub_chars): In MRI mode, silently end quoted strings
at newline characters. In MRI mode, always keep spaces in the
operands field. In MRI mode, treat a line comment character as a
regular comment character following a space.
* cond.c (ignore_input): Use strncasecmp rather than strncmp when
looking for special pseudo-ops.
* read.c (cons_worker): In MRI mode, the expressions stop at the
first unquoted space.
(equals): Likewise.
start-sanitize-sh3e
Wed Sep 6 15:03:53 1995 Jim Wilson <wilson@chestnut.cygnus.com>
* config/tc-sh.c (get_operands): Read third arg if it exists.
Otherwise, clear it.
(get_specific, case F_FR0): Add.
end-sanitize-sh3e
Wed Sep 6 15:03:53 1995 Jim Wilson <wilson@chestnut.cygnus.com>
* config/tc-sh.c (get_specific): Delete arg_to_test.
(md_assemble): Increase operand array from 2 to 3.
Tue Sep 5 16:47:36 1995 Stan Shebs <shebs@andros.cygnus.com>
* config/tc-mips.c: Remove CYGNUS LOCAL comments.

1210
gas/app.c

File diff suppressed because it is too large Load Diff

View File

@ -61,19 +61,23 @@ s_ifdef (arg)
{
as_bad ("invalid identifier for \".ifdef\"");
obstack_1grow (&cond_obstack, 0);
ignore_rest_of_line ();
}
else
{
get_symbol_end ();
++input_line_pointer;
char c;
c = get_symbol_end ();
symbolP = symbol_find (name);
*input_line_pointer = c;
initialize_cframe (&cframe);
cframe.ignoring = cframe.dead_tree || !((symbolP != 0) ^ arg);
current_cframe = (struct conditional_frame *) obstack_copy (&cond_obstack, &cframe, sizeof (cframe));
current_cframe = ((struct conditional_frame *)
obstack_copy (&cond_obstack, &cframe,
sizeof (cframe)));
demand_empty_rest_of_line ();
} /* if a valid identifyer name */
return;
} /* s_ifdef() */
void
@ -85,10 +89,19 @@ s_if (arg)
int t;
SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */
expression (&operand);
if (operand.X_op != O_constant)
as_bad ("non-constant expression in \".if\" statement");
if (current_cframe != NULL && current_cframe->ignoring)
{
operand.X_add_number = 0;
while (! is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
}
else
{
expression (&operand);
if (operand.X_op != O_constant)
as_bad ("non-constant expression in \".if\" statement");
}
switch ((operatorT) arg)
{
@ -108,7 +121,8 @@ s_if (arg)
cframe.ignoring = cframe.dead_tree || ! t;
current_cframe = ((struct conditional_frame *)
obstack_copy (&cond_obstack, &cframe, sizeof (cframe)));
return;
demand_empty_rest_of_line ();
} /* s_if() */
/* Get a string for the MRI IFC or IFNC pseudo-ops. */
@ -268,14 +282,16 @@ ignore_input ()
}
/* We cannot ignore certain pseudo ops. */
if ((s[0] == 'i'
&& (!strncmp (s, "if", 2)
|| !strncmp (s, "ifdef", 5)
|| !strncmp (s, "ifndef", 6)))
|| (s[0] == 'e'
&& (!strncmp (s, "else", 4)
|| !strncmp (s, "endif", 5)
|| !strncmp (s, "endc", 4))))
if (((s[0] == 'i'
|| s[0] == 'I')
&& (!strncasecmp (s, "if", 2)
|| !strncasecmp (s, "ifdef", 5)
|| !strncasecmp (s, "ifndef", 6)))
|| ((s[0] == 'e'
|| s[0] == 'E')
&& (!strncasecmp (s, "else", 4)
|| !strncasecmp (s, "endif", 5)
|| !strncasecmp (s, "endc", 4))))
return 0;
return (current_cframe != NULL) && (current_cframe->ignoring);

View File

@ -191,6 +191,7 @@ symbolS *mri_common_symbol;
may be needed. */
static int mri_pending_align;
static int scrub_from_string PARAMS ((char **));
static void do_align PARAMS ((int, char *));
static int hex_float PARAMS ((int, char *));
static void do_org PARAMS ((segT, expressionS *, int));
@ -330,6 +331,7 @@ static const pseudo_typeS potable[] =
/* print */
{"quad", cons, 8},
{"rept", s_rept, 0},
{"rva", s_rva, 4},
{"sbttl", listing_title, 1}, /* Subtitle of listing */
/* scl */
/* sect */
@ -425,6 +427,24 @@ pobegin ()
}
/* This function is used when scrubbing the characters between #APP
and #NO_APP. */
static char *scrub_string;
static char *scrub_string_end;
static int
scrub_from_string (from)
char **from;
{
int size;
*from = scrub_string;
size = scrub_string_end - scrub_string;
scrub_string = scrub_string_end;
return size;
}
/* read_a_source_file()
*
* We read the file, putting things into a web that
@ -810,7 +830,6 @@ read_a_source_file (name)
char *new_tmp;
unsigned int new_length;
char *tmp_buf = 0;
extern char *scrub_string, *scrub_last_string;
bump_line_counters ();
s = input_line_pointer;
@ -862,26 +881,30 @@ read_a_source_file (name)
{
input_line_pointer = ends + 8;
}
new_buf = xmalloc (100);
new_length = 100;
new_tmp = new_buf;
scrub_string = s;
scrub_last_string = ends;
scrub_string_end = ends;
new_length = ends - s;
new_buf = (char *) xmalloc (new_length);
new_tmp = new_buf;
for (;;)
{
int ch;
int space;
int size;
ch = do_scrub_next_char (scrub_from_string, scrub_to_string);
if (ch == EOF)
break;
*new_tmp++ = ch;
if (new_tmp == new_buf + new_length)
space = (new_buf + new_length) - new_tmp;
size = do_scrub_chars (scrub_from_string, new_tmp, space);
if (size < space)
{
new_buf = xrealloc (new_buf, new_length + 100);
new_tmp = new_buf + new_length;
new_length += 100;
new_tmp += size;
break;
}
new_buf = xrealloc (new_buf, new_length + 100);
new_tmp = new_buf + new_length;
new_length += 100;
}
if (tmp_buf)
@ -908,6 +931,7 @@ read_a_source_file (name)
if (old_buffer)
{
free (buffer);
bump_line_counters ();
if (old_input != 0)
{
@ -1224,11 +1248,11 @@ s_data (ignore)
}
/* Handle the .appfile pseudo-op. This is automatically generated by
do_scrub_next_char when a preprocessor # line comment is seen with
a file name. This default definition may be overridden by the
object or CPU specific pseudo-ops. This function is also the
default definition for .file; the APPFILE argument is 1 for
.appfile, 0 for .file. */
do_scrub_chars when a preprocessor # line comment is seen with a
file name. This default definition may be overridden by the object
or CPU specific pseudo-ops. This function is also the default
definition for .file; the APPFILE argument is 1 for .appfile, 0 for
.file. */
void
s_app_file (appfile)
@ -1256,9 +1280,9 @@ s_app_file (appfile)
}
/* Handle the .appline pseudo-op. This is automatically generated by
do_scrub_next_char when a preprocessor # line comment is seen.
This default definition may be overridden by the object or CPU
specific pseudo-ops. */
do_scrub_chars when a preprocessor # line comment is seen. This
default definition may be overridden by the object or CPU specific
pseudo-ops. */
void
s_app_line (ignore)
@ -2362,12 +2386,14 @@ parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes));
/* worker to do .byte etc statements */
/* clobbers input_line_pointer, checks */
/* end-of-line. */
void
cons (nbytes)
static void
cons_worker (nbytes, rva)
register int nbytes; /* 1=.byte, 2=.word, 4=.long */
int rva;
{
int c;
expressionS exp;
char *stop = NULL;
#ifdef md_flush_pending_output
md_flush_pending_output ();
@ -2379,17 +2405,54 @@ cons (nbytes)
return;
}
/* In MRI mode, the operands end at the first unquoted space. */
if (flag_mri)
{
char *s;
int inquote = 0;
for (s = input_line_pointer;
((! is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
|| inquote);
s++)
{
if (*s == '\'')
inquote = ! inquote;
}
stop = s;
}
c = 0;
do
{
if (rva)
{
/* If this is an .rva pseudoop then stick
an extra reloc in for this word. */
int reloc;
char *p = frag_more (0);
exp.X_op = O_absent;
#ifdef BFD_ASSEMBLER
reloc = BFD_RELOC_RVA;
#elif defined(TC_RVA_RELOC)
reloc = TC_RVA_RELOC;
#else
abort();
#endif
fix_new_exp (frag_now, p - frag_now->fr_literal,
nbytes, &exp, 0, reloc);
}
if (flag_mri)
parse_mri_cons (&exp, (unsigned int) nbytes);
else
TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
emit_expr (&exp, (unsigned int) nbytes);
emit_expr (&exp, (unsigned int) nbytes);
++c;
}
while (*input_line_pointer++ == ',');
while (*input_line_pointer++ == ','
&& (! flag_mri || input_line_pointer < stop));
/* In MRI mode, after an odd number of bytes, we must align to an
even word boundary, unless the next instruction is a dc.b, ds.b
@ -2398,9 +2461,33 @@ cons (nbytes)
mri_pending_align = 1;
input_line_pointer--; /* Put terminator back into stream. */
if (flag_mri)
{
input_line_pointer = stop;
while (! is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
}
demand_empty_rest_of_line ();
}
void
cons (size)
int size;
{
cons_worker (size, 0);
}
void
s_rva (size)
int size;
{
cons_worker (size, 1);
}
/* Put the contents of expression EXP into the object file using
NBYTES bytes. If need_pass_2 is 1, this does nothing. */
@ -2625,8 +2712,8 @@ emit_expr (exp, nbytes)
fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
/* @@ Should look at CPU word size. */
nbytes == 2 ? BFD_RELOC_16
: nbytes == 8 ? BFD_RELOC_64
: BFD_RELOC_32);
: nbytes == 8 ? BFD_RELOC_64
: BFD_RELOC_32);
#endif
#else
#ifdef TC_CONS_FIX_NEW
@ -3435,6 +3522,8 @@ equals (sym_name)
char *sym_name;
{
register symbolS *symbolP; /* symbol we are working with */
char *stop;
int stopc;
input_line_pointer++;
if (*input_line_pointer == '=')
@ -3443,6 +3532,25 @@ equals (sym_name)
while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
input_line_pointer++;
/* In MRI mode, the operands end at the first unquoted space. */
if (flag_mri)
{
char *s;
int inquote = 0;
for (s = input_line_pointer;
((! is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
|| inquote);
s++)
{
if (*s == '\'')
inquote = ! inquote;
}
stop = s;
stopc = *stop;
*stop = '\0';
}
if (sym_name[0] == '.' && sym_name[1] == '\0')
{
/* Turn '. = mumble' into a .org mumble */
@ -3458,6 +3566,14 @@ equals (sym_name)
symbolP = symbol_find_or_make (sym_name);
pseudo_set (symbolP);
}
if (flag_mri)
{
input_line_pointer = stop;
*stop = stopc;
while (! is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
}
} /* equals() */
/* .include -- include a file at this point. */