Use colon in "%YAML:1.0" directive when persisting to YAML-files
authorfegorsch <felix.gorschlueter@igd.fraunhofer.de>
Tue, 25 Oct 2016 16:18:35 +0000 (18:18 +0200)
committerfegorsch <felix.gorschlueter@igd.fraunhofer.de>
Tue, 25 Oct 2016 16:18:35 +0000 (18:18 +0200)
In YAML 1.0 the colon is mandatory. See http://yaml.org/spec/1.0/#id2558635.

This also allows prior releases to read YAML files created with the current version.

modules/core/src/persistence.cpp
modules/core/test/test_io.cpp

index 4ddadc9..a1c843d 100644 (file)
@@ -4332,7 +4332,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
         else if( fs->fmt == CV_STORAGE_FORMAT_YAML )
         {
             if( !append )
-                icvPuts( fs, "%YAML 1.0\n---\n" );
+                icvPuts( fs, "%YAML:1.0\n---\n" );
             else
                 icvPuts( fs, "...\n---\n" );
             fs->start_write_struct = icvYMLStartWriteStruct;
index a43356f..75953e1 100644 (file)
@@ -584,7 +584,7 @@ TEST(Core_InputOutput, FileStorageKey)
     EXPECT_NO_THROW(f << "key1" << "value1");
     EXPECT_NO_THROW(f << "_key2" << "value2");
     EXPECT_NO_THROW(f << "key_3" << "value3");
-    const std::string expected = "%YAML 1.0\n---\nkey1: value1\n_key2: value2\nkey_3: value3\n";
+    const std::string expected = "%YAML:1.0\n---\nkey1: value1\n_key2: value2\nkey_3: value3\n";
     ASSERT_STREQ(f.releaseAndGetString().c_str(), expected.c_str());
 }