Commit Diff


commit - 64af102f736c4ef596d82f1a48e3536927ce32b0
commit + a8be4bf9f8908f3b191b6c165db66a618cea186a
blob - d1203fee885c971b213fdc2623f5259baef1840a
blob + 623a26bfad0d39a91476fb7aa6e034319a2e8ceb
--- 1-11-text
+++ 1-11-text
@@ -1,4 +1,4 @@
-
+
 *** START OF THE PROJECT GUTENBERG EBOOK HAND-BOOK OF PUNCTUATION ***
 
 
blob - b49c9dbcf487ba5c9b57413511acbf0ed738b6d2
blob + b78b1c110bfbcb9e9a3f9d026aaf44c23d676d5b
--- 1-16-text
+++ 1-16-text
@@ -1,4 +1,4 @@
-THE WAY TO WEALTH
+THE WAY TO WEALTH
 
 (From "Father Abraham's Speech," forming the preface to Poor _Richard's Almanac_ for 1758.)
 
blob - 1d9c45a2688e0988cc395d791528d3cd97d3b3c1
blob + d0e3fe581cbb3d0b87fe65450f41620c41f872f0
--- 1-17-text
+++ 1-17-text
@@ -1,4 +1,4 @@
-THE WAY TO WEALTH
+THE WAY TO WEALTH
 
 (From "Father Abraham's Speech," forming
 the preface to Poor _Richard's Almanac_ for 1758.)
blob - 807e73868d9ef294eaafcd37e6aab826fe38e763
blob + f67dc6d5e509d79fc503161034d22a96326fda0c
--- 1-18-text
+++ 1-18-text
@@ -1,4 +1,4 @@
-If you would       		     
+If you would       		     
 
     	   		   
 
blob - 3765955a0b0ef9ad9a407eb16f0ea1a71657817b
blob + 69be2704d4f3b1ac171315af6def07ec90b39026
--- 1-19-text
+++ 1-19-text
@@ -1,4 +1,4 @@
-It would be thought a hard Government that should tax its People
+It would be thought a hard Government that should tax its People
 one-tenth Part of their _Time_, to be employed in its Service. But
 _Idleness_ taxes many of us much more, if we reckon all that is spent
 in absolute _Sloth_, or doing of nothing, with that which is spent in
blob - e9b378a2dd0b8cbeff0753c414845268108a3fba
blob + 3bfbb5ed19d4de92335e092bb20b5bd03d296b91
--- 1-20.c
+++ 1-20.c
@@ -2,3 +2,51 @@
  * number of blanks to space to the next tab stop. Assume a fixed set of tab
  * stops, say every n columns. Should n be a variable or a symbolic parameter?
  * */
+
+#include <stdio.h>
+
+#define MAXLINE 1000		/* maximum input line size */
+
+int getlin(char line[], int maxline);
+void detab(char s[], int n);
+
+int main() {
+	int len;				/* current line length */
+	char line[MAXLINE];		/* current input line */
+
+	while ((len = getlin(line, MAXLINE)) > 0) {
+		detab(line, 4);
+	}
+
+	return 0;
+}
+
+/* getlin: read a line into s, return length */
+int getlin(char s[], int lim) {
+	int c, i;
+
+	for (i=0; i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
+		s[i] = c;
+	if (c == '\n') {
+		s[i] = c;
+		++i;
+	}
+	s[i] = '\0';
+	return i;
+}
+
+/* detab: replace tabs in string s with the blanks to the next tab stop and
+ * print string */
+
+void detab(char s[], int n) {
+	int col = 0;
+	for (int i = 0; s[i] != '\0'; i++) {
+		if (s[i] == '\t') {
+			for (int j = col%n; j < n; j++)
+				putchar(' ');
+		} else {
+			putchar(s[i]);
+			col++;
+		}
+	}
+}
blob - bf1c54c5c8ca96735ee2b9266b0f76e87d5256a6
blob + 1ed472b40b0985d6bc79d4fe9d796d60904e421d
--- 1-8-text
+++ 1-8-text
@@ -1,2 +1,2 @@
-"_Stoop, stoop!_" I did not understand him, till I felt my head hit against the
+"_Stoop, stoop!_" I did not understand him, till I felt my head hit against the
 beam.
blob - 298797d256d5747f7d6a176d558d92df054d4425
blob + 5aa763c80cea56279a095a594880d6d2c26f7897
--- 1-9-text
+++ 1-9-text
@@ -1,4 +1,4 @@
-"    _Stoop, 			stoop!_"

-I     did  	   	not understand		him,

-		till I felt     my head	hit	 against the

-     beam.

+"    _Stoop, 			stoop!_"
+I     did  	   	not understand		him,
+		till I felt     my head	hit	 against the
+     beam.