]> granicus.if.org Git - php/commitdiff
Fixed bug #21297. The fix also fixes miscalculation of lines numbers by 1
authorIlia Alshanetsky <iliaa@php.net>
Wed, 8 Jan 2003 00:41:53 +0000 (00:41 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 8 Jan 2003 00:41:53 +0000 (00:41 +0000)
due the previously mentioned bug.

sapi/cgi/cgi_main.c
sapi/cli/php_cli.c

index 299ff3369645c1643b16ca9f67df50da35244a7c..161835cd2f6a6037da48540491e98777e35a4d4a 100644 (file)
@@ -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);
index a98865f5311b4610fa2e3d6d03e24b95d258ca16..412180b577137ee330bb9dbb9a5ea7e8f6428005 100644 (file)
@@ -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);