Quellcode durchsuchen

Add support for C-style comments to NJSON

Daniele Bartolini vor 10 Jahren
Ursprung
Commit
fd67750026
1 geänderte Dateien mit 17 neuen und 3 gelöschten Zeilen
  1. 17 3
      src/core/json/njson.cpp

+ 17 - 3
src/core/json/njson.cpp

@@ -65,9 +65,23 @@ namespace njson
 
 
 		if (*json == '/')
 		if (*json == '/')
 		{
 		{
-			json = next(json, '/');
-			json = next(json, '/');
-			while (*json && *json != '\n') json = next(json);
+			json = next(json);
+			if (*json == '/')
+			{
+				json = next(json, '/');
+				while (*json && *json != '\n')
+					json = next(json);
+			}
+			else if (*json == '*')
+			{
+				json = next(json);
+				while (*json && *json != '*')
+					json = next(json);
+				json = next(json, '*');
+				json = next(json, '/');
+			}
+			else
+				CE_FATAL("Bad comment");
 		}
 		}
 
 
 		return json;
 		return json;