caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien.Doligez@inria.fr (Damien Doligez)
To: caml-list@margaux.inria.fr
Subject: Patch for the Caml-Light runtime.
Date: Wed, 6 Apr 1994 11:20:34 +0200	[thread overview]
Message-ID: <9404060920.AA12930@lix.polytechnique.fr> (raw)

This patch will solve the problem of extra arguments being passed to
executable byte-code files on a variety of Unix systems (Pyramid,
Sequent, HP-UX, ...)  You need to install this patch if the "fib"
program in the "examples/basics" directory replies "Bad integer
constant" even when you give it a correct number as argument.

It is harmless to install this patch on systems where it is not
needed.

To install this patch, save this mail in your Caml Light source
directory "src/runtime" as file "patch1", go to that directory and
type "patch <patch1".  (You will need the "patch" utility, which is
widely available in source form. (e.g. from ftp.inria.fr))
Then recompile and reinstall Caml Light.  (If you know what you are
doing, you can recompile and reinstall only the runtime.)

*** main.c	Mon Jul 19 01:20:51 1993
--- main.c.new	Tue Apr  5 21:03:34 1994
***************
*** 58,75 ****
  
  extern char * searchpath();
  
! int attempt_open(name, trail)
       char ** name;
       struct exec_trailer * trail;
  {
    char * truename;
    int fd;
    int err;
  
    truename = searchpath(*name);
    if (truename == 0) truename = *name; else *name = truename;
    fd = open(truename, O_RDONLY | O_BINARY);
    if (fd == -1) return FILE_NOT_FOUND;
    err = read_trailer(fd, trail);
    if (err != 0) { close(fd); return err; }
    return fd;
--- 58,82 ----
  
  extern char * searchpath();
  
! int attempt_open(name, trail, do_open_script)
       char ** name;
       struct exec_trailer * trail;
+      int do_open_script;
  {
    char * truename;
    int fd;
    int err;
+   char buf [2];
  
    truename = searchpath(*name);
    if (truename == 0) truename = *name; else *name = truename;
    fd = open(truename, O_RDONLY | O_BINARY);
    if (fd == -1) return FILE_NOT_FOUND;
+   if (!do_open_script){
+     err = read (fd, buf, 2);
+     if (err < 2) return TRUNCATED_FILE;
+     if (buf [0] == '#' && buf [1] == '!') return BAD_MAGIC_NUM;
+   }
    err = read_trailer(fd, trail);
    if (err != 0) { close(fd); return err; }
    return fd;
***************
*** 82,87 ****
--- 89,115 ----
    "usage: camlrun [-v] [-V] [-g generation size] [-F free mem %] <file> <args>\n";
  #endif
  
+ /* Invocation of camlrun: 4 cases.
+ 
+    1.  runtime + bytecode
+        user types:  camlrun [options] bytecode args...
+        arguments:  camlrun [options] bytecode args...
+ 
+    2.  bytecode script
+        user types:  bytecode args...
+     a  arguments: (kernel1)  camlrun ./bytecode args...
+     b  arguments: (kernel2)  bytecode bytecode args...
+ 
+    3.  concatenated runtime and bytecode
+        user types:  composite args...
+        arguments:  composite args...
+ 
+ Algorithm: try to use the first argument as a byte-code file, except when
+ it starts with #! (case 2b).  If that fails (cases 1 and 2a) or if the file
+ starts with #!, parse the line as: (whatever) [options] bytecode args...
+ 
+ */
+ 
  int main(argc, argv)
       int argc;
       char * argv[];
***************
*** 108,114 ****
  #endif
  
    i = 0;
!   fd = attempt_open(&argv[0], &trail);
  
    if (fd < 0) {
  
--- 136,142 ----
  #endif
  
    i = 0;
!   fd = attempt_open(&argv[0], &trail, 0);
  
    if (fd < 0) {
  
***************
*** 149,155 ****
        exit(2);
      }
  
!     fd = attempt_open(&argv[i], &trail);
  
      switch(fd) {
      case FILE_NOT_FOUND:
--- 177,183 ----
        exit(2);
      }
  
!     fd = attempt_open(&argv[i], &trail, 1);
  
      switch(fd) {
      case FILE_NOT_FOUND:






                 reply	other threads:[~1994-04-06 11:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9404060920.AA12930@lix.polytechnique.fr \
    --to=damien.doligez@inria.fr \
    --cc=caml-list@margaux.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).