Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-20 Thread Dimitris Papastamos
On Sat, Jan 18, 2014 at 04:29:10PM +0100, Silvan Jegen wrote: > Find the code (including a few more escapes) and the manpage below. The > manpage is very terse at the moment so if you think we should flesh the > text out more, or change the formatting, I am open for suggestions. Also, > I am not a

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-18 Thread Silvan Jegen
On Wed, Jan 15, 2014 at 07:53:25PM +, Dimitris Papastamos wrote: > On Wed, Jan 15, 2014 at 08:43:54PM +0100, Silvan Jegen wrote: > > I will start writing a man page (possibly based on the GNU one) as soon > > as I find the time (hopefully in the next few days). > > Consider looking at the Open

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-16 Thread q
On Thu, Jan 16, 2014 at 10:46:41AM +, sin wrote: > On Thu, Jan 16, 2014 at 11:37:46AM +0100, Silvan Jegen wrote: > > On Thu, Jan 16, 2014 at 10:16 AM, Roberto E. Vargas Caballero > > wrote: > > >> I would still go for the function-pointer-less version of the > > >> code since it actually is on

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-16 Thread FRIGN
On Thu, 16 Jan 2014 11:37:46 +0100 Silvan Jegen wrote: > Does anyone else have any strong feelings one way or the other? I prefer the version _with_ the function-pointer, too. Linking against musl shows that the biggest impact still resides in the standard library-code itself. -- FRIGN

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-16 Thread sin
On Thu, Jan 16, 2014 at 11:37:46AM +0100, Silvan Jegen wrote: > On Thu, Jan 16, 2014 at 10:16 AM, Roberto E. Vargas Caballero > wrote: > >> I would still go for the function-pointer-less version of the > >> code since it actually is one line shorter, I think. The second, > >> function-pointer-less

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-16 Thread Silvan Jegen
On Thu, Jan 16, 2014 at 10:16 AM, Roberto E. Vargas Caballero wrote: >> I would still go for the function-pointer-less version of the >> code since it actually is one line shorter, I think. The second, >> function-pointer-less version of the code can be found below. > > I like more the version wit

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-16 Thread Silvan Jegen
On Thu, Jan 16, 2014 at 1:41 AM, Szabolcs Nagy wrote: > * Silvan Jegen [2014-01-15 22:32:28 +0100]: >> On Wed, Jan 15, 2014 at 09:36:07PM +0100, Szabolcs Nagy wrote: >> > > +handleescapes(char *s) >> > > +{ >> > > + switch(*s) { >> > > + case 'n': >> > > + *s = '\x0A'; >> > > + br

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-16 Thread Roberto E. Vargas Caballero
> By no means was this any serious benchmarking but eliminating the function > pointer did not seem to make an obvious difference. Good job > I would still go for the function-pointer-less version of the > code since it actually is one line shorter, I think. The second, > function-pointer-les

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-15 Thread Szabolcs Nagy
* Silvan Jegen [2014-01-15 22:32:28 +0100]: > On Wed, Jan 15, 2014 at 09:36:07PM +0100, Szabolcs Nagy wrote: > > > +handleescapes(char *s) > > > +{ > > > + switch(*s) { > > > + case 'n': > > > + *s = '\x0A'; > > > + break; > > > + case 't': > > > + *s = '\x09'; > > > +

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-15 Thread Silvan Jegen
On Wed, Jan 15, 2014 at 09:36:07PM +0100, Szabolcs Nagy wrote: > * Silvan Jegen [2014-01-15 20:43:54 +0100]: > > Note, though, that GNU's tr does not seem to handle Unicode at all[1] > > while this version of tr, according to "perf record/report", seems to > > spend most of its running time in the

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-15 Thread Szabolcs Nagy
* Silvan Jegen [2014-01-15 20:43:54 +0100]: > Note, though, that GNU's tr does not seem to handle Unicode at all[1] > while this version of tr, according to "perf record/report", seems to > spend most of its running time in the Unicode handling functions of glibc. multi-byte string decoding is kn

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-15 Thread Dimitris Papastamos
On Wed, Jan 15, 2014 at 08:43:54PM +0100, Silvan Jegen wrote: > I will start writing a man page (possibly based on the GNU one) as soon > as I find the time (hopefully in the next few days). Consider looking at the OpenBSD manpage for tr. I will apply this as soon as you send in a manpage for it.

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-15 Thread Silvan Jegen
On Wed, Jan 15, 2014 at 11:27:23AM +, sin wrote: > On Tue, Jan 14, 2014 at 09:35:11AM +0100, Silvan Jegen wrote: > > On Tue, Jan 14, 2014 at 12:22 AM, wrote: > > > On Mon, Jan 13, 2014 at 11:19:49AM -0800, Silvan Jegen wrote: > > >> I have rewritten "tr" to use mmap and the wchar.h functions.

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-15 Thread sin
On Tue, Jan 14, 2014 at 09:35:11AM +0100, Silvan Jegen wrote: > On Tue, Jan 14, 2014 at 12:22 AM, wrote: > > On Mon, Jan 13, 2014 at 11:19:49AM -0800, Silvan Jegen wrote: > >> I have rewritten "tr" to use mmap and the wchar.h functions. It seems > >> to be quite slow but as far as I can tell it w

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-15 Thread sin
On Mon, Jan 13, 2014 at 11:19:49AM -0800, Silvan Jegen wrote: > I have rewritten "tr" to use mmap and the wchar.h functions. It seems > to be quite slow but as far as I can tell it works reasonably well (at > least when using a UTF-8 locale). Comments/review and testing welcome > (I am relatively n

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-14 Thread Silvan Jegen
On Tue, Jan 14, 2014 at 12:22 AM, wrote: > On Mon, Jan 13, 2014 at 11:19:49AM -0800, Silvan Jegen wrote: >> I have rewritten "tr" to use mmap and the wchar.h functions. It seems >> to be quite slow but as far as I can tell it works reasonably well (at >> least when using a UTF-8 locale). Comments

Re: [dev] [PATCH][RFC] Add a basic version of tr

2014-01-13 Thread q
On Mon, Jan 13, 2014 at 11:19:49AM -0800, Silvan Jegen wrote: > I have rewritten "tr" to use mmap and the wchar.h functions. It seems > to be quite slow but as far as I can tell it works reasonably well (at > least when using a UTF-8 locale). Comments/review and testing welcome > (I am relatively n

[dev] [PATCH][RFC] Add a basic version of tr

2014-01-13 Thread Silvan Jegen
Hi I have rewritten "tr" to use mmap and the wchar.h functions. It seems to be quite slow but as far as I can tell it works reasonably well (at least when using a UTF-8 locale). Comments/review and testing welcome (I am relatively new to C so beware)! If you think adding this version of "tr" to s