This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch for gas to accept mri single quote strings


Hi!

The gas mri mode only supports double-quote strings. The patch below
changes this to also accept single-quote strings. For example:

	ascii 'Hello'

In the non-mri mode, this single quote string is enabled with
SINGLE_QUOTE_STRINGS #define (cf app.c). In the mri mode, the single
quote is not translated into a double quote and 'stringer' catches the
error. Recognizing single quotes in 'stringer/next_char_of_string' is
quite easy.

The patch also contains a new test for gas/mri to check double-quote
and single-quote strings.

I've verified this patch on m68k-elf and 68hc11 port.

Is it ok to integrate this patch?

Thanks,
	Stephane

gas/ChangeLog:

2000-03-19  Stephane Carrez  <stcarrez@worldnet.fr>

	* read.c (stringer): Supports strings starting with " or ' (MRI).
	(next_char_of_string): New parameter telling the string delimiter.
	(demand_copy_string): Pass '\"' as string delimiter.
	* read.h (next_char_of_string): New parameter string delimiter.
	* config/obj-elf.c (obj_elf_version): Pass '\"' as string delimiter
	for next_char_of_string.
	* config/obj-som.c (obj_som_compiler, obj_som_version,
	obj_som_copyright): Likewise.

gas/testsuite/ChangeLog:

2000-03-19  Stephane Carrez  <stcarrez@worldnet.fr>

	* gas/mri/mri.exp: Add new test mri ascii strings.
	* gas/mri/strings.s: New file.
	* gas/mri/strings.d: New file.
diff --exclude-from=binutils-exclude.lst -u -r --new-file --show-function-line=^[A-Za-z_] /src/gnu/cygnus/binutils/gas/config/obj-elf.c binutils/gas/config/obj-elf.c
--- /src/gnu/cygnus/binutils/gas/config/obj-elf.c	Sat Mar  4 11:28:15 2000
+++ binutils/gas/config/obj-elf.c	Sun Mar 19 12:12:31 2000
@@ -1280,7 +1280,7 @@ obj_elf_version (ignore)
       ++input_line_pointer;	/* -> 1st char of string. */
       name = input_line_pointer;
 
-      while (is_a_char (c = next_char_of_string ()))
+      while (is_a_char (c = next_char_of_string ('\"')))
 	;
       c = *input_line_pointer;
       *input_line_pointer = '\0';
