1999-09-11 Donn Terry <donn@interix.com>
[deliverable/binutils-gdb.git] / gas / read.c
index abee749b5d503f4fa53b11f91345f4bc7d02f68d..886c028fdb395bc2c9f8b53dfd602a9b0184ef47 100644 (file)
@@ -89,6 +89,10 @@ die horribly;
 #define LEX_QM 0
 #endif
 
+#ifndef LEX_HASH
+#define LEX_HASH 0
+#endif
+
 #ifndef LEX_DOLLAR
 /* The a29k assembler does not permits labels to start with $.  */
 #define LEX_DOLLAR 3
@@ -104,7 +108,7 @@ char lex_type[256] =
 {
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,      /* @ABCDEFGHIJKLMNO */
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,      /* PQRSTUVWXYZ[\]^_ */
-  0, 0, 0, 0, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
+  0, 0, 0, LEX_HASH, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM, /* 0123456789:;<=>? */
   LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
@@ -208,7 +212,7 @@ static int dwarf_file_string;
 #endif
 
 static void cons_worker PARAMS ((int, int));
-static int scrub_from_string PARAMS ((char **));
+static int scrub_from_string PARAMS ((char *, int));
 static void do_align PARAMS ((int, char *, int, int));
 static void s_align PARAMS ((int, int));
 static void s_lcomm_internal PARAMS ((int, int));
@@ -415,7 +419,7 @@ static const pseudo_typeS potable[] =
   {"xstabs", s_xstab, 's'},
   {"word", cons, 2},
   {"zero", s_space, 0},
-  {NULL                      /* end sentinel */
+  {NULL, NULL, 0}                      /* end sentinel */
 };
 
 static int pop_override_ok = 0;
@@ -480,15 +484,18 @@ static char *scrub_string;
 static char *scrub_string_end;
 
 static int
-scrub_from_string (from)
-     char **from;
+scrub_from_string (buf, buflen)
+     char *buf;
+     int buflen;
 {
-  int size;
-
-  *from = scrub_string;
-  size = scrub_string_end - scrub_string;
-  scrub_string = scrub_string_end;
-  return size;
+  int copy;
+
+  copy = scrub_string_end - scrub_string;
+  if (copy > buflen)
+    copy = buflen;
+  memcpy (buf, scrub_string, copy);
+  scrub_string += copy;
+  return copy;
 }
 
 /*     read_a_source_file()
@@ -788,7 +795,7 @@ read_a_source_file (name)
                          mri_pending_align = 0;
                          if (line_label != NULL)
                            {
-                             line_label->sy_frag = frag_now;
+                             symbol_set_frag (line_label, frag_now);
                              S_SET_VALUE (line_label, frag_now_fix ());
                            }
                        }
@@ -823,6 +830,9 @@ read_a_source_file (name)
                  else
                    {
                      int inquote = 0;
+#ifdef QUOTES_IN_INSN
+                     int inescape = 0;
+#endif
 
                      /* WARNING: c has char, which may be end-of-line. */
                      /* Also: input_line_pointer->`\0` where c was. */
@@ -836,6 +846,14 @@ read_a_source_file (name)
                        {
                          if (flag_m68k_mri && *input_line_pointer == '\'')
                            inquote = ! inquote;
+#ifdef QUOTES_IN_INSN
+                         if (inescape)
+                           inescape = 0;
+                         else if (*input_line_pointer == '"')
+                           inquote = ! inquote;
+                         else if (*input_line_pointer == '\\')
+                           inescape = 1;
+#endif
                          input_line_pointer++;
                        }
 
@@ -869,7 +887,7 @@ read_a_source_file (name)
                          mri_pending_align = 0;
                          if (line_label != NULL)
                            {
-                             line_label->sy_frag = frag_now;
+                             symbol_set_frag (line_label, frag_now);
                              S_SET_VALUE (line_label, frag_now_fix ());
                            }
                        }
@@ -1129,7 +1147,7 @@ mri_comment_end (stop, stopc)
 
 void 
 s_abort (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   as_fatal (_(".abort detected.  Abandoning ship."));
 }
