changeset 918:9b2a0f9aedf1

remove function macro arguments' space
author kono
date Thu, 10 Apr 2014 20:11:31 +0900
parents 60451f9e0c6e
children 08dcc3b7c39b
files mc-macro.c
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mc-macro.c	Thu Apr 10 19:27:04 2014 +0900
+++ b/mc-macro.c	Thu Apr 10 20:11:31 2014 +0900
@@ -767,6 +767,22 @@
 //    it can be sepearted by \ or comments
 //    no expansion
 
+static char *
+skip_space(char *chptr, char **pchptr) {
+    int c;
+    for(;;) {
+        c = *chptr;
+	while (c=='\n') {
+            getline1();
+            chptr = *pchptr;
+	    c = *chptr;
+	}
+        if (c==' '||c=='\t') ++chptr;
+	else break;
+    }
+    return chptr;
+}
+
 static int
 macro_args(char **pchptr)
 {
@@ -778,6 +794,7 @@
     char *chptr = *pchptr;
     int args = glist3s(STRING,0,cheap->ptr);
     body = (char **)&scaddr(args);
+    chptr = skip_space(chptr, pchptr);
     for(;;) {
 	*cheap->ptr = c = *chptr++;
         cheap = increment_cheap(cheap,body);
@@ -826,7 +843,10 @@
             in_quote = 1;
         } if (plevel==0) {
             if (c==',') {
-                cheap->ptr[-1] = 0;
+		int rev = -1;
+		while((c = cheap->ptr[--rev])==' '|| c=='\t') ;
+                cheap->ptr[++rev] = 0;
+                chptr = skip_space(chptr, pchptr);
                 args = list3s(STRING,args,cheap->ptr);
                 body = (char **)&scaddr(args);
             } else if (c==')') {