mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-21 01:04:10 +08:00
[svn-r7642] Purpose:
Code cleanup Description: Remove unused 'HD5c2fstr' routine and clean up coding for other routines. Platforms tested: h5committest
This commit is contained in:
parent
6a516752c7
commit
a467184280
@ -21,36 +21,10 @@
|
|||||||
/*
|
/*
|
||||||
* Routines from HDF4 to deal with C-FORTRAN issues.
|
* Routines from HDF4 to deal with C-FORTRAN issues.
|
||||||
*
|
*
|
||||||
* HD5c2fstr -- convert a C string into a Fortran string IN PLACE
|
|
||||||
* HD5f2cstring -- convert a Fortran string to a C string
|
* HD5f2cstring -- convert a Fortran string to a C string
|
||||||
|
* HD5packFstring -- convert a C string into a Fortran string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ------------------------------- HDc2fstr -------------------------------
|
|
||||||
NAME
|
|
||||||
HD5c2fstr -- convert a C string into a Fortran string IN PLACE
|
|
||||||
USAGE
|
|
||||||
int HD5c2fstr(str, len)
|
|
||||||
char * str; IN: string to convert
|
|
||||||
int len; IN: length of Fortran string
|
|
||||||
RETURNS
|
|
||||||
SUCCEED
|
|
||||||
DESCRIPTION
|
|
||||||
Change a C string (NULL terminated) into a Fortran string.
|
|
||||||
Basically, all that is done is that the NULL is ripped out
|
|
||||||
and the string is padded with spaces
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
|
||||||
int
|
|
||||||
HD5c2fstr(char *str, int len)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
i=(int)HDstrlen(str);
|
|
||||||
for (; i < len; i++)
|
|
||||||
str[i] = ' ';
|
|
||||||
return 0;
|
|
||||||
} /* HD5c2fstr */
|
|
||||||
|
|
||||||
/* ----------------------------- HDf2cstring ------------------------------ */
|
/* ----------------------------- HDf2cstring ------------------------------ */
|
||||||
/*
|
/*
|
||||||
NAME
|
NAME
|
||||||
@ -68,20 +42,27 @@ DESCRIPTION
|
|||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
char *
|
char *
|
||||||
HD5f2cstring(_fcd fdesc, int len)
|
HD5f2cstring(_fcd fdesc, size_t len)
|
||||||
{
|
{
|
||||||
char *cstr = NULL;
|
char *cstr; /* C string to return */
|
||||||
char *str;
|
char *str; /* Pointer to FORTRAN string */
|
||||||
int i;
|
int i; /* Local index variable */
|
||||||
|
|
||||||
|
/* Search for the end of the string */
|
||||||
str = _fcdtocp(fdesc);
|
str = _fcdtocp(fdesc);
|
||||||
/* This should be equivalent to the above test -QAK */
|
for(i=(int)len-1; i>=0 && !isgraph((int)str[i]); i--)
|
||||||
for(i=len-1; i>=0 && !isgraph((int)str[i]); i--)
|
|
||||||
/*EMPTY*/;
|
/*EMPTY*/;
|
||||||
cstr = (char *) HDmalloc( (size_t)(i + 2));
|
|
||||||
if (cstr == NULL) return NULL;
|
/* Allocate C string */
|
||||||
cstr[i + 1] = '\0';
|
if ((cstr = HDmalloc( (size_t)(i + 2))) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Copy text from FORTRAN to C string */
|
||||||
HDmemcpy(cstr,str,(size_t)(i+1));
|
HDmemcpy(cstr,str,(size_t)(i+1));
|
||||||
|
|
||||||
|
/* Terminate C string */
|
||||||
|
cstr[i + 1] = '\0';
|
||||||
|
|
||||||
return cstr;
|
return cstr;
|
||||||
} /* HD5f2cstring */
|
} /* HD5f2cstring */
|
||||||
|
|
||||||
@ -105,17 +86,17 @@ DESCRIPTION
|
|||||||
support one of these.
|
support one of these.
|
||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
int
|
void
|
||||||
HD5packFstring(char *src, char *dest, int len)
|
HD5packFstring(char *src, char *dest, size_t dst_len)
|
||||||
{
|
{
|
||||||
int sofar;
|
size_t src_len=HDstrlen(src);
|
||||||
|
|
||||||
for (sofar = 0; (sofar < len) && (*src != '\0'); sofar++)
|
/* Copy over the string information, up to the length of the src */
|
||||||
*dest++ = *src++;
|
/* (Don't copy the NUL terminator from the C string to the FORTRAN string */
|
||||||
|
HDmemcpy(dest,src,MIN(src_len,dst_len));
|
||||||
|
|
||||||
while (sofar++ < len)
|
/* Pad out any remaining space in the FORTRAN string with ' 's */
|
||||||
*dest++ = ' ';
|
if(src_len<dst_len)
|
||||||
|
HDmemset(&dest[src_len],' ',dst_len-src_len);
|
||||||
return 0;
|
} /* HD5packFstring */
|
||||||
} /* HD5packFstring */
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user