aboutsummaryrefslogtreecommitdiff
path: root/libgcobol/valconv.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libgcobol/valconv.cc')
-rw-r--r--libgcobol/valconv.cc30
1 files changed, 16 insertions, 14 deletions
diff --git a/libgcobol/valconv.cc b/libgcobol/valconv.cc
index 0b80d72..aaa89f5 100644
--- a/libgcobol/valconv.cc
+++ b/libgcobol/valconv.cc
@@ -29,11 +29,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
+#include <cctype>
+#include <cstdio>
+#include <cstring>
+
#include <algorithm>
#include <unordered_map>
+#include <vector>
#include "ec.h"
#include "common-defs.h"
@@ -67,9 +69,9 @@ __gg__realloc_if_necessary(char **dest, size_t *dest_size, size_t new_size)
new_size |= new_size>>4;
new_size |= new_size>>8;
new_size |= new_size>>16;
- new_size |= new_size>>32;
+ new_size |= (new_size>>16)>>16;
*dest_size = new_size + 1;
- *dest = (char *)realloc(*dest, *dest_size);
+ *dest = static_cast<char *>(realloc(*dest, *dest_size));
}
}
@@ -77,7 +79,7 @@ extern "C"
void
__gg__alphabet_create( cbl_encoding_t encoding,
size_t alphabet_index,
- unsigned char *alphabet,
+ const unsigned char *alphabet,
int low_char,
int high_char )
{
@@ -220,7 +222,7 @@ Rindex(const char *dest, int length, char ch)
extern "C"
bool
__gg__string_to_numeric_edited( char * const dest,
- char *source, // In source characters
+ const char *source, // In source characters
int rdigits,
int is_negative,
const char *picture)
@@ -252,8 +254,8 @@ __gg__string_to_numeric_edited( char * const dest,
if( dlength >= 2 )
{
// It's a positive number, so we might have to get rid of a CR or DB:
- char ch1 = toupper(dest[dlength-2]);
- char ch2 = toupper(dest[dlength-1]);
+ char ch1 = toupper((unsigned char)dest[dlength-2]);
+ char ch2 = toupper((unsigned char)dest[dlength-1]);
if( (ch1 == ascii_D && ch2 == ascii_B)
|| (ch1 == ascii_C && ch2 == ascii_R) )
{
@@ -853,14 +855,14 @@ got_float:
}
else
{
- const char *decimal_location = index(dest, __gg__decimal_point);
+ const char *decimal_location = strchr(dest, __gg__decimal_point);
if( !decimal_location )
{
- decimal_location = index(dest, ascii_v);
+ decimal_location = strchr(dest, ascii_v);
}
if( !decimal_location )
{
- decimal_location = index(dest, ascii_V);
+ decimal_location = strchr(dest, ascii_V);
}
if( !decimal_location )
{
@@ -1220,9 +1222,9 @@ got_float:
extern "C"
void
__gg__string_to_alpha_edited( char *dest,
- char *source,
+ const char *source,
int slength,
- char *picture)
+ const char *picture)
{
// Put the PICTURE into the data area. If the caller didn't leave enough
// room, well, poo on them. Said another way; if they specify disaster,