Normal quotes
This commit is contained in:
parent
5e10794a24
commit
18011c595a
352 changed files with 6040 additions and 6040 deletions
28
05-03.md
28
05-03.md
|
|
@ -15,7 +15,7 @@
|
|||
#include <alloc.h> /* alloc.h for Borland compilers,
|
||||
malloc.h for Microsoft compilers */
|
||||
|
||||
#define BLOCK_SIZE 0x4000 /* we’ll process the file in 16K blocks */
|
||||
#define BLOCK_SIZE 0x4000 /* we'll process the file in 16K blocks */
|
||||
|
||||
/* Searches the specified number of sequences in the specified
|
||||
buffer for matches to SearchString of SearchStringLength. Note
|
||||
|
|
@ -42,16 +42,16 @@
|
|||
also matches */
|
||||
if ( SearchStringLength == 1 ) {
|
||||
return(1); /* That one matching character was the whole
|
||||
search string, so we’ve got a match */
|
||||
search string, so we've got a match */
|
||||
}
|
||||
else {
|
||||
/* Check whether the remaining characters match */
|
||||
if ( !memcmp(PotentialMatch + 1, SearchString + 1,
|
||||
SearchStringLength - 1) ) {
|
||||
return(1); /* We’ve got a match */
|
||||
return(1); /* We've got a match */
|
||||
}
|
||||
}
|
||||
/* The string doesn’t match; keep going by pointing past the
|
||||
/* The string doesn't match; keep going by pointing past the
|
||||
potential match location we just rejected */
|
||||
SearchLength -= PotentialMatch - Buffer + 1;
|
||||
Buffer = PotentialMatch + 1;
|
||||
|
|
@ -79,13 +79,13 @@
|
|||
|
||||
/* Check for the proper number of arguments */
|
||||
if ( argc != 3 ) {
|
||||
printf(“usage: search filename search-string\n”);
|
||||
printf("usage: search filename search-string\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Try to open the file to be searched */
|
||||
if ( (Handle = open(argv[1], O_RDONLY | O_BINARY)) == -1 ) {
|
||||
printf(“Can’t open file: %s\n”, argv[1]);
|
||||
printf("Can't open file: %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
/* Calculate the length of text to search for */
|
||||
|
|
@ -93,7 +93,7 @@
|
|||
SearchStringLength = strlen(SearchString);
|
||||
/* Try to get memory in which to buffer the data */
|
||||
if ( (WorkingBlock = malloc(BLOCK_SIZE)) == NULL ) {
|
||||
printf(“Can’t get enough memory\n”);
|
||||
printf("Can't get enough memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@
|
|||
NextLoadPtr = WorkingBlock;
|
||||
NextLoadCount = BLOCK_SIZE;
|
||||
Done = 0; /* Not done with search yet */
|
||||
Found = 0; /* Assume we won’t find a match */
|
||||
Found = 0; /* Assume we won't find a match */
|
||||
/* Search the file in BLOCK_SIZE chunks */
|
||||
do {
|
||||
/* Read in however many bytes are needed to fill out the block
|
||||
|
|
@ -110,10 +110,10 @@
|
|||
the rest of the bytes in the file, whichever is less */
|
||||
if ( (WorkingLength = read(Handle, NextLoadPtr,
|
||||
NextLoadCount)) == -1 ) {
|
||||
printf(“Error reading file %s\n”, argv[1]);
|
||||
printf("Error reading file %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
/* If we didn’t read all the bytes we requested, we’re done
|
||||
/* If we didn't read all the bytes we requested, we're done
|
||||
after this block, whether we find a match or not */
|
||||
if ( WorkingLength != NextLoadCount ) {
|
||||
Done = 1;
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
WorkingLength - SearchStringLength + 1) <= 0 ) {
|
||||
Done = 1; /* Too few characters in this block for
|
||||
there to be any possible matches, so this
|
||||
is the final block and we’re done without
|
||||
is the final block and we're done without
|
||||
finding a match
|
||||
*/
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@
|
|||
/* Search this block */
|
||||
if ( SearchForString(WorkingBlock, BlockSearchLength,
|
||||
SearchString, SearchStringLength) ) {
|
||||
Found = 1; /* We’ve found a match */
|
||||
Found = 1; /* We've found a match */
|
||||
Done = 1;
|
||||
}
|
||||
else {
|
||||
|
|
@ -162,9 +162,9 @@
|
|||
|
||||
/* Report the results */
|
||||
if ( Found ) {
|
||||
printf(“String found\n”);
|
||||
printf("String found\n");
|
||||
} else {
|
||||
printf(“String not found\n”);
|
||||
printf("String not found\n");
|
||||
}
|
||||
exit(Found); /* Return the found/not found status as the
|
||||
DOS errorlevel */
|
||||
|
|
|
|||
Loading…
Reference in a new issue