iliaa           Tue Jan  7 19:41:53 2003 EDT

  Modified files:              
    /php4/sapi/cli      php_cli.c 
    /php4/sapi/cgi      cgi_main.c 
  Log:
  Fixed bug #21297. The fix also fixes miscalculation of lines numbers by 1
  due the previously mentioned bug.
  
  
Index: php4/sapi/cli/php_cli.c
diff -u php4/sapi/cli/php_cli.c:1.60 php4/sapi/cli/php_cli.c:1.61
--- php4/sapi/cli/php_cli.c:1.60        Sun Jan  5 11:10:35 2003
+++ php4/sapi/cli/php_cli.c     Tue Jan  7 19:41:53 2003
@@ -695,6 +695,13 @@
                                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: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.206 php4/sapi/cgi/cgi_main.c:1.207
--- php4/sapi/cgi/cgi_main.c:1.206      Tue Jan  7 11:33:28 2003
+++ php4/sapi/cgi/cgi_main.c    Tue Jan  7 19:41:53 2003
@@ -1413,6 +1413,13 @@
                                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);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to