CS 120 / Lab 3 - Feb 18 and 19, 2010 Allison Mankin, amankin1@jhu.edu 1. review man and man -k useful site: http://www.oreillynet.com/linux/cmd/ 2. review simple Makefile - discussion with test-splint.c below 3. tar and gzip c create v verbose f output file t show table of contents x extract tar cvf .tar tar czf .tar.gz tar tvf .tar tar xvf .tar tar xzf .tar.gz (or .tgz) instead of using z in tar, can use gzip/gunzip - see man Exercise: make a gzipped tar file containing the a copy of your ~/tmp folder, named tmp.tar.gz 4. splint - discussion with test-splint.c below 5. diff - diff two files - your choice of a program and your choice of a program with any change edited in. Explain how to interpret the output - discussion with using test-splint.c and test.c, code before inserting bug to exercise splint. use redirection of stdout what's a good use for '>>'? discuss diff, > and >> wrt to assignment p2 (?) 6. several new emacs capabilities to try at home: mark a region ctrl-spacebar then cursor down or up cut a region ctrl-w paste a region ctrl-y undo ctrl-x-u ============================================ model Makefile: CFLAGS= -ansi -pedantic -Wall -Wextra -std=c99 -O CC=gcc test: test.c test-splint: test-splint.c yourprog: yourprog.c ============================================ compilation in emacs (review) esc-x compile - respond in command buffer either: make yourprog, or make -f alternativeMakefilename yourprog ============================================ example code: /* * test.c - extract exactly 10 digit * phone numbers from any format. Returns * error if other than 10 digits found. * test-splint.c - has an error for splint. */ #include #include #include #define LINELEN 80 int main () { int input[LINELEN]; int i, int digits; printf("enter 10-digit phone number in any format\n") /* fgets needs a char array, not int. Both the compiler and the program react, so splint isn't the only line of defense. However, if this were a method of my own, vs. a C library function, splint could be alone in giving the flag. */ fgets(input, LINELEN, stdin); digits = 0; for (i=0; i diffprograms tcsh$ less diffprograms 4a5 > * test-splint.c - has an error for splint. 6d6 < 15,16c15,17 < char input[LINELEN]; < int i, digits; --- > int input[LINELEN]; > int i; > int digits; 18a20,28 > > /* > fgets should have char array, not int. > Both the compiler and my program react to > it, so splint is not crucial. However if > this were a method of my own, rather than > a C function, it might be only splint > catching this type mismatch. > */