LoongArch: Commas inside double quotes
authorAlan Modra <amodra@gmail.com>
Thu, 28 Dec 2023 11:42:17 +0000 (22:12 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 30 Dec 2023 02:29:23 +0000 (12:59 +1030)
This adds an extra feature: Commas inside double quotes are not an
arg delimiter, and thus can be part of the arg.

* loongarch-coder.c (loongarch_split_args_by_comma): Commas
inside quotes are not arg delimiters.

opcodes/loongarch-coder.c

index b683527..c5b0950 100644 (file)
@@ -18,6 +18,7 @@
    along with this program; see the file COPYING3.  If not,
    see <http://www.gnu.org/licenses/>.  */
 #include "sysdep.h"
+#include <stdbool.h>
 #include "opcode/loongarch.h"
 
 int
@@ -256,9 +257,12 @@ loongarch_split_args_by_comma (char *args, const char *arg_strs[])
 
   if (*args)
     {
+      bool inquote = false;
       arg_strs[num++] = args;
       for (; *args; args++)
-       if (*args == ',')
+       if (*args == '"')
+         inquote = !inquote;
+       else if (*args == ',' && !inquote)
          {
            if (MAX_ARG_NUM_PLUS_2 - 1 == num)
              goto out;