- Turn two instances of stricmp(...,".[Cc]") into one of strcaseccmp(...,".c")
  in filename parsing.
- Streamline line parsing a bit:
  - Scan the line only once, looking for any line terminator
  - Ignore leading and trailing blanks
  - Handle comments properly

svn path=/trunk/; revision=11557
This commit is contained in:
Art Yerkes 2004-11-06 17:37:29 +00:00
parent de2ab6cf8b
commit 03c08fd7b9

View file

@ -175,7 +175,7 @@ register_test(char *filename,
memset(ext, 0, sizeof(ext));
strncpy(&ext[0], &filename[i], strlen(&filename[i]));
if ((strncmp(ext, ".c", 2) != 0) && (strncmp(ext, ".C", 2) != 0))
if (strcasecmp(ext, ".c") != 0)
{
return;
}
@ -610,7 +610,7 @@ create_stubs_and_hooks(
FILE *hooks_out)
{
char line[INPUT_BUFFER_SIZE];
char *s;
char *s, *start;
char *dllname;
char *decoratedname_and_forward;
int stub_index;
@ -637,29 +637,30 @@ create_stubs_and_hooks(
)
{
/*
* Remove, if present, the trailing LF.
* Ignore leading blanks
*/
if ((s = (char *) strchr(line,'\n')) != NULL)
{
*s = '\0';
}
for( start = line; *start && isspace(*start); start++ );
/*
* Remove, if present, the trailing CR.
* Strip comments, eols
*/
if ((s = (char *) strchr(line,'\r')) != NULL)
{
for( s = start; *s && !strchr("#\n\r", *s); s++ );
*s = '\0';
}
/*
* Skip comments (#) and empty lines.
* Remove trailing blanks. Backup off the char that ended our
* run before.
*/
s = & line[0];
if ((*s) != '#' && (*s) != '\0')
for( s--; s > start && isspace(*s); s-- ) *s = '\0';
/*
* Skip empty lines
*/
if (s > start)
{
/* Extract the DLL name */
dllname = (char *) strtok(s, " \t");
dllname = (char *) strtok(start, " \t");
if (dllname != NULL && strlen(dllname) > 0)
{
/*
@ -669,6 +670,19 @@ create_stubs_and_hooks(
*/
decoratedname_and_forward = (char *) strtok(NULL, " \t");
/* Extract the argument count */
/* Something went wrong finding the separator ...
* print an error and bail. */
if( !decoratedname_and_forward ) {
fprintf
( stderr,
"Could not find separator between decorated "
"function name and dll name.\n"
"Format entries as <dllname> <import>\n"
"Legal comments start with #\n");
exit(1);
}
write_stub(stubs_out, hooks_out, dllname, decoratedname_and_forward, stub_index);
stub_index++;
}