Fossil

Changes On Branch bash-completion
Login

Changes On Branch bash-completion

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bash-completion Excluding Merge-Ins

This is equivalent to a diff from 9ed13436 to a4de0004

2016-12-19
07:04
Enhance TH1 'redirect' command to support for HTTP redirects with a status code of 307. ... (check-in: bee6dbde user: mistachkin tags: trunk)
2016-12-15
22:46
First jab at creating a bash script for command completion ... (Closed-Leaf check-in: a4de0004 user: baruch tags: bash-completion)
2016-12-14
01:09
Fix the logic that combines merge risers (originally added to trunk by check-in [95d6ddc3]). Add test cases for this fix to graph-test-1.wiki. ... (check-in: 9ed13436 user: drh tags: trunk)
2016-12-08
20:10
Bring the change log up-to-date with the latest enhancements. ... (check-in: d1a6222e user: drh tags: trunk)

Changes to src/main.mk.

436
437
438
439
440
441
442

443


444
445
446
447
448
449
450
451
 $(OBJDIR)/xfer.o \
 $(OBJDIR)/xfersetup.o \
 $(OBJDIR)/zip.o

APPNAME = fossil$(E)






all:	$(OBJDIR) $(APPNAME)

install:	$(APPNAME)
	mkdir -p $(INSTALLDIR)
	mv $(APPNAME) $(INSTALLDIR)

codecheck:	$(TRANS_SRC) $(OBJDIR)/codecheck1
	$(OBJDIR)/codecheck1 $(TRANS_SRC)







>

>
>
|







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
 $(OBJDIR)/xfer.o \
 $(OBJDIR)/xfersetup.o \
 $(OBJDIR)/zip.o

APPNAME = fossil$(E)


COMPNAME = completion.sh



all:	$(OBJDIR) $(APPNAME) $(COMPNAME)

install:	$(APPNAME)
	mkdir -p $(INSTALLDIR)
	mv $(APPNAME) $(INSTALLDIR)

codecheck:	$(TRANS_SRC) $(OBJDIR)/codecheck1
	$(OBJDIR)/codecheck1 $(TRANS_SRC)
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
$(SRCDIR)/../manifest:
	# noop

