Fossil

Diff
Login

Differences From Artifact [12b03962df]:

To Artifact [31e911e2f7]:


43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
43
44
45
46
47
48
49

50
51
52
53
54
55
56
57







-
+







** lineLength characters.  Indent all subsequent lines by indent.
**
** Return the number of newlines that are output.
*/
int comment_print(const char *zText, int indent, int lineLength){
  int tlen = lineLength - indent;
  int len = 0, doIndent = 0, lineCnt = 0;
  const char *zBuf;
  const char *zLine;

#if defined(_WIN32)
  if( lineLength<0 ){
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO));
    if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){
      tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent;
83
84
85
86
87
88
89
90

91
92
93
94
95
96

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
83
84
85
86
87
88
89

90
91
92
93
94
95

96
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







-
+





-
+











-
-
+
+



-
-
+
+







  if( zText[0]==0 ){
    if( !doIndent ){
      fossil_print("\n");
      lineCnt++;
    }
    return lineCnt;
  }
  zBuf = zText;
  zLine = zText;
  for(;;){
    if( zText[0]==0 ){
      if( doIndent ){
        fossil_print("%*s", indent, "");
      }
      fossil_print("%.*s", (int)(zText - zBuf), zBuf);
      fossil_print("%.*s", (int)(zText - zLine), zLine);
      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>zBuf && !fossil_isspace(zText[0]) ){ zText--; }
      fossil_print("%.*s", (int)(zText - zBuf), zBuf);
      while( zText>zLine && !fossil_isspace(zText[0]) ){ zText--; }
      fossil_print("%.*s", (int)(zText - zLine), zLine);
      if( fossil_force_newline() ){
        lineCnt++;
      }
      zBuf = zText;
      if( !zBuf++ ) break;
      zLine = zText;
      if( !zLine++ ) break;
      len = 0;
    }
    zText++;
  }
  return lineCnt;
}