Fossil SCM
Minor stylistic changes to the comment formatter.
Commit
cc9c422d8325bb0af5c3cf533f7a4cc1137094c444441757bf9ed59229e043f9
Parent
490d38ff2e0079e…
1 file changed
+12
-9
+12
-9
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -2,11 +2,11 @@ | ||
| 2 | 2 | ** Copyright (c) 2007 D. Richard Hipp |
| 3 | 3 | ** |
| 4 | 4 | ** This program is free software; you can redistribute it and/or |
| 5 | 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | - | |
| 7 | +** | |
| 8 | 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | 9 | ** but without any warranty; without even the implied warranty of |
| 10 | 10 | ** merchantability or fitness for a particular purpose. |
| 11 | 11 | ** |
| 12 | 12 | ** Author contact information: |
| @@ -152,18 +152,17 @@ | ||
| 152 | 152 | ** sequences, respectively, the other invalid lead bytes 0xF8 to 0xFF are |
| 153 | 153 | ** treated as invalid 1-byte sequences (as lone trail bytes). |
| 154 | 154 | ** Combining characters and East Asian Wide and Fullwidth characters are counted |
| 155 | 155 | ** as one, so this function does not calculate the effective "display width". |
| 156 | 156 | */ |
| 157 | -int strlen_utf8(const char *zString, int lengthBytes) | |
| 158 | -{ | |
| 157 | +int strlen_utf8(const char *zString, int lengthBytes){ | |
| 158 | + int i; /* Counted bytes. */ | |
| 159 | + int lengthUTF8; /* Counted UTF-8 sequences. */ | |
| 159 | 160 | #if 0 |
| 160 | 161 | assert( lengthBytes>=0 ); |
| 161 | 162 | #endif |
| 162 | - int i; /* Counted bytes. */ | |
| 163 | - int lengthUTF8; /* Counted UTF-8 sequences. */ | |
| 164 | - for( i=0, lengthUTF8=0; i<lengthBytes; i++, lengthUTF8++ ){ | |
| 163 | + for(i=0, lengthUTF8=0; i<lengthBytes; i++, lengthUTF8++){ | |
| 165 | 164 | char c = zString[i]; |
| 166 | 165 | int cchUTF8=1; /* Code units consumed. */ |
| 167 | 166 | int maxUTF8=1; /* Expected sequence length. */ |
| 168 | 167 | if( (c&0xe0)==0xc0 )maxUTF8=2; /* UTF-8 lead byte 110vvvvv */ |
| 169 | 168 | else if( (c&0xf0)==0xe0 )maxUTF8=3; /* UTF-8 lead byte 1110vvvv */ |
| @@ -227,20 +226,24 @@ | ||
| 227 | 226 | if( lineChars<=0 ) return; |
| 228 | 227 | #if 0 |
| 229 | 228 | assert( indent<sizeof(zBuf)-5 ); /* See following comments to explain */ |
| 230 | 229 | assert( origIndent<sizeof(zBuf)-5 ); /* these limits. */ |
| 231 | 230 | #endif |
| 232 | - if( indent>sizeof(zBuf)-6 ) /* Limit initial indent to fit output buffer. */ | |
| 231 | + if( indent>sizeof(zBuf)-6 ){ | |
| 232 | + /* Limit initial indent to fit output buffer. */ | |
| 233 | 233 | indent = sizeof(zBuf)-6; |
| 234 | + } | |
| 234 | 235 | comment_calc_indent(zLine, indent, trimCrLf, trimSpace, &index); |
| 235 | 236 | if( indent>0 ){ |
| 236 | - for( i=0; i<indent; i++ ){ | |
| 237 | + for(i=0; i<indent; i++){ | |
| 237 | 238 | zBuf[iBuf++] = ' '; |
| 238 | 239 | } |
| 239 | 240 | } |
| 240 | - if( origIndent>sizeof(zBuf)-6 ) /* Limit line indent to fit output buffer. */ | |
| 241 | + if( origIndent>sizeof(zBuf)-6 ){ | |
| 242 | + /* Limit line indent to fit output buffer. */ | |
| 241 | 243 | origIndent = sizeof(zBuf)-6; |
| 244 | + } | |
| 242 | 245 | maxChars = lineChars; |
| 243 | 246 | for(;;){ |
| 244 | 247 | int useChars = 1; |
| 245 | 248 | char c = zLine[index]; |
| 246 | 249 | /* Flush the output buffer if there's no space left for at least one more |
| 247 | 250 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -2,11 +2,11 @@ | |
| 2 | ** Copyright (c) 2007 D. Richard Hipp |
| 3 | ** |
| 4 | ** This program is free software; you can redistribute it and/or |
| 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but without any warranty; without even the implied warranty of |
| 10 | ** merchantability or fitness for a particular purpose. |
| 11 | ** |
| 12 | ** Author contact information: |
| @@ -152,18 +152,17 @@ | |
| 152 | ** sequences, respectively, the other invalid lead bytes 0xF8 to 0xFF are |
| 153 | ** treated as invalid 1-byte sequences (as lone trail bytes). |
| 154 | ** Combining characters and East Asian Wide and Fullwidth characters are counted |
| 155 | ** as one, so this function does not calculate the effective "display width". |
| 156 | */ |
| 157 | int strlen_utf8(const char *zString, int lengthBytes) |
| 158 | { |
| 159 | #if 0 |
| 160 | assert( lengthBytes>=0 ); |
| 161 | #endif |
| 162 | int i; /* Counted bytes. */ |
| 163 | int lengthUTF8; /* Counted UTF-8 sequences. */ |
| 164 | for( i=0, lengthUTF8=0; i<lengthBytes; i++, lengthUTF8++ ){ |
| 165 | char c = zString[i]; |
| 166 | int cchUTF8=1; /* Code units consumed. */ |
| 167 | int maxUTF8=1; /* Expected sequence length. */ |
| 168 | if( (c&0xe0)==0xc0 )maxUTF8=2; /* UTF-8 lead byte 110vvvvv */ |
| 169 | else if( (c&0xf0)==0xe0 )maxUTF8=3; /* UTF-8 lead byte 1110vvvv */ |
| @@ -227,20 +226,24 @@ | |
| 227 | if( lineChars<=0 ) return; |
| 228 | #if 0 |
| 229 | assert( indent<sizeof(zBuf)-5 ); /* See following comments to explain */ |
| 230 | assert( origIndent<sizeof(zBuf)-5 ); /* these limits. */ |
| 231 | #endif |
| 232 | if( indent>sizeof(zBuf)-6 ) /* Limit initial indent to fit output buffer. */ |
| 233 | indent = sizeof(zBuf)-6; |
| 234 | comment_calc_indent(zLine, indent, trimCrLf, trimSpace, &index); |
| 235 | if( indent>0 ){ |
| 236 | for( i=0; i<indent; i++ ){ |
| 237 | zBuf[iBuf++] = ' '; |
| 238 | } |
| 239 | } |
| 240 | if( origIndent>sizeof(zBuf)-6 ) /* Limit line indent to fit output buffer. */ |
| 241 | origIndent = sizeof(zBuf)-6; |
| 242 | maxChars = lineChars; |
| 243 | for(;;){ |
| 244 | int useChars = 1; |
| 245 | char c = zLine[index]; |
| 246 | /* Flush the output buffer if there's no space left for at least one more |
| 247 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -2,11 +2,11 @@ | |
| 2 | ** Copyright (c) 2007 D. Richard Hipp |
| 3 | ** |
| 4 | ** This program is free software; you can redistribute it and/or |
| 5 | ** modify it under the terms of the Simplified BSD License (also |
| 6 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 7 | ** |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but without any warranty; without even the implied warranty of |
| 10 | ** merchantability or fitness for a particular purpose. |
| 11 | ** |
| 12 | ** Author contact information: |
| @@ -152,18 +152,17 @@ | |
| 152 | ** sequences, respectively, the other invalid lead bytes 0xF8 to 0xFF are |
| 153 | ** treated as invalid 1-byte sequences (as lone trail bytes). |
| 154 | ** Combining characters and East Asian Wide and Fullwidth characters are counted |
| 155 | ** as one, so this function does not calculate the effective "display width". |
| 156 | */ |
| 157 | int strlen_utf8(const char *zString, int lengthBytes){ |
| 158 | int i; /* Counted bytes. */ |
| 159 | int lengthUTF8; /* Counted UTF-8 sequences. */ |
| 160 | #if 0 |
| 161 | assert( lengthBytes>=0 ); |
| 162 | #endif |
| 163 | for(i=0, lengthUTF8=0; i<lengthBytes; i++, lengthUTF8++){ |
| 164 | char c = zString[i]; |
| 165 | int cchUTF8=1; /* Code units consumed. */ |
| 166 | int maxUTF8=1; /* Expected sequence length. */ |
| 167 | if( (c&0xe0)==0xc0 )maxUTF8=2; /* UTF-8 lead byte 110vvvvv */ |
| 168 | else if( (c&0xf0)==0xe0 )maxUTF8=3; /* UTF-8 lead byte 1110vvvv */ |
| @@ -227,20 +226,24 @@ | |
| 226 | if( lineChars<=0 ) return; |
| 227 | #if 0 |
| 228 | assert( indent<sizeof(zBuf)-5 ); /* See following comments to explain */ |
| 229 | assert( origIndent<sizeof(zBuf)-5 ); /* these limits. */ |
| 230 | #endif |
| 231 | if( indent>sizeof(zBuf)-6 ){ |
| 232 | /* Limit initial indent to fit output buffer. */ |
| 233 | indent = sizeof(zBuf)-6; |
| 234 | } |
| 235 | comment_calc_indent(zLine, indent, trimCrLf, trimSpace, &index); |
| 236 | if( indent>0 ){ |
| 237 | for(i=0; i<indent; i++){ |
| 238 | zBuf[iBuf++] = ' '; |
| 239 | } |
| 240 | } |
| 241 | if( origIndent>sizeof(zBuf)-6 ){ |
| 242 | /* Limit line indent to fit output buffer. */ |
| 243 | origIndent = sizeof(zBuf)-6; |
| 244 | } |
| 245 | maxChars = lineChars; |
| 246 | for(;;){ |
| 247 | int useChars = 1; |
| 248 | char c = zLine[index]; |
| 249 | /* Flush the output buffer if there's no space left for at least one more |
| 250 |