diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 5a95e4f6a..56022aa72 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1,7 +1,7 @@ %option prefix="yy" %{ /* - * Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2015 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -532,6 +532,8 @@ keywords (include|define|undef|ifdef|ifndef|else|elseif|endif) } } +`` { if (istack->file != NULL) ECHO; } + \( { BEGIN(MA_ADD); macro_start_args(); } {W} {} @@ -568,8 +570,12 @@ keywords (include|define|undef|ifdef|ifndef|else|elseif|endif) "(" { macro_add_to_arg(0); ma_parenthesis_level++; } -"," { if (ma_parenthesis_level > 0) macro_add_to_arg(0); - else macro_finish_arg(); } +"," { + if (ma_parenthesis_level > 0) + macro_add_to_arg(0); + else + macro_finish_arg(); +} ")" { if (ma_parenthesis_level > 0) { @@ -1300,14 +1306,30 @@ static void macro_add_to_arg(int is_white_space) static void macro_finish_arg(void) { - char* tail = &def_buf[def_buf_size - def_buf_free]; + int offs; + char* head; + char* tail; check_for_max_args(); + offs = def_argo[def_argc-1] + def_argl[def_argc-1] + 1; + head = &def_buf[offs]; + tail = &def_buf[def_buf_size - def_buf_free]; + + /* Eat any leading and trailing white space. */ + if ((head < tail) && (*head == ' ')) { + offs++; + head++; + } + if ((tail > head) && (*(tail-1) == ' ')) { + def_buf_free++; + tail--; + } + *tail = 0; - def_argo[def_argc] = def_argo[def_argc-1] + def_argl[def_argc-1] + 1; - def_argl[def_argc] = tail - def_argv(def_argc); + def_argo[def_argc] = offs; + def_argl[def_argc] = tail - head; def_buf_free -= 1; def_argc++;