summaryrefslogtreecommitdiff
path: root/src/util/String.c
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2004-04-12 14:55:21 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2004-04-12 14:55:21 +0000
commit57a673f54ad9db37887c25dd128b28fce4bcea76 (patch)
tree738c8b6c11434e3b87eb380dbd5b03d7ac9dadb3 /src/util/String.c
parentb414c615aaf4e10f3f53661449fc13f9b351de6d (diff)
Add a function Util_StrMemCmpi that compares a C and a Fortran string
without copying the Fortran string. git-svn-id: http://svn.cactuscode.org/flesh/trunk@3661 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util/String.c')
-rw-r--r--src/util/String.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/util/String.c b/src/util/String.c
index 61cdabd0..25c3a2ae 100644
--- a/src/util/String.c
+++ b/src/util/String.c
@@ -433,6 +433,60 @@ int Util_StrCmpi (const char *string1, const char *string2)
return (retval);
}
+ /*@@
+ @routine Util_StrMemCmpi
+ @date Tue Apr 06 2004
+ @author Erik Schnetter
+ @desc
+ Case independent strmemcmp: Compare a string against a memory region,
+ i.e. a C string against a Fortran string
+ @enddesc
+ @calls
+ @calledby
+ @history
+ @endhistory
+ @var string1
+ @vdesc First string in comparison (nul-terminated)
+ @vtype const char *
+ @vio in
+ @vcomment
+
+ @endvar
+ @var string2
+ @vdesc Second string in comparison (not nul-terminated)
+ @vtype const char *
+ @vio in
+ @vcomment
+
+ @endvar
+ @var len2
+ @vdesc Length of the second string
+ @vtype size_t
+ @vio in
+ @vcomment
+
+ @endvar
+
+ @returntype int
+ @returndesc
+ +ve - string1 > string2
+ 0 - string1 = string2
+ -ve - string1 < string2
+ @endreturndesc
+@@*/
+int Util_StrMemCmpi (const char *string1, const char *string2, size_t length2)
+{
+ int retval;
+
+
+ do
+ {
+ retval = tolower (*string1) - (length2 ? tolower (*string2) : '\0');
+ } while (! retval && *string1++ && (string2++, length2--));
+
+ return (retval);
+}
+
/*@
@routine Util_SplitFilename
@date Wed Oct 4 10:14:00 2000