[svn-commits] qwell: trunk r89683 - /trunk/include/asterisk/strings.h

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Nov 27 13:12:33 CST 2007


Author: qwell
Date: Tue Nov 27 13:12:33 2007
New Revision: 89683

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89683
Log:
Add an S_COR macro, which is similar to the existing S_OR macro,
 except with an additional boolean arg.

A hack such as:
foo ? S_OR(bar, "baz") : "baz"
becomes:
S_COR(foo, bar, "baz")

Modified:
    trunk/include/asterisk/strings.h

Modified: trunk/include/asterisk/strings.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/strings.h?view=diff&rev=89683&r1=89682&r2=89683
==============================================================================
--- trunk/include/asterisk/strings.h (original)
+++ trunk/include/asterisk/strings.h Tue Nov 27 13:12:33 2007
@@ -37,7 +37,13 @@
 /*! \brief returns the equivalent of logic or for strings:
  * first one if not empty, otherwise second one.
  */
-#define S_OR(a, b)	(!ast_strlen_zero(a) ? (a) : (b))
+#define S_OR(a, b)           (!ast_strlen_zero(a) ? (a) : (b))
+
+/*! \brief returns the equivalent of logic or for strings, with an additional boolean check:
+ * second one if not empty and first one is true, otherwise third one.
+ * example: S_COR(usewidget, widget, "<no widget>")
+ */
+#define S_COR(a, b, c)   ((a && !ast_strlen_zero(b)) ? (b) : (c))
 
 /*!
   \brief Gets a pointer to the first non-whitespace character in a string.




More information about the svn-commits mailing list