Fossil SCM

merge ticket-01a2f3a346 into eclipse-project

jan.nijtmans 2012-08-28 09:13 eclipse-project merge
Commit 51253a79f2d8b6877b2c326ee43c13a19f0de28d
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
1
+eclipse.preferences.version=1
2
+encoding/<project>=UTF-8
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
 
 
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
1 eclipse.preferences.version=1
2 encoding/<project>=UTF-8
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
1
+eclipse.preferences.version=1
2
+encoding/<project>=UTF-8
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
 
 
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
1 eclipse.preferences.version=1
2 encoding/<project>=UTF-8
+9 -4
--- src/finfo.c
+++ src/finfo.c
@@ -158,19 +158,21 @@
158158
}
159159
zFilename = blob_str(&fname);
160160
db_prepare(&q,
161161
"SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
162162
" coalesce(event.ecomment, event.comment),"
163
- " coalesce(event.euser, event.user)"
163
+ " coalesce(event.euser, event.user),"
164
+ " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
165
+ " AND tagxref.rid=mlink.mid)" /* Tags */
164166
" FROM mlink, blob b, event, blob ci, filename"
165167
" WHERE filename.name=%Q %s"
166168
" AND mlink.fnid=filename.fnid"
167169
" AND b.rid=mlink.fid"
168170
" AND event.objid=mlink.mid"
169171
" AND event.objid=ci.rid"
170172
" ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
171
- zFilename, filename_collation(), iLimit, iOffset
173
+ TAG_BRANCH, zFilename, filename_collation(), iLimit, iOffset
172174
);
173175
blob_zero(&line);
174176
if( iBrief ){
175177
fossil_print("History of %s\n", blob_str(&fname));
176178
}
@@ -178,22 +180,25 @@
178180
const char *zFileUuid = db_column_text(&q, 0);
179181
const char *zCiUuid = db_column_text(&q,1);
180182
const char *zDate = db_column_text(&q, 2);
181183
const char *zCom = db_column_text(&q, 3);
182184
const char *zUser = db_column_text(&q, 4);
185
+ const char *zBr = db_column_text(&q, 5);
183186
char *zOut;
187
+ if( zBr==0 ) zBr = "trunk";
184188
if( iBrief ){
185189
fossil_print("%s ", zDate);
186
- zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
187
- zCiUuid, zCom, zUser, zFileUuid);
190
+ zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
191
+ zCiUuid, zCom, zUser, zFileUuid, zBr);
188192
comment_print(zOut, 11, 79);
189193
sqlite3_free(zOut);
190194
}else{
191195
blob_reset(&line);
192196
blob_appendf(&line, "%.10s ", zCiUuid);
193197
blob_appendf(&line, "%.10s ", zDate);
194198
blob_appendf(&line, "%8.8s ", zUser);
199
+ blob_appendf(&line, "%8.8s ", zBr);
195200
blob_appendf(&line,"%-40.40s\n", zCom );
196201
comment_print(blob_str(&line), 0, 79);
197202
}
198203
}
199204
db_finalize(&q);
200205
--- src/finfo.c
+++ src/finfo.c
@@ -158,19 +158,21 @@
158 }
159 zFilename = blob_str(&fname);
160 db_prepare(&q,
161 "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
162 " coalesce(event.ecomment, event.comment),"
163 " coalesce(event.euser, event.user)"
 
 
164 " FROM mlink, blob b, event, blob ci, filename"
165 " WHERE filename.name=%Q %s"
166 " AND mlink.fnid=filename.fnid"
167 " AND b.rid=mlink.fid"
168 " AND event.objid=mlink.mid"
169 " AND event.objid=ci.rid"
170 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
171 zFilename, filename_collation(), iLimit, iOffset
172 );
173 blob_zero(&line);
174 if( iBrief ){
175 fossil_print("History of %s\n", blob_str(&fname));
176 }
@@ -178,22 +180,25 @@
178 const char *zFileUuid = db_column_text(&q, 0);
179 const char *zCiUuid = db_column_text(&q,1);
180 const char *zDate = db_column_text(&q, 2);
181 const char *zCom = db_column_text(&q, 3);
182 const char *zUser = db_column_text(&q, 4);
 
183 char *zOut;
 
