~ubuntu-branches/ubuntu/jaunty/ruby1.8/jaunty

« back to all changes in this revision

Viewing changes to io.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-08-09 10:42:29 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070809104229-vyrvcbqyy1jw0609
Tags: 1.8.6.36-1ubuntu1
* Merge with Debian; remaining changes:
  - Adjust configure options for lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
  io.c -
4
4
 
5
 
  $Author: knu $
6
 
  $Date: 2007-02-13 15:21:47 +0900 (Tue, 13 Feb 2007) $
 
5
  $Author: shyouhei $
 
6
  $Date: 2007-05-23 01:28:10 +0900 (Wed, 23 May 2007) $
7
7
  created at: Fri Oct 15 18:08:59 JST 1993
8
8
 
9
9
  Copyright (C) 1993-2003 Yukihiro Matsumoto
1052
1052
#endif
1053
1053
}
1054
1054
 
1055
 
long
 
1055
static long
1056
1056
io_fread(ptr, len, fptr)
1057
1057
    char *ptr;
1058
1058
    long len;
3026
3026
{
3027
3027
    int modef = rb_io_mode_flags(mode);
3028
3028
    OpenFile *fptr;
3029
 
 
3030
3029
#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
3031
3030
    FILE *f;
 
3031
#else
 
3032
    int pid;
 
3033
#ifdef _WIN32
 
3034
    FILE *fpr, *fpw;
 
3035
#else
 
3036
    int pr[2], pw[2];
 
3037
#endif
 
3038
#endif
 
3039
    volatile int doexec;
3032
3040
 
3033
3041
    if (!pname) pname = StringValueCStr(pstr);
 
3042
    doexec = (strcmp("-", pname) != 0);
 
3043
 
 
3044
#if defined(DJGPP) || defined(__human68k__) || defined(__VMS) || defined(_WIN32)
 
3045
    if (!doexec) {
 
3046
        rb_raise(rb_eNotImpError,
 
3047
                 "fork() function is unimplemented on this machine");
 
3048
    }
 
3049
#endif
 
3050
 
 
3051
#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
3034
3052
    f = popen(pname, mode);
3035
3053
    
3036
3054
    if (!f) rb_sys_fail(pname);
3052
3070
    }
3053
3071
#else
3054
3072
#ifdef _WIN32
3055
 
    int pid;
3056
 
    FILE *fpr, *fpw;
3057
 
 
3058
 
    if (!pname) pname = StringValueCStr(pstr);
3059
3073
retry:
3060
3074
    pid = pipe_exec(pname, rb_io_mode_modenum(mode), &fpr, &fpw);
3061
3075
    if (pid == -1) {            /* exec failed */
3085
3099
        return (VALUE)port;
3086
3100
    }
3087
3101
#else
3088
 
    int pid, pr[2], pw[2];
3089
 
    volatile int doexec;
3090
 
 
3091
 
    if (!pname) pname = StringValueCStr(pstr);
3092
 
 
3093
3102
    if (((modef & FMODE_READABLE) && pipe(pr) == -1) ||
3094
3103
        ((modef & FMODE_WRITABLE) && pipe(pw) == -1))
3095
3104
        rb_sys_fail(pname);
3096
3105
 
3097
 
    doexec = (strcmp("-", pname) != 0);
3098
3106
    if (!doexec) {
3099
3107
        fflush(stdin);          /* is it really needed? */
3100
3108
        fflush(stdout);