clean:
	rm -rf $(OBJDIR)/* $(APPNAME)


$(OBJDIR)/page_index.h: $(TRANS_SRC) $(OBJDIR)/mkindex
	$(OBJDIR)/mkindex $(TRANS_SRC) >$@

$(OBJDIR)/builtin_data.h: $(OBJDIR)/mkbuiltin $(EXTRA_FILES)
	$(OBJDIR)/mkbuiltin --prefix $(SRCDIR)/ $(EXTRA_FILES) >$@

$(OBJDIR)/headers:	$(OBJDIR)/page_index.h $(OBJDIR)/builtin_data.h $(OBJDIR)/makeheaders $(OBJDIR)/VERSION.h
	$(OBJDIR)/makeheaders $(OBJDIR)/add_.c:$(OBJDIR)/add.h \
	$(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h \







|


|
|







588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
$(SRCDIR)/../manifest:
	# noop

clean:
	rm -rf $(OBJDIR)/* $(APPNAME) $(COMPNAME)


$(OBJDIR)/page_index.h $(COMPNAME): $(TRANS_SRC) $(OBJDIR)/mkindex
	$(OBJDIR)/mkindex --compfile $(COMPNAME) $(TRANS_SRC) >$(OBJDIR)/page_index.h

$(OBJDIR)/builtin_data.h: $(OBJDIR)/mkbuiltin $(EXTRA_FILES)
	$(OBJDIR)/mkbuiltin --prefix $(SRCDIR)/ $(EXTRA_FILES) >$@

$(OBJDIR)/headers:	$(OBJDIR)/page_index.h $(OBJDIR)/builtin_data.h $(OBJDIR)/makeheaders $(OBJDIR)/VERSION.h
	$(OBJDIR)/makeheaders $(OBJDIR)/add_.c:$(OBJDIR)/add.h \
	$(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h \

Changes to src/makemake.tcl.

279
280
281
282
283
284
285


286
287
288
289
290
291
292
293
294
295
296
297
298
writeln -nonewline "OBJ ="
foreach s [lsort $src] {
  writeln -nonewline " \\\n \$(OBJDIR)/$s.o"
}
writeln "\n"
writeln "APPNAME = $name\$(E)"
writeln "\n"



writeln [string map [list \
    <<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n                 "] \
    <<<SHELL_OPTIONS>>> [join $SHELL_OPTIONS " \\\n                "] \
    <<<MINIZ_OPTIONS>>> [join $MINIZ_OPTIONS " \\\n                "]] {
all:	$(OBJDIR) $(APPNAME)

install:	$(APPNAME)
	mkdir -p $(INSTALLDIR)
	mv $(APPNAME) $(INSTALLDIR)

codecheck:	$(TRANS_SRC) $(OBJDIR)/codecheck1
	$(OBJDIR)/codecheck1 $(TRANS_SRC)







>
>





|







279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
writeln -nonewline "OBJ ="
foreach s [lsort $src] {
  writeln -nonewline " \\\n \$(OBJDIR)/$s.o"
}
writeln "\n"
writeln "APPNAME = $name\$(E)"
writeln "\n"
writeln "COMPNAME = completion.sh"
writeln "\n"

writeln [string map [list \
    <<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n                 "] \
    <<<SHELL_OPTIONS>>> [join $SHELL_OPTIONS " \\\n                "] \
    <<<MINIZ_OPTIONS>>> [join $MINIZ_OPTIONS " \\\n                "]] {
all:	$(OBJDIR) $(APPNAME) $(COMPNAME)

install:	$(APPNAME)
	mkdir -p $(INSTALLDIR)
	mv $(APPNAME) $(INSTALLDIR)

codecheck:	$(TRANS_SRC) $(OBJDIR)/codecheck1
	$(OBJDIR)/codecheck1 $(TRANS_SRC)
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
$(SRCDIR)/../manifest:
	# noop

clean:
	rm -rf $(OBJDIR)/* $(APPNAME)

}

set mhargs {}
foreach s [lsort $src] {
  append mhargs "\$(OBJDIR)/${s}_.c:\$(OBJDIR)/$s.h <<<NEXT_LINE>>>"
  set extra_h($s) { }
}
append mhargs "\$(SRCDIR)/sqlite3.h <<<NEXT_LINE>>>"
append mhargs "\$(SRCDIR)/th.h <<<NEXT_LINE>>>"
#append mhargs "\$(SRCDIR)/cson_amalgamation.h <<<NEXT_LINE>>>"
append mhargs "\$(OBJDIR)/VERSION.h"
set mhargs [string map [list <<<NEXT_LINE>>> \\\n\t] $mhargs]
writeln "\$(OBJDIR)/page_index.h: \$(TRANS_SRC) \$(OBJDIR)/mkindex"
writeln "\t\$(OBJDIR)/mkindex \$(TRANS_SRC) >\$@\n"

writeln "\$(OBJDIR)/builtin_data.h: \$(OBJDIR)/mkbuiltin \$(EXTRA_FILES)"
writeln "\t\$(OBJDIR)/mkbuiltin --prefix \$(SRCDIR)/ \$(EXTRA_FILES) >\$@\n"

writeln "\$(OBJDIR)/headers:\t\$(OBJDIR)/page_index.h \$(OBJDIR)/builtin_data.h \$(OBJDIR)/makeheaders \$(OBJDIR)/VERSION.h"
writeln "\t\$(OBJDIR)/makeheaders $mhargs"
writeln "\ttouch \$(OBJDIR)/headers"







|













|
|







413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
$(SRCDIR)/../manifest:
	# noop

clean:
	rm -rf $(OBJDIR)/* $(APPNAME) $(COMPNAME)

}

set mhargs {}
foreach s [lsort $src] {
  append mhargs "\$(OBJDIR)/${s}_.c:\$(OBJDIR)/$s.h <<<NEXT_LINE>>>"
  set extra_h($s) { }
}
append mhargs "\$(SRCDIR)/sqlite3.h <<<NEXT_LINE>>>"
append mhargs "\$(SRCDIR)/th.h <<<NEXT_LINE>>>"
#append mhargs "\$(SRCDIR)/cson_amalgamation.h <<<NEXT_LINE>>>"
append mhargs "\$(OBJDIR)/VERSION.h"
set mhargs [string map [list <<<NEXT_LINE>>> \\\n\t] $mhargs]
writeln "\$(OBJDIR)/page_index.h \$(COMPNAME): \$(TRANS_SRC) \$(OBJDIR)/mkindex"
writeln "\t\$(OBJDIR)/mkindex --compfile \$(COMPNAME) \$(TRANS_SRC) >\$(OBJDIR)/page_index.h\n"

writeln "\$(OBJDIR)/builtin_data.h: \$(OBJDIR)/mkbuiltin \$(EXTRA_FILES)"
writeln "\t\$(OBJDIR)/mkbuiltin --prefix \$(SRCDIR)/ \$(EXTRA_FILES) >\$@\n"

writeln "\$(OBJDIR)/headers:\t\$(OBJDIR)/page_index.h \$(OBJDIR)/builtin_data.h \$(OBJDIR)/makeheaders \$(OBJDIR)/VERSION.h"
writeln "\t\$(OBJDIR)/makeheaders $mhargs"
writeln "\ttouch \$(OBJDIR)/headers"

Changes to src/mkindex.c.

128
129
130
131
132
133
134





135
136
137
138
139
140
141
int nLine;

/*
** Number of errors
*/
int nErr = 0;






/*
** Duplicate N characters of a string.
*/
char *string_dup(const char *zSrc, int n){
  char *z;
  if( n<0 ) n = strlen(zSrc);
  z = malloc( n+1 );







>
>
>
>
>







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
int nLine;

/*
** Number of errors
*/
int nErr = 0;

/*
** File name for completion bash script
*/
char *zComp;

/*
** Duplicate N characters of a string.
*/
char *string_dup(const char *zSrc, int n){
  char *z;
  if( n<0 ) n = strlen(zSrc);
  z = malloc( n+1 );
313
314
315
316
317
318
319
320
321
322
323
324











325
326
327
328
329
330
331

332
333
334
335
336
337
338
339
340
   }
   nUsed = nFixed;
}

