On Thu, 2025-06-19 at 16:49 +0100, Tim Murphy wrote:
> Hi,
> 
> I've added a couple more functions to this library of loadable C functions
> for  GNU make:
> 
> https://github.com/tnmurphy/extramake
> 
> Regards,
> 
> Tim Murphy
> 
> 
> REGEX - Regular Expression Matching
> ================================
> 
> -load regex.mk
> HANDLE:=$(regcomp, String(.*))
> MATCH1:=$(regexec $(HANDLE),String123)
> MATCH2:=$(regexec $(HANDLE),String)
> 
> $(info MATCH1=$(MATCH1))
> $(info MATCH2=$(MATCH2))
> 
> 
> The result would be
> 
> MATCH1=String123 123
> MATCH2=String
> These functions use the glibc regcomp and regexec functions to do regexp
> matching so they will build wherever you have glibc.  I wondered about
> finding some more generic library where I could include a copy like with
> siphash24 but so far I haven't found one and I thought this wasn't such a
> terrible compromise.
> 
> PROBLEMS:
> There's no way to set compile flags or exec flags yet - that can be fixed
> with a bit of dull work.
> There's some debugging code but no good error messages for regex
> compilation at least.
> 
> The big problem is that there's a limit to the number of regexps one can
> create 

On current Linux computers (with gigabytes of RAM) this is practically not
important, as long as each regex has been human written (not machne generated) 

> and I really don't want to implement some kind of "regexp free"
> function to release the resources used by the regexp.
> I could compile and execute the regexp in one function and deal with it
> that way ......but it does seem very inefficient.  At the moment I just
> have an array of regex_t structures and regcomp returns
> an index into it. That's pretty ugly but it seems relatively efficient.
> I'd love to hear thoughts on this whole issue.
> 
> 
> MKDIR - Directory Creation
> =======================
> 
> $(mkdir  /makes/all/paths/upto/and/includingthe/last)
> 
> This is like mkdir -p at the commandline. The idea is for one to be able to
> make directories before any rules get executed. WHY? Ha well. Directories
> are a nuisance because they get updated when you add a file to them so they
> cannot be used to trigger a rule because they change a lot even when it
> doesn't matter to you. So you can use order-only rules etc but sometimes
> it's just neater to make the output directory as part of a macro.
> 
> 
> The existing ones are all there too:
> 
> * $(equals x,y) tests string equality. Returns empty if the 2 parameters
> don't match or the value if they do.
>   * e.g. `FILENAME=file.$(if $(equals $(compression_level),0),tar,.tar.bz3)`
> * $(siphash24 text[,key]) returns a 16 character hash of the input text, an
> optional key can be used to make the whole thing cryptographic.
> * $(strlen <string>) returns the number of characters in <string>
> * $(sum <number> <number> .... <number> )  finds the sum of a list of
> integers. Negative integers are allowed.  Any non-numeric characters will
> cause the empty string to be returned.
> * $(mul <n> <n> <n>) returns the result of multiplying a list of numbers.
> Overflow can occur. The platform's "long long" is used.
> * $(lt x,y) returns 1 if x < y for integers x and y, empty string otherwise.
> * $(lte x,y) returns 1 if x <= y for integers x and y, empty string
> otherwise.
> * $(gt x,y) returns 1 if x >= y for integers x and y, empty string
> otherwise.
> * $(gte x,y) returns 1 if x >= y for integers x and y, empty string
> otherwise.
> * $(mkdir /path/to/dir)  makes all directories up to and including "dir".
> Returns as much of the path as could be made or empty if no path could be
> made e.g. if the root doesn't exist.
> 
> On Mon, 9 Nov 2015 at 22:45, Tim Murphy <[email protected]> wrote:
> 
> > 
> > 
> > Hi,
> > 
> > I'd just like to mention that the extramake module library that I
> > mentioned some days ago now has a few new useful functions.
> > 
> > https://bitbucket.org/tnmurphy/extramake
> > 
> > $(sum <number> <number> .... <number> )
> >    finds the sum of a list of integers. Negative integers are allowed. Any
> > non-numeric characters will cause the empty string to be returned.
> > 
> > $(mul <n> <n> <n>)
> >   returns the result of multiplying a list of numbers. Overflow can occur.
> > The platform's "long long" is used. Negative numbers are ok.
> > 
> > $(lt x,y)
> >   returns 1 if x < y for integers x and y, empty string otherwise.
> > 
> > $(lte x,y)
> >   returns 1 if x <= y for integers x and y, empty string otherwise.
> > 
> > $(gt x,y)
> >   returns 1 if x >= y for integers x and y, empty string otherwise.
> > 
> > $(gte x,y)
> >   returns 1 if x >= y for integers x and y, empty string otherwise.
> > 
> > I am sorry to offend by adding possibly undesired numerical comparison
> > functions etc but I needed them once (trying to make sure commandlines
> > would fit the restrictions of the shell) so here they are to be ignored or
> > not as you wish.
> > 
> > I've been trying to add things that don't require a lot of fancy memory
> > allocation or any other complications but the things I'm thinking about
> > next are:


Fancy memory allocation could use garbage collectors like Boehm's one or even
https://github.com/bstarynk/qish-gc (perhaps suitably improved, see
http://starynkevitch.net/basile/qishintro.html ...)
> > 
> > reduce - as in lisp
> > map  - as in lisp
> > find - finding files under a path.
> > mkdir - make directories (like mkdir -p) which can be important as a
> > companion to the $(file) function if you want to write a file to a specific
> > directory.
> > 
> > 
> > I'd love to know if there's anything else that might be wanted.  Criticism
> > would be welcome too.

I like your ideas. I hope that in a year they would be incorporated in GNU make
(without using GNU make loading
objects https://www.gnu.org/software/make/manual/html_node/Loading-Objects.html
facilities) or at least that most Linux distributions would package GNU make
with standard loadable object implementing them.

Bravo for your work! Don't forget to document it.

Regards.
-- 
Basile STARYNKEVITCH                            <[email protected]>
8 rue de la Faïencerie                       http://starynkevitch.net/Basile/  
92340 Bourg-la-Reine                         https://github.com/bstarynk
France                                https://github.com/RefPerSys/RefPerSys

Reply via email to