[FFmpeg-devel] [PATCH] Implement number parsing functions in cmdutils.c
Stefano Sabatini
stefano.sabatini-lala
Fri Feb 22 09:20:09 CET 2008
On date Thursday 2008-02-21 13:25:04 +0100, Michael Niedermayer encoded:
> On Thu, Feb 21, 2008 at 09:34:51AM +0100, Stefano Sabatini wrote:
> [...]
> > +long long int parse_integer_or_die(const char *context, const char *numstr, long long int min, long long int max)
> > +{
> > + long long int lli;
> > + char *tail;
> > +
> > + /* errno could have been set by previous library calls, so reset it */
> > + errno = 0;
> > + lli = strtoll(numstr, &tail, 10);
> > + if (*tail) {
> > + fprintf(stderr, "Expected integer for %s but found: %s\n", context, numstr);
> > + exit(1);
> > + } else if (errno == ERANGE || lli < min || lli > max) {
> > + fprintf(stderr, "The value for %s must be >= %lld and <= %lld but you used: %s\n",
> > + context, min, max, numstr);
> > + exit(1);
> > + }
> > + return lli;
> > +}
> > +
> > +double parse_double_or_die(const char *context, const char *numstr, double min, double max)
> > +{
> > + double d;
> > + char *tail;
> > +
> > + /* errno could have been set by previous library calls, so reset it */
> > + errno = 0;
> > + d = strtod(numstr, &tail);
> > + if (*tail) {
> > + fprintf(stderr, "Expected double for %s but found: %s\n", context, numstr);
> > + exit(1);
> > + } else if (errno == ERANGE || isnan(d) || d < min || d > max) {
> > + fprintf(stderr, "The value for %s must be >= %f and <= %f but you used: %s\n",
> > + context, min, max, numstr);
> > + exit(1);
> > + }
> > + return d;
> > +}
>
> commited something simpler
Thanks Michael, I'll be busy for some time, I'll try to send the
following patches (parameters commandline checks) for the end of the
next week.
Best regards
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
More information about the ffmpeg-devel
mailing list