bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Gnv-develop] Recent version of Bison under GNV/VMS


From: Block, Kenneth
Subject: RE: [Gnv-develop] Recent version of Bison under GNV/VMS
Date: Wed, 23 Jul 2003 07:44:22 -0400

Bernard,

It would be nice if open (and all related entries) could do a mapping of names 
with multiple dots in them to something reasonable on ODS-2. Then there would 
be no work in bison for filename support. Even if HP was not willing to 
consider this for the CRTL, it could be done in GNV in the CRTL supplement. 
Once you did this, you would have a framework in place to address other issues 
like the lack of symbolic links.

In the case of supporting VMS and Unix command lines, if the VMS command line 
is being implemented as a true DCL command line (set command/DCL TABLES), not 
something that just looks like a VMS command line, then the following program 
can be used to detect if a program is invoked as a DCL command or a foreign 
command. You would do the same thing for GNV as a foreign command.

Ken

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

#include <descrip.h>
#include <climsgdef.h>

#define MAX_DCL_LENGTH 1023
#define CMD_NAME "CXX"
char cmd_line [MAX_DCL_LENGTH + 2];

/*
** External system function declarations which are not in system headers
*/
extern int cli$present(struct dsc$descriptor_s *);
extern int cli$get_value(struct dsc$descriptor_s *,
                        struct dsc$descriptor *,
                        short *);


$DESCRIPTOR (file_dsc, "FILE");
$DESCRIPTOR (include_dsc, "INCLUDE_DIRECTORY");
$DESCRIPTOR (line_dsc, "$LINE");
$DESCRIPTOR (version_qual_dsc, "VERSION");

static int display_version (void)
/*
**  Check for /VERSION on the command line; if found, display ident
*/
{
int 
    displayed_ident = 0;

    return displayed_ident;
}

/* get_line: gets the command line and stores it in cmd_line.
             returns TRUE if this is a DCL command */

int get_line()
{
  struct dsc$descriptor 
    return_dsc = {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0};

  short dcl_command_length;     /* Length of user's link cmd from DCL */

  int status;

  status = cli$get_value(&line_dsc, &return_dsc, &dcl_command_length);
  if (!(status & 1)) {
    fprintf(stderr,"Unable to get line\n");
    exit(EXIT_FAILURE);
  } else {
    (void)sprintf (cmd_line, "%.*s ", 
                   (int) dcl_command_length, return_dsc.dsc$a_pointer);
  }
  if (strncmp(cmd_line,CMD_NAME,strlen(CMD_NAME))==0 &&
      (cmd_line[strlen(CMD_NAME)]==' ' ||
       cmd_line[strlen(CMD_NAME)]=='/' ||
       cmd_line[strlen(CMD_NAME)]=='\0')) {
    return TRUE;
  } else {
    return FALSE;
  }
}

int orig_argc=0;
char **orig_argv;

int vms_argc;
char **vms_argv;
int vms_allocated_argv=0;

void vms_cmd_line_add(char *arg)
{
  if (vms_allocated_argv <= vms_argc) {
    vms_allocated_argv *= 2;
    vms_argv = realloc(vms_argv,vms_allocated_argv*sizeof(char*));
  }
  vms_argv[vms_argc++] = strdup(arg);
}

void vms_cmd_line_add2(char *arg, int length)
{
  if (vms_allocated_argv <= vms_argc) {
    vms_allocated_argv *= 2;
    vms_argv = realloc(vms_argv,vms_allocated_argv*sizeof(char*));
  }

  vms_argv[vms_argc] = malloc(length+1);
  strncpy(vms_argv[vms_argc],arg,length);
  vms_argv[vms_argc][length]='\0';

  vms_argc++;
}

void vms_cmd_line_init(int *pargc, char ***pargv)
{
  int status;
  struct dsc$descriptor 
    return_dsc = {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0};

  short dsc_length;

  orig_argc = *pargc;
  orig_argv = *pargv;

  vms_allocated_argv = 10;

  vms_argv = malloc(vms_allocated_argv*sizeof(char*));
  vms_argv[0] = strdup(orig_argv[0]);
  vms_argc = 1;

  if (cli$present(&version_qual_dsc) == CLI$_DEFAULTED) {
    vms_cmd_line_add("-V");
  }

  /* Process includes */
  if (cli$present(&include_dsc) == CLI$_PRESENT) {
    do {
      status = cli$get_value(&include_dsc, &return_dsc, &dsc_length);
      if (!(status&1)) {
        printf("Problem getting include\n");
      }
      else if (status == CLI$_ABSENT)
        break;
      else {
        vms_cmd_line_add("-I");
        vms_cmd_line_add2(return_dsc.dsc$a_pointer,
                          return_dsc.dsc$w_length);
      }
    } while (status == CLI$_COMMA);
  }

  
  /* Process filenames */
  do {
    status = cli$get_value(&file_dsc, &return_dsc, &dsc_length);
    if (!(status&1)) {
      printf("Problem getting filename\n");
    }
    else if (status == CLI$_ABSENT)
      break;
    else {
      printf("%d %d\n",dsc_length,return_dsc.dsc$w_length);
      vms_cmd_line_add2(return_dsc.dsc$a_pointer,
                        return_dsc.dsc$w_length);
    }
  } while (status == CLI$_COMMA);

  *pargc = vms_argc;
  *pargv = vms_argv;
}

