[asterisk-commits] rizzo: trunk r47827 - in /trunk:
include/asterisk/cli.h main/cli.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Nov 18 13:08:17 MST 2006
Author: rizzo
Date: Sat Nov 18 14:08:17 2006
New Revision: 47827
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47827
Log:
Move this macro from cli.c to cli.h so apps can use it
without duplicating the macro or the code:
/*!
* In many cases we need to print singular or plural
* words depending on a count. This macro helps us e.g.
* printf("we have %d object%s", n, ESS(n));
*/
#define ESS(x) ((x) == 1 ? "" : "s")
Modified:
trunk/include/asterisk/cli.h
trunk/main/cli.c
Modified: trunk/include/asterisk/cli.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/cli.h?view=diff&rev=47827&r1=47826&r2=47827
==============================================================================
--- trunk/include/asterisk/cli.h (original)
+++ trunk/include/asterisk/cli.h Sat Nov 18 14:08:17 2006
@@ -47,6 +47,13 @@
#define AST_MAX_ARGS 64
#define AST_CLI_COMPLETE_EOF "_EOF_"
+
+/*!
+ * In many cases we need to print singular or plural
+ * words depending on a count. This macro helps us e.g.
+ * printf("we have %d object%s", n, ESS(n));
+ */
+#define ESS(x) ((x) == 1 ? "" : "s")
/*! \page CLI_command_api CLI command API
Modified: trunk/main/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/main/cli.c?view=diff&rev=47827&r1=47826&r2=47827
==============================================================================
--- trunk/main/cli.c (original)
+++ trunk/main/cli.c Sat Nov 18 14:08:17 2006
@@ -341,7 +341,6 @@
#define DAY (HOUR*24)
#define WEEK (DAY*7)
#define YEAR (DAY*365)
-#define ESS(x) ((x == 1) ? "" : "s") /* plural suffix */
#define NEEDCOMMA(x) ((x)? ",": "") /* define if we need a comma */
if (timeval < 0) /* invalid, nothing to show */
return;
@@ -938,7 +937,7 @@
if (havepattern)
regfree(®exbuf);
- ast_cli(fd, "%d active channel%s\n", numchans, (numchans != 1) ? "s" : "");
+ ast_cli(fd, "%d active channel%s\n", numchans, ESS(numchans));
return RESULT_SUCCESS;
#undef FORMAT_STRING
}
More information about the asterisk-commits
mailing list