Changeset 3585c395094f5bfb81cc277357241402628e4f45

Show
Ignore:
Timestamp:
12/05/04 19:45:18 (5 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1084383918 +0000
git-parent:

[eeb51429199c125ab84cada93d0a0b4d4c2e194c]

git-author:
Gildas Bazin <gbazin@videolan.org> 1084383918 +0000
Message:

* src/stream_output/stream_output.c: allows spaces in the options of the sout mrl. Heading and trailing spaces in options will be removed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stream_output/stream_output.c

    reeb5142 r3585c39  
    711711 */ 
    712712#define SKIPSPACE( p ) { while( *p && ( *p == ' ' || *p == '\t' ) ) p++; } 
     713#define SKIPTRAILINGSPACE( p, e ) \ 
     714    { while( e > p && ( *(e-1) == ' ' || *(e-1) == '\t' ) ) e--; } 
     715 
    713716/* go accross " " and { } */ 
    714717static char *_get_chain_end( char *str ) 
    715718{ 
    716     char *p = str; 
     719    char c, *p = str; 
    717720 
    718721    SKIPSPACE( p ); 
     
    720723    for( ;; ) 
    721724    { 
    722         if( *p == '{' || *p == '"' || *p == '\'') 
    723         { 
    724             char c; 
    725  
    726             if( *p == '{' ) 
    727             { 
    728                 c = '}'; 
    729             } 
    730             else 
    731             { 
    732                 c = *p; 
    733             } 
     725        if( !*p || *p == ',' || *p == '}' ) return p; 
     726 
     727        if( *p != '{' && *p != '"' && *p != '\'' ) 
     728        { 
    734729            p++; 
    735  
    736             for( ;; ) 
    737             { 
    738                 if( *p == '\0' ) 
    739                 { 
    740                     return p; 
    741                 } 
    742  
    743                 if( *p == c ) 
    744                 { 
    745                     p++; 
    746                     return p; 
    747                 } 
    748                 else if( *p == '{' && c == '}' ) 
    749                 { 
    750                     p = _get_chain_end( p ); 
    751                 } 
    752                 else 
    753                 { 
    754                     p++; 
    755                 } 
    756             } 
    757         } 
    758         else if( *p == '\0' || *p == ',' || *p == '}' || 
    759                  *p == ' ' || *p == '\t' ) 
    760         { 
    761             return p; 
    762         } 
    763         else 
    764         { 
    765             p++; 
     730            continue; 
     731        } 
     732 
     733        if( *p == '{' ) c = '}'; 
     734        else c = *p; 
     735        p++; 
     736 
     737        for( ;; ) 
     738        { 
     739            if( !*p ) return p; 
     740 
     741            if( *p == c ) return ++p; 
     742            else if( *p == '{' && c == '}' ) p = _get_chain_end( p ); 
     743            else p++; 
    766744        } 
    767745    } 
     
    830808                else 
    831809                { 
    832                     if( *p == '\'' || *p =='"' || 
     810                    /* Skip heading and trailing spaces. 
     811                     * This ain't necessary but will avoid simple 
     812                     * user mistakes. */ 
     813                    SKIPSPACE( p ); 
     814                } 
     815 
     816                if( end <= p ) 
     817                { 
     818                    cfg.psz_value = NULL; 
     819                } 
     820                else 
     821                { 
     822                    if( *p == '\'' || *p == '"' || 
    833823                        ( !b_keep_brackets && *p == '{' ) ) 
    834824                    { 
    835825                        p++; 
    836                         end--; 
     826 
     827                        if( *(end-1) != '\'' && *(end-1) == '"' ) 
     828                            SKIPTRAILINGSPACE( p, end ); 
     829 
     830                        if( end - 1 <= p ) cfg.psz_value = NULL; 
     831                        else cfg.psz_value = strndup( p, end -1 - p ); 
    837832                    } 
    838                     if( end <= p ) cfg.psz_value = NULL; 
    839                     else cfg.psz_value = strndup( p, end - p ); 
     833                    else 
     834                    { 
     835                        SKIPTRAILINGSPACE( p, end ); 
     836                        if( end <= p ) cfg.psz_value = NULL; 
     837                        else cfg.psz_value = strndup( p, end - p ); 
     838                    } 
    840839                } 
    841840