184 if( iBrief ){
185 fossil_print("%s ", zDate);
186 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
187 zCiUuid, zCom, zUser, zFileUuid);
188 comment_print(zOut, 11, 79);
189 sqlite3_free(zOut);
190 }else{
191 blob_reset(&line);
192 blob_appendf(&line, "%.10s ", zCiUuid);
193 blob_appendf(&line, "%.10s ", zDate);
194 blob_appendf(&line, "%8.8s ", zUser);
 
195 blob_appendf(&line,"%-40.40s\n", zCom );
196 comment_print(blob_str(&line), 0, 79);
197 }
198 }
199 db_finalize(&q);
200
--- src/finfo.c
+++ src/finfo.c
@@ -158,19 +158,21 @@
158 }
159 zFilename = blob_str(&fname);
160 db_prepare(&q,
161 "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
162 " coalesce(event.ecomment, event.comment),"
163 " coalesce(event.euser, event.user),"
164 " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
165 " AND tagxref.rid=mlink.mid)" /* Tags */
166 " FROM mlink, blob b, event, blob ci, filename"
167 " WHERE filename.name=%Q %s"
168 " AND mlink.fnid=filename.fnid"
169 " AND b.rid=mlink.fid"
170 " AND event.objid=mlink.mid"
171 " AND event.objid=ci.rid"
172 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
173 TAG_BRANCH, zFilename, filename_collation(), iLimit, iOffset
174 );
175 blob_zero(&line);
176 if( iBrief ){
177 fossil_print("History of %s\n", blob_str(&fname));
178 }
@@ -178,22 +180,25 @@
180 const char *zFileUuid = db_column_text(&q, 0);
181 const char *zCiUuid = db_column_text(&q,1);
182 const char *zDate = db_column_text(&q, 2);
183 const char *zCom = db_column_text(&q, 3);
184 const char *zUser = db_column_text(&q, 4);
185 const char *zBr = db_column_text(&q, 5);
186 char *zOut;
187 if( zBr==0 ) zBr = "trunk";
188 if( iBrief ){
189 fossil_print("%s ", zDate);
190 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
191 zCiUuid, zCom, zUser, zFileUuid, zBr);
192 comment_print(zOut, 11, 79);
193 sqlite3_free(zOut);
194 }else{
195 blob_reset(&line);
196 blob_appendf(&line, "%.10s ", zCiUuid);
197 blob_appendf(&line, "%.10s ", zDate);
198 blob_appendf(&line, "%8.8s ", zUser);
199 blob_appendf(&line, "%8.8s ", zBr);
200 blob_appendf(&line,"%-40.40s\n", zCom );
201 comment_print(blob_str(&line), 0, 79);
202 }
203 }
204 db_finalize(&q);
205
--- src/merge.c
+++ src/merge.c
@@ -175,10 +175,14 @@
175175
pid = mid;
176176
mid = t;
177177
}
178178
if( !is_a_version(pid) ){
179179
fossil_fatal("not a version: record #%d", pid);
180
+ }
181
+ if( mid==pid ){
182
+ fossil_print("This merge is a no-op.\n");
183
+ return;
180184
}
181185
if( detailFlag ){
182186
print_checkin_description(mid, 12, "merge-from:");
183187
print_checkin_description(pid, 12, "baseline:");
184188
}
185189
--- src/merge.c
+++ src/merge.c
@@ -175,10 +175,14 @@
175 pid = mid;
176 mid = t;
177 }
178 if( !is_a_version(pid) ){
179 fossil_fatal("not a version: record #%d", pid);
 
 
 
 
180 }
181 if( detailFlag ){
182 print_checkin_description(mid, 12, "merge-from:");
183 print_checkin_description(pid, 12, "baseline:");
184 }
185
--- src/merge.c
+++ src/merge.c
@@ -175,10 +175,14 @@
175 pid = mid;
176 mid = t;
177 }
178 if( !is_a_version(pid) ){
179 fossil_fatal("not a version: record #%d", pid);
180 }
181 if( mid==pid ){
182 fossil_print("This merge is a no-op.\n");
183 return;
184 }
185 if( detailFlag ){
186 print_checkin_description(mid, 12, "merge-from:");
187 print_checkin_description(pid, 12, "baseline:");
188 }
189
+2 -2
--- src/name.c
+++ src/name.c
@@ -107,19 +107,19 @@
107107
108108
/* Date and times */
109109
if( memcmp(zTag, "date:", 5)==0 ){
110110
rid = db_int(0,
111111
"SELECT objid FROM event"
112
- " WHERE mtime<=julianday(%Q) AND type GLOB '%q'"
112
+ " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
113113
" ORDER BY mtime DESC LIMIT 1",
114114
&zTag[5], zType);
115115
return rid;
116116
}
117117
if( is_date(zTag) ){
118118
rid = db_int(0,
119119
"SELECT objid FROM event"
120
- " WHERE mtime<=julianday(%Q) AND type GLOB '%q'"
120
+ " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
121121
" ORDER BY mtime DESC LIMIT 1",
122122
zTag, zType);
123123
if( rid) return rid;
124124
}
125125
126126
--- src/name.c
+++ src/name.c
@@ -107,19 +107,19 @@
107
108 /* Date and times */
109 if( memcmp(zTag, "date:", 5)==0 ){
110 rid = db_int(0,
111 "SELECT objid FROM event"
112 " WHERE mtime<=julianday(%Q) AND type GLOB '%q'"
113 " ORDER BY mtime DESC LIMIT 1",
114 &zTag[5], zType);
115 return rid;
116 }
117 if( is_date(zTag) ){
118 rid = db_int(0,
119 "SELECT objid FROM event"
120 " WHERE mtime<=julianday(%Q) AND type GLOB '%q'"
121 " ORDER BY mtime DESC LIMIT 1",
122 zTag, zType);
123 if( rid) return rid;
124 }
125
126
--- src/name.c
+++ src/name.c
@@ -107,19 +107,19 @@
107
108 /* Date and times */
109 if( memcmp(zTag, "date:", 5)==0 ){
110 rid = db_int(0,
111 "SELECT objid FROM event"
112 " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
113 " ORDER BY mtime DESC LIMIT 1",
114 &zTag[5], zType);
115 return rid;
116 }
117 if( is_date(zTag) ){
118 rid = db_int(0,
119 "SELECT objid FROM event"
120 " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
121 " ORDER BY mtime DESC LIMIT 1",
122 zTag, zType);
123 if( rid) return rid;
124 }
125
126
--- src/shell.c
+++ src/shell.c
@@ -62,11 +62,13 @@
6262
6363
#if defined(_WIN32) || defined(WIN32)
6464
# include <io.h>
6565
#define isatty(h) _isatty(h)
6666
#define access(f,m) _access((f),(m))
67
+#undef popen
6768
#define popen(a,b) _popen((a),(b))
69
+#undef pclose
6870
#define pclose(x) _pclose(x)
6971
#else
7072
/* Make sure isatty() has a prototype.
7173
*/
7274
extern int isatty(int);
7375
--- src/shell.c
+++ src/shell.c
@@ -62,11 +62,13 @@
62
63 #if defined(_WIN32) || defined(WIN32)
64 # include <io.h>
65 #define isatty(h) _isatty(h)
66 #define access(f,m) _access((f),(m))
 
67 #define popen(a,b) _popen((a),(b))
 
