wc.c (1591) | wc.c (13380) |
---|---|
1/* 2 * Copyright (c) 1980, 1987, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39 40#ifndef lint 41static char sccsid[] = "@(#)wc.c 8.1 (Berkeley) 6/6/93"; 42#endif /* not lint */ 43 44#include <sys/param.h> 45#include <sys/stat.h> 46#include <fcntl.h> | 1/* 2 * Copyright (c) 1980, 1987, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39 40#ifndef lint 41static char sccsid[] = "@(#)wc.c 8.1 (Berkeley) 6/6/93"; 42#endif /* not lint */ 43 44#include <sys/param.h> 45#include <sys/stat.h> 46#include <fcntl.h> |
47#include <locale.h> |
|
47#include <unistd.h> 48#include <errno.h> 49#include <stdio.h> 50#include <stdlib.h> 51#include <string.h> 52#include <ctype.h> 53 54u_long tlinect, twordct, tcharct; --- 6 unchanged lines hidden (view full) --- 61int 62main(argc, argv) 63 int argc; 64 char *argv[]; 65{ 66 register int ch; 67 int total; 68 | 48#include <unistd.h> 49#include <errno.h> 50#include <stdio.h> 51#include <stdlib.h> 52#include <string.h> 53#include <ctype.h> 54 55u_long tlinect, twordct, tcharct; --- 6 unchanged lines hidden (view full) --- 62int 63main(argc, argv) 64 int argc; 65 char *argv[]; 66{ 67 register int ch; 68 int total; 69 |
70 (void) setlocale(LC_CTYPE, ""); 71 |
|
69 while ((ch = getopt(argc, argv, "lwc")) != EOF) 70 switch((char)ch) { 71 case 'l': 72 doline = 1; 73 break; 74 case 'w': 75 doword = 1; 76 break; --- 33 unchanged lines hidden (view full) --- 110 } 111 exit(0); 112} 113 114void 115cnt(file) 116 char *file; 117{ | 72 while ((ch = getopt(argc, argv, "lwc")) != EOF) 73 switch((char)ch) { 74 case 'l': 75 doline = 1; 76 break; 77 case 'w': 78 doword = 1; 79 break; --- 33 unchanged lines hidden (view full) --- 113 } 114 exit(0); 115} 116 117void 118cnt(file) 119 char *file; 120{ |
118 register u_char *p; | 121 register u_char *p, ch; |
119 register short gotsp; | 122 register short gotsp; |
120 register int ch, len; | 123 register int len; |
121 register u_long linect, wordct, charct; 122 struct stat sb; 123 int fd; 124 u_char buf[MAXBSIZE]; 125 126 fd = STDIN_FILENO; 127 linect = wordct = charct = 0; 128 if (file) { --- 115 unchanged lines hidden --- | 124 register u_long linect, wordct, charct; 125 struct stat sb; 126 int fd; 127 u_char buf[MAXBSIZE]; 128 129 fd = STDIN_FILENO; 130 linect = wordct = charct = 0; 131 if (file) { --- 115 unchanged lines hidden --- |