Ticket #406 (new wishlist)

Opened 8 years ago

upgrade k_its() in kom.c

Reported by: baker Owned by: somebody
Priority: minor Milestone: All Platforms
Component: ALL modules Version: 7.8
Keywords: kom.c Cc:

Description

There are two versions of kom.c: src/libsrc/util/kom.c and src/seismic_processing/glass/src/modules/EarthWorm/kom.c.

I suppose the first task would be to try to reduce that to one.

This wishlist is to upgrade k_its():

/*
 * k_its : Compare string from last token to given command.
 */
int k_its(char *c)
{
        char *s;

        s = &com.crd[com.istr];
        while(*c == *s) {
                if(*s == '\0')
                        return(1);
                c++;
                s++;
        }
        return(0);
}

The passed string should be a const char *. When I add the const attribute to the array of string pointers used to call k_its(), I get warnings about passing a const char * to a char *. Also, why is it not using strcmp()? In which case, k_its() could simply be:

/*
 * k_its : Compare string from last token to given command.
 */
int k_its( const char *s1 )
{
        return ( strcmp( s1, com.crd[com.istr] ) == 0 );
}

There are several other functions in kom.c that should have their char * parameters converted to const char *.

Note: See TracTickets for help on using tickets.