Author: sveinung
Date: Tue Oct 11 16:15:46 2016
New Revision: 34094

URL: http://svn.gna.org/viewcvs/freeciv?rev=34094&view=rev
Log:
Introduce are_strvecs_equal().

See patch #7800

Modified:
    trunk/utility/string_vector.c
    trunk/utility/string_vector.h

Modified: trunk/utility/string_vector.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/utility/string_vector.c?rev=34094&r1=34093&r2=34094&view=diff
==============================================================================
--- trunk/utility/string_vector.c       (original)
+++ trunk/utility/string_vector.c       Tue Oct 11 16:15:46 2016
@@ -346,6 +346,27 @@
 }
 
 /**************************************************************************
+  Returns TRUE if stv1 and stv2 are equal.
+**************************************************************************/
+bool are_strvecs_equal(const struct strvec *stv1,
+                       const struct strvec *stv2)
+{
+  int i;
+
+  if (strvec_size(stv1) != strvec_size(stv2)) {
+    return FALSE;
+  }
+
+  for (i = 0; i < strvec_size(stv1); i++) {
+    if (0 != strcmp(stv1->vec[i], stv2->vec[i])) {
+      return FALSE;
+    }
+  }
+
+  return TRUE;
+}
+
+/**************************************************************************
   Returns the datas of the vector.
 **************************************************************************/
 const char *const *strvec_data(const struct strvec *psv)

Modified: trunk/utility/string_vector.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/utility/string_vector.h?rev=34094&r1=34093&r2=34094&view=diff
==============================================================================
--- trunk/utility/string_vector.h       (original)
+++ trunk/utility/string_vector.h       Tue Oct 11 16:15:46 2016
@@ -45,6 +45,8 @@
 bool strvec_remove(struct strvec *psv, size_t svindex);
 
 size_t strvec_size(const struct strvec *psv);
+bool are_strvecs_equal(const struct strvec *stv1,
+                       const struct strvec *stv2);
 const char *const *strvec_data(const struct strvec *psv);
 bool strvec_index_valid(const struct strvec *psv, size_t svindex);
 const char *strvec_get(const struct strvec *psv, size_t svindex);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to