<commit_before>/* -*- tab-width : 2 -*- */
#include "opt.h"

char** cmd_run_cmu(int argc,char** argv,struct sub_command* cmd) {
  char** arg=NULL;
  char* home=configdir();
  char* arch=uname_m();
  char* os=uname();
  char* impl=(char*)cmd->name;
  char* version=(char*)cmd->short_name;
  int offset=10; /*[binpath for lisp] -quiet -core param -eval init.lisp
                  -noinit -nositeinit [terminating NULL] that total 9 are default. */
  int i;
  if(strcmp(impl,"cmu"))
    impl="cmucl";
  char* impl_path= cat(home,"impls",SLASH,arch,SLASH,os,SLASH,impl,SLASH,version,NULL);
  char* help=get_opt("help",0);
  char* script=get_opt("script",0);
  char* image=get_opt("image",0);
  char* program=get_opt("program",0);
  char* dynamic_space_size=get_opt("dynamic-space-size",0);
  char* control_stack_size=get_opt("control-stack-size",0);
  char* cmu_version=get_opt("version",0);
  int paramc=0;
  char *bin;
  int issystem=(strcmp("system",version)==0);
  if(issystem){
    bin=which("lisp");
    if(strcmp(bin,"")==0)
      s(bin),bin=which("cmucl");
    bin=truename(bin);
  }else {
    bin=cat(impl_path,SLASH,"bin",SLASH,"lisp",EXE_EXTENTION,NULL);
  }
  if(dynamic_space_size)
    offset+=2;
  if(control_stack_size)
    offset+=2;
  if(cmu_version)
    offset+=2;
  if(script)
    offset+=1;
  if(quicklisp)
    offset+=2;
  if(program||script)
    offset+=2;

  arg=alloc(sizeof(char*)*(offset+argc));
  arg[paramc++]=bin;
  /* runtime options from here */

  arg[paramc++]=q("-quiet");
  if(image) {
    char *path=cat(impl_path,SLASH,"dump",SLASH,image,".core",NULL);
    arg[paramc++]=q("-core");
    if(file_exist_p(path)) {
      arg[paramc++]=path;
    }else {
      cond_printf(1,"core not found:%s\n",path);
      arg[paramc++]=cat(impl_path,SLASH,"lib",SLASH,"sbcl",SLASH,"sbcl.core",NULL);
      s(path);
    }
  }
  if(help) {
    arg[paramc++]=q("-help");
  }

  arg[paramc++]=q("-noinit");
  arg[paramc++]=q("-nositeinit");

  if(dynamic_space_size) {
    arg[paramc++]=q("-dynamic-space-size");
    arg[paramc++]=q(dynamic_space_size);
  }
  if(control_stack_size) {
    arg[paramc++]=q("-control-stack-size");
    arg[paramc++]=q(control_stack_size);
  }
  if(cmu_version) {
    arg[paramc++]=q("-eval");
    arg[paramc++]=q("(progn (format t \"~A ~A~%\" (lisp-implementation-type) (lisp-implementation-version))(extensions:quit))");
  }
  arg[paramc++]=q("-eval");
  arg[paramc++]=s_cat(q("(progn(setq *load-verbose*()*compile-verbose*())#-ros.init(cl:load \""),s_escape_string(lispdir()),q("init.lisp"),q("\"))"),NULL);

  if(quicklisp) {
    arg[paramc++]=q("-eval");
    arg[paramc++]=q("(ros:quicklisp)");
  }
  if(program || script) {
    char *tmp;
    arg[paramc++]=q("-eval");
    tmp=cat("(ros:run '(",program?program:"",script?"(:script ":"",script?script:"",script?")":"",script?"(:quit ())":"","))",NULL);
    arg[paramc++]=tmp;
  }

  for(i=1;i<argc;++i) {
    arg[paramc++]=argv[i];
  }

  s(impl_path);

  arg[paramc]=NULL;
  cond_printf(1,"\nhelp=%s script=%s\n",help?"t":"nil"
              ,script?script:"nil");
  return arg;
}<commit_msg>shorten cmd-run-cmu.c<commit_after>/* -*- tab-width : 2 -*- */
#include "opt.h"

