Fossil SCM

Use file_access(..., F_OK) in stead of file_access(zFullName, 0) everywhere, in case some platforms exist where F_OK != 0. Remove a few end-of-line spaces.

jan.nijtmans 2014-04-28 10:26 trunk
Commit 9df71fe36c00214e2602dbbd251fe2c8551cc538
+3 -3
--- src/allrepo.c
+++ src/allrepo.c
@@ -155,11 +155,11 @@
155155
int dryRunFlag = 0;
156156
int showFile = find_option("showfile",0,0)!=0;
157157
int stopOnError = find_option("dontstop",0,0)==0;
158158
int rc;
159159
int nToDel = 0;
160
-
160
+
161161
dryRunFlag = find_option("dry-run","n",0)!=0;
162162
if( !dryRunFlag ){
163163
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
164164
}
165165
@@ -282,11 +282,11 @@
282282
);
283283
}
284284
db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
285285
while( db_step(&q)==SQLITE_ROW ){
286286
const char *zFilename = db_column_text(&q, 0);
287
- if( file_access(zFilename, 0)
287
+ if( file_access(zFilename, F_OK)
288288
|| !file_is_canonical(zFilename)
289289
|| (useCheckouts && file_isdir(zFilename)!=1)
290290
){
291291
db_multi_exec("INSERT INTO todel VALUES(%Q)", db_column_text(&q, 1));
292292
nToDel++;
@@ -312,11 +312,11 @@
312312
if( stopOnError && rc ){
313313
break;
314314
}
315315
}
316316
db_finalize(&q);
317
-
317
+
318318
/* If any repositories whose names appear in the ~/.fossil file could not
319319
** be found, remove those names from the ~/.fossil file.
320320
*/
321321
if( nToDel>0 ){
322322
const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
323323
--- src/allrepo.c
+++ src/allrepo.c
@@ -155,11 +155,11 @@
155 int dryRunFlag = 0;
156 int showFile = find_option("showfile",0,0)!=0;
157 int stopOnError = find_option("dontstop",0,0)==0;
158 int rc;
159 int nToDel = 0;
160
161 dryRunFlag = find_option("dry-run","n",0)!=0;
162 if( !dryRunFlag ){
163 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
164 }
165
@@ -282,11 +282,11 @@
282 );
283 }
284 db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
285 while( db_step(&q)==SQLITE_ROW ){
286 const char *zFilename = db_column_text(&q, 0);
287 if( file_access(zFilename, 0)
288 || !file_is_canonical(zFilename)
289 || (useCheckouts && file_isdir(zFilename)!=1)
290 ){
291 db_multi_exec("INSERT INTO todel VALUES(%Q)", db_column_text(&q, 1));
292 nToDel++;
@@ -312,11 +312,11 @@
312 if( stopOnError && rc ){
313 break;
314 }
315 }
316 db_finalize(&q);
317
318 /* If any repositories whose names appear in the ~/.fossil file could not
319 ** be found, remove those names from the ~/.fossil file.
320 */
321 if( nToDel>0 ){
322 const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
323
--- src/allrepo.c
+++ src/allrepo.c
@@ -155,11 +155,11 @@
155 int dryRunFlag = 0;
156 int showFile = find_option("showfile",0,0)!=0;
157 int stopOnError = find_option("dontstop",0,0)==0;
158 int rc;
159 int nToDel = 0;
160
161 dryRunFlag = find_option("dry-run","n",0)!=0;
162 if( !dryRunFlag ){
163 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
164 }
165
@@ -282,11 +282,11 @@
282 );
283 }
284 db_multi_exec("CREATE TEMP TABLE todel(x TEXT)");
285 while( db_step(&q)==SQLITE_ROW ){
286 const char *zFilename = db_column_text(&q, 0);
287 if( file_access(zFilename, F_OK)
288 || !file_is_canonical(zFilename)
289 || (useCheckouts && file_isdir(zFilename)!=1)
290 ){
291 db_multi_exec("INSERT INTO todel VALUES(%Q)", db_column_text(&q, 1));
292 nToDel++;
@@ -312,11 +312,11 @@
312 if( stopOnError && rc ){
313 break;
314 }
315 }
316 db_finalize(&q);
317
318 /* If any repositories whose names appear in the ~/.fossil file could not
319 ** be found, remove those names from the ~/.fossil file.
320 */
321 if( nToDel>0 ){
322 const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
323
+2 -2
--- src/checkin.c
+++ src/checkin.c
@@ -86,11 +86,11 @@
8686
}
8787
blob_append(report, zPrefix, nPrefix);
8888
if( isDeleted ){
8989
blob_appendf(report, "DELETED %s\n", zDisplayName);
9090
}else if( !file_wd_isfile_or_link(zFullName) ){
91
- if( file_access(zFullName, 0)==0 ){
91
+ if( file_access(zFullName, F_OK)==0 ){
9292
blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName);
9393
if( missingIsFatal ){
9494
fossil_warning("not a file: %s", zDisplayName);
9595
nErr++;
9696
}
@@ -327,11 +327,11 @@
327327
if( isNew ){
328328
type = "ADDED ";
329329
}else if( isDeleted ){
330330
type = "DELETED ";
331331
}else if( !file_wd_isfile_or_link(zFullName) ){
332
- if( file_access(zFullName, 0)==0 ){
332
+ if( file_access(zFullName, F_OK)==0 ){
333333
type = "NOT_A_FILE ";
334334
}else{
335335
type = "MISSING ";
336336
}
337337
}else if( chnged ){
338338
--- src/checkin.c
+++ src/checkin.c
@@ -86,11 +86,11 @@
86 }
87 blob_append(report, zPrefix, nPrefix);
88 if( isDeleted ){
89 blob_appendf(report, "DELETED %s\n", zDisplayName);
90 }else if( !file_wd_isfile_or_link(zFullName) ){
91 if( file_access(zFullName, 0)==0 ){
92 blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName);
93 if( missingIsFatal ){
94 fossil_warning("not a file: %s", zDisplayName);
95 nErr++;
96 }
@@ -327,11 +327,11 @@
327 if( isNew ){
328 type = "ADDED ";
329 }else if( isDeleted ){
330 type = "DELETED ";
331 }else if( !file_wd_isfile_or_link(zFullName) ){
332 if( file_access(zFullName, 0)==0 ){
333 type = "NOT_A_FILE ";
334 }else{
335 type = "MISSING ";
336 }
337 }else if( chnged ){
338
--- src/checkin.c
+++ src/checkin.c
@@ -86,11 +86,11 @@
86 }
87 blob_append(report, zPrefix, nPrefix);
88 if( isDeleted ){
89 blob_appendf(report, "DELETED %s\n", zDisplayName);
90 }else if( !file_wd_isfile_or_link(zFullName) ){
91 if( file_access(zFullName, F_OK)==0 ){
92 blob_appendf(report, "NOT_A_FILE %s\n", zDisplayName);
93 if( missingIsFatal ){
94 fossil_warning("not a file: %s", zDisplayName);
95 nErr++;
96 }
@@ -327,11 +327,11 @@
327 if( isNew ){
328 type = "ADDED ";
329 }else if( isDeleted ){
330 type = "DELETED ";
331 }else if( !file_wd_isfile_or_link(zFullName) ){
332 if( file_access(zFullName, F_OK)==0 ){
333 type = "NOT_A_FILE ";
334 }else{
335 type = "MISSING ";
336 }
337 }else if( chnged ){
338
+3 -3
--- src/db.c
+++ src/db.c
@@ -1004,11 +1004,11 @@
10041004
if( zDbName==0 ){
10051005
db_err("unable to find the name of a repository database");
10061006
}
10071007
}
10081008
if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
1009
- if( file_access(zDbName, 0) ){
1009
+ if( file_access(zDbName, F_OK) ){
10101010
#ifdef FOSSIL_ENABLE_JSON
10111011
g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
10121012
#endif
10131013
fossil_panic("repository does not exist or"
10141014
" is in an unreadable directory: %s", zDbName);
@@ -1138,11 +1138,11 @@
11381138
if( g.argc!=3 ){
11391139
usage("PATHNAME");
11401140
}
11411141
file_canonical_name(g.argv[2], &repo, 0);
11421142
zRepo = blob_str(&repo);
1143
- if( file_access(zRepo, 0) ){
1143
+ if( file_access(zRepo, F_OK) ){
11441144
fossil_fatal("no such file: %s", zRepo);
11451145
}
11461146
if( db_open_local(zRepo)==0 ){
11471147
fossil_fatal("not in a local checkout");
11481148
return;
@@ -2513,11 +2513,11 @@
25132513
zOrigSql += j+6;
25142514
j = -1;
25152515
}
25162516
}
25172517
blob_append(&newSql, zOrigSql, -1);
2518
- blob_appendf(&allSql,
2518
+ blob_appendf(&allSql,
25192519
"ALTER TABLE %s RENAME TO x_%s;\n"
25202520
"%s WITHOUT ROWID;\n"
25212521
"INSERT INTO %s SELECT * FROM x_%s;\n"
25222522
"DROP TABLE x_%s;\n",
25232523
zTName, zTName, blob_str(&newSql), zTName, zTName, zTName
25242524
--- src/db.c
+++ src/db.c
@@ -1004,11 +1004,11 @@
1004 if( zDbName==0 ){
1005 db_err("unable to find the name of a repository database");
1006 }
1007 }
1008 if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
1009 if( file_access(zDbName, 0) ){
1010 #ifdef FOSSIL_ENABLE_JSON
1011 g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
1012 #endif
1013 fossil_panic("repository does not exist or"
1014 " is in an unreadable directory: %s", zDbName);
@@ -1138,11 +1138,11 @@
1138 if( g.argc!=3 ){
1139 usage("PATHNAME");
1140 }
1141 file_canonical_name(g.argv[2], &repo, 0);
1142 zRepo = blob_str(&repo);
1143 if( file_access(zRepo, 0) ){
1144 fossil_fatal("no such file: %s", zRepo);
1145 }
1146 if( db_open_local(zRepo)==0 ){
1147 fossil_fatal("not in a local checkout");
1148 return;
@@ -2513,11 +2513,11 @@
2513 zOrigSql += j+6;
2514 j = -1;
2515 }
2516 }
2517 blob_append(&newSql, zOrigSql, -1);
2518 blob_appendf(&allSql,
2519 "ALTER TABLE %s RENAME TO x_%s;\n"
2520 "%s WITHOUT ROWID;\n"
2521 "INSERT INTO %s SELECT * FROM x_%s;\n"
2522 "DROP TABLE x_%s;\n",
2523 zTName, zTName, blob_str(&newSql), zTName, zTName, zTName
2524
--- src/db.c
+++ src/db.c
@@ -1004,11 +1004,11 @@
1004 if( zDbName==0 ){
1005 db_err("unable to find the name of a repository database");
1006 }
1007 }
1008 if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
1009 if( file_access(zDbName, F_OK) ){
1010 #ifdef FOSSIL_ENABLE_JSON
1011 g.json.resultCode = FSL_JSON_E_DB_NOT_FOUND;
1012 #endif
1013 fossil_panic("repository does not exist or"
1014 " is in an unreadable directory: %s", zDbName);
@@ -1138,11 +1138,11 @@
1138 if( g.argc!=3 ){
1139 usage("PATHNAME");
1140 }
1141 file_canonical_name(g.argv[2], &repo, 0);
1142 zRepo = blob_str(&repo);
1143 if( file_access(zRepo, F_OK) ){
1144 fossil_fatal("no such file: %s", zRepo);
1145 }
1146 if( db_open_local(zRepo)==0 ){
1147 fossil_fatal("not in a local checkout");
1148 return;
@@ -2513,11 +2513,11 @@
2513 zOrigSql += j+6;
2514 j = -1;
2515 }
2516 }
2517 blob_append(&newSql, zOrigSql, -1);
2518 blob_appendf(&allSql,
2519 "ALTER TABLE %s RENAME TO x_%s;\n"
2520 "%s WITHOUT ROWID;\n"
2521 "INSERT INTO %s SELECT * FROM x_%s;\n"
2522 "DROP TABLE x_%s;\n",
2523 zTName, zTName, blob_str(&newSql), zTName, zTName, zTName
2524
+2 -2
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -171,11 +171,11 @@
171171
** zFile2 */
172172
blob_zero(&nameFile1);
173173
do{
174174
blob_reset(&nameFile1);
175175
blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
176
- }while( file_access(blob_str(&nameFile1),0)==0 );
176
+ }while( file_access(blob_str(&nameFile1),F_OK)==0 );
177177
blob_write_to_file(pFile1, blob_str(&nameFile1));
178178
179179
/* Construct the external diff command */
180180
blob_zero(&cmd);
181181
blob_appendf(&cmd, "%s ", zDiffCmd);
@@ -385,11 +385,11 @@
385385
char *zToFree = zFullName;
386386
int showDiff = 1;
387387
if( isDeleted ){
388388
fossil_print("DELETED %s\n", zPathname);
389389
if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
390
- }else if( file_access(zFullName, 0) ){
390
+ }else if( file_access(zFullName, F_OK) ){
391391
fossil_print("MISSING %s\n", zPathname);
392392
if( !asNewFile ){ showDiff = 0; }
393393
}else if( isNew ){
394394
fossil_print("ADDED %s\n", zPathname);
395395
srcid = 0;
396396
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -171,11 +171,11 @@
171 ** zFile2 */
172 blob_zero(&nameFile1);
173 do{
174 blob_reset(&nameFile1);
175 blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
176 }while( file_access(blob_str(&nameFile1),0)==0 );
177 blob_write_to_file(pFile1, blob_str(&nameFile1));
178
179 /* Construct the external diff command */
180 blob_zero(&cmd);
181 blob_appendf(&cmd, "%s ", zDiffCmd);
@@ -385,11 +385,11 @@
385 char *zToFree = zFullName;
386 int showDiff = 1;
387 if( isDeleted ){
388 fossil_print("DELETED %s\n", zPathname);
389 if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
390 }else if( file_access(zFullName, 0) ){
391 fossil_print("MISSING %s\n", zPathname);
392 if( !asNewFile ){ showDiff = 0; }
393 }else if( isNew ){
394 fossil_print("ADDED %s\n", zPathname);
395 srcid = 0;
396
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -171,11 +171,11 @@
171 ** zFile2 */
172 blob_zero(&nameFile1);
173 do{
174 blob_reset(&nameFile1);
175 blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
176 }while( file_access(blob_str(&nameFile1),F_OK)==0 );
177 blob_write_to_file(pFile1, blob_str(&nameFile1));
178
179 /* Construct the external diff command */
180 blob_zero(&cmd);
181 blob_appendf(&cmd, "%s ", zDiffCmd);
@@ -385,11 +385,11 @@
385 char *zToFree = zFullName;
386 int showDiff = 1;
387 if( isDeleted ){
388 fossil_print("DELETED %s\n", zPathname);
389 if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
390 }else if( file_access(zFullName, F_OK) ){
391 fossil_print("MISSING %s\n", zPathname);
392 if( !asNewFile ){ showDiff = 0; }
393 }else if( isNew ){
394 fossil_print("ADDED %s\n", zPathname);
395 srcid = 0;
396
--- src/json_status.c
+++ src/json_status.c
@@ -69,11 +69,11 @@
6969
zTmp = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
7070
cson_object_set(tmpO, "uuid", json_new_string(zTmp) );
7171
free(zTmp);
7272
7373
cson_object_set( tmpO, "tags", json_tags_for_checkin_rid(vid, 0) );
74
-
74
+
7575
/* FIXME: optimize the datetime/timestamp queries into 1 query. */
7676
zTmp = db_text(0, "SELECT datetime(mtime) || "
7777
"' UTC' FROM event WHERE objid=%d",
7878
vid);
7979
cson_object_set(tmpO, "datetime", json_new_string(zTmp));
@@ -115,11 +115,11 @@
115115
zStatus = "new" /* maintenance reminder: MUST come
116116
BEFORE the isChnged checks. */;
117117
}else if( isRenamed ){
118118
zStatus = "renamed";
119119
}else if( !file_wd_isfile_or_link(zFullName) ){
120
- if( file_access(zFullName, 0)==0 ){
120
+ if( file_access(zFullName, F_OK)==0 ){
121121
zStatus = "notAFile";
122122
++nErr;
123123
}else{
124124
zStatus = "missing";
125125
++nErr;
@@ -137,11 +137,11 @@
137137
zStatus = "conflict";
138138
}else{
139139
zStatus = "edited";
140140
}
141141
}
142
-
142
+
143143
oFile = cson_new_object();
144144
cson_array_append( aFiles, cson_object_value(oFile) );
145145
/* optimization potential: move these keys into cson_strings
146146
to take advantage of refcounting. */
147147
cson_object_set( oFile, "name", json_new_string( zPathname ) );
148148
--- src/json_status.c
+++ src/json_status.c
@@ -69,11 +69,11 @@
69 zTmp = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
70 cson_object_set(tmpO, "uuid", json_new_string(zTmp) );
71 free(zTmp);
72
73 cson_object_set( tmpO, "tags", json_tags_for_checkin_rid(vid, 0) );
74
75 /* FIXME: optimize the datetime/timestamp queries into 1 query. */
76 zTmp = db_text(0, "SELECT datetime(mtime) || "
77 "' UTC' FROM event WHERE objid=%d",
78 vid);
79 cson_object_set(tmpO, "datetime", json_new_string(zTmp));
@@ -115,11 +115,11 @@
115 zStatus = "new" /* maintenance reminder: MUST come
116 BEFORE the isChnged checks. */;
117 }else if( isRenamed ){
118 zStatus = "renamed";
119 }else if( !file_wd_isfile_or_link(zFullName) ){
120 if( file_access(zFullName, 0)==0 ){
121 zStatus = "notAFile";
122 ++nErr;
123 }else{
124 zStatus = "missing";
125 ++nErr;
@@ -137,11 +137,11 @@
137 zStatus = "conflict";
138 }else{
139 zStatus = "edited";
140 }
141 }
142
143 oFile = cson_new_object();
144 cson_array_append( aFiles, cson_object_value(oFile) );
145 /* optimization potential: move these keys into cson_strings
146 to take advantage of refcounting. */
147 cson_object_set( oFile, "name", json_new_string( zPathname ) );
148
--- src/json_status.c
+++ src/json_status.c
@@ -69,11 +69,11 @@
69 zTmp = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
70 cson_object_set(tmpO, "uuid", json_new_string(zTmp) );
71 free(zTmp);
72
73 cson_object_set( tmpO, "tags", json_tags_for_checkin_rid(vid, 0) );
74
75 /* FIXME: optimize the datetime/timestamp queries into 1 query. */
76 zTmp = db_text(0, "SELECT datetime(mtime) || "
77 "' UTC' FROM event WHERE objid=%d",
78 vid);
79 cson_object_set(tmpO, "datetime", json_new_string(zTmp));
@@ -115,11 +115,11 @@
115 zStatus = "new" /* maintenance reminder: MUST come
116 BEFORE the isChnged checks. */;
117 }else if( isRenamed ){
118 zStatus = "renamed";
119 }else if( !file_wd_isfile_or_link(zFullName) ){
120 if( file_access(zFullName, F_OK)==0 ){
121 zStatus = "notAFile";
122 ++nErr;
123 }else{
124 zStatus = "missing";
125 ++nErr;
@@ -137,11 +137,11 @@
137 zStatus = "conflict";
138 }else{
139 zStatus = "edited";
140 }
141 }
142
143 oFile = cson_new_object();
144 cson_array_append( aFiles, cson_object_value(oFile) );
145 /* optimization potential: move these keys into cson_strings
146 to take advantage of refcounting. */
147 cson_object_set( oFile, "name", json_new_string( zPathname ) );
148

Keyboard Shortcuts

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