Fossil SCM

Coding style and compiler warning fixes.

mistachkin 2015-08-15 18:37 ckol-th1-dir-cmd
Commit 4b17cb66e852d2992ba175f21965ca03a1c17386
1 file changed +13 -28
+13 -28
--- src/th_main.c
+++ src/th_main.c
@@ -143,90 +143,75 @@
143143
fossil_print("%s", blob_str(&g.thLog));
144144
fossil_print("\n------------------- END TRACE LOG -------------------\n");
145145
}
146146
}
147147
148
-
149148
/*
150
-** - adopted from ls_cmd_rev in checkin.c
149
+** - adopted from ls_cmd_rev in checkin.c
151150
** - adopted commands/error handling for usage within th1
152151
** - interface adopted to allow result creation as TH1 List
153152
**
154153
** Takes a checkin identifier in zRev and an optiona glob pattern in zGLOB
155154
** as parameter returns a TH list in pzList,pnList with filenames matching
156155
** glob pattern with the checking
157156
*/
158157
static void dir_cmd_rev(
159158
Th_Interp *interp,
160
- char** pzList,
161
- int* pnList,
162
- const char *zRev, /* Revision string given */
163
- const char* zGlob /* */
159
+ char **pzList,
160
+ int *pnList,
161
+ const char *zRev, /* Revision string given */
162
+ const char *zGlob /* Glob pattern given */
164163
){
165164
Stmt q;
166165
char *zOrderBy = "pathname COLLATE nocase";
167
- char *zName;
168166
int rid;
169
- int i;
170167
171168
rid = th1_name_to_typed_rid(interp, zRev, "ci");
172
-
173169
compute_fileage(rid, zGlob);
174170
db_prepare(&q,
175171
"SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n"
176172
" blob.size\n"
177173
" FROM fileage, blob\n"
178174
" WHERE blob.rid=fileage.fid \n"
179175
" ORDER BY %s;", zOrderBy /*safe-for-%s*/
180176
);
181
-
182177
while( db_step(&q)==SQLITE_ROW ){
183
- const char *zTime = db_column_text(&q,0);
184
- const char *zFile = db_column_text(&q,1);
185
- int size = db_column_int(&q,2);
186
-
178
+ const char *zFile = db_column_text(&q, 1);
187179
Th_ListAppend(interp, pzList, pnList, zFile, -1);
188
- //fossil_print("%s\n", zFile);
189180
}
190181
db_finalize(&q);
191182
}
192183
193184
/*
194185
** TH1 command: dir CHECKIN ?GLOB?
195186
**
196
-** Returns a list containing all files in CHECKIN. If GLOB is given
197
-** only the files matching the pattern GLOB within CHECKIN will be returned.
187
+** Returns a list containing all files in CHECKIN. If GLOB is given only
188
+** the files matching the pattern GLOB within CHECKIN will be returned.
198189
*/
199190
static int dirCmd(
200191
Th_Interp *interp,
201192
void *ctx,
202193
int argc,
203194
const char **argv,
204195
int *argl
205196
){
206197
const char *zGlob = 0;
207
- char *zList = 0;
208
- int nList = 0;
209
- int i;
210198
211
- if( argc!=2 && argc != 3){
199
+ if( argc!=2 && argc!=3 ){
212200
return Th_WrongNumArgs(interp, "dir CHECKIN ?GLOB?");
213201
}
214
-
215
- if( argc == 3){
202
+ if( argc==3 ){
216203
zGlob = argv[2];
217204
}
218
-
219205
if( Th_IsRepositoryOpen() ){
206
+ char *zList = 0;
207
+ int nList = 0;
220208
dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob);
221
-
222209
Th_SetResult(interp, zList, nList);
223210
Th_Free(interp, zList);
224
-
225211
return TH_OK;
226
-
227
- } else {
212
+ }else{
228213
Th_SetResult(interp, "repository unavailable", -1);
229214
return TH_ERROR;
230215
}
231216
}
232217
233218
--- src/th_main.c
+++ src/th_main.c
@@ -143,90 +143,75 @@
143 fossil_print("%s", blob_str(&g.thLog));
144 fossil_print("\n------------------- END TRACE LOG -------------------\n");
145 }
146 }
147
148
149 /*
150 ** - adopted from ls_cmd_rev in checkin.c
151 ** - adopted commands/error handling for usage within th1
152 ** - interface adopted to allow result creation as TH1 List
153 **
154 ** Takes a checkin identifier in zRev and an optiona glob pattern in zGLOB
155 ** as parameter returns a TH list in pzList,pnList with filenames matching
156 ** glob pattern with the checking
157 */
158 static void dir_cmd_rev(
159 Th_Interp *interp,
160 char** pzList,
161 int* pnList,
162 const char *zRev, /* Revision string given */
163 const char* zGlob /* */
164 ){
165 Stmt q;
166 char *zOrderBy = "pathname COLLATE nocase";
167 char *zName;
168 int rid;
169 int i;
170
171 rid = th1_name_to_typed_rid(interp, zRev, "ci");
172
173 compute_fileage(rid, zGlob);
174 db_prepare(&q,
175 "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n"
176 " blob.size\n"
177 " FROM fileage, blob\n"
178 " WHERE blob.rid=fileage.fid \n"
179 " ORDER BY %s;", zOrderBy /*safe-for-%s*/
180 );
181
182 while( db_step(&q)==SQLITE_ROW ){
183 const char *zTime = db_column_text(&q,0);
184 const char *zFile = db_column_text(&q,1);
185 int size = db_column_int(&q,2);
186
187 Th_ListAppend(interp, pzList, pnList, zFile, -1);
188 //fossil_print("%s\n", zFile);
189 }
190 db_finalize(&q);
191 }
192
193 /*
194 ** TH1 command: dir CHECKIN ?GLOB?
195 **
196 ** Returns a list containing all files in CHECKIN. If GLOB is given
197 ** only the files matching the pattern GLOB within CHECKIN will be returned.
198 */
199 static int dirCmd(
200 Th_Interp *interp,
201 void *ctx,
202 int argc,
203 const char **argv,
204 int *argl
205 ){
206 const char *zGlob = 0;
207 char *zList = 0;
208 int nList = 0;
209 int i;
210
211 if( argc!=2 && argc != 3){
212 return Th_WrongNumArgs(interp, "dir CHECKIN ?GLOB?");
213 }
214
215 if( argc == 3){
216 zGlob = argv[2];
217 }
218
219 if( Th_IsRepositoryOpen() ){
 
 
220 dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob);
221
222 Th_SetResult(interp, zList, nList);
223 Th_Free(interp, zList);
224
225 return TH_OK;
226
227 } else {
228 Th_SetResult(interp, "repository unavailable", -1);
229 return TH_ERROR;
230 }
231 }
232
233
--- src/th_main.c
+++ src/th_main.c
@@ -143,90 +143,75 @@
143 fossil_print("%s", blob_str(&g.thLog));
144 fossil_print("\n------------------- END TRACE LOG -------------------\n");
145 }
146 }
147
 
