Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input_line keeps ending \013 #8452

Closed
vicuna opened this issue Jan 21, 2004 · 1 comment
Closed

input_line keeps ending \013 #8452

vicuna opened this issue Jan 21, 2004 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jan 21, 2004

Original bug ID: 2050
Reporter: administrator
Status: closed (set by @xavierleroy on 2013-08-31T10:46:15Z)
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Mattias
Version: 3.07#2
OS: Mandrake 8.2
Submission from: c-44dd71d5.09-253-7570701.cust.bredbandsbolaget.se (213.113.221.68)

I switch between cygwin and linux. I had to write my own input_line that removes
final \013.

I assume this is a crlf/lf-problem. I didn't have this problem in 3.06, but I
guess it depends on where the file was created, so maybe the case didn't occur
earlier.

(** input_line but remove final '\013' which
occurs if files are created on Windows *)
let my_input_line ic =
let str = input_line ic in
if str.[String.length str - 1] = '\013' then
String.sub str 0 (String.length str - 1)
else
str ;;

@vicuna
Copy link
Author

vicuna commented Jan 27, 2012

Comment author: @damiendoligez

You have to know what file format you are using, a computer cannot guess that for you. Usually, the best solution is to write your program to ignore all CR characters in its input.

But it would be a bug for the standard library to do that on all inputs. input_line has no business removing arbitrary characters from the input data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant