sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sed suggestion: sed C API


From: Assaf Gordon
Subject: Re: sed suggestion: sed C API
Date: Sun, 8 Jul 2018 20:39:45 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

Hello Charlie,

On 08/07/18 01:58 PM, Charlie Sale wrote:
Recently, I have started learning about the SED tool. Although I have
used it before, I haven't quite grasped how to use it and have instead looked around for prewritten SED commands to do what I wanted. I want to change that now and learn more about the command.

In case you are still looking for examples, there is a wealth of
information here:
  http://sed.sourceforge.net/#docs
  http://sed.sourceforge.net/sed1line.txt
  http://www.catonmat.net/series/sed-one-liners-explained
  https://edoras.sdsu.edu/doc/sed-oneliners.html
And of course many available books.

There is always the official gnu sed manual:
  https://www.gnu.org/software/sed/manual/sed.html#Introduction

and if you find it lacking, please let us know what improvements
would you suggest for the manual to help someone new to using sed.

As I've been learning about it, I thought it might be useful for the
command to have a C API. I was thinking that it would basically take
the functionality of the command line tool and package it into a C
API.

What would be the benefit of a C api for gnu sed ?

It seems to me most high-level scripting languages (e.g. perl / python
/ ruby / php / javascript / lua) already contain their own library
functions to perform actions similar to what sed can do.

Similarly many modern non-scripting language (e.g. java, rust, go,
swift, etc) have their own regex library and powerful text replacement
facilities.

For C++ there is boost's regex module (combined with STL's file
streams), and the C++11 standard regex templates.


For C, there are the posix regex functions (should be available on
almost any modern operating system).

There are some existing regex libaries out there with binding
to many languages, e.g.:
 PCRE (http://www.pcre.org/),
 Google's RE2 (https://github.com/google/re2 library)
 Oniguruma (https://github.com/kkos/oniguruma)

Lastly, there are some people who already maintain such libraries,
though I can't attest to how reliable or well-maintained these are:
  http://code.abiyo.net/@qse
  https://github.com/jpereira/libsed

And of course, there is always the option of just executing "sed"
from your program.

SED offers more than just regex support, but then every programming
language has its own paradigm about file/text processsing.


Maintaining a stable C api library takes some effort (in terms
of software development and maintenance) - not sure this effort is
justified.

Do you have a specific use-case in mind where a C-api to GNU sed
would be useful ?


I am not very familiar with the SED source, but I'd be happy to learn
about it.

A useful place to start is this "OpenGrok" server which
allows easy navigation and exploration of SED source code.

https://opengrok.housegordon.com/source/xref/sed/


regards,
 - assaf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]