Fossil SCM
Style en comment fixes, backported from [d57f0a9361]
Commit
c7b2b2ed3ce6b253495d2695ddc32b76427fc163
Parent
1167d7b14569c61…
2 files changed
+14
-13
+19
-7
+14
-13
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -882,46 +882,47 @@ | ||
| 882 | 882 | if( pnFBcard ) *pnFBcard = nFBcard; |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | /* |
| 886 | 886 | ** Issue a warning and give the user an opportunity to abandon out |
| 887 | -** if unicode or a \r\n line ending is seen in a text file. | |
| 887 | +** if a Unicode (UTF-16) byte-order-mark (BOM) or a \r\n line ending | |
| 888 | +** is seen in a text file. | |
| 888 | 889 | */ |
| 889 | -static void encoding_warning(const Blob *p, int crnlOk, const char *zFilename){ | |
| 890 | - int looksLike; /* return value of looks_like_text() */ | |
| 890 | +static void commit_warning(const Blob *p, int crnlOk, const char *zFilename){ | |
| 891 | + int eType; /* return value of looks_like_text() */ | |
| 891 | 892 | char *zMsg; /* Warning message */ |
| 892 | 893 | Blob fname; /* Relative pathname of the file */ |
| 893 | 894 | static int allOk = 0; /* Set to true to disable this routine */ |
| 894 | 895 | |
| 895 | 896 | if( allOk ) return; |
| 896 | - looksLike = looks_like_text(p); | |
| 897 | - if( looksLike<0 ){ | |
| 898 | - const char *type; | |
| 897 | + eType = looks_like_text(p); | |
| 898 | + if( eType<0 ){ | |
| 899 | + const char *zWarning ; | |
| 899 | 900 | Blob ans; |
| 900 | 901 | char cReply; |
| 901 | 902 | |
| 902 | - if( looksLike&1 ){ | |
| 903 | + if( eType&1 ){ | |
| 903 | 904 | if( crnlOk ){ |
| 904 | 905 | return; /* We don't want CrLf warnings for this file. */ |
| 905 | 906 | } |
| 906 | - type = "CR/NL line endings"; | |
| 907 | + zWarning = "CR/NL line endings"; | |
| 907 | 908 | }else{ |
| 908 | - type = "unicode"; | |
| 909 | + zWarning = "Unicode"; | |
| 909 | 910 | } |
| 910 | 911 | file_relative_name(zFilename, &fname, 0); |
| 911 | 912 | blob_zero(&ans); |
| 912 | 913 | zMsg = mprintf( |
| 913 | - "%s contains %s; commit anyhow (a=all/y/N)?", | |
| 914 | - blob_str(&fname), type); | |
| 914 | + "%s contains %s. commit anyhow (a=all/y/N)? ", | |
| 915 | + blob_str(&fname), zWarning ); | |
| 915 | 916 | prompt_user(zMsg, &ans); |
| 916 | 917 | fossil_free(zMsg); |
| 917 | 918 | cReply = blob_str(&ans)[0]; |
| 918 | 919 | if( cReply=='a' || cReply=='A' ){ |
| 919 | 920 | allOk = 1; |
| 920 | 921 | }else if( cReply!='y' && cReply!='Y' ){ |
| 921 | 922 | fossil_fatal("Abandoning commit due to %s in %s", |
| 922 | - type, blob_str(&fname)); | |
| 923 | + zWarning , blob_str(&fname)); | |
| 923 | 924 | } |
| 924 | 925 | blob_reset(&ans); |
| 925 | 926 | blob_reset(&fname); |
| 926 | 927 | } |
| 927 | 928 | } |
| @@ -1232,11 +1233,11 @@ | ||
| 1232 | 1233 | /* Instead of file content, put link destination path */ |
| 1233 | 1234 | blob_read_link(&content, zFullname); |
| 1234 | 1235 | }else{ |
| 1235 | 1236 | blob_read_from_file(&content, zFullname); |
| 1236 | 1237 | } |
| 1237 | - encoding_warning(&content, crnlOk, zFullname); | |
| 1238 | + commit_warning(&content, crnlOk, zFullname); | |
| 1238 | 1239 | if( chnged==1 && contains_merge_marker(&content) ){ |
| 1239 | 1240 | Blob fname; /* Relative pathname of the file */ |
| 1240 | 1241 | |
| 1241 | 1242 | nConflict++; |
| 1242 | 1243 | file_relative_name(zFullname, &fname, 0); |
| 1243 | 1244 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -882,46 +882,47 @@ | |
| 882 | if( pnFBcard ) *pnFBcard = nFBcard; |
| 883 | } |
| 884 | |
| 885 | /* |
| 886 | ** Issue a warning and give the user an opportunity to abandon out |
| 887 | ** if unicode or a \r\n line ending is seen in a text file. |
| 888 | */ |
| 889 | static void encoding_warning(const Blob *p, int crnlOk, const char *zFilename){ |
| 890 | int looksLike; /* return value of looks_like_text() */ |
| 891 | char *zMsg; /* Warning message */ |
| 892 | Blob fname; /* Relative pathname of the file */ |
| 893 | static int allOk = 0; /* Set to true to disable this routine */ |
| 894 | |
| 895 | if( allOk ) return; |
| 896 | looksLike = looks_like_text(p); |
| 897 | if( looksLike<0 ){ |
| 898 | const char *type; |
| 899 | Blob ans; |
| 900 | char cReply; |
| 901 | |
| 902 | if( looksLike&1 ){ |
| 903 | if( crnlOk ){ |
| 904 | return; /* We don't want CrLf warnings for this file. */ |
| 905 | } |
| 906 | type = "CR/NL line endings"; |
| 907 | }else{ |
| 908 | type = "unicode"; |
| 909 | } |
| 910 | file_relative_name(zFilename, &fname, 0); |
| 911 | blob_zero(&ans); |
| 912 | zMsg = mprintf( |
| 913 | "%s contains %s; commit anyhow (a=all/y/N)?", |
| 914 | blob_str(&fname), type); |
| 915 | prompt_user(zMsg, &ans); |
| 916 | fossil_free(zMsg); |
| 917 | cReply = blob_str(&ans)[0]; |
| 918 | if( cReply=='a' || cReply=='A' ){ |
| 919 | allOk = 1; |
| 920 | }else if( cReply!='y' && cReply!='Y' ){ |
| 921 | fossil_fatal("Abandoning commit due to %s in %s", |
| 922 | type, blob_str(&fname)); |
| 923 | } |
| 924 | blob_reset(&ans); |
| 925 | blob_reset(&fname); |
| 926 | } |
| 927 | } |
| @@ -1232,11 +1233,11 @@ | |
| 1232 | /* Instead of file content, put link destination path */ |
| 1233 | blob_read_link(&content, zFullname); |
| 1234 | }else{ |
| 1235 | blob_read_from_file(&content, zFullname); |
| 1236 | } |
| 1237 | encoding_warning(&content, crnlOk, zFullname); |
| 1238 | if( chnged==1 && contains_merge_marker(&content) ){ |
| 1239 | Blob fname; /* Relative pathname of the file */ |
| 1240 | |
| 1241 | nConflict++; |
| 1242 | file_relative_name(zFullname, &fname, 0); |
| 1243 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -882,46 +882,47 @@ | |
| 882 | if( pnFBcard ) *pnFBcard = nFBcard; |
| 883 | } |
| 884 | |
| 885 | /* |
| 886 | ** Issue a warning and give the user an opportunity to abandon out |
| 887 | ** if a Unicode (UTF-16) byte-order-mark (BOM) or a \r\n line ending |
| 888 | ** is seen in a text file. |
| 889 | */ |
| 890 | static void commit_warning(const Blob *p, int crnlOk, const char *zFilename){ |
| 891 | int eType; /* return value of looks_like_text() */ |
| 892 | char *zMsg; /* Warning message */ |
| 893 | Blob fname; /* Relative pathname of the file */ |
| 894 | static int allOk = 0; /* Set to true to disable this routine */ |
| 895 | |
| 896 | if( allOk ) return; |
| 897 | eType = looks_like_text(p); |
| 898 | if( eType<0 ){ |
| 899 | const char *zWarning ; |
| 900 | Blob ans; |
| 901 | char cReply; |
| 902 | |
| 903 | if( eType&1 ){ |
| 904 | if( crnlOk ){ |
| 905 | return; /* We don't want CrLf warnings for this file. */ |
| 906 | } |
| 907 | zWarning = "CR/NL line endings"; |
| 908 | }else{ |
| 909 | zWarning = "Unicode"; |
| 910 | } |
| 911 | file_relative_name(zFilename, &fname, 0); |
| 912 | blob_zero(&ans); |
| 913 | zMsg = mprintf( |
| 914 | "%s contains %s. commit anyhow (a=all/y/N)? ", |
| 915 | blob_str(&fname), zWarning ); |
| 916 | prompt_user(zMsg, &ans); |
| 917 | fossil_free(zMsg); |
| 918 | cReply = blob_str(&ans)[0]; |
| 919 | if( cReply=='a' || cReply=='A' ){ |
| 920 | allOk = 1; |
| 921 | }else if( cReply!='y' && cReply!='Y' ){ |
| 922 | fossil_fatal("Abandoning commit due to %s in %s", |
| 923 | zWarning , blob_str(&fname)); |
| 924 | } |
| 925 | blob_reset(&ans); |
| 926 | blob_reset(&fname); |
| 927 | } |
| 928 | } |
| @@ -1232,11 +1233,11 @@ | |
| 1233 | /* Instead of file content, put link destination path */ |
| 1234 | blob_read_link(&content, zFullname); |
| 1235 | }else{ |
| 1236 | blob_read_from_file(&content, zFullname); |
| 1237 | } |
| 1238 | commit_warning(&content, crnlOk, zFullname); |
| 1239 | if( chnged==1 && contains_merge_marker(&content) ){ |
| 1240 | Blob fname; /* Relative pathname of the file */ |
| 1241 | |
| 1242 | nConflict++; |
| 1243 | file_relative_name(zFullname, &fname, 0); |
| 1244 |
+19
-7
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -170,21 +170,33 @@ | ||
| 170 | 170 | *pnLine = nLine; |
| 171 | 171 | return a; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /* |
| 175 | -** Returns 1, if everything OK | |
| 176 | -** Returns 0 if the specified content appears to be binary or | |
| 177 | -** contains a line that is too long | |
| 178 | -** Returns -1, if the file appears text, but it contains CrLf | |
| 179 | -** Returns -2, if the file starts with an UTF-16 BOM (le or be) | |
| 175 | +** This function attempts to scan each logical line within the blob to | |
| 176 | +** determine the type of content it appears to contain. Possible return | |
| 177 | +** values are: | |
| 178 | +** | |
| 179 | +** (1) -- The content appears to consist entirely of text, with lines | |
| 180 | +** delimited by line-feed characters; however, the encoding may | |
| 181 | +** not be UTF-8. | |
| 182 | +** | |
| 183 | +** (0) -- The content appears to be binary because it contains embedded | |
| 184 | +** NUL (\000) characters or an extremely long line. | |
| 185 | +** | |
| 186 | +** (-1) -- The content appears to consist entirely of text, with lines | |
| 187 | +** delimited by carriage-return, line-feed pairs; however, the | |
| 188 | +** encoding may not be UTF-8. | |
| 189 | +** | |
| 190 | +** (-2) -- The content appears to consist entirely of text, in the | |
| 191 | +** UTF-16 (BE or LE) encoding. | |
| 180 | 192 | */ |
| 181 | 193 | int looks_like_text(const Blob *pContent){ |
| 182 | 194 | const char *z = blob_buffer(pContent); |
| 183 | 195 | unsigned int n = blob_size(pContent); |
| 184 | 196 | int j, c; |
| 185 | - int result = 1; /* Assume text with no CrLf */ | |
| 197 | + int result = 1; /* Assume text with no CR/NL */ | |
| 186 | 198 | |
| 187 | 199 | /* Check individual lines. |
| 188 | 200 | */ |
| 189 | 201 | if( n==0 ) return result; /* Empty file -> text */ |
| 190 | 202 | c = *z; |
| @@ -200,11 +212,11 @@ | ||
| 200 | 212 | while( --n>0 ){ |
| 201 | 213 | c = *++z; ++j; |
| 202 | 214 | if( c==0 ) return 0; /* \000 byte in a file -> binary */ |
| 203 | 215 | if( c=='\n' ){ |
| 204 | 216 | if( z[-1]=='\r' ){ |
| 205 | - result = -1; /* Contains CrLf, continue */ | |
| 217 | + result = -1; /* Contains CR/NL, continue */ | |
| 206 | 218 | } |
| 207 | 219 | if( j>LENGTH_MASK ){ |
| 208 | 220 | return 0; /* Very long line -> binary */ |
| 209 | 221 | } |
| 210 | 222 | j = 0; |
| 211 | 223 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -170,21 +170,33 @@ | |
| 170 | *pnLine = nLine; |
| 171 | return a; |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | ** Returns 1, if everything OK |
| 176 | ** Returns 0 if the specified content appears to be binary or |
| 177 | ** contains a line that is too long |
| 178 | ** Returns -1, if the file appears text, but it contains CrLf |
| 179 | ** Returns -2, if the file starts with an UTF-16 BOM (le or be) |
| 180 | */ |
| 181 | int looks_like_text(const Blob *pContent){ |
| 182 | const char *z = blob_buffer(pContent); |
| 183 | unsigned int n = blob_size(pContent); |
| 184 | int j, c; |
| 185 | int result = 1; /* Assume text with no CrLf */ |
| 186 | |
| 187 | /* Check individual lines. |
| 188 | */ |
| 189 | if( n==0 ) return result; /* Empty file -> text */ |
| 190 | c = *z; |
| @@ -200,11 +212,11 @@ | |
| 200 | while( --n>0 ){ |
| 201 | c = *++z; ++j; |
| 202 | if( c==0 ) return 0; /* \000 byte in a file -> binary */ |
| 203 | if( c=='\n' ){ |
| 204 | if( z[-1]=='\r' ){ |
| 205 | result = -1; /* Contains CrLf, continue */ |
| 206 | } |
| 207 | if( j>LENGTH_MASK ){ |
| 208 | return 0; /* Very long line -> binary */ |
| 209 | } |
| 210 | j = 0; |
| 211 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -170,21 +170,33 @@ | |
| 170 | *pnLine = nLine; |
| 171 | return a; |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | ** This function attempts to scan each logical line within the blob to |
| 176 | ** determine the type of content it appears to contain. Possible return |
| 177 | ** values are: |
| 178 | ** |
| 179 | ** (1) -- The content appears to consist entirely of text, with lines |
| 180 | ** delimited by line-feed characters; however, the encoding may |
| 181 | ** not be UTF-8. |
| 182 | ** |
| 183 | ** (0) -- The content appears to be binary because it contains embedded |
| 184 | ** NUL (\000) characters or an extremely long line. |
| 185 | ** |
| 186 | ** (-1) -- The content appears to consist entirely of text, with lines |
| 187 | ** delimited by carriage-return, line-feed pairs; however, the |
| 188 | ** encoding may not be UTF-8. |
| 189 | ** |
| 190 | ** (-2) -- The content appears to consist entirely of text, in the |
| 191 | ** UTF-16 (BE or LE) encoding. |
| 192 | */ |
| 193 | int looks_like_text(const Blob *pContent){ |
| 194 | const char *z = blob_buffer(pContent); |
| 195 | unsigned int n = blob_size(pContent); |
| 196 | int j, c; |
| 197 | int result = 1; /* Assume text with no CR/NL */ |
| 198 | |
| 199 | /* Check individual lines. |
| 200 | */ |
| 201 | if( n==0 ) return result; /* Empty file -> text */ |
| 202 | c = *z; |
| @@ -200,11 +212,11 @@ | |
| 212 | while( --n>0 ){ |
| 213 | c = *++z; ++j; |
| 214 | if( c==0 ) return 0; /* \000 byte in a file -> binary */ |
| 215 | if( c=='\n' ){ |
| 216 | if( z[-1]=='\r' ){ |
| 217 | result = -1; /* Contains CR/NL, continue */ |
| 218 | } |
| 219 | if( j>LENGTH_MASK ){ |
| 220 | return 0; /* Very long line -> binary */ |
| 221 | } |
| 222 | j = 0; |
| 223 |