diff --exclude-from=binutils-exclude.lst -u -r --new-file --show-function-line=^[A-Za-z_] /src/gnu/cygnus/binutils/gas/config/obj-som.c binutils/gas/config/obj-som.c
--- /src/gnu/cygnus/binutils/gas/config/obj-som.c	Thu Feb 24 20:22:08 2000
+++ binutils/gas/config/obj-som.c	Sun Mar 19 12:13:21 2000
@@ -68,7 +68,7 @@ obj_som_compiler (unused)
     {
       buf = input_line_pointer;
       ++input_line_pointer;
-      while (is_a_char (next_char_of_string ()))
+      while (is_a_char (next_char_of_string ('\"')))
 	;
       c = *input_line_pointer;
       *input_line_pointer = '\000';
@@ -138,7 +138,7 @@ obj_som_version (unused)
     {
       version = input_line_pointer;
       ++input_line_pointer;
-      while (is_a_char (next_char_of_string ()))
+      while (is_a_char (next_char_of_string ('\"')))
 	;
       c = *input_line_pointer;
       *input_line_pointer = '\000';
@@ -183,7 +183,7 @@ obj_som_copyright (unused)
     {
       copyright = input_line_pointer;
       ++input_line_pointer;
-      while (is_a_char (next_char_of_string ()))
+      while (is_a_char (next_char_of_string ('\"')))
 	;
       c = *input_line_pointer;
       *input_line_pointer = '\000';
diff --exclude-from=binutils-exclude.lst -u -r --new-file --show-function-line=^[A-Za-z_] /src/gnu/cygnus/binutils/gas/read.c binutils/gas/read.c
--- /src/gnu/cygnus/binutils/gas/read.c	Fri Mar 17 20:03:10 2000
+++ binutils/gas/read.c	Sun Mar 19 13:47:42 2000
@@ -4489,13 +4489,17 @@ stringer (append_zero)		/* Worker to do 
     }
   while (c == ',' || c == '<' || c == '"')
     {
+      char delim;
+      
       SKIP_WHITESPACE ();
       switch (*input_line_pointer)
 	{
+        case '\'':
 	case '\"':
+          delim = *input_line_pointer;
 	  ++input_line_pointer;	/*->1st char of string. */
 	  start = input_line_pointer;
-	  while (is_a_char (c = next_char_of_string ()))
+	  while (is_a_char (c = next_char_of_string (delim)))
 	    {
 	      FRAG_APPEND_1_CHAR (c);
 	    }
@@ -4553,15 +4557,18 @@ stringer (append_zero)		/* Worker to do 
     returning values bigger than 1 byte.  xoxorich. */
 
 unsigned int 
-next_char_of_string ()
+next_char_of_string (delim)
+     unsigned int delim;
 {
   register unsigned int c;
 
   c = *input_line_pointer++ & CHAR_MASK;
   switch (c)
     {
+    case '\'':
     case '\"':
-      c = NOT_A_CHAR;
+      if (c == delim)
+        c = NOT_A_CHAR;
       break;
 
     case '\n':
@@ -4788,7 +4795,7 @@ demand_copy_string (lenP)
     {
       input_line_pointer++;	/* Skip opening quote. */
 
-      while (is_a_char (c = next_char_of_string ()))
+      while (is_a_char (c = next_char_of_string ('\"')))
 	{
 	  obstack_1grow (&notes, c);
 	  len++;
diff --exclude-from=binutils-exclude.lst -u -r --new-file --show-function-line=^[A-Za-z_] /src/gnu/cygnus/binutils/gas/read.h binutils/gas/read.h
--- /src/gnu/cygnus/binutils/gas/read.h	Tue Feb 15 21:51:10 2000
+++ binutils/gas/read.h	Sun Mar 19 12:11:28 2000
@@ -93,7 +93,7 @@ extern char *demand_copy_C_string PARAMS
 extern char get_absolute_expression_and_terminator
   PARAMS ((long *val_pointer));
 extern offsetT get_absolute_expression PARAMS ((void));
-extern unsigned int next_char_of_string PARAMS ((void));
+extern unsigned int next_char_of_string PARAMS ((unsigned int delim));
 extern void s_mri_sect PARAMS ((char *));
 extern char *mri_comment_field PARAMS ((char *));
 extern void mri_comment_end PARAMS ((char *, int));
diff --exclude-from=binutils-exclude.lst -u -r --new-file --show-function-line=^[A-Za-z_] /src/gnu/cygnus/binutils/gas/testsuite/gas/mri/mri.exp binutils/gas/testsuite/gas/mri/mri.exp
--- /src/gnu/cygnus/binutils/gas/testsuite/gas/mri/mri.exp	Mon May  3 09:28:52 1999
+++ binutils/gas/testsuite/gas/mri/mri.exp	Sun Mar 19 14:17:42 2000
@@ -16,6 +16,7 @@ run_dump_test constants
 run_dump_test immconst
 run_dump_test float
 run_dump_test char
+run_dump_test strings
 run_dump_test expr
 run_dump_test common
 run_dump_test comment
diff --exclude-from=binutils-exclude.lst -u -r --new-file --show-function-line=^[A-Za-z_] /src/gnu/cygnus/binutils/gas/testsuite/gas/mri/strings.d binutils/gas/testsuite/gas/mri/strings.d
--- /src/gnu/cygnus/binutils/gas/testsuite/gas/mri/strings.d	Thu Jan  1 01:00:00 1970
+++ binutils/gas/testsuite/gas/mri/strings.d	Sun Mar 19 14:05:09 2000
@@ -0,0 +1,13 @@
+#objcopy: -O srec
+#name: MRI strings
+#as: -M
+
+# Test MRI strings constants
+
+S0.*
+S118000048656C6C6F48656C6C6F20576F726C642148272242E3.*
+S1180015796527224279650A080C0D090B000102030405060730.*
+S118002A08090A0A0A080C0D090B000102030405060708090A22.*
+S104003F0AB2.*
+S9030000FC.*
+
diff --exclude-from=binutils-exclude.lst -u -r --new-file --show-function-line=^[A-Za-z_] /src/gnu/cygnus/binutils/gas/testsuite/gas/mri/strings.s binutils/gas/testsuite/gas/mri/strings.s
--- /src/gnu/cygnus/binutils/gas/testsuite/gas/mri/strings.s	Thu Jan  1 01:00:00 1970
+++ binutils/gas/testsuite/gas/mri/strings.s	Sun Mar 19 14:07:45 2000
@@ -0,0 +1,7 @@
+	ascii "Hello"
+	ascii 'Hello World!'
+	ascii 'H\'\"'
+	ascii 'Bye\'\"'
+	ascii "Bye"
+	ascii "\n\b\f\r\t\v\0\1\2\3\4\5\6\7\8\9\xa\xA"
+	ascii '\n\b\f\r\t\v\0\1\2\3\4\5\6\7\8\9\xa\xA'

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]