You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/12/28 09:07:30 UTC
svn commit: r894132 - in /commons/sandbox/runtime/trunk: ./ src/main/native/
src/main/native/build/org/apache/commons/runtime/ant/
src/main/native/include/ src/main/native/shared/
Author: mturk
Date: Mon Dec 28 08:07:29 2009
New Revision: 894132
URL: http://svn.apache.org/viewvc?rev=894132&view=rev
Log:
Add If Task
Added:
commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/IfTask.java (with props)
Modified:
commons/sandbox/runtime/trunk/build.xml
commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/FormattedEchoTask.java
commons/sandbox/runtime/trunk/src/main/native/configure
commons/sandbox/runtime/trunk/src/main/native/configure.xml
commons/sandbox/runtime/trunk/src/main/native/include/acr.h
commons/sandbox/runtime/trunk/src/main/native/shared/ini.c
Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=894132&r1=894131&r2=894132&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Mon Dec 28 08:07:29 2009
@@ -126,7 +126,7 @@
<equals arg1="${compile.source}" arg2="1.5"/>
</condition>
<tstamp>
- <format property="version.year" pattern="yyyy" locale="en"/>
+ <format property="YEAR" pattern="yyyy" locale="en"/>
<format property="TODAY" pattern="MMM d yyyy" locale="en"/>
<format property="TSTAMP" pattern="HH:mm:ss"/>
</tstamp>
@@ -135,7 +135,7 @@
<!-- =================================================================== -->
<!-- Creates the API documentation -->
<!-- =================================================================== -->
- <target name="javadocs" description="Java documentation">
+ <target name="javadocs" description="Java documentation" depends="compile">
<mkdir dir="${docs.dest}"/>
<mkdir dir="${docs.dest}/api"/>
<javadoc sourcepath="${build.src}/java"
@@ -146,7 +146,7 @@
packagenames="${build.package.name}.*"
windowtitle="${title} (Version ${version})"
doctitle="<h2>${title}</h2>"
- bottom="Copyright © ${version.year} The Apache Software Foundation<!--
+ bottom="Copyright &copy; ${YEAR} The Apache Software Foundation<!--
Apache Commons Runtime
This product includes software developed by
Modified: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/FormattedEchoTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/FormattedEchoTask.java?rev=894132&r1=894131&r2=894132&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/FormattedEchoTask.java (original)
+++ commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/FormattedEchoTask.java Mon Dec 28 08:07:29 2009
@@ -56,7 +56,7 @@
if (message != null) {
StringBuilder sb = new StringBuilder();
Formatter fmt = new Formatter(sb);
- String [] ma = message.split(" : ");
+ String [] ma = message.split("::");
for (int i = 0; i < ma.length; i++) {
if (ma[i].startsWith("${")) {
if (defval != null)
Added: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/IfTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/IfTask.java?rev=894132&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/IfTask.java (added)
+++ commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/IfTask.java Mon Dec 28 08:07:29 2009
@@ -0,0 +1,109 @@
+/* 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.
+ */
+package org.apache.commons.runtime.ant;
+
+import java.util.Properties;
+import java.util.Vector;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.PropertyHelper;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Sequential;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.apache.tools.ant.taskdefs.condition.ConditionBase;
+
+/**
+ */
+public class IfTask extends ConditionBase
+{
+
+ private Sequential elseTask;
+ private Sequential thenTask;
+ private Vector elifTasks;
+
+ public IfTask()
+ {
+ super();
+ thenTask = null;
+ elseTask = null;
+ elifTasks = new Vector();
+ }
+
+ public void addThen(Sequential s)
+ {
+ if (thenTask != null) {
+ throw new BuildException("Only one nested <then> allowed inside <if>");
+ }
+ thenTask = s;
+ }
+
+ public void addElse(Sequential s)
+ {
+ if (elseTask != null) {
+ throw new BuildException("Only one nested <else> allowed inside <if>");
+ }
+ elseTask = s;
+ }
+
+ public void addElif(IfTask s)
+ {
+ elifTasks.addElement(s);
+ }
+
+ public boolean eval()
+ throws BuildException
+ {
+ if (countConditions() > 1) {
+ throw new BuildException("Only one nested condition allowed inside <if>");
+ }
+ if (countConditions() < 1) {
+ throw new BuildException("One nested condition required inside <if>");
+ }
+ Condition c = (Condition)getConditions().nextElement();
+ return c.eval();
+ }
+
+ public void execute()
+ throws BuildException
+ {
+ if (countConditions() > 1) {
+ throw new BuildException("Only one nested condition allowed inside <if>");
+ }
+ if (countConditions() < 1) {
+ throw new BuildException("One nested condition required inside <if>");
+ }
+ Condition c = (Condition)getConditions().nextElement();
+ if (c.eval()) {
+ if (thenTask != null) {
+ thenTask.execute();
+ }
+ }
+ else {
+ boolean eval = false;
+ for (int i = 0; i < elifTasks.size(); i++) {
+ IfTask ei = (IfTask)(elifTasks.elementAt(i));
+ if (ei.eval()) {
+ eval = true;
+ ei.execute();
+ }
+ }
+ if (!eval && elseTask != null) {
+ elseTask.execute();
+ }
+ }
+ }
+
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ant/IfTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=894132&r1=894131&r2=894132&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Mon Dec 28 08:07:29 2009
@@ -1168,8 +1168,8 @@
#define HAVE_SYS_UIO_H `have_include 0 sys/uio`
#define HAVE_SYS_MMAN_H `have_include 0 sys/mman`
#define HAVE_SYS_EPOLL_H `have_include 0 sys/epoll`
-#define HAVE_SYS_EVENTFD_H `have_include 0 sys/eventfd`
#define HAVE_SYS_EVENT_H `have_include 0 sys/event`
+#define HAVE_SYS_EVENTFD_H `have_include 0 sys/eventfd`
#define HAVE_SYS_INOTIFY_H `have_include 0 sys/inotify`
#define HAVE_LIMITS_H `have_include 1 limits`
#define HAVE_NETDB_H `have_include 0 netdb`
@@ -1194,6 +1194,7 @@
#define HAVE_GMTIME_R `have_function 0 gmtime_r`
#define HAVE_SIGSETJMP `have_function 0 sigsetjmp`
#define HAVE_SIGACTION `have_function 0 sigaction`
+#define HAVE_EVENTFD `have_function 0 eventfd`
#define HAVE_SOCK_CLOEXEC `have_defined SOCK_CLOEXEC`
#define HAVE_FILE_CLOEXEC `have_defined O_CLOEXEC`
#define HAVE_OFF64_T $have_off64t
Modified: commons/sandbox/runtime/trunk/src/main/native/configure.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure.xml?rev=894132&r1=894131&r2=894132&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure.xml (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure.xml Mon Dec 28 08:07:29 2009
@@ -77,6 +77,10 @@
classname="${build.package.name}.ant.SystemIdTask">
<classpath refid="task.classpath"/>
</taskdef>
+ <taskdef name="if"
+ classname="${build.package.name}.ant.IfTask">
+ <classpath refid="task.classpath"/>
+ </taskdef>
<taskdef name="conditional"
classname="${build.package.name}.ant.ConditionalTask">
<classpath refid="task.classpath"/>
@@ -136,7 +140,7 @@
</fileset>
</delete>
<property name="@{result}" value="0"/>
- <info format="%1$-45s %2$s" message="Checking for sizeof(@{type}) : ${@{result}}"/>
+ <info format="%1$-45s %2$s">Checking for sizeof(@{type})::${@{result}}</info>
</sequential>
</macrodef>
@@ -158,19 +162,24 @@
<arg line="-nologo"/>
<arg line="cc${build.tstamp}.c /link /out:cc${build.tstamp}.exe"/>
</cexec>
- <conditional variable="@{result}" value="1" else="0">
- <variable name="have.err" equals="0"/>
- </conditional>
- <conditional variable="have.res" value="ok" else="not found">
- <variable name="have.err" equals="0"/>
- </conditional>
+ <if>
+ <equals arg1="${have.err}" arg2="0"/>
+ <then>
+ <variable name="@{result}" value="1"/>
+ <variable name="have.res" value="ok"/>
+ </then>
+ <else>
+ <variable name="@{result}" value="0"/>
+ <variable name="have.res" value="not found"/>
+ </else>
+ </if>
<delete>
<fileset dir="${src.native}">
<filename name="cc${build.tstamp}*" />
</fileset>
</delete>
<property name="@{result}" value="0"/>
- <info format="%1$-45s %2$s" message="Checking for <@{file}.h> : ${have.res}"/>
+ <info format="%1$-45s %2$s">Checking for <@{file}.h>::${have.res}</info>
</sequential>
</macrodef>
@@ -203,7 +212,7 @@
</fileset>
</delete>
<property name="@{result}" value="0"/>
- <info format="%1$-45s %2$s" message="Checking for @{file} library : ${have.res}"/>
+ <info format="%1$-45s %2$s">Checking for @{file} library::${have.res}</info>
</sequential>
</macrodef>
@@ -244,6 +253,31 @@
<have-library file="bufferoverflow"/>
<have-library file="ktmw32"/>
</sequence>
- <info format="#define HAVE_WINDOWS_H %1s" message="${config.have.windows}"/>
+ <info format="#define HAVE_WINDOWS_H %1s">${config.have.windows}</info>
+ <if>
+ <isset property="systemid.osss" />
+ <then>
+ <echo message="property is set" />
+ </then>
+ <elif>
+ <isset property="systemid.osw" />
+ <then>
+ <echo message="property elif is set" />
+ </then>
+ </elif>
+ <elif>
+ <or>
+ <isset property="systemid.os1" />
+ <isset property="systemid.cpu" />
+ </or>
+ <then>
+ <echo message="property elif3 is set" />
+ </then>
+ </elif>
+ <else>
+ <echo message="property is NOT set" />
+ </else>
+ </if>
</target>
</project>
+
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr.h?rev=894132&r1=894131&r2=894132&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr.h Mon Dec 28 08:07:29 2009
@@ -100,6 +100,9 @@
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#if HAVE_WTYPES_H
#include <wtypes.h>
#endif
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/ini.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/ini.c?rev=894132&r1=894131&r2=894132&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/ini.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/ini.c Mon Dec 28 08:07:29 2009
@@ -469,10 +469,24 @@
/* Some early sanity check */
if (!s || !*s)
return s;
- while ((c = *s++) != 0) {
+ while ((c = *(s++)) != 0) {
if (c == '\\') {
char *sd = s - 1;
- char *ss = s;
+ char *ss = s++;
+ switch ((c = *(ss++))) {
+ case 'n':
+ *(sd++) = '\n';
+ break;
+ case 'r':
+ *(sd++) = '\r';
+ break;
+ case 't':
+ *(sd++) = '\t';
+ break;
+ default:
+ *(sd++) = c;
+ break;
+ }
while (*sd) {
*(sd++) = *(ss++);
}
@@ -497,17 +511,7 @@
if (!var_pos) {
/* Nothing to replace.
*/
- if ((var_pos = strstr(str, "\\'$"))) {
- /* Check if we have \'${FOO}' in which case
- * unescape the string.
- */
- if (*(var_pos + 3) == '{' || *(var_pos + 3) == '(')
- return strunesc(str);
- else
- return str;
- }
- else
- return str;
+ return str;
}
acr_sbuf_new(&sbuf, NULL, strlen(str), ACR_SBUF_AUTOEXTEND);
/* Loop for each unescaped $ */
@@ -577,7 +581,7 @@
x_free(str);
str = acr_sbuf_data(&sbuf);
- return strunesc(str);
+ return str;
}
/*
@@ -629,6 +633,7 @@
}
ACR_IniAttrAddVal(_E, attr, line);
if (!nextline) {
+ attr->val = strunesc(attr->val);
attr->val = ini_expand(attr->val, NULL);
}
continue;
@@ -678,6 +683,7 @@
}
attr = ACR_IniNodeAttrAdd(_E, cur, line, val);
if (attr->val && !nextline) {
+ attr->val = strunesc(attr->val);
attr->val = ini_expand(attr->val, NULL);
}
}
@@ -733,6 +739,7 @@
}
ACR_IniAttrAddVal(_E, attr, line);
if (!nextline) {
+ attr->val = strunesc(attr->val);
attr->val = ini_expand(attr->val, NULL);
}
continue;
@@ -766,6 +773,7 @@
attr = ACR_IniNodeAttrSet(_E, node, key, val);
}
if (attr->val && !nextline) {
+ attr->val = strunesc(attr->val);
attr->val = ini_expand(attr->val, NULL);
}
}
@@ -814,6 +822,7 @@
}
ACR_IniAttrAddVal(_E, attr, line);
if (!nextline) {
+ attr->val = strunesc(attr->val);
attr->val = ini_expand(attr->val, ini);
}
continue;
@@ -884,6 +893,7 @@
}
attr = ACR_IniNodeAttrAdd(_E, cur, key, val);
if (attr->val && !nextline) {
+ attr->val = strunesc(attr->val);
attr->val = ini_expand(attr->val, ini);
}
}