delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2011/10/17/16:00:07

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: RayeR <glaux AT centrum DOT cz>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: I need strtok_r() function
Date: Mon, 17 Oct 2011 12:39:00 -0700 (PDT)
Organization: http://groups.google.com
Lines: 62
Message-ID: <3533b2fa-8962-47c1-a6a8-373cc0e8a1f3@g7g2000vbv.googlegroups.com>
References: <bf04ff58-89d4-46fe-aaf4-ad5a07eaf8ff AT k35g2000yqh DOT googlegroups DOT com>
<8339erwjdk DOT fsf AT gnu DOT org>
NNTP-Posting-Host: 90.181.199.10
Mime-Version: 1.0
X-Trace: posting.google.com 1318880457 5791 127.0.0.1 (17 Oct 2011 19:40:57 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Mon, 17 Oct 2011 19:40:57 +0000 (UTC)
Complaints-To: groups-abuse AT google DOT com
Injection-Info: g7g2000vbv.googlegroups.com; posting-host=90.181.199.10; posting-account=Q0wMHAoAAADjYrghh94FTf6YnbpTqZgp
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: HUALESNKRC
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.19)
Gecko/20110420 SeaMonkey/2.0.14,gzip(gfe)
Bytes: 3019
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id p9HK01Oq002985
Reply-To: djgpp AT delorie DOT com

> Just use strtok.  There are no reentrancy issues with DJGPP, since
> it's all single-threaded.

OK, but
char *strtok(char *_s1, const char *_s2);
has only 2 arguments. The 3rd argument is described:
s3 is a value-return parameter used by strtok_r() to record its
progress through s1.

I'm not sure if I could safely delete s3 in function call.

case1
[code]
    OPT("asm")
    {
        p->cpu = isdigit(value[0]) ? atoi(value) :
                 !strcmp(value, "auto") || atobool(value) ?
x264_cpu_detect() : 0;
        if( b_error )
        {
            char *buf = strdup(value);
            char *tok, UNUSED *saveptr=NULL, *init;
            b_error = 0;
            p->cpu = 0;
            for( init=buf; (tok=strtok_r(init, ",", &saveptr));
init=NULL )
            {
                for( i=0; x264_cpu_names[i].flags && strcasecmp(tok,
x264_cpu_names[i].name); i++ );
                p->cpu |= x264_cpu_names[i].flags;
                if( !x264_cpu_names[i].flags )
                    b_error = 1;
            }
            free( buf );
            if( p->cpu & X264_CPU_SSSE3 )
                p->cpu |= X264_CPU_SSE2_IS_FAST;
            if( p->cpu & X264_CPU_SSE4 )
                p->cpu |= X264_CPU_SHUFFLE_IS_FAST;
        }
    }
[/code]

case2
[code]
    while( (tok = strtok_r( p, ",", &saveptr )) )
    {
        char *val = strchr( tok, '=' );
        if( val )
        {
            *val = '\0';
            val++;
        }
        if( x264_param_parse( z->param, tok, val ) )
        {
            x264_log( h, X264_LOG_ERROR, "invalid zone param: %s = %s
\n", tok, val );
            return -1;
        }
        p = NULL;
    }

[/code]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019