Fossil SCM

Style en comment fixes, backported from [d57f0a9361]

jan.nijtmans 2012-10-30 16:14 trunk
Commit c7b2b2ed3ce6b253495d2695ddc32b76427fc163
2 files changed +14 -13 +19 -7
+14 -13
--- src/checkin.c
+++ src/checkin.c
@@ -882,46 +882,47 @@
882882
if( pnFBcard ) *pnFBcard = nFBcard;
883883
}
884884
885885
/*
886886
** 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.
888889
*/
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() */
891892
char *zMsg; /* Warning message */
892893
Blob fname; /* Relative pathname of the file */
893894
static int allOk = 0; /* Set to true to disable this routine */
894895
895896
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 ;
899900
Blob ans;
900901
char cReply;
901902
902
- if( looksLike&1 ){
903
+ if( eType&1 ){
903904
if( crnlOk ){
904905
return; /* We don't want CrLf warnings for this file. */
905906
}
906
- type = "CR/NL line endings";
907
+ zWarning = "CR/NL line endings";
907908
}else{
908
- type = "unicode";
909
+ zWarning = "Unicode";
909910
}
910911
file_relative_name(zFilename, &fname, 0);
911912
blob_zero(&ans);
912913
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 );
915916
prompt_user(zMsg, &ans);
916917
fossil_free(zMsg);
917918
cReply = blob_str(&ans)[0];
918919
if( cReply=='a' || cReply=='A' ){
919920
allOk = 1;
920921
}else if( cReply!='y' && cReply!='Y' ){
921922
fossil_fatal("Abandoning commit due to %s in %s",
922
- type, blob_str(&fname));
923
+ zWarning , blob_str(&fname));
923924
}
924925
blob_reset(&ans);
925926
blob_reset(&fname);
926927
}
927928
}
@@ -1232,11 +1233,11 @@
12321233
/* Instead of file content, put link destination path */
12331234
blob_read_link(&content, zFullname);
12341235
}else{
12351236
blob_read_from_file(&content, zFullname);
12361237
}
1237
- encoding_warning(&content, crnlOk, zFullname);
1238
+ commit_warning(&content, crnlOk, zFullname);
12381239
if( chnged==1 && contains_merge_marker(&content) ){
12391240
Blob fname; /* Relative pathname of the file */
12401241
12411242
nConflict++;
12421243
file_relative_name(zFullname, &fname, 0);
12431244
--- 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 @@
170170
*pnLine = nLine;
171171
return a;
172172
}
173173
174174
/*
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.
180192
*/
181193
int looks_like_text(const Blob *pContent){
182194
const char *z = blob_buffer(pContent);
183195
unsigned int n = blob_size(pContent);
184196
int j, c;
185
- int result = 1; /* Assume text with no CrLf */
197
+ int result = 1; /* Assume text with no CR/NL */
186198
187199
/* Check individual lines.
188200
*/
189201
if( n==0 ) return result; /* Empty file -> text */
190202
c = *z;
@@ -200,11 +212,11 @@
200212
while( --n>0 ){
201213
c = *++z; ++j;
202214
if( c==0 ) return 0; /* \000 byte in a file -> binary */
203215
if( c=='\n' ){
204216
if( z[-1]=='\r' ){
205
- result = -1; /* Contains CrLf, continue */
217
+ result = -1; /* Contains CR/NL, continue */
206218
}
207219
if( j>LENGTH_MASK ){
208220
return 0; /* Very long line -> binary */
209221
}
210222
j = 0;
211223
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button