public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Ping: [RFA:] .error "msg" and .warning "msg" directives.
@ 2004-11-12 10:43 Hans-Peter Nilsson
  2004-11-15  3:48 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Hans-Peter Nilsson @ 2004-11-12 10:43 UTC (permalink / raw)
  To: binutils

Ping: <URL:http://sourceware.org/ml/binutils/2004-11/msg00064.html>.

Please don't be early-distracted by the quoted dejagnu error
message at the top: it has nothing to do with the actual changes
as such.  (It will happen for any dg-*-based testsuite.)

brgds, H-P

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ping: [RFA:] .error "msg" and .warning "msg" directives.
  2004-11-12 10:43 Ping: [RFA:] .error "msg" and .warning "msg" directives Hans-Peter Nilsson
@ 2004-11-15  3:48 ` Alan Modra
  2004-11-22 13:06   ` Hans-Peter Nilsson
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2004-11-15  3:48 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

On Fri, Nov 12, 2004 at 11:43:37AM +0100, Hans-Peter Nilsson wrote:
> Ping: <URL:http://sourceware.org/ml/binutils/2004-11/msg00064.html>.

> +   char *msg = err
> +     ? _(".error directive invoked in source file")
> +     : _(".warning directive invoked in source file");

No need to internationalize the directive (and parens needed before
err for proper formatting).

  char *msg = _("%s directive invoked in source file");
.
.
  if (err)
    as_bad (msg, ".error");
  else
    as_warn (msg, ".warning");

OK with that change.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Ping: [RFA:] .error "msg" and .warning "msg" directives.
  2004-11-15  3:48 ` Alan Modra
@ 2004-11-22 13:06   ` Hans-Peter Nilsson
  0 siblings, 0 replies; 3+ messages in thread
From: Hans-Peter Nilsson @ 2004-11-22 13:06 UTC (permalink / raw)
  To: binutils

> Date: Mon, 15 Nov 2004 14:18:49 +1030
> From: Alan Modra <amodra@bigpond.net.au>

> On Fri, Nov 12, 2004 at 11:43:37AM +0100, Hans-Peter Nilsson wrote:
> > Ping: <URL:http://sourceware.org/ml/binutils/2004-11/msg00064.html>.
> 
> > +   char *msg = err
> > +     ? _(".error directive invoked in source file")
> > +     : _(".warning directive invoked in source file");
> 
> No need to internationalize the directive (and parens needed before
> err for proper formatting).
> 
>   char *msg = _("%s directive invoked in source file");
> .
> .
>   if (err)
>     as_bad (msg, ".error");
>   else
>     as_warn (msg, ".warning");
> 
> OK with that change.

I had a brief conversation with Alan regarding:
- msg is normally set from the demand_copy_C_string call, so it
needs to be self-contained, assuming we want to avoid adding
arguments to as_bad and as_warn that aren't matched by the
format string.
- that implies that I missed adding a comment to point that out.
- I also missed that I should use "%s" as the format string,
else I introduce a security hole or at least a means to crash
gas by bad input.

This is the updated read.c part, the rest checked in as-was
(as-new pun elided).

Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.80
diff -p -c -r1.80 read.c
*** read.c	10 Nov 2004 03:28:44 -0000	1.80
--- read.c	22 Nov 2004 12:52:53 -0000
*************** static const pseudo_typeS potable[] = {
*** 306,311 ****
--- 306,312 ----
    {"equ", s_set, 0},
    {"equiv", s_set, 1},
    {"err", s_err, 0},
+   {"error", s_errwarn, 1},
    {"exitm", s_mexit, 0},
  /* extend  */
    {"extern", s_ignore, 0},	/* We treat all undef as ext.  */
*************** static const pseudo_typeS potable[] = {
*** 411,416 ****
--- 412,418 ----
    {"xdef", s_globl, 0},
    {"xref", s_ignore, 0},
    {"xstabs", s_xstab, 's'},
+   {"warning", s_errwarn, 0},
    {"word", cons, 2},
    {"zero", s_space, 0},
    {NULL, NULL, 0}			/* End sentinel.  */
*************** s_err (int ignore ATTRIBUTE_UNUSED)
*** 1665,1670 ****
--- 1667,1709 ----
    demand_empty_rest_of_line ();
  }
  
+ /* Handle the .error and .warning pseudo-ops.  */
+ 
+ void
+ s_errwarn (int err)
+ {
+   int len;
+   /* The purpose for the conditional assignment is not to
+      internationalize the directive itself, but that we need a
+      self-contained message, one that can be passed like the
+      demand_copy_C_string return value, and with no assumption on the
+      location of the name of the directive within the message.  */
+   char *msg
+     = (err ? _(".error directive invoked in source file")
+        : _(".warning directive invoked in source file"));
+ 
+   if (!is_it_end_of_statement ())
+     {
+       if (*input_line_pointer != '\"')
+ 	{
+ 	  as_bad (_("%s argument must be a string"),
+ 		  err ? ".error" : ".warning");
+ 	  discard_rest_of_line ();
+ 	  return;
+ 	}
+ 
+       msg = demand_copy_C_string (&len);
+       if (msg == NULL)
+ 	return;
+     }
+ 
+   if (err)
+     as_bad ("%s", msg);
+   else
+     as_warn ("%s", msg);
+   demand_empty_rest_of_line ();
+ }
+ 
  /* Handle the MRI fail pseudo-op.  */
  
  void

brgds, H-P

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-22 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-12 10:43 Ping: [RFA:] .error "msg" and .warning "msg" directives Hans-Peter Nilsson
2004-11-15  3:48 ` Alan Modra
2004-11-22 13:06   ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).