Date: | Wed, 12 Apr 2006 23:55:40 +0300 |
From: | Diomidis Spinellis <dds@aueb.gr> |
Organization: | Athens University of Economics and Business |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0 |
MIME-Version: | 1.0 |
Newsgroups: | comp.lang.c |
Subject: | Re: K&R exercises |
References: | <1144873124.453441.223930@z34g2000cwc.googlegroups.com> |
In-Reply-To: | <1144873124.453441.223930@z34g2000cwc.googlegroups.com> |
Content-Type: | text/plain; charset=ISO-8859-1; format=flowed |
Content-Transfer-Encoding: | 7bit |
mdh wrote:
> Not looking for an answer, but more of an explanation. Thinking back
> to those heady days when you had the time to do them, may I ask this.
>
> Exercise 1-22 asks for a program to "fold" long input lines into 2 or
> more shorter lines before the nth column... etc etc. Now, there are
> numerous anwers on the web and in the "C answer book", which includes a
> function to expand the tabs to blanks ( depending upon where the tab is
> in relationship to the next tab-stop). I have been trying to understand
> why one would do this....why not just leave the tabs alone.
At some point you'll need to convert tabs into spaces in order to
display them. This might be in the firmware of the terminal or printer,
the code of the terminal emulator window, or the display function of the
editor. For example, the following excerpt from the NetBSD kernel
terminal handling code converts tabs into spaces when output is going
into a device that can't handle tabs on its own:
if (c == '\t' &&
ISSET(oflag, OXTABS) && !ISSET(tp->t_lflag, EXTPROC)) {
c = 8 - (tp->t_column & 7);
notout = b_to_q(" ", c, &tp->t_outq);
--
Diomidis Spinellis
Code Quality: The Open Source Perspective (Addison-Wesley 2006)
http://www.spinellis.gr/codequality
Newsgroup comp.lang.c contents
Newsgroup list
Diomidis Spinellis home page
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.