Author: carnold
Date: Tue Jun 17 17:45:03 2008
New Revision: 668887
URL: http://svn.apache.org/viewvc?rev=668887&view=rev
Log:
LOGCXX-291: Tab characters not recognized in properties files
Added:
logging/log4cxx/trunk/src/test/resources/input/propertiestestcase.properties
Modified:
logging/log4cxx/trunk/src/changes/changes.xml
logging/log4cxx/trunk/src/main/cpp/properties.cpp
logging/log4cxx/trunk/src/test/cpp/helpers/propertiestestcase.cpp
Modified: logging/log4cxx/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/changes/changes.xml?rev=668887&r1=668886&r2=668887&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/changes/changes.xml (original)
+++ logging/log4cxx/trunk/src/changes/changes.xml Tue Jun 17 17:45:03 2008
@@ -41,6 +41,7 @@
<action issue="LOGCXX-285">LevelRangeFilter has default value for
acceptOnMatch that is different from log4j</action>
<action issue="LOGCXX-286">gcc 4.3 requires #include <cstring> when
using memcpy and related.</action>
<action issue="LOGCXX-288">Unnecessary trailing semi-colons after LOG4CXX_INFO
et al in docs, examples and tests.<action>
+<action issue="LOGCXX-291">Tab characters are not recognized in properties
files.<action>
</release>
<release version="0.10.0" date="2008-04-03" description="First Apache release">
<action issue="LOGCXX-2">logger.h includes config.h</action>
Modified: logging/log4cxx/trunk/src/main/cpp/properties.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/properties.cpp?rev=668887&r1=668886&r2=668887&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/properties.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/properties.cpp Tue Jun 17 17:45:03 2008
@@ -47,7 +47,7 @@
switch(c)
{
case 0x20: // ' '
- case 0x08: // '\t'
+ case 0x09: // '\t'
case 0x0A: // '\n'
case 0x0D: // '\r'
if (!get(in, c))
@@ -76,7 +76,7 @@
finished = true;
break;
- case 0x08: // '\t'
+ case 0x09: // '\t'
case 0x20: // ' '
case 0x3A: // ':'
case 0x3D: // '='
@@ -106,7 +106,7 @@
case KEY_ESCAPE:
switch(c)
{
- case 0x08: // '\t'
+ case 0x09: // '\t'
case 0x20: // ' '
case 0x3A: // ':'
case 0x3D: // '='
@@ -135,7 +135,7 @@
switch(c)
{
case 0x20: // ' '
- case 0x08: // '\t'
+ case 0x09: // '\t'
if (!get(in, c))
finished = true;
break;
@@ -164,7 +164,7 @@
case DELIMITER:
switch(c)
{
- case 0x08: // '\t'
+ case 0x09: // '\t'
case 0x20: // ' '
case 0x3A: // ':'
case 0x3D: // '='
@@ -209,7 +209,7 @@
case ELEMENT_ESCAPE:
switch(c)
{
- case 0x08: // '\t'
+ case 0x09: // '\t'
case 0x20: // ' '
case 0x6E: // 'n'
case 0x72: // 'r'
@@ -242,7 +242,7 @@
switch(c)
{
case 0x20: // ' '
- case 0x08: // '\t'
+ case 0x09: // '\t'
if (!get(in, c))
finished = true;
break;
Modified: logging/log4cxx/trunk/src/test/cpp/helpers/propertiestestcase.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/helpers/propertiestestcase.cpp?rev=668887&r1=668886&r2=668887&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/helpers/propertiestestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/helpers/propertiestestcase.cpp Tue Jun
17 17:45:03 2008
@@ -28,6 +28,13 @@
{
LOGUNIT_TEST_SUITE(PropertiesTestCase);
LOGUNIT_TEST(testLoad1);
+ LOGUNIT_TEST(testTab1);
+ LOGUNIT_TEST(testTab2);
+ LOGUNIT_TEST(testTab3);
+ LOGUNIT_TEST(testTab4);
+ LOGUNIT_TEST(testTab5);
+ LOGUNIT_TEST(testTab6);
+ LOGUNIT_TEST(testTab7);
LOGUNIT_TEST_SUITE_END();
public:
@@ -41,6 +48,95 @@
LogString
pattern(properties.getProperty(LOG4CXX_STR("log4j.appender.testAppender.layout.ConversionPattern")));
LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("%-5p - %m%n"),
pattern);
}
+
+ /**
+ * Test tab as separator between key and value, see LOGCXX-291.
+ */
+ void testTab1() {
+ FileInputStreamPtr propFile(
+ new
FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
+ Properties properties;
+ properties.load(propFile);
+ LogString
actual(properties.getProperty(LOG4CXX_STR("propertiestestcase.tab1")));
+ LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("tab delimited")),
actual);
+ }
+
+ /**
+ * Test tab as whitespace before key, see LOGCXX-291.
+ */
+ void testTab2() {
+ FileInputStreamPtr propFile(
+ new
FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
+ Properties properties;
+ properties.load(propFile);
+ LogString
actual(properties.getProperty(LOG4CXX_STR("propertiestestcase.tab2")));
+ LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("tab before key")),
actual);
+ }
+
+ /**
+ * Test tab as escaped within key, see LOGCXX-291.
+ */
+ void testTab3() {
+ FileInputStreamPtr propFile(
+ new
FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
+ Properties properties;
+ properties.load(propFile);
+ LogString key(LOG4CXX_STR("propertiestestcase.tab3"));
+ key.append(1, 0x09);
+ LogString actual(properties.getProperty(key));
+ LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("key contains tab")),
actual);
+ }
+
+ /**
+ * Test tab after delimitor, see LOGCXX-291.
+ */
+ void testTab4() {
+ FileInputStreamPtr propFile(
+ new
FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
+ Properties properties;
+ properties.load(propFile);
+ LogString
actual(properties.getProperty(LOG4CXX_STR("propertiestestcase.tab4")));
+ LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("tab after equals")),
actual);
+ }
+
+ /**
+ * Test tab after continuation in key, see LOGCXX-291.
+ */
+ void testTab5() {
+ FileInputStreamPtr propFile(
+ new
FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
+ Properties properties;
+ properties.load(propFile);
+ LogString
actual(properties.getProperty(LOG4CXX_STR("propertiestestcase.tab5")));
+ LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("tab after continue")),
actual);
+ }
+
+ /**
+ * Test tab escaped in value, see LOGCXX-291.
+ */
+ void testTab6() {
+ FileInputStreamPtr propFile(
+ new
FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
+ Properties properties;
+ properties.load(propFile);
+ LogString
actual(properties.getProperty(LOG4CXX_STR("propertiestestcase.tab6")));
+ LogString expected(1, 0x09);
+ expected.append(LOG4CXX_STR(" in value"));
+ LOGUNIT_ASSERT_EQUAL(expected, actual);
+ }
+
+ /**
+ * Test tab in value continuation, see LOGCXX-291.
+ */
+ void testTab7() {
+ FileInputStreamPtr propFile(
+ new
FileInputStream(LOG4CXX_STR("input/propertiestestcase.properties")));
+ Properties properties;
+ properties.load(propFile);
+ LogString
actual(properties.getProperty(LOG4CXX_STR("propertiestestcase.tab7")));
+ LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("continuedvalue")),
actual);
+ }
+
};
Added:
logging/log4cxx/trunk/src/test/resources/input/propertiestestcase.properties
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/resources/input/propertiestestcase.properties?rev=668887&view=auto
==============================================================================
---
logging/log4cxx/trunk/src/test/resources/input/propertiestestcase.properties
(added)
+++
logging/log4cxx/trunk/src/test/resources/input/propertiestestcase.properties
Tue Jun 17 17:45:03 2008
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+propertiestestcase.tab1 tab delimited
+ propertiestestcase.tab2=tab before key
+propertiestestcase.tab3\ =key contains tab
+propertiestestcase.tab4= tab after equals
+propertiestestcase\
+ .tab5=tab after continue
+propertiestestcase.tab6=\ in value
+propertiestestcase.tab7=continued\
+ value