On 5/12/05, Alexander E. Patrakov <[EMAIL PROTECTED]> wrote:
> James Robertson wrote:
> > I usually run frame buffer consoles at
> > 1024x768 or larger and hate it when a message comes up formated for a
> > 80x25 console - ugh.
> 
> On the other hand, I have trouble following long lines (more than, say,
> 90  characters) after reading thoughts of Donald Knuth on the optimal
> line length (he says 66 characters). Anyway, if you can fix the
> function, you are welcome. Allowed assumptions:
> 
> You can even make an assumption that all characters are one cell wide,
> because the plain linux console assumes the same. However, you cannot
> assume that one character is one byte.
> 
> For counting characters in $STRING, the ${#STRING} construction can be
> used. It won't work with non-bash in UTF-8 locales correctly, but the
> only (AFAIK) shell that supports UTF-8 is bash. So it's safe to assume
> that non-bash just won't be used in UTF-8 locales.
> 
> --
> Alexander E. Patrakov
> --

I think I might have a few ideas on a better counting system.

[rough schetch]

in flex, I believe . would match every character except \r and \n.  (I
am going to assume this is a regex rule).

Then all we need to do is use sed to discard all the characters up to
the last newline.  We can easly count the remaining characters, and
store that number

conathan:~$ echo "abc\ndef" | sed "s/.*\\\\n//g"
def

(I haven't looked at functions before I did this, so for all I know,
it is already there)



BTW, does the # work under ash?  [the Counting Characters part, not
the international part.  (Internationalzation for someone who wants to
use ash, is probably not a major concern)]

-- 
Nathan Coulson (conathan)
------
nathan at linuxfromscratch org
conathan at gmail com
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to