瀏覽代碼

kconfig: support DOS line endings

Kconfig doesn't currently handle config files with DOS line endings.
While these are, of course, an abomination, etc, etc, it can be handy
to not have to convert them first.  It's also a tiny patch and even adds
support for lines ending in just \r or even \n\r.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Matthew Wilcox 19 年之前
父節點
當前提交
d3660a8cbd
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      scripts/kconfig/confdata.c

+ 6 - 2
scripts/kconfig/confdata.c

@@ -193,8 +193,11 @@ load:
 				continue;
 				continue;
 			*p++ = 0;
 			*p++ = 0;
 			p2 = strchr(p, '\n');
 			p2 = strchr(p, '\n');
-			if (p2)
-				*p2 = 0;
+			if (p2) {
+				*p2-- = 0;
+				if (*p2 == '\r')
+					*p2 = 0;
+			}
 			if (def == S_DEF_USER) {
 			if (def == S_DEF_USER) {
 				sym = sym_find(line + 7);
 				sym = sym_find(line + 7);
 				if (!sym) {
 				if (!sym) {
@@ -266,6 +269,7 @@ load:
 				;
 				;
 			}
 			}
 			break;
 			break;
+		case '\r':
 		case '\n':
 		case '\n':
 			break;
 			break;
 		default:
 		default: