Fossil SCM

Coding style tweaks.

mistachkin 2016-09-23 02:46 nick.lloyd-git-interop
Commit 32e418f85687d54d9cf3b2ee9fee534b38901ef2
2 files changed +21 -21 +1 -1
+21 -21
--- src/export.c
+++ src/export.c
@@ -133,21 +133,21 @@
133133
/*
134134
** create_mark()
135135
** Create a new (mark,rid,uuid) entry for the given rid in the 'xmark' table,
136136
** and return that information as a struct mark_t in *mark.
137137
** *unused_mark is a value representing a mark that is free for use--that is,
138
-** it does not appear in the marks file, and has not been used during this
139
-** export run. Specifically, it is the supremum of the set of used marks
140
-** plus one.
138
+** it does not appear in the marks file, and has not been used during this
139
+** export run. Specifically, it is the supremum of the set of used marks
140
+** plus one.
141141
** This function returns -1 in the case where 'rid' does not exist, otherwise
142142
** it returns 0.
143143
** mark->name is dynamically allocated and is owned by the caller upon return.
144144
*/
145145
int create_mark(int rid, struct mark_t *mark, unsigned int *unused_mark){
146146
char sid[13];
147147
char *zUuid = rid_to_uuid(rid);
148
- if(!zUuid){
148
+ if( !zUuid ){
149149
fossil_trace("Undefined rid=%d\n", rid);
150150
return -1;
151151
}
152152
mark->rid = rid;
153153
sqlite3_snprintf(sizeof(sid), sid, ":%d", *unused_mark);
@@ -170,13 +170,13 @@
170170
** (i.e. is not valid). Otherwise, it returns the name of the mark, which is
171171
** dynamically allocated and is owned by the caller of this function.
172172
*/
173173
char * mark_name_from_rid(int rid, unsigned int *unused_mark){
174174
char *zMark = db_text(0, "SELECT tname FROM xmark WHERE trid=%d", rid);
175
- if(zMark==NULL){
175
+ if( zMark==NULL ){
176176
struct mark_t mark;
177
- if(create_mark(rid, &mark, unused_mark)==0){
177
+ if( create_mark(rid, &mark, unused_mark)==0 ){
178178
zMark = mark.name;
179179
}else{
180180
return NULL;
181181
}
182182
}
@@ -195,23 +195,23 @@
195195
*/
196196
int parse_mark(char *line, struct mark_t *mark){
197197
char *cur_tok;
198198
char type_;
199199
cur_tok = strtok(line, " \t");
200
- if(!cur_tok||strlen(cur_tok)<2){
200
+ if( !cur_tok || strlen(cur_tok)<2 ){
201201
return -1;
202202
}
203203
mark->rid = atoi(&cur_tok[1]);
204204
type_ = cur_tok[0];
205
- if(type_!='c'&&type_!='b'){
205
+ if( type_!='c' && type_!='b' ){
206206
/* This is probably a blob mark */
207207
mark->name = NULL;
208208
return 0;
209209
}
210210
211211
cur_tok = strtok(NULL, " \t");
212
- if(!cur_tok){
212
+ if( !cur_tok ){
213213
/* This mark was generated by an older version of Fossil and doesn't
214214
** include the mark name and uuid. create_mark() will name the new mark
215215
** exactly as it was when exported to git, so that we should have a
216216
** valid mapping from git sha1<->mark name<->fossil sha1. */
217217
unsigned int mid;
@@ -225,20 +225,20 @@
225225
}else{
226226
mark->name = fossil_strdup(cur_tok);
227227
}
228228
229229
cur_tok = strtok(NULL, "\n");
230
- if(!cur_tok||strlen(cur_tok)!=40){
230
+ if( !cur_tok || strlen(cur_tok)!=40 ){
231231
free(mark->name);
232232
fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok);
233233
return -1;
234234
}else{
235235
sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok);
236236
}
237237
238238
/* make sure that rid corresponds to UUID */
239
- if(fast_uuid_to_rid(mark->uuid)!=mark->rid){
239
+ if( fast_uuid_to_rid(mark->uuid)!=mark->rid ){
240240
free(mark->name);
241241
fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid);
242242
return -1;
243243
}
244244
@@ -264,18 +264,18 @@
264264
*/
265265
int import_marks(FILE* f, Bag *blobs, Bag *vers, unsigned int *unused_mark){
266266
char line[101];
267267
while(fgets(line, sizeof(line), f)){
268268
struct mark_t mark;
269
- if(strlen(line)==100&&line[99]!='\n'){
269
+ if( strlen(line)==100 && line[99]!='\n' ){
270270
/* line too long */
271271
return -1;
272272
}
273273
if( parse_mark(line, &mark)<0 ){
274274
return -1;
275275
}else if( line[0]=='b' ){
276
- if(blobs!=NULL){
276
+ if( blobs!=NULL ){
277277
bag_insert(blobs, mark.rid);
278278
}
279279
}else{
280280
if( vers!=NULL ){
281281
bag_insert(vers, mark.rid);
@@ -295,11 +295,11 @@
295295
void export_mark(FILE* f, int rid, char obj_type)
296296
{
297297
unsigned int z = 0;
298298
char *zUuid = rid_to_uuid(rid);
299299
char *zMark;
300
- if(zUuid==NULL){
300
+ if( zUuid==NULL ){
301301
fossil_trace("No uuid matching rid=%d when exporting marks\n", rid);
302302
return;
303303
}
304304
/* Since rid is already in the 'xmark' table, the value of z won't be
305305
** used, but pass in a valid pointer just to be safe. */
@@ -319,11 +319,11 @@
319319
** be found for an rid in 'vers'.
320320
*/
321321
void export_marks(FILE* f, Bag *blobs, Bag *vers){
322322
int rid;
323323
324
- if( blobs!=NULL ) {
324
+ if( blobs!=NULL ){
325325
rid = bag_first(blobs);
326326
if( rid!=0 ){
327327
do{
328328
export_mark(f, rid, 'b');
329329
}while( (rid = bag_next(blobs, rid))!=0 );
@@ -398,25 +398,25 @@
398398
399399
f = fossil_fopen(markfile_in, "r");
400400
if( f==0 ){
401401
fossil_fatal("cannot open %s for reading", markfile_in);
402402
}
403
- if(import_marks(f, &blobs, &vers, &unused_mark)<0){
403
+ if( import_marks(f, &blobs, &vers, &unused_mark)<0 ){
404404
fossil_fatal("error importing marks from file: %s\n", markfile_in);
405405
}
406406
db_prepare(&qb, "INSERT OR IGNORE INTO oldblob VALUES (:rid)");
407407
db_prepare(&qc, "INSERT OR IGNORE INTO oldcommit VALUES (:rid)");
408408
rid = bag_first(&blobs);
409
- if(rid!=0){
409
+ if( rid!=0 ){
410410
do{
411411
db_bind_int(&qb, ":rid", rid);
412412
db_step(&qb);
413413
db_reset(&qb);
414414
}while((rid = bag_next(&blobs, rid))!=0);
415415
}
416416
rid = bag_first(&vers);
417
- if(rid!=0){
417
+ if( rid!=0 ){
418418
do{
419419
db_bind_int(&qc, ":rid", rid);
420420
db_step(&qc);
421421
db_reset(&qc);
422422
}while((rid = bag_next(&vers, rid))!=0);
@@ -555,13 +555,13 @@
555555
);
556556
while( db_step(&q4)==SQLITE_ROW ){
557557
const char *zName = db_column_text(&q4,0);
558558
int zNew = db_column_int(&q4,1);
559559
int mPerm = db_column_int(&q4,2);
560
- if( zNew==0)
560
+ if( zNew==0 ){
561561
printf("D %s\n", zName);
562
- else if( bag_find(&blobs, zNew) ) {
562
+ }else if( bag_find(&blobs, zNew) ){
563563
zMark = mark_name_from_rid(zNew, &unused_mark);
564564
const char *zPerm;
565565
switch( mPerm ){
566566
case PERM_LNK: zPerm = "120000"; break;
567567
case PERM_EXE: zPerm = "100755"; break;
@@ -611,12 +611,12 @@
611611
f = fossil_fopen(markfile_out, "w");
612612
if( f == 0 ){
613613
fossil_fatal("cannot open %s for writing", markfile_out);
614614
}
615615
export_marks(f, &blobs, &vers);
616
- if( ferror(f)!=0 || fclose(f)!=0 ) {
616
+ if( ferror(f)!=0 || fclose(f)!=0 ){
617617
fossil_fatal("error while writing %s", markfile_out);
618618
}
619619
}
620620
bag_clear(&blobs);
621621
bag_clear(&vers);
622622
}
623623
--- src/export.c
+++ src/export.c
@@ -133,21 +133,21 @@
133 /*
134 ** create_mark()
135 ** Create a new (mark,rid,uuid) entry for the given rid in the 'xmark' table,
136 ** and return that information as a struct mark_t in *mark.
137 ** *unused_mark is a value representing a mark that is free for use--that is,
138 ** it does not appear in the marks file, and has not been used during this
139 ** export run. Specifically, it is the supremum of the set of used marks
140 ** plus one.
141 ** This function returns -1 in the case where 'rid' does not exist, otherwise
142 ** it returns 0.
143 ** mark->name is dynamically allocated and is owned by the caller upon return.
144 */
145 int create_mark(int rid, struct mark_t *mark, unsigned int *unused_mark){
146 char sid[13];
147 char *zUuid = rid_to_uuid(rid);
148 if(!zUuid){
149 fossil_trace("Undefined rid=%d\n", rid);
150 return -1;
151 }
152 mark->rid = rid;
153 sqlite3_snprintf(sizeof(sid), sid, ":%d", *unused_mark);
@@ -170,13 +170,13 @@
170 ** (i.e. is not valid). Otherwise, it returns the name of the mark, which is
171 ** dynamically allocated and is owned by the caller of this function.
172 */
173 char * mark_name_from_rid(int rid, unsigned int *unused_mark){
174 char *zMark = db_text(0, "SELECT tname FROM xmark WHERE trid=%d", rid);
175 if(zMark==NULL){
176 struct mark_t mark;
177 if(create_mark(rid, &mark, unused_mark)==0){
178 zMark = mark.name;
179 }else{
180 return NULL;
181 }
182 }
@@ -195,23 +195,23 @@
195 */
196 int parse_mark(char *line, struct mark_t *mark){
197 char *cur_tok;
198 char type_;
199 cur_tok = strtok(line, " \t");
200 if(!cur_tok||strlen(cur_tok)<2){
201 return -1;
202 }
203 mark->rid = atoi(&cur_tok[1]);
204 type_ = cur_tok[0];
205 if(type_!='c'&&type_!='b'){
206 /* This is probably a blob mark */
207 mark->name = NULL;
208 return 0;
209 }
210
211 cur_tok = strtok(NULL, " \t");
212 if(!cur_tok){
213 /* This mark was generated by an older version of Fossil and doesn't
214 ** include the mark name and uuid. create_mark() will name the new mark
215 ** exactly as it was when exported to git, so that we should have a
216 ** valid mapping from git sha1<->mark name<->fossil sha1. */
217 unsigned int mid;
@@ -225,20 +225,20 @@
225 }else{
226 mark->name = fossil_strdup(cur_tok);
227 }
228
229 cur_tok = strtok(NULL, "\n");
230 if(!cur_tok||strlen(cur_tok)!=40){
231 free(mark->name);
232 fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok);
233 return -1;
234 }else{
235 sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok);
236 }
237
238 /* make sure that rid corresponds to UUID */
239 if(fast_uuid_to_rid(mark->uuid)!=mark->rid){
240 free(mark->name);
241 fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid);
242 return -1;
243 }
244
@@ -264,18 +264,18 @@
264 */
265 int import_marks(FILE* f, Bag *blobs, Bag *vers, unsigned int *unused_mark){
266 char line[101];
267 while(fgets(line, sizeof(line), f)){
268 struct mark_t mark;
269 if(strlen(line)==100&&line[99]!='\n'){
270 /* line too long */
271 return -1;
272 }
273 if( parse_mark(line, &mark)<0 ){
274 return -1;
275 }else if( line[0]=='b' ){
276 if(blobs!=NULL){
277 bag_insert(blobs, mark.rid);
278 }
279 }else{
280 if( vers!=NULL ){
281 bag_insert(vers, mark.rid);
@@ -295,11 +295,11 @@
295 void export_mark(FILE* f, int rid, char obj_type)
296 {
297 unsigned int z = 0;
298 char *zUuid = rid_to_uuid(rid);
299 char *zMark;
300 if(zUuid==NULL){
301 fossil_trace("No uuid matching rid=%d when exporting marks\n", rid);
302 return;
303 }
304 /* Since rid is already in the 'xmark' table, the value of z won't be
305 ** used, but pass in a valid pointer just to be safe. */
@@ -319,11 +319,11 @@
319 ** be found for an rid in 'vers'.
320 */
321 void export_marks(FILE* f, Bag *blobs, Bag *vers){
322 int rid;
323
324 if( blobs!=NULL ) {
325 rid = bag_first(blobs);
326 if( rid!=0 ){
327 do{
328 export_mark(f, rid, 'b');
329 }while( (rid = bag_next(blobs, rid))!=0 );
@@ -398,25 +398,25 @@
398
399 f = fossil_fopen(markfile_in, "r");
400 if( f==0 ){
401 fossil_fatal("cannot open %s for reading", markfile_in);
402 }
403 if(import_marks(f, &blobs, &vers, &unused_mark)<0){
404 fossil_fatal("error importing marks from file: %s\n", markfile_in);
405 }
406 db_prepare(&qb, "INSERT OR IGNORE INTO oldblob VALUES (:rid)");
407 db_prepare(&qc, "INSERT OR IGNORE INTO oldcommit VALUES (:rid)");
408 rid = bag_first(&blobs);
409 if(rid!=0){
410 do{
411 db_bind_int(&qb, ":rid", rid);
412 db_step(&qb);
413 db_reset(&qb);
414 }while((rid = bag_next(&blobs, rid))!=0);
415 }
416 rid = bag_first(&vers);
417 if(rid!=0){
418 do{
419 db_bind_int(&qc, ":rid", rid);
420 db_step(&qc);
421 db_reset(&qc);
422 }while((rid = bag_next(&vers, rid))!=0);
@@ -555,13 +555,13 @@
555 );
556 while( db_step(&q4)==SQLITE_ROW ){
557 const char *zName = db_column_text(&q4,0);
558 int zNew = db_column_int(&q4,1);
559 int mPerm = db_column_int(&q4,2);
560 if( zNew==0)
561 printf("D %s\n", zName);
562 else if( bag_find(&blobs, zNew) ) {
563 zMark = mark_name_from_rid(zNew, &unused_mark);
564 const char *zPerm;
565 switch( mPerm ){
566 case PERM_LNK: zPerm = "120000"; break;
567 case PERM_EXE: zPerm = "100755"; break;
@@ -611,12 +611,12 @@
611 f = fossil_fopen(markfile_out, "w");
612 if( f == 0 ){
613 fossil_fatal("cannot open %s for writing", markfile_out);
614 }
615 export_marks(f, &blobs, &vers);
616 if( ferror(f)!=0 || fclose(f)!=0 ) {
617 fossil_fatal("error while writing %s", markfile_out);
618 }
619 }
620 bag_clear(&blobs);
621 bag_clear(&vers);
622 }
623
--- src/export.c
+++ src/export.c
@@ -133,21 +133,21 @@
133 /*
134 ** create_mark()
135 ** Create a new (mark,rid,uuid) entry for the given rid in the 'xmark' table,
136 ** and return that information as a struct mark_t in *mark.
137 ** *unused_mark is a value representing a mark that is free for use--that is,
138 ** it does not appear in the marks file, and has not been used during this
139 ** export run. Specifically, it is the supremum of the set of used marks
140 ** plus one.
141 ** This function returns -1 in the case where 'rid' does not exist, otherwise
142 ** it returns 0.
143 ** mark->name is dynamically allocated and is owned by the caller upon return.
144 */
145 int create_mark(int rid, struct mark_t *mark, unsigned int *unused_mark){
146 char sid[13];
147 char *zUuid = rid_to_uuid(rid);
148 if( !zUuid ){
149 fossil_trace("Undefined rid=%d\n", rid);
150 return -1;
151 }
152 mark->rid = rid;
153 sqlite3_snprintf(sizeof(sid), sid, ":%d", *unused_mark);
@@ -170,13 +170,13 @@
170 ** (i.e. is not valid). Otherwise, it returns the name of the mark, which is
171 ** dynamically allocated and is owned by the caller of this function.
172 */
173 char * mark_name_from_rid(int rid, unsigned int *unused_mark){
174 char *zMark = db_text(0, "SELECT tname FROM xmark WHERE trid=%d", rid);
175 if( zMark==NULL ){
176 struct mark_t mark;
177 if( create_mark(rid, &mark, unused_mark)==0 ){
178 zMark = mark.name;
179 }else{
180 return NULL;
181 }
182 }
@@ -195,23 +195,23 @@
195 */
196 int parse_mark(char *line, struct mark_t *mark){
197 char *cur_tok;
198 char type_;
199 cur_tok = strtok(line, " \t");
200 if( !cur_tok || strlen(cur_tok)<2 ){
201 return -1;
202 }
203 mark->rid = atoi(&cur_tok[1]);
204 type_ = cur_tok[0];
205 if( type_!='c' && type_!='b' ){
206 /* This is probably a blob mark */
207 mark->name = NULL;
208 return 0;
209 }
210
211 cur_tok = strtok(NULL, " \t");
212 if( !cur_tok ){
213 /* This mark was generated by an older version of Fossil and doesn't
214 ** include the mark name and uuid. create_mark() will name the new mark
215 ** exactly as it was when exported to git, so that we should have a
216 ** valid mapping from git sha1<->mark name<->fossil sha1. */
217 unsigned int mid;
@@ -225,20 +225,20 @@
225 }else{
226 mark->name = fossil_strdup(cur_tok);
227 }
228
229 cur_tok = strtok(NULL, "\n");
230 if( !cur_tok || strlen(cur_tok)!=40 ){
231 free(mark->name);
232 fossil_trace("Invalid SHA-1 in marks file: %s\n", cur_tok);
233 return -1;
234 }else{
235 sqlite3_snprintf(sizeof(mark->uuid), mark->uuid, "%s", cur_tok);
236 }
237
238 /* make sure that rid corresponds to UUID */
239 if( fast_uuid_to_rid(mark->uuid)!=mark->rid ){
240 free(mark->name);
241 fossil_trace("Non-existent SHA-1 in marks file: %s\n", mark->uuid);
242 return -1;
243 }
244
@@ -264,18 +264,18 @@
264 */
265 int import_marks(FILE* f, Bag *blobs, Bag *vers, unsigned int *unused_mark){
266 char line[101];
267 while(fgets(line, sizeof(line), f)){
268 struct mark_t mark;
269 if( strlen(line)==100 && line[99]!='\n' ){
270 /* line too long */
271 return -1;
272 }
273 if( parse_mark(line, &mark)<0 ){
274 return -1;
275 }else if( line[0]=='b' ){
276 if( blobs!=NULL ){
277 bag_insert(blobs, mark.rid);
278 }
279 }else{
280 if( vers!=NULL ){
281 bag_insert(vers, mark.rid);
@@ -295,11 +295,11 @@
295 void export_mark(FILE* f, int rid, char obj_type)
296 {
297 unsigned int z = 0;
298 char *zUuid = rid_to_uuid(rid);
299 char *zMark;
300 if( zUuid==NULL ){
301 fossil_trace("No uuid matching rid=%d when exporting marks\n", rid);
302 return;
303 }
304 /* Since rid is already in the 'xmark' table, the value of z won't be
305 ** used, but pass in a valid pointer just to be safe. */
@@ -319,11 +319,11 @@
319 ** be found for an rid in 'vers'.
320 */
321 void export_marks(FILE* f, Bag *blobs, Bag *vers){
322 int rid;
323
324 if( blobs!=NULL ){
325 rid = bag_first(blobs);
326 if( rid!=0 ){
327 do{
328 export_mark(f, rid, 'b');
329 }while( (rid = bag_next(blobs, rid))!=0 );
@@ -398,25 +398,25 @@
398
399 f = fossil_fopen(markfile_in, "r");
400 if( f==0 ){
401 fossil_fatal("cannot open %s for reading", markfile_in);
402 }
403 if( import_marks(f, &blobs, &vers, &unused_mark)<0 ){
404 fossil_fatal("error importing marks from file: %s\n", markfile_in);
405 }
406 db_prepare(&qb, "INSERT OR IGNORE INTO oldblob VALUES (:rid)");
407 db_prepare(&qc, "INSERT OR IGNORE INTO oldcommit VALUES (:rid)");
408 rid = bag_first(&blobs);
409 if( rid!=0 ){
410 do{
411 db_bind_int(&qb, ":rid", rid);
412 db_step(&qb);
413 db_reset(&qb);
414 }while((rid = bag_next(&blobs, rid))!=0);
415 }
416 rid = bag_first(&vers);
417 if( rid!=0 ){
418 do{
419 db_bind_int(&qc, ":rid", rid);
420 db_step(&qc);
421 db_reset(&qc);
422 }while((rid = bag_next(&vers, rid))!=0);
@@ -555,13 +555,13 @@
555 );
556 while( db_step(&q4)==SQLITE_ROW ){
557 const char *zName = db_column_text(&q4,0);
558 int zNew = db_column_int(&q4,1);
559 int mPerm = db_column_int(&q4,2);
560 if( zNew==0 ){
561 printf("D %s\n", zName);
562 }else if( bag_find(&blobs, zNew) ){
563 zMark = mark_name_from_rid(zNew, &unused_mark);
564 const char *zPerm;
565 switch( mPerm ){
566 case PERM_LNK: zPerm = "120000"; break;
567 case PERM_EXE: zPerm = "100755"; break;
@@ -611,12 +611,12 @@
611 f = fossil_fopen(markfile_out, "w");
612 if( f == 0 ){
613 fossil_fatal("cannot open %s for writing", markfile_out);
614 }
615 export_marks(f, &blobs, &vers);
616 if( ferror(f)!=0 || fclose(f)!=0 ){
617 fossil_fatal("error while writing %s", markfile_out);
618 }
619 }
620 bag_clear(&blobs);
621 bag_clear(&vers);
622 }
623
+1 -1
--- src/import.c
+++ src/import.c
@@ -1770,11 +1770,11 @@
17701770
if( markfile_in ){
17711771
FILE *f = fossil_fopen(markfile_in, "r");
17721772
if( !f ){
17731773
fossil_fatal("cannot open %s for reading\n", markfile_in);
17741774
}
1775
- if(import_marks(f, &blobs, NULL, NULL)<0){
1775
+ if( import_marks(f, &blobs, NULL, NULL)<0 ){
17761776
fossil_fatal("error importing marks from file: %s\n", markfile_in);
17771777
}
17781778
fclose(f);
17791779
}
17801780
17811781
--- src/import.c
+++ src/import.c
@@ -1770,11 +1770,11 @@
1770 if( markfile_in ){
1771 FILE *f = fossil_fopen(markfile_in, "r");
1772 if( !f ){
1773 fossil_fatal("cannot open %s for reading\n", markfile_in);
1774 }
1775 if(import_marks(f, &blobs, NULL, NULL)<0){
1776 fossil_fatal("error importing marks from file: %s\n", markfile_in);
1777 }
1778 fclose(f);
1779 }
1780
1781
--- src/import.c
+++ src/import.c
@@ -1770,11 +1770,11 @@
1770 if( markfile_in ){
1771 FILE *f = fossil_fopen(markfile_in, "r");
1772 if( !f ){
1773 fossil_fatal("cannot open %s for reading\n", markfile_in);
1774 }
1775 if( import_marks(f, &blobs, NULL, NULL)<0 ){
1776 fossil_fatal("error importing marks from file: %s\n", markfile_in);
1777 }
1778 fclose(f);
1779 }
1780
1781

Keyboard Shortcuts

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