Skip to content
Snippets Groups Projects
Select Git revision
  • d6d348fb78ce80c85370afde6ae320ed68e65807
  • master default protected
  • 8.0
  • 9.0
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • nt-tools
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
  • v8.0.1982
  • v8.0.1980
  • v8.0.1978
  • v8.0.1976
  • v8.0.1974
  • v8.0.1972
  • v8.0.1970
41 results

opcodes.c

Blame
    • Fredrik Hübinette (Hubbe)'s avatar
      b1f4eb39
      Compiler update to use two pass · b1f4eb39
      Fredrik Hübinette (Hubbe) authored
      Rev: src/acconfig.h:1.14
      Rev: src/builtin_functions.c:1.59
      Rev: src/builtin_functions.h:1.5
      Rev: src/compilation.h:1.4
      Rev: src/configure.in:1.149
      Rev: src/cpp.c:1.3
      Rev: src/docode.c:1.24
      Rev: src/docode.h:1.4
      Rev: src/gc.c:1.24
      Rev: src/interpret.c:1.57
      Rev: src/interpret.h:1.16
      Rev: src/language.yacc:1.51
      Rev: src/las.c:1.40
      Rev: src/las.h:1.9
      Rev: src/lex.c:1.37
      Rev: src/lex.h:1.7
      Rev: src/main.c:1.32
      Rev: src/modules/Image/blit.c:1.26
      Rev: src/modules/Image/colortable.c:1.33
      Rev: src/modules/Image/dct.c:1.11
      Rev: src/modules/Image/image.c:1.73
      Rev: src/modules/Image/matrix.c:1.13
      Rev: src/modules/Image/operator.c:1.11
      Rev: src/modules/Image/pattern.c:1.11
      Rev: src/modules/Image/pnm.c:1.9
      Rev: src/modules/Image/polyfill.c:1.18
      Rev: src/modules/Image/togif.c:1.29
      Rev: src/modules/Image/x.c:1.17
      Rev: src/modules/Pipe/pipe.c:1.15
      Rev: src/modules/Regexp/glue.c:1.9
      Rev: src/modules/_Crypto/cbc.c:1.10
      Rev: src/modules/_Crypto/crypto.c:1.24
      Rev: src/modules/_Crypto/des.c:1.11
      Rev: src/modules/_Crypto/pipe.c:1.11
      Rev: src/modules/_Crypto/sha.c:1.9
      Rev: src/modules/files/socktest.pike:1.6
      Rev: src/modules/system/system.c:1.37
      Rev: src/object.c:1.31
      Rev: src/object.h:1.13
      Rev: src/opcodes.c:1.10
      Rev: src/operators.c:1.22
      Rev: src/peep.c:1.16
      Rev: src/peep.in:1.9
      Rev: src/pike_types.c:1.27
      Rev: src/pike_types.h:1.6
      Rev: src/program.c:1.48
      Rev: src/program.h:1.24
      Rev: src/program_areas.h:1.2
      Rev: src/stralloc.c:1.21
      Rev: src/stralloc.h:1.10
      Rev: src/svalue.c:1.18
      Rev: src/testsuite.in:1.64
      Rev: src/threads.c:1.51
      Rev: src/threads.h:1.26
      b1f4eb39
      History
      Compiler update to use two pass
      Fredrik Hübinette (Hubbe) authored
      Rev: src/acconfig.h:1.14
      Rev: src/builtin_functions.c:1.59
      Rev: src/builtin_functions.h:1.5
      Rev: src/compilation.h:1.4
      Rev: src/configure.in:1.149
      Rev: src/cpp.c:1.3
      Rev: src/docode.c:1.24
      Rev: src/docode.h:1.4
      Rev: src/gc.c:1.24
      Rev: src/interpret.c:1.57
      Rev: src/interpret.h:1.16
      Rev: src/language.yacc:1.51
      Rev: src/las.c:1.40
      Rev: src/las.h:1.9
      Rev: src/lex.c:1.37
      Rev: src/lex.h:1.7
      Rev: src/main.c:1.32
      Rev: src/modules/Image/blit.c:1.26
      Rev: src/modules/Image/colortable.c:1.33
      Rev: src/modules/Image/dct.c:1.11
      Rev: src/modules/Image/image.c:1.73
      Rev: src/modules/Image/matrix.c:1.13
      Rev: src/modules/Image/operator.c:1.11
      Rev: src/modules/Image/pattern.c:1.11
      Rev: src/modules/Image/pnm.c:1.9
      Rev: src/modules/Image/polyfill.c:1.18
      Rev: src/modules/Image/togif.c:1.29
      Rev: src/modules/Image/x.c:1.17
      Rev: src/modules/Pipe/pipe.c:1.15
      Rev: src/modules/Regexp/glue.c:1.9
      Rev: src/modules/_Crypto/cbc.c:1.10
      Rev: src/modules/_Crypto/crypto.c:1.24
      Rev: src/modules/_Crypto/des.c:1.11
      Rev: src/modules/_Crypto/pipe.c:1.11
      Rev: src/modules/_Crypto/sha.c:1.9
      Rev: src/modules/files/socktest.pike:1.6
      Rev: src/modules/system/system.c:1.37
      Rev: src/object.c:1.31
      Rev: src/object.h:1.13
      Rev: src/opcodes.c:1.10
      Rev: src/operators.c:1.22
      Rev: src/peep.c:1.16
      Rev: src/peep.in:1.9
      Rev: src/pike_types.c:1.27
      Rev: src/pike_types.h:1.6
      Rev: src/program.c:1.48
      Rev: src/program.h:1.24
      Rev: src/program_areas.h:1.2
      Rev: src/stralloc.c:1.21
      Rev: src/stralloc.h:1.10
      Rev: src/svalue.c:1.18
      Rev: src/testsuite.in:1.64
      Rev: src/threads.c:1.51
      Rev: src/threads.h:1.26
    Process.pmod 5.85 KiB
    #pike __REAL_VERSION__
    
    #define error(X) throw( ({ (X), backtrace()[0..sizeof(backtrace())-2] }) )
    
    import Stdio;
    
    #if !constant(strerror)
    #define strerror(X) ("errno="+X)
    #endif
    
    program create_process = __builtin.create_process;
    
    int exec(string file,string ... foo)
    {
      if (sizeof(file)) {
        string path;
    
        if(search(file,"/") >= 0)
          return exece(combine_path(getcwd(),file),foo,getenv());
    
        path=getenv("PATH");
    
        foreach(path ? path/":" : ({}) , path)
          if(file_stat(path=combine_path(path,file)))
    	return exece(path, foo,getenv());
      }
      return 69;
    }
    
    string sh_quote(string s)
    {
      return replace(s,
    	({"\\", "'", "\"", " "}),
    	({"\\\\", "\\'", "\\\"","\\ "}));
    }
    
    array(string) split_quoted_string(string s)
    {
      sscanf(s,"%*[ \n\t]%s",s);
      s=replace(s,
    	    ({"\"",  "'",  "\\",  " ",  "\t",  "\n"}),
    	    ({"\0\"","\0'","\0\\","\0 ","\0\t","\0\n"}));
      array(string) x=s/"\0";
      array(string) ret=({x[0]});
    
      for(int e=1;e<sizeof(x);e++)
      {
        switch(x[e][0])
        {
          case '"':
          ret[-1]+=x[e][1..];
          while(x[++e][0]!='"')
          {
    	if(strlen(x[e])==1 && x[e][0]=='\\' && x[e+1][0]=='"') e++;
    	ret[-1]+=x[e];
          }
          ret[-1]+=x[e][1..];
          break;
    
          case '\'':
          ret[-1]+=x[e][1..];
          while(x[++e][0]!='\'') ret[-1]+=x[e][1..];
          ret[-1]+=x[e][1..];
          break;
          
          case '\\':
          if(strlen(x[e])>1)
          {
    	ret[-1]+=x[e][1..];
          }else{
    	ret[-1]+=x[++e];
          }
          break;
          
          case ' ':
          case '\t':
          case '\n':
    	while(strlen(x[e])==1)
    	{
    	  if(e+1 < sizeof(x))
    	  {
    	    if((<' ','\t','\n'>) [x[e+1][0]])
    	      e++;
    	    else
    	      break;
    	  }else{
    	    return ret;
    	  }
    	}
    	ret+=({x[e][1..]});
          break;
    
          default:
    	ret[-1]+="\0"+x[e];
    	break;
        }
      }
      return ret;
    }
    
    object spawn(string s,object|void stdin,object|void stdout,object|void stderr,
    	     function|void cleanup, mixed ... args)
    {
    #if 1
      mapping data=(["env":getenv()]);
      if(stdin) data->stdin=stdin;
      if(stdout) data->stdout=stdout;
      if(stderr) data->stderr=stderr;
    #if defined(__NT__) || defined(__amigaos__)
      return create_process(split_quoted_string(s),data);
    #else /* !__NT__||__amigaos__ */
      return create_process(({ "/bin/sh", "-c", s }),data);
    #endif /* __NT__||__amigaos__ */
    #else
    
      object pid;
    
    #if constant(fork)
      pid=fork();
    #endif
      
      if(pid)
      {
        return pid;
      }else{
        if(stdin ) stdin ->dup2(File("stdin"));
        if(stdout) stdout->dup2(File("stdout"));
        if(stderr) stderr->dup2(File("stderr"));
    
        if(stdin ) destruct(stdin);
        if(stdout) destruct(stdout);
        if(stderr) destruct(stderr);
    
        if (cleanup) {
          cleanup(@args);
        }
    
        exec("/bin/sh","-c",s);
        exit(69);
      }
    #endif
    }
    
    string popen(string s)
    {
      object p;
      string t;
      object f = File();
    
      if (!f) error("Popen failed. (couldn't create pipe)\n");
    
      p=f->pipe(Stdio.PROP_IPC);
      if(!p) error("Popen failed. (couldn't create pipe)\n");
      spawn(s,0,p,0, destruct, f);
      p->close();
      destruct(p);
    
      t=f->read(0x7fffffff);
      if(!t)
      {
        int e;
        e=f->errno();
        f->close();
        destruct(f);
        error("Popen failed with error "+e+".\n");
      } else {
        f->close();
        destruct(f);
      }
      return t;
    }
    
    int system(string s)
    {
      return spawn(s)->wait();
    }
    
    #ifndef __NT__
    #if constant(fork)
    constant fork = predef::fork;
    #endif
    
    #if constant(exece)
    constant exece = predef::exece;
    #endif
    
    #if constant(fork)
    class Spawn
    {
       object stdin;
       object stdout;
       object stderr;
       array(object) fd;
    
       object pid;
    
       private object low_spawn(array(void|object(Stdio.File)) fdp,
    			    array(void|object(Stdio.File)) fd_to_close,
    			    string cmd, void|array(string) args, 
    			    void|mapping(string:string) env, 
    			    string|void cwd)
       {
          object(Stdio.File) pie,pied; /* interprocess communication */
          object pid;
    
          pie=Stdio.File();
          pied=pie->pipe();
    
          if(!(pid=fork()))
          {
    	 mixed err=catch
    	 {
    	    if(cwd && !cd(cwd))
    	    {
    	       throw(({"pike: cannot change cwd to "+cwd+
    		       ": "+strerror(errno())+"\n",
    		       backtrace()}));
    	    }
    
    	    if (sizeof(fdp)>0 && fdp[0]) fdp[0]->dup2(Stdio.File("stdin"));
    	    if (sizeof(fdp)>1 && fdp[1]) fdp[1]->dup2(Stdio.File("stdout"));
    	    if (sizeof(fdp)>2 && fdp[2]) fdp[2]->dup2(Stdio.File("stderr"));
    	    /* dup2 fdd[3..] here FIXME FIXME */
    	    foreach (fd_to_close,object f) 
    	       if (objectp(f)) { f->close(); destruct(f); }
    	    pie->close();
    	    destruct(pie);
    	   
    	    pied->set_close_on_exec(1);
    
    	    if (env) 
    	       exece(cmd,args||({}),env);
    	    else 
    	       exece(cmd,args||({}));
    
    	    throw(({"pike: failed to exece "+cmd+
    		    ": "+strerror(errno())+"\n",
    		    backtrace()}));
    	 };
    
    	 pied->write(encode_value(err));
    	 exit(1);
          }
    
          foreach (fdp,object f) if (objectp(f)) { f->close(); destruct(f); }
    
          pied->close();
          destruct(pied);
    
          mixed err=pie->read();
          if (err && err!="") throw(decode_value(err));
    
          pie->close();
          destruct(pie);
    
          return pid;
       }
    
       void create(string cmd,
    	       void|array(string) args,
    	       void|mapping(string:string) env,
    	       string|void cwd,
    	       void|array(object(Stdio.File)|void) ownpipes,
    	       void|array(object(Stdio.File)|void) fds_to_close)
       {
          if (!ownpipes)
          {
    	 stdin=Stdio.File();
    	 stdout=Stdio.File();
    	 stderr=Stdio.File();
    	 fd=({stdin->pipe(),stdout->pipe(),stderr->pipe()});
    	 fds_to_close=({stdin,stdout,stderr});
          }
          else
          {
    	 fd=ownpipes;
    	 if (sizeof(fd)>0) stdin=fd[0]; else stdin=0;
    	 if (sizeof(fd)>1) stdout=fd[1]; else stdout=0;
    	 if (sizeof(fd)>2) stderr=fd[2]; else stderr=0;
          }
          pid=low_spawn(fd,fds_to_close||({}),cmd,args,env,cwd);
       }
    
    #if constant(kill)
       int kill(int signal) 
       { 
          return predef::kill(pid,signal); 
       }
    #endif
    
       int wait()
       {
         return pid->wait();
       }
    
       // void set_done_callback(function foo,mixed ... args);
       // int result();
       // array rusage();
    }
    #endif
    #endif