@@ -1155,21 +1173,7 @@ do_align (n, fill, len, max)
 
   if (fill == NULL)
     {
-      int maybe_text;
-
-#ifdef BFD_ASSEMBLER
-      if ((bfd_get_section_flags (stdoutput, now_seg) & SEC_CODE) != 0)
-       maybe_text = 1;
-      else
-       maybe_text = 0;
-#else
-      if (now_seg != data_section && now_seg != bss_section)
-       maybe_text = 1;
-      else
-       maybe_text = 0;
-#endif
-
-      if (maybe_text)
+      if (subseg_text_p (now_seg))
        default_fill = NOP_OPCODE;
       else
        default_fill = 0;
@@ -1333,7 +1337,7 @@ s_align_ptwo (arg)
 
 void 
 s_comm (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   register char *name;
   register char c;
@@ -1415,7 +1419,7 @@ s_comm (ignore)
 
 void
 s_mri_common (small)
-     int small;
+     int small ATTRIBUTE_UNUSED;
 {
   char *name;
   char c;
@@ -1489,10 +1493,12 @@ s_mri_common (small)
 
   if (line_label != NULL)
     {
-      line_label->sy_value.X_op = O_symbol;
-      line_label->sy_value.X_add_symbol = sym;
-      line_label->sy_value.X_add_number = S_GET_VALUE (sym);
-      line_label->sy_frag = &zero_address_frag;
+      expressionS exp;
+      exp.X_op = O_symbol;
+      exp.X_add_symbol = sym;
+      exp.X_add_number = 0;
+      symbol_set_value_expression (line_label, &exp);
+      symbol_set_frag (line_label, &zero_address_frag);
       S_SET_SEGMENT (line_label, expr_section);
     }
 
@@ -1512,7 +1518,7 @@ s_mri_common (small)
 
 void
 s_data (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   segT section;
   register int temp;
@@ -1586,7 +1592,7 @@ s_app_file (appfile)
 
 void
 s_app_line (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   int l;
 
@@ -1612,7 +1618,7 @@ s_app_line (ignore)
 
 void
 s_end (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   if (flag_mri)
     {
@@ -1630,7 +1636,7 @@ s_end (ignore)
 
 void
 s_err (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   as_bad (_(".err encountered"));
   demand_empty_rest_of_line ();
@@ -1640,7 +1646,7 @@ s_err (ignore)
 
 void
 s_fail (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   offsetT temp;
   char *stop = NULL;
@@ -1663,7 +1669,7 @@ s_fail (ignore)
 
 void 
 s_fill (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   expressionS rep_exp;
   long size = 1;
@@ -1760,7 +1766,7 @@ s_fill (ignore)
 
 void 
 s_globl (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *name;
   int c;
@@ -1776,9 +1782,11 @@ s_globl (ignore)
       name = input_line_pointer;
       c = get_symbol_end ();
       symbolP = symbol_find_or_make (name);
+      S_SET_EXTERNAL (symbolP);
+
       *input_line_pointer = c;
       SKIP_WHITESPACE ();
-      S_SET_EXTERNAL (symbolP);
+      c = *input_line_pointer;
       if (c == ',')
        {
          input_line_pointer++;
@@ -1833,7 +1841,7 @@ s_irp (irpc)
 
 void
 s_linkonce (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   enum linkonce_type type;
 
@@ -2064,9 +2072,9 @@ s_lcomm_internal (needs_align, bytes_p)
        frag_align (align, 0, 0);
                                        /* detach from old frag */
       if (S_GET_SEGMENT (symbolP) == bss_seg)
-       symbolP->sy_frag->fr_symbol = NULL;
+       symbol_get_frag (symbolP)->fr_symbol = NULL;
 
-      symbolP->sy_frag = frag_now;
+      symbol_set_frag (symbolP, frag_now);
       pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
                        (offsetT) temp, (char *) 0);
       *pfrag = 0;
@@ -2111,7 +2119,7 @@ void s_lcomm_bytes (needs_align)
 
 void 
 s_lsym (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   register char *name;
   register char c;
@@ -2233,7 +2241,7 @@ get_line_sb (line)
 
 void
 s_macro (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *file;
   unsigned int line;
@@ -2261,7 +2269,7 @@ s_macro (ignore)
        {
          S_SET_SEGMENT (line_label, undefined_section);
          S_SET_VALUE (line_label, 0);
-         line_label->sy_frag = &zero_address_frag;
+         symbol_set_frag (line_label, &zero_address_frag);
        }
 
       if (((flag_m68k_mri
@@ -2285,7 +2293,7 @@ s_macro (ignore)
 
 void
 s_mexit (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   cond_exit_macro (macro_nest);
   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
@@ -2295,7 +2303,7 @@ s_mexit (ignore)
 
 void
 s_mri (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   int on, old_flag;
 
@@ -2363,7 +2371,7 @@ do_org (segment, exp, fill)
 
 void 
 s_org (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   register segT segment;
   expressionS exp;
@@ -2419,7 +2427,7 @@ s_org (ignore)
 
 void
 s_mri_sect (type)
-     char *type;
+     char *type ATTRIBUTE_UNUSED;
 {
 #ifdef TC_M68K
 
@@ -2583,7 +2591,7 @@ s_mri_sect (type)
 
 void
 s_print (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *s;
   int len;
@@ -2597,7 +2605,7 @@ s_print (ignore)
 
 void
 s_purgem (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   if (is_it_end_of_statement ())
     {
@@ -2627,7 +2635,7 @@ s_purgem (ignore)
 
 void
 s_rept (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   int count;
   sb one;
@@ -2783,9 +2791,12 @@ s_space (mult)
              S_SET_VALUE (mri_common_symbol, val + 1);
              if (line_label != NULL)
                {
-                 know (line_label->sy_value.X_op == O_symbol);
-                 know (line_label->sy_value.X_add_symbol == mri_common_symbol);
-                 line_label->sy_value.X_add_number += 1;
+                 expressionS *symexp;
+
+                 symexp = symbol_get_value_expression (line_label);
+                 know (symexp->X_op == O_symbol);
+                 know (symexp->X_add_symbol == mri_common_symbol);
+                 symexp->X_add_number += 1;
                }
            }
        }
@@ -2794,7 +2805,7 @@ s_space (mult)
          do_align (1, (char *) NULL, 0, 0);
          if (line_label != NULL)
            {
-             line_label->sy_frag = frag_now;
+             symbol_set_frag (line_label, frag_now);
              S_SET_VALUE (line_label, frag_now_fix ());
            }
        }
@@ -2996,7 +3007,7 @@ s_float_space (float_type)
 
 void
 s_struct (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *stop = NULL;
   char stopc;
@@ -3012,7 +3023,7 @@ s_struct (ignore)
 
 void
 s_text (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   register int temp;
 
@@ -3114,7 +3125,8 @@ pseudo_set (symbolP)
           && (S_GET_SEGMENT (exp.X_add_symbol)
               == S_GET_SEGMENT (exp.X_op_symbol))
           && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
-          && exp.X_add_symbol->sy_frag == exp.X_op_symbol->sy_frag)
+          && (symbol_get_frag (exp.X_add_symbol)
+              == symbol_get_frag (exp.X_op_symbol)))
     {
       exp.X_op = O_constant;
       exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
@@ -3138,19 +3150,19 @@ pseudo_set (symbolP)
 #endif /* OBJ_AOUT or OBJ_BOUT */
       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
       if (exp.X_op != O_constant)
-        symbolP->sy_frag = &zero_address_frag;
+        symbol_set_frag (symbolP, &zero_address_frag);
       break;
 
     case O_register:
       S_SET_SEGMENT (symbolP, reg_section);
       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
-      symbolP->sy_frag = &zero_address_frag;
+      symbol_set_frag (symbolP, &zero_address_frag);
       break;
 
     case O_symbol:
       if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section
          || exp.X_add_number != 0)
-       symbolP->sy_value = exp;
+       symbol_set_value_expression (symbolP, &exp);
       else
        {
          symbolS *s = exp.X_add_symbol;
@@ -3164,7 +3176,7 @@ pseudo_set (symbolP)
 #endif /* OBJ_AOUT or OBJ_BOUT */
          S_SET_VALUE (symbolP,
                       exp.X_add_number + S_GET_VALUE (s));
-         symbolP->sy_frag = s->sy_frag;
+         symbol_set_frag (symbolP, symbol_get_frag (s));
          copy_symbol_attributes (symbolP, s);
        }
       break;
@@ -3172,7 +3184,7 @@ pseudo_set (symbolP)
     default:
       /* The value is some complex expression.
         FIXME: Should we set the segment to anything?  */
-      symbolP->sy_value = exp;
+      symbol_set_value_expression (symbolP, &exp);
       break;
     }
 }
@@ -3401,13 +3413,13 @@ emit_expr (exp, nbytes)
   /* Handle a negative bignum.  */
   if (op == O_uminus
       && exp->X_add_number == 0
-      && exp->X_add_symbol->sy_value.X_op == O_big
-      && exp->X_add_symbol->sy_value.X_add_number > 0)
+      && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big
+      && symbol_get_value_expression (exp->X_add_symbol)->X_add_number > 0)
     {
       int i;
       unsigned long carry;
 
-      exp = &exp->X_add_symbol->sy_value;
+      exp = symbol_get_value_expression (exp->X_add_symbol);
 
       /* Negate the bignum: one's complement each digit and add 1.  */
       carry = 1;
@@ -4396,7 +4408,7 @@ s_leb128 (sign)
 /*
  *                     stringer()
  *
- * We read 0 or more ',' seperated, double-quoted strings.
+ * We read 0 or more ',' separated, double-quoted strings.
  *
  * Caller should have checked need_pass_2 is FALSE because we don't check it.
  */
@@ -4820,7 +4832,7 @@ equals (sym_name, reassign)
 /* ARGSUSED */
 void 
 s_include (arg)
-     int arg;
+     int arg ATTRIBUTE_UNUSED;
 {
   char *newbuf;
   char *filename;
@@ -5042,7 +5054,7 @@ do_s_func (end_p, default_prefix)
 \f
 void 
 s_ignore (arg)
-     int arg;
+     int arg ATTRIBUTE_UNUSED;
 {
   while (!is_end_of_line[(unsigned char) *input_line_pointer])
     {
This page took 0.031499 seconds and 4 git commands to generate.