Skip to contentSkip to conversation

#include Code in Dev86 to debug

DISCUSSION Jody 1 participant 1 message May 8, 2006

lore
Share & tools
lore

Jody

author
#0 lore raw

I'm releasing an updated clean tarball with DOS line endings stripped and the latest patches applied.

For ease in debugging the Dev86 problem here, this is the chunk of code in cpp.c from the most recent Dev86 that handles #include files. We can't have random included files being detected as non-existent when they are clearly present. If you're a C programmer, please figure out where this is going awry. It happens for both <xxx> and "xxx" #include directives.

I cleaned out the MS-DOS CRLF line endings that I happened upon and the problem persists.

cpp.c code in question follows:

--------------

static void
do_proc_include()
{
int ch, ch1;
char * p;
FILE * fd;

ch = get_onetok(SKIP_SPACE);
if( ch == '<' || ch == '"' )

   {
      if( ch == '"' ) ch1 = ch; else ch1 = '>';
      p = curword;
      while(p< curword+WORDSIZE-1)
      {
         ch = pgetc();
         if( ch == '\n' ) break;
         if( ch == ch1 )
         {
            *p = '\0';
	    p = strdup(curword);

	    do { ch1 = pgetc(); } while(ch1 == ' ' || ch1 == '\t');
	    unchget(ch1);
            do_proc_tail();

	    saved_files[fi_count] = curfile;
	    saved_fname[fi_count] = c_fname;
	    saved_lines[fi_count] = c_lineno;

            fd = open_include(p, "r", (ch=='"'));
            if( fd ) {
	       fi_count++;
	       curfile = fd;
	    } else
               cerror("Cannot open include file");

            return;
         }
         *p++ = ch;
      }

}
cerror("Bad #include command");
while(ch != '\n') ch = pgetc();
return;
}

--------------