~beowulfof/+junk/fossil-scm

« back to all changes in this revision

Viewing changes to src/main.c

  • Committer: Oliver Friedrich
  • Date: 2015-11-03 08:30:04 UTC
  • Revision ID: redtalonof@gmail.com-20151103083004-nl72duskc02eyo4o
Version bumb 1.34 20151102

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
struct TclContext {
105
105
  int argc;              /* Number of original (expanded) arguments. */
106
106
  char **argv;           /* Full copy of the original (expanded) arguments. */
107
 
  void *library;         /* The Tcl library module handle. */
 
107
  void *hLibrary;        /* The Tcl library module handle. */
108
108
  void *xFindExecutable; /* See tcl_FindExecutableProc in th_tcl.c. */
109
109
  void *xCreateInterp;   /* See tcl_CreateInterpProc in th_tcl.c. */
110
110
  void *xDeleteInterp;   /* See tcl_DeleteInterpProc in th_tcl.c. */
111
111
  void *xFinalize;       /* See tcl_FinalizeProc in th_tcl.c. */
112
112
  Tcl_Interp *interp;    /* The on-demand created Tcl interpreter. */
113
113
  int useObjProc;        /* Non-zero if an objProc can be called directly. */
 
114
  int useTip285;         /* Non-zero if TIP #285 is available. */
114
115
  char *setup;           /* The optional Tcl setup script. */
115
116
  void *xPreEval;        /* Optional, called before Tcl_Eval*(). */
116
117
  void *pPreContext;     /* Optional, provided to xPreEval(). */
684
685
      fossil_fatal("unable to change directories to %s", zChdir);
685
686
    }
686
687
    if( find_option("help",0,0)!=0 ){
687
 
      /* --help anywhere on the command line is translated into
688
 
      ** "fossil help argv[1] argv[2]..." */
689
 
      int i;
 
688
      /* If --help is found anywhere on the command line, translate the command
 
689
       * to "fossil help cmdname" where "cmdname" is the first argument that
 
690
       * does not begin with a "-" character.  If all arguments start with "-",
 
691
       * translate to "fossil help argv[1] argv[2]...". */
 
692
      int i, nNewArgc;
690
693
      char **zNewArgv = fossil_malloc( sizeof(char*)*(g.argc+2) );
691
 
      for(i=1; i<g.argc; i++) zNewArgv[i+1] = g.argv[i];
692
 
      zNewArgv[i+1] = 0;
693
694
      zNewArgv[0] = g.argv[0];
694
695
      zNewArgv[1] = "help";
695
 
      g.argc++;
 
696
      for(i=1; i<g.argc; i++){
 
697
        if( g.argv[i][0]!='-' ){
 
698
          nNewArgc = 3;
 
699
          zNewArgv[2] = g.argv[i];
 
700
          zNewArgv[3] = 0;
 
701
          break;
 
702
        }
 
703
      }
 
704
      if( i==g.argc ){
 
705
        for(i=1; i<g.argc; i++) zNewArgv[i+1] = g.argv[i];
 
706
        nNewArgc = g.argc+1;
 
707
        zNewArgv[i+1] = 0;
 
708
      }
 
709
      g.argc = nNewArgc;
696
710
      g.argv = zNewArgv;
697
711
    }
698
712
    zCmdName = g.argv[1];
866
880
}
867
881
 
868
882
/*
 
883
** Look for multiple occurrences of a command-line option with the
 
884
** corresponding argument.
 
885
**
 
886
** Return a malloc allocated array of pointers to the arguments.
 
887
**
 
888
** pnUsedArgs is used to store the number of matched arguments.
 
889
**
 
890
** Caller is responsible to free allocated memory.
 
891
*/
 
892
const char **find_repeatable_option(
 
893
  const char *zLong,
 
894
  const char *zShort,
 
895
  int *pnUsedArgs
 
896
){
 
897
  const char *zOption;
 
898
  const char **pzArgs = 0;
 
899
  int nAllocArgs = 0;
 
900
  int nUsedArgs = 0;
 
901
 
 
902
  while( (zOption = find_option(zLong, zShort, 1))!=0 ){
 
903
    if( pzArgs==0 && nAllocArgs==0 ){
 
904
      nAllocArgs = 1;
 
905
      pzArgs = fossil_malloc( nAllocArgs*sizeof(pzArgs[0]) );
 
906
    }else if( nAllocArgs<=nUsedArgs ){
 
907
      nAllocArgs = nAllocArgs*2;
 
908
      pzArgs = fossil_realloc( pzArgs, nAllocArgs*sizeof(pzArgs[0]) );
 
909
    }
 
910
    pzArgs[nUsedArgs++] = zOption;
 
911
  }
 
912
  *pnUsedArgs = nUsedArgs;
 
913
  return pzArgs;
 
914
}
 
915
 
 
916
/*
869
917
** Look for a repository command-line option.  If present, [re-]cache it in
870
918
** the global state and return the new pointer, freeing any previous value.
871
919
** If absent and there is no cached value, return NULL.
1015
1063
#if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
1016
1064
    fossil_print("LEGACY_MV_RM\n");
1017
1065
#endif
 
1066
#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS)
 
1067
    fossil_print("EXEC_REL_PATHS\n");
 
1068
#endif
1018
1069
#if defined(FOSSIL_ENABLE_TH1_DOCS)
1019
1070
    fossil_print("TH1_DOCS\n");
1020
1071
#endif
1046
1097
#else
1047
1098
    fossil_print("UNICODE_COMMAND_LINE\n");
1048
1099
#endif
 
1100
#if defined(FOSSIL_DYNAMIC_BUILD)
 
1101
    fossil_print("DYNAMIC_BUILD\n");
 
1102
#else
 
1103
    fossil_print("STATIC_BUILD\n");
 
1104
#endif
1049
1105
  }
1050
1106
}
1051
1107
 
1440
1496
  db_multi_exec("CREATE TABLE sfile(x TEXT);");
1441
1497
  db_multi_exec("CREATE TABLE vfile(pathname);");
1442
1498
  vfile_scan(&base, blob_size(&base), 0, 0, 0);
1443
 
  db_multi_exec("DELETE FROM sfile WHERE x NOT GLOB '*.fossil'");
 
1499
  db_multi_exec("DELETE FROM sfile WHERE x NOT GLOB '*[^/].fossil'");
1444
1500
  n = db_int(0, "SELECT count(*) FROM sfile");
1445
1501
  if( n>0 ){
1446
1502
    Stmt q;
1535
1591
        szFile = 1;
1536
1592
        break;
1537
1593
      }
1538
 
      if( szFile==0 ){
 
1594
      if( szFile==0 && sqlite3_strglob("*/.fossil",zRepo)!=0 ){
1539
1595
        if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1540
1596
        szFile = file_size(zRepo);
1541
1597
        /* this should only be set from the --baseurl option, not CGI  */