void vms_cmd_line_fini(int *pargc, char ***pargv)
{
  int i;
  for (i=0;i<*pargc;i++)
    free((*pargv)[i]);
    
  free(*pargv);

  /* Go ahead and restore them, is the really necessary? */
  *pargc = orig_argc;
  *pargv = orig_argv;
}

int main(int argc, char *argv[])
{
  int is_dcl=FALSE;

  if (get_line()) {
    /* This is DCL process it accordingly */
    is_dcl = TRUE;
    vms_cmd_line_init(&argc,&argv);
  }
  
  /*
   * Do the normal program
   */
    
  {
    int i;
    printf("argc=%d\n",argc);
    for (i = 0; i< argc; i++)
      printf("%d: %s\n",i,argv[i]);
  }
  
  if (is_dcl) {
    vms_cmd_line_fini(&argc,&argv);
  }

  return EXIT_SUCCESS;
}


-----Original Message-----
From: Bernard Giroud [mailto:address@hidden
Sent: Wednesday, July 23, 2003 6:34 AM
To: address@hidden; address@hidden
Subject: [Gnv-develop] Recent version of Bison under GNV/VMS

Hi all,

Thanks to Steve Pitcher who gave me the trick "define
DECC$PIPE_BUFFER_SIZE 64535", GNV is working
better and better. I could "./configure" and "make install"
the following packages (sometimes with little hacks):
mktemp 1.5, hostinfo 2.2, patch 2.5.4, yacc 1.9.1, flex 2.5.4
and finally bison 1.35.

Alas, when bison is used with option -y, it gives files *_tab.c
instead of the expected *.tab.c, due to the ifdef in system.h
for VMS. I also noticed that the latest version still having the
VMS command line support is 1.75, because it has been
dropped by Akim Demaille the 2002.11.12.

We need to change the way the output files are generated,
but we have 3 possibilities:

1) reintroduce a full native (comand line ) VMS support,
  but targeted to unix file names (ODS-5) only
2) reintroduce a full native (command line) VMS support,
  plus a runtime support of standard (ODS-2) file names
  or full  unix file names (ODS-5)
3) Complement the VMS ifdef to test also for GNV at
  compile time.
4) suppress the VMS ifdef: it will drop to the unix case
  ==> no more specific VMS support.

I'm personally in favor of the 4th proposal: simplest and
more POSIX like.

If one of the proposal 2 or 3 is used (or for other packages
with similar needs), then what would be the best way to test
the environment:
- at compile time do we have in the compiler (hp-compaq
  C) something like a "GNV" define ?
- if no, could it be added in the CC wrapper ?
- but if yes, ultimately, it should be needed in the true gcc.

- at run time: is it ok to test for getenv("SHELL") to distinguish
  between running under GNV or native VMS ?

Bernard Giroud
Credit Lyonnais (Suisse) SA


********************************************************************************
This e-mail contains confidential information or information belonging
to the Credit Lyonnais Group entity sending it and is intended solely
for the addressees. Any views expressed in this message are those of
the individual sender and its contents do not constitute a commitment
by Credit Lyonnais unless confirmed by letter or fax. The unauthorised
disclosure, use, dissemination or copying (either whole or partial) of
this e-mail, or any information it contains, is prohibited. E-mails are
susceptible to alteration and their integrity cannot be guaranteed.
Internet communications are not secured and therefore Credit Lyonnais
shall not be liable for this e-mail if modified or falsified. If you
are not the intended recipient of this e-mail, please delete it
immediately from your system and notify the sender of the wrong
delivery and the mail deletion.
********************************************************************************




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Gnv-develop mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/gnv-develop




reply via email to

[Prev in Thread] Current Thread [Next in Thread]