Deutsch   English   Français   Italiano  
<vhqnbm$7dc$2@reader2.panix.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc
Subject: Re: Command Languages Versus Programming Languages
Date: Fri, 22 Nov 2024 19:51:18 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <vhqnbm$7dc$2@reader2.panix.com>
References: <uu54la$3su5b$6@dont-email.me> <87cyinrt5s.fsf@doppelsaurus.mobileactivedefense.com> <vhql7r$7dv$2@reader2.panix.com> <874j3zrrxs.fsf@doppelsaurus.mobileactivedefense.com>
Injection-Date: Fri, 22 Nov 2024 19:51:18 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="7596"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
Bytes: 3570
Lines: 85

In article <874j3zrrxs.fsf@doppelsaurus.mobileactivedefense.com>,
Rainer Weikusat  <rweikusat@talktalk.net> wrote:
>cross@spitfire.i.gajendra.net (Dan Cross) writes:
>> In article <87cyinrt5s.fsf@doppelsaurus.mobileactivedefense.com>,
>> Rainer Weikusat  <rweikusat@talktalk.net> wrote:
>>>scott@slp53.sl.home (Scott Lurndal) writes:
>>>> Rainer Weikusat <rweikusat@talktalk.net> writes:
>>>
>>>[...]
>>>
>>>>>Something which would match [0-9]+ in its first argument (if any) would
>>>>>be:
>>>>>
>>>>>#include "string.h"
>>>>>#include "stdlib.h"
>>>>>
>>>>>int main(int argc, char **argv)
>>>>>{
>>>>>    char *p;
>>>>>    unsigned c;
>>>>>
>>>>>    p = argv[1];
>>>>>    if (!p) exit(1);
>>>>>    while (c = *p, c && c - '0' > 10) ++p;
>>>>>    if (!c) exit(1);
>>>>>    return 0;
>>>>>}
>>>>>
>>>>>but that's 14 lines of text, 13 of which have absolutely no relation to
>>>>>the problem of recognizing a digit.
>>>>
>>>> Personally, I'd use:
>>>>
>>>> $ cat /tmp/a.c
>>>> #include <stdint.h>
>>>> #include <string.h>
>>>>
>>>> int
>>>> main(int argc, const char **argv)
>>>> {
>>>>     char *cp;
>>>>     uint64_t value;
>>>>
>>>>     if (argc < 2) return 1;
>>>>
>>>>     value = strtoull(argv[1], &cp, 10);
>>>>     if ((cp == argv[1])
>>>>      || (*cp != '\0')) {
>>>>         return 1;
>>>>     }
>>>>    return 0;
>>>> }
>>>
>>>This will accept a string of digits whose numerical value is <=
>>>ULLONG_MAX, ie, it's basically ^[0-9]+$ with unobvious length and
>>>content limits.
>>
>> He acknowledged this already.
>>
>>>return !strstr(argv[1], "0123456789");
>>>
>>>would be a better approximation,
>>
>> No it wouldn't.  That's not even close.  `strstr` looks for an
>> instance of its second argument in its first, not an instance of
>> any character in it's second argument in its first.  Perhaps you
>> meant something with `strspn` or similar.  E.g.,
>>
>>     const char *p = argv[1] + strspn(argv[1], "0123456789");
>>     return *p != '\0';
>
>My bad.

You've made a lot of "bad"s in this thread, and been rude about
it to boot, crying foul when someone's pointed out ways that
your code is deficient; claiming offense at what you perceive as
"snark" while dishing the same out in kind, making basic errors
that show you haven't done the barest minimum of testing, and
making statements that show you have, at best, a limited grasp
on the language you're choosing to use.

I'm done being polite.  My conclusion is that perhaps you are
not as up on these things as you seem to think that you are.

	- Dan C.