diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2003-01-08 00:41:53 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2003-01-08 00:41:53 +0000 |
commit | 5de9962d505334046c0fa822f58e3cc0d94c9e80 (patch) | |
tree | 203ac5fa6017c97c53247b3712c75f39d3ed5374 /sapi | |
parent | ac3e8601ae0cc3a8cf326fa1f1e78ff99aa6d79b (diff) | |
download | php-git-5de9962d505334046c0fa822f58e3cc0d94c9e80.tar.gz |
Fixed bug #21297. The fix also fixes miscalculation of lines numbers by 1
due the previously mentioned bug.
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/cgi/cgi_main.c | 7 | ||||
-rw-r--r-- | sapi/cli/php_cli.c | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 299ff33696..161835cd2f 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -1413,6 +1413,13 @@ consult the installation file that came with this distribution, or visit \n\ while (c != 10 && c != 13) { c = fgetc(file_handle.handle.fp); /* skip to end of line */ } + /* handle situations where line is terminated by \r\n */ + if (c == 13) { + if (fgetc(file_handle.handle.fp) != 10) { + long pos = ftell(file_handle.handle.fp); + fseek(file_handle.handle.fp, pos - 1, SEEK_SET); + } + } CG(start_lineno) = 2; } else { rewind(file_handle.handle.fp); diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index a98865f531..412180b577 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -695,6 +695,13 @@ int main(int argc, char *argv[]) while (c != 10 && c != 13) { c = fgetc(file_handle.handle.fp); /* skip to end of line */ } + /* handle situations where line is terminated by \r\n */ + if (c == 13) { + if (fgetc(file_handle.handle.fp) != 10) { + long pos = ftell(file_handle.handle.fp); + fseek(file_handle.handle.fp, pos - 1, SEEK_SET); + } + } CG(start_lineno) = 2; } else { rewind(file_handle.handle.fp); |