68 #define pclose(x) _pclose(x)
69 #else
70 /* Make sure isatty() has a prototype.
71 */
72 extern int isatty(int);
73
--- src/shell.c
+++ src/shell.c
@@ -62,11 +62,13 @@
62
63 #if defined(_WIN32) || defined(WIN32)
64 # include <io.h>
65 #define isatty(h) _isatty(h)
66 #define access(f,m) _access((f),(m))
67 #undef popen
68 #define popen(a,b) _popen((a),(b))
69 #undef pclose
70 #define pclose(x) _pclose(x)
71 #else
72 /* Make sure isatty() has a prototype.
73 */
74 extern int isatty(int);
75
+78 -64
--- src/timeline.c
+++ src/timeline.c
@@ -810,33 +810,49 @@
810810
style_submenu_element(zMenuName, zMenuName, "%s",
811811
url_render(pUrl, zParam, zValue, zRemove, 0));
812812
}
813813
814814
815
+/*
816
+** Convert a symbolic name used as an argument to the a=, b=, or c=
817
+** query parameters of timeline into a julianday mtime value.
818
+*/
819
+double symbolic_name_to_mtime(const char *z){
820
+ double mtime;
821
+ int rid;
822
+ if( z==0 ) return -1.0;
823
+ rid = symbolic_name_to_rid(z, "ci");
824
+ if( rid==0 ) return -1.0;
825
+ mtime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
826
+ return mtime;
827
+}
828
+
829
+/*
830
+** The value of one second in julianday notation
831
+*/
832
+#define ONE_SECOND (1.0/86400.0)
833
+
815834
/*
816835
** zDate is a localtime date. Insert records into the
817836
** "timeline" table to cause <hr> to be inserted before and after
818837
** entries of that date. If zDate==NULL then put dividers around
819838
** the event identified by rid.
820839
*/
821
-static void timeline_add_dividers(const char *zDate, int rid){
840
+static void timeline_add_dividers(double rDate, int rid){
822841
char *zToDel = 0;
823
- if( zDate==0 ){
824
- zToDel = db_text(0,"SELECT julianday(mtime,'localtime') FROM event"
825
- " WHERE objid=%d", rid);
826
- zDate = zToDel;
827
- if( zDate==0 ) zDate = "1";
842
+ if( rDate==0 ){
843
+ rDate = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
828844
}
829845
db_multi_exec(
830846
"INSERT INTO timeline(rid,sortby,etype)"
831
- "VALUES(-1,julianday(%Q,'utc')-1.0e-5,'div')",
832
- zDate
847
+ "VALUES(-1,%.16g,'div')",
848
+ rDate-ONE_SECOND
833849
);
834850
db_multi_exec(
835851
"INSERT INTO timeline(rid,sortby,etype)"
836
- "VALUES(-2,julianday(%Q,'utc')+1.0e-5,'div')",
837
- zDate
852
+ "VALUES(-2,%.17g,'div')",
853
+ rDate+ONE_SECOND
838854
);
839855
fossil_free(zToDel);
840856
}
841857
842858
@@ -843,14 +859,14 @@
843859
/*
844860
** WEBPAGE: timeline
845861
**
846862
** Query parameters:
847863
**
848
-** a=TIMESTAMP after this date
849
-** b=TIMESTAMP before this date.
850
-** c=TIMESTAMP "circa" this date.
851
-** n=COUNT number of events in output
864
+** a=TIMEORTAG after this event
865
+** b=TIMEORTAG before this event
866
+** c=TIMEORTAG "circa" this event
867
+** n=COUNT max number of events in output
852868
** p=UUID artifact and up to COUNT parents and ancestors
853869
** d=UUID artifact and up to COUNT descendants
854870
** dp=UUUID The same as d=UUID&p=UUID
855871
** t=TAGID show only check-ins with the given tagid
856872
** r=TAGID show check-ins related to tagid
@@ -901,10 +917,11 @@
901917
int to_rid = name_to_typed_rid(P("to"),"ci"); /* to= for path timelines */
902918
int noMerge = P("nomerge")!=0; /* Do not follow merge links */
903919
int me_rid = name_to_typed_rid(P("me"),"ci"); /* me= for common ancestory */
904920
int you_rid = name_to_typed_rid(P("you"),"ci");/* you= for common ancst */
905921
int pd_rid;
922
+ double rBefore, rAfter, rCirca; /* Boundary times */
906923
907924
/* To view the timeline, must have permission to read project data.
908925
*/
909926
pd_rid = name_to_typed_rid(P("dp"),"ci");
910927
if( pd_rid ){
@@ -1121,63 +1138,55 @@
11211138
blob_appendf(&sql,
11221139
" AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
11231140
zSearch, zSearch);
11241141
url_add_parameter(&url, "s", zSearch);
11251142
}
1126
- if( zAfter ){
1127
- while( fossil_isspace(zAfter[0]) ){ zAfter++; }
1128
- if( zAfter[0] ){
1129
- blob_appendf(&sql,
1130
- " AND event.mtime>=(SELECT julianday(%Q, 'utc'))"
1131
- " ORDER BY event.mtime ASC", zAfter);
1132
- url_add_parameter(&url, "a", zAfter);
1133
- zBefore = 0;
1134
- }else{
1135
- zAfter = 0;
1136
- }
1137
- }else if( zBefore ){
1138
- while( fossil_isspace(zBefore[0]) ){ zBefore++; }
1139
- if( zBefore[0] ){
1140
- blob_appendf(&sql,
1141
- " AND event.mtime<=(SELECT julianday(%Q, 'utc'))"
1142
- " ORDER BY event.mtime DESC", zBefore);
1143
- url_add_parameter(&url, "b", zBefore);
1144
- }else{
1145
- zBefore = 0;
1146
- }
1147
- }else if( zCirca ){
1148
- while( fossil_isspace(zCirca[0]) ){ zCirca++; }
1149
- if( zCirca[0] ){
1150
- double rCirca = db_double(0.0, "SELECT julianday(%Q, 'utc')", zCirca);
1151
- Blob sql2;
1152
- blob_init(&sql2, blob_str(&sql), -1);
1153
- blob_appendf(&sql2,
1154
- " AND event.mtime<=%f ORDER BY event.mtime DESC LIMIT %d",
1155
- rCirca, (nEntry+1)/2
1156
- );
1157
- db_multi_exec("%s", blob_str(&sql2));
1158
- blob_reset(&sql2);
1159
- blob_appendf(&sql,
1160
- " AND event.mtime>=%f ORDER BY event.mtime ASC",
1161
- rCirca
1162
- );
1163
- nEntry -= (nEntry+1)/2;
1164
- if( useDividers ) timeline_add_dividers(zCirca, 0);
1165
- url_add_parameter(&url, "c", zCirca);
1166
- }else{
1167
- zCirca = 0;
1168
- }
1143
+ rBefore = symbolic_name_to_mtime(zBefore);
1144
+ rAfter = symbolic_name_to_mtime(zAfter);
1145
+ rCirca = symbolic_name_to_mtime(zCirca);
1146
+ if( rAfter>0.0 ){
1147
+ if( rBefore>0.0 ){
1148
+ blob_appendf(&sql,
1149
+ " AND event.mtime>=%.17g AND event.mtime<=%.17g"
1150
+ " ORDER BY event.mtime ASC", rAfter-ONE_SECOND, rBefore+ONE_SECOND);
1151
+ url_add_parameter(&url, "a", zAfter);
1152
+ url_add_parameter(&url, "b", zBefore);
1153
+ nEntry = 1000000;
1154
+ }else{
1155
+ blob_appendf(&sql,
1156
+ " AND event.mtime>=%.17g ORDER BY event.mtime ASC",
1157
+ rAfter-ONE_SECOND);
1158
+ url_add_parameter(&url, "a", zAfter);
1159
+ }
1160
+ }else if( rBefore>0.0 ){
1161
+ blob_appendf(&sql,
1162
+ " AND event.mtime<=%.17g ORDER BY event.mtime DESC",
1163
+ rBefore+ONE_SECOND);
1164
+ url_add_parameter(&url, "b", zBefore);
1165
+ }else if( rCirca>0.0 ){
1166
+ Blob sql2;
1167
+ blob_init(&sql2, blob_str(&sql), -1);
1168
+ blob_appendf(&sql2,
1169
+ " AND event.mtime<=%f ORDER BY event.mtime DESC LIMIT %d",
1170
+ rCirca, (nEntry+1)/2
1171
+ );
1172
+ db_multi_exec("%s", blob_str(&sql2));
1173
+ blob_reset(&sql2);
1174
+ blob_appendf(&sql,
1175
+ " AND event.mtime>=%f ORDER BY event.mtime ASC",
1176
+ rCirca
1177
+ );
1178
+ nEntry -= (nEntry+1)/2;
1179
+ if( useDividers ) timeline_add_dividers(rCirca, 0);
1180
+ url_add_parameter(&url, "c", zCirca);
11691181
}else{
11701182
blob_appendf(&sql, " ORDER BY event.mtime DESC");
11711183
}
11721184
blob_appendf(&sql, " LIMIT %d", nEntry);
11731185
db_multi_exec("%s", blob_str(&sql));
11741186
11751187
n = db_int(0, "SELECT count(*) FROM timeline /*scan*/");
1176
- if( n<nEntry && zAfter ){
1177
- cgi_redirect(url_render(&url, "a", 0, "b", 0));
1178
- }
11791188
if( zAfter==0 && zBefore==0 && zCirca==0 ){
11801189
blob_appendf(&desc, "%d most recent %ss", n, zEType);
11811190
}else{
11821191
blob_appendf(&desc, "%d %ss", n, zEType);
11831192
}
@@ -1190,15 +1199,20 @@
11901199
tmFlags |= TIMELINE_DISJOINT;
11911200
}else if( zBrName ){
11921201
blob_appendf(&desc, " related to \"%h\"", zBrName);
11931202
tmFlags |= TIMELINE_DISJOINT;
11941203
}
1195
- if( zAfter ){
1196
- blob_appendf(&desc, " occurring on or after %h.<br />", zAfter);
1197
- }else if( zBefore ){
1204
+ if( rAfter>0.0 ){
1205
+ if( rBefore>0.0 ){
1206
+ blob_appendf(&desc, " occurring between %h and %h.<br>",
1207
+ zAfter, zBefore);
1208
+ }else{
1209
+ blob_appendf(&desc, " occurring on or after %h.<br />", zAfter);
1210
+ }
1211
+ }else if( rBefore>0.0 ){
11981212
blob_appendf(&desc, " occurring on or before %h.<br />", zBefore);
1199
- }else if( zCirca ){
1213
+ }else if( rCirca>0.0 ){
12001214
blob_appendf(&desc, " occurring around %h.<br />", zCirca);
12011215
}
12021216
if( zSearch ){
12031217
blob_appendf(&desc, " matching \"%h\"", zSearch);
12041218
}
12051219
--- src/timeline.c
+++ src/timeline.c
@@ -810,33 +810,49 @@
810 style_submenu_element(zMenuName, zMenuName, "%s",
811 url_render(pUrl, zParam, zValue, zRemove, 0));
812 }
813
814
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815 /*
816 ** zDate is a localtime date. Insert records into the
817 ** "timeline" table to cause <hr> to be inserted before and after
818 ** entries of that date. If zDate==NULL then put dividers around
819 ** the event identified by rid.
820 */
821 static void timeline_add_dividers(const char *zDate, int rid){
822 char *zToDel = 0;
823 if( zDate==0 ){
824 zToDel = db_text(0,"SELECT julianday(mtime,'localtime') FROM event"
825 " WHERE objid=%d", rid);
826 zDate = zToDel;
827 if( zDate==0 ) zDate = "1";
828 }
829 db_multi_exec(
830 "INSERT INTO timeline(rid,sortby,etype)"
831 "VALUES(-1,julianday(%Q,'utc')-1.0e-5,'div')",
832 zDate
833 );
834 db_multi_exec(
835 "INSERT INTO timeline(rid,sortby,etype)"
836 "VALUES(-2,julianday(%Q,'utc')+1.0e-5,'div')",
837 zDate
838 );
839 fossil_free(zToDel);
840 }
841
842
@@ -843,14 +859,14 @@
843 /*
844 ** WEBPAGE: timeline
845 **
846 ** Query parameters:
847 **
848 ** a=TIMESTAMP after this date
849 ** b=TIMESTAMP before this date.
850 ** c=TIMESTAMP "circa" this date.
851 ** n=COUNT number of events in output
852 ** p=UUID artifact and up to COUNT parents and ancestors
853 ** d=UUID artifact and up to COUNT descendants
854 ** dp=UUUID The same as d=UUID&p=UUID
855 ** t=TAGID show only check-ins with the given tagid
856 ** r=TAGID show check-ins related to tagid
@@ -901,10 +917,11 @@
901 int to_rid = name_to_typed_rid(P("to"),"ci"); /* to= for path timelines */
902 int noMerge = P("nomerge")!=0; /* Do not follow merge links */
903 int me_rid = name_to_typed_rid(P("me"),"ci"); /* me= for common ancestory */
904 int you_rid = name_to_typed_rid(P("you"),"ci");/* you= for common ancst */
905 int pd_rid;
 
906
907 /* To view the timeline, must have permission to read project data.
908 */
909 pd_rid = name_to_typed_rid(P("dp"),"ci");
910 if( pd_rid ){
@@ -1121,63 +1138,55 @@
1121 blob_appendf(&sql,
1122 " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
1123 zSearch, zSearch);
1124 url_add_parameter(&url, "s", zSearch);
1125 }
1126 if( zAfter ){
1127 while( fossil_isspace(zAfter[0]) ){ zAfter++; }
1128 if( zAfter[0] ){
1129 blob_appendf(&sql,
1130 " AND event.mtime>=(SELECT julianday(%Q, 'utc'))"
1131 " ORDER BY event.mtime ASC", zAfter);
1132 url_add_parameter(&url, "a", zAfter);
1133 zBefore = 0;
1134 }else{
1135 zAfter = 0;
1136 }
1137 }else if( zBefore ){
1138 while( fossil_isspace(zBefore[0]) ){ zBefore++; }
1139 if( zBefore[0] ){
1140 blob_appendf(&sql,
1141 " AND event.mtime<=(SELECT julianday(%Q, 'utc'))"
1142 " ORDER BY event.mtime DESC", zBefore);
1143 url_add_parameter(&url, "b", zBefore);
1144 }else{
1145 zBefore = 0;
1146 }
1147 }else if( zCirca ){
1148 while( fossil_isspace(zCirca[0]) ){ zCirca++; }
1149 if( zCirca[0] ){
1150 double rCirca = db_double(0.0, "SELECT julianday(%Q, 'utc')", zCirca);
1151 Blob sql2;
1152 blob_init(&sql2, blob_str(&sql), -1);
1153 blob_appendf(&sql2,
1154 " AND event.mtime<=%f ORDER BY event.mtime DESC LIMIT %d",
1155 rCirca, (nEntry+1)/2
1156 );
1157 db_multi_exec("%s", blob_str(&sql2));
1158 blob_reset(&sql2);
1159 blob_appendf(&sql,
1160 " AND event.mtime>=%f ORDER BY event.mtime ASC",
1161 rCirca
1162 );
1163 nEntry -= (nEntry+1)/2;
1164 if( useDividers ) timeline_add_dividers(zCirca, 0);
1165 url_add_parameter(&url, "c", zCirca);
1166 }else{
1167 zCirca = 0;
1168 }
1169 }else{
1170 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1171 }
1172 blob_appendf(&sql, " LIMIT %d", nEntry);
1173 db_multi_exec("%s", blob_str(&sql));
1174
1175 n = db_int(0, "SELECT count(*) FROM timeline /*scan*/");
1176 if( n<nEntry && zAfter ){
1177 cgi_redirect(url_render(&url, "a", 0, "b", 0));
1178 }
1179 if( zAfter==0 && zBefore==0 && zCirca==0 ){
1180 blob_appendf(&desc, "%d most recent %ss", n, zEType);
1181 }else{
1182 blob_appendf(&desc, "%d %ss", n, zEType);
1183 }
@@ -1190,15 +1199,20 @@
1190 tmFlags |= TIMELINE_DISJOINT;
1191 }else if( zBrName ){
1192 blob_appendf(&desc, " related to \"%h\"", zBrName);
1193 tmFlags |= TIMELINE_DISJOINT;
1194 }
1195 if( zAfter ){
1196 blob_appendf(&desc, " occurring on or after %h.<br />", zAfter);
1197 }else if( zBefore ){
 
 
 
 
 
1198 blob_appendf(&desc, " occurring on or before %h.<br />", zBefore);
1199 }else if( zCirca ){
1200 blob_appendf(&desc, " occurring around %h.<br />", zCirca);
1201 }
1202 if( zSearch ){
1203 blob_appendf(&desc, " matching \"%h\"", zSearch);
1204 }
1205
--- src/timeline.c
+++ src/timeline.c
@@ -810,33 +810,49 @@
810 style_submenu_element(zMenuName, zMenuName, "%s",
811 url_render(pUrl, zParam, zValue, zRemove, 0));
812 }
813
814
815 /*
816 ** Convert a symbolic name used as an argument to the a=, b=, or c=
817 ** query parameters of timeline into a julianday mtime value.
818 */
819 double symbolic_name_to_mtime(const char *z){
820 double mtime;
821 int rid;
822 if( z==0 ) return -1.0;
823 rid = symbolic_name_to_rid(z, "ci");
824 if( rid==0 ) return -1.0;
825 mtime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
826 return mtime;
827 }
828
829 /*
830 ** The value of one second in julianday notation
831 */
832 #define ONE_SECOND (1.0/86400.0)
833
834 /*
835 ** zDate is a localtime date. Insert records into the
836 ** "timeline" table to cause <hr> to be inserted before and after
837 ** entries of that date. If zDate==NULL then put dividers around
838 ** the event identified by rid.
839 */
840 static void timeline_add_dividers(double rDate, int rid){
841 char *zToDel = 0;
842 if( rDate==0 ){
843 rDate = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
 
 
 
844 }
845 db_multi_exec(
846 "INSERT INTO timeline(rid,sortby,etype)"
847 "VALUES(-1,%.16g,'div')",
848 rDate-ONE_SECOND
849 );
850 db_multi_exec(
851 "INSERT INTO timeline(rid,sortby,etype)"
852 "VALUES(-2,%.17g,'div')",
853 rDate+ONE_SECOND
854 );
855 fossil_free(zToDel);
856 }
857
858
@@ -843,14 +859,14 @@
859 /*
860 ** WEBPAGE: timeline
861 **
862 ** Query parameters:
863 **
864 ** a=TIMEORTAG after this event
865 ** b=TIMEORTAG before this event
866 ** c=TIMEORTAG "circa" this event
867 ** n=COUNT max number of events in output
868 ** p=UUID artifact and up to COUNT parents and ancestors
869 ** d=UUID artifact and up to COUNT descendants
870 ** dp=UUUID The same as d=UUID&p=UUID
871 ** t=TAGID show only check-ins with the given tagid
872 ** r=TAGID show check-ins related to tagid
@@ -901,10 +917,11 @@
917 int to_rid = name_to_typed_rid(P("to"),"ci"); /* to= for path timelines */
918 int noMerge = P("nomerge")!=0; /* Do not follow merge links */
919 int me_rid = name_to_typed_rid(P("me"),"ci"); /* me= for common ancestory */
920 int you_rid = name_to_typed_rid(P("you"),"ci");/* you= for common ancst */
921 int pd_rid;
922 double rBefore, rAfter, rCirca; /* Boundary times */
923
924 /* To view the timeline, must have permission to read project data.
925 */
926 pd_rid = name_to_typed_rid(P("dp"),"ci");
927 if( pd_rid ){
@@ -1121,63 +1138,55 @@
1138 blob_appendf(&sql,
1139 " AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
1140 zSearch, zSearch);
1141 url_add_parameter(&url, "s", zSearch);
1142 }
1143 rBefore = symbolic_name_to_mtime(zBefore);
1144 rAfter = symbolic_name_to_mtime(zAfter);
1145 rCirca = symbolic_name_to_mtime(zCirca);
1146 if( rAfter>0.0 ){
1147 if( rBefore>0.0 ){
1148 blob_appendf(&sql,
1149 " AND event.mtime>=%.17g AND event.mtime<=%.17g"
1150 " ORDER BY event.mtime ASC", rAfter-ONE_SECOND, rBefore+ONE_SECOND);
1151 url_add_parameter(&url, "a", zAfter);
1152 url_add_parameter(&url, "b", zBefore);
1153 nEntry = 1000000;
1154 }else{
1155 blob_appendf(&sql,
1156 " AND event.mtime>=%.17g ORDER BY event.mtime ASC",
1157 rAfter-ONE_SECOND);
1158 url_add_parameter(&url, "a", zAfter);
1159 }
1160 }else if( rBefore>0.0 ){
1161 blob_appendf(&sql,
1162 " AND event.mtime<=%.17g ORDER BY event.mtime DESC",
1163 rBefore+ONE_SECOND);
1164 url_add_parameter(&url, "b", zBefore);
1165 }else if( rCirca>0.0 ){
1166 Blob sql2;
1167 blob_init(&sql2, blob_str(&sql), -1);
1168 blob_appendf(&sql2,
1169 " AND event.mtime<=%f ORDER BY event.mtime DESC LIMIT %d",
1170 rCirca, (nEntry+1)/2
1171 );
1172 db_multi_exec("%s", blob_str(&sql2));
1173 blob_reset(&sql2);
1174 blob_appendf(&sql,
1175 " AND event.mtime>=%f ORDER BY event.mtime ASC",
1176 rCirca
1177 );
1178 nEntry -= (nEntry+1)/2;
1179 if( useDividers ) timeline_add_dividers(rCirca, 0);
1180 url_add_parameter(&url, "c", zCirca);
 
 
 
 
 
1181 }else{
1182 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1183 }
1184 blob_appendf(&sql, " LIMIT %d", nEntry);
1185 db_multi_exec("%s", blob_str(&sql));
1186
1187 n = db_int(0, "SELECT count(*) FROM timeline /*scan*/");
 
 
 
