Fossil SCM

All the --context option on diff to have a value of 0.

drh 2013-01-01 22:56 trunk
Commit d74698ec28794dc10de018547d2bfa9ab51e3216
1 file changed +5 -4
+5 -4
--- src/diff.c
+++ src/diff.c
@@ -38,10 +38,11 @@
3838
#define DIFF_HTML ((u64)0x10000000) /* Render for HTML */
3939
#define DIFF_LINENO ((u64)0x20000000) /* Show line numbers */
4040
#define DIFF_WS_WARNING ((u64)0x40000000) /* Warn about whitespace */
4141
#define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
4242
#define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
43
+#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
4344
4445
/*
4546
** These error messages are shared in multiple locations. They are defined
4647
** here for consistency.
4748
*/
@@ -1800,11 +1801,11 @@
18001801
** Extract the number of lines of context from diffFlags. Supply an
18011802
** appropriate default if no context width is specified.
18021803
*/
18031804
int diff_context_lines(u64 diffFlags){
18041805
int n = diffFlags & DIFF_CONTEXT_MASK;
1805
- if( n==0 ) n = 5;
1806
+ if( n==0 && (diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5;
18061807
return n;
18071808
}
18081809
18091810
/*
18101811
** Extract the width of columns for side-by-side diff. Supply an
@@ -1903,19 +1904,19 @@
19031904
** --noopt Disable optimization DIFF_NOOPT
19041905
** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
19051906
** --unified Unified diff. ~DIFF_SIDEBYSIDE
19061907
** --width|-W N N character lines. DIFF_WIDTH_MASK
19071908
*/
1908
-int diff_options(void){
1909
+u64 diff_options(void){
19091910
u64 diffFlags = 0;
19101911
const char *z;
19111912
int f;
19121913
if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE;
19131914
if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE;
1914
- if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>0 ){
1915
+ if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){
19151916
if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK;
1916
- diffFlags |= f;
1917
+ diffFlags |= f + DIFF_CONTEXT_EX;
19171918
}
19181919
if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
19191920
f *= DIFF_CONTEXT_MASK+1;
19201921
if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
19211922
diffFlags |= f;
19221923
--- src/diff.c
+++ src/diff.c
@@ -38,10 +38,11 @@
38 #define DIFF_HTML ((u64)0x10000000) /* Render for HTML */
39 #define DIFF_LINENO ((u64)0x20000000) /* Show line numbers */
40 #define DIFF_WS_WARNING ((u64)0x40000000) /* Warn about whitespace */
41 #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
42 #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
 
43
44 /*
45 ** These error messages are shared in multiple locations. They are defined
46 ** here for consistency.
47 */
@@ -1800,11 +1801,11 @@
1800 ** Extract the number of lines of context from diffFlags. Supply an
1801 ** appropriate default if no context width is specified.
1802 */
1803 int diff_context_lines(u64 diffFlags){
1804 int n = diffFlags & DIFF_CONTEXT_MASK;
1805 if( n==0 ) n = 5;
1806 return n;
1807 }
1808
1809 /*
1810 ** Extract the width of columns for side-by-side diff. Supply an
@@ -1903,19 +1904,19 @@
1903 ** --noopt Disable optimization DIFF_NOOPT
1904 ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
1905 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1906 ** --width|-W N N character lines. DIFF_WIDTH_MASK
1907 */
1908 int diff_options(void){
1909 u64 diffFlags = 0;
1910 const char *z;
1911 int f;
1912 if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE;
1913 if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE;
1914 if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>0 ){
1915 if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK;
1916 diffFlags |= f;
1917 }
1918 if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
1919 f *= DIFF_CONTEXT_MASK+1;
1920 if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
1921 diffFlags |= f;
1922
--- src/diff.c
+++ src/diff.c
@@ -38,10 +38,11 @@
38 #define DIFF_HTML ((u64)0x10000000) /* Render for HTML */
39 #define DIFF_LINENO ((u64)0x20000000) /* Show line numbers */
40 #define DIFF_WS_WARNING ((u64)0x40000000) /* Warn about whitespace */
41 #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */
42 #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */
43 #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */
44
45 /*
46 ** These error messages are shared in multiple locations. They are defined
47 ** here for consistency.
48 */
@@ -1800,11 +1801,11 @@
1801 ** Extract the number of lines of context from diffFlags. Supply an
1802 ** appropriate default if no context width is specified.
1803 */
1804 int diff_context_lines(u64 diffFlags){
1805 int n = diffFlags & DIFF_CONTEXT_MASK;
1806 if( n==0 && (diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5;
1807 return n;
1808 }
1809
1810 /*
1811 ** Extract the width of columns for side-by-side diff. Supply an
@@ -1903,19 +1904,19 @@
1904 ** --noopt Disable optimization DIFF_NOOPT
1905 ** --side-by-side|-y Side-by-side diff. DIFF_SIDEBYSIDE
1906 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
1907 ** --width|-W N N character lines. DIFF_WIDTH_MASK
1908 */
1909 u64 diff_options(void){
1910 u64 diffFlags = 0;
1911 const char *z;
1912 int f;
1913 if( find_option("side-by-side","y",0)!=0 ) diffFlags |= DIFF_SIDEBYSIDE;
1914 if( find_option("unified",0,0)!=0 ) diffFlags &= ~DIFF_SIDEBYSIDE;
1915 if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){
1916 if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK;
1917 diffFlags |= f + DIFF_CONTEXT_EX;
1918 }
1919 if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){
1920 f *= DIFF_CONTEXT_MASK+1;
1921 if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK;
1922 diffFlags |= f;
1923

Keyboard Shortcuts

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