OpenCOBOL 1.1pre-rel
|
#include <libcob/common.h>
Go to the source code of this file.
Functions | |
void | cob_inspect_init (cob_field *, const int) |
void | cob_inspect_start (void) |
void | cob_inspect_before (const cob_field *) |
void | cob_inspect_after (const cob_field *) |
void | cob_inspect_characters (cob_field *) |
void | cob_inspect_all (cob_field *, cob_field *) |
void | cob_inspect_leading (cob_field *, cob_field *) |
void | cob_inspect_first (cob_field *, cob_field *) |
void | cob_inspect_trailing (cob_field *, cob_field *) |
void | cob_inspect_converting (cob_field *, cob_field *) |
void | cob_inspect_finish (void) |
void | cob_string_init (cob_field *, cob_field *) |
void | cob_string_delimited (cob_field *) |
void | cob_string_append (cob_field *) |
void | cob_string_finish (void) |
void | cob_unstring_init (cob_field *, cob_field *, const size_t) |
void | cob_unstring_delimited (cob_field *, const int) |
void | cob_unstring_into (cob_field *, cob_field *, cob_field *) |
void | cob_unstring_tallying (cob_field *) |
void | cob_unstring_finish (void) |
void cob_inspect_after | ( | const cob_field * | ) |
Definition at line 297 of file strings.c.
{ inspect_common (f1, f2, INSPECT_ALL); }
void cob_inspect_before | ( | const cob_field * | ) |
void cob_inspect_characters | ( | cob_field * | ) |
Definition at line 265 of file strings.c.
{ int *mark; int i; int n; int len; mark = &inspect_mark[inspect_start - inspect_data]; len = (int)(inspect_end - inspect_start); if (inspect_replacing) { /* INSPECT REPLACING CHARACTERS f1 */ for (i = 0; i < len; i++) { if (mark[i] == -1) { mark[i] = f1->data[0]; } } } else { /* INSPECT TALLYING f1 CHARACTERS */ n = 0; for (i = 0; i < len; i++) { if (mark[i] == -1) { mark[i] = 1; n++; } } if (n > 0) { cob_add_int (f1, n); } } }
void cob_inspect_finish | ( | void | ) |
Definition at line 339 of file strings.c.
{ size_t i; if (inspect_replacing) { for (i = 0; i < inspect_size; i++) { if (inspect_mark[i] != -1) { inspect_data[i] = inspect_mark[i]; } } } cob_put_sign (inspect_var, inspect_sign); }
Definition at line 309 of file strings.c.
{ inspect_common (f1, f2, INSPECT_FIRST); }
void cob_inspect_init | ( | cob_field * | , |
const int | |||
) |
Definition at line 205 of file strings.c.
{ size_t i; size_t digcount; inspect_var_copy = *var; inspect_var = &inspect_var_copy; inspect_replacing = replacing; inspect_sign = cob_get_sign (var); inspect_size = COB_FIELD_SIZE (var); inspect_data = COB_FIELD_DATA (var); inspect_start = NULL; inspect_end = NULL; digcount = inspect_size * sizeof (int); if (digcount > lastsize) { free (inspect_mark); inspect_mark = cob_malloc (digcount); lastsize = digcount; } for (i = 0; i < inspect_size; i++) { inspect_mark[i] = -1; } cob_exception_code = 0; }
Definition at line 303 of file strings.c.
{ inspect_common (f1, f2, INSPECT_LEADING); }
void cob_inspect_start | ( | void | ) |
Definition at line 315 of file strings.c.
{ inspect_common (f1, f2, INSPECT_TRAILING); }
void cob_string_append | ( | cob_field * | ) |
Definition at line 390 of file strings.c.
{ size_t src_size; int i; int size; if (cob_exception_code) { return; } src_size = src->size; if (string_dlm) { size = (int)(src_size - string_dlm->size + 1); for (i = 0; i < size; i++) { if (memcmp (src->data + i, string_dlm->data, string_dlm->size) == 0) { src_size = i; break; } } } if (src_size <= string_dst->size - string_offset) { memcpy (string_dst->data + string_offset, src->data, src_size); string_offset += (int) src_size; } else { size = (int)(string_dst->size - string_offset); memcpy (string_dst->data + string_offset, src->data, (size_t)size); string_offset += size; cob_set_exception (COB_EC_OVERFLOW_STRING); } }
void cob_string_delimited | ( | cob_field * | ) |
void cob_string_finish | ( | void | ) |
Definition at line 423 of file strings.c.
{ if (string_ptr) { cob_set_int (string_ptr, string_offset + 1); } }
Definition at line 359 of file strings.c.
{ string_dst_copy = *dst; string_dst = &string_dst_copy; string_ptr = NULL; if (ptr) { string_ptr_copy = *ptr; string_ptr = &string_ptr_copy; } string_offset = 0; cob_exception_code = 0; if (string_ptr) { string_offset = cob_get_int (string_ptr) - 1; if (string_offset < 0 || string_offset >= (int)string_dst->size) { cob_set_exception (COB_EC_OVERFLOW_STRING); } } }
void cob_unstring_delimited | ( | cob_field * | , |
const int | |||
) |
void cob_unstring_finish | ( | void | ) |
Definition at line 581 of file strings.c.
{ if (unstring_offset < (int)unstring_src->size) { cob_set_exception (COB_EC_OVERFLOW_UNSTRING); } if (unstring_ptr) { cob_set_int (unstring_ptr, unstring_offset + 1); } }
Definition at line 435 of file strings.c.
{ static size_t udlmcount = 0; unstring_src_copy = *src; unstring_src = &unstring_src_copy; unstring_ptr = NULL; if (ptr) { unstring_ptr_copy = *ptr; unstring_ptr = &unstring_ptr_copy; } unstring_offset = 0; unstring_count = 0; unstring_ndlms = 0; cob_exception_code = 0; if (!dlm_list) { if (num_dlm <= DLM_DEFAULT_NUM) { dlm_list = cob_malloc (DLM_DEFAULT_NUM * sizeof(struct dlm_struct)); udlmcount = DLM_DEFAULT_NUM; } else { dlm_list = cob_malloc (num_dlm * sizeof(struct dlm_struct)); udlmcount = num_dlm; } } else { if (num_dlm > udlmcount) { free (dlm_list); dlm_list = cob_malloc (num_dlm * sizeof(struct dlm_struct)); udlmcount = num_dlm; } } if (unstring_ptr) { unstring_offset = cob_get_int (unstring_ptr) - 1; if (unstring_offset < 0 || unstring_offset >= (int)unstring_src->size) { cob_set_exception (COB_EC_OVERFLOW_UNSTRING); } } }
Definition at line 484 of file strings.c.
{ unsigned char *p; unsigned char *dp; unsigned char *s; unsigned char *dlm_data; unsigned char *start; size_t dlm_size = 0; int i; int srsize; int dlsize; int match_size = 0; int brkpt = 0; if (cob_exception_code) { return; } if (unstring_offset >= (int)unstring_src->size) { return; } start = unstring_src->data + unstring_offset; dlm_data = NULL; if (unstring_ndlms == 0) { match_size = cob_min_int ((int)COB_FIELD_SIZE (dst), (int)unstring_src->size - unstring_offset); cob_memcpy (dst, start, match_size); unstring_offset += match_size; } else { srsize = (int) unstring_src->size; s = unstring_src->data + srsize; for (p = start; p < s; p++) { for (i = 0; i < unstring_ndlms; i++) { dlsize = (int) dlm_list[i].uns_dlm->size; dp = dlm_list[i].uns_dlm->data; if (p + dlsize > s) { break; } if (!memcmp (p, dp, (size_t)dlsize)) { match_size = (int)(p - start); cob_memcpy (dst, start, match_size); unstring_offset += match_size + dlsize; dlm_data = dp; dlm_size = dlsize; if (dlm_list[i].uns_all) { for (p++ ; p < s; p++) { if (p + dlsize > s) { break; } if (memcmp (p, dp, (size_t)dlsize)) { break; } unstring_offset += dlsize; } } brkpt = 1; break; } } if (brkpt) { break; } } if (!brkpt) { /* no match */ match_size = (int)(unstring_src->size - unstring_offset); cob_memcpy (dst, start, match_size); unstring_offset = (int) unstring_src->size; dlm_data = NULL; } } unstring_count++; if (dlm) { if (dlm_data) { cob_memcpy (dlm, dlm_data, (int) dlm_size); } else if (COB_FIELD_IS_NUMERIC (dlm)) { cob_move (&cob_zero, dlm); } else { cob_move (&cob_space, dlm); } } if (cnt) { cob_set_int (cnt, match_size); } }
void cob_unstring_tallying | ( | cob_field * | ) |
Definition at line 575 of file strings.c.
{ cob_add_int (f, unstring_count); }