src/grib_dumper_class_bufr_encode_fortran.c
/* Some lines can grow longer than Fortran compilers allow (=132). */
/* This is mainly due to long key names with attributes. */
/* The resturn value of this function must be freed by the caller */
Some lines can grow longer than Fortran compilers allow (=132).
This is mainly due to long key names with attributes.
The resturn value of this function must be freed by the caller
Some lines can grow longer than Fortran compilers allow ( = 132 ) . This is mainly due to long key names with attributes . The resturn value of this function must be freed by the caller
static char* break_line(grib_context* c, const char* input)
{
    char* a_token    = NULL;
    int first        = 1;
    const size_t len = strlen(input);
    char* result = (char*)grib_context_malloc_clear(c, sizeof(char) * len + 100);
    if (len < 70 || strchr(input, '\n')) {
        strcpy(result, input);
        return result;
    }
    a_token = strtok((char*)input, "->");
    while (a_token) {
        if (first) {
            first = 0;
            strcat(result, a_token);
        }
        else {
            char tmp[256] = {0,};
            sprintf(tmp, "->&\n    &%s", a_token);
            strcat(result, tmp);
        }
        a_token = strtok(NULL, "->");
    }
    return result;
}
static char * break_line ( grib_context * c , const char * input ) { char * a_token = NULL ; int first = 1 ; const size_t len = strlen ( input ) ; char * result = ( char * ) grib_context_malloc_clear ( c , sizeof ( char ) * len + 100 ) ; if ( len < 70 || strchr ( input , ' \n ' ) ) { strcpy ( result , input ) ; return result ; } a_token = strtok ( ( char * ) input , " " ) ; while ( a_token ) { if ( first ) { first = 0 ; strcat ( result , a_token ) ; } else { char tmp [ 256 ] = { 0 , } ; sprintf ( tmp , " \n " , a_token ) ; strcat ( result , tmp ) ; } a_token = strtok ( NULL , " " ) ; } return result ; }
Some lines can grow longer than Fortran compilers allow (=132).
Some lines can grow longer than Fortran compilers allow ( = 132 ) .
/* Break a long line using Fortran continuation characters */ /* Add a bit more for inserted newlines and continuation characters */ /* No need to alter input which is already too short or has newlines */ /* A Fortran multi-line string has two ampersands. E.g. */ /* 'hello &
     * &world'  is the same as 'hello world'
     */