mirror of
				https://github.com/espressif/binutils-gdb.git
				synced 2025-11-04 06:37:06 +08:00 
			
		
		
		
	gas: fold do_repeat{,_with_expander}()
do_repeat_with_expander() already deals with the "no expander" case quite fine, so there's really little point having two functions. What it lacks compared with do_repeat() is a call to sb_build(), which can simply be moved (and the then redundant sb_new() be avoided). Along with this moving also flip if the main if()'s condition such that the "no expander" case is handled first.
This commit is contained in:
		gas
@ -566,7 +566,7 @@ rx_rept (int ignore ATTRIBUTE_UNUSED)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  size_t count = get_absolute_expression ();
 | 
					  size_t count = get_absolute_expression ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  do_repeat_with_expander (count, "MREPEAT", "ENDR", "..MACREP");
 | 
					  do_repeat (count, "MREPEAT", "ENDR", "..MACREP");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Like cons() accept that strings are allowed.  */
 | 
					/* Like cons() accept that strings are allowed.  */
 | 
				
			||||||
 | 
				
			|||||||
@ -2034,7 +2034,7 @@ tic54x_loop (int count)
 | 
				
			|||||||
  if (!is_end_of_line[(unsigned char) *input_line_pointer])
 | 
					  if (!is_end_of_line[(unsigned char) *input_line_pointer])
 | 
				
			||||||
    count = get_absolute_expression ();
 | 
					    count = get_absolute_expression ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  do_repeat ((size_t) count, "LOOP", "ENDLOOP");
 | 
					  do_repeat ((size_t) count, "LOOP", "ENDLOOP", NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Normally, endloop gets eaten by the preceding loop.  */
 | 
					/* Normally, endloop gets eaten by the preceding loop.  */
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										56
									
								
								gas/read.c
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										56
									
								
								gas/read.c
									
									
									
									
									
								
							@ -3094,49 +3094,16 @@ s_rept (int ignore ATTRIBUTE_UNUSED)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  count = (size_t) get_absolute_expression ();
 | 
					  count = (size_t) get_absolute_expression ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  do_repeat (count, "REPT", "ENDR");
 | 
					  do_repeat (count, "REPT", "ENDR", NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* This function provides a generic repeat block implementation.   It allows
 | 
					/* This function provides a generic repeat block implementation.   It allows
 | 
				
			||||||
   different directives to be used as the start/end keys.  */
 | 
					   different directives to be used as the start/end keys.  Any text matching
 | 
				
			||||||
 | 
					   the optional EXPANDER in the block is replaced by the remaining iteration
 | 
				
			||||||
 | 
					   count.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
do_repeat (size_t count, const char *start, const char *end)
 | 
					do_repeat (size_t count, const char *start, const char *end,
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  sb one;
 | 
					 | 
				
			||||||
  sb many;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (((ssize_t) count) < 0)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      as_bad (_("negative count for %s - ignored"), start);
 | 
					 | 
				
			||||||
      count = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  sb_new (&one);
 | 
					 | 
				
			||||||
  if (!buffer_and_nest (start, end, &one, get_non_macro_line_sb))
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      as_bad (_("%s without %s"), start, end);
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  sb_build (&many, count * one.len);
 | 
					 | 
				
			||||||
  while (count-- > 0)
 | 
					 | 
				
			||||||
    sb_add_sb (&many, &one);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  sb_kill (&one);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  input_scrub_include_sb (&many, input_line_pointer, expanding_repeat);
 | 
					 | 
				
			||||||
  sb_kill (&many);
 | 
					 | 
				
			||||||
  buffer_limit = input_scrub_next_buffer (&input_line_pointer);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Like do_repeat except that any text matching EXPANDER in the
 | 
					 | 
				
			||||||
   block is replaced by the iteration count.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
do_repeat_with_expander (size_t count,
 | 
					 | 
				
			||||||
			 const char * start,
 | 
					 | 
				
			||||||
			 const char * end,
 | 
					 | 
				
			||||||
	   const char *expander)
 | 
						   const char *expander)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  sb one;
 | 
					  sb one;
 | 
				
			||||||
@ -3155,10 +3122,16 @@ do_repeat_with_expander (size_t count,
 | 
				
			|||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (expander == NULL || strstr (one.ptr, expander) == NULL)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      sb_build (&many, count * one.len);
 | 
				
			||||||
 | 
					      while (count-- > 0)
 | 
				
			||||||
 | 
						sb_add_sb (&many, &one);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
      sb_new (&many);
 | 
					      sb_new (&many);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (expander != NULL && strstr (one.ptr, expander) != NULL)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      while (count -- > 0)
 | 
					      while (count -- > 0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  int len;
 | 
						  int len;
 | 
				
			||||||
@ -3177,9 +3150,6 @@ do_repeat_with_expander (size_t count,
 | 
				
			|||||||
	  sb_kill (& processed);
 | 
						  sb_kill (& processed);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    while (count-- > 0)
 | 
					 | 
				
			||||||
      sb_add_sb (&many, &one);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sb_kill (&one);
 | 
					  sb_kill (&one);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -148,8 +148,7 @@ extern void stabs_generate_asm_file (void);
 | 
				
			|||||||
extern void stabs_generate_asm_lineno (void);
 | 
					extern void stabs_generate_asm_lineno (void);
 | 
				
			||||||
extern void stabs_generate_asm_func (const char *, const char *);
 | 
					extern void stabs_generate_asm_func (const char *, const char *);
 | 
				
			||||||
extern void stabs_generate_asm_endfunc (const char *, const char *);
 | 
					extern void stabs_generate_asm_endfunc (const char *, const char *);
 | 
				
			||||||
extern void do_repeat (size_t, const char *, const char *);
 | 
					extern void do_repeat (size_t, const char *, const char *, const char *);
 | 
				
			||||||
extern void do_repeat_with_expander (size_t, const char *, const char *, const char *);
 | 
					 | 
				
			||||||
extern void end_repeat (int);
 | 
					extern void end_repeat (int);
 | 
				
			||||||
extern void do_parse_cons_expression (expressionS *, int);
 | 
					extern void do_parse_cons_expression (expressionS *, int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user