8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 18:03:04 +01:00

Commit fix from Stephen Boyd for his RMCOBOL interface library.

This commit is contained in:
robocop 2007-08-29 10:02:42 +00:00
parent f1c264cfe4
commit 64bfb9e026

View File

@ -1521,7 +1521,7 @@ EXPORT RM_ENTRY(rmc_ftoc)
// Convert a Cobol alpha (PIC X) field to a C string. This is done by trimming trailing spaces // Convert a Cobol alpha (PIC X) field to a C string. This is done by trimming trailing spaces
// and adding the trailing '\0'. // and adding the trailing '\0'.
EXPORT RM_ENTRY(rmc_ctos) EXPORT RM_ENTRY(rmc_stoc)
{ {
char* dest = (char*) arg_vector[-1].a_address; char* dest = (char*) arg_vector[-1].a_address;
const int dlen = arg_vector[-1].a_length; const int dlen = arg_vector[-1].a_length;
@ -1531,7 +1531,7 @@ EXPORT RM_ENTRY(rmc_ctos)
int i = slen - 1; int i = slen - 1;
while (src[i] == ' ' && i >= 0) while (src[i] == ' ' && i >= 0)
--i; --i;
int len = ((i + 1) < dlen) ? i + 1 : dlen - 1; int len = ((i + 1) < dlen) ? i + 1 : dlen - 1;
memmove(dest, src, len); memmove(dest, src, len);
dest[len] = '\0'; dest[len] = '\0';
@ -1541,12 +1541,12 @@ EXPORT RM_ENTRY(rmc_ctos)
// Convert a C string to a Cobol alpha (PIC X) field. This is done by copying the original // Convert a C string to a Cobol alpha (PIC X) field. This is done by copying the original
// string and padding on the right with spaces. // string and padding on the right with spaces.
EXPORT RM_ENTRY(rmc_stoc) EXPORT RM_ENTRY(rmc_ctos)
{ {
char* dest = (char*) arg_vector[-1].a_address; char* dest = (char*) arg_vector[-1].a_address;
const int dlen = arg_vector[-1].a_length; const int dlen = arg_vector[-1].a_length;
const char* src = (char*) arg_vector[0].a_address; const char* src = (char*) arg_vector[0].a_address;
const int slen = arg_vector[0].a_length; const int slen = strlen(src);
memset(dest, ' ', dlen); memset(dest, ' ', dlen);
int len = (slen <= dlen) ? slen : dlen; int len = (slen <= dlen) ? slen : dlen;
@ -1554,10 +1554,8 @@ EXPORT RM_ENTRY(rmc_stoc)
return (0); return (0);
} }
static char* banner = "Firebird Embedded SQL Interface"; static char* banner = "Firebird Embedded SQL Interface";
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif