88import abc
99import ast
1010import atexit
11- import clinic
1211import collections
1312import contextlib
1413import functools
@@ -898,13 +897,21 @@ def parse_verbatim_block(self):
898897 def parse_clinic_block (self , dsl_name ):
899898 input_add , input_output = text_accumulator ()
900899 self .block_start_line_number = self .line_number + 1
901- stop_line = self .language .stop_line .format (dsl_name = dsl_name ) + ' \n '
900+ stop_line = self .language .stop_line .format (dsl_name = dsl_name )
902901 body_prefix = self .language .body_prefix .format (dsl_name = dsl_name )
903902
903+ def is_stop_line (line ):
904+ # make sure to recognize stop line even if it
905+ # doesn't end with EOL (it could be the very end of the file)
906+ if not line .startswith (stop_line ):
907+ return False
908+ remainder = line [len (stop_line ):]
909+ return (not remainder ) or remainder .isspace ()
910+
904911 # consume body of program
905912 while self .input :
906913 line = self ._line ()
907- if line == stop_line or self .is_start_line (line ):
914+ if is_stop_line ( line ) or self .is_start_line (line ):
908915 break
909916 if body_prefix :
910917 line = line .lstrip ()
@@ -1396,7 +1403,8 @@ def render(self, parameter, data):
13961403 data is a CRenderData instance.
13971404 """
13981405 self .parameter = parameter
1399- name = ensure_legal_c_identifier (self .name )
1406+ original_name = self .name
1407+ name = ensure_legal_c_identifier (original_name )
14001408
14011409 # declarations
14021410 d = self .declaration ()
@@ -1414,7 +1422,7 @@ def render(self, parameter, data):
14141422 data .impl_arguments .append (self .length_name ())
14151423
14161424 # keywords
1417- data .keywords .append (name )
1425+ data .keywords .append (original_name )
14181426
14191427 # format_units
14201428 if self .is_optional () and '|' not in data .format_units :
0 commit comments