Fossil

Check-in [d547629280]
Login

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

Overview
Comment:Merge updates from branch. Gracefully handle the case where the first line contains no spaces.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: d54762928054fa44c6f184db87cef6b78a5c033b
User & Date: mistachkin 2014-06-19 05:43:18.017
Context
2014-06-19
21:25
Complete re-write of the comment printing algorithm, taking the preservation of any pre-existing formatting within the comment into account. No attempt is made to avoid breaking a line in the middle of a word. check-in: 89aa595f88 user: mistachkin tags: experimental
05:43
Merge updates from branch. Gracefully handle the case where the first line contains no spaces. check-in: d547629280 user: mistachkin tags: experimental
04:21
Merge updates from trunk. Adjust tests to account for comment formatting changes. One key test is still failing. check-in: 59d80134ff user: mistachkin tags: respectformatting
03:04
Merge variable name change. check-in: 05ea665fef user: mistachkin tags: experimental
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/comformat.c.
97
98
99
100
101
102
103

104
105
106
107

108

109





110
111
112
113
114
115
116
117
118
119
120
      if( fossil_force_newline() ){
        lineCnt++;
      }
      break;
    }
    len += ((zText[0]=='\t') ? 8 : 1);
    if( zText[0]=='\n' || len>=tlen ){

      if( doIndent ){
        fossil_print("%*s", indent, "");
      }
      doIndent = 1;

      while( zText>zLine && !fossil_isspace(zText[0]) ){ zText--; }

      fossil_print("%.*s", (int)(zText - zLine), zLine);





      if( fossil_force_newline() ){
        lineCnt++;
      }
      zLine = zText;
      if( !zLine++ ) break;
      len = 0;
    }
    zText++;
  }
  return lineCnt;
}







>




>

>
|
>
>
>
>
>



<







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

121
122
123
124
125
126
127
      if( fossil_force_newline() ){
        lineCnt++;
      }
      break;
    }
    len += ((zText[0]=='\t') ? 8 : 1);
    if( zText[0]=='\n' || len>=tlen ){
      const char *zNewLine;
      if( doIndent ){
        fossil_print("%*s", indent, "");
      }
      doIndent = 1;
      zNewLine = zText + 1;
      while( zText>zLine && !fossil_isspace(zText[0]) ){ zText--; }
      if( zText>zLine ){
        fossil_print("%.*s", (int)(zText - zLine), zLine);
        zLine = zText;
      }else{
        fossil_print("%.*s", (int)(zNewLine - zLine), zLine);
        zLine = zNewLine;
      }
      if( fossil_force_newline() ){
        lineCnt++;
      }

      if( !zLine++ ) break;
      len = 0;
    }
    zText++;
  }
  return lineCnt;
}
Added test/comment.test.


















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Copyright (c) 2014 D. Richard Hipp
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the Simplified BSD License (also
# known as the "2-Clause License" or "FreeBSD License".)
#
# This program is distributed in the hope that it will be useful,
# but without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose.
#
# Author contact information:
#   drh@hwaci.com
#   http://www.hwaci.com/drh/
#
############################################################################
#
# Test comment formatting and printing.
#

fossil test-comment-format "" ""
test comment-1 {$RESULT eq "\n(1 lines output)"}

###############################################################################

fossil test-comment-format --decode "" ""
test comment-2 {$RESULT eq "\n(1 lines output)"}

###############################################################################

fossil test-comment-format " " "this is a short comment." 26
test comment-3 {$RESULT eq " this is a short comment.\n(1 lines output)"}

###############################################################################

fossil test-comment-format --decode " " "this is a short comment." 26
test comment-4 {$RESULT eq " this is a short comment.\n(1 lines output)"}

###############################################################################

fossil test-comment-format "*PREFIX* " "this is a short comment." 26
test comment-5 {$RESULT eq "*PREFIX* this is a short\n         comment.\n(2 lines output)"}

###############################################################################

fossil test-comment-format --decode "*PREFIX* " "this is a short comment." 26
test comment-6 {$RESULT eq "*PREFIX* this is a short\n         comment.\n(2 lines output)"}

###############################################################################

fossil test-comment-format "" "this\\sis\\sa\\sshort\\scomment."
test comment-7 {$RESULT eq "this\\sis\\sa\\sshort\\scomment.\n(1 lines output)"}

###############################################################################

fossil test-comment-format --decode "" "this\\sis\\sa\\sshort\\scomment." 26
test comment-8 {$RESULT eq "this is a short comment.\n(1 lines output)"}
Changes to test/tester.tcl.
19
20
21
22
23
24
25

26
27
28
29
30
31
32
#
#     tclsh ../test/tester.tcl ../bld/fossil
#
# Where ../test/tester.tcl is the name of this file and ../bld/fossil
# is the name of the executable to be tested.
#


set testdir [file normalize [file dir $argv0]]
set fossilexe [file normalize [lindex $argv 0]]
set argv [lrange $argv 1 end]

set i [lsearch $argv -halt]
if {$i>=0} {
  set HALT 1







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
#     tclsh ../test/tester.tcl ../bld/fossil
#
# Where ../test/tester.tcl is the name of this file and ../bld/fossil
# is the name of the executable to be tested.
#

set testrundir [pwd]
set testdir [file normalize [file dir $argv0]]
set fossilexe [file normalize [lindex $argv 0]]
set argv [lrange $argv 1 end]

set i [lsearch $argv -halt]
if {$i>=0} {
  set HALT 1
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  set tempPath [string map [list \\ /] $tempPath]
}

# start protocol
#
proc protInit {cmd} {
  if {$::PROT} {
    set out [open "prot" w]
    fconfigure $out -translation platform
    puts $out "starting tests with:$cmd"
    close $out
  }
}

# write protocol
#
proc protOut {msg} {
  puts "$msg"
  if {$::PROT} {
    set out [open "prot" a]
    fconfigure $out -translation platform
    puts $out "$msg"
    close $out
  }
}

# Run the fossil program
#
proc fossil {args} {
  global fossilexe
  set cmd $fossilexe
  foreach a $args {
    lappend cmd $a
  }
  protOut $cmd

  flush stdout
  set rc [catch {eval exec $cmd} result]
  global RESULT CODE
  set CODE $rc
  if {$rc} {puts "ERROR: $result"}
  set RESULT $result
}

# Read a file into memory.
#
proc read_file {filename} {
  set in [open $filename r]







|

|







|

|

|


















|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  set tempPath [string map [list \\ /] $tempPath]
}

# start protocol
#
proc protInit {cmd} {
  if {$::PROT} {
    set out [open [file join $::testrundir prot] w]
    fconfigure $out -translation platform
    puts $out "starting tests with: $cmd"
    close $out
  }
}

# write protocol
#
proc protOut {msg} {
  puts stdout $msg
  if {$::PROT} {
    set out [open [file join $::testrundir prot] a]
    fconfigure $out -translation platform
    puts $out $msg
    close $out
  }
}

# Run the fossil program
#
proc fossil {args} {
  global fossilexe
  set cmd $fossilexe
  foreach a $args {
    lappend cmd $a
  }
  protOut $cmd

  flush stdout
  set rc [catch {eval exec $cmd} result]
  global RESULT CODE
  set CODE $rc
  if {$rc} {protOut "ERROR: $result"}
  set RESULT $result
}

# Read a file into memory.
#
proc read_file {filename} {
  set in [open $filename r]