Changeset 269580c for lib


Ignore:
Timestamp:
2014-07-24T03:51:07Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
59e66ff
Parents:
1783ab6
Message:

Add limit param to split_command_parts(), fix twitter quotes bug

Only took me a few months to write. I even added a test case.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    r1783ab6 r269580c  
    682682   white\ space in 'various ways'. Returns a NULL-terminated static
    683683   char** so watch out with nested use! Definitely not thread-safe. */
    684 char **split_command_parts( char *command )
     684char **split_command_parts( char *command, int limit )
    685685{
    686686        static char *cmd[IRC_MAX_ARGS+1];
     
    692692        k = 1;
    693693        for( s = command; *s && k < IRC_MAX_ARGS; s ++ )
     694        {
    694695                if( *s == ' ' && !q )
    695696                {
    696697                        *s = 0;
    697698                        while( *++s == ' ' );
    698                         if( *s == '"' || *s == '\'' )
     699                        if( k != limit && (*s == '"' || *s == '\'') )
    699700                        {
    700701                                q = *s;
     
    704705                        {
    705706                                cmd[k++] = s;
     707                                if (limit && k > limit) {
     708                                        break;
     709                                }
    706710                                s --;
    707711                        }
     
    722726                        q = *s = 0;
    723727                }
     728        }
    724729       
    725730        /* Full zero-padding for easier argc checking. */
  • lib/misc.h

    r1783ab6 r269580c  
    6767G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl );
    6868G_MODULE_EXPORT int md5_verify_password( char *password, char *hash );
    69 G_MODULE_EXPORT char **split_command_parts( char *command );
     69G_MODULE_EXPORT char **split_command_parts( char *command, int limit );
    7070G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len );
    7171
Note: See TracChangeset for help on using the changeset viewer.