首页 > > 详细

辅导CIS 212调试R、R讲解、辅导R编程

项目预算:   开发周期:  发布时间:   要求地区:

CIS 212 Project 3

A Simple grep in C
Due at 8:00pm on Monday, 27 April 2019
Write a C source file, sgrep.c, and an appropriate Makefile that builds an executable
file named sgrep, that conforms to the following synopsis:
./sgrep [OPTION] ... STRING [FILE] ...
sgrep searches the named input FILEs (or standard input if no files are named) for
lines containing the given STRING. By default, sgrep prints the matching lines on
standard output.
sgrep is to support the following options:
-i Ignore case distinctions in both the STRING and the lines in the input files.
-v Invert the sense of matching to select non-matching lines.
-c Suppress normal output; instead, print a count of matching lines for each
input file. If –v is also specified, count non-matching lines.
If multiple filenames have been specified in the command line, each line of output from
sgrep should be prefixed with “:” where is
replaced by the filename associated with the output.
1 Starting files
In Canvas, in Files/Projects, you will find a gzipped tar archive named P3start.tgz;
this file contains the following files:
• input1 – a file that contains text.
• input2 – another file that contains text
• tscript – a bash script file that performs a number of tests of your
sgrep.py using input1, input2, and test*.out; invoking
./tscript
will execute all of the tests using your executable sgrep.
• test*.out – the correct output files for the tests in tscript.
2 Hints
I suggest that you review available functions in the C string library1, especially how one
determines that a particular STRING is contained in another string and how you
convert characters from one case to another.

1 See the manual page at http://man7.org/linux/man-pages/man3/string.3.html.
CIS 212 Project 3
-2-
3 Checking that your solution works correctly
tscript takes zero or more arguments; if one or more arguments are specified,
tscript will only perform those specific tests; if no arguments are specified, all of the
tests are performed.
The tests that tscript performs are:
a Tests that a STRING has been provided and prints an error message.
b Tests that it defaults to standard input if no filenames are specified.
c Tests that it handles case insensitivity for the lines in the file[s].
d Tests that it handles case insensitivity for the STRING argument.
e Tests that the –c flag works for a single input file.
f Tests that –i and –c work together.
g Tests that –v works.
h Tests that –icv work together.
i Tests that the default behaviour works with two input files.
j Tests that the –i flag works for multiple files.
k Tests that the –c flag works for multiple files.
l Tests that the –v flag works for multiple files.
m Tests that all three flags work for multiple files.
n Tests that an error message is printed when a file cannot be opened.
o Tests that an error message is printed when an illegal flag is input.
For each test, tscript prints out “Starting test ”, where
is one of {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o};
it then prints a 1-line description of what it is testing; it then prints the actual command
line that it is executing; finally, it prints “Stopping test ”.
If there is any output between the actual command line and the Stopping line, except
for tests a, n, and o, where you should print an error message on stderr, the test has
failed.
4 Submission2
You will submit your solutions electronically by uploading a gzipped tar archive3 via
Canvas.

2 A 75% penalty will be assessed if you do not follow these submission instructions.
3 See section 7 of Canvas/Files/Projects/Project1/P1Handout.pdf for instructions if you do not remember
how to create a gzipped tar archive. Obviously, the filenames used for this project will be different.
CIS 212 Project 3
-3-
Your TGZ archive should be named -project3.tgz, where is
your “duckid”. It should contain your files sgrep.c and Makefile; it should also
contain a file named report.txt; this file should contain your name, duckid, the
names of any classmates who helped you, and the current state of your solution.
CIS 212 Project 3
-1-
Grading Rubric
Your submission will be marked on a 50 point scale. Substantial emphasis is placed
upon WORKING submissions, and you will note that a large fraction of the points are
reserved for this aspect. It is to your advantage to ensure that whatever you submit
compiles, links, and runs correctly. The information returned to you will indicate the
number of points awarded for the submission.

You must be sure that your code works correctly on the virtual machine under
VirtualBox, regardless of which platform you use for development and testing. Leave
enough time in your development to fully test on the virtual machine before
submission.

The marking scheme is as follows:
Points Description
5 Your report – honestly describes the state of your submission
1
2
2
2
2
3
2
2
3
3
3
3
3
2
2
1
1
1
1
1
5
Your sgrep passes test a on an unseen set of input files.
Your sgrep passes test b on an unseen set of input files.
Your sgrep passes test c on an unseen set of input files.
Your sgrep passes test d on an unseen set of input files.
Your sgrep passes test e on an unseen set of input files.
Your sgrep passes test f on an unseen set of input files.
Your sgrep passes test g on an unseen set of input files.
Your sgrep passes test h on an unseen set of input files.
Your sgrep passes test i on an unseen set of input files.
Your sgrep passes test j on an unseen set of input files.
Your sgrep passes test k on an unseen set of input files.
Your sgrep passes test l on an unseen set of input files.
Your sgrep passes test m on an unseen set of input files.
Your sgrep passes test n on an unseen set of input files.
Your sgrep passes test o on an unseen set of input files.
sgrep.c successfully compiles
sgrep.c successfully compiles with no warnings
The link phase to create sgrep is successful
The link phase to create sgrep is successful with no warnings
There are no memory leaks in your program
The code could have worked with minor modification to the source.

Note that:
• Your report needs to be honest. Stating that everything works and then finding
that it doesn’t is offensive. The 5 points associated with the report are probably
the easiest 5 points you will ever earn as long as you are honest.
CIS 212 Project 3
-2-
• The 5 points for “could have worked” is the maximum awarded in this category;
your mark in this category may be lower depending upon how close you were to
a working implementation.

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!