Skip to content

Commit b7f86c2

Browse files
committed
rs274: only allow a line starting with ";py," to go to convert_comment
Semicolon to indicate everything following ";" is to be ignored and treated as a comment until the end of the line was added via commit 2ea4151 15 years ago. 11 years ago commit 38abee6 allowed comments following a semicolon to be passed to convert_comment (interp_convert.cc) no matter where the semicolon appeared in the line. Per the commit notes: "rationale: enable ;py,<some executable Python command>" This causes unexpected behavior if more than one comment of each type (semicolon, and text appearing between "()") appeared on a line and they both had one of the allowable commands in the convert_comment function. Per the RS274 standard: "If more than one comment appears on a line, only the last one will be used; each of the other comments will be read and its format will be checked, but it will be ignored thereafter.". This commit brings the code back in line with the original intents of the aforementioned commits; ignore anything after a ";", and allow lines starting with ";py," to execute python code. It also more closely aligns to the RS274 standard.
1 parent d473941 commit b7f86c2

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/emc/rs274ngc/interp_read.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,20 +302,19 @@ int Interp::read_comment(char *line, //!< string: line of RS274 code being p
302302
return INTERP_OK;
303303
}
304304

305-
// A semicolon marks the beginning of a comment. The comment goes to
306-
// the end of the line.
305+
// With the exception of lines starting with ';py,',
306+
// Everything after a semicolon will be ignored/treated as a comment until the end of the line.
307307

308308
int Interp::read_semicolon(char *line, //!< string: line of RS274 code being processed
309309
int *counter, //!< pointer to a counter for position on the line
310310
block_pointer block, //!< pointer to a block being filled from the line
311311
double *parameters) //!< array of system parameters
312312
{
313-
char *s;
314313
CHKS((line[*counter] != ';'), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);
315314
(*counter) = strlen(line);
316-
// pass unmutilated line to convert_comment - FIXME access to _setup
317-
if (( s = strchr(_setup.linetext,';')) != NULL)
318-
CHP(convert_comment(s+1, false));
315+
// pass unmutilated line starting with ';py,' to convert_comment - FIXME access to _setup
316+
if (strncmp (_setup.linetext, ";py,", 4) == 0)
317+
CHP(convert_comment(_setup.linetext+1, false));
319318
return INTERP_OK;
320319
}
321320

0 commit comments

Comments
 (0)