148 /*
149 ** - adopted from ls_cmd_rev in checkin.c
150 ** - adopted commands/error handling for usage within th1
151 ** - interface adopted to allow result creation as TH1 List
152 **
153 ** Takes a checkin identifier in zRev and an optiona glob pattern in zGLOB
154 ** as parameter returns a TH list in pzList,pnList with filenames matching
155 ** glob pattern with the checking
156 */
157 static void dir_cmd_rev(
158 Th_Interp *interp,
159 char **pzList,
160 int *pnList,
161 const char *zRev, /* Revision string given */
162 const char *zGlob /* Glob pattern given */
163 ){
164 Stmt q;
165 char *zOrderBy = "pathname COLLATE nocase";
 
166 int rid;
 
167
168 rid = th1_name_to_typed_rid(interp, zRev, "ci");
 
169 compute_fileage(rid, zGlob);
170 db_prepare(&q,
171 "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n"
172 " blob.size\n"
173 " FROM fileage, blob\n"
174 " WHERE blob.rid=fileage.fid \n"
175 " ORDER BY %s;", zOrderBy /*safe-for-%s*/
176 );
 
177 while( db_step(&q)==SQLITE_ROW ){
178 const char *zFile = db_column_text(&q, 1);
 
 
 
179 Th_ListAppend(interp, pzList, pnList, zFile, -1);
 
180 }
181 db_finalize(&q);
182 }
183
184 /*
185 ** TH1 command: dir CHECKIN ?GLOB?
186 **
187 ** Returns a list containing all files in CHECKIN. If GLOB is given only
188 ** the files matching the pattern GLOB within CHECKIN will be returned.
189 */
190 static int dirCmd(
191 Th_Interp *interp,
192 void *ctx,
193 int argc,
194 const char **argv,
195 int *argl
196 ){
197 const char *zGlob = 0;
 
 
 
198
199 if( argc!=2 && argc!=3 ){
200 return Th_WrongNumArgs(interp, "dir CHECKIN ?GLOB?");
201 }
202 if( argc==3 ){
 
203 zGlob = argv[2];
204 }
 
205 if( Th_IsRepositoryOpen() ){
206 char *zList = 0;
207 int nList = 0;
208 dir_cmd_rev(interp, &zList, &nList, argv[1], zGlob);
 
209 Th_SetResult(interp, zList, nList);
210 Th_Free(interp, zList);
 
211 return TH_OK;
212 }else{
 
213 Th_SetResult(interp, "repository unavailable", -1);
214 return TH_ERROR;
215 }
216 }
217
218

Keyboard Shortcuts

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