You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2011/05/17 14:01:01 UTC

svn commit: r1104177 - /subversion/trunk/subversion/libsvn_subr/date.c

Author: stsp
Date: Tue May 17 12:01:01 2011
New Revision: 1104177

URL: http://svn.apache.org/viewvc?rev=1104177&view=rev
Log:
* subversion/libsvn_subr/date.c
  (number_words_table): Use svn_token_map_t and rename to number_words_map.
  (words_match): Replace a loop with svn_token__from_word().

Suggested by: gstein

Modified:
    subversion/trunk/subversion/libsvn_subr/date.c

Modified: subversion/trunk/subversion/libsvn_subr/date.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/date.c?rev=1104177&r1=1104176&r2=1104177&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/date.c (original)
+++ subversion/trunk/subversion/libsvn_subr/date.c Tue May 17 12:01:01 2011
@@ -25,6 +25,7 @@
 #include "svn_string.h"
 
 #include "svn_private_config.h"
+#include "private/svn_token.h"
 
 /* Valid rule actions */
 enum rule_action {
@@ -204,10 +205,7 @@ static struct unit_words_table {
   { NULL ,      0 }
 };
 
-static struct number_words_table {
-  const char *word;
-  int number;
-} number_words_table[] = {
+static svn_token_map_t number_words_map[] = {
   { "zero", 0 }, { "one", 1 }, { "two", 2 }, { "three", 3 }, { "four", 4 },
   { "five", 5 }, { "six", 6 }, { "seven", 7 }, { "eight", 8 }, { "nine", 9 },
   { "ten", 10 }, { "eleven", 11 }, { "twelve", 12 }, { NULL, 0 }
@@ -231,7 +229,6 @@ words_match(apr_time_exp_t *expt, svn_bo
   apr_array_header_t *words;
   int i;
   int n = -1;
-  const char *number_str;
   const char *unit_str;
 
   words = svn_cstring_split(text, " ", TRUE /* chop_whitespace */, pool);
@@ -242,17 +239,9 @@ words_match(apr_time_exp_t *expt, svn_bo
   word = APR_ARRAY_IDX(words, 0, const char *);
 
   /* Try to parse a number word. */
-  for (i = 0, number_str = number_words_table[i].word;
-       number_str = number_words_table[i].word, number_str != NULL; i++)
-    {
-      if (!strcmp(word, number_str))
-        {
-          n = number_words_table[i].number;
-          break;
-        }
-    }
+  n = svn_token__from_word(number_words_map, word);
 
-  if (n < 0)
+  if (n == SVN_TOKEN_UNKNOWN)
     {
       svn_error_t *err;