The fix is a one liner in routine "input_entry" in file "representation.py":
definput_entry(text_file,allow_quotes,end_all=(),end_not_quoted=(',',)):word,blanks='',''# skip leading spaces and line feeds and NUL. c=text_skip(text_file,ascii_white)ifcinend_all+end_not_quoted:return''quoted=(c=='"'andallow_quotes)ifquoted:text_file.read_chars(1)whileTrue:# read entryiftext_file.end_of_file():breakc=''.join(text_file.read_chars(1))ifcinend_allor(cinend_not_quotedandnotquoted):# on KYBD: text file, this will do nothing - comma is swallowedtext_file.seek(-len(c),1)breakelifc=='"'andquoted:quoted=False# ignore blanks after the quotesc=text_skip(text_file,ascii_white)breakelifcinascii_whiteandnotquoted:blanks+=celse:word+=blanks+cblanks=''# WJB - clear blanks after reading a non-blank characteriflen(word)+len(blanks)>=255:text_file.seek(-len(c),1)breakreturnword
2. Error reading numeric value on one line, followed by text string on the next.
The numeric value is followed by <space><cr><lf>. The existing code just skips the trailing space, leaving the file pointer at the end of line. So the following text input just reads an empty string. It is necessary to skip all trailing white space and possibly one end of line after reading a value. The fix is in routine "input_vars_file", again in "representation.py":
definput_vars_file(readvar,text_file):forvinreadvar:typechar=v[0][-1]iftypechar=='$':valstr=input_entry(text_file,allow_quotes=True,end_all=('\r','\x1a'),end_not_quoted=(',','\n'))print('Read string "%s" from file'%valstr)else:valstr=input_entry(text_file,allow_quotes=False,end_all=('\r','\x1a',',','\n',' '))print('Read value %s from file'%valstr)value=str_to_type(valstr,typechar)ifvalue==None:value=vartypes.null[typechar]# process the ending char (this may raise FIELD OVERFLOW but should avoid INPUT PAST END)ifnottext_file.end_of_file()andtext_file.peek_char()notin('','\x1a'):text_file.read_chars(1)# WJB - Skip trailing space and an end of linwtext_skip(text_file,ascii_white)ifnottext_file.end_of_file()andtext_file.peek_char()=='\r':text_file.read_chars(1)ifnottext_file.end_of_file()andtext_file.peek_char()=='\n':text_file.read_chars(1)# and then set the valuev.append(value)returnreadvar
Regards,
WJB
Don't seem to be able to get code formatting to work, sorry.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi WJB, thanks for reporting the bugs and for your patches!
I believe bug #1 has been fixed, at least in the development branch, but it's probably still there in the latest package release - I'll check and do a bugfix release.
I'll have a look at your test case and patch for bug #2.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have found a couple of input bugs:
1. Spurious spaces when reading unquoted strings.
Test program:
Run the program and when prompted enter:
AAA BBB
The program responds:
AAA B B B
Note the extra spaces introduced between the Bs.
The fix is a one liner in routine "input_entry" in file "representation.py":
2. Error reading numeric value on one line, followed by text string on the next.
Test program:
This displays:
314
END
The "Test String" is not read. Dumping the test data file shows:
The numeric value is followed by <space><cr><lf>. The existing code just skips the trailing space, leaving the file pointer at the end of line. So the following text input just reads an empty string. It is necessary to skip all trailing white space and possibly one end of line after reading a value. The fix is in routine "input_vars_file", again in "representation.py":
Regards,
WJB
Don't seem to be able to get code formatting to work, sorry.
Hi WJB, thanks for reporting the bugs and for your patches!
I believe bug #1 has been fixed, at least in the development branch, but it's probably still there in the latest package release - I'll check and do a bugfix release.
I'll have a look at your test case and patch for bug #2.
I've implemented your fix, slightly modified to account for comma-separated values. Thanks!
These bugs are now fixed with release 14.04.5.