summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2009-12-05 04:11:47 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2009-12-05 04:11:47 +0000
commit2c593dcfba874dc6156f9192c3ca80a3a225e420 (patch)
treeedca0a8fbf844ca89f3daf1a5eccc9fc2d12624b /src/util
parente1d64c86a158f57ef5c65e85051fb786a0df63be (diff)
Modify the behaviour of mixed C/Fortran string comparisons, so that it
is consistent with the routines converting Fortran strings to C strings. Fortran strings have a fixed length, and trailing white space is usually ignored. The Cactus routine converting Fortran to C strings did already ignore trailing white space, but the routine comparing Fortran and C strings did not. This is now consistent. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4590 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util')
-rw-r--r--src/util/String.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/util/String.c b/src/util/String.c
index e152efd9..23be0987 100644
--- a/src/util/String.c
+++ b/src/util/String.c
@@ -477,12 +477,20 @@ int Util_StrCmpi (const char *string1, const char *string2)
int Util_StrMemCmpi (const char *string1, const char *string2, size_t length2)
{
int retval;
+ size_t last2;
+ /* Fortran speciality: ignore trailing blanks */
+ last2 = length2;
+ while (last2 > 0 && string2[last2-1] == ' ')
+ {
+ last2--;
+ }
+
do
{
- retval = tolower (*string1) - (length2 ? tolower (*string2) : '\0');
- } while (! retval && *string1++ && (string2++, length2--));
+ retval = tolower (*string1) - (last2 ? tolower (*string2) : '\0');
+ } while (! retval && *string1++ && (string2++, last2--));
return (retval);
}