浏览代码

accept `\r' as newline when looking for line end

Roberto Ierusalimschy 21 年之前
父节点
当前提交
1c459b881f
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      lobject.c

+ 2 - 2
lobject.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.c,v 2.1 2003/12/10 12:13:36 roberto Exp roberto $
+** $Id: lobject.c,v 2.2 2004/04/30 20:13:38 roberto Exp roberto $
 ** Some generic functions over Lua objects
 ** Some generic functions over Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -173,7 +173,7 @@ void luaO_chunkid (char *out, const char *source, int bufflen) {
       strcat(out, source);
       strcat(out, source);
     }
     }
     else {  /* out = [string "string"] */
     else {  /* out = [string "string"] */
-      int len = strcspn(source, "\n");  /* stop at first newline */
+      int len = strcspn(source, "\n\r");  /* stop at first newline */
       bufflen -= sizeof(" [string \"...\"] ");
       bufflen -= sizeof(" [string \"...\"] ");
       if (len > bufflen) len = bufflen;
       if (len > bufflen) len = bufflen;
       strcpy(out, "[string \"");
       strcpy(out, "[string \"");