Browse Source

Plan 9 from Bell Labs 2013-09-24

David du Colombier 10 years ago
parent
commit
2fc422bcfd
3 changed files with 41 additions and 38 deletions
  1. 9 8
      sys/man/1/join
  2. 0 17
      sys/src/9/teg2/usbehci.h
  3. 32 13
      sys/src/cmd/join.c

+ 9 - 8
sys/man/1/join

@@ -24,7 +24,7 @@ the standard input is used.
 and
 .I file2
 must be sorted in increasing
-.SM ASCII 
+.SM UTF
 collating
 sequence on the fields
 on which they are to be joined,
@@ -48,6 +48,8 @@ In this case, multiple separators count as one, and
 leading separators are discarded.
 .PP
 The following options are recognized, with POSIX syntax.
+.TF "\fL-j\fIn m\fR  "
+.PD
 .TP
 .BI -a " n
 In addition to the normal output,
@@ -80,7 +82,7 @@ or
 .TP
 .BI -j "n m"
 Archaic equivalent for
-.BI - n " m"\f1.
+.BI - "n m\f1."
 .TP
 .BI -o fields
 Each output line comprises the designated fields.
@@ -94,7 +96,6 @@ is a file number and
 .I m
 is a field number.
 Archaic usage allows separate arguments for field designators.
-.PP
 .TP
 .BI -t c
 Use character
@@ -111,7 +112,7 @@ Add birthdays to the
 .B /adm/users
 file, leaving unknown
 birthdays empty.
-The layout of 
+The layout of
 .B /adm/users
 is given in
 .IR users (6);
@@ -120,18 +121,18 @@ contains sorted lines like
 .LR "ken:Feb\ 4,\ 1953" .
 .TP
 .L
-tr : ' ' </adm/users | sort -k 3 3 >temp
+awk -F: '$3 != ""' /adm/users | tr : ' ' | sort -k 3,3 >temp
 .br
 .ns
 .TP
 .L
 join -1 3 -2 3 -o 1.1,2.1 temp temp | awk '$1 < $2'
-Print all pairs of users with identical userids.
+Print all pairs of users with identical non-empty userids.
 .SH SOURCE
 .B /sys/src/cmd/join.c
 .SH "SEE ALSO"
-.IR sort (1), 
-.IR comm (1), 
+.IR sort (1),
+.IR comm (1),
 .IR awk (1)
 .SH BUGS
 With default field separation,

+ 0 - 17
sys/src/9/teg2/usbehci.h

@@ -77,23 +77,6 @@ struct Eopio
 	ulong	insn[6];	/* implementation-specific */
 };
 
-typedef struct Uhh Uhh;
-struct Uhh {
-	ulong	revision;	/* ro */
-	uchar	_pad0[0x10-0x4];
-	ulong	sysconfig;
-	ulong	sysstatus;	/* ro */
-
-	uchar	_pad1[0x40-0x18];
-	ulong	hostconfig;
-	ulong	debug_csr;
-};
-
-enum {
-	/* hostconfig bits */
-	P1ulpi_bypass = 1<<0,	/* utmi if set; else ulpi */
-};
-
 extern Ecapio *ehcidebugcapio;
 extern int ehcidebugport;
 

+ 32 - 13
sys/src/cmd/join.c

@@ -3,11 +3,13 @@
 #include <libc.h>
 #include <stdio.h>
 #include <ctype.h>
+
 #define F1 0
 #define F2 1
 #define F0 3
 #define	NFLD	100	/* max field per line */
 #define comp() runecmp(ppi[F1][j1],ppi[F2][j2])
+
 FILE *f[2];
 Rune buf[2][BUFSIZ];	/*input lines */
 Rune *ppi[2][NFLD+1];	/* pointers to fields in lines */
@@ -33,7 +35,6 @@ void error(char*, char*);
 void seek1(void), seek2(void);
 Rune *strtorune(Rune *, char *);
 
-
 void
 main(int argc, char **argv)
 {
@@ -139,30 +140,47 @@ proceed:
 		error("some input line was truncated", "");
 	exits("");
 }
-int runecmp(Rune *a, Rune *b){
-	while(*a==*b){
-		if(*a=='\0') return 0;
+
+int
+runecmp(Rune *a, Rune *b)
+{
+	while(*a == *b) {
+		if(*a == '\0')
+			return 0;
 		a++;
 		b++;
 	}
-	if(*a<*b) return -1;
+	if(*a < *b)
+		return -1;
 	return 1;
 }
-char *runetostr(char *buf, Rune *r){
+
+char *
+runetostr(char *buf, Rune *r)
+{
 	char *s;
-	for(s=buf;*r;r++) s+=runetochar(s, r);
-	*s='\0';
+
+	for(s = buf; *r; r++)
+		s += runetochar(s, r);
+	*s = '\0';
 	return buf;
 }
-Rune *strtorune(Rune *buf, char *s){
+
+Rune *
+strtorune(Rune *buf, char *s)
+{
 	Rune *r;
-	for(r=buf;*s;r++) s+=chartorune(r, s);
-	*r='\0';
+
+	for (r = buf; *s; r++)
+		s += chartorune(r, s);
+	*r = '\0';
 	return buf;
 }
+
 /* lazy.  there ought to be a clean way to combine seek1 & seek2 */
 #define get1() n1=input(F1)
 #define get2() n2=input(F2)
+
 void
 seek2()
 {
@@ -253,7 +271,7 @@ seek1()
 int
 input(int n)		/* get input line and split into fields */
 {
-	register int i, c;
+	int i, c;
 	Rune *bp;
 	Rune **pp;
 	char line[BUFSIZ];
@@ -358,7 +376,8 @@ oparse(char *s)
 				olistf[no] = *s=='1'? F1: F2;
 				olist[no] = atoi(s += 2);
 				break;
-			} /* fall thru */
+			}
+			/* fall thru */
 		default:
 			error("invalid -o list", "");
 		}