Fossil

Check-in [29d3a2ed]
Login

Check-in [29d3a2ed]

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

Overview
Comment:Ensure the line buffer for the legacy comment printing algorithm can hold maximum-length UTF-8 sequences.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | comment-formatter-utf8
Files: files | file ages | folders
SHA1: 29d3a2ed4ee03c7f7ba222b7f2fddfa27c5cd823
User & Date: florian 2018-11-15 15:32:00
Context
2018-11-16
11:14
For better word breaking results with the (non-legacy) comment printing algorithm, make sure the lookahead to the next space character is UTF-8-aware. Also make sure the per-line remaining character count is decremented properly for UTF-8 sequences. The neuralgic points now handle UTF-8 sequences correctly, and they could be enhanced to work with the effective display width, if required (to handle combining characters, and East Asian Wide and Fullwidth characters). ... (check-in: c9ec3d18 user: florian tags: comment-formatter-utf8)
2018-11-15
15:32
Ensure the line buffer for the legacy comment printing algorithm can hold maximum-length UTF-8 sequences. ... (check-in: 29d3a2ed user: florian tags: comment-formatter-utf8)
15:16
Fix a problem with initial indent introduced by the previous check-in, so that all regression tests from test/comment.test now succeed. Also eliminate three more calls to fossil_print(). Regarding performance, the legacy comment printing algorithm is outnumbered by factor 2-3, with these changes. ... (check-in: b029ed22 user: florian tags: comment-formatter-utf8)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/comformat.c.

320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335
  if( width<0 ){
    comment_set_maxchars(indent, &maxChars);
  }
  if( zText==0 ) zText = "(NULL)";
  if( maxChars<=0 ){
    maxChars = strlen(zText);
  }

  if( maxChars >= (sizeof(zBuffer)) ){
    zBuf = fossil_malloc(maxChars+1);
  }else{
    zBuf = zBuffer;
  }
  for(;;){
    while( fossil_isspace(zText[0]) ){ zText++; }
    if( zText[0]==0 ){
      if( doIndent==0 ){







>
|
|







320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
  if( width<0 ){
    comment_set_maxchars(indent, &maxChars);
  }
  if( zText==0 ) zText = "(NULL)";
  if( maxChars<=0 ){
    maxChars = strlen(zText);
  }
  /* Ensure the buffer can hold the longest-possible UTF-8 sequences. */
  if( maxChars >= (sizeof(zBuffer)/4-1) ){
    zBuf = fossil_malloc(maxChars*4+1);
  }else{
    zBuf = zBuffer;
  }
  for(;;){
    while( fossil_isspace(zText[0]) ){ zText++; }
    if( zText[0]==0 ){
      if( doIndent==0 ){