char** cmd_run_cmu(int argc,char** argv,struct sub_command* cmd) {
  char* home=configdir();
  char* arch=uname_m();
  char* os=uname();
  char* impl=(char*)cmd->name;
  char* version=(char*)cmd->short_name;

  /*[binpath for lisp] -quiet -core param -eval init.lisp
    -noinit -nositeinit [terminating NULL] that total 9 are default. */
  int i;
  char* impl_path= cat(home,"impls",SLASH,arch,SLASH,os,SLASH,impl,SLASH,version,NULL);
  char* help=get_opt("help",0);
  char* script=get_opt("script",0);
  char* image=get_opt("image",0);
  char* program=get_opt("program",0);
  char* dynamic_space_size=get_opt("dynamic-space-size",0);
  char* control_stack_size=get_opt("control-stack-size",0);
  char* cmu_version=get_opt("version",0);
  char *bin;
  LVal ret=0;

  if(strcmp(impl,"cmu"))
    impl="cmucl";

  if(strcmp("system",version)==0) {
    bin=which("lisp");
    if(strcmp(bin,"")==0)
      s(bin),bin=which("cmucl");
    bin=truename(bin);
  }else
    bin=cat(impl_path,SLASH,"bin",SLASH,"lisp",EXE_EXTENTION,NULL);

  ret=conss(bin,ret);
  /* runtime options from here */

  ret=conss(q("-quiet"),ret);
  if(image) {
    char *path=cat(impl_path,SLASH,"dump",SLASH,image,".core",NULL);
    if(file_exist_p(path)) {
      ret=conss(q("-core"),ret);
      ret=conss(q(path),ret);
    }else
      cond_printf(1,"core not found:%s\n",path);
    s(path);
  }
  if(help)
    ret=conss(q("-help"),ret);

  ret=conss(q("-noinit"),ret);
  ret=conss(q("-nositeinit"),ret);

  if(dynamic_space_size) {
    ret=conss(q("-dynamic-space-size"),ret);
    ret=conss(q(dynamic_space_size),ret);
  }
  if(control_stack_size) {
    ret=conss(q("-control-stack-size"),ret);
    ret=conss(q(control_stack_size),ret);
  }
  if(cmu_version) {
    ret=conss(q("-eval"),ret);
    ret=conss(q("(progn (format t \"~A ~A~%\" (lisp-implementation-type) (lisp-implementation-version))(extensions:quit))"),ret);
  }
  ret=conss(q("-eval"),ret);
  ret=conss(s_cat(q("(progn(setq *load-verbose*()*compile-verbose*())#-ros.init(cl:load \""),s_escape_string(lispdir()),q("init.lisp"),q("\"))"),NULL),ret);

  if(quicklisp) {
    ret=conss(q("-eval"),ret);
    ret=conss(q("(ros:quicklisp)"),ret);
  }
  if(program || script) {
    ret=conss(q("-eval"),ret);
    ret=conss(cat("(ros:run '(",program?program:"",
                  script?"(:script ":"",script?script:"",script?")":"",script?"(:quit ())":"",
                  "))",NULL),ret);
  }

  for(i=1;i<argc;++i)
    ret=conss(q(argv[i]),ret);

  s(impl_path);

  cond_printf(1,"\nhelp=%s script=%s\n",help?"t":"nil",script?script:"nil");
  return stringlist_array(nreverse(ret));
}
{'fraction_non_alphanumeric': 0.23681936041486604, 'fraction_numerical': 0.006568712186689715, 'mean_word_length': 4.745779543197616, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3780474', 'n_tokens_mistral': 2363, 'n_tokens_neox': 2350, 'n_words': 281}