/*
** Compare two entries
*/
int e_compare(const void *a, const void *b){
  const Entry *pA = (const Entry*)a;
  const Entry *pB = (const Entry*)b;
  return strcmp(pA->zPath, pB->zPath);
}












/*
** Build the binary search table.
*/
void build_table(void){
  int i;
  int nWeb = 0;


  qsort(aEntry, nFixed, sizeof(aEntry[0]), e_compare);

  printf(
    "/* Automatically generated code\n"
    "** DO NOT EDIT!\n"
    "**\n"
    "** This file was generated by the mkindex.exe program based on\n"
    "** comments in other Fossil source files.\n"







|




>
>
>
>
>
>
>
>
>
>
>







>

|







318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
   }
   nUsed = nFixed;
}

/*
** Compare two entries
*/
int e_compare_path(const void *a, const void *b){
  const Entry *pA = (const Entry*)a;
  const Entry *pB = (const Entry*)b;
  return strcmp(pA->zPath, pB->zPath);
}

/*
** Compare two entries by type
*/
int e_compare_type(const void *a, const void *b){
  const Entry *pA = (const Entry*)a;
  const Entry *pB = (const Entry*)b;
  if( pA->eType < pB->eType ) return -1;
  if( pA->eType > pB->eType ) return 1;
  return 0;
}

/*
** Build the binary search table.
*/
void build_table(void){
  int i;
  int nWeb = 0;
  FILE *comp;

  qsort(aEntry, nFixed, sizeof(aEntry[0]), e_compare_path);

  printf(
    "/* Automatically generated code\n"
    "** DO NOT EDIT!\n"
    "**\n"
    "** This file was generated by the mkindex.exe program based on\n"
    "** comments in other Fossil source files.\n"
386
387
388
389
390
391
392









































393
394
395
396
397
398
399
      aEntry[i].iHelp,
      aEntry[i].eType
    );
    if( aEntry[i].zIf ) printf("#endif\n");
  }
  printf("};\n");
  printf("#define FOSSIL_FIRST_CMD %d\n", nWeb);









































}

/*
** Process a single file of input
*/
void process_file(void){
  FILE *in = fopen(zFile, "r");







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
      aEntry[i].iHelp,
      aEntry[i].eType
    );
    if( aEntry[i].zIf ) printf("#endif\n");
  }
  printf("};\n");
  printf("#define FOSSIL_FIRST_CMD %d\n", nWeb);
  
  /* Generate bash completion script */
  comp = fopen(zComp, "w");
  if( comp==0 ){
    fprintf(stderr,"%s: cannot open completion script file\n", zComp);
  }else{
    qsort(aEntry, nFixed, sizeof(aEntry[0]), e_compare_type);
    
    fprintf(comp,
      "_fossil_comp(){\n"
        "local cur opts1 opts2\n"
        "COMPREPLY=()\n"
        "cur=\"${COMP_WORDS[COMP_CWORD]}\"\n"
    );
    fprintf(comp, "opts1=\"");
    for(i=nWeb+1;
        i<nFixed && aEntry[i].eType==(CMDFLAG_COMMAND|CMDFLAG_1ST_TIER);
        i++)
    {
      fprintf(comp, "%s ", aEntry[i].zPath);
    }
    fprintf(comp, "\"\n");
    fprintf(comp, "opts2=\"");
    for( ;
        i<nFixed && aEntry[i].eType==(CMDFLAG_COMMAND|CMDFLAG_2ND_TIER);
        i++)
    {
      fprintf(comp, "%s ", aEntry[i].zPath);
    }
    fprintf(comp, "\"\n");
    fprintf(comp,
        "COMPREPLY=($(compgen -W \"${opts1}\" -- ${cur}))\n"
        "if [ ${#COMPREPLY[@]} -eq 0 ]; then\n"
          "COMPREPLY=($(compgen -W \"${opts2}\" -- ${cur}))\n"
        "fi\n"
        "return 0\n"
      "}\n"
      "complete -F _fossil_comp fossil"
    );
    fclose(comp);
  }
}

/*
** Process a single file of input
*/
void process_file(void){
  FILE *in = fopen(zFile, "r");
413
414
415
416
417
418
419







420
421
422
423
424
425
  fclose(in);
  nUsed = nFixed;
}

int main(int argc, char **argv){
  int i;
  for(i=1; i<argc; i++){







    zFile = argv[i];
    process_file();
  }
  build_table();
  return nErr;
}







>
>
>
>
>
>
>






471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
  fclose(in);
  nUsed = nFixed;
}

int main(int argc, char **argv){
  int i;
  for(i=1; i<argc; i++){
    if( argv[i][0]=='-' && strcmp(argv[i], "--compfile")==0 ){
      if( ++i < argc ){
        zComp = argv[i];
      }else{
        fprintf(stderr,"no file name supplied to --compfile\n");
      }
    }
    zFile = argv[i];
    process_file();
  }
  build_table();
  return nErr;
}