Fossil

Check-in [2dca9b82]
Login

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

Overview
Comment:More coding style fixes.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | comment-formatter-utf8
Files: files | file ages | folders
SHA1: 2dca9b82d943d36caa1cc95060dbf1f892bc01f8
User & Date: florian 2018-11-16 14:02:00.000
Context
2018-11-16
19:39
Fix a bug (already present on trunk) with the (non-legacy) comment printing algorithm, detected while running the regression tests from test/comment.test with UTF-8 text: the function to print the indent (modified to a calculate-only function on this branch) was handed a pointer to the current line index and the current line index, thus performing checks at (current line index * 2), causing random increments of the current line index. ... (check-in: 70dd8f74 user: florian tags: comment-formatter-utf8)
14:02
More coding style fixes. ... (check-in: 2dca9b82 user: florian tags: comment-formatter-utf8)
11:26
Coding style fixes. ... (check-in: aadbbb38 user: florian tags: comment-formatter-utf8)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/comformat.c.
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
  assert( indent<sizeof(zBuf)-5 );       /* See following comments to explain */
  assert( origIndent<sizeof(zBuf)-5 );   /* these limits. */
#endif
  if( indent>sizeof(zBuf)-6 )   /* Limit initial indent to fit output buffer. */
    indent = sizeof(zBuf)-6;
  comment_calc_indent(zLine, indent, trimCrLf, trimSpace, &index);
  if( indent>0 ){
    for ( i=0; i<indent; i++ ){
      zBuf[iBuf++] = ' ';
    }
  }
  if( origIndent>sizeof(zBuf)-6 )  /* Limit line indent to fit output buffer. */
    origIndent = sizeof(zBuf)-6;
  maxChars = lineChars;
  for(;;){







|







230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
  assert( indent<sizeof(zBuf)-5 );       /* See following comments to explain */
  assert( origIndent<sizeof(zBuf)-5 );   /* these limits. */
#endif
  if( indent>sizeof(zBuf)-6 )   /* Limit initial indent to fit output buffer. */
    indent = sizeof(zBuf)-6;
  comment_calc_indent(zLine, indent, trimCrLf, trimSpace, &index);
  if( indent>0 ){
    for( i=0; i<indent; i++ ){
      zBuf[iBuf++] = ' ';
    }
  }
  if( origIndent>sizeof(zBuf)-6 )  /* Limit line indent to fit output buffer. */
    origIndent = sizeof(zBuf)-6;
  maxChars = lineChars;
  for(;;){
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
    }else{
      if( origBreak && index>0 ){
        const char *zCurrent = &zLine[index];
        if( comment_check_orig(zOrigText, zCurrent, &charCnt, &lineCnt) ){
          zBuf[iBuf++] = '\n';
          comment_calc_indent(zCurrent, origIndent, trimCrLf, trimSpace,
                              &index);
          for ( i=0; i<origIndent; i++ ){
            zBuf[iBuf++] = ' ';
          }
          maxChars = lineChars;
        }
      }
      index++;
    }







|







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
    }else{
      if( origBreak && index>0 ){
        const char *zCurrent = &zLine[index];
        if( comment_check_orig(zOrigText, zCurrent, &charCnt, &lineCnt) ){
          zBuf[iBuf++] = '\n';
          comment_calc_indent(zCurrent, origIndent, trimCrLf, trimSpace,
                              &index);
          for( i=0; i<origIndent; i++ ){
            zBuf[iBuf++] = ' ';
          }
          maxChars = lineChars;
        }
      }
      index++;
    }
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
      else if( (c&0xf8)==0xf0 )maxUTF8=4;     /* UTF-8 lead byte 11110vvv */
      while( cchUTF8<maxUTF8 &&
              (zLine[index]&0xc0)==0x80 ){    /* UTF-8 trail byte 10vvvvvv */
        cchUTF8++;
        zBuf[iBuf++] = zLine[index++];
      }
      maxChars--;
    }
    else {
      zBuf[iBuf++] = c;
      maxChars -= useChars;
    }
    if( maxChars<=0 ) break;
    if( c=='\n' ) break;
  }
  if( charCnt>0 ){
    zBuf[iBuf++] = '\n';
    lineCnt++;
  }
  /* Flush the remaining output buffer. */
  if( iBuf>0 ) {
    zBuf[iBuf]=0;
    iBuf=0;
    fossil_print("%s", zBuf);
  }
  if( pLineCnt ){
    *pLineCnt += lineCnt;
  }







<
|











|







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
      else if( (c&0xf8)==0xf0 )maxUTF8=4;     /* UTF-8 lead byte 11110vvv */
      while( cchUTF8<maxUTF8 &&
              (zLine[index]&0xc0)==0x80 ){    /* UTF-8 trail byte 10vvvvvv */
        cchUTF8++;
        zBuf[iBuf++] = zLine[index++];
      }
      maxChars--;

    }else{
      zBuf[iBuf++] = c;
      maxChars -= useChars;
    }
    if( maxChars<=0 ) break;
    if( c=='\n' ) break;
  }
  if( charCnt>0 ){
    zBuf[iBuf++] = '\n';
    lineCnt++;
  }
  /* Flush the remaining output buffer. */
  if( iBuf>0 ){
    zBuf[iBuf]=0;
    iBuf=0;
    fossil_print("%s", zBuf);
  }
  if( pLineCnt ){
    *pLineCnt += lineCnt;
  }