commit dc61ade11352c8d73a7f810bca35d34e64281d6f
parent 342a8857ecfc9e8c5101cc45e725d48e3a722b96
Author: qorg11 <qorg@vxempire.xyz>
Date: Mon, 30 Nov 2020 11:38:31 +0100
sorry, my emacs indentation was retarded
Diffstat:
M | src/cat.c | | | 38 | +++++++++++++++++++------------------- |
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/cat.c b/src/cat.c
@@ -8,32 +8,32 @@
int
cat(int fd, const char *filename)
{
- int c;
- char buf[8192];
- if (filename[0] == '-' && filename[1] != 'u')
- fd = 0;
+ int c;
+ char buf[8192];
+ if (filename[0] == '-' && filename[1] != 'u')
+ fd = 0;
- if(fd != 0)
- fd = open(filename, O_RDONLY);
+ if(fd != 0)
+ fd = open(filename, O_RDONLY);
- if (fd == -1)
- fprintf(stderr,"error opening %s: %s\n",
- filename,strerror(errno));
+ if (fd == -1)
+ fprintf(stderr,"error opening %s: %s\n",
+ filename,strerror(errno));
- while((c = read(fd,buf,sizeof(buf))) > 0)
- write(1,buf,c);
- close(fd);
- return 0;
+ while((c = read(fd,buf,sizeof(buf))) > 0)
+ write(1,buf,c);
+ close(fd);
+ return 0;
}
int
main(int argc, char *argv[])
{
- getopt(argc,argv,"u");
- if (argc == optind)
- cat(0,"-");
- for(int i = optind; i<argc;i++)
- cat(1,argv[i]);
+ getopt(argc,argv,"u");
+ if (argc == optind)
+ cat(0,"-");
+ for(int i = optind; i<argc;i++)
+ cat(1,argv[i]);
- return 0;
+ return 0;
}