Fossil SCM
If both files being merged by 'fossil merge' contain a UTF-8 byte order mark (BOM), keep it in the produced merged file.
Commit
91182cd1f369b9c1f4173eb106319dfd485c623e97a8c0acfdb16f6443dd40f9
Parent
60ecf5d9ed63799…
1 file changed
+9
+9
| --- src/merge3.c | ||
| +++ src/merge3.c | ||
| @@ -198,10 +198,19 @@ | ||
| 198 | 198 | int limit1, limit2; /* Sizes of aC1[] and aC2[] */ |
| 199 | 199 | int nConflict = 0; /* Number of merge conflicts seen so far */ |
| 200 | 200 | |
| 201 | 201 | blob_zero(pOut); /* Merge results stored in pOut */ |
| 202 | 202 | |
| 203 | + /* If both pV1 and pV2 start with a UTF-8 byte-order-mark (BOM), | |
| 204 | + ** keep it in the output. This should be secure enough not to cause | |
| 205 | + ** unintended changes to the merged file and consistent with what | |
| 206 | + ** users are using in their source files. | |
| 207 | + */ | |
| 208 | + if( starts_with_utf8_bom(pV1, 0) && starts_with_utf8_bom(pV2, 0) ){ | |
| 209 | + blob_append(pOut, get_utf8_bom(0), -1); | |
| 210 | + } | |
| 211 | + | |
| 203 | 212 | /* Check once to see if both pV1 and pV2 contains CR/LF endings. |
| 204 | 213 | ** If true, CR/LF pair will be used later to append the |
| 205 | 214 | ** boundary markers for merge conflicts. |
| 206 | 215 | */ |
| 207 | 216 | int useCrLf = 0; |
| 208 | 217 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -198,10 +198,19 @@ | |
| 198 | int limit1, limit2; /* Sizes of aC1[] and aC2[] */ |
| 199 | int nConflict = 0; /* Number of merge conflicts seen so far */ |
| 200 | |
| 201 | blob_zero(pOut); /* Merge results stored in pOut */ |
| 202 | |
| 203 | /* Check once to see if both pV1 and pV2 contains CR/LF endings. |
| 204 | ** If true, CR/LF pair will be used later to append the |
| 205 | ** boundary markers for merge conflicts. |
| 206 | */ |
| 207 | int useCrLf = 0; |
| 208 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -198,10 +198,19 @@ | |
| 198 | int limit1, limit2; /* Sizes of aC1[] and aC2[] */ |
| 199 | int nConflict = 0; /* Number of merge conflicts seen so far */ |
| 200 | |
| 201 | blob_zero(pOut); /* Merge results stored in pOut */ |
| 202 | |
| 203 | /* If both pV1 and pV2 start with a UTF-8 byte-order-mark (BOM), |
| 204 | ** keep it in the output. This should be secure enough not to cause |
| 205 | ** unintended changes to the merged file and consistent with what |
| 206 | ** users are using in their source files. |
| 207 | */ |
| 208 | if( starts_with_utf8_bom(pV1, 0) && starts_with_utf8_bom(pV2, 0) ){ |
| 209 | blob_append(pOut, get_utf8_bom(0), -1); |
| 210 | } |
| 211 | |
| 212 | /* Check once to see if both pV1 and pV2 contains CR/LF endings. |
| 213 | ** If true, CR/LF pair will be used later to append the |
| 214 | ** boundary markers for merge conflicts. |
| 215 | */ |
| 216 | int useCrLf = 0; |
| 217 |