| 954 | static int rescan_lineno; |
| 955 | |
| 956 | static char *copy_args(int *alen) |
| 957 | { |
| 958 | struct mstring *s = msnew(); |
| 959 | int depth = 0, len = 1, c; |
| 960 | char quote = 0; |
| 961 | int a_lineno = lineno; |
| 962 | char *a_line = dup_line(); |
| 963 | char *a_cptr = a_line + (cptr - line - 1); |
| 964 | |
| 965 | rescan_lineno = lineno; |
| 966 | while ((c = *cptr++) != ')' || depth || quote) { |
| 967 | if (c == ',' && !quote && !depth) { |
| 968 | len++; |
| 969 | mputc(s, 0); |
| 970 | continue; } |
| 971 | mputc(s, c); |
| 972 | if (c == '\n') { |
| 973 | get_line(); |
| 974 | if (!line) { |
| 975 | if (quote) |
| 976 | unterminated_string(a_lineno, a_line, a_cptr); |
| 977 | else |
| 978 | unterminated_arglist(a_lineno, a_line, a_cptr); } } |
| 979 | else if (quote) { |
| 980 | if (c == quote) quote = 0; |
| 981 | else if (c == '\\') { |
| 982 | if (*cptr != '\n') mputc(s, *cptr++); } } |
| 983 | else { |
| 984 | if (c == '(') depth++; |
| 985 | else if (c == ')') depth--; |
| 986 | else if (c == '\"' || c == '\'') quote = c; } } |
| 987 | if (alen) *alen = len; |
| 988 | FREE(a_line); |
| 989 | return msdone(s); |
| 990 | } |
| 991 | |
| 992 | static char *parse_id(char *p, char **save) |
| 993 | { |
no test coverage detected