Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-15 Thread Duy Nguyen
On Sun, Aug 9, 2015 at 9:11 PM, Karthik Nayak wrote: > Add strbuf_utf8_align() which will align a given string into a strbuf > as per given align_type and width. If the width is greater than the > string length then no alignment is performed. I smell an opportunity to reuse this code and kill som

Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-14 Thread Junio C Hamano
Eric Sunshine writes: > Please extend this documentation to state explicitly that this > function preserves (does not truncate) the input string if it is wider > than 'width'. That's quite important information for the caller to > know. > > (Aside: I could easily see this function being extended

Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-13 Thread Karthik Nayak
On Fri, Aug 14, 2015 at 12:38 AM, Eric Sunshine wrote: > On Sun, Aug 9, 2015 at 10:11 AM, Karthik Nayak wrote: >> Add strbuf_utf8_align() which will align a given string into a strbuf >> as per given align_type and width. If the width is greater than the >> string length then no alignment is perf

Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-13 Thread Eric Sunshine
On Sun, Aug 9, 2015 at 10:11 AM, Karthik Nayak wrote: > Add strbuf_utf8_align() which will align a given string into a strbuf > as per given align_type and width. If the width is greater than the > string length then no alignment is performed. In addition to Junio's valuable comments... > Signed

Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-12 Thread Karthik Nayak
On Wed, Aug 12, 2015 at 10:10 PM, Junio C Hamano wrote: > Karthik Nayak writes: > >> On Tue, Aug 11, 2015 at 11:52 PM, Junio C Hamano wrote: >>> Karthik Nayak writes: >>> +void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned int width, +co

Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-12 Thread Junio C Hamano
Karthik Nayak writes: > On Tue, Aug 11, 2015 at 11:52 PM, Junio C Hamano wrote: >> Karthik Nayak writes: >> >>> +void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned >>> int width, >>> +const char *s) >>> +{ >>> + int display_len = utf8_strnwidth(s,

Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-12 Thread Karthik Nayak
On Tue, Aug 11, 2015 at 11:52 PM, Junio C Hamano wrote: > Karthik Nayak writes: > >> +void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned >> int width, >> +const char *s) >> +{ >> + int display_len = utf8_strnwidth(s, strlen(s), 0); >> + int utf8_

Re: [PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-11 Thread Junio C Hamano
Karthik Nayak writes: > +void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned int > width, > +const char *s) > +{ > + int display_len = utf8_strnwidth(s, strlen(s), 0); > + int utf8_compenstation = strlen(s) - display_len; compensation, perhaps?

[PATCH v10 04/13] utf8: add function to align a string into given strbuf

2015-08-09 Thread Karthik Nayak
Add strbuf_utf8_align() which will align a given string into a strbuf as per given align_type and width. If the width is greater than the string length then no alignment is performed. Helped-by: Eric Sunshine Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak