Deutsch   English   Français   Italiano  
<vhngoi$2p6$1@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: Thu, 21 Nov 2024 14:40:18 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <vhngoi$2p6$1@reader2.panix.com>
References: <uu54la$3su5b$6@dont-email.me> <vhkh94$2oi3$1@dont-email.me> <vhkvpi$5h8v$1@dont-email.me> <875xohbxre.fsf@doppelsaurus.mobileactivedefense.com>
Injection-Date: Thu, 21 Nov 2024 14:40:18 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="2854"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
Bytes: 2020
Lines: 27

In article <875xohbxre.fsf@doppelsaurus.mobileactivedefense.com>,
Rainer Weikusat  <rweikusat@talktalk.net> wrote:
>Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>[...]
>
>> Personally I think that writing bulky procedural stuff for something
>> like [0-9]+ can only be much worse, and that further abbreviations
>> like \d+ are the better direction to go if targeting a good interface.
>> YMMV.
>
>Assuming that p is a pointer to the current position in a string, e is a
>pointer to the end of it (ie, point just past the last byte) and -
>that's important - both are pointers to unsigned quantities, the 'bulky'
>C equivalent of [0-9]+ is
>
>while (p < e && *p - '0' < 10) ++p;
>
>That's not too bad. And it's really a hell lot faster than a
>general-purpose automaton programmed to recognize the same pattern
>(which might not matter most of the time, but sometimes, it does).

It's also not exactly right.  `[0-9]+` would match one or more
characters; this possibly matches 0 (ie, if `p` pointed to
something that wasn't a digit).

	- Dan C.