[cmor] 169/190: Issue #4: fix for '.' at the end of a substring searched for in the history string

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository cmor.

commit 6bbe5a9dc127d04a1c8040ac06b14c2117b9333d
Author: Jamie Kettleborough <jamie.kettleborough at metoffice.gov.uk>
Date:   Tue Nov 19 17:00:30 2013 +0000

    Issue #4: fix for '.' at the end of a substring searched for in the history string
---
 Src/cmor.c                  | 11 +++++++++--
 Test/test_unit_cat_unique.c | 14 ++++++++++++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/Src/cmor.c b/Src/cmor.c
index 030d102..02d034c 100644
--- a/Src/cmor.c
+++ b/Src/cmor.c
@@ -58,13 +58,20 @@ char cmor_traceback_info[CMOR_MAX_STRING];
 /* is src in dest?*/
 
 int cmor_stringinstring (char* dest, char* src) {
+  /* returns 1 if dest contains the words of src.
+     the end of a word is either a space, a period or null.
+     
+     this will not give the desired results if period is used
+     internal to a word.
+ */
   char* pstr=dest;
   while (pstr=strstr(pstr, src)) {
     /* if this word is at the beginning of msg or preceeded by a space */
     if (pstr==dest || pstr[-1]==' ') {
       /* if it isn't a substring match */
       if ((pstr[strlen(src)] == ' ') ||
-          (pstr[strlen(src)] == 0)) {
+          (pstr[strlen(src)] == 0) ||
+	  (pstr[strlen(src)] == '.')) {
         /* then return 1 to indicate string found */
         return 1;
       }
@@ -2539,7 +2546,7 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
         if (cmor_history_contains(var_id, msg)) {
           /* do nothing */
         } else {
-	cmor_update_history(var_id,msg);
+	  cmor_update_history(var_id,msg);
         }
       }
       /* Axis length */
diff --git a/Test/test_unit_cat_unique.c b/Test/test_unit_cat_unique.c
index a3e9895..0c8f167 100644
--- a/Test/test_unit_cat_unique.c
+++ b/Test/test_unit_cat_unique.c
@@ -6,6 +6,16 @@ int fail(int code, char *expect, char *got) {
   return code;
 }
 
+int test_cmor_stringinstring(void) {
+  printf("running cmor_stringinstring tests\n");
+  if (cmor_stringinstring("Inverted axis: rlat.", "Inverted axis: rlat")) {
+    /* should match */
+  } else {
+    printf("failed stringinstring test with period after string\n");
+    return 1;
+  }
+}
+  
 int test_cat_unique_string(void) {
   char dest[CMOR_MAX_STRING];
   char src[CMOR_MAX_STRING];
@@ -15,7 +25,7 @@ int test_cat_unique_string(void) {
   strcpy(expected, "rumble");
 
   /* 1. simple test: add string to blank */
-  printf("running tests\n");
+  printf("running cat_unique_string tests\n");
   cmor_cat_unique_string(dest,src);
   if (strcmp(dest,expected)) {
     return fail(1, expected, dest);
@@ -124,6 +134,6 @@ int test_cat_unique_string(void) {
 }
 
 int main(int argc, char **argv) {
+  test_cmor_stringinstring();
   test_cat_unique_string();
- 
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cmor.git



More information about the debian-science-commits mailing list