Strange #include behaviour?
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
No, PAWN is open-source and is publically available, hence it is used in SA:MP. The compiler has been modified with use with SA:MP and although the open source modifications were lost I believe they have been recovered.
Код:
/*  doinclude
 *
 *  Gets the name of an include file, pushes the old file on the stack and
 *  sets some options. This routine doesn't use lex(), since lex() doesn't
 *  recognize file names (and directories).
 *
 *  Global references: inpf     (altered)
 *                     inpfname (altered)
 *                     lptr     (altered)
 */
static void doinclude(int silent)
{
  char name[_MAX_PATH];
  char symname[sNAMEMAX];
  char *ptr;
  char c;
  int i, result;

  while (*lptr<=' ' && *lptr!='\0')         /* skip leading whitespace */
    lptr++;
  if (*lptr=='<' || *lptr=='\"') {
    c=(char)((*lptr=='\"') ? '\"' : '>');   /* termination character */
    lptr++;
    while (*lptr<=' ' && *lptr!='\0')       /* skip whitespace after quote */
      lptr++;
  } else {
    c='\0';
  } /* if */

  i=0;
  while (*lptr!=c && *lptr!='\0' && i<sizearray(name)-1)  /* find the end of the string */
    name[i++]=*lptr++;
  while (i>0 && name[i-1]<=' ')
    i--;                        /* strip trailing whitespace */
  assert(i>=0 && i<sizearray(name));
  name[i]='\0';                 /* zero-terminate the string */

  if (*lptr!=c) {               /* verify correct string termination */
    error(37);                  /* invalid string */
    return;
  } /* if */
  if (c!='\0')
    check_empty(lptr+1);        /* verify that the rest of the line is whitespace */

  /* create a symbol from the name of the include file; this allows the system
   * to test for multiple inclusions
   */
  strcpy(symname,"_inc_");
  if ((ptr=strrchr(name,DIRSEP_CHAR))!=NULL)
    strlcat(symname,ptr+1,sizearray(symname));
  else
    strlcat(symname,name,sizearray(symname));
  /* replace invalid characters by '_' (anything not a digit, character or
   * underscore)
   */
  for (i=0; symname[i]!='\0'; i++)
    if (!alphanum(symname[i]))
      symname[i]='_';
  #if defined __WIN32__ || defined _WIN32 || defined _Windows || defined __MSDOS__
    /* on systems with case-insentive filenames, force the symbol for the file
     * to lower case
     */
    strlwr(symname);
  #endif
  if (find_symbol(&glbtab,symname,fcurrent,-1)==NULL) {
    /* constant is not present, so this file has not been included yet */

    /* Include files between "..." or without quotes are read from the same
     * relative path as the current file, from the active directory, or from
     * a list of "include directories". Include files between <...> are only
     * read from the list of include directories.
     */
    result=plungefile(name,(c!='>'),TRUE);
    if (result)
      add_constant(symname,1,sGLOBAL,0);
    else if (!silent)
      error(100,name);            /* cannot read from ... (fatal error) */
  } /* if */
}
Where _MAX_PATH > 250, which is enough IMO. I'll investigate further.
Reply


Messages In This Thread
Strange #include behaviour? - by Dan.. - 13.08.2012, 15:10
Re: Strange #include behaviour? - by Dan.. - 13.08.2012, 15:14
Re: Strange #include behaviour? - by FalconX - 13.08.2012, 15:14
Re: Strange #include behaviour? - by Vince - 13.08.2012, 15:15
Re: Strange #include behaviour? - by Dan.. - 13.08.2012, 15:17
Re: Strange #include behaviour? - by Vince - 13.08.2012, 15:21
Re: Strange #include behaviour? - by Dan.. - 13.08.2012, 15:24
Re: Strange #include behaviour? - by Dan.. - 13.08.2012, 16:51
Re: Strange #include behaviour? - by Dan.. - 13.08.2012, 17:39
Re: Strange #include behaviour? - by Dan.. - 13.08.2012, 19:59

Forum Jump:


Users browsing this thread: 2 Guest(s)