1188 if( zAfter==0 && zBefore==0 && zCirca==0 ){
1189 blob_appendf(&desc, "%d most recent %ss", n, zEType);
1190 }else{
1191 blob_appendf(&desc, "%d %ss", n, zEType);
1192 }
@@ -1190,15 +1199,20 @@
1199 tmFlags |= TIMELINE_DISJOINT;
1200 }else if( zBrName ){
1201 blob_appendf(&desc, " related to \"%h\"", zBrName);
1202 tmFlags |= TIMELINE_DISJOINT;
1203 }
1204 if( rAfter>0.0 ){
1205 if( rBefore>0.0 ){
1206 blob_appendf(&desc, " occurring between %h and %h.<br>",
1207 zAfter, zBefore);
1208 }else{
1209 blob_appendf(&desc, " occurring on or after %h.<br />", zAfter);
1210 }
1211 }else if( rBefore>0.0 ){
1212 blob_appendf(&desc, " occurring on or before %h.<br />", zBefore);
1213 }else if( rCirca>0.0 ){
1214 blob_appendf(&desc, " occurring around %h.<br />", zCirca);
1215 }
1216 if( zSearch ){
1217 blob_appendf(&desc, " matching \"%h\"", zSearch);
1218 }
1219
+31 -4
--- src/translate.c
+++ src/translate.c
@@ -1,7 +1,7 @@
11
/*
2
-** Copyright (c) 2002 D. Richard Hipp
2
+** Copyright © 2002 D. Richard Hipp
33
**
44
** This program is free software; you can redistribute it and/or
55
** modify it under the terms of the Simplified BSD License (also
66
** known as the "2-Clause License" or "FreeBSD License".)
77
@@ -76,17 +76,34 @@
7676
char c1, c2; /* Characters used to start a comment */
7777
int lastWasEq = 0; /* True if last non-whitespace character was "=" */
7878
int lastWasComma = 0; /* True if last non-whitespace character was "," */
7979
char zLine[2000]; /* A single line of input */
8080
char zOut[4000]; /* The input line translated into appropriate output */
81
+ int isFirstline = 1; /* True if this is the first line */
8182
8283
c1 = c2 = '-';
8384
while( fgets(zLine, sizeof(zLine), in) ){
85
+ if (isFirstline) {
86
+ static const char bom[] = { 0xEF, 0xBB, 0xBF };
87
+ if( memcmp(zLine, bom, 3)==0 ) {
88
+ memmove(zLine, zLine+3, sizeof(zLine)-3);
89
+ }
90
+ isFirstline = 0;
91
+ }
8492
for(i=0; zLine[i] && isspace(zLine[i]); i++){}
8593
if( zLine[i]!='@' ){
8694
if( inPrint || inStr ) end_block(out);
87
- fprintf(out,"%s",zLine);
95
+ for(j=0; zLine[i]; i++){
96
+ if (128 <= (unsigned char)zLine[i]) {
97
+ sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
98
+ j += 5;
99
+ } else {
100
+ zOut[j++] = zLine[i];
101
+ }
102
+ }
103
+ zOut[j] = 0;
104
+ fprintf(out,"%s",zOut);
88105
/* 0123456789 12345 */
89106
if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
90107
c1 = zLine[14];
91108
c2 = zLine[15];
92109
}
@@ -110,11 +127,16 @@
110127
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
111128
if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
112129
omitline = 1; break;
113130
}
114131
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
115
- zOut[j++] = zLine[i];
132
+ if (128 <= (unsigned char)zLine[i]) {
133
+ sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
134
+ j += 5;
135
+ } else {
136
+ zOut[j++] = zLine[i];
137
+ }
116138
}
117139
while( j>0 && isspace(zOut[j-1]) ){ j--; }
118140
zOut[j] = 0;
119141
if( j<=0 && omitline ){
120142
fprintf(out,"\n");
@@ -134,11 +156,16 @@
134156
i++;
135157
if( isspace(zLine[i]) ){ i++; }
136158
indent = i;
137159
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
138160
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
139
- zOut[j++] = zLine[i];
161
+ if (128 <= (unsigned char)zLine[i]) {
162
+ sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
163
+ j += 5;
164
+ } else {
165
+ zOut[j++] = zLine[i];
166
+ }
140167
if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
141168
for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
142169
if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
143170
while( --nC ) zOut[j++] = zLine[++i];
144171
zArg[nArg++] = ',';
145172
--- src/translate.c
+++ src/translate.c
@@ -1,7 +1,7 @@
1 /*
2 ** Copyright (c) 2002 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
@@ -76,17 +76,34 @@
76 char c1, c2; /* Characters used to start a comment */
77 int lastWasEq = 0; /* True if last non-whitespace character was "=" */
78 int lastWasComma = 0; /* True if last non-whitespace character was "," */
79 char zLine[2000]; /* A single line of input */
80 char zOut[4000]; /* The input line translated into appropriate output */
 
81
82 c1 = c2 = '-';
83 while( fgets(zLine, sizeof(zLine), in) ){
 
 
 
 
 
 
 
84 for(i=0; zLine[i] && isspace(zLine[i]); i++){}
85 if( zLine[i]!='@' ){
86 if( inPrint || inStr ) end_block(out);
87 fprintf(out,"%s",zLine);
 
 
 
 
 
 
 
 
 
88 /* 0123456789 12345 */
89 if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
90 c1 = zLine[14];
91 c2 = zLine[15];
92 }
@@ -110,11 +127,16 @@
110 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
111 if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
112 omitline = 1; break;
113 }
114 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
115 zOut[j++] = zLine[i];
 
 
 
 
 
116 }
117 while( j>0 && isspace(zOut[j-1]) ){ j--; }
118 zOut[j] = 0;
119 if( j<=0 && omitline ){
120 fprintf(out,"\n");
@@ -134,11 +156,16 @@
134 i++;
135 if( isspace(zLine[i]) ){ i++; }
136 indent = i;
137 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
138 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
139 zOut[j++] = zLine[i];
 
 
 
 
 
140 if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
141 for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
142 if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
143 while( --nC ) zOut[j++] = zLine[++i];
144 zArg[nArg++] = ',';
145
--- src/translate.c
+++ src/translate.c
@@ -1,7 +1,7 @@
1 /*
2 ** Copyright © 2002 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
@@ -76,17 +76,34 @@
76 char c1, c2; /* Characters used to start a comment */
77 int lastWasEq = 0; /* True if last non-whitespace character was "=" */
78 int lastWasComma = 0; /* True if last non-whitespace character was "," */
79 char zLine[2000]; /* A single line of input */
80 char zOut[4000]; /* The input line translated into appropriate output */
81 int isFirstline = 1; /* True if this is the first line */
82
83 c1 = c2 = '-';
84 while( fgets(zLine, sizeof(zLine), in) ){
85 if (isFirstline) {
86 static const char bom[] = { 0xEF, 0xBB, 0xBF };
87 if( memcmp(zLine, bom, 3)==0 ) {
88 memmove(zLine, zLine+3, sizeof(zLine)-3);
89 }
90 isFirstline = 0;
91 }
92 for(i=0; zLine[i] && isspace(zLine[i]); i++){}
93 if( zLine[i]!='@' ){
94 if( inPrint || inStr ) end_block(out);
95 for(j=0; zLine[i]; i++){
96 if (128 <= (unsigned char)zLine[i]) {
97 sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
98 j += 5;
99 } else {
100 zOut[j++] = zLine[i];
101 }
102 }
103 zOut[j] = 0;
104 fprintf(out,"%s",zOut);
105 /* 0123456789 12345 */
106 if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
107 c1 = zLine[14];
108 c2 = zLine[15];
109 }
@@ -110,11 +127,16 @@
127 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
128 if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
129 omitline = 1; break;
130 }
131 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
132 if (128 <= (unsigned char)zLine[i]) {
133 sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
134 j += 5;
135 } else {
136 zOut[j++] = zLine[i];
137 }
138 }
139 while( j>0 && isspace(zOut[j-1]) ){ j--; }
140 zOut[j] = 0;
141 if( j<=0 && omitline ){
142 fprintf(out,"\n");
@@ -134,11 +156,16 @@
156 i++;
157 if( isspace(zLine[i]) ){ i++; }
158 indent = i;
159 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
160 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
161 if (128 <= (unsigned char)zLine[i]) {
162 sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
163 j += 5;
164 } else {
165 zOut[j++] = zLine[i];
166 }
167 if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
168 for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
169 if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
170 while( --nC ) zOut[j++] = zLine[++i];
171 zArg[nArg++] = ',';
172
+31 -4
--- src/translate.c
+++ src/translate.c
@@ -1,7 +1,7 @@
11
/*
2
-** Copyright (c) 2002 D. Richard Hipp
2
+** Copyright © 2002 D. Richard Hipp
33
**
44
** This program is free software; you can redistribute it and/or
55
** modify it under the terms of the Simplified BSD License (also
66
** known as the "2-Clause License" or "FreeBSD License".)
77
@@ -76,17 +76,34 @@
7676
char c1, c2; /* Characters used to start a comment */
7777
int lastWasEq = 0; /* True if last non-whitespace character was "=" */
7878
int lastWasComma = 0; /* True if last non-whitespace character was "," */
7979
char zLine[2000]; /* A single line of input */
8080
char zOut[4000]; /* The input line translated into appropriate output */
81
+ int isFirstline = 1; /* True if this is the first line */
8182
8283
c1 = c2 = '-';
8384
while( fgets(zLine, sizeof(zLine), in) ){
85
+ if (isFirstline) {
86
+ static const char bom[] = { 0xEF, 0xBB, 0xBF };
87
+ if( memcmp(zLine, bom, 3)==0 ) {
88
+ memmove(zLine, zLine+3, sizeof(zLine)-3);
89
+ }
90
+ isFirstline = 0;
91
+ }
8492
for(i=0; zLine[i] && isspace(zLine[i]); i++){}
8593
if( zLine[i]!='@' ){
8694
if( inPrint || inStr ) end_block(out);
87
- fprintf(out,"%s",zLine);
95
+ for(j=0; zLine[i]; i++){
96
+ if (128 <= (unsigned char)zLine[i]) {
97
+ sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
98
+ j += 5;
99
+ } else {
100
+ zOut[j++] = zLine[i];
101
+ }
102
+ }
103
+ zOut[j] = 0;
104
+ fprintf(out,"%s",zOut);
88105
/* 0123456789 12345 */
89106
if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
90107
c1 = zLine[14];
91108
c2 = zLine[15];
92109
}
@@ -110,11 +127,16 @@
110127
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
111128
if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
112129
omitline = 1; break;
113130
}
114131
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
115
- zOut[j++] = zLine[i];
132
+ if (128 <= (unsigned char)zLine[i]) {
133
+ sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
134
+ j += 5;
135
+ } else {
136
+ zOut[j++] = zLine[i];
137
+ }
116138
}
117139
while( j>0 && isspace(zOut[j-1]) ){ j--; }
118140
zOut[j] = 0;
119141
if( j<=0 && omitline ){
120142
fprintf(out,"\n");
@@ -134,11 +156,16 @@
134156
i++;
135157
if( isspace(zLine[i]) ){ i++; }
136158
indent = i;
137159
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
138160
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
139
- zOut[j++] = zLine[i];
161
+ if (128 <= (unsigned char)zLine[i]) {
162
+ sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
163
+ j += 5;
164
+ } else {
165
+ zOut[j++] = zLine[i];
166
+ }
140167
if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
141168
for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
142169
if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
143170
while( --nC ) zOut[j++] = zLine[++i];
144171
zArg[nArg++] = ',';
145172
--- src/translate.c
+++ src/translate.c
@@ -1,7 +1,7 @@
1 /*
2 ** Copyright (c) 2002 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
@@ -76,17 +76,34 @@
76 char c1, c2; /* Characters used to start a comment */
77 int lastWasEq = 0; /* True if last non-whitespace character was "=" */
78 int lastWasComma = 0; /* True if last non-whitespace character was "," */
79 char zLine[2000]; /* A single line of input */
80 char zOut[4000]; /* The input line translated into appropriate output */
 
81
82 c1 = c2 = '-';
83 while( fgets(zLine, sizeof(zLine), in) ){
 
 
 
 
 
 
 
84 for(i=0; zLine[i] && isspace(zLine[i]); i++){}
85 if( zLine[i]!='@' ){
86 if( inPrint || inStr ) end_block(out);
87 fprintf(out,"%s",zLine);
 
 
 
 
 
 
 
 
 
88 /* 0123456789 12345 */
89 if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
90 c1 = zLine[14];
91 c2 = zLine[15];
92 }
@@ -110,11 +127,16 @@
110 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
111 if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
112 omitline = 1; break;
113 }
114 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
115 zOut[j++] = zLine[i];
 
 
 
 
 
116 }
117 while( j>0 && isspace(zOut[j-1]) ){ j--; }
118 zOut[j] = 0;
119 if( j<=0 && omitline ){
120 fprintf(out,"\n");
@@ -134,11 +156,16 @@
134 i++;
135 if( isspace(zLine[i]) ){ i++; }
136 indent = i;
137 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
138 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
139 zOut[j++] = zLine[i];
 
 
 
 
 
140 if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
141 for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
142 if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
143 while( --nC ) zOut[j++] = zLine[++i];
144 zArg[nArg++] = ',';
145
--- src/translate.c
+++ src/translate.c
@@ -1,7 +1,7 @@
1 /*
2 ** Copyright © 2002 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
@@ -76,17 +76,34 @@
76 char c1, c2; /* Characters used to start a comment */
77 int lastWasEq = 0; /* True if last non-whitespace character was "=" */
78 int lastWasComma = 0; /* True if last non-whitespace character was "," */
79 char zLine[2000]; /* A single line of input */
80 char zOut[4000]; /* The input line translated into appropriate output */
81 int isFirstline = 1; /* True if this is the first line */
82
83 c1 = c2 = '-';
84 while( fgets(zLine, sizeof(zLine), in) ){
85 if (isFirstline) {
86 static const char bom[] = { 0xEF, 0xBB, 0xBF };
87 if( memcmp(zLine, bom, 3)==0 ) {
88 memmove(zLine, zLine+3, sizeof(zLine)-3);
89 }
90 isFirstline = 0;
91 }
92 for(i=0; zLine[i] && isspace(zLine[i]); i++){}
93 if( zLine[i]!='@' ){
94 if( inPrint || inStr ) end_block(out);
95 for(j=0; zLine[i]; i++){
96 if (128 <= (unsigned char)zLine[i]) {
97 sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
98 j += 5;
99 } else {
100 zOut[j++] = zLine[i];
101 }
102 }
103 zOut[j] = 0;
104 fprintf(out,"%s",zOut);
105 /* 0123456789 12345 */
106 if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
107 c1 = zLine[14];
108 c2 = zLine[15];
109 }
@@ -110,11 +127,16 @@
127 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
128 if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
129 omitline = 1; break;
130 }
131 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
132 if (128 <= (unsigned char)zLine[i]) {
133 sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
134 j += 5;
135 } else {
136 zOut[j++] = zLine[i];
137 }
138 }
139 while( j>0 && isspace(zOut[j-1]) ){ j--; }
140 zOut[j] = 0;
141 if( j<=0 && omitline ){
142 fprintf(out,"\n");
@@ -134,11 +156,16 @@
156 i++;
157 if( isspace(zLine[i]) ){ i++; }
158 indent = i;
159 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
160 if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
161 if (128 <= (unsigned char)zLine[i]) {
162 sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
163 j += 5;
164 } else {
165 zOut[j++] = zLine[i];
166 }
167 if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
168 for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
169 if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
170 while( --nC ) zOut[j++] = zLine[++i];
171 zArg[nArg++] = ',';
172

Keyboard Shortcuts

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