pike.git / src / modules / _Stdio / efuns.c

version» Context lines:

pike.git/src/modules/_Stdio/efuns.c:44: Inside #if 0 and #if defined(HAVE_LIBZFS_INIT)
  #ifdef HAVE_LIBZFS_H   #include <libzfs.h>   #endif /* HAVE_LIBZFS_H */   static libzfs_handle_t *libzfs_handle;   #endif /* HAVE_LIBZFS_INIT */   #endif /* 0 */      #define sp Pike_sp      /* #define READDIR_DEBUG */ + #ifdef READDIR_DEBUG + #define RDWERR(...) fprintf(stderr,__VA_ARGS__) + #else + #define RDWERR(...) + #endif      #ifdef __NT__      #include <winbase.h>   #include <io.h>   #include <direct.h>      /* Old versions of the headerfiles don't have this constant... */   #ifndef INVALID_SET_FILE_POINTER   #define INVALID_SET_FILE_POINTER ((DWORD)-1)
pike.git/src/modules/_Stdio/efuns.c:1069: Inside #if defined(__NT__)
      if (wcslen(STR1(sb.s)) != (size_t)sb.s->len) {    /* Filenames with NUL are not supported. */    free_string_builder(&sb);    errno = ENOENT;    pop_n_elems(args);    push_int(0);    return;    }    - #ifdef READDIR_DEBUG -  fprintf(stderr, "FindFirstFile(\"%S\")...\n", STR1(sb.s)); - #endif /* READDIR_DEBUG */ +  RDWERR("FindFirstFile(\"%S\")...\n", STR1(sb.s));       dir = FindFirstFileW(STR1(sb.s), &d);       free_string_builder(&sb);       if (dir == INVALID_HANDLE_VALUE) {    int err = GetLastError(); - #ifdef READDIR_DEBUG -  fprintf(stderr, " INVALID_HANDLE_VALUE, error %d\n", err); - #endif /* READDIR_DEBUG */ +  RDWERR(" INVALID_HANDLE_VALUE, error %d\n", err);       pop_n_elems(args);    if (err == ERROR_FILE_NOT_FOUND) {    /* Normally there should at least be a "." entry, so this seldom    * happens. But it seems unwise to count on it, considering this    * being Windows and all..    *    * Note: The error is ERROR_PATH_NOT_FOUND if the directory    * doesn't exist.    */
pike.git/src/modules/_Stdio/efuns.c:1107: Inside #if defined(__NT__)
   }    return;    }       {    int err;       BEGIN_AGGREGATE_ARRAY(10);       do { - #ifdef READDIR_DEBUG -  fprintf(stderr, " \"%S\"\n", d.cFileName); - #endif /* READDIR_DEBUG */ +  RDWERR(" \"%S\"\n", d.cFileName);    /* Filter "." and ".." from the list. */    if(d.cFileName[0]=='.')    {    if(!d.cFileName[1]) continue;    if(d.cFileName[1]=='.' && !d.cFileName[2]) continue;    }    push_string(make_shared_binary_string1(d.cFileName, wcslen(d.cFileName)));    DO_AGGREGATE_ARRAY(120);    } while(FindNextFileW(dir, &d));    err = GetLastError();    - #ifdef READDIR_DEBUG -  fprintf(stderr, " DONE, error %d\n", err); - #endif /* READDIR_DEBUG */ +  RDWERR(" DONE, error %d\n", err);       FindClose(dir);       END_AGGREGATE_ARRAY;       stack_pop_n_elems_keep_top(args);       if (err != ERROR_SUCCESS && err != ERROR_NO_MORE_FILES) {    set_errno_from_win32_error (err);    pop_stack();
pike.git/src/modules/_Stdio/efuns.c:1220: Inside #if defined(_REENTRANT) && defined(HAVE_READDIR_R)
   } else {    d = tmp;    }   #elif defined(HAVE_POSIX_READDIR_R)    /* POSIX readdir_r returns 0 on success, and ERRNO on failure.    * at end of dir it sets the third arg to NULL.    */    d = NULL;    errno = 0;    if ((err = readdir_r(dir, tmp, &d)) || !d) { - #ifdef READDIR_DEBUG -  fprintf(stderr, "POSIX readdir_r() => err %d\n", err); -  fprintf(stderr, "POSIX readdir_r(), d= 0x%08x\n", (unsigned int)d); - #endif /* READDIR_DEBUG */ +  RDWERR("POSIX readdir_r() => err %d\n", err); +  RDWERR("POSIX readdir_r(), d= 0x%08x\n", (unsigned int)d);    if (err == -1) {    /* Solaris readdir_r returns -1, and sets errno. */    err = errno;    } - #ifdef READDIR_DEBUG -  fprintf(stderr, "POSIX readdir_r() => errno %d\n", err); - #endif /* READDIR_DEBUG */ +  RDWERR("POSIX readdir_r() => errno %d\n", err);    /* Solaris readdir_r seems to set errno to ENOENT sometimes.    *    * AIX readdir_r seems to set errno to EBADF at end of dir.    */    if ((err == ENOENT) || (err == EBADF)) {    err = 0;    }    break;    } - #ifdef READDIR_DEBUG -  fprintf(stderr, "POSIX readdir_r() => \"%s\"\n", d->d_name); - #endif /* READDIR_DEBUG */ +  RDWERR("POSIX readdir_r() => \"%s\"\n", d->d_name);   #else   #error Unknown readdir_r variant   #endif    /* Filter "." and ".." from the list. */    if(d->d_name[0]=='.')    {    if(NAMLEN(d)==1) continue;    if(d->d_name[1]=='.' && NAMLEN(d)==2) continue;    }    if(num_files >= FPR) break;
pike.git/src/modules/_Stdio/efuns.c:1265:    memcpy(bufptr, d->d_name, lens[num_files]);    ptrs[num_files]=bufptr;    bufptr+=lens[num_files];    num_files++;    }    THREADS_DISALLOW();    if ((!d) && err) {    free(tmp);    Pike_error("get_dir(): readdir_r() failed: %d\n", err);    } - #ifdef READDIR_DEBUG -  fprintf(stderr, "Pushing %d filenames...\n", num_files); - #endif /* READDIR_DEBUG */ +  RDWERR("Pushing %d filenames...\n", num_files);    for(e=0;e<num_files;e++)    {    push_string(make_shared_binary_string(ptrs[e],lens[e]));    }    if(d)    push_string(make_shared_binary_string(d->d_name,NAMLEN(d)));    else    break;    DO_AGGREGATE_ARRAY(120);    }       free(tmp);   #else    for(d=readdir(dir); d; d=readdir(dir))    { - #ifdef READDIR_DEBUG -  fprintf(stderr, "readdir(): %s\n", d->d_name); - #endif /* READDIR_DEBUG */ +  RDWERR("readdir(): %s\n", d->d_name);    /* Filter "." and ".." from the list. */    if(d->d_name[0]=='.')    {    if(NAMLEN(d)==1) continue;    if(d->d_name[1]=='.' && NAMLEN(d)==2) continue;    }    push_string(make_shared_binary_string(d->d_name, NAMLEN(d)));       DO_AGGREGATE_ARRAY(120);    }